1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <tools/string.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <xmloff/xmlscripti.hxx> 34*cdf0e10cSrcweir #include "sdxmlimp_impl.hxx" 35*cdf0e10cSrcweir #include "ximpbody.hxx" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <xmloff/xmlmetai.hxx> 38*cdf0e10cSrcweir #include "ximpstyl.hxx" 39*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 40*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 41*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 42*cdf0e10cSrcweir #include <xmloff/DocumentSettingsContext.hxx> 43*cdf0e10cSrcweir #include <com/sun/star/form/XFormsSupplier.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 48*cdf0e10cSrcweir #include "sdpropls.hxx" 49*cdf0e10cSrcweir #include <xmloff/xmlexppr.hxx> 50*cdf0e10cSrcweir #include "xmloff/xmlerror.hxx" 51*cdf0e10cSrcweir #include <tools/debug.hxx> 52*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include <xmloff/XMLFontStylesContext.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir using ::rtl::OUString; 60*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir using namespace ::com::sun::star; 63*cdf0e10cSrcweir using namespace ::xmloff::token; 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir class SdXMLBodyContext_Impl : public SvXMLImportContext 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir const SdXMLImport& GetSdImport() const 82*cdf0e10cSrcweir { return (const SdXMLImport&)GetImport(); } 83*cdf0e10cSrcweir SdXMLImport& GetSdImport() { return (SdXMLImport&)GetImport(); } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir public: 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir SdXMLBodyContext_Impl( SdXMLImport& rImport, sal_uInt16 nPrfx, 88*cdf0e10cSrcweir const OUString& rLName, 89*cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & xAttrList ); 90*cdf0e10cSrcweir virtual ~SdXMLBodyContext_Impl(); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 93*cdf0e10cSrcweir const OUString& rLocalName, 94*cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & xAttrList ); 95*cdf0e10cSrcweir }; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir SdXMLBodyContext_Impl::SdXMLBodyContext_Impl( SdXMLImport& rImport, 98*cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLName, 99*cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & ) : 100*cdf0e10cSrcweir SvXMLImportContext( rImport, nPrfx, rLName ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir SdXMLBodyContext_Impl::~SdXMLBodyContext_Impl() 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir SvXMLImportContext *SdXMLBodyContext_Impl::CreateChildContext( 109*cdf0e10cSrcweir sal_uInt16 /*nPrefix*/, 110*cdf0e10cSrcweir const OUString& rLocalName, 111*cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & xAttrList ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir return GetSdImport().CreateBodyContext(rLocalName, xAttrList); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir // NB: virtually inherit so we can multiply inherit properly 119*cdf0e10cSrcweir // in SdXMLFlatDocContext_Impl 120*cdf0e10cSrcweir class SdXMLDocContext_Impl : public virtual SvXMLImportContext 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir protected: 123*cdf0e10cSrcweir const SdXMLImport& GetSdImport() const { return (const SdXMLImport&)GetImport(); } 124*cdf0e10cSrcweir SdXMLImport& GetSdImport() { return (SdXMLImport&)GetImport(); } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir public: 127*cdf0e10cSrcweir SdXMLDocContext_Impl( 128*cdf0e10cSrcweir SdXMLImport& rImport, 129*cdf0e10cSrcweir sal_uInt16 nPrfx, 130*cdf0e10cSrcweir const OUString& rLName, 131*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList); 132*cdf0e10cSrcweir virtual ~SdXMLDocContext_Impl(); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir TYPEINFO(); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, 137*cdf0e10cSrcweir const OUString& rLocalName, 138*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList); 139*cdf0e10cSrcweir }; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir SdXMLDocContext_Impl::SdXMLDocContext_Impl( 144*cdf0e10cSrcweir SdXMLImport& rImport, 145*cdf0e10cSrcweir sal_uInt16 nPrfx, 146*cdf0e10cSrcweir const OUString& rLName, 147*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>&) 148*cdf0e10cSrcweir : SvXMLImportContext(rImport, nPrfx, rLName) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir SdXMLDocContext_Impl::~SdXMLDocContext_Impl() 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir TYPEINIT1( SdXMLDocContext_Impl, SvXMLImportContext ); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir SvXMLImportContext *SdXMLDocContext_Impl::CreateChildContext( 163*cdf0e10cSrcweir sal_uInt16 nPrefix, 164*cdf0e10cSrcweir const OUString& rLocalName, 165*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir SvXMLImportContext* pContext = 0L; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap(); 170*cdf0e10cSrcweir switch(rTokenMap.Get(nPrefix, rLocalName)) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir case XML_TOK_DOC_FONTDECLS: 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir pContext = GetSdImport().CreateFontDeclsContext( rLocalName, xAttrList ); 175*cdf0e10cSrcweir break; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir case XML_TOK_DOC_SETTINGS: 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir if( GetImport().getImportFlags() & IMPORT_SETTINGS ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir pContext = new XMLDocumentSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList ); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir break; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir case XML_TOK_DOC_STYLES: 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if( GetImport().getImportFlags() & IMPORT_STYLES ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir // office:styles inside office:document 190*cdf0e10cSrcweir pContext = GetSdImport().CreateStylesContext(rLocalName, xAttrList); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir break; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir case XML_TOK_DOC_AUTOSTYLES: 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir if( GetImport().getImportFlags() & IMPORT_AUTOSTYLES ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir // office:automatic-styles inside office:document 199*cdf0e10cSrcweir pContext = GetSdImport().CreateAutoStylesContext(rLocalName, xAttrList); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir break; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir case XML_TOK_DOC_MASTERSTYLES: 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir if( GetImport().getImportFlags() & IMPORT_MASTERSTYLES ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir // office:master-styles inside office:document 208*cdf0e10cSrcweir pContext = GetSdImport().CreateMasterStylesContext(rLocalName, xAttrList); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir break; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir case XML_TOK_DOC_META: 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); 215*cdf0e10cSrcweir break; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir case XML_TOK_DOC_SCRIPT: 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir if( GetImport().getImportFlags() & IMPORT_SCRIPTS ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir // office:script inside office:document 222*cdf0e10cSrcweir pContext = GetSdImport().CreateScriptContext( rLocalName ); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir break; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir case XML_TOK_DOC_BODY: 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir if( GetImport().getImportFlags() & IMPORT_CONTENT ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir // office:body inside office:document 231*cdf0e10cSrcweir pContext = new SdXMLBodyContext_Impl(GetSdImport(),nPrefix, 232*cdf0e10cSrcweir rLocalName, xAttrList); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir break; 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir // call parent when no own context was created 239*cdf0e10cSrcweir if(!pContext) 240*cdf0e10cSrcweir pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir return pContext; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir // context for flat file xml format 248*cdf0e10cSrcweir class SdXMLFlatDocContext_Impl 249*cdf0e10cSrcweir : public SdXMLDocContext_Impl, public SvXMLMetaDocumentContext 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir public: 252*cdf0e10cSrcweir SdXMLFlatDocContext_Impl( SdXMLImport& i_rImport, 253*cdf0e10cSrcweir sal_uInt16 i_nPrefix, const OUString & i_rLName, 254*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& i_xAttrList, 255*cdf0e10cSrcweir const uno::Reference<document::XDocumentProperties>& i_xDocProps, 256*cdf0e10cSrcweir const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir virtual ~SdXMLFlatDocContext_Impl(); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( 261*cdf0e10cSrcweir sal_uInt16 i_nPrefix, const OUString& i_rLocalName, 262*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& i_xAttrList); 263*cdf0e10cSrcweir }; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir SdXMLFlatDocContext_Impl::SdXMLFlatDocContext_Impl( SdXMLImport& i_rImport, 266*cdf0e10cSrcweir sal_uInt16 i_nPrefix, const OUString & i_rLName, 267*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& i_xAttrList, 268*cdf0e10cSrcweir const uno::Reference<document::XDocumentProperties>& i_xDocProps, 269*cdf0e10cSrcweir const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) : 270*cdf0e10cSrcweir SvXMLImportContext(i_rImport, i_nPrefix, i_rLName), 271*cdf0e10cSrcweir SdXMLDocContext_Impl(i_rImport, i_nPrefix, i_rLName, i_xAttrList), 272*cdf0e10cSrcweir SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName, 273*cdf0e10cSrcweir i_xDocProps, i_xDocBuilder) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir SdXMLFlatDocContext_Impl::~SdXMLFlatDocContext_Impl() { } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir SvXMLImportContext *SdXMLFlatDocContext_Impl::CreateChildContext( 280*cdf0e10cSrcweir sal_uInt16 i_nPrefix, const OUString& i_rLocalName, 281*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& i_xAttrList) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir // behave like meta base class iff we encounter office:meta 284*cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap(); 285*cdf0e10cSrcweir if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) { 286*cdf0e10cSrcweir return SvXMLMetaDocumentContext::CreateChildContext( 287*cdf0e10cSrcweir i_nPrefix, i_rLocalName, i_xAttrList ); 288*cdf0e10cSrcweir } else { 289*cdf0e10cSrcweir return SdXMLDocContext_Impl::CreateChildContext( 290*cdf0e10cSrcweir i_nPrefix, i_rLocalName, i_xAttrList ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir #define SERVICE(classname,servicename,implementationname,draw,flags)\ 297*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL classname##_getSupportedServiceNames() throw()\ 298*cdf0e10cSrcweir {\ 299*cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( servicename ) );\ 300*cdf0e10cSrcweir const uno::Sequence< OUString > aSeq( &aServiceName, 1 );\ 301*cdf0e10cSrcweir return aSeq;\ 302*cdf0e10cSrcweir }\ 303*cdf0e10cSrcweir OUString SAL_CALL classname##_getImplementationName() throw()\ 304*cdf0e10cSrcweir {\ 305*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationname ) );\ 306*cdf0e10cSrcweir }\ 307*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )\ 308*cdf0e10cSrcweir {\ 309*cdf0e10cSrcweir return (cppu::OWeakObject*)new SdXMLImport( rSMgr, draw, flags );\ 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir SERVICE( XMLImpressImportOasis, "com.sun.star.comp.Impress.XMLOasisImporter", "XMLImpressImportOasis", sal_False, IMPORT_ALL ) 313*cdf0e10cSrcweir SERVICE( XMLDrawImportOasis, "com.sun.star.comp.Draw.XMLOasisImporter", "XMLDrawImportOasis", sal_True, IMPORT_ALL ) 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir SERVICE( XMLImpressStylesImportOasis, "com.sun.star.comp.Impress.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", sal_False, IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES ) 316*cdf0e10cSrcweir SERVICE( XMLDrawStylesImportOasis, "com.sun.star.comp.Draw.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", sal_True, IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES ) 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir SERVICE( XMLImpressContentImportOasis, "com.sun.star.comp.Impress.XMLOasisContentImporter", "XMLImpressContentImportOasis", sal_False, IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS ) 319*cdf0e10cSrcweir SERVICE( XMLDrawContentImportOasis, "com.sun.star.comp.Draw.XMLOasisContentImporter", "XMLImpressContentImportOasis", sal_True, IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS ) 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir SERVICE( XMLImpressMetaImportOasis, "com.sun.star.comp.Impress.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", sal_False, IMPORT_META ) 322*cdf0e10cSrcweir SERVICE( XMLDrawMetaImportOasis, "com.sun.star.comp.Draw.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", sal_True, IMPORT_META ) 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir SERVICE( XMLImpressSettingsImportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_False, IMPORT_SETTINGS ) 325*cdf0e10cSrcweir SERVICE( XMLDrawSettingsImportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_True, IMPORT_SETTINGS ) 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir // #110680# 330*cdf0e10cSrcweir SdXMLImport::SdXMLImport( 331*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 332*cdf0e10cSrcweir sal_Bool bIsDraw, sal_uInt16 nImportFlags ) 333*cdf0e10cSrcweir : SvXMLImport( xServiceFactory, nImportFlags ), 334*cdf0e10cSrcweir mpMasterStylesContext(0L), 335*cdf0e10cSrcweir mpDocElemTokenMap(0L), 336*cdf0e10cSrcweir mpBodyElemTokenMap(0L), 337*cdf0e10cSrcweir mpStylesElemTokenMap(0L), 338*cdf0e10cSrcweir mpMasterPageElemTokenMap(0L), 339*cdf0e10cSrcweir mpMasterPageAttrTokenMap(0L), 340*cdf0e10cSrcweir mpPageMasterAttrTokenMap(0L), 341*cdf0e10cSrcweir mpPageMasterStyleAttrTokenMap(0L), 342*cdf0e10cSrcweir mpDrawPageAttrTokenMap(0L), 343*cdf0e10cSrcweir mpDrawPageElemTokenMap(0L), 344*cdf0e10cSrcweir mpPresentationPlaceholderAttrTokenMap(0L), 345*cdf0e10cSrcweir mnStyleFamilyMask(0), 346*cdf0e10cSrcweir mnNewPageCount(0L), 347*cdf0e10cSrcweir mnNewMasterPageCount(0L), 348*cdf0e10cSrcweir mbIsDraw(bIsDraw), 349*cdf0e10cSrcweir mbLoadDoc(sal_True), 350*cdf0e10cSrcweir mbPreview(sal_False), 351*cdf0e10cSrcweir msPageLayouts( RTL_CONSTASCII_USTRINGPARAM( "PageLayouts" ) ), 352*cdf0e10cSrcweir msPreview( RTL_CONSTASCII_USTRINGPARAM( "Preview" ) ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir // add namespaces 355*cdf0e10cSrcweir GetNamespaceMap().Add( 356*cdf0e10cSrcweir GetXMLToken(XML_NP_PRESENTATION), 357*cdf0e10cSrcweir GetXMLToken(XML_N_PRESENTATION), 358*cdf0e10cSrcweir XML_NAMESPACE_PRESENTATION); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir GetNamespaceMap().Add( 361*cdf0e10cSrcweir GetXMLToken(XML_NP_SMIL), 362*cdf0e10cSrcweir GetXMLToken(XML_N_SMIL_COMPAT), 363*cdf0e10cSrcweir XML_NAMESPACE_SMIL); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir GetNamespaceMap().Add( 366*cdf0e10cSrcweir GetXMLToken(XML_NP_ANIMATION), 367*cdf0e10cSrcweir GetXMLToken(XML_N_ANIMATION), 368*cdf0e10cSrcweir XML_NAMESPACE_ANIMATION); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir // XImporter 372*cdf0e10cSrcweir void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc ) 373*cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir SvXMLImport::setTargetDocument( xDoc ); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir uno::Reference< lang::XServiceInfo > xDocServices( GetModel(), uno::UNO_QUERY ); 378*cdf0e10cSrcweir if( !xDocServices.is() ) 379*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir mbIsDraw = !xDocServices->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir // prepare access to styles 384*cdf0e10cSrcweir uno::Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), uno::UNO_QUERY ); 385*cdf0e10cSrcweir if(xFamSup.is()) 386*cdf0e10cSrcweir mxDocStyleFamilies = xFamSup->getStyleFamilies(); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir // prepare access to master pages 389*cdf0e10cSrcweir uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY); 390*cdf0e10cSrcweir if(xMasterPagesSupplier.is()) 391*cdf0e10cSrcweir mxDocMasterPages = mxDocMasterPages.query( xMasterPagesSupplier->getMasterPages() ); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // prepare access to draw pages 394*cdf0e10cSrcweir uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY); 395*cdf0e10cSrcweir if(!xDrawPagesSupplier.is()) 396*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir mxDocDrawPages = mxDocDrawPages.query( xDrawPagesSupplier->getDrawPages() ); 399*cdf0e10cSrcweir if(!mxDocDrawPages.is()) 400*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir if( mxDocDrawPages.is() && mxDocDrawPages->getCount() > 0 ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir uno::Reference< form::XFormsSupplier > xFormsSupp; 405*cdf0e10cSrcweir mxDocDrawPages->getByIndex(0) >>= xFormsSupp; 406*cdf0e10cSrcweir mbIsFormsSupported = xFormsSupp.is(); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir // #88546# enable progress bar increments, SdXMLImport is only used for 410*cdf0e10cSrcweir // draw/impress import 411*cdf0e10cSrcweir GetShapeImport()->enableHandleProgressBar(); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY ); 414*cdf0e10cSrcweir if( xFac.is() ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir uno::Sequence< OUString > sSNS( xFac->getAvailableServiceNames() ); 417*cdf0e10cSrcweir sal_Int32 n = sSNS.getLength(); 418*cdf0e10cSrcweir const OUString* pSNS( sSNS.getConstArray() ); 419*cdf0e10cSrcweir while( --n > 0 ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir if( (*pSNS++).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape") ) ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir mbIsTableShapeSupported = true; 424*cdf0e10cSrcweir break; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir // XInitialization 431*cdf0e10cSrcweir void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments ) 432*cdf0e10cSrcweir throw( uno::Exception, uno::RuntimeException) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir SvXMLImport::initialize( aArguments ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() ); 437*cdf0e10cSrcweir if( xInfoSet.is() ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() ); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir if( xInfoSetInfo->hasPropertyByName( msPageLayouts ) ) 442*cdf0e10cSrcweir xInfoSet->getPropertyValue( msPageLayouts ) >>= mxPageLayouts; 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir if( xInfoSetInfo->hasPropertyByName( msPreview ) ) 445*cdf0e10cSrcweir xInfoSet->getPropertyValue( msPreview ) >>= mbPreview; 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir ::rtl::OUString const sOrganizerMode( 448*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("OrganizerMode")); 449*cdf0e10cSrcweir if (xInfoSetInfo->hasPropertyByName(sOrganizerMode)) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir sal_Bool bStyleOnly(sal_False); 452*cdf0e10cSrcweir if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir mbLoadDoc = !bStyleOnly; 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir SdXMLImport::~SdXMLImport() throw () 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir // #80365# removed ending of progress bar here, this was an old implementation 465*cdf0e10cSrcweir // and maybe removed on demand 466*cdf0e10cSrcweir // // stop progress view 467*cdf0e10cSrcweir // if(mxStatusIndicator.is()) 468*cdf0e10cSrcweir // { 469*cdf0e10cSrcweir // mxStatusIndicator->end(); 470*cdf0e10cSrcweir // mxStatusIndicator->reset(); 471*cdf0e10cSrcweir // } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir // Styles or AutoStyles context? 474*cdf0e10cSrcweir if(mpMasterStylesContext) 475*cdf0e10cSrcweir mpMasterStylesContext->ReleaseRef(); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir // delete all token maps 478*cdf0e10cSrcweir if(mpDocElemTokenMap) 479*cdf0e10cSrcweir delete mpDocElemTokenMap; 480*cdf0e10cSrcweir if(mpBodyElemTokenMap) 481*cdf0e10cSrcweir delete mpBodyElemTokenMap; 482*cdf0e10cSrcweir if(mpStylesElemTokenMap) 483*cdf0e10cSrcweir delete mpStylesElemTokenMap; 484*cdf0e10cSrcweir if(mpMasterPageElemTokenMap) 485*cdf0e10cSrcweir delete mpMasterPageElemTokenMap; 486*cdf0e10cSrcweir if(mpMasterPageAttrTokenMap) 487*cdf0e10cSrcweir delete mpMasterPageAttrTokenMap; 488*cdf0e10cSrcweir if(mpPageMasterAttrTokenMap) 489*cdf0e10cSrcweir delete mpPageMasterAttrTokenMap; 490*cdf0e10cSrcweir if(mpPageMasterStyleAttrTokenMap) 491*cdf0e10cSrcweir delete mpPageMasterStyleAttrTokenMap; 492*cdf0e10cSrcweir if(mpDrawPageAttrTokenMap) 493*cdf0e10cSrcweir delete mpDrawPageAttrTokenMap; 494*cdf0e10cSrcweir if(mpDrawPageElemTokenMap) 495*cdf0e10cSrcweir delete mpDrawPageElemTokenMap; 496*cdf0e10cSrcweir if(mpPresentationPlaceholderAttrTokenMap) 497*cdf0e10cSrcweir delete mpPresentationPlaceholderAttrTokenMap; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir void SdXMLImport::SetProgress(sal_Int32 nProg) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir // set progress view 505*cdf0e10cSrcweir if(mxStatusIndicator.is()) 506*cdf0e10cSrcweir mxStatusIndicator->setValue(nProg); 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetDocElemTokenMap() 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir if(!mpDocElemTokenMap) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aDocElemTokenMap[] = 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS }, 518*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, 519*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, 520*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES }, 521*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META }, 522*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPT }, 523*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY }, 524*cdf0e10cSrcweir { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, 525*cdf0e10cSrcweir XML_TOKEN_MAP_END 526*cdf0e10cSrcweir }; 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir mpDocElemTokenMap = new SvXMLTokenMap(aDocElemTokenMap); 529*cdf0e10cSrcweir } // if(!mpDocElemTokenMap) 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir return *mpDocElemTokenMap; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetBodyElemTokenMap() 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir if(!mpBodyElemTokenMap) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aBodyElemTokenMap[] = 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_PAGE, XML_TOK_BODY_PAGE }, 543*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_SETTINGS, XML_TOK_BODY_SETTINGS }, 544*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, XML_TOK_BODY_HEADER_DECL }, 545*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, XML_TOK_BODY_FOOTER_DECL }, 546*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL,XML_TOK_BODY_DATE_TIME_DECL }, 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir XML_TOKEN_MAP_END 549*cdf0e10cSrcweir }; 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir mpBodyElemTokenMap = new SvXMLTokenMap(aBodyElemTokenMap); 552*cdf0e10cSrcweir } // if(!mpBodyElemTokenMap) 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir return *mpBodyElemTokenMap; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetStylesElemTokenMap() 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir if(!mpStylesElemTokenMap) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aStylesElemTokenMap[] = 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT, XML_TOK_STYLES_PAGE_MASTER }, 566*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_PRESENTATION_PAGE_LAYOUT, XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT }, 567*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_STYLE, XML_TOK_STYLES_STYLE }, 568*cdf0e10cSrcweir XML_TOKEN_MAP_END 569*cdf0e10cSrcweir }; 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir mpStylesElemTokenMap = new SvXMLTokenMap(aStylesElemTokenMap); 572*cdf0e10cSrcweir } // if(!mpStylesElemTokenMap) 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir return *mpStylesElemTokenMap; 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetMasterPageElemTokenMap() 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir if(!mpMasterPageElemTokenMap) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aMasterPageElemTokenMap[] = 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_STYLE, XML_TOK_MASTERPAGE_STYLE }, 586*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_NOTES, XML_TOK_MASTERPAGE_NOTES }, 587*cdf0e10cSrcweir XML_TOKEN_MAP_END 588*cdf0e10cSrcweir }; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir mpMasterPageElemTokenMap = new SvXMLTokenMap(aMasterPageElemTokenMap); 591*cdf0e10cSrcweir } // if(!mpMasterPageElemTokenMap) 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir return *mpMasterPageElemTokenMap; 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetMasterPageAttrTokenMap() 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir if(!mpMasterPageAttrTokenMap) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aMasterPageAttrTokenMap[] = 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_NAME, XML_TOK_MASTERPAGE_NAME }, 605*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, XML_TOK_MASTERPAGE_DISPLAY_NAME }, 606*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, XML_TOK_MASTERPAGE_PAGE_MASTER_NAME }, 607*cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_MASTERPAGE_STYLE_NAME }, 608*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME }, 609*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, XML_TOK_MASTERPAGE_USE_HEADER_NAME }, 610*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, XML_TOK_MASTERPAGE_USE_FOOTER_NAME }, 611*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_USE_DATE_TIME_NAME, XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME }, 612*cdf0e10cSrcweir XML_TOKEN_MAP_END 613*cdf0e10cSrcweir }; 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir mpMasterPageAttrTokenMap = new SvXMLTokenMap(aMasterPageAttrTokenMap); 616*cdf0e10cSrcweir } // if(!mpMasterPageAttrTokenMap) 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir return *mpMasterPageAttrTokenMap; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetPageMasterAttrTokenMap() 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir if(!mpPageMasterAttrTokenMap) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aPageMasterAttrTokenMap[] = 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_NAME, XML_TOK_PAGEMASTER_NAME }, 630*cdf0e10cSrcweir XML_TOKEN_MAP_END 631*cdf0e10cSrcweir }; 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir mpPageMasterAttrTokenMap = new SvXMLTokenMap(aPageMasterAttrTokenMap); 634*cdf0e10cSrcweir } // if(!mpPageMasterAttrTokenMap) 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir return *mpPageMasterAttrTokenMap; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetPageMasterStyleAttrTokenMap() 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir if(!mpPageMasterStyleAttrTokenMap) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aPageMasterStyleAttrTokenMap[] = 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir { XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TOK_PAGEMASTERSTYLE_MARGIN_TOP }, 648*cdf0e10cSrcweir { XML_NAMESPACE_FO, XML_MARGIN_BOTTOM, XML_TOK_PAGEMASTERSTYLE_MARGIN_BOTTOM }, 649*cdf0e10cSrcweir { XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TOK_PAGEMASTERSTYLE_MARGIN_LEFT }, 650*cdf0e10cSrcweir { XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TOK_PAGEMASTERSTYLE_MARGIN_RIGHT }, 651*cdf0e10cSrcweir { XML_NAMESPACE_FO, XML_PAGE_WIDTH, XML_TOK_PAGEMASTERSTYLE_PAGE_WIDTH }, 652*cdf0e10cSrcweir { XML_NAMESPACE_FO, XML_PAGE_HEIGHT, XML_TOK_PAGEMASTERSTYLE_PAGE_HEIGHT }, 653*cdf0e10cSrcweir { XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_TOK_PAGEMASTERSTYLE_PAGE_ORIENTATION }, 654*cdf0e10cSrcweir XML_TOKEN_MAP_END 655*cdf0e10cSrcweir }; 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir mpPageMasterStyleAttrTokenMap = new SvXMLTokenMap(aPageMasterStyleAttrTokenMap); 658*cdf0e10cSrcweir } // if(!mpPageMasterStyleAttrTokenMap) 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir return *mpPageMasterStyleAttrTokenMap; 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetDrawPageAttrTokenMap() 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir if(!mpDrawPageAttrTokenMap) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aDrawPageAttrTokenMap[] = 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_DRAWPAGE_NAME }, 672*cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_DRAWPAGE_STYLE_NAME }, 673*cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_MASTER_PAGE_NAME, XML_TOK_DRAWPAGE_MASTER_PAGE_NAME }, 674*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME }, 675*cdf0e10cSrcweir { XML_NAMESPACE_DRAW, XML_ID, XML_TOK_DRAWPAGE_DRAWID }, 676*cdf0e10cSrcweir { XML_NAMESPACE_XML, XML_ID, XML_TOK_DRAWPAGE_XMLID }, 677*cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_DRAWPAGE_HREF }, 678*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, XML_TOK_DRAWPAGE_USE_HEADER_NAME }, 679*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, XML_TOK_DRAWPAGE_USE_FOOTER_NAME }, 680*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_USE_DATE_TIME_NAME, XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME }, 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir XML_TOKEN_MAP_END 683*cdf0e10cSrcweir }; 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir mpDrawPageAttrTokenMap = new SvXMLTokenMap(aDrawPageAttrTokenMap); 686*cdf0e10cSrcweir } // if(!mpDrawPageAttrTokenMap) 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir return *mpDrawPageAttrTokenMap; 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetDrawPageElemTokenMap() 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir if(!mpDrawPageElemTokenMap) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aDrawPageElemTokenMap[] = 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_NOTES, XML_TOK_DRAWPAGE_NOTES }, 700*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_PAR, XML_TOK_DRAWPAGE_PAR }, 701*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_SEQ, XML_TOK_DRAWPAGE_SEQ }, 702*cdf0e10cSrcweir XML_TOKEN_MAP_END 703*cdf0e10cSrcweir }; 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir mpDrawPageElemTokenMap = new SvXMLTokenMap(aDrawPageElemTokenMap); 706*cdf0e10cSrcweir } // if(!mpDrawPageElemTokenMap) 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir return *mpDrawPageElemTokenMap; 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir const SvXMLTokenMap& SdXMLImport::GetPresentationPlaceholderAttrTokenMap() 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir if(!mpPresentationPlaceholderAttrTokenMap) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aPresentationPlaceholderAttrTokenMap[] = 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_OBJECT, XML_TOK_PRESENTATIONPLACEHOLDER_OBJECTNAME }, 720*cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_X, XML_TOK_PRESENTATIONPLACEHOLDER_X }, 721*cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_Y, XML_TOK_PRESENTATIONPLACEHOLDER_Y }, 722*cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_PRESENTATIONPLACEHOLDER_WIDTH }, 723*cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_PRESENTATIONPLACEHOLDER_HEIGHT }, 724*cdf0e10cSrcweir XML_TOKEN_MAP_END 725*cdf0e10cSrcweir }; 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir mpPresentationPlaceholderAttrTokenMap = new SvXMLTokenMap(aPresentationPlaceholderAttrTokenMap); 728*cdf0e10cSrcweir } // if(!mpPresentationPlaceholderAttrTokenMap) 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir return *mpPresentationPlaceholderAttrTokenMap; 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir SvXMLImportContext *SdXMLImport::CreateContext(sal_uInt16 nPrefix, 736*cdf0e10cSrcweir const OUString& rLocalName, 737*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir SvXMLImportContext* pContext = 0; 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir if(XML_NAMESPACE_OFFICE == nPrefix && 742*cdf0e10cSrcweir ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) || 743*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) || 744*cdf0e10cSrcweir IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS ) )) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir pContext = new SdXMLDocContext_Impl(*this, nPrefix, rLocalName, xAttrList); 747*cdf0e10cSrcweir } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && 748*cdf0e10cSrcweir ( IsXMLToken(rLocalName, XML_DOCUMENT_META)) ) { 749*cdf0e10cSrcweir pContext = CreateMetaContext(rLocalName, xAttrList); 750*cdf0e10cSrcweir } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && 751*cdf0e10cSrcweir ( IsXMLToken(rLocalName, XML_DOCUMENT)) ) { 752*cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( 753*cdf0e10cSrcweir mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( 754*cdf0e10cSrcweir "com.sun.star.xml.dom.SAXDocumentBuilder")), 755*cdf0e10cSrcweir uno::UNO_QUERY_THROW); 756*cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 757*cdf0e10cSrcweir GetModel(), uno::UNO_QUERY_THROW); 758*cdf0e10cSrcweir // flat OpenDocument file format 759*cdf0e10cSrcweir pContext = new SdXMLFlatDocContext_Impl( *this, nPrefix, rLocalName, 760*cdf0e10cSrcweir xAttrList, xDPS->getDocumentProperties(), xDocBuilder); 761*cdf0e10cSrcweir } else { 762*cdf0e10cSrcweir pContext = SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList); 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir return pContext; 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir SvXMLImportContext *SdXMLImport::CreateMetaContext(const OUString& rLocalName, 771*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>&) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir SvXMLImportContext* pContext = 0L; 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir if (getImportFlags() & IMPORT_META) 776*cdf0e10cSrcweir { 777*cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( 778*cdf0e10cSrcweir mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( 779*cdf0e10cSrcweir "com.sun.star.xml.dom.SAXDocumentBuilder")), 780*cdf0e10cSrcweir uno::UNO_QUERY_THROW); 781*cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 782*cdf0e10cSrcweir GetModel(), uno::UNO_QUERY_THROW); 783*cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> const xDocProps( 784*cdf0e10cSrcweir (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties()); 785*cdf0e10cSrcweir pContext = new SvXMLMetaDocumentContext(*this, 786*cdf0e10cSrcweir XML_NAMESPACE_OFFICE, rLocalName, 787*cdf0e10cSrcweir xDocProps, xDocBuilder); 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir if(!pContext) 791*cdf0e10cSrcweir { 792*cdf0e10cSrcweir pContext = new SvXMLImportContext(*this, XML_NAMESPACE_OFFICE, rLocalName); 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir return pContext; 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir SvXMLImportContext *SdXMLImport::CreateBodyContext(const OUString& rLocalName, 801*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>&) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 804*cdf0e10cSrcweir pContext = new SdXMLBodyContext(*this, XML_NAMESPACE_OFFICE, rLocalName); 805*cdf0e10cSrcweir return pContext; 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir SvXMLStylesContext *SdXMLImport::CreateStylesContext(const OUString& rLocalName, 811*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir if(GetShapeImport()->GetStylesContext()) 814*cdf0e10cSrcweir return GetShapeImport()->GetStylesContext(); 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir GetShapeImport()->SetStylesContext(new SdXMLStylesContext( 817*cdf0e10cSrcweir *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, sal_False)); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir return GetShapeImport()->GetStylesContext(); 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext(const OUString& rLocalName, 825*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir if(GetShapeImport()->GetAutoStylesContext()) 828*cdf0e10cSrcweir return GetShapeImport()->GetAutoStylesContext(); 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir GetShapeImport()->SetAutoStylesContext(new SdXMLStylesContext( 831*cdf0e10cSrcweir *this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, sal_True)); 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir return GetShapeImport()->GetAutoStylesContext(); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir SvXMLImportContext* SdXMLImport::CreateMasterStylesContext(const OUString& rLocalName, 839*cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>&) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir if(mpMasterStylesContext) 842*cdf0e10cSrcweir return mpMasterStylesContext; 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir mpMasterStylesContext = new SdXMLMasterStylesContext( 845*cdf0e10cSrcweir *this, XML_NAMESPACE_OFFICE, rLocalName); 846*cdf0e10cSrcweir mpMasterStylesContext->AddRef(); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir return mpMasterStylesContext; 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir SvXMLImportContext *SdXMLImport::CreateFontDeclsContext(const OUString& rLocalName, 854*cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & xAttrList ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir XMLFontStylesContext *pFSContext = 857*cdf0e10cSrcweir new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE, 858*cdf0e10cSrcweir rLocalName, xAttrList, 859*cdf0e10cSrcweir gsl_getSystemTextEncoding() ); 860*cdf0e10cSrcweir SetFontDecls( pFSContext ); 861*cdf0e10cSrcweir return pFSContext; 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 865*cdf0e10cSrcweir // import pool defaults. Parameter contains pool defaults read 866*cdf0e10cSrcweir // from input data. These data needs to be set at the model. 867*cdf0e10cSrcweir // 868*cdf0e10cSrcweir void SdXMLImport::ImportPoolDefaults(const XMLPropStyleContext*) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir SvXMLImportContext *SdXMLImport::CreateScriptContext( 875*cdf0e10cSrcweir const OUString& rLocalName ) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir pContext = new XMLScriptContext( *this, 880*cdf0e10cSrcweir XML_NAMESPACE_OFFICE, rLocalName, 881*cdf0e10cSrcweir GetModel() ); 882*cdf0e10cSrcweir return pContext; 883*cdf0e10cSrcweir } 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir void SdXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( GetModel(), uno::UNO_QUERY ); 890*cdf0e10cSrcweir if( !xPropSet.is() ) 891*cdf0e10cSrcweir return; 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir awt::Rectangle aVisArea( 0,0, 28000, 21000 ); 894*cdf0e10cSrcweir sal_Int32 nCount = aViewProps.getLength(); 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir const beans::PropertyValue* pValues = aViewProps.getConstArray(); 897*cdf0e10cSrcweir 898*cdf0e10cSrcweir while( nCount-- ) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir const OUString& rName = pValues->Name; 901*cdf0e10cSrcweir const uno::Any rValue = pValues->Value; 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("VisibleAreaTop") ) ) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir rValue >>= aVisArea.Y; 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("VisibleAreaLeft") ) ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir rValue >>= aVisArea.X; 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("VisibleAreaWidth") ) ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir rValue >>= aVisArea.Width; 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("VisibleAreaHeight") ) ) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir rValue >>= aVisArea.Height; 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir pValues++; 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir try 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), uno::makeAny( aVisArea ) ); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir catch( com::sun::star::uno::Exception /*e*/ ) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir /* #i79978# since old documents may contain invalid view settings, this is nothing to worry the user about. 930*cdf0e10cSrcweir uno::Sequence<OUString> aSeq(0); 931*cdf0e10cSrcweir SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL ); 932*cdf0e10cSrcweir */ 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir void SdXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps) 937*cdf0e10cSrcweir { 938*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY ); 939*cdf0e10cSrcweir if( !xFac.is() ) 940*cdf0e10cSrcweir return; 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), uno::UNO_QUERY ); 943*cdf0e10cSrcweir if( !xProps.is() ) 944*cdf0e10cSrcweir return; 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfo( xProps->getPropertySetInfo() ); 947*cdf0e10cSrcweir if( !xInfo.is() ) 948*cdf0e10cSrcweir return; 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir sal_Int32 nCount = aConfigProps.getLength(); 951*cdf0e10cSrcweir const beans::PropertyValue* pValues = aConfigProps.getConstArray(); 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir while( nCount-- ) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir try 956*cdf0e10cSrcweir { 957*cdf0e10cSrcweir const OUString& rProperty = pValues->Name; 958*cdf0e10cSrcweir if( xInfo->hasPropertyByName( rProperty ) ) 959*cdf0e10cSrcweir xProps->setPropertyValue( rProperty, pValues->Value ); 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir catch( uno::Exception& e ) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir (void)e; 964*cdf0e10cSrcweir OSL_TRACE( "#SdXMLImport::SetConfigurationSettings: Exception!" ); 965*cdf0e10cSrcweir } 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir pValues++; 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir } 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir // #80365# overload this method to read and use the hint value from the 972*cdf0e10cSrcweir // written meta information. If no info is found, guess 10 draw objects 973*cdf0e10cSrcweir //void SdXMLImport::SetStatisticAttributes(const uno::Reference<xml::sax::XAttributeList>& xAttrList) 974*cdf0e10cSrcweir void SdXMLImport::SetStatistics( 975*cdf0e10cSrcweir const uno::Sequence<beans::NamedValue> & i_rStats) 976*cdf0e10cSrcweir { 977*cdf0e10cSrcweir static const char* s_stats[] = 978*cdf0e10cSrcweir { "ObjectCount", 0 }; 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir SvXMLImport::SetStatistics(i_rStats); 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir sal_uInt32 nCount(10); 983*cdf0e10cSrcweir for (sal_Int32 i = 0; i < i_rStats.getLength(); ++i) { 984*cdf0e10cSrcweir for (const char** pStat = s_stats; *pStat != 0; ++pStat) { 985*cdf0e10cSrcweir if (i_rStats[i].Name.equalsAscii(*pStat)) { 986*cdf0e10cSrcweir sal_Int32 val = 0; 987*cdf0e10cSrcweir if (i_rStats[i].Value >>= val) { 988*cdf0e10cSrcweir nCount = val; 989*cdf0e10cSrcweir } else { 990*cdf0e10cSrcweir DBG_ERROR("SdXMLImport::SetStatistics: invalid entry"); 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir } 993*cdf0e10cSrcweir } 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir if(nCount) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir GetProgressBarHelper()->SetReference(nCount); 999*cdf0e10cSrcweir GetProgressBarHelper()->SetValue(0); 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir } 1002*cdf0e10cSrcweir 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir // XServiceInfo 1005*cdf0e10cSrcweir OUString SAL_CALL SdXMLImport::getImplementationName() throw( uno::RuntimeException ) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir if( IsDraw()) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir // Draw 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir switch( getImportFlags()) 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir case IMPORT_ALL: 1014*cdf0e10cSrcweir return XMLDrawImportOasis_getImplementationName(); 1015*cdf0e10cSrcweir case (IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES): 1016*cdf0e10cSrcweir return XMLDrawStylesImportOasis_getImplementationName(); 1017*cdf0e10cSrcweir case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS): 1018*cdf0e10cSrcweir return XMLDrawContentImportOasis_getImplementationName(); 1019*cdf0e10cSrcweir case IMPORT_META: 1020*cdf0e10cSrcweir return XMLDrawMetaImportOasis_getImplementationName(); 1021*cdf0e10cSrcweir case IMPORT_SETTINGS: 1022*cdf0e10cSrcweir return XMLDrawSettingsImportOasis_getImplementationName(); 1023*cdf0e10cSrcweir default: 1024*cdf0e10cSrcweir return XMLDrawImportOasis_getImplementationName(); 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir else 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir // Impress 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir switch( getImportFlags()) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir case IMPORT_ALL: 1034*cdf0e10cSrcweir return XMLImpressImportOasis_getImplementationName(); 1035*cdf0e10cSrcweir case (IMPORT_STYLES|IMPORT_AUTOSTYLES|IMPORT_MASTERSTYLES): 1036*cdf0e10cSrcweir return XMLImpressStylesImportOasis_getImplementationName(); 1037*cdf0e10cSrcweir case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS): 1038*cdf0e10cSrcweir return XMLImpressContentImportOasis_getImplementationName(); 1039*cdf0e10cSrcweir case IMPORT_META: 1040*cdf0e10cSrcweir return XMLImpressMetaImportOasis_getImplementationName(); 1041*cdf0e10cSrcweir case IMPORT_SETTINGS: 1042*cdf0e10cSrcweir return XMLImpressSettingsImportOasis_getImplementationName(); 1043*cdf0e10cSrcweir default: 1044*cdf0e10cSrcweir return XMLImpressImportOasis_getImplementationName(); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir HeaderFooterDeclMap maHeaderDeclsMap; 1050*cdf0e10cSrcweir HeaderFooterDeclMap maFooterDeclsMap; 1051*cdf0e10cSrcweir DateTimeDeclMap maDateTimeDeclsMap; 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir void SdXMLImport::AddHeaderDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText ) 1054*cdf0e10cSrcweir { 1055*cdf0e10cSrcweir if( rName.getLength() && rText.getLength() ) 1056*cdf0e10cSrcweir maHeaderDeclsMap[rName] = rText; 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir void SdXMLImport::AddFooterDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText ) 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir if( rName.getLength() && rText.getLength() ) 1062*cdf0e10cSrcweir maFooterDeclsMap[rName] = rText; 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir void SdXMLImport::AddDateTimeDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText, sal_Bool bFixed, const ::rtl::OUString& rDateTimeFormat ) 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir if( rName.getLength() && (rText.getLength() || !bFixed) ) 1068*cdf0e10cSrcweir { 1069*cdf0e10cSrcweir DateTimeDeclContextImpl aDecl; 1070*cdf0e10cSrcweir aDecl.maStrText = rText; 1071*cdf0e10cSrcweir aDecl.mbFixed = bFixed; 1072*cdf0e10cSrcweir aDecl.maStrDateTimeFormat = rDateTimeFormat; 1073*cdf0e10cSrcweir maDateTimeDeclsMap[rName] = aDecl; 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir 1077*cdf0e10cSrcweir ::rtl::OUString SdXMLImport::GetHeaderDecl( const ::rtl::OUString& rName ) const 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir ::rtl::OUString aRet; 1080*cdf0e10cSrcweir HeaderFooterDeclMap::const_iterator aIter( maHeaderDeclsMap.find( rName ) ); 1081*cdf0e10cSrcweir if( aIter != maHeaderDeclsMap.end() ) 1082*cdf0e10cSrcweir aRet = (*aIter).second; 1083*cdf0e10cSrcweir 1084*cdf0e10cSrcweir return aRet; 1085*cdf0e10cSrcweir } 1086*cdf0e10cSrcweir 1087*cdf0e10cSrcweir ::rtl::OUString SdXMLImport::GetFooterDecl( const ::rtl::OUString& rName ) const 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir ::rtl::OUString aRet; 1090*cdf0e10cSrcweir HeaderFooterDeclMap::const_iterator aIter( maFooterDeclsMap.find( rName ) ); 1091*cdf0e10cSrcweir if( aIter != maFooterDeclsMap.end() ) 1092*cdf0e10cSrcweir aRet = (*aIter).second; 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir return aRet; 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir ::rtl::OUString SdXMLImport::GetDateTimeDecl( const ::rtl::OUString& rName, sal_Bool& rbFixed, ::rtl::OUString& rDateTimeFormat ) 1098*cdf0e10cSrcweir { 1099*cdf0e10cSrcweir DateTimeDeclContextImpl aDecl; 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir DateTimeDeclMap::const_iterator aIter( maDateTimeDeclsMap.find( rName ) ); 1102*cdf0e10cSrcweir if( aIter != maDateTimeDeclsMap.end() ) 1103*cdf0e10cSrcweir aDecl = (*aIter).second; 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir rbFixed = aDecl.mbFixed; 1106*cdf0e10cSrcweir rDateTimeFormat = aDecl.maStrDateTimeFormat; 1107*cdf0e10cSrcweir return aDecl.maStrText; 1108*cdf0e10cSrcweir } 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir // eof 1111