LibreOffice Module xmloff (master)  1
sdxmlimp.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <osl/thread.h>
21 #include <sal/log.hxx>
23 #include <comphelper/sequence.hxx>
24 
25 #include <xmloff/xmlscripti.hxx>
26 #include "sdxmlimp_impl.hxx"
27 #include "ximpbody.hxx"
28 
29 #include <xmloff/xmlmetai.hxx>
30 #include "ximpstyl.hxx"
31 #include <xmloff/xmlnmspe.hxx>
32 #include <xmloff/xmltoken.hxx>
34 #include <com/sun/star/awt/Rectangle.hpp>
35 #include <com/sun/star/form/XFormsSupplier.hpp>
36 #include <com/sun/star/frame/XModel.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
39 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
40 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
41 #include <xmloff/settingsstore.hxx>
43 
45 
46 #include <com/sun/star/document/XDocumentProperties.hpp>
47 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
48 
49 using namespace ::com::sun::star;
50 using namespace ::xmloff::token;
51 
52 namespace {
53 
54 class SdXMLBodyContext_Impl : public SvXMLImportContext
55 {
56  SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
57 
58 public:
59 
60  SdXMLBodyContext_Impl( SdXMLImport& rImport );
61 
62  virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
63  const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
64 
65  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
66  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
67 };
68 
69 }
70 
71 SdXMLBodyContext_Impl::SdXMLBodyContext_Impl( SdXMLImport& rImport ) :
72  SvXMLImportContext( rImport )
73 {
74 }
75 
76 css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLBodyContext_Impl::createFastChildContext(
77  sal_Int32 /*nElement*/,
78  const uno::Reference< xml::sax::XFastAttributeList > & /*xAttrList*/ )
79 {
80  return new SdXMLBodyContext(GetSdImport());
81 }
82 
83 namespace {
84 
85 // NB: virtually inherit so we can multiply inherit properly
86 // in SdXMLFlatDocContext_Impl
87 class SdXMLDocContext_Impl : public virtual SvXMLImportContext
88 {
89 protected:
90  SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
91 
92 public:
93  SdXMLDocContext_Impl( SdXMLImport& rImport );
94 
95  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
96  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
97 
98  virtual void SAL_CALL characters( const OUString& /*aChars*/ ) override {}
99 
100  virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
101  const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override {}
102 
103  virtual void SAL_CALL endFastElement( sal_Int32 /*nElement*/ ) override {}
104 };
105 
106 }
107 
108 SdXMLDocContext_Impl::SdXMLDocContext_Impl(
109  SdXMLImport& rImport )
110 : SvXMLImportContext(rImport)
111 {
112 }
113 
114 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::createFastChildContext(
115  sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
116 {
117  switch (nElement)
118  {
119  case XML_ELEMENT(OFFICE, XML_SCRIPTS):
120  {
121  if( GetImport().getImportFlags() & SvXMLImportFlags::SCRIPTS )
122  {
123  // office:script inside office:document
124  return new XMLScriptContext( GetSdImport(), GetSdImport().GetModel() );
125  }
126  break;
127  }
128  case XML_ELEMENT(OFFICE, XML_MASTER_STYLES):
129  {
130  if( GetImport().getImportFlags() & SvXMLImportFlags::MASTERSTYLES )
131  {
132  // office:master-styles inside office:document
133  return GetSdImport().CreateMasterStylesContext();
134  }
135  break;
136  }
137  case XML_ELEMENT(OFFICE, XML_BODY):
138  {
139  if( GetImport().getImportFlags() & SvXMLImportFlags::CONTENT )
140  {
141  // office:body inside office:document
142  return new SdXMLBodyContext_Impl(GetSdImport());
143  }
144  break;
145  }
146  case XML_ELEMENT(OFFICE, XML_SETTINGS):
147  {
148  if( GetImport().getImportFlags() & SvXMLImportFlags::SETTINGS )
149  {
150  return new XMLDocumentSettingsContext(GetImport());
151  }
152  break;
153  }
154  case XML_ELEMENT(OFFICE, XML_STYLES):
155  {
156  if( GetImport().getImportFlags() & SvXMLImportFlags::STYLES )
157  {
158  // office:styles inside office:document
159  return GetSdImport().CreateStylesContext();
160  }
161  break;
162  }
163  case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
164  {
165  if( GetImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES )
166  {
167  // office:automatic-styles inside office:document
168  return GetSdImport().CreateAutoStylesContext();
169  }
170  break;
171  }
172  case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS):
173  {
174  return GetSdImport().CreateFontDeclsContext();
175  break;
176  }
177  case XML_ELEMENT(OFFICE, XML_META):
178  {
179  SAL_INFO("xmloff.draw", "XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?");
180  break;
181  }
182  }
183  return nullptr;
184 }
185 
186 namespace {
187 
188 // context for flat file xml format
189 class SdXMLFlatDocContext_Impl
190  : public SdXMLDocContext_Impl, public SvXMLMetaDocumentContext
191 {
192 public:
193  SdXMLFlatDocContext_Impl( SdXMLImport& i_rImport,
194  const uno::Reference<document::XDocumentProperties>& i_xDocProps );
195 
196  virtual void SAL_CALL startFastElement( sal_Int32 nElement,
197  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
198 
199  virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
200 
201  virtual void SAL_CALL characters( const OUString& aChars ) override;
202 
203  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
204  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
205 };
206 
207 }
208 
209 SdXMLFlatDocContext_Impl::SdXMLFlatDocContext_Impl( SdXMLImport& i_rImport,
210  const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
211  SvXMLImportContext(i_rImport),
212  SdXMLDocContext_Impl(i_rImport),
213  SvXMLMetaDocumentContext(i_rImport, i_xDocProps)
214 {
215 }
216 
217 void SAL_CALL SdXMLFlatDocContext_Impl::startFastElement( sal_Int32 nElement,
218  const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
219 {
220  SvXMLMetaDocumentContext::startFastElement(nElement, xAttrList);
221 }
222 
223 void SAL_CALL SdXMLFlatDocContext_Impl::endFastElement( sal_Int32 nElement )
224 {
226 }
227 
228 void SAL_CALL SdXMLFlatDocContext_Impl::characters( const OUString& rChars )
229 {
231 }
232 
233 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLFlatDocContext_Impl::createFastChildContext(
234  sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
235 {
236  // behave like meta base class iff we encounter office:meta
237  if ( nElement == XML_ELEMENT( OFFICE, XML_META ) ) {
239  nElement, xAttrList );
240  } else {
241  return SdXMLDocContext_Impl::createFastChildContext(
242  nElement, xAttrList );
243  }
244 }
245 
246 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
248  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
249 {
250  return cppu::acquire(
251  new SdXMLImport(pCtx, "XMLImpressImportOasis", false, SvXMLImportFlags::ALL));
252 }
253 
254 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
256  uno::Sequence<uno::Any> const& /*rSeq*/)
257 {
258  return cppu::acquire(new SdXMLImport(pCtx, "XMLDrawImportOasis", true, SvXMLImportFlags::ALL));
259 }
260 
261 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
263  uno::Sequence<uno::Any> const& /*rSeq*/)
264 {
265  return cppu::acquire(new SdXMLImport(pCtx, "XMLDrawStylesImportOasis", true,
268 }
269 
270 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
272  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
273 {
274  return cppu::acquire(new SdXMLImport(pCtx, "XMLDrawContentImportOasis", true,
278 }
279 
280 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
282  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
283 {
284  return cppu::acquire(
285  new SdXMLImport(pCtx, "XMLDrawMetaImportOasis", true, SvXMLImportFlags::META));
286 }
287 
288 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
290  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
291 {
292  return cppu::acquire(
293  new SdXMLImport(pCtx, "XMLDrawSettingsImportOasis", true, SvXMLImportFlags::SETTINGS));
294 }
295 
296 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
298  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
299 {
300  return cppu::acquire(new SdXMLImport(pCtx, "XMLImpressStylesImportOasis", false,
303 }
304 
305 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
307  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
308 {
309  return cppu::acquire(new SdXMLImport(pCtx, "XMLImpressContentImportOasis", false,
313 }
314 
315 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
317  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
318 {
319  return cppu::acquire(
320  new SdXMLImport(pCtx, "XMLImpressMetaImportOasis", false, SvXMLImportFlags::META));
321 }
322 
323 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
325  uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
326 {
327  return cppu::acquire(
328  new SdXMLImport(pCtx, "XMLImpressSettingsImportOasis", false, SvXMLImportFlags::SETTINGS));
329 }
330 
332  const css::uno::Reference< css::uno::XComponentContext >& xContext,
333  OUString const & implementationName,
334  bool bIsDraw, SvXMLImportFlags nImportFlags )
335 : SvXMLImport( xContext, implementationName, nImportFlags ),
336  mnNewPageCount(0),
337  mnNewMasterPageCount(0),
338  mbIsDraw(bIsDraw),
339  mbLoadDoc(true),
340  mbPreview(false)
341 {
342  // add namespaces
347 
352 }
353 
354 // XImporter
355 void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
356 {
358 
359  uno::Reference< lang::XServiceInfo > xDocServices( GetModel(), uno::UNO_QUERY );
360  if( !xDocServices.is() )
361  throw lang::IllegalArgumentException();
362 
363  mbIsDraw = !xDocServices->supportsService("com.sun.star.presentation.PresentationDocument");
364 
365  // prepare access to styles
366  uno::Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), uno::UNO_QUERY );
367  if(xFamSup.is())
368  mxDocStyleFamilies = xFamSup->getStyleFamilies();
369 
370  // prepare access to master pages
371  uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
372  if(xMasterPagesSupplier.is())
373  mxDocMasterPages = xMasterPagesSupplier->getMasterPages();
374 
375  // prepare access to draw pages
376  uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY);
377  if(!xDrawPagesSupplier.is())
378  throw lang::IllegalArgumentException();
379 
380  mxDocDrawPages = xDrawPagesSupplier->getDrawPages();
381  if(!mxDocDrawPages.is())
382  throw lang::IllegalArgumentException();
383 
384  if( mxDocDrawPages.is() && mxDocDrawPages->getCount() > 0 )
385  {
386  uno::Reference< form::XFormsSupplier > xFormsSupp;
387  mxDocDrawPages->getByIndex(0) >>= xFormsSupp;
388  mbIsFormsSupported = xFormsSupp.is();
389  }
390 
391  // #88546# enable progress bar increments, SdXMLImport is only used for
392  // draw/impress import
393  GetShapeImport()->enableHandleProgressBar();
394 
395  uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
396  if( xFac.is() )
397  {
398  uno::Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
399  if (comphelper::findValue(sSNS, "com.sun.star.drawing.TableShape") != -1)
401  }
402 }
403 
404 // XInitialization
405 void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
406 {
407  SvXMLImport::initialize( aArguments );
408 
409  uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() );
410  if( !xInfoSet.is() )
411  return;
412 
413  uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );
414 
415  if( xInfoSetInfo->hasPropertyByName( gsPageLayouts ) )
416  xInfoSet->getPropertyValue( gsPageLayouts ) >>= mxPageLayouts;
417 
418  if( xInfoSetInfo->hasPropertyByName( gsPreview ) )
419  xInfoSet->getPropertyValue( gsPreview ) >>= mbPreview;
420 
421  OUString const sOrganizerMode(
422  "OrganizerMode");
423  if (xInfoSetInfo->hasPropertyByName(sOrganizerMode))
424  {
425  bool bStyleOnly(false);
426  if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
427  {
428  mbLoadDoc = !bStyleOnly;
429  }
430  }
431 }
432 
434 {
435  if(!mpBodyElemTokenMap)
436  {
437  static const SvXMLTokenMapEntry aBodyElemTokenMap[] =
438  {
444 
446  };
447 
448  mpBodyElemTokenMap = std::make_unique<SvXMLTokenMap>(aBodyElemTokenMap);
449  }
450 
451  return *mpBodyElemTokenMap;
452 }
453 
455 {
457  {
458  static const SvXMLTokenMapEntry aStylesElemTokenMap[] =
459  {
464  };
465 
466  mpStylesElemTokenMap = std::make_unique<SvXMLTokenMap>(aStylesElemTokenMap);
467  }
468 
469  return *mpStylesElemTokenMap;
470 }
471 
473 {
475  {
476  static const SvXMLTokenMapEntry aMasterPageElemTokenMap[] =
477  {
481  };
482 
483  mpMasterPageElemTokenMap = std::make_unique<SvXMLTokenMap>(aMasterPageElemTokenMap);
484  }
485 
486  return *mpMasterPageElemTokenMap;
487 }
488 
490 {
492  {
493  static const SvXMLTokenMapEntry aPageMasterAttrTokenMap[] =
494  {
497  };
498 
499  mpPageMasterAttrTokenMap = std::make_unique<SvXMLTokenMap>(aPageMasterAttrTokenMap);
500  }
501 
502  return *mpPageMasterAttrTokenMap;
503 }
504 
506 {
508  {
509  static const SvXMLTokenMapEntry aPageMasterStyleAttrTokenMap[] =
510  {
519  };
520 
521  mpPageMasterStyleAttrTokenMap = std::make_unique<SvXMLTokenMap>(aPageMasterStyleAttrTokenMap);
522  }
523 
525 }
526 
528 {
530  {
531  static const SvXMLTokenMapEntry aPresentationPlaceholderAttrTokenMap[] =
532  {
539  };
540 
541  mpPresentationPlaceholderAttrTokenMap = std::make_unique<SvXMLTokenMap>(aPresentationPlaceholderAttrTokenMap);
542  }
543 
545 }
546 
548  const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
549 {
550  SvXMLImportContext* pContext = nullptr;
551 
552  switch (nElement)
553  {
557  pContext = new SdXMLDocContext_Impl(*this);
558  break;
560  pContext = CreateMetaContext(nElement, xAttrList);
561  break;
563  {
564  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
565  GetModel(), uno::UNO_QUERY_THROW);
566  // flat OpenDocument file format
567  pContext = new SdXMLFlatDocContext_Impl( *this, xDPS->getDocumentProperties());
568  }
569  break;
570  }
571  return pContext;
572 }
573 
575  const uno::Reference<xml::sax::XFastAttributeList>&)
576 {
577  SvXMLImportContext* pContext = nullptr;
578 
580  {
581  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
582  GetModel(), uno::UNO_QUERY_THROW);
583  uno::Reference<document::XDocumentProperties> const xDocProps(
584  !mbLoadDoc ? nullptr : xDPS->getDocumentProperties());
585  pContext = new SvXMLMetaDocumentContext(*this, xDocProps);
586  }
587 
588  return pContext;
589 }
590 
592 {
593  if(GetShapeImport()->GetStylesContext())
594  return GetShapeImport()->GetStylesContext();
595 
596  GetShapeImport()->SetStylesContext(new SdXMLStylesContext(
597  *this, false));
598 
599  return GetShapeImport()->GetStylesContext();
600 }
601 
603 {
604  if(GetShapeImport()->GetAutoStylesContext())
605  return GetShapeImport()->GetAutoStylesContext();
606 
607  GetShapeImport()->SetAutoStylesContext(new SdXMLStylesContext(
608  *this, true));
609 
610  return GetShapeImport()->GetAutoStylesContext();
611 }
612 
614 {
615  if (!mxMasterStylesContext.is())
617  return mxMasterStylesContext.get();
618 }
619 
621 {
622  XMLFontStylesContext *pFSContext =
623  new XMLFontStylesContext( *this, osl_getThreadTextEncoding() );
624  SetFontDecls( pFSContext );
625  return pFSContext;
626 }
627 
628 void SdXMLImport::SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps)
629 {
630  uno::Reference< beans::XPropertySet > xPropSet( GetModel(), uno::UNO_QUERY );
631  if( !xPropSet.is() )
632  return;
633 
634  awt::Rectangle aVisArea( 0,0, 28000, 21000 );
635 
636  for( const auto& rViewProp : aViewProps )
637  {
638  const OUString& rName = rViewProp.Name;
639  const uno::Any rValue = rViewProp.Value;
640 
641  if ( rName == "VisibleAreaTop" )
642  {
643  rValue >>= aVisArea.Y;
644  }
645  else if ( rName == "VisibleAreaLeft" )
646  {
647  rValue >>= aVisArea.X;
648  }
649  else if ( rName == "VisibleAreaWidth" )
650  {
651  rValue >>= aVisArea.Width;
652  }
653  else if ( rName == "VisibleAreaHeight" )
654  {
655  rValue >>= aVisArea.Height;
656  }
657  }
658 
659  try
660  {
661  xPropSet->setPropertyValue("VisibleArea", uno::makeAny( aVisArea ) );
662  }
663  catch(const css::uno::Exception&)
664  {
665 /* #i79978# since old documents may contain invalid view settings, this is nothing to worry the user about.
666  uno::Sequence<OUString> aSeq(0);
667  SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL );
668 */
669  }
670 }
671 
672 void SdXMLImport::SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps)
673 {
674  uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
675  if( !xFac.is() )
676  return;
677 
678  uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
679  if( !xProps.is() )
680  return;
681 
682  uno::Reference< beans::XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
683  if( !xInfo.is() )
684  return;
685 
686  const uno::Sequence<beans::PropertyValue>* pValues = &aConfigProps;
687 
689  pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get());
690  uno::Sequence<beans::PropertyValue> aFiltered;
691  if( pFilter )
692  {
693  aFiltered = pFilter->filterStreamsFromStorage( GetDocumentBase(), GetSourceStorage(), aConfigProps );
694  pValues = &aFiltered;
695  }
696 
697  for( const auto& rValue : *pValues )
698  {
699  try
700  {
701  const OUString& rProperty = rValue.Name;
702  if( xInfo->hasPropertyByName( rProperty ) )
703  xProps->setPropertyValue( rProperty, rValue.Value );
704  }
705  catch(const uno::Exception&)
706  {
707  SAL_INFO("xmloff.draw", "#SdXMLImport::SetConfigurationSettings: Exception!" );
708  }
709  }
710 }
711 
712 // #80365# override this method to read and use the hint value from the
713 // written meta information. If no info is found, guess 10 draw objects
714 //void SdXMLImport::SetStatisticAttributes(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
716  const uno::Sequence<beans::NamedValue> & i_rStats)
717 {
718  static const char* s_stats[] =
719  { "ObjectCount", nullptr };
720 
721  SvXMLImport::SetStatistics(i_rStats);
722 
723  sal_uInt32 nCount(10);
724  for (const auto& rStat : i_rStats) {
725  for (const char** pStat = s_stats; *pStat != nullptr; ++pStat) {
726  if (rStat.Name.equalsAscii(*pStat)) {
727  sal_Int32 val = 0;
728  if (rStat.Value >>= val) {
729  nCount = val;
730  } else {
731  SAL_WARN("xmloff.draw", "SdXMLImport::SetStatistics: invalid entry");
732  }
733  }
734  }
735  }
736 
737  if(nCount)
738  {
741  }
742 }
743 
744 void SdXMLImport::AddHeaderDecl( const OUString& rName, const OUString& rText )
745 {
746  if( !rName.isEmpty() && !rText.isEmpty() )
747  maHeaderDeclsMap[rName] = rText;
748 }
749 
750 void SdXMLImport::AddFooterDecl( const OUString& rName, const OUString& rText )
751 {
752  if( !rName.isEmpty() && !rText.isEmpty() )
753  maFooterDeclsMap[rName] = rText;
754 }
755 
756 void SdXMLImport::AddDateTimeDecl( const OUString& rName, const OUString& rText, bool bFixed, const OUString& rDateTimeFormat )
757 {
758  if( !rName.isEmpty() && (!rText.isEmpty() || !bFixed) )
759  {
761  aDecl.maStrText = rText;
762  aDecl.mbFixed = bFixed;
763  aDecl.maStrDateTimeFormat = rDateTimeFormat;
764  maDateTimeDeclsMap[rName] = aDecl;
765  }
766 }
767 
768 OUString SdXMLImport::GetHeaderDecl( const OUString& rName ) const
769 {
770  OUString aRet;
771  HeaderFooterDeclMap::const_iterator aIter( maHeaderDeclsMap.find( rName ) );
772  if( aIter != maHeaderDeclsMap.end() )
773  aRet = (*aIter).second;
774 
775  return aRet;
776 }
777 
778 OUString SdXMLImport::GetFooterDecl( const OUString& rName ) const
779 {
780  OUString aRet;
781  HeaderFooterDeclMap::const_iterator aIter( maFooterDeclsMap.find( rName ) );
782  if( aIter != maFooterDeclsMap.end() )
783  aRet = (*aIter).second;
784 
785  return aRet;
786 }
787 
788 OUString SdXMLImport::GetDateTimeDecl( const OUString& rName, bool& rbFixed, OUString& rDateTimeFormat )
789 {
791 
792  DateTimeDeclMap::const_iterator aIter( maDateTimeDeclsMap.find( rName ) );
793  if( aIter != maDateTimeDeclsMap.end() )
794  aDecl = (*aIter).second;
795 
796  rbFixed = aDecl.mbFixed;
797  rDateTimeFormat = aDecl.maStrDateTimeFormat;
798  return aDecl.maStrText;
799 }
800 
802 {
803  uno::Reference< lang::XMultiServiceFactory > xFac( GetModel(), uno::UNO_QUERY );
804  if( xFac.is() )
805  {
806  uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
807  if( xProps.is() )
808  xProps->setPropertyValue("EmbedFonts", uno::makeAny( true ) );
809  }
810 }
811 
812 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
bool mbIsFormsSupported
Definition: xmlimp.hxx:250
void AddFooterDecl(const OUString &rName, const OUString &rText)
Definition: sdxmlimp.cxx:750
static constexpr OUStringLiteral gsPreview
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: sdxmlimp.cxx:547
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisContentImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:306
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
Definition: xmlmetai.cxx:208
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:71
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
css::uno::Reference< css::container::XIndexAccess > mxDocMasterPages
constexpr sal_uInt16 XML_NAMESPACE_SMIL
Definition: xmlnmspe.hxx:49
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: sdxmlimp.cxx:628
std::unique_ptr< SvXMLTokenMap > mpStylesElemTokenMap
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:401
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: sdxmlimp.cxx:355
css::uno::Reference< css::embed::XStorage > const & GetSourceStorage() const
Definition: xmlimp.cxx:1439
std::unique_ptr< SvXMLTokenMap > mpBodyElemTokenMap
OUString GetDocumentBase() const
Definition: xmlimp.cxx:1904
#define XML_TOKEN_MAP_END
Definition: xmltkmap.hxx:33
void SetFontDecls(XMLFontStylesContext *pFontDecls)
Definition: xmlimp.cxx:1622
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
const SvXMLTokenMap & GetMasterPageElemTokenMap()
Definition: sdxmlimp.cxx:472
const SvXMLTokenMap & GetPresentationPlaceholderAttrTokenMap()
Definition: sdxmlimp.cxx:527
SvXMLImportFlags
Definition: xmlimp.hxx:108
OUString GetHeaderDecl(const OUString &rName) const
Definition: sdxmlimp.cxx:768
css::uno::Reference< css::container::XNameAccess > mxPageLayouts
int nCount
std::unique_ptr< SvXMLTokenMap > mpPageMasterStyleAttrTokenMap
const SvXMLTokenMap & GetPageMasterAttrTokenMap()
Definition: sdxmlimp.cxx:489
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1044
const SvXMLTokenMap & GetPageMasterStyleAttrTokenMap()
Definition: sdxmlimp.cxx:505
virtual css::uno::Sequence< css::beans::PropertyValue > filterStreamsFromStorage(OUString const &referer, const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps)=0
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:297
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisContentImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:271
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlmetai.cxx:231
constexpr sal_uInt16 XML_NAMESPACE_DRAW
Definition: xmlnmspe.hxx:33
HeaderFooterDeclMap maFooterDeclsMap
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: sdxmlimp.cxx:574
bool mbIsTableShapeSupported
Definition: xmlimp.hxx:251
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:255
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
Definition: xmlnmspe.hxx:39
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisMetaImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:281
SvXMLStylesContext * CreateAutoStylesContext()
Definition: sdxmlimp.cxx:602
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlmetai.cxx:200
SvXMLImportContext * CreateFontDeclsContext()
Definition: sdxmlimp.cxx:620
HeaderFooterDeclMap maHeaderDeclsMap
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisSettingsImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:289
rtl::Reference< SdXMLMasterStylesContext > mxMasterStylesContext
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlimp.cxx:1531
void AddDateTimeDecl(const OUString &rName, const OUString &rText, bool bFixed, const OUString &rDateTimeFormat)
Definition: sdxmlimp.cxx:756
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: sdxmlimp.cxx:405
void AddHeaderDecl(const OUString &rName, const OUString &rText)
Definition: sdxmlimp.cxx:744
std::unique_ptr< SvXMLTokenMap > mpPageMasterAttrTokenMap
SvXMLImportContext * CreateMasterStylesContext()
Definition: sdxmlimp.cxx:613
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: sdxmlimp.cxx:672
SvXMLStylesContext * CreateStylesContext()
Definition: sdxmlimp.cxx:591
std::unique_ptr< SvXMLTokenMap > mpPresentationPlaceholderAttrTokenMap
constexpr sal_uInt16 XML_NAMESPACE_FO
Definition: xmlnmspe.hxx:34
css::uno::Reference< css::container::XNameAccess > mxDocStyleFamilies
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisSettingsImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:324
const PropertyValue * pValues
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
Definition: xmlictxt.cxx:114
OUString GetFooterDecl(const OUString &rName) const
Definition: sdxmlimp.cxx:778
SvXMLImportFlags getImportFlags() const
Definition: xmlimp.hxx:459
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3372
OUString GetDateTimeDecl(const OUString &rName, bool &rbFixed, OUString &rDateTimeFormat)
Definition: sdxmlimp.cxx:788
Handling of tokens in XML:
static constexpr OUStringLiteral gsPageLayouts
#define SAL_INFO(area, stream)
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:128
const SvXMLTokenMap & GetStylesElemTokenMap()
Definition: sdxmlimp.cxx:454
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats)
Definition: xmlimp.cxx:994
std::unique_ptr< SvXMLTokenMap > mpMasterPageElemTokenMap
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:94
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
Definition: nmspmap.cxx:103
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:407
virtual void NotifyEmbeddedFontRead() override
Definition: sdxmlimp.cxx:801
void SetValue(sal_Int32 nValue)
css::uno::Reference< css::container::XIndexAccess > mxDocDrawPages
const struct statistic s_stats[]
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:247
const SvXMLTokenMap & GetBodyElemTokenMap()
Definition: sdxmlimp.cxx:433
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
Definition: xmlimp.hxx:390
void SetReference(sal_Int32 nVal)
handles the top-level office:document-meta element of meta.xml documents
Definition: xmlmetai.hxx:35
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
Definition: sdxmlimp.cxx:715
#define SAL_WARN(area, stream)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Impress_XMLOasisMetaImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:316
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:1001
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlmetai.cxx:227
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlictxt.cxx:142
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Draw_XMLOasisStylesImporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
Definition: sdxmlimp.cxx:262
constexpr sal_uInt16 XML_NAMESPACE_SVG
Definition: xmlnmspe.hxx:40
SdXMLImport(const css::uno::Reference< css::uno::XComponentContext > &xContext, OUString const &implementationName, bool bIsDraw, SvXMLImportFlags nImportFlags)
Definition: sdxmlimp.cxx:331
DateTimeDeclMap maDateTimeDeclsMap
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:607