LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/core - xmlexp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 685 1146 59.8 %
Date: 2012-12-17 Functions: 74 116 63.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10