diff options
author | Christian Lippka <cl@openoffice.org> | 2002-06-04 07:27:50 +0000 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2002-06-04 07:27:50 +0000 |
commit | 7c00e325d711522714eb7e84964abd30c8976ef6 (patch) | |
tree | 6d6cc52688d69cf9a9899094cbd902e8b14738f2 /xmloff | |
parent | 873148a351efa5c92a96d9b5a031b29e8f7e9cc0 (diff) |
#99870# create graphic and object resolver on demand
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 51 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 74 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 8 |
3 files changed, 112 insertions, 21 deletions
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index a0f8561d73d6..de5ded5f2817 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlexp.cxx,v $ * - * $Revision: 1.94 $ + * $Revision: 1.95 $ * - * last change: $Author: sab $ $Date: 2001-11-26 07:58:54 $ + * last change: $Author: cl $ $Date: 2002-06-04 08:25:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -937,6 +937,41 @@ void SvXMLExport::SetBodyAttributes() sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) { + bool bOwnGraphicResolver = false; + bool bOwnEmbeddedResolver = false; + + if( !xGraphicResolver.is() || !xEmbeddedResolver.is() ) + { + Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY ); + if( xFactory.is() ) + { + try + { + if( !xGraphicResolver.is() ) + { + xGraphicResolver = Reference< XGraphicObjectResolver >::query( + xFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.document.ExportGraphicObjectResolver")))); + bOwnGraphicResolver = xGraphicResolver.is; + } + + if( !xEmbeddedResolver.is() ) + { + xEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query( + xFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.document.ExportEmbeddedObjectResolver")))); + bOwnEmbeddedResolver = xEmbeddedResolver.is; + } + } + catch( com::sun::star::uno::Exception& ) + { + } + } + } + + xHandler->startDocument(); // <?xml version="1.0" encoding="UTF-8"?> @@ -1048,6 +1083,18 @@ sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) xHandler->endDocument(); + if( bOwnGraphicResolver ) + { + Reference< XComponent > xComp( xGraphicResolver, UNO_QUERY ); + xComp->dispose(); + } + + if( bOwnEmbeddedResolver ) + { + Reference< XComponent > xComp( xEmbeddedResolver, UNO_QUERY ); + xComp->dispose(); + } + return 0; } diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index cfc29a43eef2..5c657ffd1687 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlimp.cxx,v $ * - * $Revision: 1.61 $ + * $Revision: 1.62 $ * - * last change: $Author: dvo $ $Date: 2001-10-30 15:59:24 $ + * last change: $Author: cl $ $Date: 2002-06-04 08:25:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,6 +125,9 @@ #include "xmlerror.hxx" #endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_ #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #endif @@ -169,6 +172,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; using namespace ::xmloff::token; sal_Char __READONLY_DATA sXML_np__office[] = "_office"; @@ -239,7 +243,10 @@ public: FontToSubsFontConverter hBatsFontConv; FontToSubsFontConverter hMathFontConv; - SvXMLImport_Impl() : hBatsFontConv( 0 ), hMathFontConv( 0 ) {} + bool mbOwnGraphicResolver; + bool mbOwnEmbeddedResolver; + + SvXMLImport_Impl() : hBatsFontConv( 0 ), hMathFontConv( 0 ), mbOwnGraphicResolver( false ), mbOwnEmbeddedResolver( false ) {} ~SvXMLImport_Impl() { if( hBatsFontConv ) @@ -350,7 +357,7 @@ void SvXMLImport::_InitCtor() } SvXMLImport::SvXMLImport( sal_uInt16 nImportFlags ) throw () : - pImpl( 0 ), + pImpl( new SvXMLImport_Impl() ), pNamespaceMap( new SvXMLNamespaceMap ), pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ), pContexts( new SvXMLImportContexts_Impl ), @@ -366,7 +373,7 @@ SvXMLImport::SvXMLImport( sal_uInt16 nImportFlags ) throw () : } SvXMLImport::SvXMLImport( const Reference< XModel > & rModel ) throw () : - pImpl( 0 ), + pImpl( new SvXMLImport_Impl() ), pNamespaceMap( new SvXMLNamespaceMap ), pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ), pContexts( new SvXMLImportContexts_Impl ), @@ -385,7 +392,7 @@ SvXMLImport::SvXMLImport( const Reference< XModel > & rModel ) throw () : SvXMLImport::SvXMLImport( const Reference< XModel > & rModel, const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > & rGraphicObjects ) throw () : - pImpl( 0 ), + pImpl( new SvXMLImport_Impl() ), pNamespaceMap( new SvXMLNamespaceMap ), pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ), pContexts( new SvXMLImportContexts_Impl ), @@ -456,10 +463,9 @@ SvXMLImport::~SvXMLImport() throw () xmloff::token::ResetTokens(); -#ifdef CONV_STAR_FONTS if( pImpl ) delete pImpl; -#endif + if (pEventListener && xModel.is()) xModel->removeEventListener(pEventListener); } @@ -506,6 +512,37 @@ void SAL_CALL SvXMLImport::startDocument( void ) throw( xml::sax::SAXException, uno::RuntimeException ) { RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "{ SvXMLImport::startDocument" ); + + if( !xGraphicResolver.is() || !xEmbeddedResolver.is() ) + { + Reference< lang::XMultiServiceFactory > xFactory( xModel, UNO_QUERY ); + if( xFactory.is() ) + { + try + { + if( !xGraphicResolver.is() ) + { + xGraphicResolver = Reference< XGraphicObjectResolver >::query( + xFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.document.ExportGraphicObjectResolver")))); + pImpl->mbOwnGraphicResolver = xGraphicResolver.is; + } + + if( !xEmbeddedResolver.is() ) + { + xEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query( + xFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.document.ExportEmbeddedObjectResolver")))); + pImpl->mbOwnEmbeddedResolver = xEmbeddedResolver.is; + } + } + catch( com::sun::star::uno::Exception& ) + { + } + } + } } void SAL_CALL SvXMLImport::endDocument( void ) @@ -513,6 +550,18 @@ void SAL_CALL SvXMLImport::endDocument( void ) { RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "} SvXMLImport::startDocument" ); + if( pImpl->mbOwnGraphicResolver ) + { + Reference< lang::XComponent > xComp( xGraphicResolver, UNO_QUERY ); + xComp->dispose(); + } + + if( pImpl->mbOwnEmbeddedResolver ) + { + Reference< lang::XComponent > xComp( xEmbeddedResolver, UNO_QUERY ); + xComp->dispose(); + } + if ( pXMLErrors != NULL ) { pXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE ); @@ -1267,11 +1316,8 @@ void SvXMLImport::_CreateDataStylesImport() sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c ) { sal_Unicode cNew = c; - if( !pImpl || !pImpl->hBatsFontConv ) + if( !pImpl->hBatsFontConv ) { - if( !pImpl ) - pImpl = new SvXMLImport_Impl; - OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) ); pImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats, FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); @@ -1288,10 +1334,8 @@ sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c ) sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c ) { sal_Unicode cNew = c; - if( !pImpl || !pImpl->hMathFontConv ) + if( !pImpl->hMathFontConv ) { - if( !pImpl ) - pImpl = new SvXMLImport_Impl; OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) ); pImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath, FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 3fa6e229646b..9a9f32d37097 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlexp.cxx,v $ * - * $Revision: 1.79 $ + * $Revision: 1.80 $ * - * last change: $Author: cl $ $Date: 2001-12-17 15:51:30 $ + * last change: $Author: cl $ $Date: 2002-06-04 08:25:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2500,7 +2500,7 @@ OUString SAL_CALL SdImpressXMLExport_getImplementationName() throw() uno::Reference< uno::XInterface > SAL_CALL SdImpressXMLExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ) { - return (cppu::OWeakObject*)new SdXMLExport( sal_False ); + return (cppu::OWeakObject*)new SdXMLExport( sal_False, EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED ); } uno::Sequence< OUString > SAL_CALL SdDrawXMLExport_getSupportedServiceNames() throw() @@ -2517,7 +2517,7 @@ OUString SAL_CALL SdDrawXMLExport_getImplementationName() throw() uno::Reference< uno::XInterface > SAL_CALL SdDrawXMLExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ) { - return (cppu::OWeakObject*)new SdXMLExport( sal_True ); + return (cppu::OWeakObject*)new SdXMLExport( sal_True, EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED ); } ////////////////////////////////////////////////////////////////////////////// |