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