You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2012/08/20 13:46:47 UTC
svn commit: r1374979 [18/29] - in /incubator/ooo/branches/writer001: ./
ext_libraries/apr-util/ ext_libraries/apr-util/prj/ ext_libraries/apr/
ext_libraries/coinmp/ ext_libraries/hunspell/ ext_libraries/serf/
ext_libraries/serf/prj/ ext_sources/ extras...
Modified: incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.cxx?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.cxx (original)
+++ incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.cxx Mon Aug 20 11:46:19 2012
@@ -210,13 +210,13 @@ void SVGAttributeWriter::AddGradientDef(
Rectangle aRect( aPoly.GetBoundRect() );
// adjust start/end colors with intensities
- aStartColor.SetRed( (sal_uInt8)( (long) aStartColor.GetRed() * rGradient.GetStartIntensity() ) / 100 );
- aStartColor.SetGreen( (sal_uInt8)( (long) aStartColor.GetGreen() * rGradient.GetStartIntensity() ) / 100 );
- aStartColor.SetBlue( (sal_uInt8)( (long) aStartColor.GetBlue() * rGradient.GetStartIntensity() ) / 100 );
+ aStartColor.SetRed( (sal_uInt8)( ( (long) aStartColor.GetRed() * rGradient.GetStartIntensity() ) / 100 ) );
+ aStartColor.SetGreen( (sal_uInt8)( ( (long) aStartColor.GetGreen() * rGradient.GetStartIntensity() ) / 100 ) );
+ aStartColor.SetBlue( (sal_uInt8)( ( (long) aStartColor.GetBlue() * rGradient.GetStartIntensity() ) / 100 ) );
- aEndColor.SetRed( (sal_uInt8)( (long) aEndColor.GetRed() * rGradient.GetEndIntensity() ) / 100 );
- aEndColor.SetGreen( (sal_uInt8)( (long) aEndColor.GetGreen() * rGradient.GetEndIntensity() ) / 100 );
- aEndColor.SetBlue( (sal_uInt8)( (long) aEndColor.GetBlue() * rGradient.GetEndIntensity() ) / 100 );
+ aEndColor.SetRed( (sal_uInt8)( ( (long) aEndColor.GetRed() * rGradient.GetEndIntensity() ) / 100 ) );
+ aEndColor.SetGreen( (sal_uInt8)( ( (long) aEndColor.GetGreen() * rGradient.GetEndIntensity() ) / 100 ) );
+ aEndColor.SetBlue( (sal_uInt8)( ( (long) aEndColor.GetBlue() * rGradient.GetEndIntensity() ) / 100 ) );
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId,
( rGradientId = B2UCONST( "Gradient_" ) ) += ::rtl::OUString::valueOf( nCurGradientId++ ) );
@@ -853,57 +853,95 @@ void SVGActionWriter::ImplWriteText( con
if( nLen > 1 )
{
- aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( nLen - 1 ) );
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( ::vcl::unohelper::CreateBreakIterator() );
+ const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale();
+ sal_Int32 nCurPos = 0, nLastPos = 0, nX = aPos.X();
- if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) )
- {
- const double fFactor = (double) nWidth / aNormSize.Width();
+ if ( mrExport.IsUseTSpans() )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
+ {
+ rtl::OUString aString;
+ for( sal_Bool bCont = sal_True; bCont; )
+ {
+ sal_Int32 nCount = 1;
+ const ::rtl::OUString aSpace( ' ' );
- for( i = 0; i < ( nLen - 1 ); i++ )
- pDX[ i ] = FRound( pDX[ i ] * fFactor );
- }
- else
- {
- ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( ::vcl::unohelper::CreateBreakIterator() );
- const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale();
- sal_Int32 nCurPos = 0, nLastPos = 0, nX = aPos.X();
+ nLastPos = nCurPos;
+ nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
+ nCount = nCurPos - nLastPos;
+ bCont = ( nCurPos < rText.Len() ) && nCount;
- // write single glyphs at absolute text positions
- for( sal_Bool bCont = sal_True; bCont; )
- {
- sal_Int32 nCount = 1;
+ if( nCount )
+ {
+ aString += rtl::OUString::valueOf( nX );
+ if( bCont )
+ {
+ sal_Int32 nWidth = pDX[ nCurPos - 1 ];
+ if ( bApplyMapping )
+ nWidth = ImplMap( nWidth );
+ nX = aPos.X() + nWidth;
+ aString += aSpace;
+ }
+ }
+ }
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aString );
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemTSpan, sal_True, sal_False );
+ mrExport.GetDocHandler()->characters( rText );
+ }
+ }
+ else
+ {
+ aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( nLen - 1 ) );
- nLastPos = nCurPos;
- nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale,
- ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL,
- nCount, nCount );
+ if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) )
+ {
+ const double fFactor = (double) nWidth / aNormSize.Width();
- nCount = nCurPos - nLastPos;
- bCont = ( nCurPos < rText.Len() ) && nCount;
-
- if( nCount )
- {
- const ::rtl::OUString aGlyph( rText.Copy( nLastPos, nCount ) );
+ for( i = 0; i < ( nLen - 1 ); i++ )
+ pDX[ i ] = FRound( pDX[ i ] * fFactor );
+ }
+ else
+ {
+ // write single glyphs at absolute text positions
+ for( sal_Bool bCont = sal_True; bCont; )
+ {
+ sal_Int32 nCount = 1;
- mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) );
- mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+ nLastPos = nCurPos;
+ nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale,
+ ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL,
+ nCount, nCount );
- {
- SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
- mrExport.GetDocHandler()->characters( aGlyph );
- }
+ nCount = nCurPos - nLastPos;
+ bCont = ( nCurPos < rText.Len() ) && nCount;
+
+ if( nCount )
+ {
+ const ::rtl::OUString aGlyph( rText.Copy( nLastPos, nCount ) );
- if( bCont )
- {
- // #118796# do NOT access pDXArray, it may be zero (!)
- sal_Int32 nWidth = pDX[ nCurPos - 1 ];
- if ( bApplyMapping )
- nWidth = ImplMap( nWidth );
- nX = aPos.X() + nWidth;
- }
- }
- }
- }
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
+ mrExport.GetDocHandler()->characters( aGlyph );
+ }
+
+ if( bCont )
+ {
+ // #118796# do NOT access pDXArray, it may be zero (!)
+ sal_Int32 nWidth = pDX[ nCurPos - 1 ];
+ if ( bApplyMapping )
+ nWidth = ImplMap( nWidth );
+ nX = aPos.X() + nWidth;
+ }
+ }
+ }
+ }
+ }
}
else
{
@@ -994,8 +1032,8 @@ void SVGActionWriter::ImplWriteBmp( cons
aPt = rPt;
aSz = rSz;
}
-
- if( xExtDocHandler.is() )
+ const Rectangle aRect( aPt, aSz );
+ if( mrExport.IsVisible( aRect ) && xExtDocHandler.is() )
{
static const sal_uInt32 nPartLen = 64;
const ::rtl::OUString aSpace( ' ' );
@@ -1888,8 +1926,9 @@ SVGWriter::~SVGWriter()
ANY SAL_CALL SVGWriter::queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException )
{
- const ANY aRet( NMSP_CPPU::queryInterface( rType, static_cast< NMSP_SVG::XSVGWriter* >( this ) ) );
-
+ const ANY aRet( NMSP_CPPU::queryInterface( rType,
+ static_cast< NMSP_SVG::XSVGWriter* >( this ),
+ static_cast< NMSP_LANG::XInitialization* >( this ) ) );
return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) );
}
@@ -1919,9 +1958,7 @@ void SAL_CALL SVGWriter::write( const RE
aMemStm >> aMtf;
const REF( NMSP_SAX::XDocumentHandler ) xDocumentHandler( rxDocHandler );
- const Sequence< PropertyValue > aFilterData;
-
- SVGExport* pWriter = new SVGExport( mxFact, xDocumentHandler, aFilterData );
+ SVGExport* pWriter = new SVGExport( mxFact, xDocumentHandler, maFilterData );
pWriter->writeMtf( aMtf );
delete pWriter;
@@ -1929,6 +1966,18 @@ void SAL_CALL SVGWriter::write( const RE
// -----------------------------------------------------------------------------
+void SVGWriter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if ( aArguments.getLength() == 1 )
+ {
+ ::com::sun::star::uno::Any aArg = aArguments.getConstArray()[0];
+ aArg >>= maFilterData;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
#define SVG_WRITER_SERVICE_NAME "com.sun.star.svg.SVGWriter"
#define SVG_WRITER_IMPLEMENTATION_NAME "com.sun.star.comp.Draw.SVGWriter"
@@ -1955,7 +2004,7 @@ Sequence< rtl::OUString > SAL_CALL SVGWr
{
Sequence< rtl::OUString > aRet( 1 );
- aRet.getArray()[ 0 ] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_WRITER_SERVICE_NAME ) );
+ aRet.getArray()[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SVG_WRITER_SERVICE_NAME ) );
return aRet;
}
@@ -1967,4 +2016,3 @@ Reference< XInterface > SAL_CALL SVGWrit
{
return( static_cast< cppu::OWeakObject* >( new SVGWriter( rSMgr ) ) );
}
-
Modified: incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.hxx?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.hxx (original)
+++ incubator/ooo/branches/writer001/main/filter/source/svg/svgwriter.hxx Mon Aug 20 11:46:19 2012
@@ -66,6 +66,7 @@
#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/svg/XSVGWriter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
// -----------------------------------------------------------------------------
@@ -234,12 +235,13 @@ public:
const ::rtl::OUString* pElementId = NULL );
};
-class SVGWriter : public NMSP_CPPU::OWeakObject, NMSP_SVG::XSVGWriter
+class SVGWriter : public NMSP_CPPU::OWeakObject, NMSP_SVG::XSVGWriter, com::sun::star::lang::XInitialization
{
private:
- REF( NMSP_LANG::XMultiServiceFactory ) mxFact;
-
+ REF( NMSP_LANG::XMultiServiceFactory ) mxFact;
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maFilterData;
+
SVGWriter();
public:
@@ -255,6 +257,10 @@ public:
// XSVGWriter
virtual void SAL_CALL write( const REF( NMSP_SAX::XDocumentHandler )& rxDocHandler,
const SEQ( sal_Int8 )& rMtfSeq ) throw( NMSP_UNO::RuntimeException );
+
+ // ::com::sun::star::lang::XInitialization
+ void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
};
::rtl::OUString SVGWriter_getImplementationName ()
@@ -276,5 +282,4 @@ sal_Bool SAL_CALL SVGWriter_supportsServ
SAL_CALL SVGWriter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
throw ( ::com::sun::star::uno::Exception );
-
#endif
Modified: incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/filterdetect.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/filterdetect.cxx?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/filterdetect.cxx (original)
+++ incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/filterdetect.cxx Mon Aug 20 11:46:19 2012
@@ -55,6 +55,9 @@
#include <unotools/ucbhelper.hxx>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+//UOF v2 deep type detection
+#include "../xsltfilter/uof2storage.cxx"
+#include <rtl/string.hxx>
using rtl::OUString;
@@ -100,6 +103,7 @@ Reference< com::sun::star::frame::XModel
Sequence<PropertyValue > lProps ;
com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInStream;
+ com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xIn;
::rtl::OUString temp;
//OSL_ENSURE( sal_False, " starting Detect" );
const PropertyValue * pValue = aArguments.getConstArray();
@@ -128,9 +132,9 @@ Reference< com::sun::star::frame::XModel
else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
{
pValue[i].Value >>= xInStream ;
+ pValue[i].Value >>= xIn ;
}
-
}
try{
Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
@@ -187,6 +191,41 @@ Reference< com::sun::star::frame::XModel
if(sTypeName.equalsAscii(""))
{
//sTypeName=::rtl::OUString::createFromAscii("writer_Flat_XML_File");
+ //UOF v2.0 deep type detection
+ if(sUrl.indexOf( ::rtl::OUString::createFromAscii(".uot") ) != -1 ||
+ sUrl.indexOf( ::rtl::OUString::createFromAscii(".uos") ) != -1 ||
+ sUrl.indexOf( ::rtl::OUString::createFromAscii(".uop") ) != -1)
+ {
+ if(xIn.is())
+ {
+ XSLT::UOF2Storage aUOF2Storage(mxMSF, xIn);
+ if(aUOF2Storage.isValidUOF2Doc())
+ {
+ xIn->skipBytes(0);
+ Reference< XInputStream > xUOFInputStream = aUOF2Storage.getMainStorageRef()->openInputStream(XSLT::UOFELEMNAME);
+ if(xUOFInputStream.is())
+ {
+ Sequence< sal_Int8 > aSeq;
+ xUOFInputStream->readBytes(aSeq, 2000);
+ ::rtl::OString sUOFXML( reinterpret_cast< sal_Char* >(aSeq.getArray()));
+ OUString sOUSUOFXML( OStringToOUString(sUOFXML, RTL_TEXTENCODING_UTF8));
+ if(sOUSUOFXML.getLength())
+ {
+ const OUString sText( OUString::createFromAscii("vnd.uof.text"));
+ const OUString sCalc( OUString::createFromAscii("vnd.uof.spreadsheet"));
+ const OUString sImpress( OUString::createFromAscii("vnd.uof.presentation"));
+
+ if(sOUSUOFXML.indexOf(sText) != -1)
+ sTypeName = OUString::createFromAscii("writer_NSO_UOF2");
+ else if(sOUSUOFXML.indexOf(sCalc) != -1)
+ sTypeName = OUString::createFromAscii("calc_NSO_UOF2");
+ else if(sOUSUOFXML.indexOf(sImpress) != -1)
+ sTypeName = OUString::createFromAscii("impress_NSO_UOF2");
+ }
+ }
+ }
+ }
+ }
}
else
{
Modified: incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/makefile.mk?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/makefile.mk (original)
+++ incubator/ooo/branches/writer001/main/filter/source/xmlfilterdetect/makefile.mk Mon Aug 20 11:46:19 2012
@@ -51,7 +51,8 @@ SHL1OBJS= $(SLO)$/fdcomp.obj \
SHL1STDLIBS= $(UCBHELPERLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
- $(SALLIB)
+ $(SALLIB) \
+ $(COMPHELPERLIB)
.INCLUDE : target.mk
Modified: incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_page.xsl
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_page.xsl?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_page.xsl (original)
+++ incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_page.xsl Mon Aug 20 11:46:19 2012
@@ -175,7 +175,28 @@
</style:page-layout-properties>
<style:header-style>
<style:header-footer-properties style:dynamic-spacing="true" fo:margin-bottom="0">
- <xsl:attribute name="fo:min-height.value"><xsl:value-of select="concat('(.(twips2cm(?(>($0(-[', w:pgMar/@w:top, '](|[', w:pgMar/@w:header, '][720])))[0])($0)[0]))[cm])')"/></xsl:attribute>
+ <xsl:variable name="header-margin">
+ <xsl:choose>
+ <xsl:when test="w:pgMar/@w:header">
+ <xsl:value-of select="w:pgMar/@w:header"/>
+ </xsl:when>
+ <xsl:otherwise>720</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="header-margin-diff">
+ <xsl:value-of select="w:pgMar/@w:top - $header-margin"/>
+ </xsl:variable>
+ <xsl:variable name="min-height">
+ <xsl:choose>
+ <xsl:when test="$header-margin-diff > 0">
+ <xsl:value-of select="$header-margin-diff div 567.0"/>
+ </xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:attribute name="fo:min-height">
+ <xsl:value-of select="concat($min-height, 'cm')"/>
+ </xsl:attribute>
</style:header-footer-properties>
</style:header-style>
</style:page-layout>
Modified: incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_props.xsl
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_props.xsl?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_props.xsl (original)
+++ incubator/ooo/branches/writer001/main/filter/source/xslt/import/wordml/wordml2ooo_props.xsl Mon Aug 20 11:46:19 2012
@@ -29,30 +29,79 @@
<xsl:template name="page-layout-properties">
-<xsl:attribute name="fo:margin-top.value">
- <xsl:value-of select="concat('(.(twips2cm(?[',name(w:hdr),'](?(>=($0[',w:pgMar/@w:top,'])($1(|[',w:pgMar/@w:header,'][720])))($1)($0))[',w:pgMar/@w:top,']))[cm])')"/>
+<!-- NOTE: "div 567.0" converts from twips to cm -->
+<xsl:attribute name="fo:margin-top">
+ <xsl:variable name="header-margin">
+ <xsl:choose>
+ <xsl:when test="w:pgMar/@w:header">
+ <xsl:value-of select="w:pgMar/@w:header"/>
+ </xsl:when>
+ <xsl:otherwise>720</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="margin-top">
+ <xsl:choose>
+ <xsl:when test="w:hdr">
+ <xsl:choose>
+ <xsl:when test="w:pgMar/@w:top >= $header-margin">
+ <xsl:value-of select="$header-margin"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="w:pgMar/@w:top"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="w:pgMar/@w:top"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:value-of select="concat($margin-top div 567.0, 'cm')"/>
+</xsl:attribute>
+<xsl:attribute name="fo:margin-bottom">
+ <xsl:variable name="footer-margin">
+ <xsl:choose>
+ <xsl:when test="w:pgMar/@w:footer">
+ <xsl:value-of select="w:pgMar/@w:footer"/>
+ </xsl:when>
+ <xsl:otherwise>720</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="margin-bottom">
+ <xsl:choose>
+ <xsl:when test="w:ftr">
+ <xsl:value-of select="$footer-margin"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="w:pgMar/@w:bottom"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:value-of select="concat($margin-bottom div 567.0, 'cm')"/>
</xsl:attribute>
-<xsl:attribute name="fo:margin-bottom.value">
- <xsl:value-of select="concat('(.(twips2cm(?[',name(w:ftr),'](|[',w:pgMar/@w:footer,'][720])[',w:pgMar/@w:bottom,']))[cm])')"/>
+<xsl:attribute name="fo:margin-left">
+ <xsl:value-of select="concat(w:pgMar/@w:left div 567.0, 'cm')"/>
</xsl:attribute>
-<xsl:attribute name="fo:margin-left.value">
- <xsl:value-of select="concat('(.(twips2cm[',w:pgMar/@w:left,'])[cm])')"/>
-</xsl:attribute>
-<xsl:attribute name="fo:margin-right.value">
- <xsl:value-of select="concat('(.(twips2cm[',w:pgMar/@w:right,'])[cm])')"/>
+<xsl:attribute name="fo:margin-right">
+ <xsl:value-of select="concat(w:pgMar/@w:right div 567.0, 'cm')"/>
</xsl:attribute>
-<xsl:attribute name="fo:page-width.value">
- <xsl:value-of select="concat('(.(twips2cm[',w:pgSz/@w:w,'])[cm])')"/>
+<xsl:attribute name="fo:page-width">
+ <xsl:value-of select="concat(w:pgSz/@w:w div 567.0, 'cm')"/>
</xsl:attribute>
-<xsl:attribute name="fo:page-height.value">
- <xsl:value-of select="concat('(.(twips2cm[',w:pgSz/@w:h,'])[cm])')"/>
+<xsl:attribute name="fo:page-height">
+ <xsl:value-of select="concat(w:pgSz/@w:h div 567.0, 'cm')"/>
</xsl:attribute>
-<xsl:attribute name="style:footnote-max-height.value">
- <xsl:value-of select="'[0cm]'"/>
+<xsl:attribute name="style:footnote-max-height">
+ <xsl:value-of select="'0cm'"/>
</xsl:attribute>
-<xsl:attribute name="style:print-orientation.value">
- <xsl:value-of select="concat('(|[',w:pgSz/@w:orient,'][portrait])')"/>
+<xsl:attribute name="style:print-orientation">
+ <xsl:choose>
+ <xsl:when test="w:pgSz/@w:orient">
+ <xsl:value-of select="w:pgSz/@w:orient"/>
+ </xsl:when>
+ <xsl:otherwise>portrait</xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="//w:bgPict"/>
<xsl:call-template name="column-properties"/>
@@ -66,27 +115,37 @@
</an:column-properties>
<xsl:template name="column-properties">
<style:columns>
-<xsl:attribute name="fo:column-count.value">
- <xsl:value-of select="concat('(|[',w:cols/@w:num,'][1])')"/>
+<xsl:attribute name="fo:column-count">
+ <xsl:choose>
+ <xsl:when test="w:cols/@w:num">
+ <xsl:value-of select="w:cols/@w:num"/>
+ </xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
<xsl:if test="not(w:cols/w:col)">
<!-- bug in the OASIS spec resp. bug in xmloff -->
-<xsl:attribute name="fo:column-gap.value">
- <xsl:value-of select="concat('(.(twips2cm[',w:cols/@w:space,'])[cm])')"/>
+<xsl:attribute name="fo:column-gap">
+ <xsl:value-of select="concat(w:cols/@w:space div 567.0, 'cm')"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="w:cols/w:col">
<style:column>
- <xsl:attribute name="style:rel-width.value">
- <xsl:value-of select="concat('(.[',@w:w,'][*])')"/>
+ <xsl:attribute name="style:rel-width">
+ <xsl:value-of select="concat(@w:w, '*')"/>
</xsl:attribute>
- <xsl:attribute name="fo:start-indent.value">
- <xsl:value-of select="'[0cm]'"/>
+ <xsl:attribute name="fo:start-indent">
+ <xsl:value-of select="'0cm'"/>
</xsl:attribute>
- <xsl:attribute name="fo:end-indent.value">
- <xsl:value-of select="concat('(.(twips2cm(|[',@w:space,'][0]))[cm])')"/>
+ <xsl:attribute name="fo:end-indent">
+ <xsl:choose>
+ <xsl:when test="@w:space">
+ <xsl:value-of select="concat(@w:space div 567.0, 'cm')"/>
+ </xsl:when>
+ <xsl:otherwise>0cm</xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
</style:column>
</xsl:for-each>
@@ -98,29 +157,131 @@
context-node-output="style:text-properties">
</an:text-properties >
<xsl:template name="text-properties">
-<xsl:attribute name="fo:font-weight.value">
- <xsl:value-of select="concat('(switch(|[',w:b/@val,'][',local-name(w:b),'])[on][bold][off][normal][b][bold][])')"/>
-</xsl:attribute>
-<xsl:attribute name="style:font-weight-asian.value">
- <xsl:value-of select="concat('(switch(|[',w:b/@val,'][',local-name(w:b),'])[on][bold][off][normal][b][bold][])')"/>
-</xsl:attribute>
-<xsl:attribute name="style:font-weight-complex.value">
- <xsl:value-of select="concat('(switch(|[',w:b-cs/@val,'][',local-name(w:b-cs),'])[on][bold][off][normal][b-cs][bold][])')"/>
-</xsl:attribute>
-<xsl:attribute name="fo:font-style.value">
- <xsl:value-of select="concat('(switch(|[',w:i/@val,'][',local-name(w:i),'])[on][italic][off][normal][i][italic][])')"/>
-</xsl:attribute>
-<xsl:attribute name="style:font-style-asian.value">
- <xsl:value-of select="concat('(switch(|[',w:i/@val,'][',local-name(w:i),'])[on][italic][off][normal][i][italic][])')"/>
-</xsl:attribute>
-<xsl:attribute name="style:font-style-complex.value">
- <xsl:value-of select="concat('(switch(|[',w:i-cs/@val,'][',local-name(w:i-cs),'])[on][italic][off][normal][i-cs][italic][])')"/>
-</xsl:attribute>
-<xsl:attribute name="fo:text-transform.value">
- <xsl:value-of select="concat('(switch(|[',w:caps/@val,'][',local-name(w:caps),'])[on][uppercase][off][normal][caps][uppercase][])')"/>
-</xsl:attribute>
-<xsl:attribute name="fo:font-variant.value">
- <xsl:value-of select="concat('(switch(|[',w:smallCaps/@val,'][',local-name(w:smallCaps),'])[on][small-caps][off][normal][smallCaps][small-caps][])')"/>
+<xsl:variable name="b-value">
+ <xsl:choose>
+ <xsl:when test="w:b/@val">
+ <xsl:value-of select="w:b/@val"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(w:b)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+<!-- could be simplified: is "b" actually a valid value of w:b/@val ? -->
+<xsl:variable name="font-weight">
+ <xsl:choose>
+ <xsl:when test="$b-value = 'on'">bold</xsl:when>
+ <xsl:when test="$b-value = 'off'">normal</xsl:when>
+ <xsl:when test="$b-value = 'b'">bold</xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+<xsl:attribute name="fo:font-weight">
+ <xsl:value-of select="$font-weight"/>
+</xsl:attribute>
+<xsl:attribute name="style:font-weight-asian">
+ <xsl:value-of select="$font-weight"/>
+</xsl:attribute>
+<xsl:attribute name="style:font-weight-complex">
+ <xsl:variable name="b-cs-value">
+ <xsl:choose>
+ <xsl:when test="w:b-cs/@val">
+ <xsl:value-of select="w:b-cs/@val"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(w:b-cs)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- could be simplified: is "b-cs" actually a valid value of w:b-cs/@val -->
+ <xsl:choose>
+ <xsl:when test="$b-cs-value = 'on'">bold</xsl:when>
+ <xsl:when test="$b-cs-value = 'off'">normal</xsl:when>
+ <xsl:when test="$b-cs-value = 'b-cs'">bold</xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+</xsl:attribute>
+<xsl:variable name="i-value">
+ <xsl:choose>
+ <xsl:when test="w:i/@val">
+ <xsl:value-of select="w:i/@val"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(w:i)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+<!-- could be simplified: is "i" actually a valid value of w:i/@val ? -->
+<xsl:variable name="font-style">
+ <xsl:choose>
+ <xsl:when test="$i-value = 'on'">italic</xsl:when>
+ <xsl:when test="$i-value = 'off'">normal</xsl:when>
+ <xsl:when test="$i-value = 'i'">italic</xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+<xsl:attribute name="fo:font-style">
+ <xsl:value-of select="$font-style"/>
+</xsl:attribute>
+<xsl:attribute name="style:font-style-asian">
+ <xsl:value-of select="$font-style"/>
+</xsl:attribute>
+<xsl:attribute name="style:font-style-complex">
+ <xsl:variable name="i-cs-value">
+ <xsl:choose>
+ <xsl:when test="w:i-cs/@val">
+ <xsl:value-of select="w:i-cs/@val"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(w:i-cs)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- could be simplified: is "i-cs" actually a valid value of w:i-cs/@val -->
+ <xsl:choose>
+ <xsl:when test="$i-cs-value = 'on'">italic</xsl:when>
+ <xsl:when test="$i-cs-value = 'off'">normal</xsl:when>
+ <xsl:when test="$i-cs-value = 'i-cs'">italic</xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+</xsl:attribute>
+<xsl:attribute name="fo:text-transform">
+ <xsl:variable name="caps-value">
+ <xsl:choose>
+ <xsl:when test="w:caps/@val">
+ <xsl:value-of select="w:caps/@val"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(w:caps)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- could be simplified: is "caps" actually a valid value of w:caps/@val -->
+ <xsl:choose>
+ <xsl:when test="$caps-value = 'on'">uppercase</xsl:when>
+ <xsl:when test="$caps-value = 'off'">normal</xsl:when>
+ <xsl:when test="$caps-value = 'caps'">uppercase</xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+</xsl:attribute>
+<xsl:attribute name="fo:font-variant">
+ <xsl:variable name="small-caps-value">
+ <xsl:choose>
+ <xsl:when test="w:smallCaps/@val">
+ <xsl:value-of select="w:smallCaps/@val"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(w:smallCaps)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- could be simplified: is "smallCaps" actually a valid value of w:smallCaps/@val -->
+ <xsl:choose>
+ <xsl:when test="$small-caps-value = 'on'">small-caps</xsl:when>
+ <xsl:when test="$small-caps-value = 'off'">normal</xsl:when>
+ <xsl:when test="$small-caps-value = 'smallCaps'">small-caps</xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
</xsl:template>
Modified: incubator/ooo/branches/writer001/main/filter/source/xsltfilter/XSLTFilter.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/xsltfilter/XSLTFilter.cxx?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/xsltfilter/XSLTFilter.cxx (original)
+++ incubator/ooo/branches/writer001/main/filter/source/xsltfilter/XSLTFilter.cxx Mon Aug 20 11:46:19 2012
@@ -17,20 +17,16 @@
* specific language governing permissions and limitations
* under the License.
*
- *************************************************************/
-
-
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
+ **************************************************************/
+
+ // MARKER(update_precomp.py): autogen include statement, do not remove
+//This file is about the conversion of the UOF v2.0 and ODF document format
#include "precompiled_filter.hxx"
#include <stdio.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/servicefactory.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase.hxx>
@@ -69,8 +65,17 @@
#include <com/sun/star/util/XStringSubstitution.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+
+#include <unotools/streamwrap.hxx>
+#include <comphelper/processfactory.hxx>
+#include <tools/stream.hxx>
+#include "uof2splitter.hxx"
+
#include <xmloff/attrlist.hxx>
-#include <fla.hxx>
+#include "uof2storage.hxx"
+#include "uof2merge.hxx"
+#include <tools/stream.hxx>
+#include <string>
using namespace ::rtl;
using namespace ::cppu;
@@ -87,132 +92,6 @@ using namespace ::com::sun::star::util;
namespace XSLT {
-class FLABridge : public WeakImplHelper1< XDocumentHandler>
-{
-private:
- const Reference<XDocumentHandler>& m_rDocumentHandler;
- const sal_Unicode *eval(const sal_Unicode *expr, sal_Int32 exprLen);
- FLA::Evaluator ev;
- bool active;
-
-public:
- FLABridge(const Reference<XDocumentHandler>& m_rDocumentHandler);
-
- // XDocumentHandler
- virtual void SAL_CALL startDocument()
- throw (SAXException,RuntimeException);
- virtual void SAL_CALL endDocument()
- throw (SAXException, RuntimeException);
- virtual void SAL_CALL startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
- throw (SAXException,RuntimeException);
- virtual void SAL_CALL endElement(const OUString& str)
- throw (SAXException, RuntimeException);
- virtual void SAL_CALL characters(const OUString& str)
- throw (SAXException, RuntimeException);
- virtual void SAL_CALL ignorableWhitespace(const OUString& str)
- throw (SAXException, RuntimeException);
- virtual void SAL_CALL processingInstruction(const OUString& str, const OUString& str2)
- throw (com::sun::star::xml::sax::SAXException,RuntimeException);
- virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& doclocator)
- throw (SAXException,RuntimeException);
-
-};
-
-FLABridge::FLABridge(const Reference<XDocumentHandler>& _rDocumentHandler) : m_rDocumentHandler(_rDocumentHandler), active(false)
-{
-}
-
-void FLABridge::startDocument() throw (SAXException,RuntimeException){
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->startDocument();
-}
-
-void FLABridge::endDocument() throw (SAXException,RuntimeException){
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->endDocument();
-
-}
-
-
-void FLABridge::startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
- throw (SAXException, RuntimeException)
-{
- OSL_ASSERT(m_rDocumentHandler.is());
- if (active)
- {
-// SvXMLAttributeList* _attriblist=SvXMLAttributeList::getImplementation(attriblist);
- const int len=attriblist->getLength();
- SvXMLAttributeList *_newattriblist= new SvXMLAttributeList();
- for(int i=0;i<len;i++)
- {
- const OUString& name=attriblist->getNameByIndex( sal::static_int_cast<sal_Int16>( i ) );
- sal_Int32 pos;
- static const OUString _value_(".value", 6, RTL_TEXTENCODING_ASCII_US);
- if ((pos=name.lastIndexOf(L'.'))!=-1 && name.match(_value_, pos))
- {
- const OUString newName(name, pos);
- const OUString& value=attriblist->getValueByIndex( sal::static_int_cast<sal_Int16>( i ) );
- const OUString newValue(ev.eval(value.getStr(), value.getLength()));
- if (newValue.getLength()>0)
- {
- _newattriblist->AddAttribute(newName, newValue);
- }
- }
- else
- {
- _newattriblist->AddAttribute(name, attriblist->getValueByIndex( sal::static_int_cast<sal_Int16>( i )));
- }
- };
- const Reference<XAttributeList> newattriblist(_newattriblist);
- m_rDocumentHandler->startElement(str, newattriblist);
- }
- else
- {
- if (str.compareToAscii("fla:fla.activate")==0)
- {
- active=1;
- }
- m_rDocumentHandler->startElement(str, attriblist);
- }
-}
-
-void FLABridge::endElement(const OUString& str)
- throw (SAXException, RuntimeException)
-{
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->endElement(str);
-}
-
-void FLABridge::characters(const OUString& str)
- throw (SAXException, RuntimeException)
-{
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->characters(str);
-}
-
-void FLABridge::ignorableWhitespace(const OUString& str)
- throw (SAXException, RuntimeException)
-{
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->ignorableWhitespace(str);
-}
-
-void FLABridge::processingInstruction(const OUString& str, const OUString& str2)
- throw (SAXException, RuntimeException)
-{
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->processingInstruction(str, str2);
-}
-
-void FLABridge::setDocumentLocator(const Reference<XLocator>& doclocator)
- throw (SAXException, RuntimeException)
-{
- OSL_ASSERT(m_rDocumentHandler.is());
- m_rDocumentHandler->setDocumentLocator(doclocator);
-}
-
-
-
class XSLTFilter : public WeakImplHelper4< XImportFilter, XExportFilter, XDocumentHandler, XStreamListener>
{
private:
@@ -228,6 +107,10 @@ private:
Reference< XActiveDataControl > m_tcontrol;
oslCondition m_cTransformed;
+
+ //UOF v2.0 export
+ Reference< XActiveDataControl > m_splitControl;
+
sal_Bool m_bTerminated;
sal_Bool m_bError;
@@ -280,6 +163,11 @@ public:
throw (com::sun::star::xml::sax::SAXException,RuntimeException);
virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& doclocator)
throw (SAXException,RuntimeException);
+ // UOF v2.0 export
+private:
+ Reference< XStream > m_rStream;
+ UOF2Splitter * pSplitter;
+
};
XSLTFilter::XSLTFilter( const Reference< XMultiServiceFactory > &r )
@@ -416,11 +304,20 @@ sal_Bool XSLTFilter::importer(
{
try
{
- // we want to be notfied when the processing is done...
+ // we want to be notified when the processing is done...
m_tcontrol->addListener(Reference< XStreamListener >(this));
// connect input to transformer
Reference< XActiveDataSink > tsink(m_tcontrol, UNO_QUERY);
+ //UOF v2 import
+ UOF2Storage aUOF2Storage(m_rServiceFactory, xInputStream);
+ if(aUOF2Storage.isValidUOF2Doc())
+ {
+ UOF2Merge aUOF2Merge(aUOF2Storage, m_rServiceFactory);
+ aUOF2Merge.merge();
+ tsink->setInputStream(aUOF2Merge.getMergedInStream());
+ }
+ else
tsink->setInputStream(xInputStream);
// create pipe
@@ -439,7 +336,7 @@ sal_Bool XSLTFilter::importer(
aInput.aInputStream = pipein;
// set doc handler
- xSaxParser->setDocumentHandler(new FLABridge(xHandler));
+ xSaxParser->setDocumentHandler(xHandler);
// transform
m_tcontrol->start();
@@ -483,7 +380,7 @@ sal_Bool XSLTFilter::exporter(
OUString udStyleSheet = rel2abs(msUserData[5]);
// read source data
- // we are especialy interested in the output stream
+ // we are especially interested in the output stream
// since that is where our xml-writer will push the data
// from it's data-source interface
OUString aName, sURL;
@@ -505,6 +402,9 @@ sal_Bool XSLTFilter::exporter(
aSourceData[i].Value >>= m_rOutputStream;
else if ( aName.equalsAscii("URL" ))
aSourceData[i].Value >>= sURL;
+ //UOF v2.0 export, get Stream for constructing UOF2Storage
+ if ( aName.equalsAscii("StreamForOutput"))
+ aSourceData[i].Value >>= m_rStream;
}
if (!m_rDocumentHandler.is()) {
@@ -541,7 +441,7 @@ sal_Bool XSLTFilter::exporter(
OSL_ASSERT(m_tcontrol.is());
if (m_tcontrol.is() && m_rOutputStream.is() && m_rDocumentHandler.is())
{
- // we want to be notfied when the processing is done...
+ // we want to be notified when the processing is done...
m_tcontrol->addListener(Reference< XStreamListener >(this));
// create pipe
@@ -557,9 +457,26 @@ sal_Bool XSLTFilter::exporter(
Reference< XActiveDataSink > tsink(m_tcontrol, UNO_QUERY);
tsink->setInputStream(pipein);
- // connect transformer to output
- Reference< XActiveDataSource > tsource(m_tcontrol, UNO_QUERY);
- tsource->setOutputStream(m_rOutputStream);
+
+ //creating pipe2
+ Reference< XOutputStream > x_Pipeout( m_rServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY );
+ Reference< XInputStream > x_Pipein( x_Pipeout, UNO_QUERY );
+
+ // connect transformer to pipe2
+ Reference< XActiveDataSource > tsource(m_tcontrol, UNO_QUERY);
+ tsource->setOutputStream( x_Pipeout );
+
+ pSplitter = new UOF2Splitter( m_rServiceFactory, sURL );
+ m_splitControl = Reference< XActiveDataControl >( static_cast< cppu::OWeakObject* >( pSplitter), UNO_QUERY );
+ //m_splitControl->addListener( Reference< XStreamListener >(this));
+ // connect pipe2 to splitter
+ Reference< XActiveDataSink > splitsink( m_splitControl, UNO_QUERY );
+ splitsink->setInputStream( x_Pipein );
+ // connect splitter to output
+ Reference< XActiveDataStreamer > splitout( m_splitControl, UNO_QUERY );
+ splitout->setStream( m_rStream );
+ m_rOutputStream = m_rStream->getOutputStream();
// we will start receiving events after returning 'true'.
// we will start the transformation as soon as we receive the startDocument
@@ -584,6 +501,10 @@ void XSLTFilter::startDocument() throw (
void XSLTFilter::endDocument() throw (SAXException, RuntimeException){
OSL_ASSERT(m_rDocumentHandler.is());
m_rDocumentHandler->endDocument();
+
+ //when the inputStream(outputStream of filter) was closed, start to parse it.
+ m_splitControl->start();
+
// wait for the transformer to finish
osl_waitCondition(m_cTransformed, 0);
if (!m_bError && !m_bTerminated)
@@ -678,6 +599,31 @@ void SAL_CALL component_getImplementatio
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
+sal_Bool SAL_CALL component_writeInfo(void * /* pServiceManager */, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+
void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
{
Modified: incubator/ooo/branches/writer001/main/filter/source/xsltfilter/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/filter/source/xsltfilter/makefile.mk?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/filter/source/xsltfilter/makefile.mk (original)
+++ incubator/ooo/branches/writer001/main/filter/source/xsltfilter/makefile.mk Mon Aug 20 11:46:19 2012
@@ -33,7 +33,14 @@ CLASSDIR!:=$(CLASSDIR)$/$(TARGET)
.IF "$(DISABLE_SAXON)" == ""
-SLOFILES=$(SLO)$/XSLTFilter.obj $(SLO)$/fla.obj
+SLOFILES= \
+ $(SLO)$/XSLTFilter.obj \
+ $(SLO)$/uof2storage.obj \
+ $(SLO)$/uof2merge.obj \
+ $(SLO)$/XMLBase64Codec.obj \
+ $(SLO)$/uof2splithandler.obj \
+ $(SLO)$/uof2splitter.obj
+
LIBNAME=xsltfilter
SHL1TARGETDEPN=makefile.mk
SHL1OBJS=$(SLOFILES)
@@ -48,7 +55,8 @@ SHL1STDLIBS= \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(XMLOFFLIB) \
- $(SALLIB)
+ $(SALLIB) \
+ $(COMPHELPERLIB)
.IF "$(SOLAR_JAVA)"!=""
Modified: incubator/ooo/branches/writer001/main/fpicker/source/office/iodlgimp.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/fpicker/source/office/iodlgimp.cxx?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/fpicker/source/office/iodlgimp.cxx (original)
+++ incubator/ooo/branches/writer001/main/fpicker/source/office/iodlgimp.cxx Mon Aug 20 11:46:19 2012
@@ -103,7 +103,7 @@ namespace
{
ResMgr * operator ()()
{
- return ResMgr::CreateResMgr (CREATEVERSIONRESMGR_NAME(svs));
+ return ResMgr::CreateResMgr (CREATEVERSIONRESMGR_NAME(svl));
}
static ResMgr * getOrCreate()
{
Modified: incubator/ooo/branches/writer001/main/framework/source/accelerators/acceleratorconfiguration.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/framework/source/accelerators/acceleratorconfiguration.cxx?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/framework/source/accelerators/acceleratorconfiguration.cxx (original)
+++ incubator/ooo/branches/writer001/main/framework/source/accelerators/acceleratorconfiguration.cxx Mon Aug 20 11:46:19 2012
@@ -1301,14 +1301,14 @@ void SAL_CALL XCUBasedAcceleratorConfigu
}
//-----------------------------------------------
-void SAL_CALL XCUBasedAcceleratorConfiguration::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
+void SAL_CALL XCUBasedAcceleratorConfiguration::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& /* xListener */ )
throw(css::uno::RuntimeException)
{
// nop
}
//-----------------------------------------------
-void SAL_CALL XCUBasedAcceleratorConfiguration::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
+void SAL_CALL XCUBasedAcceleratorConfiguration::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& /* aListener */ )
throw(css::uno::RuntimeException)
{
// nop
Modified: incubator/ooo/branches/writer001/main/hwpfilter/prj/build.lst
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/prj/build.lst?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/prj/build.lst (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/prj/build.lst Mon Aug 20 11:46:19 2012
@@ -1,4 +1,4 @@
-hw hwpfilter : offuh cppuhelper ZLIB:zlib LIBXSLT:libxslt NULL
+hw hwpfilter : offuh cppuhelper comphelper ZLIB:zlib LIBXSLT:libxslt NULL
hw hwpfilter usr1 - all hw_mkout NULL
hw hwpfilter\prj get - all hw_prj NULL
hw hwpfilter\inc nmake - all hw_inc NULL
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/drawdef.h
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/drawdef.h?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/drawdef.h (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/drawdef.h Mon Aug 20 11:46:19 2012
@@ -175,7 +175,7 @@ struct HWPDOProperty
ZZPoint offset1;
ZZPoint offset2;
- char szPatternFile[MAX_PATH + 1];
+ char szPatternFile[260 + 1];
char pictype;
};
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/drawing.h
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/drawing.h?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/drawing.h (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/drawing.h Mon Aug 20 11:46:19 2012
@@ -36,6 +36,8 @@
#include <math.h>
+#include <comphelper/newarray.hxx>
+
#include "hwplib.h"
#include "hwpfile.h"
#include "hiodev.h"
@@ -361,6 +363,7 @@ static HWPDrawingObject *LoadDrawingObje
hdo->child = LoadDrawingObject();
if (hdo->child == NULL)
{
+ goto error;
}
}
if (prev == NULL)
@@ -659,6 +662,7 @@ static int getBlend(int alpha)
}
*/
+
static int
HWPDOFreeFormFunc(int type, HWPDrawingObject * hdo,
int cmd, void *argp, int argv)
@@ -682,7 +686,8 @@ int cmd, void *argp, int argv)
return OBJRET_FILE_ERROR;
if (hdo->u.freeform.npt)
{
- hdo->u.freeform.pt = new ZZPoint[hdo->u.freeform.npt];
+ hdo->u.freeform.pt =
+ ::comphelper::newArray_null<ZZPoint>(hdo->u.freeform.npt);
if (hdo->u.freeform.pt == NULL)
{
hdo->u.freeform.npt = 0;
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/formula.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/formula.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/formula.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/formula.cpp Mon Aug 20 11:46:19 2012
@@ -35,7 +35,6 @@ extern LinkedList<Node> nodelist;
#include "hcode.h"
-static hchar entity[32];
#define ascii(x) OUString::createFromAscii(x)
#define rstartEl(x,y) rDocumentHandler->startElement(x,y)
#define rendEl(x) rDocumentHandler->endElement(x)
@@ -44,7 +43,6 @@ static hchar entity[32];
#define reucstr(x,y) rDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR))
#define padd(x,y,z) pList->addAttribute(x,y,z)
#else
-static char entity[32];
static int indent = 0;
#define inds indent++; for(int i = 0 ; i < indent ; i++) fprintf(stderr," ")
#define inde for(int i = 0 ; i < indent ; i++) fprintf(stderr," "); indent--
@@ -225,11 +223,12 @@ void Formula::makeIdentifier(Node *res)
case ID_IDENTIFIER :
#ifdef DEBUG
inds;
- fprintf(stderr,"<math:mi>%s</math:mi>\n",getMathMLEntity(tmp->value, entity));
+ fprintf(stderr,"<math:mi>%s</math:mi>\n",
+ getMathMLEntity(tmp->value).c_str());
indo;
#else
rstartEl(ascii("math:mi"), rList);
- runistr(getMathMLEntity(tmp->value, entity));
+ runistr(getMathMLEntity(tmp->value).c_str());
rendEl(ascii("math:mi"));
#endif
break;
@@ -251,7 +250,7 @@ void Formula::makeIdentifier(Node *res)
inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value); indo;
#else
rstartEl(ascii("math:mo"), rList);
- runistr(getMathMLEntity(tmp->value,entity));
+ runistr(getMathMLEntity(tmp->value).c_str());
rendEl(ascii("math:mo"));
#endif
break;
@@ -407,11 +406,12 @@ void Formula::makeDecoration(Node *res)
#ifdef DEBUG
inds;
- fprintf(stderr,"<math:mo>%s</math:mo>\n", getMathMLEntity(tmp->value,entity));
+ fprintf(stderr,"<math:mo>%s</math:mo>\n",
+ getMathMLEntity(tmp->value).c_str());
indo;
#else
rstartEl(ascii("math:mo"), rList);
- runistr(getMathMLEntity(tmp->value,entity));
+ runistr(getMathMLEntity(tmp->value).c_str());
rendEl(ascii("math:mo"));
#endif
@@ -532,11 +532,14 @@ void Formula::makeFence(Node *res)
Node *tmp = res->child;
#ifdef DEBUG
inds;
- fprintf(stderr,"<math:mfenced open=\"%s\" close=\"%s\">\n",getMathMLEntity(tmp->value, entity),
- getMathMLEntity(tmp->next->next->value,entity));
-#else
- padd(ascii("open"), ascii("CDATA"), OUString(getMathMLEntity(tmp->value,entity)) );
- padd(ascii("close"), ascii("CDATA"), OUString(getMathMLEntity(tmp->next->next->value,entity)) );
+ fprintf(stderr,"<math:mfenced open=\"%s\" close=\"%s\">\n",
+ getMathMLEntity(tmp->value).c_str(),
+ getMathMLEntity(tmp->next->next->value).c_str());
+#else
+ padd(ascii("open"), ascii("CDATA"),
+ OUString(getMathMLEntity(tmp->value).c_str()) );
+ padd(ascii("close"), ascii("CDATA"),
+ OUString(getMathMLEntity(tmp->next->next->value).c_str()) );
rstartEl(ascii("math:mfenced"), rList);
pList->clear();
#endif
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.cpp Mon Aug 20 11:46:19 2012
@@ -65,11 +65,11 @@ int HBox::WSize(void)
}
-int HBox::GetString(hchar * hstr, int )
+hchar_string HBox::GetString()
{
- *hstr++ = hh;
- *hstr = 0;
- return 1;
+ hchar_string ret;
+ ret.push_back(hh);
+ return ret;
}
@@ -145,9 +145,10 @@ DateCode::DateCode(void):HBox(CH_DATE_CO
#define _DATECODE_WEEK_DEFINES_
#include "datecode.h"
-int DateCode::GetString(hchar * hstr, int slen)
+hchar_string DateCode::GetString()
{
- hchar *fmt, *d;
+ hchar_string ret;
+ hchar *fmt;
int i, num;
const char *form;
char cbuf[256];
@@ -157,8 +158,7 @@ int DateCode::GetString(hchar * hstr, in
format[DATE_SIZE - 1] = 0;
fmt = format[0] ? format : defaultform;
- d = hstr;
- for (; *fmt && ((int) (d - hstr) < DATE_SIZE) && slen > 1; fmt++)
+ for (; *fmt && ((int) ret.size() < DATE_SIZE); fmt++)
{
form = (add_zero) ? "%02d" : "%d";
@@ -222,8 +222,7 @@ int DateCode::GetString(hchar * hstr, in
num = date[MIN];
break;
case '6':
- *d++ = kor_week[date[WEEK]];
- slen--;
+ ret.push_back(kor_week[date[WEEK]]);
break;
case '^':
memcpy(cbuf, eng_week + date[WEEK] * 3, 3);
@@ -234,11 +233,8 @@ int DateCode::GetString(hchar * hstr, in
strcpy(cbuf, en_week[date[WEEK]]);
break;
case '7':
- if (slen > 3)
- {
- *d++ = 0xB5A1;
- *d++ = (is_pm) ? 0xD281 : 0xB8E5;
- }
+ ret.push_back(0xB5A1);
+ ret.push_back((is_pm) ? 0xD281 : 0xB8E5);
break;
case '&':
strcpy(cbuf, (is_pm) ? "p.m." : "a.m.");
@@ -271,28 +267,24 @@ int DateCode::GetString(hchar * hstr, in
fmt++;
if (*fmt == '6')
{
- *d++ = china_week[date[WEEK]];
- slen--;
+ ret.push_back(china_week[date[WEEK]]);
break;
}
break;
default:
if (*fmt == '\\' && *++fmt == 0)
goto done;
- *d++ = *fmt;
- slen--;
+ ret.push_back(*fmt);
}
if (num != -1)
sprintf(cbuf, form, num);
- for (i = 0; 0 != cbuf[i] && slen > 1; i++)
+ for (i = 0; 0 != cbuf[i]; i++)
{
- *d++ = *(cbuf + i);
- slen--;
+ ret.push_back(*(cbuf + i));
}
}
done:
- *d = 0;
- return hstrlen(hstr);
+ return ret;
}
@@ -415,10 +407,9 @@ Footnote::~Footnote(void)
// Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21)
// mail merge(22)
-int MailMerge::GetString(hchar * hstr, int )
+hchar_string MailMerge::GetString()
{
- *hstr = 0;
- return 0;
+ return hchar_string();
}
@@ -564,7 +555,7 @@ enum
number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
*/
-hchar *Outline::GetUnicode(hchar * hstr, int)
+hchar_string Outline::GetUnicode() const
{
int levelnum;
hchar *p;
@@ -592,14 +583,14 @@ hchar *Outline::GetUnicode(hchar * hstr,
strcat(buf, cur_num_str);
}
str2hstr(buf, buffer);
- return hstr2ucsstr(buffer, hstr);
+ return hstr2ucsstr(buffer);
}
case OLSTY_NUMSIG1:
case OLSTY_NUMSIG2:
case OLSTY_NUMSIG3:
{
getOutlineNumStr(shape, level, number[level], buffer);
- return hstr2ucsstr(buffer, hstr);
+ return hstr2ucsstr(buffer);
}
case OLSTY_BULLET1:
case OLSTY_BULLET2:
@@ -610,7 +601,7 @@ hchar *Outline::GetUnicode(hchar * hstr,
p = GetOutlineStyleChars(shape);
buffer[0] = p[level];
buffer[1] = 0;
- return hstr2ucsstr(buffer, hstr);
+ return hstr2ucsstr(buffer);
}
case OLSTY_USER:
case OLSTY_BULUSER:
@@ -697,11 +688,11 @@ hchar *Outline::GetUnicode(hchar * hstr,
buffer[l++] = deco[i][1];
}
buffer[l] = 0;
- return hstr2ucsstr(buffer, hstr);
+ return hstr2ucsstr(buffer);
}
}
}
- return hstr2ucsstr(buffer, hstr);
+ return hstr2ucsstr(buffer);
}
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.h
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.h?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.h (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hbox.h Mon Aug 20 11:46:19 2012
@@ -66,12 +66,8 @@ struct HBox
* @returns True if reading from stream is successful.
*/
virtual int Read(HWPFile &hwpf);
-/**
- * @param hstr Buffer to save string
- * @param slen Size of buffer
- * @returns The string having each proper format by pointer
- */
- virtual int GetString(hchar *hstr, int slen = 255);
+
+ virtual hchar_string GetString();
private:
static int boxCount;
};
@@ -168,10 +164,8 @@ struct DateCode: public HBox
DateCode();
virtual int Read(HWPFile &hwpf);
-/**
- * @returns Length of date string
- */
- virtual int GetString(hchar *hstr, int slen = 255);
+
+ virtual hchar_string GetString();
};
/**
@@ -409,8 +403,8 @@ struct TxtBox: public FBox
struct Columns
{
int *data;
- int nCount;
- int nTotal;
+ size_t nCount;
+ size_t nTotal;
Columns(){
nCount = 0;
nTotal = INIT_SIZE;
@@ -420,8 +414,12 @@ struct Columns
void AddColumnsSize(){
int *tmp = data;
+ if (nTotal + ADD_AMOUNT < nTotal) // overflow
+ {
+ throw ::std::bad_alloc();
+ }
data = new int[nTotal + ADD_AMOUNT];
- for( int i = 0 ; i < nTotal ; i++ )
+ for (size_t i = 0 ; i < nTotal ; i++)
data[i] = tmp[i];
nTotal += ADD_AMOUNT;
delete[] tmp;
@@ -432,13 +430,13 @@ struct Columns
data[nCount++] = pos;
return;
}
- for( int i = 0 ; i < nCount; i++ ){
+ for (size_t i = 0 ; i < nCount; i++ ) {
if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
return; // Already exist;
if( pos < data[i] ){
if( nCount == nTotal )
AddColumnsSize();
- for( int j = nCount ; j > i ; j-- )
+ for (size_t j = nCount ; j > i ; j--)
data[j] = data[j-1];
data[i] = pos;
nCount++;
@@ -455,7 +453,7 @@ struct Columns
{
if( pos == 0 )
return 0;
- for( int i = 0 ; i < nCount; i++){
+ for (size_t i = 0 ; i < nCount; i++) {
if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
return i;
}
@@ -466,8 +464,8 @@ struct Columns
struct Rows
{
int *data;
- int nCount;
- int nTotal;
+ size_t nCount;
+ size_t nTotal;
Rows(){
nCount = 0;
nTotal = INIT_SIZE;
@@ -477,8 +475,12 @@ struct Rows
void AddRowsSize(){
int *tmp = data;
+ if (nTotal + ADD_AMOUNT < nTotal) // overflow
+ {
+ throw ::std::bad_alloc();
+ }
data = new int[nTotal + ADD_AMOUNT];
- for( int i = 0 ; i < nTotal ; i++ )
+ for (size_t i = 0 ; i < nTotal ; i++)
data[i] = tmp[i];
nTotal += ADD_AMOUNT;
delete[] tmp;
@@ -489,13 +491,13 @@ struct Rows
data[nCount++] = pos;
return;
}
- for( int i = 0 ; i < nCount; i++ ){
+ for (size_t i = 0 ; i < nCount; i++) {
if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
return; // Already exist;
if( pos < data[i] ){
if( nCount == nTotal )
AddRowsSize();
- for( int j = nCount ; j > i ; j-- )
+ for (size_t j = nCount ; j > i ; j--)
data[j] = data[j-1];
data[i] = pos;
nCount++;
@@ -512,7 +514,7 @@ struct Rows
{
if( pos == 0 )
return 0;
- for( int i = 0 ; i < nCount; i++){
+ for (size_t i = 0 ; i < nCount; i++) {
if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
return i;
}
@@ -866,7 +868,7 @@ struct MailMerge: public HBox
MailMerge();
virtual int Read(HWPFile &hwpf);
- virtual int GetString(hchar *, int slen = 255);
+ virtual hchar_string GetString();
};
// char compositon(23)
@@ -1004,7 +1006,7 @@ class Outline: public HBox
Outline();
virtual int Read(HWPFile &hwpf);
- hchar *GetUnicode(hchar *, int slen = 255);
+ hchar_string GetUnicode() const;
};
/* ¹À½ ºóÄ(30) */
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.cpp Mon Aug 20 11:46:19 2012
@@ -1198,49 +1198,46 @@ hchar ksc5601_han_to_ucs2 (hchar input)
return '?';
}
-hchar* hstr2ucsstr(hchar* hstr, hchar* ubuf)
+hchar_string hstr2ucsstr(hchar const* hstr)
{
- int i = 0, j;
- int res;
- hchar dest[3];
- hchar *tmp = ubuf;
- for( ; *hstr ; ){
- res = hcharconv(*hstr++, dest, UNICODE);
- for( j = 0 ; j < res ; j++)
- tmp[i++] = dest[j];
- }
-
- tmp[i]= '\0';
- return ubuf;
+ hchar_string ret;
+ hchar dest[3];
+ for( ; *hstr ; ){
+ int const res = hcharconv(*hstr++, dest, UNICODE);
+ for (int j = 0 ; j < res ; j++) {
+ ret.push_back(dest[j]);
+ }
+ }
+ return ret;
}
+
/**
* ÇÑÄĽºÆ®¸µÀ» ¿Ï¼ºÇü½ºÆ®¸µÀ¸·Î º¯È¯ÇÑ´Ù
*/
-int hstr2ksstr(hchar* hstr, char* buf)
+::std::string hstr2ksstr(hchar const* hstr)
{
-
- int i = 0, res, j;
+ ::std::string ret;
+ int res, j;
int c;
hchar dest[3];
- char *tmp = buf;
for( ; *hstr ; )
{
res = hcharconv(*hstr++, dest, KS);
for( j = 0 ; j < res ; j++ ){
c = dest[j];
if( c < 32 ) c = ' ';
- else if( c < 256 )
- tmp[i++] = sal::static_int_cast<char>(c);
+ else if( c < 256 )
+ {
+ ret.push_back(sal::static_int_cast<char>(c));
+ }
else
{
- tmp[i++] = sal::static_int_cast<char>((c >> 8 ) & 0xff);
- tmp[i++] = sal::static_int_cast<char>(c & 0xff);
+ ret.push_back(sal::static_int_cast<char>((c >> 8 ) & 0xff));
+ ret.push_back(sal::static_int_cast<char>(c & 0xff));
}
}
}
- tmp[i]= '\0';
-
- return i;
+ return ret;
}
@@ -1248,25 +1245,22 @@ int hstr2ksstr(hchar* hstr, char* buf)
* Çѱۿ¡¼ ¿µ¹®¿ÜÀÇ ¹®ÀÚ±îÁö Æ÷ÇÔÇÒ ¼ö ÀÖ´Â kcharŸÀÔÀÇ ¹®ÀÚ¿À»
* Çѱۿ¡¼ »ç¿ëÇÏ´Â hcharŸÀÔÀÇ ¹®ÀÚ¿·Î º¯È¯ÇÑ´Ù.
*/
-unsigned short *kstr2hstr( unsigned char *src, unsigned short *dest )
+hchar_string kstr2hstr(unsigned char const* src)
{
- int i=0, ii;
- unsigned short* tmp = dest;
-
- for(i=0,ii=0 ; src[i] != '\0' ; i++,ii++ )
+ hchar_string ret;
+ for (unsigned int i = 0; src[i] != '\0' ; i++)
{
if ( src[i] < 127 )
{
- tmp[ii] = src[i];
+ ret.push_back(src[i]);
}
else
{
- tmp[ii] = src[i] << 8 | src[i+1];
+ ret.push_back(src[i] << 8 | src[i+1]);
i++;
}
}
- tmp[ii] = '\0';
- return dest;
+ return ret;
}
@@ -1338,119 +1332,87 @@ char *hcolor2str(uchar color, uchar shad
}
-char *urltounix(const char *src, char *dest )
+::std::string urltounix(const char *src)
{
+ ::std::string ret;
+ unsigned int i = 0;
if( src[0] == 'C' && src[1] == ':' && src[2] == '\\' ) // Home Dir
{
- unsigned int i, len;
- sprintf(dest,"file://%s/", getenv("HOME") );
- len = strlen( dest );
-
- for( i = 0 ; i + 3 < strlen(src) ; i++ )
- {
- if( src[i + 3] == '\\')
- dest[i + len] = '/';
- else
- dest[i + len] = src[ i +3];
- }
- dest[i + len] = '\0';
- return dest;
+ ret.append("file://");
+ ret.append(getenv("HOME"));
+ ret.push_back('/');
+ i = 3; // skip first 3
}
else if( src[0] == 'D' && src[1] == ':' && src[2] == '\\' ) // Root Dir
{
- unsigned int i, len;
- sprintf(dest,"file:///");
- len = strlen( dest );
- for( i = 0 ; i + 3 < strlen(src) ; i++ )
- {
- if( src[i + 3] == '\\')
- dest[i + len] = '/';
- else
- dest[i + len] = src[i+3];
- }
- dest[i + len] = '\0';
- return dest;
+ ret.append("file:///");
+ i = 3; // skip first 3
}
else if( !strncmp(src,"http",4) ) // Start from "http"
- {
- unsigned int i;
- for( i = 0 ; i < strlen(src) ; i++ )
- {
- if( src[i] == '\\')
- dest[i] = '/';
- else
- dest[i] = src[i];
- }
- dest[i] = '\0';
- return dest;
+ {
+ // nothing special here, just copy
}
else
{
- unsigned int i, len, srclen;
- srclen = strlen(src);
- char ext[4];
- strncpy(ext,src + srclen - 3,3);
- ext[3]=0;
+ unsigned int srclen = strlen(src);
+ if (3 < srclen)
+ {
+ char const*const ext = src + (srclen-3);
#ifdef _WIN32
- if( _strnicmp(ext,"HWP",3) && _strnicmp(ext,"HWT",3))
+ if (_strnicmp(ext,"HWP",3) && _strnicmp(ext,"HWT",3))
#else
- if( strcasecmp(ext,"HWP") && strcasecmp(ext,"HWT"))
+ if (strcasecmp(ext,"HWP") && strcasecmp(ext,"HWT"))
#endif
- sprintf(dest, "http://");
- len = strlen(dest);
- for( i = 0 ; i < strlen(src) ; i++ )
- {
- if( src[i] == '\\')
- dest[i+len] = '/';
- else
- dest[i+len] = src[i];
+ {
+ ret.append("http://");
+ }
}
- dest[i+len] = '\0';
- return dest;
}
+ for (; i < strlen(src); i++)
+ {
+ if (src[i] == '\\') {
+ ret.push_back('/');
+ } else {
+ ret.push_back(src[i]);
+ }
+ }
+ return ret;
}
#ifdef _WIN32
-char *urltowin(const char *src, char *dest )
+::std::string urltowin(const char *src)
{
+ std::string ret;
if( !_strnicmp(src, "http", 4))
{
- int i;
- for( i = 0 ; i < sal::static_int_cast<int>(strlen(src)) ; i++ )
- {
- if( src[i] == '\\')
- dest[i] = '/';
- else
- dest[i] = src[i];
- }
- dest[i] = '\0';
- return dest;
+ // nothing special here, just copy
}
else
{
- int i, len, srclen;
- srclen = strlen(src);
- char ext[4];
- strncpy(ext,src + srclen - 3,3);
- ext[3]=0;
- //printf("hcode.cpp : ext = %s\n",ext);
-
- if( !_strnicmp(ext,"HWP",3) || !_strnicmp(ext,"HWT",3)){
- strcpy(dest,src);
- return dest;
- }
- sprintf(dest, "http://");
- len = strlen(dest);
- for( i = 0 ; i < sal::static_int_cast<int>(strlen(src)) ; i++ )
+ unsigned int srclen = strlen(src);
+ if (3 < srclen)
{
- if( src[i] == '\\')
- dest[i+len] = '/';
+ char const*const ext = src + (srclen-3);
+ if (_strnicmp(ext,"HWP",3) && _strnicmp(ext,"HWT",3))
+ {
+ ret.append("http://");
+ }
else
- dest[i+len] = src[i];
+ {
+ ret.append(src); // no backslash conversion
+ return ret;
+ }
}
- dest[i+len] = '\0';
- return dest;
}
+ for (unsigned int i = 0; i < strlen(src); i++)
+ {
+ if (src[i] == '\\') {
+ ret.push_back('/');
+ } else {
+ ret.push_back(src[i]);
+ }
+ }
+ return ret;
}
#endif
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.h
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.h?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.h (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hcode.h Mon Aug 20 11:46:19 2012
@@ -41,27 +41,27 @@ DLLEXPORT int hcharconv(hchar ch, hchar
DLLEXPORT int kssm_hangul_to_ucs2(hchar ch, hchar *dest) ;
DLLEXPORT hchar ksc5601_han_to_ucs2 (hchar);
DLLEXPORT hchar ksc5601_sym_to_ucs2 (hchar);
-DLLEXPORT hchar* hstr2ucsstr(hchar* hstr, hchar* ubuf);
+DLLEXPORT hchar_string hstr2ucsstr(hchar const* hstr);
/**
* ÇÑÄĽºÆ®¸µÀ» ¿Ï¼ºÇü½ºÆ®¸µÀ¸·Î º¯È¯ÇÑ´Ù.
*/
-DLLEXPORT int hstr2ksstr(hchar* hstr, char* buf);
+DLLEXPORT ::std::string hstr2ksstr(hchar const* hstr);
/**
* ÇѱÛÀ» Æ÷ÇÔÇÒ ¼ö ÀÖ´Â charÇü½ºÆ®¸µÀ» ÇÑÄĽºÆ®¸µÀ¸·Î º¯È¯ÇÑ´Ù.
*/
-DLLEXPORT hchar *kstr2hstr( uchar *src, hchar *dest );
+DLLEXPORT hchar_string kstr2hstr(uchar const* src);
/**
* hwpÀÇ °æ·Î¸¦ unixÇüÅ·Π¹Ù²Û´Ù.
*/
-DLLEXPORT char *urltounix(const char *src, char *buf );
+DLLEXPORT ::std::string urltounix(const char *src);
/**
* hwpÀÇ °æ·Î¸¦ windowsÇüÅ·Π¹Ù²Û´Ù.
*/
#ifdef _WIN32
-DLLEXPORT char *urltowin(const char *src, char *buf );
+DLLEXPORT ::std::string urltowin(const char *src);
#endif
/**
* Transfer interger to string following format
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hpara.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hpara.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hpara.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hpara.cpp Mon Aug 20 11:46:19 2012
@@ -22,9 +22,11 @@
/* $Id: hpara.cpp,v 1.6 2008-06-04 09:59:35 vg Exp $ */
-
+#define NOMINMAX
#include "precompile.h"
+#include <comphelper/newarray.hxx>
+
#include "hwplib.h"
#include "hwpfile.h"
#include "hpara.h"
@@ -116,7 +118,8 @@ int HWPPara::Read(HWPFile & hwpf, unsign
pshape.pagebreak = etcflag;
}
- linfo = new LineInfo[nline];
+ linfo = ::comphelper::newArray_null<LineInfo>(nline);
+ if (!linfo) { return false; }
for (ii = 0; ii < nline; ii++)
{
linfo[ii].Read(hwpf, this);
@@ -143,7 +146,7 @@ int HWPPara::Read(HWPFile & hwpf, unsign
if (contain_cshape)
{
- cshapep = new CharShape[nch];
+ cshapep = ::comphelper::newArray_null<CharShape>(nch);
if (!cshapep)
{
perror("Memory Allocation: cshape\n");
@@ -167,7 +170,8 @@ int HWPPara::Read(HWPFile & hwpf, unsign
}
}
// read string
- hhstr = new HBox *[nch];
+ hhstr = ::comphelper::newArray_null<HBox *>(nch);
+ if (!hhstr) { return false; }
for (ii = 0; ii < nch; ii++)
hhstr[ii] = 0;
ii = 0;
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hstyle.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hstyle.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hstyle.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hstyle.cpp Mon Aug 20 11:46:19 2012
@@ -23,8 +23,11 @@
/* $Id: hstyle.cpp,v 1.3 2008-04-10 12:07:14 rt Exp $ */
+#define NOMINMAX
#include "precompile.h"
+#include <comphelper/newarray.hxx>
+
#include "hwplib.h"
#include "hwpfile.h"
#include "hstyle.h"
@@ -129,7 +132,7 @@ bool HWPStyle::Read(HWPFile & hwpf)
ParaShape pshape;
hwpf.Read2b(&nstyles, 1);
- style = new StyleData[nstyles];
+ style = ::comphelper::newArray_null<StyleData>(nstyles);
if (!style)
return false;
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/htags.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/htags.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/htags.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/htags.cpp Mon Aug 20 11:46:19 2012
@@ -41,7 +41,6 @@
#include "hwplib.h"
#include "hwpfile.h"
#include "htags.h"
-#include "himgutil.h"
bool HyperText::Read(HWPFile & hwpf)
{
@@ -75,11 +74,6 @@ EmPicture::EmPicture(int tsize):size(tsi
#endif
EmPicture::~EmPicture(void)
{
-// clear temporary image file
- char *fname = (char *) GetEmbImgname(this);
-
- if (fname && access(fname, 0) == 0)
- unlink(fname);
if (data)
delete[]data;
};
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hwpeq.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hwpeq.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hwpeq.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hwpeq.cpp Mon Aug 20 11:46:19 2012
@@ -678,7 +678,7 @@ static bool eq_sentence(MzString& outs,
static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
{
MzString white, token;
- char key[20];
+ char key[256];
int ch, result;
hwpeq *eq = 0;
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hwplib.h
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hwplib.h?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hwplib.h (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hwplib.h Mon Aug 20 11:46:19 2012
@@ -26,6 +26,9 @@
#ifndef _HWPLIB_H_
#define _HWPLIB_H_
#include "precompile.h"
+
+#include <string>
+
/* hwp96ºÎÅÍ hunit°¡ 4byte°¡ µÇ¾ú´Ù. */
/**
* size of hunit is 4 since hwp96 version
@@ -56,6 +59,8 @@ typedef unsigned int uint;
typedef unsigned long ulong;
#endif /* _UTYPE_ */
+typedef ::std::basic_string<hchar> hchar_string;
+
#ifndef _ZZRECT_
#define _ZZRECT_
/**
Modified: incubator/ooo/branches/writer001/main/hwpfilter/source/hwpread.cpp
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/hwpfilter/source/hwpread.cpp?rev=1374979&r1=1374978&r2=1374979&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/hwpfilter/source/hwpread.cpp (original)
+++ incubator/ooo/branches/writer001/main/hwpfilter/source/hwpread.cpp Mon Aug 20 11:46:19 2012
@@ -23,8 +23,11 @@
/* $Id: hwpread.cpp,v 1.5 2008-04-10 12:10:14 rt Exp $ */
+#define NOMINMAX
#include "precompile.h"
+#include <comphelper/newarray.hxx>
+
#include "list.hxx"
#include "hwpfile.h"
@@ -83,20 +86,30 @@ int FieldCode::Read(HWPFile & hwpf)
hwpf.Read4b(&len3, 1);
hwpf.Read4b(&binlen, 1);
- str1 = new hchar[len1];
- str2 = new hchar[len2];
- str3 = new hchar[len3];
+ ulong const len1_ = ((len1 > 1024) ? 1024 : len1) / sizeof(hchar);
+ ulong const len2_ = ((len2 > 1024) ? 1024 : len2) / sizeof(hchar);
+ ulong const len3_ = ((len3 > 1024) ? 1024 : len3) / sizeof(hchar);
+
+ str1 = new hchar[len1_ ? len1_ : 1];
+ str2 = new hchar[len2_ ? len2_ : 1];
+ str3 = new hchar[len3_ ? len3_ : 1];
bin = new char[binlen];
- hwpf.Read2b(str1, len1/2);
- hwpf.Read2b(str2, len2/2);
- hwpf.Read2b(str3, len3/2);
+ hwpf.Read2b(str1, len1_);
+ hwpf.SkipBlock(len1 - (len1_ * sizeof(hchar)));
+ str1[len1_ ? (len1_ - 1) : 0] = 0;
+ hwpf.Read2b(str2, len2_);
+ hwpf.SkipBlock(len2 - (len2_ * sizeof(hchar)));
+ str2[len2_ ? (len2_ - 1) : 0] = 0;
+ hwpf.Read2b(str3, len3_);
+ hwpf.SkipBlock(len3 - (len3_ * sizeof(hchar)));
+ str3[len3_ ? (len3_ - 1) : 0] = 0;
hwpf.ReadBlock(bin, binlen);
if( type[0] == 3 && type[1] == 2 ){ /* ¸¸µç³¯Â¥·Î¼ Æ÷¸ËÀ» »ý¼ºÇØ¾ß ÇÑ´Ù. */
DateCode *pDate = new DateCode;
- for( int i = 0 ;i < (int)(len3/2) ; i++ ){
+ for (int i = 0 ; i < static_cast<int>(len3_); i++) {
if(str3[i] == 0 ) break;
if( i >= DATE_SIZE ) break;
pDate->format[i] = str3[i];
@@ -283,7 +296,10 @@ int TxtBox::Read(HWPFile & hwpf)
return hwpf.SetState(HWP_InvalidFileFormat);
}
- cell = new Cell[ncell];
+ cell = ::comphelper::newArray_null<Cell>(ncell);
+ if (!cell) {
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
for (ii = 0; ii < ncell; ii++)
{
cell[ii].Read(hwpf);
@@ -291,7 +307,10 @@ int TxtBox::Read(HWPFile & hwpf)
}
if (ncell == 1)
style.cell = &cell[0];
- plists = new LinkedList < HWPPara >[ncell];
+ plists = ::comphelper::newArray_null< LinkedList< HWPPara > >(ncell);
+ if (!plists) {
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
for (ii = 0; ii < ncell; ii++)
hwpf.ReadParaList(plists[ii]);
// caption
@@ -306,7 +325,10 @@ int TxtBox::Read(HWPFile & hwpf)
tbl->rows.insert(cell[ii].y);
tbl->rows.insert(cell[ii].y + cell[ii].h);
}
- TCell* *pArr = new TCell*[ncell];
+ TCell* *pArr = ::comphelper::newArray_null<TCell *>(ncell);
+ if (!pArr) {
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
for( ii = 0 ; ii < ncell; ii++)
{
TCell *tcell = new TCell;