LCOV - code coverage report
Current view: top level - xmloff/source/draw - sdxmlimp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 302 353 85.6 %
Date: 2015-06-13 12:38:46 Functions: 65 86 75.6 %
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 <osl/thread.h>
      21             : #include <comphelper/processfactory.hxx>
      22             : 
      23             : #include <xmloff/xmlscripti.hxx>
      24             : #include "facreg.hxx"
      25             : #include "sdxmlimp_impl.hxx"
      26             : #include "ximpbody.hxx"
      27             : 
      28             : #include <xmloff/xmlmetai.hxx>
      29             : #include "ximpstyl.hxx"
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/xmltoken.hxx>
      32             : #include <xmloff/xmluconv.hxx>
      33             : #include <xmloff/DocumentSettingsContext.hxx>
      34             : #include <com/sun/star/form/XFormsSupplier.hpp>
      35             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      36             : #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
      37             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      38             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      39             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      40             : #include "sdpropls.hxx"
      41             : #include <xmloff/xmlexppr.hxx>
      42             : #include <xmloff/xmlerror.hxx>
      43             : #include <xmloff/settingsstore.hxx>
      44             : #include <com/sun/star/style/XStyle.hpp>
      45             : 
      46             : #include <xmloff/XMLFontStylesContext.hxx>
      47             : 
      48             : #include <com/sun/star/document/XDocumentProperties.hpp>
      49             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      50             : 
      51             : using namespace ::com::sun::star;
      52             : using namespace ::xmloff::token;
      53             : 
      54             : class SdXMLBodyContext_Impl : public SvXMLImportContext
      55             : {
      56          89 :     SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
      57             : 
      58             : public:
      59             : 
      60             :     SdXMLBodyContext_Impl( SdXMLImport& rImport, sal_uInt16 nPrfx,
      61             :                 const OUString& rLName,
      62             :                 const uno::Reference< xml::sax::XAttributeList > & xAttrList );
      63             :     virtual ~SdXMLBodyContext_Impl();
      64             : 
      65             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
      66             :                 const OUString& rLocalName,
      67             :                 const uno::Reference< xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
      68             : };
      69             : 
      70          89 : SdXMLBodyContext_Impl::SdXMLBodyContext_Impl( SdXMLImport& rImport,
      71             :                 sal_uInt16 nPrfx, const OUString& rLName,
      72             :                 const uno::Reference< xml::sax::XAttributeList > & ) :
      73          89 :     SvXMLImportContext( rImport, nPrfx, rLName )
      74             : {
      75          89 : }
      76             : 
      77         178 : SdXMLBodyContext_Impl::~SdXMLBodyContext_Impl()
      78             : {
      79         178 : }
      80             : 
      81          89 : SvXMLImportContext *SdXMLBodyContext_Impl::CreateChildContext(
      82             :         sal_uInt16 /*nPrefix*/,
      83             :         const OUString& rLocalName,
      84             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
      85             : {
      86          89 :     return GetSdImport().CreateBodyContext(rLocalName, xAttrList);
      87             : }
      88             : 
      89             : // NB: virtually inherit so we can multiply inherit properly
      90             : //     in SdXMLFlatDocContext_Impl
      91             : class SdXMLDocContext_Impl : public virtual SvXMLImportContext
      92             : {
      93             : protected:
      94        1530 :     SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
      95             : 
      96             : public:
      97             :     SdXMLDocContext_Impl(
      98             :         SdXMLImport& rImport,
      99             :         sal_uInt16 nPrfx,
     100             :         const OUString& rLName,
     101             :         const uno::Reference<xml::sax::XAttributeList>& xAttrList);
     102             :     virtual ~SdXMLDocContext_Impl();
     103             : 
     104             :     TYPEINFO_OVERRIDE();
     105             : 
     106             :     virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
     107             :         const OUString& rLocalName,
     108             :         const uno::Reference<xml::sax::XAttributeList>& xAttrList) SAL_OVERRIDE;
     109             : };
     110             : 
     111         177 : SdXMLDocContext_Impl::SdXMLDocContext_Impl(
     112             :     SdXMLImport& rImport,
     113             :     sal_uInt16 nPrfx,
     114             :     const OUString& rLName,
     115             :     const uno::Reference<xml::sax::XAttributeList>&)
     116         177 : :   SvXMLImportContext(rImport, nPrfx, rLName)
     117             : {
     118         177 : }
     119             : 
     120         441 : SdXMLDocContext_Impl::~SdXMLDocContext_Impl()
     121             : {
     122         441 : }
     123             : 
     124           0 : TYPEINIT1( SdXMLDocContext_Impl, SvXMLImportContext );
     125             : 
     126         656 : SvXMLImportContext *SdXMLDocContext_Impl::CreateChildContext(
     127             :     sal_uInt16 nPrefix,
     128             :     const OUString& rLocalName,
     129             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     130             : {
     131         656 :     SvXMLImportContext* pContext = 0L;
     132             : 
     133         656 :     const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap();
     134         656 :     switch(rTokenMap.Get(nPrefix, rLocalName))
     135             :     {
     136             :         case XML_TOK_DOC_FONTDECLS:
     137             :         {
     138         125 :             pContext = GetSdImport().CreateFontDeclsContext( rLocalName, xAttrList );
     139         125 :             break;
     140             :         }
     141             :         case XML_TOK_DOC_SETTINGS:
     142             :         {
     143          87 :             if( GetImport().getImportFlags() & SvXMLImportFlags::SETTINGS )
     144             :             {
     145          87 :                 pContext = new XMLDocumentSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList );
     146             :             }
     147          87 :             break;
     148             :         }
     149             :         case XML_TOK_DOC_STYLES:
     150             :         {
     151          89 :             if( GetImport().getImportFlags() & SvXMLImportFlags::STYLES )
     152             :             {
     153             :                 // office:styles inside office:document
     154          89 :                 pContext = GetSdImport().CreateStylesContext(rLocalName, xAttrList);
     155             :             }
     156          89 :             break;
     157             :         }
     158             :         case XML_TOK_DOC_AUTOSTYLES:
     159             :         {
     160         133 :             if( GetImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES )
     161             :             {
     162             :                 // office:automatic-styles inside office:document
     163         133 :                 pContext = GetSdImport().CreateAutoStylesContext(rLocalName, xAttrList);
     164             :             }
     165         133 :             break;
     166             :         }
     167             :         case XML_TOK_DOC_MASTERSTYLES:
     168             :         {
     169          89 :             if( GetImport().getImportFlags() & SvXMLImportFlags::MASTERSTYLES )
     170             :             {
     171             :                 // office:master-styles inside office:document
     172          89 :                 pContext = GetSdImport().CreateMasterStylesContext(rLocalName, xAttrList);
     173             :             }
     174          89 :             break;
     175             :         }
     176             :         case XML_TOK_DOC_META:
     177             :         {
     178             :             SAL_INFO("xmloff.draw", "XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
     179           0 :             break;
     180             :         }
     181             :         case XML_TOK_DOC_SCRIPT:
     182             :         {
     183          44 :             if( GetImport().getImportFlags() & SvXMLImportFlags::SCRIPTS )
     184             :             {
     185             :                 // office:script inside office:document
     186          44 :                 pContext = GetSdImport().CreateScriptContext( rLocalName );
     187             :             }
     188          44 :             break;
     189             :         }
     190             :         case XML_TOK_DOC_BODY:
     191             :         {
     192          89 :             if( GetImport().getImportFlags() & SvXMLImportFlags::CONTENT )
     193             :             {
     194             :                 // office:body inside office:document
     195             :                 pContext = new SdXMLBodyContext_Impl(GetSdImport(),nPrefix,
     196          89 :                                                      rLocalName, xAttrList);
     197             :             }
     198          89 :             break;
     199             :         }
     200             :     }
     201             : 
     202             :     // call parent when no own context was created
     203         656 :     if(!pContext)
     204           0 :         pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
     205             : 
     206         656 :     return pContext;
     207             : }
     208             : 
     209             : // context for flat file xml format
     210             : class SdXMLFlatDocContext_Impl
     211             :     : public SdXMLDocContext_Impl, public SvXMLMetaDocumentContext
     212             : {
     213             : public:
     214             :     SdXMLFlatDocContext_Impl( SdXMLImport& i_rImport,
     215             :         sal_uInt16 i_nPrefix, const OUString & i_rLName,
     216             :         const uno::Reference<xml::sax::XAttributeList>& i_xAttrList,
     217             :         const uno::Reference<document::XDocumentProperties>& i_xDocProps);
     218             : 
     219             :     virtual ~SdXMLFlatDocContext_Impl();
     220             : 
     221             :     virtual SvXMLImportContext *CreateChildContext(
     222             :         sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
     223             :         const uno::Reference<xml::sax::XAttributeList>& i_xAttrList) SAL_OVERRIDE;
     224             : };
     225             : 
     226          45 : SdXMLFlatDocContext_Impl::SdXMLFlatDocContext_Impl( SdXMLImport& i_rImport,
     227             :         sal_uInt16 i_nPrefix, const OUString & i_rLName,
     228             :         const uno::Reference<xml::sax::XAttributeList>& i_xAttrList,
     229             :         const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
     230             :     SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
     231             :     SdXMLDocContext_Impl(i_rImport, i_nPrefix, i_rLName, i_xAttrList),
     232             :     SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
     233          45 :         i_xDocProps)
     234             : {
     235          45 : }
     236             : 
     237          90 : SdXMLFlatDocContext_Impl::~SdXMLFlatDocContext_Impl() { }
     238             : 
     239         305 : SvXMLImportContext *SdXMLFlatDocContext_Impl::CreateChildContext(
     240             :     sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
     241             :     const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
     242             : {
     243             :     // behave like meta base class iff we encounter office:meta
     244         305 :     const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap();
     245         305 :     if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) {
     246             :         return SvXMLMetaDocumentContext::CreateChildContext(
     247          39 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     248             :     } else {
     249             :         return SdXMLDocContext_Impl::CreateChildContext(
     250         266 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     251             :     }
     252             : }
     253             : 
     254             : #define SERVICE(classname,servicename,implementationname,draw,flags)\
     255             : uno::Sequence< OUString > SAL_CALL classname##_getSupportedServiceNames() throw()\
     256             : {\
     257             :     const OUString aServiceName(  servicename  );\
     258             :     const uno::Sequence< OUString > aSeq( &aServiceName, 1 );\
     259             :     return aSeq;\
     260             : }\
     261             : OUString SAL_CALL classname##_getImplementationName() throw()\
     262             : {\
     263             :     return OUString(  implementationname  );\
     264             : }\
     265             : uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )\
     266             : {\
     267             :     return static_cast<cppu::OWeakObject*>(new SdXMLImport( comphelper::getComponentContext(rSMgr), implementationname, draw, flags )); \
     268             : }
     269             : 
     270         118 : SERVICE( XMLImpressImportOasis, "com.sun.star.comp.Impress.XMLOasisImporter", "XMLImpressImportOasis", false, SvXMLImportFlags::ALL )
     271         115 : SERVICE( XMLDrawImportOasis, "com.sun.star.comp.Draw.XMLOasisImporter", "XMLDrawImportOasis", true, SvXMLImportFlags::ALL )
     272             : 
     273         174 : SERVICE( XMLImpressStylesImportOasis, "com.sun.star.comp.Impress.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", false, SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES )
     274          60 : SERVICE( XMLDrawStylesImportOasis, "com.sun.star.comp.Draw.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", true, SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES )
     275             : 
     276         167 : SERVICE( XMLImpressContentImportOasis, "com.sun.star.comp.Impress.XMLOasisContentImporter", "XMLImpressContentImportOasis", false, SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::CONTENT|SvXMLImportFlags::SCRIPTS|SvXMLImportFlags::FONTDECLS )
     277          60 : SERVICE( XMLDrawContentImportOasis, "com.sun.star.comp.Draw.XMLOasisContentImporter", "XMLImpressContentImportOasis", true, SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::CONTENT|SvXMLImportFlags::SCRIPTS|SvXMLImportFlags::FONTDECLS )
     278             : 
     279         150 : SERVICE( XMLImpressMetaImportOasis, "com.sun.star.comp.Impress.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", false, SvXMLImportFlags::META )
     280          60 : SERVICE( XMLDrawMetaImportOasis, "com.sun.star.comp.Draw.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", true, SvXMLImportFlags::META )
     281             : 
     282         143 : SERVICE( XMLImpressSettingsImportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", false, SvXMLImportFlags::SETTINGS )
     283          60 : SERVICE( XMLDrawSettingsImportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", true, SvXMLImportFlags::SETTINGS )
     284             : 
     285             : // #110680#
     286         226 : SdXMLImport::SdXMLImport(
     287             :     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
     288             :     OUString const & implementationName,
     289             :     bool bIsDraw, SvXMLImportFlags nImportFlags )
     290             : :   SvXMLImport( xContext, implementationName, nImportFlags ),
     291             :     mpMasterStylesContext(0L),
     292             :     mpDocElemTokenMap(0L),
     293             :     mpBodyElemTokenMap(0L),
     294             :     mpStylesElemTokenMap(0L),
     295             :     mpMasterPageElemTokenMap(0L),
     296             :     mpMasterPageAttrTokenMap(0L),
     297             :     mpPageMasterAttrTokenMap(0L),
     298             :     mpPageMasterStyleAttrTokenMap(0L),
     299             :     mpDrawPageAttrTokenMap(0L),
     300             :     mpDrawPageElemTokenMap(0L),
     301             :     mpPresentationPlaceholderAttrTokenMap(0L),
     302             :     mnStyleFamilyMask(0),
     303             :     mnNewPageCount(0L),
     304             :     mnNewMasterPageCount(0L),
     305             :     mbIsDraw(bIsDraw),
     306             :     mbLoadDoc(true),
     307             :     mbPreview(false),
     308             :     msPageLayouts(  "PageLayouts"  ),
     309         226 :     msPreview(  "Preview"  )
     310             : {
     311             :     // add namespaces
     312         226 :     GetNamespaceMap().Add(
     313         226 :         GetXMLToken(XML_NP_PRESENTATION),
     314         226 :         GetXMLToken(XML_N_PRESENTATION),
     315         226 :         XML_NAMESPACE_PRESENTATION);
     316             : 
     317         226 :     GetNamespaceMap().Add(
     318         226 :         GetXMLToken(XML_NP_SMIL),
     319         226 :         GetXMLToken(XML_N_SMIL_COMPAT),
     320         226 :         XML_NAMESPACE_SMIL);
     321             : 
     322         226 :     GetNamespaceMap().Add(
     323         226 :         GetXMLToken(XML_NP_ANIMATION),
     324         226 :         GetXMLToken(XML_N_ANIMATION),
     325         226 :         XML_NAMESPACE_ANIMATION);
     326         226 : }
     327             : 
     328             : // XImporter
     329         222 : void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
     330             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     331             : {
     332         222 :     SvXMLImport::setTargetDocument( xDoc );
     333             : 
     334         222 :     uno::Reference< lang::XServiceInfo > xDocServices( GetModel(), uno::UNO_QUERY );
     335         222 :     if( !xDocServices.is() )
     336           0 :         throw lang::IllegalArgumentException();
     337             : 
     338         222 :     mbIsDraw = !xDocServices->supportsService("com.sun.star.presentation.PresentationDocument");
     339             : 
     340             :     // prepare access to styles
     341         444 :     uno::Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), uno::UNO_QUERY );
     342         222 :     if(xFamSup.is())
     343         222 :         mxDocStyleFamilies = xFamSup->getStyleFamilies();
     344             : 
     345             :     // prepare access to master pages
     346         444 :     uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
     347         222 :     if(xMasterPagesSupplier.is())
     348         222 :         mxDocMasterPages.set(xMasterPagesSupplier->getMasterPages(), css::uno::UNO_QUERY);
     349             : 
     350             :     // prepare access to draw pages
     351         444 :     uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY);
     352         222 :     if(!xDrawPagesSupplier.is())
     353           0 :         throw lang::IllegalArgumentException();
     354             : 
     355         222 :     mxDocDrawPages.set(xDrawPagesSupplier->getDrawPages(), css::uno::UNO_QUERY);
     356         222 :     if(!mxDocDrawPages.is())
     357           0 :         throw lang::IllegalArgumentException();
     358             : 
     359         222 :     if( mxDocDrawPages.is() && mxDocDrawPages->getCount() > 0 )
     360             :     {
     361         222 :         uno::Reference< form::XFormsSupplier > xFormsSupp;
     362         222 :         mxDocDrawPages->getByIndex(0) >>= xFormsSupp;
     363         222 :         mbIsFormsSupported = xFormsSupp.is();
     364             :     }
     365             : 
     366             :     // #88546# enable progress bar increments, SdXMLImport is only used for
     367             :     // draw/impress import
     368         222 :     GetShapeImport()->enableHandleProgressBar();
     369             : 
     370         444 :     uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
     371         222 :     if( xFac.is() )
     372             :     {
     373         222 :         uno::Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
     374         222 :         sal_Int32 n = sSNS.getLength();
     375         222 :         const OUString* pSNS( sSNS.getConstArray() );
     376         222 :         while( --n > 0 )
     377             :         {
     378       15318 :             if( (*pSNS++) == "com.sun.star.drawing.TableShape" )
     379             :             {
     380         222 :                 mbIsTableShapeSupported = true;
     381         222 :                 break;
     382             :             }
     383         222 :         }
     384         222 :     }
     385         222 : }
     386             : 
     387             : // XInitialization
     388         187 : void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
     389             :     throw( uno::Exception, uno::RuntimeException, std::exception)
     390             : {
     391         187 :     SvXMLImport::initialize( aArguments );
     392             : 
     393         187 :     uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() );
     394         187 :     if( xInfoSet.is() )
     395             :     {
     396         172 :         uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
     397             : 
     398         172 :         if( xInfoSetInfo->hasPropertyByName( msPageLayouts ) )
     399         170 :             xInfoSet->getPropertyValue( msPageLayouts ) >>= mxPageLayouts;
     400             : 
     401         172 :         if( xInfoSetInfo->hasPropertyByName( msPreview ) )
     402         170 :             xInfoSet->getPropertyValue( msPreview ) >>= mbPreview;
     403             : 
     404             :         OUString const sOrganizerMode(
     405         344 :             "OrganizerMode");
     406         172 :         if (xInfoSetInfo->hasPropertyByName(sOrganizerMode))
     407             :         {
     408         170 :             bool bStyleOnly(false);
     409         170 :             if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
     410             :             {
     411           0 :                 mbLoadDoc = !bStyleOnly;
     412             :             }
     413         172 :         }
     414         187 :     }
     415         187 : }
     416             : 
     417         678 : SdXMLImport::~SdXMLImport() throw ()
     418             : {
     419             :     // Styles or AutoStyles context?
     420         226 :     if(mpMasterStylesContext)
     421          89 :         mpMasterStylesContext->ReleaseRef();
     422             : 
     423             :     // delete all token maps
     424         226 :     if(mpDocElemTokenMap)
     425         177 :         delete mpDocElemTokenMap;
     426         226 :     if(mpBodyElemTokenMap)
     427          88 :         delete mpBodyElemTokenMap;
     428         226 :     if(mpStylesElemTokenMap)
     429         132 :         delete mpStylesElemTokenMap;
     430         226 :     if(mpMasterPageElemTokenMap)
     431          45 :         delete mpMasterPageElemTokenMap;
     432         226 :     if(mpMasterPageAttrTokenMap)
     433         130 :         delete mpMasterPageAttrTokenMap;
     434         226 :     if(mpPageMasterAttrTokenMap)
     435          88 :         delete mpPageMasterAttrTokenMap;
     436         226 :     if(mpPageMasterStyleAttrTokenMap)
     437          88 :         delete mpPageMasterStyleAttrTokenMap;
     438         226 :     if(mpDrawPageAttrTokenMap)
     439          88 :         delete mpDrawPageAttrTokenMap;
     440         226 :     if(mpDrawPageElemTokenMap)
     441          87 :         delete mpDrawPageElemTokenMap;
     442         226 :     if(mpPresentationPlaceholderAttrTokenMap)
     443          41 :         delete mpPresentationPlaceholderAttrTokenMap;
     444         452 : }
     445             : 
     446         961 : const SvXMLTokenMap& SdXMLImport::GetDocElemTokenMap()
     447             : {
     448         961 :     if(!mpDocElemTokenMap)
     449             :     {
     450             :         static const SvXMLTokenMapEntry aDocElemTokenMap[] =
     451             : {
     452             :     { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS,    XML_TOK_DOC_FONTDECLS       },
     453             :     { XML_NAMESPACE_OFFICE, XML_STYLES,             XML_TOK_DOC_STYLES          },
     454             :     { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES,   XML_TOK_DOC_AUTOSTYLES      },
     455             :     { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES,      XML_TOK_DOC_MASTERSTYLES    },
     456             :     { XML_NAMESPACE_OFFICE, XML_META,               XML_TOK_DOC_META            },
     457             :     { XML_NAMESPACE_OFFICE, XML_SCRIPTS,            XML_TOK_DOC_SCRIPT          },
     458             :     { XML_NAMESPACE_OFFICE, XML_BODY,               XML_TOK_DOC_BODY            },
     459             :     { XML_NAMESPACE_OFFICE, XML_SETTINGS,           XML_TOK_DOC_SETTINGS        },
     460             :     XML_TOKEN_MAP_END
     461             : };
     462             : 
     463         177 :         mpDocElemTokenMap = new SvXMLTokenMap(aDocElemTokenMap);
     464             :     } // if(!mpDocElemTokenMap)
     465             : 
     466         961 :     return *mpDocElemTokenMap;
     467             : }
     468             : 
     469         165 : const SvXMLTokenMap& SdXMLImport::GetBodyElemTokenMap()
     470             : {
     471         165 :     if(!mpBodyElemTokenMap)
     472             :     {
     473             :         static const SvXMLTokenMapEntry aBodyElemTokenMap[] =
     474             : {
     475             :     { XML_NAMESPACE_DRAW,   XML_PAGE,               XML_TOK_BODY_PAGE   },
     476             :     { XML_NAMESPACE_PRESENTATION, XML_SETTINGS,     XML_TOK_BODY_SETTINGS   },
     477             :     { XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL,  XML_TOK_BODY_HEADER_DECL    },
     478             :     { XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL,  XML_TOK_BODY_FOOTER_DECL    },
     479             :     { XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL,XML_TOK_BODY_DATE_TIME_DECL    },
     480             : 
     481             :     XML_TOKEN_MAP_END
     482             : };
     483             : 
     484          88 :         mpBodyElemTokenMap = new SvXMLTokenMap(aBodyElemTokenMap);
     485             :     } // if(!mpBodyElemTokenMap)
     486             : 
     487         165 :     return *mpBodyElemTokenMap;
     488             : }
     489             : 
     490        3193 : const SvXMLTokenMap& SdXMLImport::GetStylesElemTokenMap()
     491             : {
     492        3193 :     if(!mpStylesElemTokenMap)
     493             :     {
     494             :         static const SvXMLTokenMapEntry aStylesElemTokenMap[] =
     495             : {
     496             :     { XML_NAMESPACE_STYLE,  XML_PAGE_LAYOUT,                XML_TOK_STYLES_PAGE_MASTER              },
     497             :     { XML_NAMESPACE_STYLE,  XML_PRESENTATION_PAGE_LAYOUT,   XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT },
     498             :     { XML_NAMESPACE_STYLE,  XML_STYLE,                      XML_TOK_STYLES_STYLE    },
     499             :     XML_TOKEN_MAP_END
     500             : };
     501             : 
     502         132 :         mpStylesElemTokenMap = new SvXMLTokenMap(aStylesElemTokenMap);
     503             :     } // if(!mpStylesElemTokenMap)
     504             : 
     505        3193 :     return *mpStylesElemTokenMap;
     506             : }
     507             : 
     508         664 : const SvXMLTokenMap& SdXMLImport::GetMasterPageElemTokenMap()
     509             : {
     510         664 :     if(!mpMasterPageElemTokenMap)
     511             :     {
     512             :         static const SvXMLTokenMapEntry aMasterPageElemTokenMap[] =
     513             : {
     514             :     { XML_NAMESPACE_STYLE,          XML_STYLE,      XML_TOK_MASTERPAGE_STYLE    },
     515             :     { XML_NAMESPACE_PRESENTATION,   XML_NOTES,      XML_TOK_MASTERPAGE_NOTES    },
     516             :     XML_TOKEN_MAP_END
     517             : };
     518             : 
     519          45 :         mpMasterPageElemTokenMap = new SvXMLTokenMap(aMasterPageElemTokenMap);
     520             :     } // if(!mpMasterPageElemTokenMap)
     521             : 
     522         664 :     return *mpMasterPageElemTokenMap;
     523             : }
     524             : 
     525         528 : const SvXMLTokenMap& SdXMLImport::GetMasterPageAttrTokenMap()
     526             : {
     527         528 :     if(!mpMasterPageAttrTokenMap)
     528             :     {
     529             :         static const SvXMLTokenMapEntry aMasterPageAttrTokenMap[] =
     530             : {
     531             :     { XML_NAMESPACE_STYLE,  XML_NAME,                       XML_TOK_MASTERPAGE_NAME },
     532             :     { XML_NAMESPACE_STYLE,  XML_DISPLAY_NAME,               XML_TOK_MASTERPAGE_DISPLAY_NAME },
     533             :     { XML_NAMESPACE_STYLE,  XML_PAGE_LAYOUT_NAME,           XML_TOK_MASTERPAGE_PAGE_MASTER_NAME },
     534             :     { XML_NAMESPACE_DRAW,   XML_STYLE_NAME,                 XML_TOK_MASTERPAGE_STYLE_NAME       },
     535             :     { XML_NAMESPACE_PRESENTATION,   XML_PRESENTATION_PAGE_LAYOUT_NAME,  XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME },
     536             :     { XML_NAMESPACE_PRESENTATION,   XML_USE_HEADER_NAME,                XML_TOK_MASTERPAGE_USE_HEADER_NAME  },
     537             :     { XML_NAMESPACE_PRESENTATION,   XML_USE_FOOTER_NAME,                XML_TOK_MASTERPAGE_USE_FOOTER_NAME  },
     538             :     { XML_NAMESPACE_PRESENTATION,   XML_USE_DATE_TIME_NAME,             XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME   },
     539             :     XML_TOKEN_MAP_END
     540             : };
     541             : 
     542         130 :         mpMasterPageAttrTokenMap = new SvXMLTokenMap(aMasterPageAttrTokenMap);
     543             :     } // if(!mpMasterPageAttrTokenMap)
     544             : 
     545         528 :     return *mpMasterPageAttrTokenMap;
     546             : }
     547             : 
     548         132 : const SvXMLTokenMap& SdXMLImport::GetPageMasterAttrTokenMap()
     549             : {
     550         132 :     if(!mpPageMasterAttrTokenMap)
     551             :     {
     552             :         static const SvXMLTokenMapEntry aPageMasterAttrTokenMap[] =
     553             : {
     554             :     { XML_NAMESPACE_STYLE,          XML_NAME,               XML_TOK_PAGEMASTER_NAME                 },
     555             :     XML_TOKEN_MAP_END
     556             : };
     557             : 
     558          88 :         mpPageMasterAttrTokenMap = new SvXMLTokenMap(aPageMasterAttrTokenMap);
     559             :     } // if(!mpPageMasterAttrTokenMap)
     560             : 
     561         132 :     return *mpPageMasterAttrTokenMap;
     562             : }
     563             : 
     564         961 : const SvXMLTokenMap& SdXMLImport::GetPageMasterStyleAttrTokenMap()
     565             : {
     566         961 :     if(!mpPageMasterStyleAttrTokenMap)
     567             :     {
     568             :         static const SvXMLTokenMapEntry aPageMasterStyleAttrTokenMap[] =
     569             : {
     570             :     { XML_NAMESPACE_FO,             XML_MARGIN_TOP,         XML_TOK_PAGEMASTERSTYLE_MARGIN_TOP          },
     571             :     { XML_NAMESPACE_FO,             XML_MARGIN_BOTTOM,      XML_TOK_PAGEMASTERSTYLE_MARGIN_BOTTOM       },
     572             :     { XML_NAMESPACE_FO,             XML_MARGIN_LEFT,        XML_TOK_PAGEMASTERSTYLE_MARGIN_LEFT         },
     573             :     { XML_NAMESPACE_FO,             XML_MARGIN_RIGHT,       XML_TOK_PAGEMASTERSTYLE_MARGIN_RIGHT        },
     574             :     { XML_NAMESPACE_FO,             XML_PAGE_WIDTH,         XML_TOK_PAGEMASTERSTYLE_PAGE_WIDTH          },
     575             :     { XML_NAMESPACE_FO,             XML_PAGE_HEIGHT,        XML_TOK_PAGEMASTERSTYLE_PAGE_HEIGHT         },
     576             :     { XML_NAMESPACE_STYLE,          XML_PRINT_ORIENTATION,  XML_TOK_PAGEMASTERSTYLE_PAGE_ORIENTATION    },
     577             :     XML_TOKEN_MAP_END
     578             : };
     579             : 
     580          88 :         mpPageMasterStyleAttrTokenMap = new SvXMLTokenMap(aPageMasterStyleAttrTokenMap);
     581             :     } // if(!mpPageMasterStyleAttrTokenMap)
     582             : 
     583         961 :     return *mpPageMasterStyleAttrTokenMap;
     584             : }
     585             : 
     586         427 : const SvXMLTokenMap& SdXMLImport::GetDrawPageAttrTokenMap()
     587             : {
     588         427 :     if(!mpDrawPageAttrTokenMap)
     589             :     {
     590             :         static const SvXMLTokenMapEntry aDrawPageAttrTokenMap[] =
     591             : {
     592             :     { XML_NAMESPACE_DRAW,           XML_NAME,                           XML_TOK_DRAWPAGE_NAME               },
     593             :     { XML_NAMESPACE_DRAW,           XML_STYLE_NAME,                     XML_TOK_DRAWPAGE_STYLE_NAME         },
     594             :     { XML_NAMESPACE_DRAW,           XML_MASTER_PAGE_NAME,               XML_TOK_DRAWPAGE_MASTER_PAGE_NAME   },
     595             :     { XML_NAMESPACE_PRESENTATION,   XML_PRESENTATION_PAGE_LAYOUT_NAME,  XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME   },
     596             :     { XML_NAMESPACE_DRAW,           XML_ID,                             XML_TOK_DRAWPAGE_DRAWID                 },
     597             :     { XML_NAMESPACE_XML,            XML_ID,                             XML_TOK_DRAWPAGE_XMLID                  },
     598             :     { XML_NAMESPACE_XLINK,          XML_HREF,                           XML_TOK_DRAWPAGE_HREF               },
     599             :     { XML_NAMESPACE_PRESENTATION,   XML_USE_HEADER_NAME,                XML_TOK_DRAWPAGE_USE_HEADER_NAME    },
     600             :     { XML_NAMESPACE_PRESENTATION,   XML_USE_FOOTER_NAME,                XML_TOK_DRAWPAGE_USE_FOOTER_NAME    },
     601             :     { XML_NAMESPACE_PRESENTATION,   XML_USE_DATE_TIME_NAME,             XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME },
     602             : 
     603             :     XML_TOKEN_MAP_END
     604             : };
     605             : 
     606          88 :         mpDrawPageAttrTokenMap = new SvXMLTokenMap(aDrawPageAttrTokenMap);
     607             :     } // if(!mpDrawPageAttrTokenMap)
     608             : 
     609         427 :     return *mpDrawPageAttrTokenMap;
     610             : }
     611             : 
     612         986 : const SvXMLTokenMap& SdXMLImport::GetDrawPageElemTokenMap()
     613             : {
     614         986 :     if(!mpDrawPageElemTokenMap)
     615             :     {
     616             :         static const SvXMLTokenMapEntry aDrawPageElemTokenMap[] =
     617             : {
     618             :     { XML_NAMESPACE_PRESENTATION,   XML_NOTES,              XML_TOK_DRAWPAGE_NOTES      },
     619             :     { XML_NAMESPACE_ANIMATION,      XML_PAR,                XML_TOK_DRAWPAGE_PAR        },
     620             :     { XML_NAMESPACE_ANIMATION,      XML_SEQ,                XML_TOK_DRAWPAGE_SEQ        },
     621             :     XML_TOKEN_MAP_END
     622             : };
     623             : 
     624          87 :         mpDrawPageElemTokenMap = new SvXMLTokenMap(aDrawPageElemTokenMap);
     625             :     } // if(!mpDrawPageElemTokenMap)
     626             : 
     627         986 :     return *mpDrawPageElemTokenMap;
     628             : }
     629             : 
     630        1755 : const SvXMLTokenMap& SdXMLImport::GetPresentationPlaceholderAttrTokenMap()
     631             : {
     632        1755 :     if(!mpPresentationPlaceholderAttrTokenMap)
     633             :     {
     634             :         static const SvXMLTokenMapEntry aPresentationPlaceholderAttrTokenMap[] =
     635             : {
     636             :     { XML_NAMESPACE_PRESENTATION,   XML_OBJECT,     XML_TOK_PRESENTATIONPLACEHOLDER_OBJECTNAME  },
     637             :     { XML_NAMESPACE_SVG,            XML_X,          XML_TOK_PRESENTATIONPLACEHOLDER_X           },
     638             :     { XML_NAMESPACE_SVG,            XML_Y,          XML_TOK_PRESENTATIONPLACEHOLDER_Y           },
     639             :     { XML_NAMESPACE_SVG,            XML_WIDTH,      XML_TOK_PRESENTATIONPLACEHOLDER_WIDTH       },
     640             :     { XML_NAMESPACE_SVG,            XML_HEIGHT,     XML_TOK_PRESENTATIONPLACEHOLDER_HEIGHT      },
     641             :     XML_TOKEN_MAP_END
     642             : };
     643             : 
     644          41 :         mpPresentationPlaceholderAttrTokenMap = new SvXMLTokenMap(aPresentationPlaceholderAttrTokenMap);
     645             :     } // if(!mpPresentationPlaceholderAttrTokenMap)
     646             : 
     647        1755 :     return *mpPresentationPlaceholderAttrTokenMap;
     648             : }
     649             : 
     650        1101 : SvXMLImportContext *SdXMLImport::CreateContext(sal_uInt16 nPrefix,
     651             :     const OUString& rLocalName,
     652             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     653             : {
     654        1101 :     SvXMLImportContext* pContext = 0;
     655             : 
     656        1448 :     if(XML_NAMESPACE_OFFICE == nPrefix &&
     657         386 :         ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ||
     658         298 :           IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) ||
     659         127 :           IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS )   ))
     660             :     {
     661         132 :          pContext = new SdXMLDocContext_Impl(*this, nPrefix, rLocalName, xAttrList);
     662        1052 :     } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
     663          83 :                 ( IsXMLToken(rLocalName, XML_DOCUMENT_META)) ) {
     664          38 :         pContext = CreateMetaContext(rLocalName, xAttrList);
     665         976 :     } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
     666          45 :                 ( IsXMLToken(rLocalName, XML_DOCUMENT)) ) {
     667             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     668          45 :             GetModel(), uno::UNO_QUERY_THROW);
     669             :         // flat OpenDocument file format
     670         135 :         pContext = new SdXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
     671         180 :                         xAttrList, xDPS->getDocumentProperties());
     672             :     } else {
     673         886 :         pContext = SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
     674             :     }
     675             : 
     676        1101 :     return pContext;
     677             : }
     678             : 
     679          38 : SvXMLImportContext *SdXMLImport::CreateMetaContext(const OUString& rLocalName,
     680             :     const uno::Reference<xml::sax::XAttributeList>&)
     681             : {
     682          38 :     SvXMLImportContext* pContext = 0L;
     683             : 
     684          38 :     if (getImportFlags() & SvXMLImportFlags::META)
     685             :     {
     686             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     687          38 :             GetModel(), uno::UNO_QUERY_THROW);
     688             :         uno::Reference<document::XDocumentProperties> const xDocProps(
     689          76 :             (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties());
     690          76 :         pContext = new SvXMLMetaDocumentContext(*this,
     691             :                         XML_NAMESPACE_OFFICE, rLocalName,
     692         114 :                         xDocProps);
     693             :     }
     694             : 
     695          38 :     if(!pContext)
     696             :     {
     697           0 :         pContext = new SvXMLImportContext(*this, XML_NAMESPACE_OFFICE, rLocalName);
     698             :     }
     699             : 
     700          38 :     return pContext;
     701             : }
     702             : 
     703          89 : SvXMLImportContext *SdXMLImport::CreateBodyContext(const OUString& rLocalName,
     704             :     const uno::Reference<xml::sax::XAttributeList>&)
     705             : {
     706          89 :     SvXMLImportContext *pContext = 0;
     707          89 :     pContext = new SdXMLBodyContext(*this, XML_NAMESPACE_OFFICE, rLocalName);
     708          89 :     return pContext;
     709             : }
     710             : 
     711          89 : SvXMLStylesContext *SdXMLImport::CreateStylesContext(const OUString& rLocalName,
     712             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     713             : {
     714          89 :     if(GetShapeImport()->GetStylesContext())
     715           0 :         return GetShapeImport()->GetStylesContext();
     716             : 
     717             :     GetShapeImport()->SetStylesContext(new SdXMLStylesContext(
     718          89 :         *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, false));
     719             : 
     720          89 :     return GetShapeImport()->GetStylesContext();
     721             : }
     722             : 
     723         133 : SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext(const OUString& rLocalName,
     724             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     725             : {
     726         133 :     if(GetShapeImport()->GetAutoStylesContext())
     727           0 :         return GetShapeImport()->GetAutoStylesContext();
     728             : 
     729             :     GetShapeImport()->SetAutoStylesContext(new SdXMLStylesContext(
     730         133 :         *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, true));
     731             : 
     732         133 :     return GetShapeImport()->GetAutoStylesContext();
     733             : }
     734             : 
     735          89 : SvXMLImportContext* SdXMLImport::CreateMasterStylesContext(const OUString& rLocalName,
     736             :     const uno::Reference<xml::sax::XAttributeList>&)
     737             : {
     738          89 :     if(mpMasterStylesContext)
     739           0 :         return mpMasterStylesContext;
     740             : 
     741             :     mpMasterStylesContext = new SdXMLMasterStylesContext(
     742          89 :         *this, XML_NAMESPACE_OFFICE, rLocalName);
     743          89 :     mpMasterStylesContext->AddFirstRef();
     744             : 
     745          89 :     return mpMasterStylesContext;
     746             : }
     747             : 
     748         125 : SvXMLImportContext *SdXMLImport::CreateFontDeclsContext(const OUString& rLocalName,
     749             :     const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     750             : {
     751             :     XMLFontStylesContext *pFSContext =
     752             :             new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE,
     753             :                                       rLocalName, xAttrList,
     754         125 :                                       osl_getThreadTextEncoding() );
     755         125 :     SetFontDecls( pFSContext );
     756         125 :     return pFSContext;
     757             : }
     758             : 
     759          44 : SvXMLImportContext *SdXMLImport::CreateScriptContext(
     760             :                                        const OUString& rLocalName )
     761             : {
     762          44 :     SvXMLImportContext *pContext = 0;
     763             : 
     764             :     pContext = new XMLScriptContext( *this,
     765             :                                     XML_NAMESPACE_OFFICE, rLocalName,
     766          44 :                                     GetModel() );
     767          44 :     return pContext;
     768             : }
     769             : 
     770          87 : void SdXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps)
     771             : {
     772          87 :     uno::Reference< beans::XPropertySet > xPropSet( GetModel(), uno::UNO_QUERY );
     773          87 :     if( !xPropSet.is() )
     774          87 :         return;
     775             : 
     776          87 :     awt::Rectangle aVisArea( 0,0, 28000, 21000 );
     777          87 :     sal_Int32 nCount = aViewProps.getLength();
     778             : 
     779          87 :     const beans::PropertyValue* pValues = aViewProps.getConstArray();
     780             : 
     781         564 :     while( nCount-- )
     782             :     {
     783         390 :         const OUString& rName = pValues->Name;
     784         390 :         const uno::Any rValue = pValues->Value;
     785             : 
     786         390 :         if ( rName == "VisibleAreaTop" )
     787             :         {
     788          87 :             rValue >>= aVisArea.Y;
     789             :         }
     790         303 :         else if ( rName == "VisibleAreaLeft" )
     791             :         {
     792          87 :             rValue >>= aVisArea.X;
     793             :         }
     794         216 :         else if ( rName == "VisibleAreaWidth" )
     795             :         {
     796          87 :             rValue >>= aVisArea.Width;
     797             :         }
     798         129 :         else if ( rName == "VisibleAreaHeight" )
     799             :         {
     800          87 :             rValue >>= aVisArea.Height;
     801             :         }
     802             : 
     803         390 :         pValues++;
     804         390 :     }
     805             : 
     806             :     try
     807             :     {
     808          88 :         xPropSet->setPropertyValue("VisibleArea", uno::makeAny( aVisArea )  );
     809             :     }
     810           1 :     catch(const com::sun::star::uno::Exception&)
     811             :     {
     812             : /* #i79978# since old documents may contain invalid view settings, this is nothing to worry the user about.
     813             :         uno::Sequence<OUString> aSeq(0);
     814             :         SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL );
     815             : */
     816          87 :     }
     817             : }
     818             : 
     819          44 : void SdXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps)
     820             : {
     821          44 :     uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
     822          44 :     if( !xFac.is() )
     823           0 :         return;
     824             : 
     825          88 :     uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
     826          44 :     if( !xProps.is() )
     827           0 :         return;
     828             : 
     829          88 :     uno::Reference< beans::XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
     830          44 :     if( !xInfo.is() )
     831           0 :         return;
     832             : 
     833          44 :     sal_Int32 nCount = aConfigProps.getLength();
     834          44 :     const beans::PropertyValue* pValues = aConfigProps.getConstArray();
     835             : 
     836             :     DocumentSettingsSerializer *pFilter;
     837          44 :     pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get());
     838          88 :     uno::Sequence<beans::PropertyValue> aFiltered;
     839          44 :     if( pFilter )
     840             :     {
     841          44 :         aFiltered = pFilter->filterStreamsFromStorage( GetDocumentBase(), GetSourceStorage(), aConfigProps );
     842          44 :         nCount = aFiltered.getLength();
     843          44 :         pValues = aFiltered.getConstArray();
     844             :     }
     845             : 
     846        1394 :     while( nCount-- )
     847             :     {
     848             :         try
     849             :         {
     850        1306 :             const OUString& rProperty = pValues->Name;
     851        1306 :             if( xInfo->hasPropertyByName( rProperty ) )
     852        1303 :                 xProps->setPropertyValue( rProperty, pValues->Value );
     853             :         }
     854           0 :         catch(const uno::Exception&)
     855             :         {
     856             :             SAL_INFO("xmloff.draw",  "#SdXMLImport::SetConfigurationSettings: Exception!" );
     857             :         }
     858             : 
     859        1306 :         pValues++;
     860          44 :     }
     861             : }
     862             : 
     863             : // #80365# override this method to read and use the hint value from the
     864             : // written meta information. If no info is found, guess 10 draw objects
     865             : //void SdXMLImport::SetStatisticAttributes(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     866          83 : void SdXMLImport::SetStatistics(
     867             :         const uno::Sequence<beans::NamedValue> & i_rStats)
     868             : {
     869             :     static const char* s_stats[] =
     870             :         { "ObjectCount", 0 };
     871             : 
     872          83 :     SvXMLImport::SetStatistics(i_rStats);
     873             : 
     874          83 :     sal_uInt32 nCount(10);
     875         121 :     for (sal_Int32 i = 0; i < i_rStats.getLength(); ++i) {
     876          76 :         for (const char** pStat = s_stats; *pStat != 0; ++pStat) {
     877          38 :             if (i_rStats[i].Name.equalsAscii(*pStat)) {
     878          38 :                 sal_Int32 val = 0;
     879          38 :                 if (i_rStats[i].Value >>= val) {
     880          38 :                     nCount = val;
     881             :                 } else {
     882             :                     SAL_WARN("xmloff.draw", "SdXMLImport::SetStatistics: invalid entry");
     883             :                 }
     884             :             }
     885             :         }
     886             :     }
     887             : 
     888          83 :     if(nCount)
     889             :     {
     890          82 :         GetProgressBarHelper()->SetReference(nCount);
     891          82 :         GetProgressBarHelper()->SetValue(0);
     892             :     }
     893          83 : }
     894             : 
     895           0 : void SdXMLImport::AddHeaderDecl( const OUString& rName, const OUString& rText )
     896             : {
     897           0 :     if( !rName.isEmpty() && !rText.isEmpty() )
     898           0 :         maHeaderDeclsMap[rName] = rText;
     899           0 : }
     900             : 
     901           0 : void SdXMLImport::AddFooterDecl( const OUString& rName, const OUString& rText )
     902             : {
     903           0 :     if( !rName.isEmpty() && !rText.isEmpty() )
     904           0 :         maFooterDeclsMap[rName] = rText;
     905           0 : }
     906             : 
     907           0 : void SdXMLImport::AddDateTimeDecl( const OUString& rName, const OUString& rText, bool bFixed, const OUString& rDateTimeFormat )
     908             : {
     909           0 :     if( !rName.isEmpty() && (!rText.isEmpty() || !bFixed) )
     910             :     {
     911           0 :         DateTimeDeclContextImpl aDecl;
     912           0 :         aDecl.maStrText = rText;
     913           0 :         aDecl.mbFixed = bFixed;
     914           0 :         aDecl.maStrDateTimeFormat = rDateTimeFormat;
     915           0 :         maDateTimeDeclsMap[rName] = aDecl;
     916             :     }
     917           0 : }
     918             : 
     919           0 : OUString SdXMLImport::GetHeaderDecl( const OUString& rName ) const
     920             : {
     921           0 :     OUString aRet;
     922           0 :     HeaderFooterDeclMap::const_iterator aIter( maHeaderDeclsMap.find( rName ) );
     923           0 :     if( aIter != maHeaderDeclsMap.end() )
     924           0 :         aRet = (*aIter).second;
     925             : 
     926           0 :     return aRet;
     927             : }
     928             : 
     929           0 : OUString SdXMLImport::GetFooterDecl( const OUString& rName ) const
     930             : {
     931           0 :     OUString aRet;
     932           0 :     HeaderFooterDeclMap::const_iterator aIter( maFooterDeclsMap.find( rName ) );
     933           0 :     if( aIter != maFooterDeclsMap.end() )
     934           0 :         aRet = (*aIter).second;
     935             : 
     936           0 :     return aRet;
     937             : }
     938             : 
     939           0 : OUString SdXMLImport::GetDateTimeDecl( const OUString& rName, bool& rbFixed, OUString& rDateTimeFormat )
     940             : {
     941           0 :     DateTimeDeclContextImpl aDecl;
     942             : 
     943           0 :     DateTimeDeclMap::const_iterator aIter( maDateTimeDeclsMap.find( rName ) );
     944           0 :     if( aIter != maDateTimeDeclsMap.end() )
     945           0 :         aDecl = (*aIter).second;
     946             : 
     947           0 :     rbFixed = aDecl.mbFixed;
     948           0 :     rDateTimeFormat = aDecl.maStrDateTimeFormat;
     949           0 :     return aDecl.maStrText;
     950             : }
     951             : 
     952          13 : void SdXMLImport::NotifyEmbeddedFontRead()
     953             : {
     954          13 :     uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
     955          13 :     if( xFac.is() )
     956             :     {
     957          13 :         uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
     958          13 :         if( xProps.is() )
     959          13 :             xProps->setPropertyValue("EmbedFonts", uno::makeAny( true ) );
     960          13 :     }
     961          13 : }
     962             : 
     963             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11