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

Generated by: LCOV version 1.10