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