163bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 363bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 463bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 563bba73cSAndrew Rist * distributed with this work for additional information 663bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 763bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 863bba73cSAndrew Rist * "License"); you may not use this file except in compliance 963bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1163bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1363bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 1463bba73cSAndrew Rist * software distributed under the License is distributed on an 1563bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1663bba73cSAndrew Rist * KIND, either express or implied. See the License for the 1763bba73cSAndrew Rist * specific language governing permissions and limitations 1863bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 2063bba73cSAndrew Rist *************************************************************/ 2163bba73cSAndrew Rist 2263bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifdef PRECOMPILED 28cdf0e10cSrcweir #include "filt_pch.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx" 31cdf0e10cSrcweir #include <osl/mutex.hxx> 32cdf0e10cSrcweir #include <rtl/uuid.h> 33cdf0e10cSrcweir #include <tools/debug.hxx> 34cdf0e10cSrcweir #include <tools/urlobj.hxx> 35cdf0e10cSrcweir #include <comphelper/genericpropertyset.hxx> 36cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 37cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 38cdf0e10cSrcweir #include <com/sun/star/document/XBinaryStreamResolver.hpp> 39cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp> 40cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp> 41cdf0e10cSrcweir #include <com/sun/star/uri/UriReferenceFactory.hpp> 42cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 43cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 44cdf0e10cSrcweir #include <xmloff/attrlist.hxx> 45cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 46cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 47cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 48cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 49cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 50cdf0e10cSrcweir #include <xmloff/xmlnumfe.hxx> 51cdf0e10cSrcweir #include <xmloff/xmlmetae.hxx> 52cdf0e10cSrcweir #include <xmloff/XMLSettingsExportContext.hxx> 53cdf0e10cSrcweir #include <xmloff/families.hxx> 54cdf0e10cSrcweir #include <xmloff/XMLEventExport.hxx> 55cdf0e10cSrcweir #include "XMLStarBasicExportHandler.hxx" 56cdf0e10cSrcweir #include "XMLScriptExportHandler.hxx" 57cdf0e10cSrcweir #include <xmloff/SettingsExportHelper.hxx> 58cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 59cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 60cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp> 61cdf0e10cSrcweir #include <com/sun/star/document/XViewDataSupplier.hpp> 62cdf0e10cSrcweir #include <xmloff/GradientStyle.hxx> 63cdf0e10cSrcweir #include <xmloff/HatchStyle.hxx> 64cdf0e10cSrcweir #include <xmloff/ImageStyle.hxx> 65cdf0e10cSrcweir #include <TransGradientStyle.hxx> 66cdf0e10cSrcweir #include <xmloff/MarkerStyle.hxx> 67cdf0e10cSrcweir #include <xmloff/DashStyle.hxx> 68cdf0e10cSrcweir #include <xmloff/XMLFontAutoStylePool.hxx> 69cdf0e10cSrcweir #include "XMLImageMapExport.hxx" 70cdf0e10cSrcweir #include "XMLBase64Export.hxx" 71cdf0e10cSrcweir #include "xmloff/xmlerror.hxx" 72cdf0e10cSrcweir #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> 73cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 74cdf0e10cSrcweir #include "xmloff/XMLFilterServiceNames.h" 75cdf0e10cSrcweir #include "xmloff/XMLEmbeddedObjectExportFilter.hxx" 76cdf0e10cSrcweir #include "XMLBasicExportFilter.hxx" 77cdf0e10cSrcweir #include <vos/mutex.hxx> 78cdf0e10cSrcweir #include <rtl/logfile.hxx> 79cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 80cdf0e10cSrcweir #include <comphelper/extract.hxx> 81cdf0e10cSrcweir #include "PropertySetMerger.hxx" 82cdf0e10cSrcweir 83cdf0e10cSrcweir #include "svl/urihelper.hxx" 84cdf0e10cSrcweir #include "xmloff/xformsexport.hxx" 85cdf0e10cSrcweir 86cdf0e10cSrcweir #include <unotools/docinfohelper.hxx> 87cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 88cdf0e10cSrcweir #include <unotools/configmgr.hxx> 89cdf0e10cSrcweir #include <tools/inetdef.hxx> 90cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 91cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 92cdf0e10cSrcweir 93cdf0e10cSrcweir #include <com/sun/star/rdf/XMetadatable.hpp> 94cdf0e10cSrcweir #include "RDFaExportHelper.hxx" 95cdf0e10cSrcweir 96cdf0e10cSrcweir 97cdf0e10cSrcweir using ::rtl::OUString; 98cdf0e10cSrcweir 99cdf0e10cSrcweir using namespace ::osl; 100cdf0e10cSrcweir using namespace ::com::sun::star; 101cdf0e10cSrcweir using namespace ::com::sun::star::uno; 102cdf0e10cSrcweir using namespace ::com::sun::star::frame; 103cdf0e10cSrcweir using namespace ::com::sun::star::container; 104cdf0e10cSrcweir using namespace ::com::sun::star::lang; 105cdf0e10cSrcweir using namespace ::com::sun::star::document; 106cdf0e10cSrcweir using namespace ::com::sun::star::beans; 107cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 108cdf0e10cSrcweir using namespace ::com::sun::star::io; 109cdf0e10cSrcweir using namespace ::xmloff::token; 110cdf0e10cSrcweir 111cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_1_1[] = "1.1"; 112cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_1_2[] = "1.2"; 113cdf0e10cSrcweir 114cdf0e10cSrcweir const sal_Char *sOpenOfficeOrgProject ="OpenOffice.org_project"; 115cdf0e10cSrcweir 116cdf0e10cSrcweir // #i115030#: the XSLT is not finished, and not available via HTTP 117cdf0e10cSrcweir const sal_Char s_grddl_xsl[] = "http://FIXME"; 118cdf0e10cSrcweir 119cdf0e10cSrcweir #define LOGFILE_AUTHOR "mb93740" 120cdf0e10cSrcweir 121cdf0e10cSrcweir #define XML_MODEL_SERVICE_WRITER "com.sun.star.text.TextDocument" 122cdf0e10cSrcweir #define XML_MODEL_SERVICE_CALC "com.sun.star.sheet.SpreadsheetDocument" 123cdf0e10cSrcweir #define XML_MODEL_SERVICE_DRAW "com.sun.star.drawing.DrawingDocument" 124cdf0e10cSrcweir #define XML_MODEL_SERVICE_IMPRESS "com.sun.star.presentation.PresentationDocument" 125cdf0e10cSrcweir #define XML_MODEL_SERVICE_MATH "com.sun.star.formula.FormulaProperties" 126cdf0e10cSrcweir #define XML_MODEL_SERVICE_CHART "com.sun.star.chart.ChartDocument" 127cdf0e10cSrcweir 128cdf0e10cSrcweir #define XML_USEPRETTYPRINTING "UsePrettyPrinting" 129cdf0e10cSrcweir 130cdf0e10cSrcweir #define C2U(cChar) OUString( RTL_CONSTASCII_USTRINGPARAM(cChar) ) 131cdf0e10cSrcweir 132cdf0e10cSrcweir struct XMLServiceMapEntry_Impl 133cdf0e10cSrcweir { 134cdf0e10cSrcweir const sal_Char *sModelService; 135cdf0e10cSrcweir sal_Int32 nModelServiceLen; 136cdf0e10cSrcweir const sal_Char *sFilterService; 137cdf0e10cSrcweir sal_Int32 nFilterServiceLen; 138cdf0e10cSrcweir }; 139cdf0e10cSrcweir 140cdf0e10cSrcweir #define SERVICE_MAP_ENTRY( app ) \ 141cdf0e10cSrcweir { XML_MODEL_SERVICE_##app, sizeof(XML_MODEL_SERVICE_##app)-1, \ 142cdf0e10cSrcweir XML_EXPORT_FILTER_##app, sizeof(XML_EXPORT_FILTER_##app)-1 } 143cdf0e10cSrcweir 144cdf0e10cSrcweir const XMLServiceMapEntry_Impl aServiceMap[] = 145cdf0e10cSrcweir { 146cdf0e10cSrcweir SERVICE_MAP_ENTRY( WRITER ), 147cdf0e10cSrcweir SERVICE_MAP_ENTRY( CALC ), 148cdf0e10cSrcweir SERVICE_MAP_ENTRY( IMPRESS ),// Impress supports DrawingDocument, too, so 149cdf0e10cSrcweir SERVICE_MAP_ENTRY( DRAW ), // it must appear before Draw 150cdf0e10cSrcweir SERVICE_MAP_ENTRY( MATH ), 151cdf0e10cSrcweir SERVICE_MAP_ENTRY( CHART ), 152cdf0e10cSrcweir { 0, 0, 0, 0 } 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir 155cdf0e10cSrcweir //============================================================================== 156cdf0e10cSrcweir 157cdf0e10cSrcweir class SAL_DLLPRIVATE SettingsExportFacade : public ::xmloff::XMLSettingsExportContext 158cdf0e10cSrcweir { 159cdf0e10cSrcweir public: 160cdf0e10cSrcweir SettingsExportFacade( SvXMLExport& i_rExport ) 161cdf0e10cSrcweir :m_rExport( i_rExport ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir virtual ~SettingsExportFacade() 166cdf0e10cSrcweir { 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, 170cdf0e10cSrcweir const ::rtl::OUString& i_rValue ); 171cdf0e10cSrcweir virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, 172cdf0e10cSrcweir enum ::xmloff::token::XMLTokenEnum i_eValue ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, 175cdf0e10cSrcweir const sal_Bool i_bIgnoreWhitespace ); 176cdf0e10cSrcweir virtual void EndElement( const sal_Bool i_bIgnoreWhitespace ); 177cdf0e10cSrcweir 178cdf0e10cSrcweir virtual void Characters( const ::rtl::OUString& i_rCharacters ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > 181cdf0e10cSrcweir GetServiceFactory() const; 182cdf0e10cSrcweir private: 183cdf0e10cSrcweir SvXMLExport& m_rExport; 184cdf0e10cSrcweir ::std::stack< ::rtl::OUString > m_aElements; 185cdf0e10cSrcweir }; 186cdf0e10cSrcweir 187cdf0e10cSrcweir void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_rValue ); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_eValue ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir void SettingsExportFacade::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir const ::rtl::OUString sElementName( m_rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_CONFIG, GetXMLToken( i_eName ) ) ); 200cdf0e10cSrcweir m_rExport.StartElement( sElementName, i_bIgnoreWhitespace ); 201cdf0e10cSrcweir m_aElements.push( sElementName ); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir void SettingsExportFacade::EndElement( const sal_Bool i_bIgnoreWhitespace ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir const ::rtl::OUString sElementName( m_aElements.top() ); 207cdf0e10cSrcweir m_rExport.EndElement( sElementName, i_bIgnoreWhitespace ); 208cdf0e10cSrcweir m_aElements.pop(); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir void SettingsExportFacade::Characters( const ::rtl::OUString& i_rCharacters ) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir m_rExport.GetDocHandler()->characters( i_rCharacters ); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir Reference< XMultiServiceFactory > SettingsExportFacade::GetServiceFactory() const 217cdf0e10cSrcweir { 218cdf0e10cSrcweir return m_rExport.getServiceFactory(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir //============================================================================== 222cdf0e10cSrcweir 223cdf0e10cSrcweir class SvXMLExportEventListener : public cppu::WeakImplHelper1< 224cdf0e10cSrcweir com::sun::star::lang::XEventListener > 225cdf0e10cSrcweir { 226cdf0e10cSrcweir private: 227cdf0e10cSrcweir SvXMLExport* pExport; 228cdf0e10cSrcweir 229cdf0e10cSrcweir public: 230cdf0e10cSrcweir SvXMLExportEventListener(SvXMLExport* pExport); 231cdf0e10cSrcweir virtual ~SvXMLExportEventListener(); 232cdf0e10cSrcweir 233cdf0e10cSrcweir // XEventListener 234cdf0e10cSrcweir virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException); 235cdf0e10cSrcweir }; 236cdf0e10cSrcweir 237cdf0e10cSrcweir SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport) 238cdf0e10cSrcweir : pExport(pTempExport) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir SvXMLExportEventListener::~SvXMLExportEventListener() 243cdf0e10cSrcweir { 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir // XEventListener 247cdf0e10cSrcweir void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& ) 248cdf0e10cSrcweir throw(uno::RuntimeException) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir if (pExport) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir pExport->DisposingModel(); 253cdf0e10cSrcweir pExport = NULL; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir //============================================================================== 258cdf0e10cSrcweir 259cdf0e10cSrcweir class SvXMLExport_Impl 260cdf0e10cSrcweir { 261cdf0e10cSrcweir public: 262cdf0e10cSrcweir SvXMLExport_Impl(); 263cdf0e10cSrcweir 264cdf0e10cSrcweir ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper; 265cdf0e10cSrcweir uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory; 266cdf0e10cSrcweir rtl::OUString msPackageURI; 267cdf0e10cSrcweir rtl::OUString msPackageURIScheme; 268cdf0e10cSrcweir // --> OD 2006-09-27 #i69627# 269cdf0e10cSrcweir sal_Bool mbOutlineStyleAsNormalListStyle; 270cdf0e10cSrcweir // <-- 271cdf0e10cSrcweir // --> PB 2007-07-06 #i146851# 272cdf0e10cSrcweir sal_Bool mbSaveBackwardCompatibleODF; 273cdf0e10cSrcweir // <-- 274cdf0e10cSrcweir 275cdf0e10cSrcweir uno::Reference< embed::XStorage > mxTargetStorage; 276cdf0e10cSrcweir 277cdf0e10cSrcweir SvtSaveOptions maSaveOptions; 278cdf0e10cSrcweir 279cdf0e10cSrcweir /// relative path of stream in package, e.g. "someobject/content.xml" 280cdf0e10cSrcweir ::rtl::OUString mStreamPath; 281cdf0e10cSrcweir 282cdf0e10cSrcweir const uno::Reference< uno::XComponentContext > mxComponentContext; 283cdf0e10cSrcweir 284cdf0e10cSrcweir /// name of stream in package, e.g., "content.xml" 285cdf0e10cSrcweir ::rtl::OUString mStreamName; 286cdf0e10cSrcweir 287cdf0e10cSrcweir /// stack of backed up namespace maps 288cdf0e10cSrcweir /// long: depth at which namespace map has been backed up into the stack 289cdf0e10cSrcweir ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps; 290cdf0e10cSrcweir /// counts depth (number of open elements/start tags) 291cdf0e10cSrcweir long mDepth; 292cdf0e10cSrcweir 293cdf0e10cSrcweir ::std::auto_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper; 294cdf0e10cSrcweir 295cdf0e10cSrcweir // --> OD 2008-11-26 #158694# 296cdf0e10cSrcweir sal_Bool mbExportTextNumberElement; 297cdf0e10cSrcweir // <-- 298cdf0e10cSrcweir sal_Bool mbNullDateInitialized; 299cdf0e10cSrcweir 300cdf0e10cSrcweir void SetSchemeOf( const ::rtl::OUString& rOrigFileName ) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir sal_Int32 nSep = rOrigFileName.indexOf(':'); 303cdf0e10cSrcweir if( nSep != -1 ) 304cdf0e10cSrcweir msPackageURIScheme = rOrigFileName.copy( 0, nSep ); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir }; 307cdf0e10cSrcweir 308cdf0e10cSrcweir SvXMLExport_Impl::SvXMLExport_Impl() 309cdf0e10cSrcweir // --> OD 2006-09-27 #i69627# 310cdf0e10cSrcweir : mbOutlineStyleAsNormalListStyle( false ) 311cdf0e10cSrcweir // <-- 312cdf0e10cSrcweir // --> PB 2007-07-06 #i146851# 313cdf0e10cSrcweir ,mbSaveBackwardCompatibleODF( sal_True ) 314cdf0e10cSrcweir // <-- 315cdf0e10cSrcweir ,mxComponentContext( ::comphelper::getProcessComponentContext() ) 316cdf0e10cSrcweir ,mStreamName() 317cdf0e10cSrcweir ,mNamespaceMaps() 318cdf0e10cSrcweir ,mDepth(0) 319cdf0e10cSrcweir ,mpRDFaHelper() // lazy 320cdf0e10cSrcweir // --> OD 2008-11-26 #158694# 321cdf0e10cSrcweir ,mbExportTextNumberElement( sal_False ) 322cdf0e10cSrcweir // <-- 323cdf0e10cSrcweir ,mbNullDateInitialized( sal_False ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir OSL_ENSURE(mxComponentContext.is(), "SvXMLExport: no ComponentContext"); 326cdf0e10cSrcweir if (!mxComponentContext.is()) throw uno::RuntimeException(); 327cdf0e10cSrcweir mxUriReferenceFactory = uri::UriReferenceFactory::create( 328cdf0e10cSrcweir mxComponentContext ); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir //============================================================================== 332cdf0e10cSrcweir 333cdf0e10cSrcweir void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir mxHandler = rHandler; 336cdf0e10cSrcweir mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY ); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir void SvXMLExport::_InitCtor() 340cdf0e10cSrcweir { 341cdf0e10cSrcweir // note: it is not necessary to add XML_NP_XML (it is declared implicitly) 342cdf0e10cSrcweir if( (getExportFlags() & ~EXPORT_OASIS) != 0 ) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE ); 345cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO ); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO ); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 ) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK ); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir if( (getExportFlags() & EXPORT_SETTINGS) != 0 ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG ); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_META|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); 363cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META), XML_NAMESPACE_META ); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE ); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir // namespaces for documents 371cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); 374cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT ); 375cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW ); 376cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_DR3D), GetXMLToken(XML_N_DR3D), XML_NAMESPACE_DR3D ); 377cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG ); 378cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_CHART), GetXMLToken(XML_N_CHART), XML_NAMESPACE_CHART ); 379cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT ); 380cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE ); 381cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_NUMBER),GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER ); 382cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW ); 383cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC ); 384cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_OF), GetXMLToken(XML_N_OF), XML_NAMESPACE_OF ); 385cdf0e10cSrcweir 386cdf0e10cSrcweir if (getDefaultVersion() > SvtSaveOptions::ODFVER_012) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir mpNamespaceMap->Add( 389cdf0e10cSrcweir GetXMLToken(XML_NP_TABLE_EXT), GetXMLToken(XML_N_TABLE_EXT), XML_NAMESPACE_TABLE_EXT); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir } 392cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 ) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH ); 395cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM ); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS) ) != 0 ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_SCRIPT), GetXMLToken(XML_N_SCRIPT), XML_NAMESPACE_SCRIPT ); 400cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM ); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir if( (getExportFlags() & EXPORT_CONTENT ) != 0 ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_XFORMS_1_0), GetXMLToken(XML_N_XFORMS_1_0), XML_NAMESPACE_XFORMS ); 405cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_XSD), GetXMLToken(XML_N_XSD), XML_NAMESPACE_XSD ); 406cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_XSI), GetXMLToken(XML_N_XSI), XML_NAMESPACE_XSI ); 407cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_FIELD), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD ); 408cdf0e10cSrcweir } 409cdf0e10cSrcweir // RDFa: needed for content and header/footer styles 410cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 ) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_XHTML), 413cdf0e10cSrcweir GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML ); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir // GRDDL: to convert RDFa and meta.xml to RDF 416cdf0e10cSrcweir if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir mpNamespaceMap->Add( GetXMLToken(XML_NP_GRDDL), 419cdf0e10cSrcweir GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL ); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir mxAttrList = (xml::sax::XAttributeList*)mpAttrList; 423cdf0e10cSrcweir 424cdf0e10cSrcweir msPicturesPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#Pictures/" ) ); 425cdf0e10cSrcweir msObjectsPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#./" ) ); 426cdf0e10cSrcweir msGraphicObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ); 427cdf0e10cSrcweir msEmbeddedObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) ); 428cdf0e10cSrcweir 429cdf0e10cSrcweir if (mxModel.is() && !mxEventListener.is()) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir mxEventListener.set( new SvXMLExportEventListener(this)); 432cdf0e10cSrcweir mxModel->addEventListener(mxEventListener); 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir // --> OD 2006-03-10 #i51726# - determine model type 436cdf0e10cSrcweir _DetermineModelType(); 437cdf0e10cSrcweir // <-- 438cdf0e10cSrcweir 439cdf0e10cSrcweir mbEnableExperimentalOdfExport = getenv("ENABLE_EXPERIMENTAL_ODF_EXPORT") != NULL; 440cdf0e10cSrcweir 441cdf0e10cSrcweir // --> PB 2007-07-06 #146851# - load mbSaveBackwardCompatibleODF from configuration 442cdf0e10cSrcweir 443cdf0e10cSrcweir // cl: but only if we do export to current oasis format, old openoffice format *must* always be compatible 444cdf0e10cSrcweir if( (getExportFlags() & EXPORT_OASIS) != 0 ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir sal_Bool bTemp = sal_True; 447cdf0e10cSrcweir if ( ::comphelper::ConfigurationHelper::readDirectKey( 448cdf0e10cSrcweir getServiceFactory(), 449cdf0e10cSrcweir C2U("org.openoffice.Office.Common/"), C2U("Save/Document"), C2U("SaveBackwardCompatibleODF"), 450cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY ) >>= bTemp ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir mpImpl->mbSaveBackwardCompatibleODF = bTemp; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir // <-- 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir // --> OD 2006-03-14 #i51726# 459cdf0e10cSrcweir void SvXMLExport::_DetermineModelType() 460cdf0e10cSrcweir { 461cdf0e10cSrcweir meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY; 462cdf0e10cSrcweir 463cdf0e10cSrcweir if ( mxModel.is() ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel ); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir } 468cdf0e10cSrcweir // <-- 469cdf0e10cSrcweir 470cdf0e10cSrcweir // #110680# 471cdf0e10cSrcweir SvXMLExport::SvXMLExport( 472cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 473cdf0e10cSrcweir MapUnit eDfltUnit, const enum XMLTokenEnum eClass, sal_uInt16 nExportFlags ) 474cdf0e10cSrcweir : mpImpl( new SvXMLExport_Impl ), 475cdf0e10cSrcweir // #110680# 476cdf0e10cSrcweir mxServiceFactory(xServiceFactory), 477cdf0e10cSrcweir mpAttrList( new SvXMLAttributeList ), 478cdf0e10cSrcweir mpNamespaceMap( new SvXMLNamespaceMap ), 479cdf0e10cSrcweir // #110680# 480cdf0e10cSrcweir mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ), 481cdf0e10cSrcweir mpNumExport(0L), 482cdf0e10cSrcweir mpProgressBarHelper( NULL ), 483cdf0e10cSrcweir mpEventExport( NULL ), 484cdf0e10cSrcweir mpImageMapExport( NULL ), 485cdf0e10cSrcweir mpXMLErrors( NULL ), 486cdf0e10cSrcweir mbExtended( sal_False ), 487cdf0e10cSrcweir meClass( eClass ), 488cdf0e10cSrcweir mnExportFlags( nExportFlags ), 489cdf0e10cSrcweir mnErrorFlags( ERROR_NO ), 490cdf0e10cSrcweir msWS( GetXMLToken(XML_WS) ), 491cdf0e10cSrcweir mbSaveLinkedSections(sal_True) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); 494cdf0e10cSrcweir _InitCtor(); 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir // #110680# 498cdf0e10cSrcweir SvXMLExport::SvXMLExport( 499cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 500cdf0e10cSrcweir const OUString &rFileName, 501cdf0e10cSrcweir const uno::Reference< xml::sax::XDocumentHandler > & rHandler, 502cdf0e10cSrcweir MapUnit eDfltUnit ) 503cdf0e10cSrcweir : mpImpl( new SvXMLExport_Impl ), 504cdf0e10cSrcweir // #110680# 505cdf0e10cSrcweir mxServiceFactory(xServiceFactory), 506cdf0e10cSrcweir mxHandler( rHandler ), 507cdf0e10cSrcweir mxExtHandler( rHandler, uno::UNO_QUERY ), 508cdf0e10cSrcweir mpAttrList( new SvXMLAttributeList ), 509cdf0e10cSrcweir msOrigFileName( rFileName ), 510cdf0e10cSrcweir mpNamespaceMap( new SvXMLNamespaceMap ), 511cdf0e10cSrcweir // #110680# 512cdf0e10cSrcweir mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ), 513cdf0e10cSrcweir mpNumExport(0L), 514cdf0e10cSrcweir mpProgressBarHelper( NULL ), 515cdf0e10cSrcweir mpEventExport( NULL ), 516cdf0e10cSrcweir mpImageMapExport( NULL ), 517cdf0e10cSrcweir mpXMLErrors( NULL ), 518cdf0e10cSrcweir mbExtended( sal_False ), 519cdf0e10cSrcweir meClass( XML_TOKEN_INVALID ), 520cdf0e10cSrcweir mnExportFlags( 0 ), 521cdf0e10cSrcweir mnErrorFlags( ERROR_NO ), 522cdf0e10cSrcweir msWS( GetXMLToken(XML_WS) ), 523cdf0e10cSrcweir mbSaveLinkedSections(sal_True) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir mpImpl->SetSchemeOf( msOrigFileName ); 526cdf0e10cSrcweir DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); 527cdf0e10cSrcweir _InitCtor(); 528cdf0e10cSrcweir 529cdf0e10cSrcweir if (mxNumberFormatsSupplier.is()) 530cdf0e10cSrcweir mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir // #110680# 534cdf0e10cSrcweir SvXMLExport::SvXMLExport( 535cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 536cdf0e10cSrcweir const OUString &rFileName, 537cdf0e10cSrcweir const uno::Reference< xml::sax::XDocumentHandler > & rHandler, 538cdf0e10cSrcweir const Reference< XModel >& rModel, 539cdf0e10cSrcweir sal_Int16 eDfltUnit ) 540cdf0e10cSrcweir : mpImpl( new SvXMLExport_Impl ), 541cdf0e10cSrcweir // #110680# 542cdf0e10cSrcweir mxServiceFactory(xServiceFactory), 543cdf0e10cSrcweir mxModel( rModel ), 544cdf0e10cSrcweir mxHandler( rHandler ), 545cdf0e10cSrcweir mxExtHandler( rHandler, uno::UNO_QUERY ), 546cdf0e10cSrcweir mxNumberFormatsSupplier (rModel, uno::UNO_QUERY), 547cdf0e10cSrcweir mpAttrList( new SvXMLAttributeList ), 548cdf0e10cSrcweir msOrigFileName( rFileName ), 549cdf0e10cSrcweir mpNamespaceMap( new SvXMLNamespaceMap ), 550cdf0e10cSrcweir // #110680# 551cdf0e10cSrcweir // pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit) ) ), 552cdf0e10cSrcweir mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ), 553cdf0e10cSrcweir mpNumExport(0L), 554cdf0e10cSrcweir mpProgressBarHelper( NULL ), 555cdf0e10cSrcweir mpEventExport( NULL ), 556cdf0e10cSrcweir mpImageMapExport( NULL ), 557cdf0e10cSrcweir mpXMLErrors( NULL ), 558cdf0e10cSrcweir mbExtended( sal_False ), 559cdf0e10cSrcweir meClass( XML_TOKEN_INVALID ), 560cdf0e10cSrcweir mnExportFlags( 0 ), 561cdf0e10cSrcweir mnErrorFlags( ERROR_NO ), 562cdf0e10cSrcweir msWS( GetXMLToken(XML_WS) ), 563cdf0e10cSrcweir mbSaveLinkedSections(sal_True) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir mpImpl->SetSchemeOf( msOrigFileName ); 566cdf0e10cSrcweir DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); 567cdf0e10cSrcweir _InitCtor(); 568cdf0e10cSrcweir 569cdf0e10cSrcweir if (mxNumberFormatsSupplier.is()) 570cdf0e10cSrcweir mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir // #110680# 574cdf0e10cSrcweir SvXMLExport::SvXMLExport( 575cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 576cdf0e10cSrcweir const OUString &rFileName, 577cdf0e10cSrcweir const uno::Reference< xml::sax::XDocumentHandler > & rHandler, 578cdf0e10cSrcweir const Reference< XModel >& rModel, 579cdf0e10cSrcweir const Reference< document::XGraphicObjectResolver >& rEmbeddedGraphicObjects, 580cdf0e10cSrcweir sal_Int16 eDfltUnit ) 581cdf0e10cSrcweir : mpImpl( new SvXMLExport_Impl ), 582cdf0e10cSrcweir // #110680# 583cdf0e10cSrcweir mxServiceFactory(xServiceFactory), 584cdf0e10cSrcweir mxModel( rModel ), 585cdf0e10cSrcweir mxHandler( rHandler ), 586cdf0e10cSrcweir mxExtHandler( rHandler, uno::UNO_QUERY ), 587cdf0e10cSrcweir mxNumberFormatsSupplier (rModel, uno::UNO_QUERY), 588cdf0e10cSrcweir mxGraphicResolver( rEmbeddedGraphicObjects ), 589cdf0e10cSrcweir mpAttrList( new SvXMLAttributeList ), 590cdf0e10cSrcweir msOrigFileName( rFileName ), 591cdf0e10cSrcweir mpNamespaceMap( new SvXMLNamespaceMap ), 592cdf0e10cSrcweir // #110680# 593cdf0e10cSrcweir mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ), 594cdf0e10cSrcweir mpNumExport(0L), 595cdf0e10cSrcweir mpProgressBarHelper( NULL ), 596cdf0e10cSrcweir mpEventExport( NULL ), 597cdf0e10cSrcweir mpImageMapExport( NULL ), 598cdf0e10cSrcweir mpXMLErrors( NULL ), 599cdf0e10cSrcweir mbExtended( sal_False ), 600cdf0e10cSrcweir meClass( XML_TOKEN_INVALID ), 601cdf0e10cSrcweir mnExportFlags( 0 ), 602cdf0e10cSrcweir mnErrorFlags( ERROR_NO ), 603cdf0e10cSrcweir msWS( GetXMLToken(XML_WS) ), 604cdf0e10cSrcweir mbSaveLinkedSections(sal_True) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir mpImpl->SetSchemeOf( msOrigFileName ); 607cdf0e10cSrcweir DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); 608cdf0e10cSrcweir _InitCtor(); 609cdf0e10cSrcweir 610cdf0e10cSrcweir if (mxNumberFormatsSupplier.is()) 611cdf0e10cSrcweir mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier); 612cdf0e10cSrcweir } 613cdf0e10cSrcweir 614cdf0e10cSrcweir SvXMLExport::~SvXMLExport() 615cdf0e10cSrcweir { 616cdf0e10cSrcweir delete mpXMLErrors; 617cdf0e10cSrcweir delete mpImageMapExport; 618cdf0e10cSrcweir delete mpEventExport; 619cdf0e10cSrcweir delete mpNamespaceMap; 620cdf0e10cSrcweir delete mpUnitConv; 621cdf0e10cSrcweir if (mpProgressBarHelper || mpNumExport) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir if (mxExportInfo.is()) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo(); 626cdf0e10cSrcweir if (xPropertySetInfo.is()) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir if (mpProgressBarHelper) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX)); 631cdf0e10cSrcweir OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT)); 632cdf0e10cSrcweir OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT)); 633cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sProgressMax) && 634cdf0e10cSrcweir xPropertySetInfo->hasPropertyByName(sProgressCurrent)) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir sal_Int32 nProgressMax(mpProgressBarHelper->GetReference()); 637cdf0e10cSrcweir sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue()); 638cdf0e10cSrcweir uno::Any aAny; 639cdf0e10cSrcweir aAny <<= nProgressMax; 640cdf0e10cSrcweir mxExportInfo->setPropertyValue(sProgressMax, aAny); 641cdf0e10cSrcweir aAny <<= nProgressCurrent; 642cdf0e10cSrcweir mxExportInfo->setPropertyValue(sProgressCurrent, aAny); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sRepeat)) 645cdf0e10cSrcweir mxExportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat())); 646cdf0e10cSrcweir } 647cdf0e10cSrcweir if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES))) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES)); 650cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats)) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir uno::Sequence<sal_Int32> aWasUsed; 653cdf0e10cSrcweir mpNumExport->GetWasUsed(aWasUsed); 654cdf0e10cSrcweir uno::Any aAny; 655cdf0e10cSrcweir aAny <<= aWasUsed; 656cdf0e10cSrcweir mxExportInfo->setPropertyValue(sWrittenNumberFormats, aAny); 657cdf0e10cSrcweir } 658cdf0e10cSrcweir } 659cdf0e10cSrcweir } 660cdf0e10cSrcweir } 661cdf0e10cSrcweir delete mpProgressBarHelper; 662cdf0e10cSrcweir delete mpNumExport; 663cdf0e10cSrcweir } 664cdf0e10cSrcweir 665cdf0e10cSrcweir xmloff::token::ResetTokens(); 666cdf0e10cSrcweir 667cdf0e10cSrcweir if (mxEventListener.is() && mxModel.is()) 668cdf0e10cSrcweir mxModel->removeEventListener(mxEventListener); 669cdf0e10cSrcweir 670cdf0e10cSrcweir delete mpImpl; 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 674cdf0e10cSrcweir 675cdf0e10cSrcweir // XExporter 676cdf0e10cSrcweir void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc ) 677cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir mxModel = uno::Reference< frame::XModel >::query( xDoc ); 680cdf0e10cSrcweir if( !mxModel.is() ) 681cdf0e10cSrcweir throw lang::IllegalArgumentException(); 682cdf0e10cSrcweir if (mxModel.is() && ! mxEventListener.is()) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir mxEventListener.set( new SvXMLExportEventListener(this)); 685cdf0e10cSrcweir mxModel->addEventListener(mxEventListener); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir if(!mxNumberFormatsSupplier.is() ) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir mxNumberFormatsSupplier = mxNumberFormatsSupplier.query( mxModel ); 691cdf0e10cSrcweir if(mxNumberFormatsSupplier.is() && mxHandler.is()) 692cdf0e10cSrcweir mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier); 693cdf0e10cSrcweir } 694cdf0e10cSrcweir if (mxExportInfo.is()) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo(); 697cdf0e10cSrcweir if (xPropertySetInfo.is()) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM(XML_USEPRETTYPRINTING)); 700cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting)) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting); 703*4082994dSJim Jagielski try 704*4082994dSJim Jagielski { 705cdf0e10cSrcweir if (::cppu::any2bool(aAny)) 706cdf0e10cSrcweir mnExportFlags |= EXPORT_PRETTY; 707cdf0e10cSrcweir else 708cdf0e10cSrcweir mnExportFlags &= ~EXPORT_PRETTY; 709cdf0e10cSrcweir } 710*4082994dSJim Jagielski catch ( lang::IllegalArgumentException& ) 711*4082994dSJim Jagielski { 712*4082994dSJim Jagielski DBG_ERRORFILE("why is bUsePrettyPrint not boolean?"); 713*4082994dSJim Jagielski } 714*4082994dSJim Jagielski } 715cdf0e10cSrcweir 716cdf0e10cSrcweir if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES))) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES)); 719cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats)) 720cdf0e10cSrcweir { 721cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats); 722cdf0e10cSrcweir uno::Sequence<sal_Int32> aWasUsed; 723cdf0e10cSrcweir if(aAny >>= aWasUsed) 724cdf0e10cSrcweir mpNumExport->SetWasUsed(aWasUsed); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir } 727cdf0e10cSrcweir } 728cdf0e10cSrcweir } 729cdf0e10cSrcweir 730cdf0e10cSrcweir // --> PB 2007-07-06 #i146851# 731cdf0e10cSrcweir if ( mpImpl->mbSaveBackwardCompatibleODF ) 732cdf0e10cSrcweir mnExportFlags |= EXPORT_SAVEBACKWARDCOMPATIBLE; 733cdf0e10cSrcweir else 734cdf0e10cSrcweir mnExportFlags &= ~EXPORT_SAVEBACKWARDCOMPATIBLE; 735cdf0e10cSrcweir // <-- 736cdf0e10cSrcweir 737cdf0e10cSrcweir // namespaces for user defined attributes 738cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY ); 739cdf0e10cSrcweir if( xFactory.is() ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir try 742cdf0e10cSrcweir { 743cdf0e10cSrcweir Reference < XInterface > xIfc = 744cdf0e10cSrcweir xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM( 745cdf0e10cSrcweir "com.sun.star.xml.NamespaceMap")) ); 746cdf0e10cSrcweir if( xIfc.is() ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY ); 749cdf0e10cSrcweir if( xNamespaceMap.is() ) 750cdf0e10cSrcweir { 751cdf0e10cSrcweir Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() ); 752cdf0e10cSrcweir 753cdf0e10cSrcweir OUString* pPrefix = aPrefixes.getArray(); 754cdf0e10cSrcweir const sal_Int32 nCount = aPrefixes.getLength(); 755cdf0e10cSrcweir sal_Int32 nIndex; 756cdf0e10cSrcweir OUString aURL; 757cdf0e10cSrcweir 758cdf0e10cSrcweir for( nIndex = 0; nIndex < nCount; ++nIndex, ++pPrefix ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir if( xNamespaceMap->getByName( *pPrefix ) >>= aURL ) 761cdf0e10cSrcweir _GetNamespaceMap().Add( *pPrefix, aURL, XML_NAMESPACE_UNKNOWN ); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir } 764cdf0e10cSrcweir } 765cdf0e10cSrcweir } 766cdf0e10cSrcweir catch( com::sun::star::uno::Exception& ) 767cdf0e10cSrcweir { 768cdf0e10cSrcweir } 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir // --> OD 2006-03-10 #i51726# - determine model type 772cdf0e10cSrcweir _DetermineModelType(); 773cdf0e10cSrcweir // <-- 774cdf0e10cSrcweir } 775cdf0e10cSrcweir 776cdf0e10cSrcweir // XInitialize 777cdf0e10cSrcweir void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments ) 778cdf0e10cSrcweir throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results. 781cdf0e10cSrcweir 782cdf0e10cSrcweir const sal_Int32 nAnyCount = aArguments.getLength(); 783cdf0e10cSrcweir const uno::Any* pAny = aArguments.getConstArray(); 784cdf0e10cSrcweir 785cdf0e10cSrcweir for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ ) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir Reference<XInterface> xValue; 788cdf0e10cSrcweir *pAny >>= xValue; 789cdf0e10cSrcweir 790cdf0e10cSrcweir // status indicator 791cdf0e10cSrcweir uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY ); 792cdf0e10cSrcweir if ( xTmpStatus.is() ) 793cdf0e10cSrcweir mxStatusIndicator = xTmpStatus; 794cdf0e10cSrcweir 795cdf0e10cSrcweir // graphic resolver 796cdf0e10cSrcweir uno::Reference<document::XGraphicObjectResolver> xTmpGraphic( 797cdf0e10cSrcweir xValue, UNO_QUERY ); 798cdf0e10cSrcweir if ( xTmpGraphic.is() ) 799cdf0e10cSrcweir mxGraphicResolver = xTmpGraphic; 800cdf0e10cSrcweir 801cdf0e10cSrcweir // object resolver 802cdf0e10cSrcweir uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver( 803cdf0e10cSrcweir xValue, UNO_QUERY ); 804cdf0e10cSrcweir if ( xTmpObjectResolver.is() ) 805cdf0e10cSrcweir mxEmbeddedResolver = xTmpObjectResolver; 806cdf0e10cSrcweir 807cdf0e10cSrcweir // document handler 808cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler( 809cdf0e10cSrcweir xValue, UNO_QUERY ); 810cdf0e10cSrcweir if( xTmpDocHandler.is() ) 811cdf0e10cSrcweir { 812cdf0e10cSrcweir mxHandler = xTmpDocHandler; 813cdf0e10cSrcweir *pAny >>= mxExtHandler; 814cdf0e10cSrcweir 815cdf0e10cSrcweir if (mxNumberFormatsSupplier.is() && mpNumExport == NULL) 816cdf0e10cSrcweir mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier); 817cdf0e10cSrcweir } 818cdf0e10cSrcweir 819cdf0e10cSrcweir // property set to transport data across 820cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xTmpPropertySet( 821cdf0e10cSrcweir xValue, UNO_QUERY ); 822cdf0e10cSrcweir if( xTmpPropertySet.is() ) 823cdf0e10cSrcweir mxExportInfo = xTmpPropertySet; 824cdf0e10cSrcweir } 825cdf0e10cSrcweir 826cdf0e10cSrcweir if( mxExportInfo.is() ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = 829cdf0e10cSrcweir mxExportInfo->getPropertySetInfo(); 830cdf0e10cSrcweir OUString sPropName( 831cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) ); 832cdf0e10cSrcweir if( xPropertySetInfo->hasPropertyByName(sPropName) ) 833cdf0e10cSrcweir { 834cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue(sPropName); 835cdf0e10cSrcweir aAny >>= msOrigFileName; 836cdf0e10cSrcweir mpImpl->msPackageURI = msOrigFileName; 837cdf0e10cSrcweir mpImpl->SetSchemeOf( msOrigFileName ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir OUString sRelPath; 840cdf0e10cSrcweir sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) ); 841cdf0e10cSrcweir if( xPropertySetInfo->hasPropertyByName(sPropName) ) 842cdf0e10cSrcweir { 843cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue(sPropName); 844cdf0e10cSrcweir aAny >>= sRelPath; 845cdf0e10cSrcweir } 846cdf0e10cSrcweir OUString sName; 847cdf0e10cSrcweir sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) ); 848cdf0e10cSrcweir if( xPropertySetInfo->hasPropertyByName(sPropName) ) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue(sPropName); 851cdf0e10cSrcweir aAny >>= sName; 852cdf0e10cSrcweir } 853cdf0e10cSrcweir if( msOrigFileName.getLength() && sName.getLength() ) 854cdf0e10cSrcweir { 855cdf0e10cSrcweir INetURLObject aBaseURL( msOrigFileName ); 856cdf0e10cSrcweir if( sRelPath.getLength() ) 857cdf0e10cSrcweir aBaseURL.insertName( sRelPath ); 858cdf0e10cSrcweir aBaseURL.insertName( sName ); 859cdf0e10cSrcweir msOrigFileName = aBaseURL.GetMainURL(INetURLObject::DECODE_TO_IURI); 860cdf0e10cSrcweir } 861cdf0e10cSrcweir mpImpl->mStreamName = sName; // Note: may be empty (XSLT) 862cdf0e10cSrcweir 863cdf0e10cSrcweir // --> OD 2006-09-26 #i69627# 864cdf0e10cSrcweir const ::rtl::OUString sOutlineStyleAsNormalListStyle( 865cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("OutlineStyleAsNormalListStyle") ); 866cdf0e10cSrcweir if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) ) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle ); 869cdf0e10cSrcweir aAny >>= (mpImpl->mbOutlineStyleAsNormalListStyle); 870cdf0e10cSrcweir } 871cdf0e10cSrcweir // <-- 872cdf0e10cSrcweir 873cdf0e10cSrcweir OUString sTargetStorage( RTL_CONSTASCII_USTRINGPARAM("TargetStorage") ); 874cdf0e10cSrcweir if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) ) 875cdf0e10cSrcweir mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage; 876cdf0e10cSrcweir 877cdf0e10cSrcweir // --> OD 2008-11-26 #158694# 878cdf0e10cSrcweir const ::rtl::OUString sExportTextNumberElement( 879cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("ExportTextNumberElement") ); 880cdf0e10cSrcweir if( xPropertySetInfo->hasPropertyByName( sExportTextNumberElement ) ) 881cdf0e10cSrcweir { 882cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement ); 883cdf0e10cSrcweir aAny >>= (mpImpl->mbExportTextNumberElement); 884cdf0e10cSrcweir } 885cdf0e10cSrcweir // <-- 886cdf0e10cSrcweir } 887cdf0e10cSrcweir 888cdf0e10cSrcweir } 889cdf0e10cSrcweir 890cdf0e10cSrcweir // XFilter 891cdf0e10cSrcweir sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor ) throw(uno::RuntimeException) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogContext, "xmloff", LOGFILE_AUTHOR, 894cdf0e10cSrcweir "SvXMLExport::filter" ); 895cdf0e10cSrcweir 896cdf0e10cSrcweir // check for xHandler first... should have been supplied in initialize 897cdf0e10cSrcweir if( !mxHandler.is() ) 898cdf0e10cSrcweir return sal_False; 899cdf0e10cSrcweir 900cdf0e10cSrcweir try 901cdf0e10cSrcweir { 902cdf0e10cSrcweir const sal_uInt32 nTest = 903cdf0e10cSrcweir EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS; 904cdf0e10cSrcweir if( (mnExportFlags & nTest) == nTest && !msOrigFileName.getLength() ) 905cdf0e10cSrcweir { 906cdf0e10cSrcweir // evaluate descriptor only for flat files and if a base URI 907cdf0e10cSrcweir // has not been provided already 908cdf0e10cSrcweir const sal_Int32 nPropCount = aDescriptor.getLength(); 909cdf0e10cSrcweir const beans::PropertyValue* pProps = aDescriptor.getConstArray(); 910cdf0e10cSrcweir 911cdf0e10cSrcweir for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ ) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir const OUString& rPropName = pProps->Name; 914cdf0e10cSrcweir const Any& rValue = pProps->Value; 915cdf0e10cSrcweir 916cdf0e10cSrcweir if( rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FileName" ) ) ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir if( !(rValue >>= msOrigFileName ) ) 919cdf0e10cSrcweir return sal_False; 920cdf0e10cSrcweir } 921cdf0e10cSrcweir else if (rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterName" ) ) ) 922cdf0e10cSrcweir { 923cdf0e10cSrcweir if( !(rValue >>= msFilterName ) ) 924cdf0e10cSrcweir return sal_False; 925cdf0e10cSrcweir } 926cdf0e10cSrcweir } 927cdf0e10cSrcweir } 928cdf0e10cSrcweir 929cdf0e10cSrcweir #ifdef TIMELOG 930cdf0e10cSrcweir if (GetModel().is()) 931cdf0e10cSrcweir { 932cdf0e10cSrcweir // print a trace message with the URL 933cdf0e10cSrcweir ByteString aUrl( (String) GetModel()->getURL(), 934cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 935cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "%s", aUrl.GetBuffer() ); 936cdf0e10cSrcweir 937cdf0e10cSrcweir // we also want a trace message with the document class 938cdf0e10cSrcweir ByteString aClass( (String)GetXMLToken(meClass), 939cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 940cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "class=\"%s\"", 941cdf0e10cSrcweir aClass.GetBuffer() ); 942cdf0e10cSrcweir } 943cdf0e10cSrcweir #endif 944cdf0e10cSrcweir 945cdf0e10cSrcweir exportDoc( meClass ); 946cdf0e10cSrcweir } 947cdf0e10cSrcweir catch( uno::Exception e ) 948cdf0e10cSrcweir { 949cdf0e10cSrcweir // We must catch exceptions, because according to the 950cdf0e10cSrcweir // API definition export must not throw one! 951cdf0e10cSrcweir Sequence<OUString> aSeq(0); 952cdf0e10cSrcweir SetError( XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API, 953cdf0e10cSrcweir aSeq, e.Message, NULL ); 954cdf0e10cSrcweir } 955cdf0e10cSrcweir 956cdf0e10cSrcweir // return true only if no error occured 957cdf0e10cSrcweir return (GetErrorFlags() & (ERROR_DO_NOTHING|ERROR_ERROR_OCCURED)) == 0; 958cdf0e10cSrcweir } 959cdf0e10cSrcweir 960cdf0e10cSrcweir void SAL_CALL SvXMLExport::cancel() throw(uno::RuntimeException) 961cdf0e10cSrcweir { 962cdf0e10cSrcweir // stop export 963cdf0e10cSrcweir Sequence<OUString> aEmptySeq; 964cdf0e10cSrcweir SetError(XMLERROR_CANCEL|XMLERROR_FLAG_SEVERE, aEmptySeq); 965cdf0e10cSrcweir } 966cdf0e10cSrcweir 967cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvXMLExport::getName( ) 968cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 969cdf0e10cSrcweir { 970cdf0e10cSrcweir return msFilterName; 971cdf0e10cSrcweir } 972cdf0e10cSrcweir 973cdf0e10cSrcweir void SAL_CALL SvXMLExport::setName( const ::rtl::OUString& ) 974cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 975cdf0e10cSrcweir { 976cdf0e10cSrcweir // do nothing, because it is not possible to set the FilterName 977cdf0e10cSrcweir } 978cdf0e10cSrcweir 979cdf0e10cSrcweir 980cdf0e10cSrcweir // XServiceInfo 981cdf0e10cSrcweir OUString SAL_CALL SvXMLExport::getImplementationName( ) throw(uno::RuntimeException) 982cdf0e10cSrcweir { 983cdf0e10cSrcweir OUString aStr; 984cdf0e10cSrcweir return aStr; 985cdf0e10cSrcweir } 986cdf0e10cSrcweir 987cdf0e10cSrcweir sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName ) throw(uno::RuntimeException) 988cdf0e10cSrcweir { 989cdf0e10cSrcweir return 990cdf0e10cSrcweir rServiceName.equalsAsciiL( 991cdf0e10cSrcweir "com.sun.star.document.ExportFilter", 992cdf0e10cSrcweir sizeof("com.sun.star.document.ExportFilter")-1 ) || 993cdf0e10cSrcweir rServiceName.equalsAsciiL( 994cdf0e10cSrcweir "com.sun.star.xml.XMLExportFilter", 995cdf0e10cSrcweir sizeof("com.sun.star.xml.XMLExportFilter")-1); 996cdf0e10cSrcweir } 997cdf0e10cSrcweir 998cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( ) 999cdf0e10cSrcweir throw(uno::RuntimeException) 1000cdf0e10cSrcweir { 1001cdf0e10cSrcweir uno::Sequence<OUString> aSeq(2); 1002cdf0e10cSrcweir aSeq[0] = OUString( 1003cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter")); 1004cdf0e10cSrcweir aSeq[1] = OUString( 1005cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter")); 1006cdf0e10cSrcweir return aSeq; 1007cdf0e10cSrcweir } 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir ::rtl::OUString 1012cdf0e10cSrcweir SvXMLExport::EnsureNamespace(::rtl::OUString const & i_rNamespace, 1013cdf0e10cSrcweir ::rtl::OUString const & i_rPreferredPrefix) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir ::rtl::OUString sPrefix; 1016cdf0e10cSrcweir sal_uInt16 nKey( _GetNamespaceMap().GetKeyByName( i_rNamespace ) ); 1017cdf0e10cSrcweir if( XML_NAMESPACE_UNKNOWN == nKey ) 1018cdf0e10cSrcweir { 1019cdf0e10cSrcweir // There is no prefix for the namespace, so 1020cdf0e10cSrcweir // we have to generate one and have to add it. 1021cdf0e10cSrcweir sPrefix = i_rPreferredPrefix; 1022cdf0e10cSrcweir nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix ); 1023cdf0e10cSrcweir sal_Int32 n( 0 ); 1024cdf0e10cSrcweir ::rtl::OUStringBuffer buf; 1025cdf0e10cSrcweir while( nKey != USHRT_MAX ) 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir buf.append( i_rPreferredPrefix ); 1028cdf0e10cSrcweir buf.append( ++n ); 1029cdf0e10cSrcweir sPrefix = buf.makeStringAndClear(); 1030cdf0e10cSrcweir nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix ); 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir 1033cdf0e10cSrcweir if (mpImpl->mNamespaceMaps.empty() 1034cdf0e10cSrcweir || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth)) 1035cdf0e10cSrcweir { 1036cdf0e10cSrcweir // top was created for lower depth... need a new namespace map! 1037cdf0e10cSrcweir mpImpl->mNamespaceMaps.push( 1038cdf0e10cSrcweir ::std::make_pair(mpNamespaceMap, mpImpl->mDepth) ); 1039cdf0e10cSrcweir mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap ); 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir // add the namespace to the map and as attribute 1043cdf0e10cSrcweir mpNamespaceMap->Add( sPrefix, i_rNamespace ); 1044cdf0e10cSrcweir buf.append( GetXMLToken(XML_XMLNS) ); 1045cdf0e10cSrcweir buf.append( sal_Unicode(':') ); 1046cdf0e10cSrcweir buf.append( sPrefix ); 1047cdf0e10cSrcweir AddAttribute( buf.makeStringAndClear(), i_rNamespace ); 1048cdf0e10cSrcweir } 1049cdf0e10cSrcweir else 1050cdf0e10cSrcweir { 1051cdf0e10cSrcweir // If there is a prefix for the namespace, reuse that. 1052cdf0e10cSrcweir sPrefix = _GetNamespaceMap().GetPrefixByKey( nKey ); 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir return sPrefix; 1055cdf0e10cSrcweir } 1056cdf0e10cSrcweir 1057cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey, 1060cdf0e10cSrcweir const sal_Char *pName, 1061cdf0e10cSrcweir const sal_Char *pValue ) 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir OUString sName( OUString::createFromAscii( pName ) ); 1064cdf0e10cSrcweir OUString sValue( OUString::createFromAscii( pValue ) ); 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir mpAttrList->AddAttribute( 1067cdf0e10cSrcweir _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), sValue ); 1068cdf0e10cSrcweir } 1069cdf0e10cSrcweir 1070cdf0e10cSrcweir void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName, 1071cdf0e10cSrcweir const OUString& rValue ) 1072cdf0e10cSrcweir { 1073cdf0e10cSrcweir OUString sName( OUString::createFromAscii( pName ) ); 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir mpAttrList->AddAttribute( 1076cdf0e10cSrcweir _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), rValue ); 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName, 1080cdf0e10cSrcweir const OUString& rValue ) 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir mpAttrList->AddAttribute( 1083cdf0e10cSrcweir _GetNamespaceMap().GetQNameByKey( nPrefixKey, rName ), rValue ); 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir 1086cdf0e10cSrcweir void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, 1087cdf0e10cSrcweir enum XMLTokenEnum eName, 1088cdf0e10cSrcweir const OUString& rValue ) 1089cdf0e10cSrcweir { 1090cdf0e10cSrcweir mpAttrList->AddAttribute( 1091cdf0e10cSrcweir _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ), 1092cdf0e10cSrcweir rValue ); 1093cdf0e10cSrcweir } 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, 1096cdf0e10cSrcweir enum XMLTokenEnum eName, 1097cdf0e10cSrcweir enum XMLTokenEnum eValue) 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir mpAttrList->AddAttribute( 1100cdf0e10cSrcweir _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ), 1101cdf0e10cSrcweir GetXMLToken(eValue) ); 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir void SvXMLExport::AddAttribute( const ::rtl::OUString& rQName, 1105cdf0e10cSrcweir const ::rtl::OUString& rValue ) 1106cdf0e10cSrcweir { 1107cdf0e10cSrcweir mpAttrList->AddAttribute( 1108cdf0e10cSrcweir rQName, 1109cdf0e10cSrcweir rValue ); 1110cdf0e10cSrcweir } 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir void SvXMLExport::AddAttribute( const ::rtl::OUString& rQName, 1113cdf0e10cSrcweir enum ::xmloff::token::XMLTokenEnum eValue ) 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir mpAttrList->AddAttribute( 1116cdf0e10cSrcweir rQName, 1117cdf0e10cSrcweir GetXMLToken(eValue) ); 1118cdf0e10cSrcweir } 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir if( xAttrList.is()) 1123cdf0e10cSrcweir mpAttrList->AppendAttributeList( xAttrList ); 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir void SvXMLExport::ClearAttrList() 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir mpAttrList->Clear(); 1129cdf0e10cSrcweir } 1130cdf0e10cSrcweir 1131cdf0e10cSrcweir #ifdef DBG_UTIL 1132cdf0e10cSrcweir void SvXMLExport::CheckAttrList() 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir DBG_ASSERT( !mpAttrList->getLength(), 1135cdf0e10cSrcweir "XMLExport::CheckAttrList: list is not empty" ); 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir #endif 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir void SvXMLExport::ImplExportMeta() 1140cdf0e10cSrcweir { 1141cdf0e10cSrcweir CheckAttrList(); 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir _ExportMeta(); 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir void SvXMLExport::ImplExportSettings() 1147cdf0e10cSrcweir { 1148cdf0e10cSrcweir CheckAttrList(); 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir ::std::list< SettingsGroup > aSettings; 1151cdf0e10cSrcweir sal_Int32 nSettingsCount = 0; 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir // view settings 1154cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aViewSettings; 1155cdf0e10cSrcweir GetViewSettingsAndViews( aViewSettings ); 1156cdf0e10cSrcweir aSettings.push_back( SettingsGroup( XML_VIEW_SETTINGS, aViewSettings ) ); 1157cdf0e10cSrcweir nSettingsCount += aViewSettings.getLength(); 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir // configuration settings 1160cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aConfigSettings; 1161cdf0e10cSrcweir GetConfigurationSettings( aConfigSettings ); 1162cdf0e10cSrcweir aSettings.push_back( SettingsGroup( XML_CONFIGURATION_SETTINGS, aConfigSettings ) ); 1163cdf0e10cSrcweir nSettingsCount += aConfigSettings.getLength(); 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir // any document specific settings 1166cdf0e10cSrcweir nSettingsCount += GetDocumentSpecificSettings( aSettings ); 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir { 1169cdf0e10cSrcweir SvXMLElementExport aElem( *this, 1170cdf0e10cSrcweir nSettingsCount != 0, 1171cdf0e10cSrcweir XML_NAMESPACE_OFFICE, XML_SETTINGS, 1172cdf0e10cSrcweir sal_True, sal_True ); 1173cdf0e10cSrcweir 1174cdf0e10cSrcweir SettingsExportFacade aSettingsExportContext( *this ); 1175cdf0e10cSrcweir XMLSettingsExportHelper aSettingsExportHelper( aSettingsExportContext ); 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir for ( ::std::list< SettingsGroup >::const_iterator settings = aSettings.begin(); 1178cdf0e10cSrcweir settings != aSettings.end(); 1179cdf0e10cSrcweir ++settings 1180cdf0e10cSrcweir ) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir if ( !settings->aSettings.getLength() ) 1183cdf0e10cSrcweir continue; 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir OUString sSettingsName( GetXMLToken( settings->eGroupName ) ); 1186cdf0e10cSrcweir OUString sQName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO, sSettingsName ); 1187cdf0e10cSrcweir aSettingsExportHelper.exportAllSettings( settings->aSettings, sQName ); 1188cdf0e10cSrcweir } 1189cdf0e10cSrcweir } 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir 1192cdf0e10cSrcweir void SvXMLExport::ImplExportStyles( sal_Bool ) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir CheckAttrList(); 1195cdf0e10cSrcweir 1196cdf0e10cSrcweir // AddAttribute( XML_NAMESPACE_NONE, XML_ID, XML_STYLES_ID ); 1197cdf0e10cSrcweir { 1198cdf0e10cSrcweir // <style:styles> 1199cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_STYLES, 1200cdf0e10cSrcweir sal_True, sal_True ); 1201cdf0e10cSrcweir 1202cdf0e10cSrcweir _ExportStyles( sal_False ); 1203cdf0e10cSrcweir } 1204cdf0e10cSrcweir 1205cdf0e10cSrcweir // transfer style names (+ families) TO other components (if appropriate) 1206cdf0e10cSrcweir if( ( ( mnExportFlags & EXPORT_CONTENT ) == 0 ) && mxExportInfo.is() ) 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir static OUString sStyleNames( RTL_CONSTASCII_USTRINGPARAM("StyleNames") ); 1209cdf0e10cSrcweir static OUString sStyleFamilies( RTL_CONSTASCII_USTRINGPARAM("StyleFamilies") ); 1210cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo(); 1211cdf0e10cSrcweir if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) ) 1212cdf0e10cSrcweir { 1213cdf0e10cSrcweir Sequence<sal_Int32> aStyleFamilies; 1214cdf0e10cSrcweir Sequence<OUString> aStyleNames; 1215cdf0e10cSrcweir mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames ); 1216cdf0e10cSrcweir mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) ); 1217cdf0e10cSrcweir mxExportInfo->setPropertyValue( sStyleFamilies, 1218cdf0e10cSrcweir makeAny( aStyleFamilies ) ); 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir } 1221cdf0e10cSrcweir } 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir void SvXMLExport::ImplExportAutoStyles( sal_Bool ) 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir // transfer style names (+ families) FROM other components (if appropriate) 1226cdf0e10cSrcweir OUString sStyleNames( RTL_CONSTASCII_USTRINGPARAM("StyleNames") ); 1227cdf0e10cSrcweir OUString sStyleFamilies( RTL_CONSTASCII_USTRINGPARAM("StyleFamilies") ); 1228cdf0e10cSrcweir if( ( ( mnExportFlags & EXPORT_STYLES ) == 0 ) 1229cdf0e10cSrcweir && mxExportInfo.is() 1230cdf0e10cSrcweir && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames ) 1231cdf0e10cSrcweir && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) ) 1232cdf0e10cSrcweir { 1233cdf0e10cSrcweir Sequence<sal_Int32> aStyleFamilies; 1234cdf0e10cSrcweir mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies; 1235cdf0e10cSrcweir Sequence<OUString> aStyleNames; 1236cdf0e10cSrcweir mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames; 1237cdf0e10cSrcweir mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames ); 1238cdf0e10cSrcweir } 1239cdf0e10cSrcweir 1240cdf0e10cSrcweir // AddAttributeASCII( XML_NAMESPACE_NONE, XML_ID, XML_AUTO_STYLES_ID ); 1241cdf0e10cSrcweir { 1242cdf0e10cSrcweir // <style:automatic-styles> 1243cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, 1244cdf0e10cSrcweir XML_AUTOMATIC_STYLES, sal_True, sal_True ); 1245cdf0e10cSrcweir 1246cdf0e10cSrcweir #if 0 1247cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 1248cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, XML_STYLES_HREF ); 1249cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); 1250cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_ROLE, 1251cdf0e10cSrcweir pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE, 1252cdf0e10cSrcweir GetXMLToken(XML_STYLESHEET)) ); 1253cdf0e10cSrcweir { 1254cdf0e10cSrcweir // <style:use-styles> 1255cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, 1256cdf0e10cSrcweir XML_USE_STYLES, sal_True, sal_True ); 1257cdf0e10cSrcweir } 1258cdf0e10cSrcweir #endif 1259cdf0e10cSrcweir _ExportAutoStyles(); 1260cdf0e10cSrcweir } 1261cdf0e10cSrcweir } 1262cdf0e10cSrcweir 1263cdf0e10cSrcweir void SvXMLExport::ImplExportMasterStyles( sal_Bool ) 1264cdf0e10cSrcweir { 1265cdf0e10cSrcweir { 1266cdf0e10cSrcweir // <style:master-styles> 1267cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, 1268cdf0e10cSrcweir sal_True, sal_True ); 1269cdf0e10cSrcweir 1270cdf0e10cSrcweir _ExportMasterStyles(); 1271cdf0e10cSrcweir } 1272cdf0e10cSrcweir 1273cdf0e10cSrcweir #if 0 1274cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 1275cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, XML_AUTO_STYLES_HREF ); 1276cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); 1277cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XLINK, XML_ROLE, 1278cdf0e10cSrcweir pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE, 1279cdf0e10cSrcweir GetXMLToken(XML_STYLESHEET) ) ); 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir // <style:use-styles> 1282cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, 1283cdf0e10cSrcweir XML_USE_STYLES, sal_True, sal_True ); 1284cdf0e10cSrcweir } 1285cdf0e10cSrcweir #endif 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir void SvXMLExport::ImplExportContent() 1289cdf0e10cSrcweir { 1290cdf0e10cSrcweir CheckAttrList(); 1291cdf0e10cSrcweir 1292cdf0e10cSrcweir CheckAttrList(); 1293cdf0e10cSrcweir 1294cdf0e10cSrcweir { 1295cdf0e10cSrcweir SvXMLElementExport aElemrnt( *this, XML_NAMESPACE_OFFICE, XML_BODY, 1296cdf0e10cSrcweir sal_True, sal_True ); 1297cdf0e10cSrcweir { 1298cdf0e10cSrcweir XMLTokenEnum eClass = meClass; 1299cdf0e10cSrcweir if( XML_TEXT_GLOBAL == eClass ) 1300cdf0e10cSrcweir { 1301cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_TEXT, XML_GLOBAL, 1302cdf0e10cSrcweir GetXMLToken( XML_TRUE ) ); 1303cdf0e10cSrcweir eClass = XML_TEXT; 1304cdf0e10cSrcweir } 1305cdf0e10cSrcweir // <office:body ...> 1306cdf0e10cSrcweir SetBodyAttributes(); 1307cdf0e10cSrcweir SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID, 1308cdf0e10cSrcweir XML_NAMESPACE_OFFICE, eClass, 1309cdf0e10cSrcweir sal_True, sal_True ); 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir _ExportContent(); 1312cdf0e10cSrcweir } 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir } 1315cdf0e10cSrcweir 1316cdf0e10cSrcweir void SvXMLExport::SetBodyAttributes() 1317cdf0e10cSrcweir { 1318cdf0e10cSrcweir } 1319cdf0e10cSrcweir 1320cdf0e10cSrcweir static void 1321cdf0e10cSrcweir lcl_AddGrddl(SvXMLExport & rExport, const sal_Int32 /*nExportMode*/) 1322cdf0e10cSrcweir { 1323cdf0e10cSrcweir // check version >= 1.2 1324cdf0e10cSrcweir switch (rExport.getDefaultVersion()) { 1325cdf0e10cSrcweir case SvtSaveOptions::ODFVER_011: // fall thru 1326cdf0e10cSrcweir case SvtSaveOptions::ODFVER_010: return; 1327cdf0e10cSrcweir default: break; 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir 1330cdf0e10cSrcweir // #i115030#: disabled 1331cdf0e10cSrcweir #if 0 1332cdf0e10cSrcweir if (EXPORT_SETTINGS != nExportMode) // meta, content, styles 1333cdf0e10cSrcweir { 1334cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_GRDDL, XML_TRANSFORMATION, 1335cdf0e10cSrcweir OUString::createFromAscii(s_grddl_xsl) ); 1336cdf0e10cSrcweir } 1337cdf0e10cSrcweir #endif 1338cdf0e10cSrcweir } 1339cdf0e10cSrcweir 1340cdf0e10cSrcweir sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) 1341cdf0e10cSrcweir { 1342cdf0e10cSrcweir bool bOwnGraphicResolver = false; 1343cdf0e10cSrcweir bool bOwnEmbeddedResolver = false; 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() ) 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY ); 1348cdf0e10cSrcweir if( xFactory.is() ) 1349cdf0e10cSrcweir { 1350cdf0e10cSrcweir try 1351cdf0e10cSrcweir { 1352cdf0e10cSrcweir if( !mxGraphicResolver.is() ) 1353cdf0e10cSrcweir { 1354cdf0e10cSrcweir mxGraphicResolver = Reference< XGraphicObjectResolver >::query( 1355cdf0e10cSrcweir xFactory->createInstance( 1356cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM( 1357cdf0e10cSrcweir "com.sun.star.document.ExportGraphicObjectResolver")))); 1358cdf0e10cSrcweir bOwnGraphicResolver = mxGraphicResolver.is(); 1359cdf0e10cSrcweir } 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir if( !mxEmbeddedResolver.is() ) 1362cdf0e10cSrcweir { 1363cdf0e10cSrcweir mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query( 1364cdf0e10cSrcweir xFactory->createInstance( 1365cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM( 1366cdf0e10cSrcweir "com.sun.star.document.ExportEmbeddedObjectResolver")))); 1367cdf0e10cSrcweir bOwnEmbeddedResolver = mxEmbeddedResolver.is(); 1368cdf0e10cSrcweir } 1369cdf0e10cSrcweir } 1370cdf0e10cSrcweir catch( com::sun::star::uno::Exception& ) 1371cdf0e10cSrcweir { 1372cdf0e10cSrcweir } 1373cdf0e10cSrcweir } 1374cdf0e10cSrcweir } 1375cdf0e10cSrcweir if( (getExportFlags() & EXPORT_OASIS) == 0 ) 1376cdf0e10cSrcweir { 1377cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xFactory = getServiceFactory(); 1378cdf0e10cSrcweir if( xFactory.is() ) 1379cdf0e10cSrcweir { 1380cdf0e10cSrcweir try 1381cdf0e10cSrcweir { 1382cdf0e10cSrcweir ::comphelper::PropertyMapEntry aInfoMap[] = 1383cdf0e10cSrcweir { 1384cdf0e10cSrcweir { "Class", sizeof("Class")-1, 0, 1385cdf0e10cSrcweir &::getCppuType((::rtl::OUString*)0), 1386cdf0e10cSrcweir PropertyAttribute::MAYBEVOID, 0}, 1387cdf0e10cSrcweir { NULL, 0, 0, NULL, 0, 0 } 1388cdf0e10cSrcweir }; 1389cdf0e10cSrcweir Reference< XPropertySet > xConvPropSet( 1390cdf0e10cSrcweir ::comphelper::GenericPropertySet_CreateInstance( 1391cdf0e10cSrcweir new ::comphelper::PropertySetInfo( aInfoMap ) ) ); 1392cdf0e10cSrcweir 1393cdf0e10cSrcweir Any aAny; 1394cdf0e10cSrcweir aAny <<= GetXMLToken( eClass ); 1395cdf0e10cSrcweir xConvPropSet->setPropertyValue( 1396cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Class")), aAny ); 1397cdf0e10cSrcweir 1398cdf0e10cSrcweir Reference< XPropertySet > xPropSet = 1399cdf0e10cSrcweir mxExportInfo.is() 1400cdf0e10cSrcweir ? PropertySetMerger_CreateInstance( mxExportInfo, 1401cdf0e10cSrcweir xConvPropSet ) 1402cdf0e10cSrcweir : xConvPropSet; 1403cdf0e10cSrcweir 1404cdf0e10cSrcweir Sequence<Any> aArgs( 3 ); 1405cdf0e10cSrcweir aArgs[0] <<= mxHandler; 1406cdf0e10cSrcweir aArgs[1] <<= xPropSet; 1407cdf0e10cSrcweir aArgs[2] <<= mxModel; 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir // get filter component 1410cdf0e10cSrcweir Reference< xml::sax::XDocumentHandler > xTmpDocHandler( 1411cdf0e10cSrcweir xFactory->createInstanceWithArguments( 1412cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.comp.Oasis2OOoTransformer"), 1413cdf0e10cSrcweir aArgs), UNO_QUERY); 1414cdf0e10cSrcweir OSL_ENSURE( xTmpDocHandler.is(), 1415cdf0e10cSrcweir "can't instantiate OASIS transformer component" ); 1416cdf0e10cSrcweir if( xTmpDocHandler.is() ) 1417cdf0e10cSrcweir { 1418cdf0e10cSrcweir mxHandler = xTmpDocHandler; 1419cdf0e10cSrcweir mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY ); 1420cdf0e10cSrcweir } 1421cdf0e10cSrcweir } 1422cdf0e10cSrcweir catch( com::sun::star::uno::Exception& ) 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir } 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir } 1427cdf0e10cSrcweir 1428cdf0e10cSrcweir 1429cdf0e10cSrcweir mxHandler->startDocument(); 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir // <?xml version="1.0" encoding="UTF-8"?> 1432cdf0e10cSrcweir // xHandler->processingInstruction( S2U( sXML_xml ), S2U( sXML_xml_pi ) ); 1433cdf0e10cSrcweir 1434cdf0e10cSrcweir // <office:document ...> 1435cdf0e10cSrcweir CheckAttrList(); 1436cdf0e10cSrcweir 1437cdf0e10cSrcweir // namespace attributes 1438cdf0e10cSrcweir // ( The namespace decls should be first attributes in the element; 1439cdf0e10cSrcweir // some faulty XML parsers (JAXP1.1) have a problem with this, 1440cdf0e10cSrcweir // also it's more elegant ) 1441cdf0e10cSrcweir sal_uInt16 nPos = mpNamespaceMap->GetFirstKey(); 1442cdf0e10cSrcweir while( USHRT_MAX != nPos ) 1443cdf0e10cSrcweir { 1444cdf0e10cSrcweir mpAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ), 1445cdf0e10cSrcweir mpNamespaceMap->GetNameByKey( nPos ) ); 1446cdf0e10cSrcweir nPos = mpNamespaceMap->GetNextKey( nPos ); 1447cdf0e10cSrcweir } 1448cdf0e10cSrcweir 1449cdf0e10cSrcweir 1450cdf0e10cSrcweir 1451cdf0e10cSrcweir // office:version = ... 1452cdf0e10cSrcweir if( !mbExtended ) 1453cdf0e10cSrcweir { 1454cdf0e10cSrcweir const sal_Char* pVersion = 0; 1455cdf0e10cSrcweir switch( getDefaultVersion() ) 1456cdf0e10cSrcweir { 1457cdf0e10cSrcweir case SvtSaveOptions::ODFVER_LATEST: pVersion = sXML_1_2; break; 1458cdf0e10cSrcweir case SvtSaveOptions::ODFVER_012: pVersion = sXML_1_2; break; 1459cdf0e10cSrcweir case SvtSaveOptions::ODFVER_011: pVersion = sXML_1_1; break; 1460cdf0e10cSrcweir case SvtSaveOptions::ODFVER_010: break; 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir default: 1463cdf0e10cSrcweir DBG_ERROR("xmloff::SvXMLExport::exportDoc(), unexpected odf default version!"); 1464cdf0e10cSrcweir } 1465cdf0e10cSrcweir 1466cdf0e10cSrcweir if( pVersion ) 1467cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE, XML_VERSION, 1468cdf0e10cSrcweir OUString::createFromAscii(pVersion) ); 1469cdf0e10cSrcweir } 1470cdf0e10cSrcweir 1471cdf0e10cSrcweir { 1472cdf0e10cSrcweir enum XMLTokenEnum eRootService = XML_TOKEN_INVALID; 1473cdf0e10cSrcweir const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS); 1474cdf0e10cSrcweir 1475cdf0e10cSrcweir lcl_AddGrddl(*this, nExportMode); 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir if( EXPORT_META == nExportMode ) 1478cdf0e10cSrcweir { 1479cdf0e10cSrcweir // export only meta 1480cdf0e10cSrcweir eRootService = XML_DOCUMENT_META; 1481cdf0e10cSrcweir } 1482cdf0e10cSrcweir else if ( EXPORT_SETTINGS == nExportMode ) 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir // export only settings 1485cdf0e10cSrcweir eRootService = XML_DOCUMENT_SETTINGS; 1486cdf0e10cSrcweir } 1487cdf0e10cSrcweir else if( EXPORT_STYLES == nExportMode ) 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir // export only styles 1490cdf0e10cSrcweir eRootService = XML_DOCUMENT_STYLES; 1491cdf0e10cSrcweir } 1492cdf0e10cSrcweir else if( EXPORT_CONTENT == nExportMode ) 1493cdf0e10cSrcweir { 1494cdf0e10cSrcweir // export only content 1495cdf0e10cSrcweir eRootService = XML_DOCUMENT_CONTENT; 1496cdf0e10cSrcweir } 1497cdf0e10cSrcweir else 1498cdf0e10cSrcweir { 1499cdf0e10cSrcweir // the god'ol one4all element 1500cdf0e10cSrcweir eRootService = XML_DOCUMENT; 1501cdf0e10cSrcweir // office:mimetype = ... (only for stream containing the content) 1502cdf0e10cSrcweir if( eClass != XML_TOKEN_INVALID ) 1503cdf0e10cSrcweir { 1504cdf0e10cSrcweir OUString aTmp( RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.") ); 1505cdf0e10cSrcweir aTmp += GetXMLToken( eClass ); 1506cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_OFFICE, XML_MIMETYPE, aTmp ); 1507cdf0e10cSrcweir } 1508cdf0e10cSrcweir } 1509cdf0e10cSrcweir 1510cdf0e10cSrcweir // if( (getExportFlags() & EXPORT_NODOCTYPE) == 0 && 1511cdf0e10cSrcweir // xExtHandler.is() ) 1512cdf0e10cSrcweir // { 1513cdf0e10cSrcweir // OUStringBuffer aDocType( 1514cdf0e10cSrcweir // GetXMLToken(XML_XML_DOCTYPE_PREFIX).getLength() + 1515cdf0e10cSrcweir // GetXMLToken(XML_XML_DOCTYPE_SUFFIX).getLength() + 30 ); 1516cdf0e10cSrcweir // 1517cdf0e10cSrcweir // aDocType.append( GetXMLToken(XML_XML_DOCTYPE_PREFIX) ); 1518cdf0e10cSrcweir // aDocType.append( GetNamespaceMap().GetQNameByKey( 1519cdf0e10cSrcweir // XML_NAMESPACE_OFFICE, GetXMLToken(eRootService) ) ); 1520cdf0e10cSrcweir // aDocType.append( GetXMLToken(XML_XML_DOCTYPE_SUFFIX) ); 1521cdf0e10cSrcweir // xExtHandler->unknown( aDocType.makeStringAndClear() ); 1522cdf0e10cSrcweir // } 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, sal_True, sal_True ); 1525cdf0e10cSrcweir 1526cdf0e10cSrcweir // meta information 1527cdf0e10cSrcweir if( mnExportFlags & EXPORT_META ) 1528cdf0e10cSrcweir ImplExportMeta(); 1529cdf0e10cSrcweir 1530cdf0e10cSrcweir // settings 1531cdf0e10cSrcweir if( mnExportFlags & EXPORT_SETTINGS ) 1532cdf0e10cSrcweir ImplExportSettings(); 1533cdf0e10cSrcweir 1534cdf0e10cSrcweir // scripts 1535cdf0e10cSrcweir if( mnExportFlags & EXPORT_SCRIPTS ) 1536cdf0e10cSrcweir _ExportScripts(); 1537cdf0e10cSrcweir 1538cdf0e10cSrcweir // font declerations 1539cdf0e10cSrcweir if( mnExportFlags & EXPORT_FONTDECLS ) 1540cdf0e10cSrcweir _ExportFontDecls(); 1541cdf0e10cSrcweir 1542cdf0e10cSrcweir // styles 1543cdf0e10cSrcweir if( mnExportFlags & EXPORT_STYLES ) 1544cdf0e10cSrcweir ImplExportStyles( sal_False ); 1545cdf0e10cSrcweir 1546cdf0e10cSrcweir // autostyles 1547cdf0e10cSrcweir if( mnExportFlags & EXPORT_AUTOSTYLES ) 1548cdf0e10cSrcweir ImplExportAutoStyles( sal_False ); 1549cdf0e10cSrcweir 1550cdf0e10cSrcweir // masterstyles 1551cdf0e10cSrcweir if( mnExportFlags & EXPORT_MASTERSTYLES ) 1552cdf0e10cSrcweir ImplExportMasterStyles( sal_False ); 1553cdf0e10cSrcweir 1554cdf0e10cSrcweir // contnt 1555cdf0e10cSrcweir if( mnExportFlags & EXPORT_CONTENT ) 1556cdf0e10cSrcweir ImplExportContent(); 1557cdf0e10cSrcweir } 1558cdf0e10cSrcweir 1559cdf0e10cSrcweir 1560cdf0e10cSrcweir mxHandler->endDocument(); 1561cdf0e10cSrcweir 1562cdf0e10cSrcweir if( bOwnGraphicResolver ) 1563cdf0e10cSrcweir { 1564cdf0e10cSrcweir Reference< XComponent > xComp( mxGraphicResolver, UNO_QUERY ); 1565cdf0e10cSrcweir xComp->dispose(); 1566cdf0e10cSrcweir } 1567cdf0e10cSrcweir 1568cdf0e10cSrcweir if( bOwnEmbeddedResolver ) 1569cdf0e10cSrcweir { 1570cdf0e10cSrcweir Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY ); 1571cdf0e10cSrcweir xComp->dispose(); 1572cdf0e10cSrcweir } 1573cdf0e10cSrcweir 1574cdf0e10cSrcweir return 0; 1575cdf0e10cSrcweir } 1576cdf0e10cSrcweir 1577cdf0e10cSrcweir void SvXMLExport::ResetNamespaceMap() 1578cdf0e10cSrcweir { 1579cdf0e10cSrcweir delete mpNamespaceMap; mpNamespaceMap = new SvXMLNamespaceMap; 1580cdf0e10cSrcweir } 1581cdf0e10cSrcweir 1582cdf0e10cSrcweir void SvXMLExport::_ExportMeta() 1583cdf0e10cSrcweir { 1584cdf0e10cSrcweir OUString generator( ::utl::DocInfoHelper::GetGeneratorString() ); 1585cdf0e10cSrcweir Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel, 1586cdf0e10cSrcweir UNO_QUERY); 1587cdf0e10cSrcweir if (xDocPropsSupplier.is()) { 1588cdf0e10cSrcweir Reference<XDocumentProperties> xDocProps( 1589cdf0e10cSrcweir xDocPropsSupplier->getDocumentProperties()); 1590cdf0e10cSrcweir if (!xDocProps.is()) throw; 1591cdf0e10cSrcweir // update generator here 1592cdf0e10cSrcweir xDocProps->setGenerator(generator); 1593cdf0e10cSrcweir SvXMLMetaExport * pMeta = new SvXMLMetaExport(*this, xDocProps); 1594cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xMeta(pMeta); 1595cdf0e10cSrcweir pMeta->Export(); 1596cdf0e10cSrcweir } else { 1597cdf0e10cSrcweir // office:meta 1598cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_META, 1599cdf0e10cSrcweir sal_True, sal_True ); 1600cdf0e10cSrcweir { 1601cdf0e10cSrcweir // BM: #i60323# export generator even if xInfoProp is empty (which is the 1602cdf0e10cSrcweir // case for charts). The generator does not depend on xInfoProp 1603cdf0e10cSrcweir SvXMLElementExport anElem( *this, XML_NAMESPACE_META, XML_GENERATOR, 1604cdf0e10cSrcweir sal_True, sal_True ); 1605cdf0e10cSrcweir Characters(generator); 1606cdf0e10cSrcweir } 1607cdf0e10cSrcweir } 1608cdf0e10cSrcweir } 1609cdf0e10cSrcweir 1610cdf0e10cSrcweir void SvXMLExport::_ExportScripts() 1611cdf0e10cSrcweir { 1612cdf0e10cSrcweir SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, sal_True, sal_True ); 1613cdf0e10cSrcweir 1614cdf0e10cSrcweir // export Basic macros (only for FlatXML) 1615cdf0e10cSrcweir if ( mnExportFlags & EXPORT_EMBEDDED ) 1616cdf0e10cSrcweir { 1617cdf0e10cSrcweir ::rtl::OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) ); 1618cdf0e10cSrcweir aValue += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":Basic" ) ); 1619cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, aValue ); 1620cdf0e10cSrcweir 1621cdf0e10cSrcweir SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, sal_True, sal_True ); 1622cdf0e10cSrcweir 1623cdf0e10cSrcweir // initialize Basic 1624cdf0e10cSrcweir if ( mxModel.is() ) 1625cdf0e10cSrcweir { 1626cdf0e10cSrcweir Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY ); 1627cdf0e10cSrcweir if ( xPSet.is() ) 1628cdf0e10cSrcweir xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ); 1629cdf0e10cSrcweir } 1630cdf0e10cSrcweir 1631cdf0e10cSrcweir Reference< document::XExporter > xExporter; 1632cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xMSF( getServiceFactory() ); 1633cdf0e10cSrcweir if ( xMSF.is() ) 1634cdf0e10cSrcweir { 1635cdf0e10cSrcweir Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) ); 1636cdf0e10cSrcweir Sequence < Any > aArgs( 1 ); 1637cdf0e10cSrcweir aArgs[0] <<= xHdl; 1638cdf0e10cSrcweir xExporter.set( xMSF->createInstanceWithArguments( 1639cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicExporter" ) ), aArgs ), 1640cdf0e10cSrcweir UNO_QUERY ); 1641cdf0e10cSrcweir } 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir OSL_ENSURE( xExporter.is(), 1644cdf0e10cSrcweir "SvXMLExport::_ExportScripts: can't instantiate export filter component for Basic macros" ); 1645cdf0e10cSrcweir 1646cdf0e10cSrcweir if ( xExporter.is() ) 1647cdf0e10cSrcweir { 1648cdf0e10cSrcweir Reference< XComponent > xComp( mxModel, UNO_QUERY ); 1649cdf0e10cSrcweir xExporter->setSourceDocument( xComp ); 1650cdf0e10cSrcweir Reference< XFilter > xFilter( xExporter, UNO_QUERY ); 1651cdf0e10cSrcweir if ( xFilter.is() ) 1652cdf0e10cSrcweir { 1653cdf0e10cSrcweir Sequence < PropertyValue > aMediaDesc( 0 ); 1654cdf0e10cSrcweir xFilter->filter( aMediaDesc ); 1655cdf0e10cSrcweir } 1656cdf0e10cSrcweir } 1657cdf0e10cSrcweir } 1658cdf0e10cSrcweir 1659cdf0e10cSrcweir // export document events 1660cdf0e10cSrcweir Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY ); 1661cdf0e10cSrcweir GetEventExport().Export( xEvents, sal_True ); 1662cdf0e10cSrcweir } 1663cdf0e10cSrcweir 1664cdf0e10cSrcweir void SvXMLExport::_ExportFontDecls() 1665cdf0e10cSrcweir { 1666cdf0e10cSrcweir if( mxFontAutoStylePool.is() ) 1667cdf0e10cSrcweir mxFontAutoStylePool->exportXML(); 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir void SvXMLExport::_ExportStyles( sal_Bool ) 1671cdf0e10cSrcweir { 1672cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY ); 1673cdf0e10cSrcweir if( xFact.is()) 1674cdf0e10cSrcweir { 1675cdf0e10cSrcweir // export (fill-)gradient-styles 1676cdf0e10cSrcweir try 1677cdf0e10cSrcweir { 1678cdf0e10cSrcweir uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable") ) ), uno::UNO_QUERY ); 1679cdf0e10cSrcweir if( xGradient.is() ) 1680cdf0e10cSrcweir { 1681cdf0e10cSrcweir XMLGradientStyleExport aGradientStyle( *this ); 1682cdf0e10cSrcweir 1683cdf0e10cSrcweir if( xGradient->hasElements() ) 1684cdf0e10cSrcweir { 1685cdf0e10cSrcweir uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() ); 1686cdf0e10cSrcweir sal_Int32 nCount = aNamesSeq.getLength(); 1687cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1688cdf0e10cSrcweir { 1689cdf0e10cSrcweir const OUString& rStrName = aNamesSeq[ i ]; 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir try 1692cdf0e10cSrcweir { 1693cdf0e10cSrcweir uno::Any aValue = xGradient->getByName( rStrName ); 1694cdf0e10cSrcweir 1695cdf0e10cSrcweir aGradientStyle.exportXML( rStrName, aValue ); 1696cdf0e10cSrcweir } 1697cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1698cdf0e10cSrcweir {} 1699cdf0e10cSrcweir } 1700cdf0e10cSrcweir } 1701cdf0e10cSrcweir } 1702cdf0e10cSrcweir } 1703cdf0e10cSrcweir catch( lang::ServiceNotRegisteredException& ) 1704cdf0e10cSrcweir {} 1705cdf0e10cSrcweir 1706cdf0e10cSrcweir // export (fill-)hatch-styles 1707cdf0e10cSrcweir try 1708cdf0e10cSrcweir { 1709cdf0e10cSrcweir uno::Reference< container::XNameAccess > xHatch( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable") ) ), uno::UNO_QUERY ); 1710cdf0e10cSrcweir if( xHatch.is() ) 1711cdf0e10cSrcweir { 1712cdf0e10cSrcweir XMLHatchStyleExport aHatchStyle( *this ); 1713cdf0e10cSrcweir 1714cdf0e10cSrcweir if( xHatch->hasElements() ) 1715cdf0e10cSrcweir { 1716cdf0e10cSrcweir uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() ); 1717cdf0e10cSrcweir sal_Int32 nCount = aNamesSeq.getLength(); 1718cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1719cdf0e10cSrcweir { 1720cdf0e10cSrcweir const OUString& rStrName = aNamesSeq[ i ]; 1721cdf0e10cSrcweir 1722cdf0e10cSrcweir try 1723cdf0e10cSrcweir { 1724cdf0e10cSrcweir uno::Any aValue = xHatch->getByName( rStrName ); 1725cdf0e10cSrcweir 1726cdf0e10cSrcweir aHatchStyle.exportXML( rStrName, aValue ); 1727cdf0e10cSrcweir } 1728cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1729cdf0e10cSrcweir {} 1730cdf0e10cSrcweir } 1731cdf0e10cSrcweir } 1732cdf0e10cSrcweir } 1733cdf0e10cSrcweir } 1734cdf0e10cSrcweir catch( lang::ServiceNotRegisteredException& ) 1735cdf0e10cSrcweir {} 1736cdf0e10cSrcweir 1737cdf0e10cSrcweir // export (fill-)bitmap-styles 1738cdf0e10cSrcweir try 1739cdf0e10cSrcweir { 1740cdf0e10cSrcweir uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable") ) ), uno::UNO_QUERY ); 1741cdf0e10cSrcweir if( xBitmap.is() ) 1742cdf0e10cSrcweir { 1743cdf0e10cSrcweir XMLImageStyle aImageStyle; 1744cdf0e10cSrcweir 1745cdf0e10cSrcweir if( xBitmap->hasElements() ) 1746cdf0e10cSrcweir { 1747cdf0e10cSrcweir uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() ); 1748cdf0e10cSrcweir sal_Int32 nCount = aNamesSeq.getLength(); 1749cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1750cdf0e10cSrcweir { 1751cdf0e10cSrcweir const OUString& rStrName = aNamesSeq[ i ]; 1752cdf0e10cSrcweir 1753cdf0e10cSrcweir try 1754cdf0e10cSrcweir { 1755cdf0e10cSrcweir uno::Any aValue = xBitmap->getByName( rStrName ); 1756cdf0e10cSrcweir 1757cdf0e10cSrcweir aImageStyle.exportXML( rStrName, aValue, *this ); 1758cdf0e10cSrcweir } 1759cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1760cdf0e10cSrcweir {} 1761cdf0e10cSrcweir } 1762cdf0e10cSrcweir } 1763cdf0e10cSrcweir } 1764cdf0e10cSrcweir } 1765cdf0e10cSrcweir catch( lang::ServiceNotRegisteredException& ) 1766cdf0e10cSrcweir {} 1767cdf0e10cSrcweir 1768cdf0e10cSrcweir // export transparency-gradient -styles 1769cdf0e10cSrcweir try 1770cdf0e10cSrcweir { 1771cdf0e10cSrcweir uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ), uno::UNO_QUERY ); 1772cdf0e10cSrcweir if( xTransGradient.is() ) 1773cdf0e10cSrcweir { 1774cdf0e10cSrcweir XMLTransGradientStyleExport aTransGradientstyle( *this ); 1775cdf0e10cSrcweir 1776cdf0e10cSrcweir if( xTransGradient->hasElements() ) 1777cdf0e10cSrcweir { 1778cdf0e10cSrcweir uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() ); 1779cdf0e10cSrcweir sal_Int32 nCount = aNamesSeq.getLength(); 1780cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1781cdf0e10cSrcweir { 1782cdf0e10cSrcweir const OUString& rStrName = aNamesSeq[ i ]; 1783cdf0e10cSrcweir 1784cdf0e10cSrcweir try 1785cdf0e10cSrcweir { 1786cdf0e10cSrcweir uno::Any aValue = xTransGradient->getByName( rStrName ); 1787cdf0e10cSrcweir 1788cdf0e10cSrcweir aTransGradientstyle.exportXML( rStrName, aValue ); 1789cdf0e10cSrcweir } 1790cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1791cdf0e10cSrcweir {} 1792cdf0e10cSrcweir } 1793cdf0e10cSrcweir } 1794cdf0e10cSrcweir } 1795cdf0e10cSrcweir } 1796cdf0e10cSrcweir catch( lang::ServiceNotRegisteredException& ) 1797cdf0e10cSrcweir {} 1798cdf0e10cSrcweir 1799cdf0e10cSrcweir // export marker-styles 1800cdf0e10cSrcweir try 1801cdf0e10cSrcweir { 1802cdf0e10cSrcweir uno::Reference< container::XNameAccess > xMarker( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable") ) ), uno::UNO_QUERY ); 1803cdf0e10cSrcweir if( xMarker.is() ) 1804cdf0e10cSrcweir { 1805cdf0e10cSrcweir XMLMarkerStyleExport aMarkerStyle( *this ); 1806cdf0e10cSrcweir 1807cdf0e10cSrcweir if( xMarker->hasElements() ) 1808cdf0e10cSrcweir { 1809cdf0e10cSrcweir uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() ); 1810cdf0e10cSrcweir sal_Int32 nCount = aNamesSeq.getLength(); 1811cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1812cdf0e10cSrcweir { 1813cdf0e10cSrcweir const OUString& rStrName = aNamesSeq[ i ]; 1814cdf0e10cSrcweir 1815cdf0e10cSrcweir try 1816cdf0e10cSrcweir { 1817cdf0e10cSrcweir uno::Any aValue = xMarker->getByName( rStrName ); 1818cdf0e10cSrcweir 1819cdf0e10cSrcweir aMarkerStyle.exportXML( rStrName, aValue ); 1820cdf0e10cSrcweir } 1821cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1822cdf0e10cSrcweir {} 1823cdf0e10cSrcweir } 1824cdf0e10cSrcweir } 1825cdf0e10cSrcweir } 1826cdf0e10cSrcweir } 1827cdf0e10cSrcweir catch( lang::ServiceNotRegisteredException& ) 1828cdf0e10cSrcweir {} 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir // export dash-styles 1831cdf0e10cSrcweir try 1832cdf0e10cSrcweir { 1833cdf0e10cSrcweir uno::Reference< container::XNameAccess > xDashes( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable") ) ), uno::UNO_QUERY ); 1834cdf0e10cSrcweir if( xDashes.is() ) 1835cdf0e10cSrcweir { 1836cdf0e10cSrcweir XMLDashStyleExport aDashStyle( *this ); 1837cdf0e10cSrcweir 1838cdf0e10cSrcweir if( xDashes->hasElements() ) 1839cdf0e10cSrcweir { 1840cdf0e10cSrcweir uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() ); 1841cdf0e10cSrcweir sal_Int32 nCount = aNamesSeq.getLength(); 1842cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1843cdf0e10cSrcweir { 1844cdf0e10cSrcweir const OUString& rStrName = aNamesSeq[ i ]; 1845cdf0e10cSrcweir 1846cdf0e10cSrcweir try 1847cdf0e10cSrcweir { 1848cdf0e10cSrcweir uno::Any aValue = xDashes->getByName( rStrName ); 1849cdf0e10cSrcweir 1850cdf0e10cSrcweir aDashStyle.exportXML( rStrName, aValue ); 1851cdf0e10cSrcweir } 1852cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1853cdf0e10cSrcweir {} 1854cdf0e10cSrcweir } 1855cdf0e10cSrcweir } 1856cdf0e10cSrcweir } 1857cdf0e10cSrcweir } 1858cdf0e10cSrcweir catch( lang::ServiceNotRegisteredException& ) 1859cdf0e10cSrcweir {} 1860cdf0e10cSrcweir } 1861cdf0e10cSrcweir } 1862cdf0e10cSrcweir 1863cdf0e10cSrcweir XMLTextParagraphExport* SvXMLExport::CreateTextParagraphExport() 1864cdf0e10cSrcweir { 1865cdf0e10cSrcweir return new XMLTextParagraphExport( *this, *(GetAutoStylePool().get()) ); 1866cdf0e10cSrcweir } 1867cdf0e10cSrcweir 1868cdf0e10cSrcweir XMLShapeExport* SvXMLExport::CreateShapeExport() 1869cdf0e10cSrcweir { 1870cdf0e10cSrcweir return new XMLShapeExport(*this); 1871cdf0e10cSrcweir } 1872cdf0e10cSrcweir 1873cdf0e10cSrcweir SvXMLAutoStylePoolP* SvXMLExport::CreateAutoStylePool() 1874cdf0e10cSrcweir { 1875cdf0e10cSrcweir return new SvXMLAutoStylePoolP(*this); 1876cdf0e10cSrcweir } 1877cdf0e10cSrcweir 1878cdf0e10cSrcweir XMLPageExport* SvXMLExport::CreatePageExport() 1879cdf0e10cSrcweir { 1880cdf0e10cSrcweir return new XMLPageExport( *this ); 1881cdf0e10cSrcweir } 1882cdf0e10cSrcweir 1883cdf0e10cSrcweir SchXMLExportHelper* SvXMLExport::CreateChartExport() 1884cdf0e10cSrcweir { 1885cdf0e10cSrcweir return new SchXMLExportHelper(*this,*GetAutoStylePool().get()); 1886cdf0e10cSrcweir } 1887cdf0e10cSrcweir 1888cdf0e10cSrcweir XMLFontAutoStylePool* SvXMLExport::CreateFontAutoStylePool() 1889cdf0e10cSrcweir { 1890cdf0e10cSrcweir return new XMLFontAutoStylePool( *this ); 1891cdf0e10cSrcweir } 1892cdf0e10cSrcweir 1893cdf0e10cSrcweir xmloff::OFormLayerXMLExport* SvXMLExport::CreateFormExport() 1894cdf0e10cSrcweir { 1895cdf0e10cSrcweir return new xmloff::OFormLayerXMLExport(*this); 1896cdf0e10cSrcweir } 1897cdf0e10cSrcweir 1898cdf0e10cSrcweir void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps) 1899cdf0e10cSrcweir { 1900cdf0e10cSrcweir GetViewSettings(rProps); 1901cdf0e10cSrcweir uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY); 1902cdf0e10cSrcweir if(xViewDataSupplier.is()) 1903cdf0e10cSrcweir { 1904cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAccess; 1905cdf0e10cSrcweir xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence 1906cdf0e10cSrcweir xIndexAccess = xViewDataSupplier->getViewData(); 1907cdf0e10cSrcweir sal_Bool bAdd = sal_False; 1908cdf0e10cSrcweir uno::Any aAny; 1909cdf0e10cSrcweir if(xIndexAccess.is() && xIndexAccess->hasElements() ) 1910cdf0e10cSrcweir { 1911cdf0e10cSrcweir sal_Int32 nCount = xIndexAccess->getCount(); 1912cdf0e10cSrcweir for (sal_Int32 i = 0; i < nCount; i++) 1913cdf0e10cSrcweir { 1914cdf0e10cSrcweir aAny = xIndexAccess->getByIndex(i); 1915cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aProps; 1916cdf0e10cSrcweir if( aAny >>= aProps ) 1917cdf0e10cSrcweir { 1918cdf0e10cSrcweir if( aProps.getLength() > 0 ) 1919cdf0e10cSrcweir { 1920cdf0e10cSrcweir bAdd = sal_True; 1921cdf0e10cSrcweir break; 1922cdf0e10cSrcweir } 1923cdf0e10cSrcweir } 1924cdf0e10cSrcweir } 1925cdf0e10cSrcweir } 1926cdf0e10cSrcweir 1927cdf0e10cSrcweir if( bAdd ) 1928cdf0e10cSrcweir { 1929cdf0e10cSrcweir sal_Int32 nOldLength(rProps.getLength()); 1930cdf0e10cSrcweir rProps.realloc(nOldLength + 1); 1931cdf0e10cSrcweir beans::PropertyValue aProp; 1932cdf0e10cSrcweir aProp.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Views")); 1933cdf0e10cSrcweir aProp.Value <<= xIndexAccess; 1934cdf0e10cSrcweir rProps[nOldLength] = aProp; 1935cdf0e10cSrcweir } 1936cdf0e10cSrcweir } 1937cdf0e10cSrcweir } 1938cdf0e10cSrcweir 1939cdf0e10cSrcweir void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&) 1940cdf0e10cSrcweir { 1941cdf0e10cSrcweir } 1942cdf0e10cSrcweir 1943cdf0e10cSrcweir void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&) 1944cdf0e10cSrcweir { 1945cdf0e10cSrcweir } 1946cdf0e10cSrcweir 1947cdf0e10cSrcweir sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings ) 1948cdf0e10cSrcweir { 1949cdf0e10cSrcweir (void)_out_rSettings; 1950cdf0e10cSrcweir return 0; 1951cdf0e10cSrcweir } 1952cdf0e10cSrcweir 1953cdf0e10cSrcweir void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ ) 1954cdf0e10cSrcweir { 1955cdf0e10cSrcweir if(mpNumExport) 1956cdf0e10cSrcweir mpNumExport->SetUsed(nNumberFormat); 1957cdf0e10cSrcweir } 1958cdf0e10cSrcweir 1959cdf0e10cSrcweir void SvXMLExport::exportDataStyles() 1960cdf0e10cSrcweir { 1961cdf0e10cSrcweir if(mpNumExport) 1962cdf0e10cSrcweir mpNumExport->Export(sal_False); 1963cdf0e10cSrcweir } 1964cdf0e10cSrcweir 1965cdf0e10cSrcweir void SvXMLExport::exportAutoDataStyles() 1966cdf0e10cSrcweir { 1967cdf0e10cSrcweir if(mpNumExport) 1968cdf0e10cSrcweir mpNumExport->Export(sal_True); 1969cdf0e10cSrcweir 1970cdf0e10cSrcweir if (mxFormExport.is()) 1971cdf0e10cSrcweir mxFormExport->exportAutoControlNumberStyles(); 1972cdf0e10cSrcweir } 1973cdf0e10cSrcweir 1974cdf0e10cSrcweir OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ ) const 1975cdf0e10cSrcweir { 1976cdf0e10cSrcweir OUString sTemp; 1977cdf0e10cSrcweir if(mpNumExport) 1978cdf0e10cSrcweir sTemp = mpNumExport->GetStyleName(nNumberFormat); 1979cdf0e10cSrcweir return sTemp; 1980cdf0e10cSrcweir } 1981cdf0e10cSrcweir 1982cdf0e10cSrcweir void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&) 1983cdf0e10cSrcweir { 1984cdf0e10cSrcweir } 1985cdf0e10cSrcweir 1986cdf0e10cSrcweir sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const 1987cdf0e10cSrcweir { 1988cdf0e10cSrcweir return ( mpNumExport != NULL ) 1989cdf0e10cSrcweir ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat; 1990cdf0e10cSrcweir } 1991cdf0e10cSrcweir 1992cdf0e10cSrcweir 1993cdf0e10cSrcweir OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL ) 1994cdf0e10cSrcweir { 1995cdf0e10cSrcweir OUString sRet( rGraphicObjectURL ); 1996cdf0e10cSrcweir if( 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol, 1997cdf0e10cSrcweir msGraphicObjectProtocol.getLength() ) && 1998cdf0e10cSrcweir mxGraphicResolver.is() ) 1999cdf0e10cSrcweir { 2000cdf0e10cSrcweir if( (getExportFlags() & EXPORT_EMBEDDED) == 0 ) 2001cdf0e10cSrcweir sRet = mxGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL ); 2002cdf0e10cSrcweir else 2003cdf0e10cSrcweir sRet = OUString(); 2004cdf0e10cSrcweir } 2005cdf0e10cSrcweir else 2006cdf0e10cSrcweir sRet = GetRelativeReference( sRet ); 2007cdf0e10cSrcweir 2008cdf0e10cSrcweir return sRet; 2009cdf0e10cSrcweir } 2010cdf0e10cSrcweir 2011cdf0e10cSrcweir sal_Bool SvXMLExport::AddEmbeddedGraphicObjectAsBase64( const OUString& rGraphicObjectURL ) 2012cdf0e10cSrcweir { 2013cdf0e10cSrcweir sal_Bool bRet = sal_False; 2014cdf0e10cSrcweir 2015cdf0e10cSrcweir if( (getExportFlags() & EXPORT_EMBEDDED) != 0 && 2016cdf0e10cSrcweir 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol, 2017cdf0e10cSrcweir msGraphicObjectProtocol.getLength() ) && 2018cdf0e10cSrcweir mxGraphicResolver.is() ) 2019cdf0e10cSrcweir { 2020cdf0e10cSrcweir Reference< XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY ); 2021cdf0e10cSrcweir 2022cdf0e10cSrcweir if( xStmResolver.is() ) 2023cdf0e10cSrcweir { 2024cdf0e10cSrcweir Reference< XInputStream > xIn( xStmResolver->getInputStream( rGraphicObjectURL ) ); 2025cdf0e10cSrcweir 2026cdf0e10cSrcweir if( xIn.is() ) 2027cdf0e10cSrcweir { 2028cdf0e10cSrcweir XMLBase64Export aBase64Exp( *this ); 2029cdf0e10cSrcweir bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn ); 2030cdf0e10cSrcweir } 2031cdf0e10cSrcweir } 2032cdf0e10cSrcweir } 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir return bRet; 2035cdf0e10cSrcweir } 2036cdf0e10cSrcweir 2037cdf0e10cSrcweir OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL ) 2038cdf0e10cSrcweir { 2039cdf0e10cSrcweir OUString sRet; 2040cdf0e10cSrcweir if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol, 2041cdf0e10cSrcweir msEmbeddedObjectProtocol.getLength() ) || 2042cdf0e10cSrcweir 0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol, 2043cdf0e10cSrcweir msGraphicObjectProtocol.getLength() ) ) && 2044cdf0e10cSrcweir mxEmbeddedResolver.is() ) 2045cdf0e10cSrcweir { 2046cdf0e10cSrcweir sRet = 2047cdf0e10cSrcweir mxEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL ); 2048cdf0e10cSrcweir } 2049cdf0e10cSrcweir else 2050cdf0e10cSrcweir sRet = GetRelativeReference( rEmbeddedObjectURL ); 2051cdf0e10cSrcweir 2052cdf0e10cSrcweir return sRet; 2053cdf0e10cSrcweir } 2054cdf0e10cSrcweir 2055cdf0e10cSrcweir sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL ) 2056cdf0e10cSrcweir { 2057cdf0e10cSrcweir sal_Bool bRet = sal_False; 2058cdf0e10cSrcweir if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol, 2059cdf0e10cSrcweir msEmbeddedObjectProtocol.getLength() ) || 2060cdf0e10cSrcweir 0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol, 2061cdf0e10cSrcweir msGraphicObjectProtocol.getLength() ) ) && 2062cdf0e10cSrcweir mxEmbeddedResolver.is() ) 2063cdf0e10cSrcweir { 2064cdf0e10cSrcweir Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY ); 2065cdf0e10cSrcweir if( xNA.is() ) 2066cdf0e10cSrcweir { 2067cdf0e10cSrcweir Any aAny = xNA->getByName( rEmbeddedObjectURL ); 2068cdf0e10cSrcweir Reference < XInputStream > xIn; 2069cdf0e10cSrcweir aAny >>= xIn; 2070cdf0e10cSrcweir if( xIn.is() ) 2071cdf0e10cSrcweir { 2072cdf0e10cSrcweir XMLBase64Export aBase64Exp( *this ); 2073cdf0e10cSrcweir bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn ); 2074cdf0e10cSrcweir } 2075cdf0e10cSrcweir } 2076cdf0e10cSrcweir } 2077cdf0e10cSrcweir 2078cdf0e10cSrcweir return bRet; 2079cdf0e10cSrcweir } 2080cdf0e10cSrcweir 2081cdf0e10cSrcweir OUString SvXMLExport::EncodeStyleName( 2082cdf0e10cSrcweir const OUString& rName, 2083cdf0e10cSrcweir sal_Bool *pEncoded ) const 2084cdf0e10cSrcweir { 2085cdf0e10cSrcweir return GetMM100UnitConverter().encodeStyleName( rName, pEncoded ); 2086cdf0e10cSrcweir } 2087cdf0e10cSrcweir 2088cdf0e10cSrcweir ProgressBarHelper* SvXMLExport::GetProgressBarHelper() 2089cdf0e10cSrcweir { 2090cdf0e10cSrcweir if (!mpProgressBarHelper) 2091cdf0e10cSrcweir { 2092cdf0e10cSrcweir mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_True); 2093cdf0e10cSrcweir 2094cdf0e10cSrcweir if (mxExportInfo.is()) 2095cdf0e10cSrcweir { 2096cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo(); 2097cdf0e10cSrcweir if (xPropertySetInfo.is()) 2098cdf0e10cSrcweir { 2099cdf0e10cSrcweir OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE)); 2100cdf0e10cSrcweir OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX)); 2101cdf0e10cSrcweir OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT)); 2102cdf0e10cSrcweir OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT)); 2103cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sProgressMax) && 2104cdf0e10cSrcweir xPropertySetInfo->hasPropertyByName(sProgressCurrent) && 2105cdf0e10cSrcweir xPropertySetInfo->hasPropertyByName(sProgressRange)) 2106cdf0e10cSrcweir { 2107cdf0e10cSrcweir uno::Any aAny; 2108cdf0e10cSrcweir sal_Int32 nProgressMax(0); 2109cdf0e10cSrcweir sal_Int32 nProgressCurrent(0); 2110cdf0e10cSrcweir sal_Int32 nProgressRange(0); 2111cdf0e10cSrcweir aAny = mxExportInfo->getPropertyValue(sProgressRange); 2112cdf0e10cSrcweir if (aAny >>= nProgressRange) 2113cdf0e10cSrcweir mpProgressBarHelper->SetRange(nProgressRange); 2114cdf0e10cSrcweir aAny = mxExportInfo->getPropertyValue(sProgressMax); 2115cdf0e10cSrcweir if (aAny >>= nProgressMax) 2116cdf0e10cSrcweir mpProgressBarHelper->SetReference(nProgressMax); 2117cdf0e10cSrcweir aAny = mxExportInfo->getPropertyValue(sProgressCurrent); 2118cdf0e10cSrcweir if (aAny >>= nProgressCurrent) 2119cdf0e10cSrcweir mpProgressBarHelper->SetValue(nProgressCurrent); 2120cdf0e10cSrcweir } 2121cdf0e10cSrcweir if (xPropertySetInfo->hasPropertyByName(sRepeat)) 2122cdf0e10cSrcweir { 2123cdf0e10cSrcweir uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat); 2124cdf0e10cSrcweir if (aAny.getValueType() == getBooleanCppuType()) 2125cdf0e10cSrcweir mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny)); 2126cdf0e10cSrcweir else { 2127cdf0e10cSrcweir DBG_ERRORFILE("why is it no boolean?"); 2128cdf0e10cSrcweir } 2129cdf0e10cSrcweir } 2130cdf0e10cSrcweir } 2131cdf0e10cSrcweir } 2132cdf0e10cSrcweir } 2133cdf0e10cSrcweir return mpProgressBarHelper; 2134cdf0e10cSrcweir } 2135cdf0e10cSrcweir 2136cdf0e10cSrcweir XMLEventExport& SvXMLExport::GetEventExport() 2137cdf0e10cSrcweir { 2138cdf0e10cSrcweir if( NULL == mpEventExport) 2139cdf0e10cSrcweir { 2140cdf0e10cSrcweir // create EventExport on demand 2141cdf0e10cSrcweir mpEventExport = new XMLEventExport(*this, NULL); 2142cdf0e10cSrcweir 2143cdf0e10cSrcweir // and register standard handlers + names 2144cdf0e10cSrcweir OUString sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")); 2145cdf0e10cSrcweir mpEventExport->AddHandler(sStarBasic, new XMLStarBasicExportHandler()); 2146cdf0e10cSrcweir OUString sScript(RTL_CONSTASCII_USTRINGPARAM("Script")); 2147cdf0e10cSrcweir mpEventExport->AddHandler(sScript, new XMLScriptExportHandler()); 2148cdf0e10cSrcweir mpEventExport->AddTranslationTable(aStandardEventTable); 2149cdf0e10cSrcweir } 2150cdf0e10cSrcweir 2151cdf0e10cSrcweir return *mpEventExport; 2152cdf0e10cSrcweir } 2153cdf0e10cSrcweir 2154cdf0e10cSrcweir XMLImageMapExport& SvXMLExport::GetImageMapExport() 2155cdf0e10cSrcweir { 2156cdf0e10cSrcweir // image map export, create on-demand 2157cdf0e10cSrcweir if( NULL == mpImageMapExport ) 2158cdf0e10cSrcweir { 2159cdf0e10cSrcweir mpImageMapExport = new XMLImageMapExport(*this); 2160cdf0e10cSrcweir } 2161cdf0e10cSrcweir 2162cdf0e10cSrcweir return *mpImageMapExport; 2163cdf0e10cSrcweir } 2164cdf0e10cSrcweir 2165cdf0e10cSrcweir // XUnoTunnel & co 2166cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SvXMLExport::getUnoTunnelId() throw() 2167cdf0e10cSrcweir { 2168cdf0e10cSrcweir static uno::Sequence< sal_Int8 > * pSeq = 0; 2169cdf0e10cSrcweir if( !pSeq ) 2170cdf0e10cSrcweir { 2171cdf0e10cSrcweir Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); 2172cdf0e10cSrcweir if( !pSeq ) 2173cdf0e10cSrcweir { 2174cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 2175cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 2176cdf0e10cSrcweir pSeq = &aSeq; 2177cdf0e10cSrcweir } 2178cdf0e10cSrcweir } 2179cdf0e10cSrcweir return *pSeq; 2180cdf0e10cSrcweir } 2181cdf0e10cSrcweir 2182cdf0e10cSrcweir SvXMLExport* SvXMLExport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() 2183cdf0e10cSrcweir { 2184cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY ); 2185cdf0e10cSrcweir if( xUT.is() ) 2186cdf0e10cSrcweir { 2187cdf0e10cSrcweir return 2188cdf0e10cSrcweir reinterpret_cast<SvXMLExport*>( 2189cdf0e10cSrcweir sal::static_int_cast<sal_IntPtr>( 2190cdf0e10cSrcweir xUT->getSomething( SvXMLExport::getUnoTunnelId()))); 2191cdf0e10cSrcweir } 2192cdf0e10cSrcweir else 2193cdf0e10cSrcweir return NULL; 2194cdf0e10cSrcweir } 2195cdf0e10cSrcweir 2196cdf0e10cSrcweir // XUnoTunnel 2197cdf0e10cSrcweir sal_Int64 SAL_CALL SvXMLExport::getSomething( const uno::Sequence< sal_Int8 >& rId ) 2198cdf0e10cSrcweir throw( uno::RuntimeException ) 2199cdf0e10cSrcweir { 2200cdf0e10cSrcweir if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 2201cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 2202cdf0e10cSrcweir { 2203cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); 2204cdf0e10cSrcweir } 2205cdf0e10cSrcweir return 0; 2206cdf0e10cSrcweir } 2207cdf0e10cSrcweir 2208cdf0e10cSrcweir sal_Bool SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent >& rComp ) 2209cdf0e10cSrcweir { 2210cdf0e10cSrcweir OUString sFilterService; 2211cdf0e10cSrcweir bool bIsChart = false; 2212cdf0e10cSrcweir 2213cdf0e10cSrcweir Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY ); 2214cdf0e10cSrcweir if( xServiceInfo.is() ) 2215cdf0e10cSrcweir { 2216cdf0e10cSrcweir const XMLServiceMapEntry_Impl *pEntry = aServiceMap; 2217cdf0e10cSrcweir while( pEntry->sModelService ) 2218cdf0e10cSrcweir { 2219cdf0e10cSrcweir OUString sModelService( pEntry->sModelService, 2220cdf0e10cSrcweir pEntry->nModelServiceLen, 2221cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 2222cdf0e10cSrcweir if( xServiceInfo->supportsService( sModelService ) ) 2223cdf0e10cSrcweir { 2224cdf0e10cSrcweir sFilterService = OUString( pEntry->sFilterService, 2225cdf0e10cSrcweir pEntry->nFilterServiceLen, 2226cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 2227cdf0e10cSrcweir bIsChart = sModelService.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( XML_MODEL_SERVICE_CHART )); 2228cdf0e10cSrcweir break; 2229cdf0e10cSrcweir } 2230cdf0e10cSrcweir pEntry++; 2231cdf0e10cSrcweir } 2232cdf0e10cSrcweir } 2233cdf0e10cSrcweir 2234cdf0e10cSrcweir OSL_ENSURE( sFilterService.getLength(), "no export filter for own object" ); 2235cdf0e10cSrcweir 2236cdf0e10cSrcweir if( !sFilterService.getLength() ) 2237cdf0e10cSrcweir return sal_False; 2238cdf0e10cSrcweir 2239cdf0e10cSrcweir Reference < XDocumentHandler > xHdl = 2240cdf0e10cSrcweir new XMLEmbeddedObjectExportFilter( mxHandler ); 2241cdf0e10cSrcweir 2242cdf0e10cSrcweir Sequence < Any > aArgs( 1 ); 2243cdf0e10cSrcweir // #144135# the filters for embedded objects in flat format are always 2244cdf0e10cSrcweir // instantiated as Oasis filters and transformed afterwards. Therefore, all 2245cdf0e10cSrcweir // special handling that is done if the exportFlags do not contain 2246cdf0e10cSrcweir // EXPORT_OASIS must be changed to properties being passed in the info 2247cdf0e10cSrcweir // propertyset 2248cdf0e10cSrcweir 2249cdf0e10cSrcweir if( ! (getExportFlags() & EXPORT_OASIS) && 2250cdf0e10cSrcweir bIsChart ) 2251cdf0e10cSrcweir { 2252cdf0e10cSrcweir static ::comphelper::PropertyMapEntry aInfoMap[] = 2253cdf0e10cSrcweir { 2254cdf0e10cSrcweir { RTL_CONSTASCII_STRINGPARAM("ExportTableNumberList"), 0, &::getBooleanCppuType(), PropertyAttribute::MAYBEVOID, 0}, 2255cdf0e10cSrcweir { NULL, 0, 0, NULL, 0, 0 } 2256cdf0e10cSrcweir }; 2257cdf0e10cSrcweir Reference< XPropertySet > xInfoProp( 2258cdf0e10cSrcweir ::comphelper::GenericPropertySet_CreateInstance( 2259cdf0e10cSrcweir new ::comphelper::PropertySetInfo( aInfoMap ))); 2260cdf0e10cSrcweir 2261cdf0e10cSrcweir if( bIsChart ) 2262cdf0e10cSrcweir xInfoProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ExportTableNumberList")), makeAny( true )); 2263cdf0e10cSrcweir 2264cdf0e10cSrcweir aArgs.realloc( 2 ); 2265cdf0e10cSrcweir aArgs[1] <<= xInfoProp; 2266cdf0e10cSrcweir } 2267cdf0e10cSrcweir aArgs[0] <<= xHdl; 2268cdf0e10cSrcweir 2269cdf0e10cSrcweir // #110680# 2270cdf0e10cSrcweir // Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory(); 2271cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xServiceFactory = getServiceFactory(); 2272cdf0e10cSrcweir 2273cdf0e10cSrcweir Reference< document::XExporter > xExporter( 2274cdf0e10cSrcweir xServiceFactory->createInstanceWithArguments( sFilterService, aArgs), 2275cdf0e10cSrcweir UNO_QUERY); 2276cdf0e10cSrcweir OSL_ENSURE( xExporter.is(), 2277cdf0e10cSrcweir "can't instantiate export filter component for own object" ); 2278cdf0e10cSrcweir if( !xExporter.is() ) 2279cdf0e10cSrcweir return sal_False; 2280cdf0e10cSrcweir 2281cdf0e10cSrcweir xExporter->setSourceDocument( rComp ); 2282cdf0e10cSrcweir 2283cdf0e10cSrcweir Reference<XFilter> xFilter( xExporter, UNO_QUERY ); 2284cdf0e10cSrcweir 2285cdf0e10cSrcweir Sequence < PropertyValue > aMediaDesc( 0 ); 2286cdf0e10cSrcweir return xFilter->filter( aMediaDesc ); 2287cdf0e10cSrcweir } 2288cdf0e10cSrcweir 2289cdf0e10cSrcweir OUString SvXMLExport::GetRelativeReference(const OUString& rValue) 2290cdf0e10cSrcweir { 2291cdf0e10cSrcweir OUString sValue( rValue ); 2292cdf0e10cSrcweir // #i65474# handling of fragment URLs ("#....") is undefined 2293cdf0e10cSrcweir // they are stored 'as is' 2294cdf0e10cSrcweir uno::Reference< uri::XUriReference > xUriRef; 2295cdf0e10cSrcweir if(sValue.getLength() && sValue.getStr()[0] != '#') 2296cdf0e10cSrcweir { 2297cdf0e10cSrcweir try 2298cdf0e10cSrcweir { 2299cdf0e10cSrcweir xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue ); 2300cdf0e10cSrcweir if( xUriRef.is() && !xUriRef->isAbsolute() ) 2301cdf0e10cSrcweir { 2302cdf0e10cSrcweir //#i61943# relative URLs need special handling 2303cdf0e10cSrcweir INetURLObject aTemp( mpImpl->msPackageURI ); 2304cdf0e10cSrcweir bool bWasAbsolute = false; 2305cdf0e10cSrcweir sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DECODE_TO_IURI); 2306cdf0e10cSrcweir } 2307cdf0e10cSrcweir } 2308cdf0e10cSrcweir catch( uno::Exception& ) 2309cdf0e10cSrcweir { 2310cdf0e10cSrcweir } 2311cdf0e10cSrcweir } 2312cdf0e10cSrcweir OUString sRet = sValue; 2313cdf0e10cSrcweir if( xUriRef.is() )//no conversion for empty values or for fragments 2314cdf0e10cSrcweir { 2315cdf0e10cSrcweir //conversion for matching schemes only 2316cdf0e10cSrcweir if( xUriRef->getScheme() == mpImpl->msPackageURIScheme ) 2317cdf0e10cSrcweir { 2318cdf0e10cSrcweir sValue = INetURLObject::GetRelURL( msOrigFileName, sValue, 2319cdf0e10cSrcweir INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI, RTL_TEXTENCODING_UTF8, INetURLObject::FSYS_DETECT); 2320cdf0e10cSrcweir } 2321cdf0e10cSrcweir } 2322cdf0e10cSrcweir return sValue; 2323cdf0e10cSrcweir } 2324cdf0e10cSrcweir 2325cdf0e10cSrcweir void SvXMLExport::StartElement(sal_uInt16 nPrefix, 2326cdf0e10cSrcweir enum ::xmloff::token::XMLTokenEnum eName, 2327cdf0e10cSrcweir sal_Bool bIgnWSOutside ) 2328cdf0e10cSrcweir { 2329cdf0e10cSrcweir StartElement(_GetNamespaceMap().GetQNameByKey( nPrefix, 2330cdf0e10cSrcweir GetXMLToken(eName) ), bIgnWSOutside); 2331cdf0e10cSrcweir } 2332cdf0e10cSrcweir 2333cdf0e10cSrcweir void SvXMLExport::StartElement(const OUString& rName, 2334cdf0e10cSrcweir sal_Bool bIgnWSOutside ) 2335cdf0e10cSrcweir { 2336cdf0e10cSrcweir if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING) 2337cdf0e10cSrcweir { 2338cdf0e10cSrcweir try 2339cdf0e10cSrcweir { 2340cdf0e10cSrcweir if( bIgnWSOutside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY)) 2341cdf0e10cSrcweir mxHandler->ignorableWhitespace( msWS ); 2342cdf0e10cSrcweir mxHandler->startElement( rName, GetXAttrList() ); 2343cdf0e10cSrcweir } 2344cdf0e10cSrcweir catch ( SAXInvalidCharacterException& e ) 2345cdf0e10cSrcweir { 2346cdf0e10cSrcweir Sequence<OUString> aPars(1); 2347cdf0e10cSrcweir aPars[0] = rName; 2348cdf0e10cSrcweir SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL ); 2349cdf0e10cSrcweir } 2350cdf0e10cSrcweir catch ( SAXException& e ) 2351cdf0e10cSrcweir { 2352cdf0e10cSrcweir Sequence<OUString> aPars(1); 2353cdf0e10cSrcweir aPars[0] = rName; 2354cdf0e10cSrcweir SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, 2355cdf0e10cSrcweir aPars, e.Message, NULL ); 2356cdf0e10cSrcweir } 2357cdf0e10cSrcweir } 2358cdf0e10cSrcweir ClearAttrList(); 2359cdf0e10cSrcweir ++mpImpl->mDepth; // increment nesting depth counter 2360cdf0e10cSrcweir } 2361cdf0e10cSrcweir 2362cdf0e10cSrcweir void SvXMLExport::Characters(const ::rtl::OUString& rChars) 2363cdf0e10cSrcweir { 2364cdf0e10cSrcweir if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING) 2365cdf0e10cSrcweir { 2366cdf0e10cSrcweir try 2367cdf0e10cSrcweir { 2368cdf0e10cSrcweir mxHandler->characters(rChars); 2369cdf0e10cSrcweir } 2370cdf0e10cSrcweir catch ( SAXInvalidCharacterException& e ) 2371cdf0e10cSrcweir { 2372cdf0e10cSrcweir Sequence<OUString> aPars(1); 2373cdf0e10cSrcweir aPars[0] = rChars; 2374cdf0e10cSrcweir SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL ); 2375cdf0e10cSrcweir } 2376cdf0e10cSrcweir catch ( SAXException& e ) 2377cdf0e10cSrcweir { 2378cdf0e10cSrcweir Sequence<OUString> aPars(1); 2379cdf0e10cSrcweir aPars[0] = rChars; 2380cdf0e10cSrcweir SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, 2381cdf0e10cSrcweir aPars, e.Message, NULL ); 2382cdf0e10cSrcweir } 2383cdf0e10cSrcweir } 2384cdf0e10cSrcweir } 2385cdf0e10cSrcweir 2386cdf0e10cSrcweir void SvXMLExport::EndElement(sal_uInt16 nPrefix, 2387cdf0e10cSrcweir enum ::xmloff::token::XMLTokenEnum eName, 2388cdf0e10cSrcweir sal_Bool bIgnWSInside ) 2389cdf0e10cSrcweir { 2390cdf0e10cSrcweir EndElement(_GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(eName) ), 2391cdf0e10cSrcweir bIgnWSInside); 2392cdf0e10cSrcweir } 2393cdf0e10cSrcweir 2394cdf0e10cSrcweir void SvXMLExport::EndElement(const OUString& rName, 2395cdf0e10cSrcweir sal_Bool bIgnWSInside ) 2396cdf0e10cSrcweir { 2397cdf0e10cSrcweir // decrement nesting depth counter & (maybe) restore namespace map 2398cdf0e10cSrcweir --mpImpl->mDepth; 2399cdf0e10cSrcweir if (!mpImpl->mNamespaceMaps.empty() && 2400cdf0e10cSrcweir (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth)) 2401cdf0e10cSrcweir { 2402cdf0e10cSrcweir delete mpNamespaceMap; 2403cdf0e10cSrcweir mpNamespaceMap = mpImpl->mNamespaceMaps.top().first; 2404cdf0e10cSrcweir mpImpl->mNamespaceMaps.pop(); 2405cdf0e10cSrcweir } 2406cdf0e10cSrcweir OSL_ENSURE(mpImpl->mNamespaceMaps.empty() || 2407cdf0e10cSrcweir (mpImpl->mNamespaceMaps.top().second < mpImpl->mDepth), 2408cdf0e10cSrcweir "SvXMLExport: NamespaceMaps corrupted"); 2409cdf0e10cSrcweir 2410cdf0e10cSrcweir if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING) 2411cdf0e10cSrcweir { 2412cdf0e10cSrcweir try 2413cdf0e10cSrcweir { 2414cdf0e10cSrcweir if( bIgnWSInside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY)) 2415cdf0e10cSrcweir mxHandler->ignorableWhitespace( msWS ); 2416cdf0e10cSrcweir mxHandler->endElement( rName ); 2417cdf0e10cSrcweir } 2418cdf0e10cSrcweir catch ( SAXException& e ) 2419cdf0e10cSrcweir { 2420cdf0e10cSrcweir Sequence<OUString> aPars(1); 2421cdf0e10cSrcweir aPars[0] = rName; 2422cdf0e10cSrcweir SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, 2423cdf0e10cSrcweir aPars, e.Message, NULL ); 2424cdf0e10cSrcweir } 2425cdf0e10cSrcweir } 2426cdf0e10cSrcweir } 2427cdf0e10cSrcweir 2428cdf0e10cSrcweir void SvXMLExport::IgnorableWhitespace() 2429cdf0e10cSrcweir { 2430cdf0e10cSrcweir if ((mnExportFlags & EXPORT_PRETTY) != EXPORT_PRETTY) 2431cdf0e10cSrcweir return; 2432cdf0e10cSrcweir 2433cdf0e10cSrcweir if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING) 2434cdf0e10cSrcweir { 2435cdf0e10cSrcweir try 2436cdf0e10cSrcweir { 2437cdf0e10cSrcweir mxHandler->ignorableWhitespace( msWS ); 2438cdf0e10cSrcweir } 2439cdf0e10cSrcweir catch ( SAXException& e ) 2440cdf0e10cSrcweir { 2441cdf0e10cSrcweir Sequence<OUString> aPars(0); 2442cdf0e10cSrcweir SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, 2443cdf0e10cSrcweir aPars, e.Message, NULL ); 2444cdf0e10cSrcweir } 2445cdf0e10cSrcweir } 2446cdf0e10cSrcweir } 2447cdf0e10cSrcweir 2448cdf0e10cSrcweir 2449cdf0e10cSrcweir void SvXMLExport::SetError( 2450cdf0e10cSrcweir sal_Int32 nId, 2451cdf0e10cSrcweir const Sequence<OUString>& rMsgParams, 2452cdf0e10cSrcweir const OUString& rExceptionMessage, 2453cdf0e10cSrcweir const Reference<XLocator>& rLocator ) 2454cdf0e10cSrcweir { 2455cdf0e10cSrcweir // allow multi-threaded access to the cancel() method 2456cdf0e10cSrcweir static ::vos::OMutex aMutex; 2457cdf0e10cSrcweir ::vos::OGuard aGuard(aMutex); 2458cdf0e10cSrcweir 2459cdf0e10cSrcweir // maintain error flags 2460cdf0e10cSrcweir if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 ) 2461cdf0e10cSrcweir mnErrorFlags |= ERROR_ERROR_OCCURED; 2462cdf0e10cSrcweir if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 ) 2463cdf0e10cSrcweir mnErrorFlags |= ERROR_WARNING_OCCURED; 2464cdf0e10cSrcweir if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 ) 2465cdf0e10cSrcweir mnErrorFlags |= ERROR_DO_NOTHING; 2466cdf0e10cSrcweir 2467cdf0e10cSrcweir // create error lsit on demand 2468cdf0e10cSrcweir if ( mpXMLErrors == NULL ) 2469cdf0e10cSrcweir mpXMLErrors = new XMLErrors(); 2470cdf0e10cSrcweir 2471cdf0e10cSrcweir // save error information 2472cdf0e10cSrcweir mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator ); 2473cdf0e10cSrcweir } 2474cdf0e10cSrcweir 2475cdf0e10cSrcweir void SvXMLExport::SetError( 2476cdf0e10cSrcweir sal_Int32 nId, 2477cdf0e10cSrcweir const Sequence<OUString>& rMsgParams) 2478cdf0e10cSrcweir { 2479cdf0e10cSrcweir OUString sEmpty; 2480cdf0e10cSrcweir SetError( nId, rMsgParams, sEmpty, NULL ); 2481cdf0e10cSrcweir } 2482cdf0e10cSrcweir 2483cdf0e10cSrcweir 2484cdf0e10cSrcweir XMLErrors* SvXMLExport::GetErrors() 2485cdf0e10cSrcweir { 2486cdf0e10cSrcweir return mpXMLErrors; 2487cdf0e10cSrcweir } 2488cdf0e10cSrcweir 2489cdf0e10cSrcweir void SvXMLExport::DisposingModel() 2490cdf0e10cSrcweir { 2491cdf0e10cSrcweir mxModel.clear(); 2492cdf0e10cSrcweir // --> OD 2006-03-13 #i51726# 2493cdf0e10cSrcweir meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;; 2494cdf0e10cSrcweir // <-- 2495cdf0e10cSrcweir mxEventListener.clear(); 2496cdf0e10cSrcweir } 2497cdf0e10cSrcweir 2498cdf0e10cSrcweir // #110680# 2499cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLExport::getServiceFactory() 2500cdf0e10cSrcweir { 2501cdf0e10cSrcweir // #110680# 2502cdf0e10cSrcweir return mxServiceFactory; 2503cdf0e10cSrcweir } 2504cdf0e10cSrcweir 2505cdf0e10cSrcweir uno::Reference< uno::XComponentContext > 2506cdf0e10cSrcweir SvXMLExport::GetComponentContext() const 2507cdf0e10cSrcweir { 2508cdf0e10cSrcweir return mpImpl->mxComponentContext; 2509cdf0e10cSrcweir } 2510cdf0e10cSrcweir 2511cdf0e10cSrcweir ::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLExport::getInterfaceToIdentifierMapper() 2512cdf0e10cSrcweir { 2513cdf0e10cSrcweir return mpImpl->maInterfaceToIdentifierMapper; 2514cdf0e10cSrcweir } 2515cdf0e10cSrcweir 2516cdf0e10cSrcweir // --> OD 2006-09-27 #i69627# 2517cdf0e10cSrcweir sal_Bool SvXMLExport::writeOutlineStyleAsNormalListStyle() const 2518cdf0e10cSrcweir { 2519cdf0e10cSrcweir return mpImpl->mbOutlineStyleAsNormalListStyle; 2520cdf0e10cSrcweir } 2521cdf0e10cSrcweir // <-- 2522cdf0e10cSrcweir 2523cdf0e10cSrcweir uno::Reference< embed::XStorage > SvXMLExport::GetTargetStorage() 2524cdf0e10cSrcweir { 2525cdf0e10cSrcweir return mpImpl->mxTargetStorage; 2526cdf0e10cSrcweir } 2527cdf0e10cSrcweir 2528cdf0e10cSrcweir /// returns the currently configured default version for odf export 2529cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const 2530cdf0e10cSrcweir { 2531cdf0e10cSrcweir if( mpImpl ) 2532cdf0e10cSrcweir return mpImpl->maSaveOptions.GetODFDefaultVersion(); 2533cdf0e10cSrcweir 2534cdf0e10cSrcweir // fatal error, use current version as default 2535cdf0e10cSrcweir return SvtSaveOptions::ODFVER_012; 2536cdf0e10cSrcweir } 2537cdf0e10cSrcweir 2538cdf0e10cSrcweir ::rtl::OUString SvXMLExport::GetStreamName() const 2539cdf0e10cSrcweir { 2540cdf0e10cSrcweir return mpImpl->mStreamName; 2541cdf0e10cSrcweir } 2542cdf0e10cSrcweir 2543cdf0e10cSrcweir void 2544cdf0e10cSrcweir SvXMLExport::AddAttributeIdLegacy( 2545cdf0e10cSrcweir sal_uInt16 const nLegacyPrefix, ::rtl::OUString const& rValue) 2546cdf0e10cSrcweir { 2547cdf0e10cSrcweir switch (getDefaultVersion()) { 2548cdf0e10cSrcweir case SvtSaveOptions::ODFVER_011: // fall thru 2549cdf0e10cSrcweir case SvtSaveOptions::ODFVER_010: break; 2550cdf0e10cSrcweir default: // ODF 1.2: xml:id 2551cdf0e10cSrcweir AddAttribute(XML_NAMESPACE_XML, XML_ID, rValue); 2552cdf0e10cSrcweir } 2553cdf0e10cSrcweir // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id 2554cdf0e10cSrcweir // backward compatibility: in ODF 1.2 write _both_ id attrs 2555cdf0e10cSrcweir AddAttribute(nLegacyPrefix, XML_ID, rValue); 2556cdf0e10cSrcweir // FIXME: this function simply assumes that rValue is unique 2557cdf0e10cSrcweir } 2558cdf0e10cSrcweir 2559cdf0e10cSrcweir void 2560cdf0e10cSrcweir SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc) 2561cdf0e10cSrcweir { 2562cdf0e10cSrcweir // check version >= 1.2 2563cdf0e10cSrcweir switch (getDefaultVersion()) { 2564cdf0e10cSrcweir case SvtSaveOptions::ODFVER_011: // fall thru 2565cdf0e10cSrcweir case SvtSaveOptions::ODFVER_010: return; 2566cdf0e10cSrcweir default: break; 2567cdf0e10cSrcweir } 2568cdf0e10cSrcweir const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc, 2569cdf0e10cSrcweir uno::UNO_QUERY); 2570cdf0e10cSrcweir //FIXME not yet... 2571cdf0e10cSrcweir // OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable"); 2572cdf0e10cSrcweir if ( xMeta.is() ) 2573cdf0e10cSrcweir { 2574cdf0e10cSrcweir const beans::StringPair mdref( xMeta->getMetadataReference() ); 2575cdf0e10cSrcweir if ( !mdref.Second.equalsAscii("") ) 2576cdf0e10cSrcweir { 2577cdf0e10cSrcweir const ::rtl::OUString streamName( GetStreamName() ); 2578cdf0e10cSrcweir if ( streamName.getLength() ) 2579cdf0e10cSrcweir { 2580cdf0e10cSrcweir if ( streamName.equals(mdref.First) ) 2581cdf0e10cSrcweir { 2582cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second ); 2583cdf0e10cSrcweir } 2584cdf0e10cSrcweir else 2585cdf0e10cSrcweir { 2586cdf0e10cSrcweir OSL_ENSURE(false, "SvXMLExport::AddAttributeXmlId: " 2587cdf0e10cSrcweir "invalid stream name"); 2588cdf0e10cSrcweir } 2589cdf0e10cSrcweir } 2590cdf0e10cSrcweir else 2591cdf0e10cSrcweir { 2592cdf0e10cSrcweir // FIXME: this is ugly 2593cdf0e10cSrcweir // there is no stream name (e.g. XSLT, flat-xml format)! 2594cdf0e10cSrcweir // but how do we ensure uniqueness in this case? 2595cdf0e10cSrcweir // a) just omit styles.xml ids -- they are unlikely anyway... 2596cdf0e10cSrcweir // b) somehow find out whether we are currently exporting styles 2597cdf0e10cSrcweir // or content, and prefix "s" or "c" => unique 2598cdf0e10cSrcweir if ( mdref.First.equalsAscii("content.xml") ) 2599cdf0e10cSrcweir { 2600cdf0e10cSrcweir AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second ); 2601cdf0e10cSrcweir } 2602cdf0e10cSrcweir else 2603cdf0e10cSrcweir { 2604cdf0e10cSrcweir OSL_TRACE("SvXMLExport::AddAttributeXmlId: " 2605cdf0e10cSrcweir "no stream name given: dropping styles.xml xml:id"); 2606cdf0e10cSrcweir } 2607cdf0e10cSrcweir } 2608cdf0e10cSrcweir } 2609cdf0e10cSrcweir } 2610cdf0e10cSrcweir } 2611cdf0e10cSrcweir 2612cdf0e10cSrcweir void 2613cdf0e10cSrcweir SvXMLExport::AddAttributesRDFa( 2614cdf0e10cSrcweir uno::Reference<text::XTextContent> const & i_xTextContent) 2615cdf0e10cSrcweir { 2616cdf0e10cSrcweir // check version >= 1.2 2617cdf0e10cSrcweir switch (getDefaultVersion()) { 2618cdf0e10cSrcweir case SvtSaveOptions::ODFVER_011: // fall thru 2619cdf0e10cSrcweir case SvtSaveOptions::ODFVER_010: return; 2620cdf0e10cSrcweir default: break; 2621cdf0e10cSrcweir } 2622cdf0e10cSrcweir 2623cdf0e10cSrcweir const uno::Reference<rdf::XMetadatable> xMeta( 2624cdf0e10cSrcweir i_xTextContent, uno::UNO_QUERY); 2625cdf0e10cSrcweir if (!xMeta.is() || !xMeta->getMetadataReference().Second.getLength()) 2626cdf0e10cSrcweir { 2627cdf0e10cSrcweir return; // no xml:id => no RDFa 2628cdf0e10cSrcweir } 2629cdf0e10cSrcweir 2630cdf0e10cSrcweir if (!mpImpl->mpRDFaHelper.get()) 2631cdf0e10cSrcweir { 2632cdf0e10cSrcweir mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) ); 2633cdf0e10cSrcweir } 2634cdf0e10cSrcweir mpImpl->mpRDFaHelper->AddRDFa(xMeta); 2635cdf0e10cSrcweir } 2636cdf0e10cSrcweir 2637cdf0e10cSrcweir sal_Bool SvXMLExport::exportTextNumberElement() const 2638cdf0e10cSrcweir { 2639cdf0e10cSrcweir return mpImpl->mbExportTextNumberElement; 2640cdf0e10cSrcweir } 2641cdf0e10cSrcweir 2642cdf0e10cSrcweir sal_Bool SvXMLExport::SetNullDateOnUnitConverter() 2643cdf0e10cSrcweir { 2644cdf0e10cSrcweir // if the null date has already been set, don't set it again (performance) 2645cdf0e10cSrcweir if (!mpImpl->mbNullDateInitialized) 2646cdf0e10cSrcweir mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel()); 2647cdf0e10cSrcweir 2648cdf0e10cSrcweir return mpImpl->mbNullDateInitialized; 2649cdf0e10cSrcweir } 2650cdf0e10cSrcweir 2651c45df7c4SOliver-Rainer Wittmann 2652cdf0e10cSrcweir //============================================================================= 2653cdf0e10cSrcweir 2654c45df7c4SOliver-Rainer Wittmann 2655c45df7c4SOliver-Rainer Wittmann void SvXMLElementExport::StartElement( 2656c45df7c4SOliver-Rainer Wittmann const sal_uInt16 nPrefixKey, 2657cdf0e10cSrcweir const OUString& rLName, 2658c45df7c4SOliver-Rainer Wittmann const sal_Bool bIgnoreWhitespaceOutside ) 2659cdf0e10cSrcweir { 2660c45df7c4SOliver-Rainer Wittmann maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName); 2661c45df7c4SOliver-Rainer Wittmann mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside); 2662cdf0e10cSrcweir } 2663cdf0e10cSrcweir 2664c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2665c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2666cdf0e10cSrcweir sal_uInt16 nPrefixKey, 2667cdf0e10cSrcweir const sal_Char *pLName, 2668cdf0e10cSrcweir sal_Bool bIWSOutside, 2669c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2670c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2671c45df7c4SOliver-Rainer Wittmann , maElementName() 2672c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2673c45df7c4SOliver-Rainer Wittmann , mbDoSomething( sal_True ) 2674cdf0e10cSrcweir { 2675c45df7c4SOliver-Rainer Wittmann const OUString sLName( OUString::createFromAscii( pLName ) ); 2676c45df7c4SOliver-Rainer Wittmann StartElement( nPrefixKey, sLName, bIWSOutside ); 2677cdf0e10cSrcweir } 2678cdf0e10cSrcweir 2679c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2680c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2681cdf0e10cSrcweir sal_uInt16 nPrefixKey, 2682cdf0e10cSrcweir const OUString& rLName, 2683cdf0e10cSrcweir sal_Bool bIWSOutside, 2684c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2685c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2686c45df7c4SOliver-Rainer Wittmann , maElementName() 2687c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2688c45df7c4SOliver-Rainer Wittmann , mbDoSomething( sal_True ) 2689cdf0e10cSrcweir { 2690c45df7c4SOliver-Rainer Wittmann StartElement( nPrefixKey, rLName, bIWSOutside ); 2691cdf0e10cSrcweir } 2692cdf0e10cSrcweir 2693c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2694c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2695cdf0e10cSrcweir sal_uInt16 nPrefixKey, 2696cdf0e10cSrcweir enum XMLTokenEnum eLName, 2697cdf0e10cSrcweir sal_Bool bIWSOutside, 2698c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2699c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2700c45df7c4SOliver-Rainer Wittmann , maElementName() 2701c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2702c45df7c4SOliver-Rainer Wittmann , mbDoSomething( sal_True ) 2703cdf0e10cSrcweir { 2704c45df7c4SOliver-Rainer Wittmann StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside ); 2705cdf0e10cSrcweir } 2706cdf0e10cSrcweir 2707c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2708c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2709cdf0e10cSrcweir sal_Bool bDoSth, 2710cdf0e10cSrcweir sal_uInt16 nPrefixKey, 2711cdf0e10cSrcweir const sal_Char *pLName, 2712cdf0e10cSrcweir sal_Bool bIWSOutside, 2713c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2714c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2715c45df7c4SOliver-Rainer Wittmann , maElementName() 2716c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2717c45df7c4SOliver-Rainer Wittmann , mbDoSomething( bDoSth ) 2718cdf0e10cSrcweir { 2719c45df7c4SOliver-Rainer Wittmann if ( mbDoSomething ) 2720cdf0e10cSrcweir { 2721c45df7c4SOliver-Rainer Wittmann const OUString sLName( OUString::createFromAscii( pLName ) ); 2722c45df7c4SOliver-Rainer Wittmann StartElement( nPrefixKey, sLName, bIWSOutside ); 2723cdf0e10cSrcweir } 2724cdf0e10cSrcweir } 2725cdf0e10cSrcweir 2726c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2727c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2728cdf0e10cSrcweir sal_Bool bDoSth, 2729cdf0e10cSrcweir sal_uInt16 nPrefixKey, 2730cdf0e10cSrcweir const OUString& rLName, 2731cdf0e10cSrcweir sal_Bool bIWSOutside, 2732c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2733c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2734c45df7c4SOliver-Rainer Wittmann , maElementName() 2735c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2736c45df7c4SOliver-Rainer Wittmann , mbDoSomething( bDoSth ) 2737cdf0e10cSrcweir { 2738c45df7c4SOliver-Rainer Wittmann if ( mbDoSomething ) 2739c45df7c4SOliver-Rainer Wittmann StartElement( nPrefixKey, rLName, bIWSOutside ); 2740cdf0e10cSrcweir } 2741cdf0e10cSrcweir 2742c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2743c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2744cdf0e10cSrcweir sal_Bool bDoSth, 2745cdf0e10cSrcweir sal_uInt16 nPrefixKey, 2746cdf0e10cSrcweir enum XMLTokenEnum eLName, 2747cdf0e10cSrcweir sal_Bool bIWSOutside, 2748c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2749c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2750c45df7c4SOliver-Rainer Wittmann , maElementName() 2751c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2752c45df7c4SOliver-Rainer Wittmann , mbDoSomething( bDoSth ) 2753cdf0e10cSrcweir { 2754c45df7c4SOliver-Rainer Wittmann if ( mbDoSomething ) 2755c45df7c4SOliver-Rainer Wittmann StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside ); 2756cdf0e10cSrcweir } 2757cdf0e10cSrcweir 2758c45df7c4SOliver-Rainer Wittmann SvXMLElementExport::SvXMLElementExport( 2759c45df7c4SOliver-Rainer Wittmann SvXMLExport& rExp, 2760cdf0e10cSrcweir const OUString& rQName, 2761cdf0e10cSrcweir sal_Bool bIWSOutside, 2762c45df7c4SOliver-Rainer Wittmann sal_Bool bIWSInside ) 2763c45df7c4SOliver-Rainer Wittmann : mrExport( rExp ) 2764c45df7c4SOliver-Rainer Wittmann , maElementName() 2765c45df7c4SOliver-Rainer Wittmann , mbIgnoreWhitespaceInside( bIWSInside ) 2766c45df7c4SOliver-Rainer Wittmann , mbDoSomething( sal_True ) 2767cdf0e10cSrcweir { 2768c45df7c4SOliver-Rainer Wittmann maElementName = rQName; 2769cdf0e10cSrcweir rExp.StartElement( rQName, bIWSOutside ); 2770cdf0e10cSrcweir } 2771cdf0e10cSrcweir 2772cdf0e10cSrcweir SvXMLElementExport::~SvXMLElementExport() 2773cdf0e10cSrcweir { 2774c45df7c4SOliver-Rainer Wittmann if ( mbDoSomething ) 2775cdf0e10cSrcweir { 2776c45df7c4SOliver-Rainer Wittmann mrExport.EndElement( maElementName, mbIgnoreWhitespaceInside ); 2777cdf0e10cSrcweir } 2778cdf0e10cSrcweir } 2779cdf0e10cSrcweir 2780