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