LCOV - code coverage report
Current view: top level - xmloff/source/draw - sdxmlimp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 353 0.0 %
Date: 2014-04-14 Functions: 0 86 0.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 <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/task/XStatusIndicatorSupplier.hpp>
      36             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      37             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      38             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      39             : #include "sdpropls.hxx"
      40             : #include <xmloff/xmlexppr.hxx>
      41             : #include <xmloff/xmlerror.hxx>
      42             : #include <tools/debug.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           0 :     SdXMLImport& GetSdImport() { return (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           0 : SdXMLBodyContext_Impl::SdXMLBodyContext_Impl( SdXMLImport& rImport,
      71             :                 sal_uInt16 nPrfx, const OUString& rLName,
      72             :                 const uno::Reference< xml::sax::XAttributeList > & ) :
      73           0 :     SvXMLImportContext( rImport, nPrfx, rLName )
      74             : {
      75           0 : }
      76             : 
      77           0 : SdXMLBodyContext_Impl::~SdXMLBodyContext_Impl()
      78             : {
      79           0 : }
      80             : 
      81           0 : SvXMLImportContext *SdXMLBodyContext_Impl::CreateChildContext(
      82             :         sal_uInt16 /*nPrefix*/,
      83             :         const OUString& rLocalName,
      84             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
      85             : {
      86           0 :     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           0 :     SdXMLImport& GetSdImport() { return (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           0 : SdXMLDocContext_Impl::SdXMLDocContext_Impl(
     112             :     SdXMLImport& rImport,
     113             :     sal_uInt16 nPrfx,
     114             :     const OUString& rLName,
     115             :     const uno::Reference<xml::sax::XAttributeList>&)
     116           0 : :   SvXMLImportContext(rImport, nPrfx, rLName)
     117             : {
     118           0 : }
     119             : 
     120           0 : SdXMLDocContext_Impl::~SdXMLDocContext_Impl()
     121             : {
     122           0 : }
     123             : 
     124           0 : TYPEINIT1( SdXMLDocContext_Impl, SvXMLImportContext );
     125             : 
     126           0 : SvXMLImportContext *SdXMLDocContext_Impl::CreateChildContext(
     127             :     sal_uInt16 nPrefix,
     128             :     const OUString& rLocalName,
     129             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     130             : {
     131           0 :     SvXMLImportContext* pContext = 0L;
     132             : 
     133           0 :     const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap();
     134           0 :     switch(rTokenMap.Get(nPrefix, rLocalName))
     135             :     {
     136             :         case XML_TOK_DOC_FONTDECLS:
     137             :         {
     138           0 :             pContext = GetSdImport().CreateFontDeclsContext( rLocalName, xAttrList );
     139           0 :             break;
     140             :         }
     141             :         case XML_TOK_DOC_SETTINGS:
     142             :         {
     143           0 :             if( GetImport().getImportFlags() & IMPORT_SETTINGS )
     144             :             {
     145           0 :                 pContext = new XMLDocumentSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList );
     146             :             }
     147           0 :             break;
     148             :         }
     149             :         case XML_TOK_DOC_STYLES:
     150             :         {
     151           0 :             if( GetImport().getImportFlags() & IMPORT_STYLES )
     152             :             {
     153             :                 // office:styles inside office:document
     154           0 :                 pContext = GetSdImport().CreateStylesContext(rLocalName, xAttrList);
     155             :             }
     156           0 :             break;
     157             :         }
     158             :         case XML_TOK_DOC_AUTOSTYLES:
     159             :         {
     160           0 :             if( GetImport().getImportFlags() & IMPORT_AUTOSTYLES )
     161             :             {
     162             :                 // office:automatic-styles inside office:document
     163           0 :                 pContext = GetSdImport().CreateAutoStylesContext(rLocalName, xAttrList);
     164             :             }
     165           0 :             break;
     166             :         }
     167             :         case XML_TOK_DOC_MASTERSTYLES:
     168             :         {
     169           0 :             if( GetImport().getImportFlags() & IMPORT_MASTERSTYLES )
     170             :             {
     171             :                 // office:master-styles inside office:document
     172           0 :                 pContext = GetSdImport().CreateMasterStylesContext(rLocalName, xAttrList);
     173             :             }
     174           0 :             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           0 :             if( GetImport().getImportFlags() & IMPORT_SCRIPTS )
     184             :             {
     185             :                 // office:script inside office:document
     186           0 :                 pContext = GetSdImport().CreateScriptContext( rLocalName );
     187             :             }
     188           0 :             break;
     189             :         }
     190             :         case XML_TOK_DOC_BODY:
     191             :         {
     192           0 :             if( GetImport().getImportFlags() & IMPORT_CONTENT )
     193             :             {
     194             :                 // office:body inside office:document
     195             :                 pContext = new SdXMLBodyContext_Impl(GetSdImport(),nPrefix,
     196           0 :                                                      rLocalName, xAttrList);
     197             :             }
     198           0 :             break;
     199             :         }
     200             :     }
     201             : 
     202             :     // call parent when no own context was created
     203           0 :     if(!pContext)
     204           0 :         pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
     205             : 
     206           0 :     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           0 : 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           0 :         i_xDocProps)
     234             : {
     235           0 : }
     236             : 
     237           0 : SdXMLFlatDocContext_Impl::~SdXMLFlatDocContext_Impl() { }
     238             : 
     239           0 : 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           0 :     const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap();
     245           0 :     if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) {
     246             :         return SvXMLMetaDocumentContext::CreateChildContext(
     247           0 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     248             :     } else {
     249             :         return SdXMLDocContext_Impl::CreateChildContext(
     250           0 :                     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 (cppu::OWeakObject*)new SdXMLImport( comphelper::getComponentContext(rSMgr), implementationname, draw, flags ); \
     268             : }
     269             : 
     270           0 : SERVICE( XMLImpressImportOasis, "com.sun.star.comp.Impress.XMLOasisImporter", "XMLImpressImportOasis", sal_False, IMPORT_ALL )
     271           0 : SERVICE( XMLDrawImportOasis, "com.sun.star.comp.Draw.XMLOasisImporter", "XMLDrawImportOasis", sal_True, IMPORT_ALL )
     272             : 
     273           0 : SERVICE( XMLImpressStylesImportOasis, "com.sun.star.comp.Impress.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", sal_False, IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES )
     274           0 : SERVICE( XMLDrawStylesImportOasis, "com.sun.star.comp.Draw.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", sal_True, IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES )
     275             : 
     276           0 : SERVICE( XMLImpressContentImportOasis, "com.sun.star.comp.Impress.XMLOasisContentImporter", "XMLImpressContentImportOasis", sal_False, IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS )
     277           0 : SERVICE( XMLDrawContentImportOasis, "com.sun.star.comp.Draw.XMLOasisContentImporter", "XMLImpressContentImportOasis", sal_True, IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS )
     278             : 
     279           0 : SERVICE( XMLImpressMetaImportOasis, "com.sun.star.comp.Impress.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", sal_False, IMPORT_META )
     280           0 : SERVICE( XMLDrawMetaImportOasis, "com.sun.star.comp.Draw.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", sal_True, IMPORT_META )
     281             : 
     282           0 : SERVICE( XMLImpressSettingsImportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_False, IMPORT_SETTINGS )
     283           0 : SERVICE( XMLDrawSettingsImportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_True, IMPORT_SETTINGS )
     284             : 
     285             : // #110680#
     286           0 : SdXMLImport::SdXMLImport(
     287             :     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
     288             :     OUString const & implementationName,
     289             :     sal_Bool bIsDraw, sal_uInt16 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(sal_True),
     307             :     mbPreview(sal_False),
     308             :     msPageLayouts(  "PageLayouts"  ),
     309           0 :     msPreview(  "Preview"  )
     310             : {
     311             :     // add namespaces
     312           0 :     GetNamespaceMap().Add(
     313           0 :         GetXMLToken(XML_NP_PRESENTATION),
     314           0 :         GetXMLToken(XML_N_PRESENTATION),
     315           0 :         XML_NAMESPACE_PRESENTATION);
     316             : 
     317           0 :     GetNamespaceMap().Add(
     318           0 :         GetXMLToken(XML_NP_SMIL),
     319           0 :         GetXMLToken(XML_N_SMIL_COMPAT),
     320           0 :         XML_NAMESPACE_SMIL);
     321             : 
     322           0 :     GetNamespaceMap().Add(
     323           0 :         GetXMLToken(XML_NP_ANIMATION),
     324           0 :         GetXMLToken(XML_N_ANIMATION),
     325           0 :         XML_NAMESPACE_ANIMATION);
     326           0 : }
     327             : 
     328             : // XImporter
     329           0 : void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
     330             :     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     331             : {
     332           0 :     SvXMLImport::setTargetDocument( xDoc );
     333             : 
     334           0 :     uno::Reference< lang::XServiceInfo > xDocServices( GetModel(), uno::UNO_QUERY );
     335           0 :     if( !xDocServices.is() )
     336           0 :         throw lang::IllegalArgumentException();
     337             : 
     338           0 :     mbIsDraw = !xDocServices->supportsService("com.sun.star.presentation.PresentationDocument");
     339             : 
     340             :     // prepare access to styles
     341           0 :     uno::Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), uno::UNO_QUERY );
     342           0 :     if(xFamSup.is())
     343           0 :         mxDocStyleFamilies = xFamSup->getStyleFamilies();
     344             : 
     345             :     // prepare access to master pages
     346           0 :     uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
     347           0 :     if(xMasterPagesSupplier.is())
     348           0 :         mxDocMasterPages = mxDocMasterPages.query( xMasterPagesSupplier->getMasterPages() );
     349             : 
     350             :     // prepare access to draw pages
     351           0 :     uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY);
     352           0 :     if(!xDrawPagesSupplier.is())
     353           0 :         throw lang::IllegalArgumentException();
     354             : 
     355           0 :     mxDocDrawPages = mxDocDrawPages.query( xDrawPagesSupplier->getDrawPages() );
     356           0 :     if(!mxDocDrawPages.is())
     357           0 :         throw lang::IllegalArgumentException();
     358             : 
     359           0 :     if( mxDocDrawPages.is() && mxDocDrawPages->getCount() > 0 )
     360             :     {
     361           0 :         uno::Reference< form::XFormsSupplier > xFormsSupp;
     362           0 :         mxDocDrawPages->getByIndex(0) >>= xFormsSupp;
     363           0 :         mbIsFormsSupported = xFormsSupp.is();
     364             :     }
     365             : 
     366             :     // #88546# enable progress bar increments, SdXMLImport is only used for
     367             :     // draw/impress import
     368           0 :     GetShapeImport()->enableHandleProgressBar();
     369             : 
     370           0 :     uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
     371           0 :     if( xFac.is() )
     372             :     {
     373           0 :         uno::Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
     374           0 :         sal_Int32 n = sSNS.getLength();
     375           0 :         const OUString* pSNS( sSNS.getConstArray() );
     376           0 :         while( --n > 0 )
     377             :         {
     378           0 :             if( (*pSNS++) == "com.sun.star.drawing.TableShape" )
     379             :             {
     380           0 :                 mbIsTableShapeSupported = true;
     381           0 :                 break;
     382             :             }
     383           0 :         }
     384           0 :     }
     385           0 : }
     386             : 
     387             : // XInitialization
     388           0 : void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
     389             :     throw( uno::Exception, uno::RuntimeException, std::exception)
     390             : {
     391           0 :     SvXMLImport::initialize( aArguments );
     392             : 
     393           0 :     uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() );
     394           0 :     if( xInfoSet.is() )
     395             :     {
     396           0 :         uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
     397             : 
     398           0 :         if( xInfoSetInfo->hasPropertyByName( msPageLayouts ) )
     399           0 :             xInfoSet->getPropertyValue( msPageLayouts ) >>= mxPageLayouts;
     400             : 
     401           0 :         if( xInfoSetInfo->hasPropertyByName( msPreview ) )
     402           0 :             xInfoSet->getPropertyValue( msPreview ) >>= mbPreview;
     403             : 
     404             :         OUString const sOrganizerMode(
     405           0 :             "OrganizerMode");
     406           0 :         if (xInfoSetInfo->hasPropertyByName(sOrganizerMode))
     407             :         {
     408           0 :             sal_Bool bStyleOnly(sal_False);
     409           0 :             if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
     410             :             {
     411           0 :                 mbLoadDoc = !bStyleOnly;
     412             :             }
     413           0 :         }
     414           0 :     }
     415           0 : }
     416             : 
     417           0 : SdXMLImport::~SdXMLImport() throw ()
     418             : {
     419             :     // Styles or AutoStyles context?
     420           0 :     if(mpMasterStylesContext)
     421           0 :         mpMasterStylesContext->ReleaseRef();
     422             : 
     423             :     // delete all token maps
     424           0 :     if(mpDocElemTokenMap)
     425           0 :         delete mpDocElemTokenMap;
     426           0 :     if(mpBodyElemTokenMap)
     427           0 :         delete mpBodyElemTokenMap;
     428           0 :     if(mpStylesElemTokenMap)
     429           0 :         delete mpStylesElemTokenMap;
     430           0 :     if(mpMasterPageElemTokenMap)
     431           0 :         delete mpMasterPageElemTokenMap;
     432           0 :     if(mpMasterPageAttrTokenMap)
     433           0 :         delete mpMasterPageAttrTokenMap;
     434           0 :     if(mpPageMasterAttrTokenMap)
     435           0 :         delete mpPageMasterAttrTokenMap;
     436           0 :     if(mpPageMasterStyleAttrTokenMap)
     437           0 :         delete mpPageMasterStyleAttrTokenMap;
     438           0 :     if(mpDrawPageAttrTokenMap)
     439           0 :         delete mpDrawPageAttrTokenMap;
     440           0 :     if(mpDrawPageElemTokenMap)
     441           0 :         delete mpDrawPageElemTokenMap;
     442           0 :     if(mpPresentationPlaceholderAttrTokenMap)
     443           0 :         delete mpPresentationPlaceholderAttrTokenMap;
     444           0 : }
     445             : 
     446           0 : const SvXMLTokenMap& SdXMLImport::GetDocElemTokenMap()
     447             : {
     448           0 :     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           0 :         mpDocElemTokenMap = new SvXMLTokenMap(aDocElemTokenMap);
     464             :     } // if(!mpDocElemTokenMap)
     465             : 
     466           0 :     return *mpDocElemTokenMap;
     467             : }
     468             : 
     469           0 : const SvXMLTokenMap& SdXMLImport::GetBodyElemTokenMap()
     470             : {
     471           0 :     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           0 :         mpBodyElemTokenMap = new SvXMLTokenMap(aBodyElemTokenMap);
     485             :     } // if(!mpBodyElemTokenMap)
     486             : 
     487           0 :     return *mpBodyElemTokenMap;
     488             : }
     489             : 
     490           0 : const SvXMLTokenMap& SdXMLImport::GetStylesElemTokenMap()
     491             : {
     492           0 :     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           0 :         mpStylesElemTokenMap = new SvXMLTokenMap(aStylesElemTokenMap);
     503             :     } // if(!mpStylesElemTokenMap)
     504             : 
     505           0 :     return *mpStylesElemTokenMap;
     506             : }
     507             : 
     508           0 : const SvXMLTokenMap& SdXMLImport::GetMasterPageElemTokenMap()
     509             : {
     510           0 :     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           0 :         mpMasterPageElemTokenMap = new SvXMLTokenMap(aMasterPageElemTokenMap);
     520             :     } // if(!mpMasterPageElemTokenMap)
     521             : 
     522           0 :     return *mpMasterPageElemTokenMap;
     523             : }
     524             : 
     525           0 : const SvXMLTokenMap& SdXMLImport::GetMasterPageAttrTokenMap()
     526             : {
     527           0 :     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           0 :         mpMasterPageAttrTokenMap = new SvXMLTokenMap(aMasterPageAttrTokenMap);
     543             :     } // if(!mpMasterPageAttrTokenMap)
     544             : 
     545           0 :     return *mpMasterPageAttrTokenMap;
     546             : }
     547             : 
     548           0 : const SvXMLTokenMap& SdXMLImport::GetPageMasterAttrTokenMap()
     549             : {
     550           0 :     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           0 :         mpPageMasterAttrTokenMap = new SvXMLTokenMap(aPageMasterAttrTokenMap);
     559             :     } // if(!mpPageMasterAttrTokenMap)
     560             : 
     561           0 :     return *mpPageMasterAttrTokenMap;
     562             : }
     563             : 
     564           0 : const SvXMLTokenMap& SdXMLImport::GetPageMasterStyleAttrTokenMap()
     565             : {
     566           0 :     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           0 :         mpPageMasterStyleAttrTokenMap = new SvXMLTokenMap(aPageMasterStyleAttrTokenMap);
     581             :     } // if(!mpPageMasterStyleAttrTokenMap)
     582             : 
     583           0 :     return *mpPageMasterStyleAttrTokenMap;
     584             : }
     585             : 
     586           0 : const SvXMLTokenMap& SdXMLImport::GetDrawPageAttrTokenMap()
     587             : {
     588           0 :     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           0 :         mpDrawPageAttrTokenMap = new SvXMLTokenMap(aDrawPageAttrTokenMap);
     607             :     } // if(!mpDrawPageAttrTokenMap)
     608             : 
     609           0 :     return *mpDrawPageAttrTokenMap;
     610             : }
     611             : 
     612           0 : const SvXMLTokenMap& SdXMLImport::GetDrawPageElemTokenMap()
     613             : {
     614           0 :     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           0 :         mpDrawPageElemTokenMap = new SvXMLTokenMap(aDrawPageElemTokenMap);
     625             :     } // if(!mpDrawPageElemTokenMap)
     626             : 
     627           0 :     return *mpDrawPageElemTokenMap;
     628             : }
     629             : 
     630           0 : const SvXMLTokenMap& SdXMLImport::GetPresentationPlaceholderAttrTokenMap()
     631             : {
     632           0 :     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           0 :         mpPresentationPlaceholderAttrTokenMap = new SvXMLTokenMap(aPresentationPlaceholderAttrTokenMap);
     645             :     } // if(!mpPresentationPlaceholderAttrTokenMap)
     646             : 
     647           0 :     return *mpPresentationPlaceholderAttrTokenMap;
     648             : }
     649             : 
     650           0 : SvXMLImportContext *SdXMLImport::CreateContext(sal_uInt16 nPrefix,
     651             :     const OUString& rLocalName,
     652             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     653             : {
     654           0 :     SvXMLImportContext* pContext = 0;
     655             : 
     656           0 :     if(XML_NAMESPACE_OFFICE == nPrefix &&
     657           0 :         ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ||
     658           0 :           IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) ||
     659           0 :           IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS )   ))
     660             :     {
     661           0 :          pContext = new SdXMLDocContext_Impl(*this, nPrefix, rLocalName, xAttrList);
     662           0 :     } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
     663           0 :                 ( IsXMLToken(rLocalName, XML_DOCUMENT_META)) ) {
     664           0 :         pContext = CreateMetaContext(rLocalName, xAttrList);
     665           0 :     } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
     666           0 :                 ( IsXMLToken(rLocalName, XML_DOCUMENT)) ) {
     667             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     668           0 :             GetModel(), uno::UNO_QUERY_THROW);
     669             :         // flat OpenDocument file format
     670           0 :         pContext = new SdXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
     671           0 :                         xAttrList, xDPS->getDocumentProperties());
     672             :     } else {
     673           0 :         pContext = SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList);
     674             :     }
     675             : 
     676           0 :     return pContext;
     677             : }
     678             : 
     679           0 : SvXMLImportContext *SdXMLImport::CreateMetaContext(const OUString& rLocalName,
     680             :     const uno::Reference<xml::sax::XAttributeList>&)
     681             : {
     682           0 :     SvXMLImportContext* pContext = 0L;
     683             : 
     684           0 :     if (getImportFlags() & IMPORT_META)
     685             :     {
     686             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     687           0 :             GetModel(), uno::UNO_QUERY_THROW);
     688             :         uno::Reference<document::XDocumentProperties> const xDocProps(
     689           0 :             (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties());
     690           0 :         pContext = new SvXMLMetaDocumentContext(*this,
     691             :                         XML_NAMESPACE_OFFICE, rLocalName,
     692           0 :                         xDocProps);
     693             :     }
     694             : 
     695           0 :     if(!pContext)
     696             :     {
     697           0 :         pContext = new SvXMLImportContext(*this, XML_NAMESPACE_OFFICE, rLocalName);
     698             :     }
     699             : 
     700           0 :     return pContext;
     701             : }
     702             : 
     703           0 : SvXMLImportContext *SdXMLImport::CreateBodyContext(const OUString& rLocalName,
     704             :     const uno::Reference<xml::sax::XAttributeList>&)
     705             : {
     706           0 :     SvXMLImportContext *pContext = 0;
     707           0 :     pContext = new SdXMLBodyContext(*this, XML_NAMESPACE_OFFICE, rLocalName);
     708           0 :     return pContext;
     709             : }
     710             : 
     711           0 : SvXMLStylesContext *SdXMLImport::CreateStylesContext(const OUString& rLocalName,
     712             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     713             : {
     714           0 :     if(GetShapeImport()->GetStylesContext())
     715           0 :         return GetShapeImport()->GetStylesContext();
     716             : 
     717             :     GetShapeImport()->SetStylesContext(new SdXMLStylesContext(
     718           0 :         *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, sal_False));
     719             : 
     720           0 :     return GetShapeImport()->GetStylesContext();
     721             : }
     722             : 
     723           0 : SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext(const OUString& rLocalName,
     724             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList)
     725             : {
     726           0 :     if(GetShapeImport()->GetAutoStylesContext())
     727           0 :         return GetShapeImport()->GetAutoStylesContext();
     728             : 
     729             :     GetShapeImport()->SetAutoStylesContext(new SdXMLStylesContext(
     730           0 :         *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, sal_True));
     731             : 
     732           0 :     return GetShapeImport()->GetAutoStylesContext();
     733             : }
     734             : 
     735           0 : SvXMLImportContext* SdXMLImport::CreateMasterStylesContext(const OUString& rLocalName,
     736             :     const uno::Reference<xml::sax::XAttributeList>&)
     737             : {
     738           0 :     if(mpMasterStylesContext)
     739           0 :         return mpMasterStylesContext;
     740             : 
     741             :     mpMasterStylesContext = new SdXMLMasterStylesContext(
     742           0 :         *this, XML_NAMESPACE_OFFICE, rLocalName);
     743           0 :     mpMasterStylesContext->AddRef();
     744             : 
     745           0 :     return mpMasterStylesContext;
     746             : }
     747             : 
     748           0 : 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           0 :                                       osl_getThreadTextEncoding() );
     755           0 :     SetFontDecls( pFSContext );
     756           0 :     return pFSContext;
     757             : }
     758             : 
     759           0 : SvXMLImportContext *SdXMLImport::CreateScriptContext(
     760             :                                        const OUString& rLocalName )
     761             : {
     762           0 :     SvXMLImportContext *pContext = 0;
     763             : 
     764             :     pContext = new XMLScriptContext( *this,
     765             :                                     XML_NAMESPACE_OFFICE, rLocalName,
     766           0 :                                     GetModel() );
     767           0 :     return pContext;
     768             : }
     769             : 
     770           0 : void SdXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps)
     771             : {
     772           0 :     uno::Reference< beans::XPropertySet > xPropSet( GetModel(), uno::UNO_QUERY );
     773           0 :     if( !xPropSet.is() )
     774           0 :         return;
     775             : 
     776           0 :     awt::Rectangle aVisArea( 0,0, 28000, 21000 );
     777           0 :     sal_Int32 nCount = aViewProps.getLength();
     778             : 
     779           0 :     const beans::PropertyValue* pValues = aViewProps.getConstArray();
     780             : 
     781           0 :     while( nCount-- )
     782             :     {
     783           0 :         const OUString& rName = pValues->Name;
     784           0 :         const uno::Any rValue = pValues->Value;
     785             : 
     786           0 :         if ( rName == "VisibleAreaTop" )
     787             :         {
     788           0 :             rValue >>= aVisArea.Y;
     789             :         }
     790           0 :         else if ( rName == "VisibleAreaLeft" )
     791             :         {
     792           0 :             rValue >>= aVisArea.X;
     793             :         }
     794           0 :         else if ( rName == "VisibleAreaWidth" )
     795             :         {
     796           0 :             rValue >>= aVisArea.Width;
     797             :         }
     798           0 :         else if ( rName == "VisibleAreaHeight" )
     799             :         {
     800           0 :             rValue >>= aVisArea.Height;
     801             :         }
     802             : 
     803           0 :         pValues++;
     804           0 :     }
     805             : 
     806             :     try
     807             :     {
     808           0 :         xPropSet->setPropertyValue("VisibleArea", uno::makeAny( aVisArea )  );
     809             :     }
     810           0 :     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           0 :     }
     817             : }
     818             : 
     819           0 : void SdXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps)
     820             : {
     821           0 :     uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
     822           0 :     if( !xFac.is() )
     823           0 :         return;
     824             : 
     825           0 :     uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
     826           0 :     if( !xProps.is() )
     827           0 :         return;
     828             : 
     829           0 :     uno::Reference< beans::XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
     830           0 :     if( !xInfo.is() )
     831           0 :         return;
     832             : 
     833           0 :     sal_Int32 nCount = aConfigProps.getLength();
     834           0 :     const beans::PropertyValue* pValues = aConfigProps.getConstArray();
     835             : 
     836             :     DocumentSettingsSerializer *pFilter;
     837           0 :     pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get());
     838           0 :     uno::Sequence<beans::PropertyValue> aFiltered;
     839           0 :     if( pFilter )
     840             :     {
     841           0 :         aFiltered = pFilter->filterStreamsFromStorage( GetDocumentBase(), GetSourceStorage(), aConfigProps );
     842           0 :         nCount = aFiltered.getLength();
     843           0 :         pValues = aFiltered.getConstArray();
     844             :     }
     845             : 
     846           0 :     while( nCount-- )
     847             :     {
     848             :         try
     849             :         {
     850           0 :             const OUString& rProperty = pValues->Name;
     851           0 :             if( xInfo->hasPropertyByName( rProperty ) )
     852           0 :                 xProps->setPropertyValue( rProperty, pValues->Value );
     853             :         }
     854           0 :         catch(const uno::Exception&)
     855             :         {
     856             :             SAL_INFO("xmloff.draw",  "#SdXMLImport::SetConfigurationSettings: Exception!" );
     857             :         }
     858             : 
     859           0 :         pValues++;
     860           0 :     }
     861             : }
     862             : 
     863             : // #80365# overload 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           0 : void SdXMLImport::SetStatistics(
     867             :         const uno::Sequence<beans::NamedValue> & i_rStats)
     868             : {
     869             :     static const char* s_stats[] =
     870             :         { "ObjectCount", 0 };
     871             : 
     872           0 :     SvXMLImport::SetStatistics(i_rStats);
     873             : 
     874           0 :     sal_uInt32 nCount(10);
     875           0 :     for (sal_Int32 i = 0; i < i_rStats.getLength(); ++i) {
     876           0 :         for (const char** pStat = s_stats; *pStat != 0; ++pStat) {
     877           0 :             if (i_rStats[i].Name.equalsAscii(*pStat)) {
     878           0 :                 sal_Int32 val = 0;
     879           0 :                 if (i_rStats[i].Value >>= val) {
     880           0 :                     nCount = val;
     881             :                 } else {
     882             :                     SAL_WARN("xmloff.draw", "SdXMLImport::SetStatistics: invalid entry");
     883             :                 }
     884             :             }
     885             :         }
     886             :     }
     887             : 
     888           0 :     if(nCount)
     889             :     {
     890           0 :         GetProgressBarHelper()->SetReference(nCount);
     891           0 :         GetProgressBarHelper()->SetValue(0);
     892             :     }
     893           0 : }
     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, sal_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, sal_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           0 : void SdXMLImport::NotifyEmbeddedFontRead()
     953             : {
     954           0 :     uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
     955           0 :     if( xFac.is() )
     956             :     {
     957           0 :         uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
     958           0 :         if( xProps.is() )
     959           0 :             xProps->setPropertyValue("EmbedFonts", uno::makeAny( true ) );
     960           0 :     }
     961           0 : }
     962             : 
     963             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10