LibreOffice Module xmloff (master)  1
xmlexp.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 <memory>
21 #include <sal/config.h>
22 #include <sal/log.hxx>
23 
24 #include <mutex>
25 #include <stack>
26 #include <optional>
27 #include <utility>
28 
30 #include <tools/urlobj.hxx>
31 #include <vcl/graph.hxx>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/io/XInputStream.hpp>
35 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
36 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
37 #include <com/sun/star/text/XTextContent.hpp>
38 #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
39 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
40 #include <com/sun/star/uri/UriReferenceFactory.hpp>
41 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
42 #include <com/sun/star/util/MeasureUnit.hpp>
46 #include <xmloff/attrlist.hxx>
47 #include <xmloff/namespacemap.hxx>
48 #include <xmloff/xmluconv.hxx>
49 #include <xmloff/xmlnamespace.hxx>
50 #include <xmloff/xmltoken.hxx>
51 #include <xmloff/xmlexp.hxx>
52 #include <xmloff/xmlnumfe.hxx>
53 #include <xmloff/xmlmetae.hxx>
60 #include <com/sun/star/document/XEventsSupplier.hpp>
61 #include <com/sun/star/document/XViewDataSupplier.hpp>
62 #include <com/sun/star/frame/XModel.hpp>
63 #include <com/sun/star/frame/XModule.hpp>
64 #include <xmloff/GradientStyle.hxx>
65 #include <xmloff/HatchStyle.hxx>
66 #include <xmloff/ImageStyle.hxx>
67 #include <TransGradientStyle.hxx>
68 #include <xmloff/MarkerStyle.hxx>
69 #include <xmloff/DashStyle.hxx>
71 #include <XMLImageMapExport.hxx>
72 #include <XMLBase64Export.hxx>
73 #include <xmloff/xmlerror.hxx>
74 #include <com/sun/star/style/XStyle.hpp>
75 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
76 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
77 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
78 #include <com/sun/star/beans/PropertyAttribute.hpp>
81 #include <XMLBasicExportFilter.hxx>
82 #include <cppuhelper/exc_hlp.hxx>
83 #include <cppuhelper/implbase.hxx>
85 #include <comphelper/extract.hxx>
87 #include <PropertySetMerger.hxx>
88 
90 #include <com/sun/star/document/XDocumentProperties.hpp>
91 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
92 #include <com/sun/star/document/XMLOasisBasicExporter.hpp>
93 #include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
94 #include <com/sun/star/document/XGraphicStorageHandler.hpp>
95 #include <com/sun/star/rdf/XMetadatable.hpp>
96 #include <RDFaExportHelper.hxx>
97 
98 #include <comphelper/xmltools.hxx>
100 
101 using namespace ::com::sun::star;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::frame;
104 using namespace ::com::sun::star::container;
105 using namespace ::com::sun::star::lang;
106 using namespace ::com::sun::star::document;
107 using namespace ::com::sun::star::beans;
108 using namespace ::com::sun::star::xml::sax;
109 using namespace ::com::sun::star::io;
110 using namespace ::xmloff::token;
111 
112 constexpr OUStringLiteral XML_MODEL_SERVICE_WRITER = u"com.sun.star.text.TextDocument";
113 constexpr OUStringLiteral XML_MODEL_SERVICE_CALC = u"com.sun.star.sheet.SpreadsheetDocument";
114 constexpr OUStringLiteral XML_MODEL_SERVICE_DRAW = u"com.sun.star.drawing.DrawingDocument";
115 constexpr OUStringLiteral XML_MODEL_SERVICE_IMPRESS = u"com.sun.star.presentation.PresentationDocument";
116 constexpr OUStringLiteral XML_MODEL_SERVICE_MATH = u"com.sun.star.formula.FormulaProperties";
117 constexpr OUStringLiteral XML_MODEL_SERVICE_CHART = u"com.sun.star.chart.ChartDocument";
118 
119 constexpr OUStringLiteral XML_USEPRETTYPRINTING = u"UsePrettyPrinting";
120 
121 constexpr OUStringLiteral XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE = u"vnd.sun.star.GraphicObject:";
122 constexpr OUStringLiteral XML_EMBEDDEDOBJECT_URL_BASE = u"vnd.sun.star.EmbeddedObject:";
123 
124 const std::pair<OUString, OUString> aServiceMap[] = {
127  { XML_MODEL_SERVICE_IMPRESS, XML_EXPORT_FILTER_IMPRESS }, // Impress supports DrawingDocument,
128  { XML_MODEL_SERVICE_DRAW, XML_EXPORT_FILTER_DRAW }, // too, so it must appear before Draw
131 };
132 
133 namespace {
134 
135 class SettingsExportFacade : public ::xmloff::XMLSettingsExportContext
136 {
137 public:
138  explicit SettingsExportFacade( SvXMLExport& i_rExport )
139  :m_rExport( i_rExport )
140  {
141  }
142 
143  virtual ~SettingsExportFacade()
144  {
145  }
146 
147  virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
148  const OUString& i_rValue ) override;
149  virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
150  enum ::xmloff::token::XMLTokenEnum i_eValue ) override;
151 
152  virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName ) override;
153  virtual void EndElement( const bool i_bIgnoreWhitespace ) override;
154 
155  virtual void Characters( const OUString& i_rCharacters ) override;
156 
157  virtual css::uno::Reference< css::uno::XComponentContext >
158  GetComponentContext() const override;
159 private:
160  SvXMLExport& m_rExport;
161  ::std::stack< OUString > m_aElements;
162 };
163 
164 }
165 
166 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const OUString& i_rValue )
167 {
168  m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_rValue );
169 }
170 
171 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue )
172 {
173  m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_eValue );
174 }
175 
176 void SettingsExportFacade::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName )
177 {
178  const OUString sElementName( m_rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_CONFIG, GetXMLToken( i_eName ) ) );
179  m_rExport.StartElement( sElementName, true/*i_bIgnoreWhitespace*/ );
180  m_aElements.push( sElementName );
181 }
182 
183 void SettingsExportFacade::EndElement( const bool i_bIgnoreWhitespace )
184 {
185  const OUString sElementName( m_aElements.top() );
186  m_rExport.EndElement( sElementName, i_bIgnoreWhitespace );
187  m_aElements.pop();
188 }
189 
190 void SettingsExportFacade::Characters( const OUString& i_rCharacters )
191 {
192  m_rExport.GetDocHandler()->characters( i_rCharacters );
193 }
194 
195 Reference< XComponentContext > SettingsExportFacade::GetComponentContext() const
196 {
197  return m_rExport.getComponentContext();
198 }
199 
200 namespace {
201 
202 class SvXMLExportEventListener : public cppu::WeakImplHelper<
203  css::lang::XEventListener >
204 {
205 private:
206  SvXMLExport* pExport;
207 
208 public:
209  explicit SvXMLExportEventListener(SvXMLExport* pExport);
210 
211  // XEventListener
212  virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) override;
213 };
214 
215 }
216 
217 SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport)
218  : pExport(pTempExport)
219 {
220 }
221 
222 // XEventListener
223 void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& )
224 {
225  if (pExport)
226  {
227  pExport->DisposingModel();
228  pExport = nullptr;
229  }
230 }
231 
233 {
234 public:
236 
238  uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory;
239  OUString msPackageURI;
241  // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
243 
244  uno::Reference< embed::XStorage > mxTargetStorage;
245 
246  std::optional<SvtSaveOptions::ODFSaneDefaultVersion> m_oOverrideODFVersion;
247 
249  OUString mStreamName;
250 
251  OUString maSrcShellID;
252  OUString maDestShellID;
253 
256  ::std::stack< ::std::pair< std::unique_ptr<SvXMLNamespaceMap>, tools::Long > > mNamespaceMaps;
259 
260  ::std::unique_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper;
261 
264 
265  void SetSchemeOf( const OUString& rOrigFileName )
266  {
267  sal_Int32 nSep = rOrigFileName.indexOf(':');
268  if( nSep != -1 )
269  msPackageURIScheme = rOrigFileName.copy( 0, nSep );
270  }
271 };
272 
274 : mxUriReferenceFactory( uri::UriReferenceFactory::create(comphelper::getProcessComponentContext()) ),
275  // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
276  mbOutlineStyleAsNormalListStyle( false ),
277  mDepth( 0 ),
278  mbExportTextNumberElement( false ),
279  mbNullDateInitialized( false )
280 {
281 }
282 
283 void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler )
284 {
285  mxHandler = rHandler;
286  mxExtHandler.set( mxHandler, UNO_QUERY );
287 }
288 
290 {
291  // note: it is not necessary to add XML_NP_XML (it is declared implicitly)
293  {
296  }
298  {
300  }
302  {
304  }
306  {
308  }
309 
311  {
314  }
316  {
318  }
319 
320  // namespaces for documents
322  {
335 
337  {
338  mpNamespaceMap->Add(
340  mpNamespaceMap->Add(
342  mpNamespaceMap->Add(
344  mpNamespaceMap->Add(
348  }
349  }
351  {
354  }
356  {
359  }
361  {
366  }
367 
368  // RDFa: needed for content and header/footer styles
370  {
373  }
374  // GRDDL: to convert RDFa and meta.xml to RDF
376  {
379  }
380  // CSS Text Level 3 for distributed text justification.
382  {
383  mpNamespaceMap->Add(
385  }
386 
387  if (mxModel.is() && !mxEventListener.is())
388  {
389  mxEventListener.set( new SvXMLExportEventListener(this));
390  mxModel->addEventListener(mxEventListener);
391  }
392 
393  // Determine model type (#i51726#)
395 }
396 
397 // Shapes in Writer cannot be named via context menu (#i51726#)
399 {
401 
402  if ( mxModel.is() )
403  {
405 
406  // note: MATH documents will throw NotInitializedException; maybe unit test problem
408  {
409  uno::Reference<frame::XModule> const xModule(mxModel, uno::UNO_QUERY);
410  bool const isBaseForm(xModule.is() &&
411  xModule->getIdentifier() == "com.sun.star.sdb.FormDesign");
412  if (isBaseForm)
413  {
414  switch (GetODFSaneDefaultVersion())
415  {
417  SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2");
418  mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED;
420  break;
422  SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2");
423  mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012;
425  break;
426  default:
427  break;
428  }
429  }
430  }
431  }
432 }
433 
435  const uno::Reference< uno::XComponentContext >& xContext,
436  OUString const & implementationName,
437  sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
438  const enum XMLTokenEnum eClass, SvXMLExportFlags nExportFlags )
439 : mpImpl( new SvXMLExport_Impl ),
440  m_xContext(xContext), m_implementationName(implementationName),
441  mxAttrList( new SvXMLAttributeList ),
442  mpNamespaceMap( new SvXMLNamespaceMap ),
443  mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
444  maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()),
445  meClass( eClass ),
446  mnExportFlags( nExportFlags ),
447  mnErrorFlags( SvXMLErrorFlags::NO ),
448  msWS( GetXMLToken(XML_WS) ),
449  mbSaveLinkedSections(true),
450  mbAutoStylesCollected(false)
451 {
452  SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
453  InitCtor_();
454 }
455 
457  const css::uno::Reference< css::uno::XComponentContext >& xContext,
458  OUString const & implementationName,
459  const OUString &rFileName,
460  sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
461  const uno::Reference< xml::sax::XDocumentHandler > & rHandler)
462 : mpImpl( new SvXMLExport_Impl ),
463  m_xContext(xContext), m_implementationName(implementationName),
464  mxHandler( rHandler ),
465  mxExtHandler( rHandler, uno::UNO_QUERY ),
466  mxAttrList( new SvXMLAttributeList ),
467  msOrigFileName( rFileName ),
468  mpNamespaceMap( new SvXMLNamespaceMap ),
469  mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
470  maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()),
472  mnExportFlags( SvXMLExportFlags::NONE ),
473  mnErrorFlags( SvXMLErrorFlags::NO ),
474  msWS( GetXMLToken(XML_WS) ),
475  mbSaveLinkedSections(true),
476  mbAutoStylesCollected(false)
477 {
478  SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
479  mpImpl->SetSchemeOf( msOrigFileName );
480  InitCtor_();
481 
482  if (mxNumberFormatsSupplier.is())
484 }
485 
487  const css::uno::Reference< css::uno::XComponentContext >& xContext,
488  OUString const & implementationName,
489  const OUString &rFileName,
490  const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
491  const Reference< XModel >& rModel,
492  FieldUnit const eDefaultFieldUnit,
493  SvXMLExportFlags nExportFlag)
494 : mpImpl( new SvXMLExport_Impl ),
495  m_xContext(xContext), m_implementationName(implementationName),
496  mxModel( rModel ),
497  mxHandler( rHandler ),
498  mxExtHandler( rHandler, uno::UNO_QUERY ),
499  mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
500  mxAttrList( new SvXMLAttributeList ),
501  msOrigFileName( rFileName ),
502  mpNamespaceMap( new SvXMLNamespaceMap ),
503  mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
504  maUnitConv( xContext,
505  util::MeasureUnit::MM_100TH,
506  SvXMLUnitConverter::GetMeasureUnit(eDefaultFieldUnit),
507  getSaneDefaultVersion()),
509  mnExportFlags( nExportFlag ),
510  mnErrorFlags( SvXMLErrorFlags::NO ),
511  msWS( GetXMLToken(XML_WS) ),
512  mbSaveLinkedSections(true),
513  mbAutoStylesCollected(false)
514 {
515  SAL_WARN_IF(!xContext.is(), "xmloff.core", "got no service manager" );
516  mpImpl->SetSchemeOf( msOrigFileName );
517  InitCtor_();
518 
519  if (mxNumberFormatsSupplier.is())
521 }
522 
524 {
525  mpXMLErrors.reset();
526  mpImageMapExport.reset();
527  mpEventExport.reset();
528  mpNamespaceMap.reset();
530  {
531  if (mxExportInfo.is())
532  {
533  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
534  if (xPropertySetInfo.is())
535  {
537  {
538  OUString sProgressMax(XML_PROGRESSMAX);
539  OUString sProgressCurrent(XML_PROGRESSCURRENT);
540  OUString sRepeat(XML_PROGRESSREPEAT);
541  if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
542  xPropertySetInfo->hasPropertyByName(sProgressCurrent))
543  {
544  sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
545  sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
546  mxExportInfo->setPropertyValue(sProgressMax, uno::Any(nProgressMax));
547  mxExportInfo->setPropertyValue(sProgressCurrent, uno::Any(nProgressCurrent));
548  }
549  if (xPropertySetInfo->hasPropertyByName(sRepeat))
550  mxExportInfo->setPropertyValue(sRepeat, css::uno::makeAny(mpProgressBarHelper->GetRepeat()));
551  }
553  {
554  OUString sWrittenNumberFormats(XML_WRITTENNUMBERSTYLES);
555  if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
556  {
557  mxExportInfo->setPropertyValue(sWrittenNumberFormats, Any(mpNumExport->GetWasUsed()));
558  }
559  }
560  }
561  }
562  mpProgressBarHelper.reset();
563  mpNumExport.reset();
564  }
565 
566  if (mxEventListener.is() && mxModel.is())
567  mxModel->removeEventListener(mxEventListener);
568 }
569 
570 // XExporter
571 void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
572 {
573  mxModel.set( xDoc, UNO_QUERY );
574  if( !mxModel.is() )
575  throw lang::IllegalArgumentException();
576  if (mxModel.is() && ! mxEventListener.is())
577  {
578  mxEventListener.set( new SvXMLExportEventListener(this));
579  mxModel->addEventListener(mxEventListener);
580  }
581 
582  if(!mxNumberFormatsSupplier.is() )
583  {
584  mxNumberFormatsSupplier.set(mxModel, css::uno::UNO_QUERY);
585  if(mxNumberFormatsSupplier.is() && mxHandler.is())
587  }
588  if (mxExportInfo.is())
589  {
590  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
591  if (xPropertySetInfo.is())
592  {
593  OUString sUsePrettyPrinting(XML_USEPRETTYPRINTING);
594  if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting))
595  {
596  uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting);
597  if (::cppu::any2bool(aAny))
599  else
601  }
602 
604  {
605  OUString sWrittenNumberFormats(XML_WRITTENNUMBERSTYLES);
606  if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
607  {
608  uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats);
609  uno::Sequence<sal_Int32> aWasUsed;
610  if(aAny >>= aWasUsed)
611  mpNumExport->SetWasUsed(aWasUsed);
612  }
613  }
614  }
615  }
616 
617  // namespaces for user defined attributes
618  Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
619  if( xFactory.is() )
620  {
621  try
622  {
623  Reference < XInterface > xIfc =
624  xFactory->createInstance("com.sun.star.xml.NamespaceMap");
625  if( xIfc.is() )
626  {
627  Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY );
628  if( xNamespaceMap.is() )
629  {
630  const Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() );
631  for( OUString const & prefix : aPrefixes )
632  {
633  OUString aURL;
634  if( xNamespaceMap->getByName( prefix ) >>= aURL )
635  GetNamespaceMap_().Add( prefix, aURL );
636  }
637  }
638  }
639  }
640  catch(const css::uno::Exception&)
641  {
642  }
643  }
644 
645  // Determine model type (#i51726#)
647 }
648 
649 // XInitialize
650 void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments )
651 {
652  // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
653 
654  for( const auto& rAny : aArguments )
655  {
656  Reference<XInterface> xValue;
657  rAny >>= xValue;
658 
659  // status indicator
660  uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
661  if ( xTmpStatus.is() )
662  mxStatusIndicator = xTmpStatus;
663 
664  // graphic storage handler
665  uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(xValue, UNO_QUERY);
666  if (xGraphicStorageHandler.is())
667  mxGraphicStorageHandler = xGraphicStorageHandler;
668 
669  // object resolver
670  uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
671  xValue, UNO_QUERY );
672  if ( xTmpObjectResolver.is() )
673  mxEmbeddedResolver = xTmpObjectResolver;
674 
675  // document handler
676  uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler(
677  xValue, UNO_QUERY );
678  if( xTmpDocHandler.is() )
679  {
680  mxHandler = xTmpDocHandler;
681  rAny >>= mxExtHandler;
682 
683  if (mxNumberFormatsSupplier.is() && mpNumExport == nullptr)
685  }
686 
687  // property set to transport data across
688  uno::Reference<beans::XPropertySet> xTmpPropertySet(
689  xValue, UNO_QUERY );
690  if( xTmpPropertySet.is() )
691  mxExportInfo = xTmpPropertySet;
692  }
693 
694  if( !mxExportInfo.is() )
695  return;
696 
697  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
698  mxExportInfo->getPropertySetInfo();
699  OUString sPropName(
700  "BaseURI" );
701  if( xPropertySetInfo->hasPropertyByName(sPropName) )
702  {
703  uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
704  aAny >>= msOrigFileName;
705  mpImpl->msPackageURI = msOrigFileName;
706  mpImpl->SetSchemeOf( msOrigFileName );
707  }
708  OUString sRelPath;
709  sPropName = "StreamRelPath";
710  if( xPropertySetInfo->hasPropertyByName(sPropName) )
711  {
712  uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
713  aAny >>= sRelPath;
714  }
715  OUString sName;
716  sPropName = "StreamName";
717  if( xPropertySetInfo->hasPropertyByName(sPropName) )
718  {
719  uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
720  aAny >>= sName;
721  }
722  if( !msOrigFileName.isEmpty() && !sName.isEmpty() )
723  {
724  INetURLObject aBaseURL( msOrigFileName );
725  if( !sRelPath.isEmpty() )
726  aBaseURL.insertName( sRelPath );
727  aBaseURL.insertName( sName );
729  }
730  mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
731 
732  // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
733  static const OUStringLiteral sOutlineStyleAsNormalListStyle(
734  u"OutlineStyleAsNormalListStyle" );
735  if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) )
736  {
737  uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle );
738  aAny >>= mpImpl->mbOutlineStyleAsNormalListStyle;
739  }
740 
741  OUString sTargetStorage( "TargetStorage" );
742  if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) )
743  mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage;
744 
745  static const OUStringLiteral sExportTextNumberElement(
746  u"ExportTextNumberElement" );
747  if( xPropertySetInfo->hasPropertyByName( sExportTextNumberElement ) )
748  {
749  uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement );
750  aAny >>= mpImpl->mbExportTextNumberElement;
751  }
752 }
753 
754 // XFilter
755 sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
756 {
757  // check for xHandler first... should have been supplied in initialize
758  if( !mxHandler.is() )
759  return false;
760 
761  try
762  {
763  const SvXMLExportFlags nTest =
765  if( (mnExportFlags & nTest) == nTest && msOrigFileName.isEmpty() )
766  {
767  // evaluate descriptor only for flat files and if a base URI
768  // has not been provided already
769 
770  for( const auto& rProp : aDescriptor )
771  {
772  const OUString& rPropName = rProp.Name;
773  const Any& rValue = rProp.Value;
774 
775  if ( rPropName == "FileName" )
776  {
777  if( !(rValue >>= msOrigFileName ) )
778  return false;
779  }
780  else if ( rPropName == "FilterName" )
781  {
782  if( !(rValue >>= msFilterName ) )
783  return false;
784  }
785  }
786  }
787 
788  for( const auto& rProp : aDescriptor )
789  {
790  const OUString& rPropName = rProp.Name;
791  const Any& rValue = rProp.Value;
792 
793  if (rPropName == "SourceShellID")
794  {
795  if (!(rValue >>= mpImpl->maSrcShellID))
796  return false;
797  }
798  else if (rPropName == "DestinationShellID")
799  {
800  if (!(rValue >>= mpImpl->maDestShellID))
801  return false;
802  }
803  else if( rPropName == "ImageFilter")
804  {
805  if (!(rValue >>= msImgFilterName))
806  return false;
807  }
808  }
809 
810 
811  exportDoc( meClass );
812  }
813  catch(const uno::Exception& e)
814  {
815  // We must catch exceptions, because according to the
816  // API definition export must not throw one!
817  css::uno::Any ex(cppu::getCaughtException());
818  OUString sMessage( ex.getValueTypeName() + ": \"" + e.Message + "\"");
819  if (e.Context.is())
820  {
821  const char* pContext = typeid(*e.Context).name();
822  sMessage += " (context: " + OUString::createFromAscii(pContext) + " )";
823  }
825  Sequence<OUString>(), sMessage, nullptr );
826  }
827 
828  // return true only if no error occurred
830 }
831 
832 void SAL_CALL SvXMLExport::cancel()
833 {
834  // stop export
835  Sequence<OUString> aEmptySeq;
837 }
838 
839 OUString SAL_CALL SvXMLExport::getName( )
840 {
841  return msFilterName;
842 }
843 
844 void SAL_CALL SvXMLExport::setName( const OUString& )
845 {
846  // do nothing, because it is not possible to set the FilterName
847 }
848 
849 // XServiceInfo
851 {
852  return m_implementationName;
853 }
854 
855 sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName )
856 {
857  return cppu::supportsService(this, rServiceName);
858 }
859 
860 uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
861 {
862  return { "com.sun.star.document.ExportFilter", "com.sun.star.xml.XMLExportFilter" };
863 }
864 
865 OUString
866 SvXMLExport::EnsureNamespace(OUString const & i_rNamespace)
867 {
868  OUString const aPreferredPrefix("gen");
869  OUString sPrefix;
870  sal_uInt16 nKey( GetNamespaceMap_().GetKeyByName( i_rNamespace ) );
871  if( XML_NAMESPACE_UNKNOWN == nKey )
872  {
873  // There is no prefix for the namespace, so
874  // we have to generate one and have to add it.
875  sPrefix = aPreferredPrefix;
876  nKey = GetNamespaceMap_().GetKeyByPrefix( sPrefix );
877  sal_Int32 n( 0 );
878  OUStringBuffer buf;
879  while( nKey != USHRT_MAX )
880  {
881  buf.append( aPreferredPrefix );
882  buf.append( ++n );
883  sPrefix = buf.makeStringAndClear();
884  nKey = GetNamespaceMap_().GetKeyByPrefix( sPrefix );
885  }
886 
887  if (mpImpl->mNamespaceMaps.empty()
888  || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
889  {
890  // top was created for lower depth... need a new namespace map!
891  auto pNew = new SvXMLNamespaceMap( *mpNamespaceMap );
892  mpImpl->mNamespaceMaps.push(
893  ::std::make_pair(std::move(mpNamespaceMap), mpImpl->mDepth) );
894  mpNamespaceMap.reset( pNew );
895  }
896 
897  // add the namespace to the map and as attribute
898  mpNamespaceMap->Add( sPrefix, i_rNamespace );
899  AddAttribute( GetXMLToken(XML_XMLNS) + ":" + sPrefix, i_rNamespace );
900  }
901  else
902  {
903  // If there is a prefix for the namespace, reuse that.
904  sPrefix = GetNamespaceMap_().GetPrefixByKey( nKey );
905  }
906  return sPrefix;
907 }
908 
909 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
910  const OUString& rValue )
911 {
912  AddAttribute(GetNamespaceMap_().GetQNameByKey(nPrefixKey, rName), rValue);
913 }
914 
915 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
916  enum XMLTokenEnum eName,
917  const OUString& rValue )
918 {
919  AddAttribute(nPrefixKey, GetXMLToken(eName), rValue);
920 }
921 
922 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
923  enum XMLTokenEnum eName,
924  enum XMLTokenEnum eValue)
925 {
926  AddAttribute(nPrefixKey, eName, GetXMLToken(eValue));
927 }
928 
929 void SvXMLExport::AddAttribute( const OUString& rQName,
930  const OUString& rValue )
931 {
932  mxAttrList->AddAttribute(
933  rQName,
934  rValue );
935 }
936 
937 void SvXMLExport::AddAttribute( const OUString& rQName,
939 {
940  AddAttribute(rQName, GetXMLToken(eValue));
941 }
942 
943 void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
944  const css::lang::Locale& rLocale, bool bWriteEmpty )
945 {
946  if (rLocale.Variant.isEmpty())
947  {
948  // Per convention The BCP 47 string is always stored in Variant, if
949  // that is empty we have a plain language-country combination, no need
950  // to convert to LanguageTag first. Also catches the case of empty
951  // locale denoting system locale.
952  xmloff::token::XMLTokenEnum eLanguage, eCountry;
953  eLanguage = XML_LANGUAGE;
954  eCountry = XML_COUNTRY;
955  if (bWriteEmpty || !rLocale.Language.isEmpty())
956  AddAttribute( nPrefix, eLanguage, rLocale.Language);
957  if (bWriteEmpty || !rLocale.Country.isEmpty())
958  AddAttribute( nPrefix, eCountry, rLocale.Country);
959  }
960  else
961  {
962  LanguageTag aLanguageTag( rLocale);
963  AddLanguageTagAttributes( nPrefix, nPrefixRfc, aLanguageTag, bWriteEmpty);
964  }
965 }
966 
967 void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
968  const LanguageTag& rLanguageTag, bool bWriteEmpty )
969 {
970  if (rLanguageTag.isIsoODF())
971  {
972  if (bWriteEmpty || !rLanguageTag.isSystemLocale())
973  {
974  AddAttribute( nPrefix, XML_LANGUAGE, rLanguageTag.getLanguage());
976  AddAttribute( nPrefix, XML_SCRIPT, rLanguageTag.getScript());
977  if (bWriteEmpty || !rLanguageTag.getCountry().isEmpty())
978  AddAttribute( nPrefix, XML_COUNTRY, rLanguageTag.getCountry());
979  }
980  }
981  else
982  {
984  AddAttribute( nPrefixRfc, XML_RFC_LANGUAGE_TAG, rLanguageTag.getBcp47());
985  // Also in case of non-pure-ISO tag store best matching fo: attributes
986  // for consumers not handling *:rfc-language-tag, ensuring that only
987  // valid ISO codes are stored. Here the bWriteEmpty parameter has no
988  // meaning.
989  OUString aLanguage, aScript, aCountry;
990  rLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
991  if (!aLanguage.isEmpty())
992  {
993  AddAttribute( nPrefix, XML_LANGUAGE, aLanguage);
994  if (!aScript.isEmpty() && getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
995  AddAttribute( nPrefix, XML_SCRIPT, aScript);
996  if (!aCountry.isEmpty())
997  AddAttribute( nPrefix, XML_COUNTRY, aCountry);
998  }
999  }
1000 }
1001 
1002 void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1003 {
1004  if( xAttrList.is())
1005  mxAttrList->AppendAttributeList( xAttrList );
1006 }
1007 
1009 {
1010  mxAttrList->Clear();
1011 }
1012 
1013 #ifdef DBG_UTIL
1015 {
1016  SAL_WARN_IF( mxAttrList->getLength(), "xmloff.core", "XMLExport::CheckAttrList: list is not empty" );
1017 }
1018 #endif
1019 
1021 {
1022  CheckAttrList();
1023 
1024  ExportMeta_();
1025 }
1026 
1028 {
1029  CheckAttrList();
1030 
1031  ::std::vector< SettingsGroup > aSettings;
1032  sal_Int32 nSettingsCount = 0;
1033 
1034  // view settings
1035  uno::Sequence< beans::PropertyValue > aViewSettings;
1036  GetViewSettingsAndViews( aViewSettings );
1037  aSettings.emplace_back( XML_VIEW_SETTINGS, aViewSettings );
1038  nSettingsCount += aViewSettings.getLength();
1039 
1040  // configuration settings
1041  uno::Sequence<beans::PropertyValue> aConfigSettings;
1042  GetConfigurationSettings( aConfigSettings );
1043  aSettings.emplace_back( XML_CONFIGURATION_SETTINGS, aConfigSettings );
1044  nSettingsCount += aConfigSettings.getLength();
1045 
1046  // any document specific settings
1047  nSettingsCount += GetDocumentSpecificSettings( aSettings );
1048 
1049  {
1050  SvXMLElementExport aElem( *this,
1051  nSettingsCount != 0,
1053  true, true );
1054 
1055  SettingsExportFacade aSettingsExportContext( *this );
1056  XMLSettingsExportHelper aSettingsExportHelper( aSettingsExportContext );
1057 
1058  for (auto const& settings : aSettings)
1059  {
1060  if ( !settings.aSettings.hasElements() )
1061  continue;
1062 
1063  const OUString& sSettingsName( GetXMLToken( settings.eGroupName ) );
1064  OUString sQName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO, sSettingsName );
1065  aSettingsExportHelper.exportAllSettings( settings.aSettings, sQName );
1066  }
1067  }
1068 }
1069 
1071 {
1072  CheckAttrList();
1073 
1074  {
1075  // <style:styles>
1077  true, true );
1078 
1079  ExportStyles_( false );
1080  }
1081 
1082  // transfer style names (+ families) TO other components (if appropriate)
1084  return;
1085 
1086  static OUString sStyleNames( "StyleNames" );
1087  static OUString sStyleFamilies( "StyleFamilies" );
1088  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1089  if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) )
1090  {
1091  Sequence<sal_Int32> aStyleFamilies;
1092  Sequence<OUString> aStyleNames;
1093  mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
1094  mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) );
1095  mxExportInfo->setPropertyValue( sStyleFamilies,
1096  makeAny( aStyleFamilies ) );
1097  }
1098 }
1099 
1101 {
1102  // transfer style names (+ families) FROM other components (if appropriate)
1103  OUString sStyleNames( "StyleNames" );
1104  OUString sStyleFamilies( "StyleFamilies" );
1106  && mxExportInfo.is()
1107  && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
1108  && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
1109  {
1110  Sequence<sal_Int32> aStyleFamilies;
1111  mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies;
1112  Sequence<OUString> aStyleNames;
1113  mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames;
1114  mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames );
1115  }
1116 
1117  {
1118  // <style:automatic-styles>
1120  XML_AUTOMATIC_STYLES, true, true );
1121 
1123  }
1124 }
1125 
1127 {
1128  // <style:master-styles>
1130  true, true );
1131 
1133 }
1134 
1136 {
1137  CheckAttrList();
1138 
1139  {
1141  true, true );
1142  {
1143  XMLTokenEnum eClass = meClass;
1144  if( XML_TEXT_GLOBAL == eClass )
1145  {
1147  GetXMLToken( XML_TRUE ) );
1148  eClass = XML_TEXT;
1149  }
1150  if ( XML_GRAPHICS == eClass )
1151  eClass = XML_DRAWING;
1152  // <office:body ...>
1154  SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID,
1155  XML_NAMESPACE_OFFICE, eClass,
1156  true, true );
1157 
1158  ExportContent_();
1159  }
1160  }
1161 }
1162 
1164 {
1165 }
1166 
1167 static void
1168 lcl_AddGrddl(SvXMLExport const & rExport, const SvXMLExportFlags /*nExportMode*/)
1169 {
1170  // check version >= 1.2
1171  switch (rExport.getSaneDefaultVersion()) {
1172  case SvtSaveOptions::ODFSVER_011: // fall through
1173  case SvtSaveOptions::ODFSVER_010: return;
1174  default: break;
1175  }
1176 
1177  // #i115030#: disabled, the XSLT is not finished, and not available via HTTP
1178 #if 0
1179  if (SvXMLExportFlags::SETTINGS != nExportMode) // meta, content, styles
1180  {
1182  OUString("http://FIXME") );
1183  }
1184 #endif
1185 }
1186 
1188 {
1189  uno::Reference< embed::XEncryptionProtectedSource2 > xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
1190 
1191  if (xEncr.is() && xEncr->hasEncryptionData() && mxExtHandler.is())
1192  {
1193  mxExtHandler->comment(OStringToOUString(comphelper::xml::makeXMLChaff(), RTL_TEXTENCODING_ASCII_US));
1194  }
1195 }
1196 
1197 auto SvXMLExport::GetODFVersionAttributeValue() const -> char const*
1198 {
1199  char const* pVersion(nullptr);
1200  switch (getSaneDefaultVersion())
1201  {
1202  case SvtSaveOptions::ODFSVER_013_EXTENDED: [[fallthrough]];
1203  case SvtSaveOptions::ODFSVER_013: pVersion = "1.3"; break;
1204  case SvtSaveOptions::ODFSVER_012_EXTENDED: [[fallthrough]];
1205  case SvtSaveOptions::ODFSVER_012_EXT_COMPAT: [[fallthrough]];
1206  case SvtSaveOptions::ODFSVER_012: pVersion = "1.2"; break;
1207  case SvtSaveOptions::ODFSVER_011: pVersion = "1.1"; break;
1208  case SvtSaveOptions::ODFSVER_010: break;
1209 
1210  default:
1211  assert(!"xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1212  }
1213  return pVersion;
1214 }
1215 
1217 {
1218  bool bOwnGraphicResolver = false;
1219  bool bOwnEmbeddedResolver = false;
1220 
1221  if (!mxGraphicStorageHandler.is() || !mxEmbeddedResolver.is())
1222  {
1223  Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
1224  if( xFactory.is() )
1225  {
1226  try
1227  {
1228  if (!mxGraphicStorageHandler.is())
1229  {
1230  mxGraphicStorageHandler.set(xFactory->createInstance( "com.sun.star.document.ExportGraphicStorageHandler"), UNO_QUERY);
1231  bOwnGraphicResolver = mxGraphicStorageHandler.is();
1232  }
1233 
1234  if( !mxEmbeddedResolver.is() )
1235  {
1236  mxEmbeddedResolver.set(
1237  xFactory->createInstance( "com.sun.star.document.ExportEmbeddedObjectResolver" ), UNO_QUERY);
1238  bOwnEmbeddedResolver = mxEmbeddedResolver.is();
1239  }
1240  }
1241  catch(const css::uno::Exception&)
1242  {
1243  }
1244  }
1245  }
1247  {
1248  try
1249  {
1250  static ::comphelper::PropertyMapEntry const aInfoMap[] =
1251  {
1252  { OUString("Class"), 0,
1254  PropertyAttribute::MAYBEVOID, 0},
1255  { OUString(), 0, css::uno::Type(), 0, 0 }
1256  };
1257  Reference< XPropertySet > xConvPropSet(
1259  new ::comphelper::PropertySetInfo( aInfoMap ) ) );
1260 
1261  xConvPropSet->setPropertyValue( "Class", Any(GetXMLToken( eClass )) );
1262 
1263  Reference< XPropertySet > xPropSet =
1264  mxExportInfo.is()
1266  xConvPropSet )
1267  : xConvPropSet;
1268 
1269  Sequence<Any> aArgs( 3 );
1270  aArgs[0] <<= mxHandler;
1271  aArgs[1] <<= xPropSet;
1272  aArgs[2] <<= mxModel;
1273 
1274  // get filter component
1276  m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.Oasis2OOoTransformer", aArgs, m_xContext),
1277  UNO_QUERY);
1278  SAL_WARN_IF(!xTmpDocHandler.is(), "xmloff.core", "can't instantiate OASIS transformer component" );
1279  if( xTmpDocHandler.is() )
1280  {
1281  mxHandler = xTmpDocHandler;
1282  mxExtHandler.set( mxHandler, UNO_QUERY );
1283  }
1284  }
1285  catch(const css::uno::Exception&)
1286  {
1287  }
1288  }
1289 
1290  mxHandler->startDocument();
1291 
1293 
1294  // <office:document ...>
1295  CheckAttrList();
1296 
1297  // namespace attributes
1298  // ( The namespace decls should be first attributes in the element;
1299  // some faulty XML parsers (JAXP1.1) have a problem with this,
1300  // also it's more elegant )
1301  sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
1302  while( USHRT_MAX != nPos )
1303  {
1304  mxAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
1305  mpNamespaceMap->GetNameByKey( nPos ) );
1306  nPos = mpNamespaceMap->GetNextKey( nPos );
1307  }
1308 
1309  // office:version = ...
1310  const char*const pVersion = GetODFVersionAttributeValue();
1311 
1312  if (pVersion)
1313  {
1315  OUString::createFromAscii(pVersion) );
1316  }
1317 
1318  {
1319  enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
1321 
1322  lcl_AddGrddl(*this, nExportMode);
1323 
1324  if( SvXMLExportFlags::META == nExportMode )
1325  {
1326  // export only meta
1327  eRootService = XML_DOCUMENT_META;
1328  }
1329  else if ( SvXMLExportFlags::SETTINGS == nExportMode )
1330  {
1331  // export only settings
1332  eRootService = XML_DOCUMENT_SETTINGS;
1333  }
1334  else if( SvXMLExportFlags::STYLES == nExportMode )
1335  {
1336  // export only styles
1337  eRootService = XML_DOCUMENT_STYLES;
1338  }
1339  else if( SvXMLExportFlags::CONTENT == nExportMode )
1340  {
1341  // export only content
1342  eRootService = XML_DOCUMENT_CONTENT;
1343  }
1344  else
1345  {
1346  // the god'ol one4all element
1347  eRootService = XML_DOCUMENT;
1348  // office:mimetype = ... (only for stream containing the content)
1349  if( eClass != XML_TOKEN_INVALID )
1350  {
1351  OUString aTmp = "application/vnd.oasis.opendocument." + GetXMLToken( eClass );
1353  }
1354  }
1355 
1356  SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, true, true );
1357 
1358  // meta information
1360  ImplExportMeta();
1361 
1362  // settings
1365 
1366  // scripts
1368  ExportScripts_();
1369 
1370  // font declarations
1372  ExportFontDecls_();
1373 
1374  // styles
1376  ImplExportStyles();
1377 
1378  // autostyles
1381 
1382  // masterstyles
1385 
1386  // content
1389  }
1390 
1391  mxHandler->endDocument();
1392 
1393  if( bOwnGraphicResolver )
1394  {
1395  uno::Reference<XComponent> xComp(mxGraphicStorageHandler, UNO_QUERY);
1396  xComp->dispose();
1397  }
1398 
1399  if( bOwnEmbeddedResolver )
1400  {
1401  Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
1402  xComp->dispose();
1403  }
1404 
1405  return ERRCODE_NONE;
1406 }
1407 
1409 {
1410  mpNamespaceMap.reset( new SvXMLNamespaceMap );
1411 }
1412 
1413 OUString const & SvXMLExport::GetSourceShellID() const
1414 {
1415  return mpImpl->maSrcShellID;
1416 }
1417 
1418 OUString const & SvXMLExport::GetDestinationShellID() const
1419 {
1420  return mpImpl->maDestShellID;
1421 }
1422 
1424 {
1425  OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
1426  Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
1427  UNO_QUERY);
1428  if (xDocPropsSupplier.is()) {
1429  Reference<XDocumentProperties> xDocProps(
1430  xDocPropsSupplier->getDocumentProperties());
1431  if (!xDocProps.is()) throw;
1432  // update generator here
1433  xDocProps->setGenerator(generator);
1434  rtl::Reference<SvXMLMetaExport> pMeta = new SvXMLMetaExport(*this, xDocProps);
1435  pMeta->Export();
1436  } else {
1437  // office:meta
1439  true, true );
1440  {
1441  // BM: #i60323# export generator even if xInfoProp is empty (which is the
1442  // case for charts). The generator does not depend on xInfoProp
1444  true, true );
1445  Characters(generator);
1446  }
1447  }
1448 }
1449 
1451 {
1452  SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, true, true );
1453 
1454  // export Basic macros (only for FlatXML)
1456  {
1457  OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) + ":Basic" );
1459 
1460  SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, true, true );
1461 
1462  // initialize Basic
1463  if ( mxModel.is() )
1464  {
1465  Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
1466  if ( xPSet.is() )
1467  xPSet->getPropertyValue("BasicLibraries");
1468  }
1469 
1470  Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
1471  Reference< document::XXMLBasicExporter > xExporter = document::XMLOasisBasicExporter::createWithHandler( m_xContext, xHdl );
1472 
1473  xExporter->setSourceDocument( mxModel );
1474  Sequence< PropertyValue > aMediaDesc( 0 );
1475  xExporter->filter( aMediaDesc );
1476  }
1477 
1478  // export document events
1479  Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
1480  GetEventExport().Export( xEvents );
1481 }
1482 
1484 {
1485  if( mxFontAutoStylePool.is() )
1486  mxFontAutoStylePool->exportXML();
1487 }
1488 
1490 {
1491  uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
1492  if( !xFact.is())
1493  return;
1494 
1495  // export (fill-)gradient-styles
1496  try
1497  {
1498  uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
1499  if( xGradient.is() )
1500  {
1501  XMLGradientStyleExport aGradientStyle( *this );
1502 
1503  if( xGradient->hasElements() )
1504  {
1505  const uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1506  for( const OUString& rStrName : aNamesSeq )
1507  {
1508  try
1509  {
1510  uno::Any aValue = xGradient->getByName( rStrName );
1511 
1512  aGradientStyle.exportXML( rStrName, aValue );
1513  }
1514  catch(const container::NoSuchElementException&)
1515  {
1516  }
1517  }
1518  }
1519  }
1520  }
1521  catch(const lang::ServiceNotRegisteredException&)
1522  {
1523  }
1524 
1525  // export (fill-)hatch-styles
1526  try
1527  {
1528  uno::Reference< container::XNameAccess > xHatch( xFact->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY );
1529  if( xHatch.is() )
1530  {
1531  XMLHatchStyleExport aHatchStyle( *this );
1532 
1533  if( xHatch->hasElements() )
1534  {
1535  const uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1536  for( const OUString& rStrName : aNamesSeq )
1537  {
1538  try
1539  {
1540  uno::Any aValue = xHatch->getByName( rStrName );
1541 
1542  aHatchStyle.exportXML( rStrName, aValue );
1543  }
1544  catch(const container::NoSuchElementException&)
1545  {}
1546  }
1547  }
1548  }
1549  }
1550  catch(const lang::ServiceNotRegisteredException&)
1551  {
1552  }
1553 
1554  // export (fill-)bitmap-styles
1555  try
1556  {
1557  uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
1558  if( xBitmap.is() )
1559  {
1560  if( xBitmap->hasElements() )
1561  {
1562  const uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1563  for( const OUString& rStrName : aNamesSeq )
1564  {
1565  try
1566  {
1567  uno::Any aValue = xBitmap->getByName( rStrName );
1568 
1569  XMLImageStyle::exportXML( rStrName, aValue, *this );
1570  }
1571  catch(const container::NoSuchElementException&)
1572  {
1573  }
1574  }
1575  }
1576  }
1577  }
1578  catch(const lang::ServiceNotRegisteredException&)
1579  {
1580  }
1581 
1582  // export transparency-gradient -styles
1583  try
1584  {
1585  uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY );
1586  if( xTransGradient.is() )
1587  {
1588  XMLTransGradientStyleExport aTransGradientstyle( *this );
1589 
1590  if( xTransGradient->hasElements() )
1591  {
1592  const uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1593  for( const OUString& rStrName : aNamesSeq )
1594  {
1595  try
1596  {
1597  uno::Any aValue = xTransGradient->getByName( rStrName );
1598 
1599  aTransGradientstyle.exportXML( rStrName, aValue );
1600  }
1601  catch(const container::NoSuchElementException&)
1602  {
1603  }
1604  }
1605  }
1606  }
1607  }
1608  catch(const lang::ServiceNotRegisteredException&)
1609  {
1610  }
1611 
1612  // export marker-styles
1613  try
1614  {
1615  uno::Reference< container::XNameAccess > xMarker( xFact->createInstance("com.sun.star.drawing.MarkerTable"), uno::UNO_QUERY );
1616  if( xMarker.is() )
1617  {
1618  XMLMarkerStyleExport aMarkerStyle( *this );
1619 
1620  if( xMarker->hasElements() )
1621  {
1622  const uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1623  for( const OUString& rStrName : aNamesSeq )
1624  {
1625  try
1626  {
1627  uno::Any aValue = xMarker->getByName( rStrName );
1628 
1629  aMarkerStyle.exportXML( rStrName, aValue );
1630  }
1631  catch(const container::NoSuchElementException&)
1632  {
1633  }
1634  }
1635  }
1636  }
1637  }
1638  catch(const lang::ServiceNotRegisteredException&)
1639  {
1640  }
1641 
1642  // export dash-styles
1643  try
1644  {
1645  uno::Reference< container::XNameAccess > xDashes( xFact->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
1646  if( xDashes.is() )
1647  {
1648  XMLDashStyleExport aDashStyle( *this );
1649 
1650  if( xDashes->hasElements() )
1651  {
1652  const uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1653  for( const OUString& rStrName : aNamesSeq )
1654  {
1655  try
1656  {
1657  uno::Any aValue = xDashes->getByName( rStrName );
1658 
1659  aDashStyle.exportXML( rStrName, aValue );
1660  }
1661  catch(const container::NoSuchElementException&)
1662  {
1663  }
1664  }
1665  }
1666  }
1667  }
1668  catch(const lang::ServiceNotRegisteredException&)
1669  {
1670  }
1671 }
1672 
1674 {
1675  return new XMLTextParagraphExport( *this, *GetAutoStylePool() );
1676 }
1677 
1679 {
1680  return new XMLShapeExport(*this);
1681 }
1682 
1684 {
1685  return new SvXMLAutoStylePoolP(*this);
1686 }
1687 
1689 {
1690 }
1691 
1693 {
1694  return new XMLPageExport( *this );
1695 }
1696 
1698 {
1699  return new SchXMLExportHelper(*this, *GetAutoStylePool());
1700 }
1701 
1703 {
1704  return new XMLFontAutoStylePool( *this );
1705 }
1706 
1708 {
1709  return new xmloff::OFormLayerXMLExport(*this);
1710 }
1711 
1712 void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1713 {
1714  GetViewSettings(rProps);
1715  uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1716  if(!xViewDataSupplier.is())
1717  return;
1718 
1719  uno::Reference<container::XIndexAccess> xIndexAccess;
1720  xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1721  {
1722  // tdf#130559: don't export preview view data if active
1723  css::uno::ContextLayer layer(comphelper::NewFlagContext("NoPreviewData"));
1724  xIndexAccess = xViewDataSupplier->getViewData();
1725  }
1726  bool bAdd = false;
1727  uno::Any aAny;
1728  if(xIndexAccess.is() && xIndexAccess->hasElements() )
1729  {
1730  sal_Int32 nCount = xIndexAccess->getCount();
1731  for (sal_Int32 i = 0; i < nCount; i++)
1732  {
1733  aAny = xIndexAccess->getByIndex(i);
1734  uno::Sequence<beans::PropertyValue> aProps;
1735  if( aAny >>= aProps )
1736  {
1737  if( aProps.hasElements() )
1738  {
1739  bAdd = true;
1740  break;
1741  }
1742  }
1743  }
1744  }
1745 
1746  if( bAdd )
1747  {
1748  sal_Int32 nOldLength(rProps.getLength());
1749  rProps.realloc(nOldLength + 1);
1750  beans::PropertyValue aProp;
1751  aProp.Name = "Views";
1752  aProp.Value <<= xIndexAccess;
1753  rProps[nOldLength] = aProp;
1754  }
1755 }
1756 
1757 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1758 {
1759 }
1760 
1761 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1762 {
1763 }
1764 
1765 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::vector< SettingsGroup >& )
1766 {
1767  return 0;
1768 }
1769 
1770 void SvXMLExport::collectDataStyles(bool bFromUsedStyles)
1771 {
1772  Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetModel(), uno::UNO_QUERY);
1773  if (!xStyleFamiliesSupplier.is())
1774  return;
1775 
1776  Reference<container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
1777  if (!xStylesFamilies.is())
1778  return;
1779 
1780  Reference<container::XIndexAccess> xCellStyles(xStylesFamilies->getByName("CellStyles"), uno::UNO_QUERY);
1781  if (!xCellStyles.is())
1782  return;
1783 
1784  sal_Int32 nCount(xCellStyles->getCount());
1785  for (sal_Int32 i = 0; i < nCount; ++i)
1786  {
1787  Reference<style::XStyle> xStyle(xCellStyles->getByIndex(i), uno::UNO_QUERY);
1788  if (bFromUsedStyles && !xStyle->isInUse())
1789  continue;
1790 
1791  Reference<beans::XPropertySet> xCellProperties(xStyle, uno::UNO_QUERY);
1792  if (xCellProperties.is())
1793  {
1794  sal_Int32 nNumberFormat = 0;
1795  if (xCellProperties->getPropertyValue("NumberFormat") >>= nNumberFormat)
1796  addDataStyle(nNumberFormat);
1797  }
1798  }
1799 }
1800 
1801 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ )
1802 {
1803  if(mpNumExport)
1804  mpNumExport->SetUsed(nNumberFormat);
1805 }
1806 
1808 {
1809  if(mpNumExport)
1810  mpNumExport->Export(false);
1811 }
1812 
1814 {
1815  if(mpNumExport)
1816  mpNumExport->Export(true);
1817 
1818  if (mxFormExport.is())
1819  mxFormExport->exportAutoControlNumberStyles();
1820 }
1821 
1822 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ ) const
1823 {
1824  OUString sTemp;
1825  if(mpNumExport)
1826  sTemp = mpNumExport->GetStyleName(nNumberFormat);
1827  return sTemp;
1828 }
1829 
1830 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1831 {
1832 }
1833 
1834 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1835 {
1836  return ( mpNumExport != nullptr )
1837  ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1838 }
1839 
1840 OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName)
1841 {
1842  OUString sURL;
1843 
1844  Graphic aGraphic(rxGraphic);
1845  OUString aOriginURL = aGraphic.getOriginURL();
1846 
1847  if (!aOriginURL.isEmpty())
1848  {
1849  sURL = GetRelativeReference(aOriginURL);
1850  }
1851  else
1852  {
1853  if (mxGraphicStorageHandler.is())
1854  {
1856  sURL = mxGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutMimeType, rRequestedName);
1857  }
1858  }
1859  return sURL;
1860 }
1861 
1862 bool SvXMLExport::GetGraphicMimeTypeFromStream(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType)
1863 {
1864  if (mxGraphicStorageHandler.is())
1865  {
1866  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1867  if (xInputStream.is())
1868  {
1870  return true;
1871  }
1872  }
1873 
1874  return false;
1875 }
1876 
1877 bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic> const & rxGraphic)
1878 {
1881  {
1882  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1883  if (xInputStream.is())
1884  {
1885  Graphic aGraphic(rxGraphic);
1886  if (aGraphic.getOriginURL().isEmpty()) // don't add the base64 if the origin URL is set (image is from an external URL)
1887  {
1888  XMLBase64Export aBase64Exp(*this);
1889  return aBase64Exp.exportOfficeBinaryDataElement(xInputStream);
1890  }
1891  }
1892  }
1893 
1894  return false;
1895 }
1896 
1897 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
1898 {
1899  OUString sRet;
1900  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1901  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1902  if (bSupportedURL && mxEmbeddedResolver.is())
1903  {
1904  sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(rEmbeddedObjectURL);
1905  }
1906  else
1907  sRet = GetRelativeReference( rEmbeddedObjectURL );
1908 
1909  return sRet;
1910 }
1911 
1912 bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
1913 {
1914  bool bRet = false;
1915  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1916  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1917  if (bSupportedURL && mxEmbeddedResolver.is())
1918  {
1920  if( xNA.is() )
1921  {
1922  Any aAny = xNA->getByName( rEmbeddedObjectURL );
1924  aAny >>= xIn;
1925  if( xIn.is() )
1926  {
1927  XMLBase64Export aBase64Exp( *this );
1928  bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1929  }
1930  }
1931  }
1932 
1933  return bRet;
1934 }
1935 
1937  const OUString& rName,
1938  bool *pEncoded ) const
1939 {
1940  return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
1941 }
1942 
1944 {
1945  if (!mpProgressBarHelper)
1946  {
1948 
1949  if (mxExportInfo.is())
1950  {
1951  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1952  if (xPropertySetInfo.is())
1953  {
1954  OUString sProgressRange(XML_PROGRESSRANGE);
1955  OUString sProgressMax(XML_PROGRESSMAX);
1956  OUString sProgressCurrent(XML_PROGRESSCURRENT);
1957  OUString sRepeat(XML_PROGRESSREPEAT);
1958  if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1959  xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1960  xPropertySetInfo->hasPropertyByName(sProgressRange))
1961  {
1962  uno::Any aAny;
1963  sal_Int32 nProgressMax(0);
1964  sal_Int32 nProgressCurrent(0);
1965  sal_Int32 nProgressRange(0);
1966  aAny = mxExportInfo->getPropertyValue(sProgressRange);
1967  if (aAny >>= nProgressRange)
1968  mpProgressBarHelper->SetRange(nProgressRange);
1969  aAny = mxExportInfo->getPropertyValue(sProgressMax);
1970  if (aAny >>= nProgressMax)
1971  mpProgressBarHelper->SetReference(nProgressMax);
1972  aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
1973  if (aAny >>= nProgressCurrent)
1974  mpProgressBarHelper->SetValue(nProgressCurrent);
1975  }
1976  if (xPropertySetInfo->hasPropertyByName(sRepeat))
1977  {
1978  uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
1979  if (aAny.getValueType() == cppu::UnoType<bool>::get())
1980  mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1981  else {
1982  SAL_WARN("xmloff.core", "why is it no boolean?" );
1983  }
1984  }
1985  }
1986  }
1987  }
1988  return mpProgressBarHelper.get();
1989 }
1990 
1992 {
1993  if( nullptr == mpEventExport)
1994  {
1995  // create EventExport on demand
1996  mpEventExport.reset( new XMLEventExport(*this) );
1997 
1998  // and register standard handlers + names
1999  mpEventExport->AddHandler("StarBasic", std::make_unique<XMLStarBasicExportHandler>());
2000  mpEventExport->AddHandler("Script", std::make_unique<XMLScriptExportHandler>());
2001  mpEventExport->AddTranslationTable(aStandardEventTable);
2002  }
2003 
2004  return *mpEventExport;
2005 }
2006 
2008 {
2009  // image map export, create on-demand
2010  if( nullptr == mpImageMapExport )
2011  {
2012  mpImageMapExport.reset( new XMLImageMapExport(*this) );
2013  }
2014 
2015  return *mpImageMapExport;
2016 }
2017 
2018 // XUnoTunnel & co
2020 
2021 void SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent > const & rComp )
2022 {
2023  OUString sFilterService;
2024 
2025  Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2026  if( xServiceInfo.is() )
2027  {
2028  for (const auto& [sModelService, sMatchingFilterService] : aServiceMap)
2029  {
2030  if( xServiceInfo->supportsService( sModelService ) )
2031  {
2032  sFilterService = sMatchingFilterService;
2033  break;
2034  }
2035  }
2036  }
2037 
2038  SAL_WARN_IF( !sFilterService.getLength(), "xmloff.core", "no export filter for own object" );
2039 
2040  if( sFilterService.isEmpty() )
2041  return;
2042 
2043  Reference < XDocumentHandler > xHdl =
2045 
2046  Sequence < Any > aArgs( 1 );
2047  aArgs[0] <<= xHdl;
2048 
2049  Reference< document::XExporter > xExporter(
2050  m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(sFilterService, aArgs, m_xContext),
2051  UNO_QUERY);
2052  SAL_WARN_IF( !xExporter.is(), "xmloff.core", "can't instantiate export filter component for own object" );
2053  if( !xExporter.is() )
2054  return;
2055 
2056  xExporter->setSourceDocument( rComp );
2057 
2058  Reference<XFilter> xFilter( xExporter, UNO_QUERY );
2059 
2060  Sequence < PropertyValue > aMediaDesc( 0 );
2061  xFilter->filter( aMediaDesc );
2062 }
2063 
2064 OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
2065 {
2066  OUString sValue( rValue );
2067  // #i65474# handling of fragment URLs ("#...") is undefined
2068  // they are stored 'as is'
2069  uno::Reference< uri::XUriReference > xUriRef;
2070  if(!sValue.isEmpty() && sValue[0] != '#')
2071  {
2072  try
2073  {
2074  xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
2075  if( xUriRef.is() && !xUriRef->isAbsolute() )
2076  {
2077  //#i61943# relative URLs need special handling
2078  INetURLObject aTemp( mpImpl->msPackageURI );
2079  bool bWasAbsolute = false;
2080  sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
2081  }
2082  }
2083  catch(const uno::Exception&)
2084  {
2085  }
2086  }
2087  if( xUriRef.is() )//no conversion for empty values or for fragments
2088  {
2089  //conversion for matching schemes only
2090  if( xUriRef->getScheme() == mpImpl->msPackageURIScheme )
2091  {
2092  sValue = INetURLObject::GetRelURL( msOrigFileName, sValue );
2093  }
2094  }
2095  return sValue;
2096 }
2097 
2098 void SvXMLExport::StartElement(sal_uInt16 nPrefix,
2100  bool bIgnWSOutside )
2101 {
2102  StartElement(GetNamespaceMap_().GetQNameByKey( nPrefix,
2103  GetXMLToken(eName) ), bIgnWSOutside);
2104 }
2105 
2106 void SvXMLExport::StartElement(const OUString& rName,
2107  bool bIgnWSOutside )
2108 {
2109  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) != SvXMLErrorFlags::DO_NOTHING)
2110  {
2111  try
2112  {
2113  if( bIgnWSOutside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY))
2114  mxHandler->ignorableWhitespace( msWS );
2115  mxHandler->startElement( rName, GetXAttrList() );
2116  }
2117  catch (const SAXInvalidCharacterException& e)
2118  {
2119  Sequence<OUString> aPars { rName };
2120  SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2121  }
2122  catch (const SAXException& e)
2123  {
2124  Sequence<OUString> aPars { rName };
2126  aPars, e.Message, nullptr );
2127  }
2128  }
2129  ClearAttrList();
2130  ++mpImpl->mDepth; // increment nesting depth counter
2131 }
2132 
2133 void SvXMLExport::Characters(const OUString& rChars)
2134 {
2135  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2136  return;
2137 
2138  try
2139  {
2140  mxHandler->characters(rChars);
2141  }
2142  catch (const SAXInvalidCharacterException& e)
2143  {
2144  Sequence<OUString> aPars { rChars };
2145  SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2146  }
2147  catch (const SAXException& e)
2148  {
2149  Sequence<OUString> aPars { rChars };
2151  aPars, e.Message, nullptr );
2152  }
2153 }
2154 
2155 void SvXMLExport::EndElement(sal_uInt16 nPrefix,
2157  bool bIgnWSInside )
2158 {
2159  EndElement(GetNamespaceMap_().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
2160  bIgnWSInside);
2161 }
2162 
2163 void SvXMLExport::EndElement(const OUString& rName,
2164  bool bIgnWSInside )
2165 {
2166  // decrement nesting depth counter & (maybe) restore namespace map
2167  --mpImpl->mDepth;
2168  if (!mpImpl->mNamespaceMaps.empty() &&
2169  (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
2170  {
2171  mpNamespaceMap = std::move(mpImpl->mNamespaceMaps.top().first);
2172  mpImpl->mNamespaceMaps.pop();
2173  }
2174  SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() &&
2175  (mpImpl->mNamespaceMaps.top().second >= mpImpl->mDepth), "xmloff.core", "SvXMLExport: NamespaceMaps corrupted");
2176 
2177  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2178  return;
2179 
2180  try
2181  {
2182  if( bIgnWSInside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY))
2183  mxHandler->ignorableWhitespace( msWS );
2184  mxHandler->endElement( rName );
2185  }
2186  catch (const SAXException& e)
2187  {
2188  Sequence<OUString> aPars { rName };
2190  aPars, e.Message, nullptr );
2191  }
2192 }
2193 
2195 {
2196  if ((mnExportFlags & SvXMLExportFlags::PRETTY) != SvXMLExportFlags::PRETTY)
2197  return;
2198 
2199  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2200  return;
2201 
2202  try
2203  {
2204  mxHandler->ignorableWhitespace( msWS );
2205  }
2206  catch (const SAXException& e)
2207  {
2209  {}, e.Message, nullptr );
2210  }
2211 }
2212 
2214  sal_Int32 nId,
2215  const Sequence<OUString>& rMsgParams,
2216  const OUString& rExceptionMessage,
2217  const Reference<XLocator>& rLocator )
2218 {
2219  // allow multi-threaded access to the cancel() method
2220  static std::mutex aMutex;
2221  std::scoped_lock aGuard(aMutex);
2222 
2223  // maintain error flags
2224  if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
2226  if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
2228  if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
2230 
2231  // create error list on demand
2232  if ( mpXMLErrors == nullptr )
2233  mpXMLErrors.reset( new XMLErrors() );
2234 
2235  // save error information
2236  mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
2237 }
2238 
2240  sal_Int32 nId,
2241  const Sequence<OUString>& rMsgParams)
2242 {
2243  SetError( nId, rMsgParams, "", nullptr );
2244 }
2245 
2247 {
2248  mxModel.clear();
2249  // Shapes in Writer cannot be named via context menu (#i51726#)
2251  mxEventListener.clear();
2252 }
2253 
2254 
2256 {
2257  return mpImpl->maInterfaceToIdentifierMapper;
2258 }
2259 
2260 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
2262 {
2263  return mpImpl->mbOutlineStyleAsNormalListStyle;
2264 }
2265 
2266 uno::Reference< embed::XStorage > const & SvXMLExport::GetTargetStorage() const
2267 {
2268  return mpImpl->mxTargetStorage;
2269 }
2270 
2272 {
2273  if (mpImpl->m_oOverrideODFVersion)
2274  {
2275  return *mpImpl->m_oOverrideODFVersion;
2276  }
2277  return GetODFSaneDefaultVersion();
2278 }
2279 
2280 void
2282  sal_uInt16 const nLegacyPrefix, OUString const& rValue)
2283 {
2284  switch (getSaneDefaultVersion()) {
2285  case SvtSaveOptions::ODFSVER_011: // fall through
2286  case SvtSaveOptions::ODFSVER_010: break;
2287  default: // ODF 1.2: xml:id
2289  }
2290  // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
2291  // backward compatibility: in ODF 1.2 write _both_ id attrs
2292  AddAttribute(nLegacyPrefix, XML_ID, rValue);
2293  // FIXME: this function simply assumes that rValue is unique
2294 }
2295 
2296 void
2297 SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
2298 {
2299  // check version >= 1.2
2300  switch (getSaneDefaultVersion()) {
2301  case SvtSaveOptions::ODFSVER_011: // fall through
2302  case SvtSaveOptions::ODFSVER_010: return;
2303  default: break;
2304  }
2305  const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2306  uno::UNO_QUERY);
2307 //FIXME not yet...
2308  if ( !xMeta.is() )
2309  return;
2310 
2311  const beans::StringPair mdref( xMeta->getMetadataReference() );
2312  if ( mdref.Second.isEmpty() )
2313  return;
2314 
2315  const OUString streamName = mpImpl->mStreamName;
2316  if ( !streamName.isEmpty() )
2317  {
2318  if ( streamName == mdref.First )
2319  {
2320  AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2321  }
2322  else
2323  {
2324  SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name");
2325  }
2326  }
2327  else
2328  {
2329  // FIXME: this is ugly
2330  // there is no stream name (e.g. XSLT, flat-xml format)!
2331  // but how do we ensure uniqueness in this case?
2332  // a) just omit styles.xml ids -- they are unlikely anyway...
2333  // b) somehow find out whether we are currently exporting styles
2334  // or content, and prefix "s" or "c" => unique
2335  if ( mdref.First == "content.xml" )
2336  {
2337  AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2338  }
2339  else
2340  {
2341  SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id");
2342  }
2343  }
2344 }
2345 
2346 void
2348  uno::Reference<text::XTextContent> const & i_xTextContent)
2349 {
2350  // check version >= 1.2
2351  switch (getSaneDefaultVersion()) {
2352  case SvtSaveOptions::ODFSVER_011: // fall through
2353  case SvtSaveOptions::ODFSVER_010: return;
2354  default: break;
2355  }
2356 
2357  const uno::Reference<rdf::XMetadatable> xMeta(
2358  i_xTextContent, uno::UNO_QUERY);
2359  if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty())
2360  {
2361  return; // no xml:id => no RDFa
2362  }
2363 
2364  if (!mpImpl->mpRDFaHelper)
2365  {
2366  mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
2367  }
2368  mpImpl->mpRDFaHelper->AddRDFa(xMeta);
2369 }
2370 
2372 {
2373  return mpImpl->mbExportTextNumberElement;
2374 }
2375 
2377 {
2378  // if the null date has already been set, don't set it again (performance)
2379  if (!mpImpl->mbNullDateInitialized)
2380  mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel());
2381 
2382  return mpImpl->mbNullDateInitialized;
2383 }
2384 
2385 OUString const & SvXMLExport::GetImageFilterName() const
2386 {
2387  return msImgFilterName;
2388 }
2389 
2391  const sal_uInt16 nPrefixKey,
2392  const OUString& rLName,
2393  const bool bIgnoreWhitespaceOutside )
2394 {
2395  maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
2396  mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside);
2397 }
2398 
2400  SvXMLExport& rExp,
2401  sal_uInt16 nPrefixKey,
2402  const char *pLName,
2403  bool bIWSOutside,
2404  bool bIWSInside )
2405  : mrExport( rExp )
2406  , mbIgnoreWhitespaceInside( bIWSInside )
2407  , mbDoSomething( true )
2408 {
2409  const OUString sLName( OUString::createFromAscii( pLName ) );
2410  StartElement( nPrefixKey, sLName, bIWSOutside );
2411 }
2412 
2414  SvXMLExport& rExp,
2415  sal_uInt16 nPrefixKey,
2416  const OUString& rLName,
2417  bool bIWSOutside,
2418  bool bIWSInside )
2419  : mrExport( rExp )
2420  , mbIgnoreWhitespaceInside( bIWSInside )
2421  , mbDoSomething( true )
2422 {
2423  StartElement( nPrefixKey, rLName, bIWSOutside );
2424 }
2425 
2427  SvXMLExport& rExp,
2428  sal_uInt16 nPrefixKey,
2429  enum XMLTokenEnum eLName,
2430  bool bIWSOutside,
2431  bool bIWSInside )
2432  : mrExport( rExp )
2433  , mbIgnoreWhitespaceInside( bIWSInside )
2434  , mbDoSomething( true )
2435 {
2436  StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2437 }
2438 
2440  SvXMLExport& rExp,
2441  bool bDoSth,
2442  sal_uInt16 nPrefixKey,
2443  enum XMLTokenEnum eLName,
2444  bool bIWSOutside,
2445  bool bIWSInside )
2446  : mrExport( rExp )
2447  , mbIgnoreWhitespaceInside( bIWSInside )
2448  , mbDoSomething( bDoSth )
2449 {
2450  if ( mbDoSomething )
2451  StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside );
2452 }
2453 
2455  SvXMLExport& rExp,
2456  const OUString& rQName,
2457  bool bIWSOutside,
2458  bool bIWSInside )
2459  : mrExport( rExp )
2460  , mbIgnoreWhitespaceInside( bIWSInside )
2461  , mbDoSomething( true )
2462 {
2463  maElementName = rQName;
2464  rExp.StartElement( rQName, bIWSOutside );
2465 }
2466 
2468 {
2469  if ( mbDoSomething )
2470  {
2472  }
2473 }
2474 
2475 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
css::uno::Reference< css::embed::XStorage > const & GetTargetStorage() const
Definition: xmlexp.cxx:2266
constexpr sal_uInt16 XML_NAMESPACE_MATH
SvXMLExportFlags mnExportFlags
Definition: xmlexp.hxx:159
sal_uInt16 GetKeyByPrefix(const OUString &rPrefix) const
virtual OUString SAL_CALL getImplementationName() final override
Definition: xmlexp.cxx:850
URL aURL
FieldUnit
OUString sMessage
OUString maElementName
Definition: xmlexp.hxx:639
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
Definition: DashStyle.cxx:187
constexpr OUStringLiteral XML_EMBEDDEDOBJECT_URL_BASE
Definition: xmlexp.cxx:122
#define XML_WRITTENNUMBERSTYLES
Definition: xmlnumfe.hxx:35
constexpr sal_uInt16 XML_NAMESPACE_XFORMS
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_DR3D
char const * GetODFVersionAttributeValue() const
returns value of ODF version attribute
Definition: xmlexp.cxx:1197
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlexp.cxx:2255
constexpr OUStringLiteral XML_EXPORT_FILTER_IMPRESS
constexpr sal_uInt16 XML_NAMESPACE_DRAW_EXT
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:82
::std::unique_ptr< ::xmloff::RDFaExportHelper > mpRDFaHelper
Definition: xmlexp.cxx:260
virtual void DisposingModel()
Definition: xmlexp.cxx:2246
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
virtual void exportAutoDataStyles()
Definition: xmlexp.cxx:1813
OUString msPackageURI
Definition: xmlexp.cxx:239
constexpr sal_uInt16 XML_NAMESPACE_OOOC
void addChaffWhenEncryptedStorage()
Definition: xmlexp.cxx:1187
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:396
static EFactory ClassifyFactoryByModel(const css::uno::Reference< css::frame::XModel > &xModel)
long Long
void CheckAttrList()
Definition: xmlexp.cxx:1014
constexpr sal_uInt16 XML_NAMESPACE_FORMX
SvXMLExportFlags
Definition: xmlexp.hxx:91
constexpr OUStringLiteral XML_MODEL_SERVICE_CALC
Definition: xmlexp.cxx:113
css::uno::Reference< css::beans::XPropertySet > mxExportInfo
Definition: xmlexp.hxx:131
The XMLErrors is used to collect all errors and warnings that occur for appropriate processing...
Definition: xmlerror.hxx:102
virtual SvXMLAutoStylePoolP * CreateAutoStylePool()
Definition: xmlexp.cxx:1683
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlexp.cxx:571
sal_Int64 n
const OUString & getBcp47(bool bResolveSystem=true) const
void AddAttributesRDFa(css::uno::Reference< css::text::XTextContent > const &i_xTextContent)
add RDFa attributes for a metadatable text content
Definition: xmlexp.cxx:2347
OUString EnsureNamespace(OUString const &i_rNamespace)
ensures that the given namespace is in scope at the next started element.
Definition: xmlexp.cxx:866
css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler
Definition: xmlexp.hxx:128
bool exportTextNumberElement() const
Definition: xmlexp.cxx:2371
SvXMLExport & mrExport
Definition: xmlexp.hxx:638
OUString getScript() const
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr OUStringLiteral XML_MODEL_SERVICE_CHART
Definition: xmlexp.cxx:117
constexpr OUStringLiteral XML_EXPORT_FILTER_CHART
constexpr sal_uInt16 XML_NAMESPACE_OOO
css::uno::Reference< css::frame::XModel2 > mxModel
virtual XMLTextParagraphExport * CreateTextParagraphExport()
Definition: xmlexp.cxx:1673
virtual css::uno::Reference< css::uno::XComponentContext > GetComponentContext() const =0
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
OUString msPackageURIScheme
Definition: xmlexp.cxx:240
static OUString GetRelURL(OUString const &rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
void GetViewSettingsAndViews(css::uno::Sequence< css::beans::PropertyValue > &rProps)
Definition: xmlexp.cxx:1712
constexpr OUStringLiteral XML_MODEL_SERVICE_WRITER
Definition: xmlexp.cxx:112
bool AddEmbeddedObjectAsBase64(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1912
constexpr sal_uInt16 XML_NAMESPACE_CSS3TEXT
std::unique_ptr< SvXMLNamespaceMap > mpNamespaceMap
Definition: xmlexp.hxx:139
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OString makeXMLChaff()
OUString msFilterName
Definition: xmlexp.hxx:137
css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver
Definition: xmlexp.hxx:129
constexpr sal_uInt16 XML_NAMESPACE_NUMBER
virtual ErrCode exportDoc(enum::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID)
Definition: xmlexp.cxx:1216
constexpr sal_uInt16 XML_NAMESPACE_DOM
void SAL_DLLPRIVATE AddAttributeIdLegacy(sal_uInt16 const nLegacyPrefix, OUString const &rValue)
add xml:id and legacy namespace id
Definition: xmlexp.cxx:2281
void getIsoLanguageScriptCountry(OUString &rLanguage, OUString &rScript, OUString &rCountry) const
virtual void ExportStyles_(bool bUsed)
Override this method to export the content of .
Definition: xmlexp.cxx:1489
SAL_DLLPRIVATE void ImplExportAutoStyles()
Definition: xmlexp.cxx:1100
SAL_DLLPRIVATE void DetermineModelType_()
Definition: xmlexp.cxx:398
NONE
#define XMLERROR_API
Definition: xmlerror.hxx:71
constexpr sal_uInt16 XML_NAMESPACE_CALC_EXT
const sal_uInt16 XML_NAMESPACE_UNKNOWN
uno::Reference< embed::XStorage > mxTargetStorage
Definition: xmlexp.cxx:244
constexpr sal_uInt16 XML_NAMESPACE_XSI
virtual void SetBodyAttributes()
Definition: xmlexp.cxx:1163
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlexp.hxx:416
rtl::Reference< xmloff::OFormLayerXMLExport > mxFormExport
Definition: xmlexp.hxx:151
virtual void SAL_CALL cancel() override
Definition: xmlexp.cxx:832
virtual void exportAnnotationMeta(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: xmlexp.cxx:1830
virtual void EndElement(const bool i_bIgnoreWhitespace)=0
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlexp.cxx:1943
SchXMLExportHelper * CreateChartExport()
Definition: xmlexp.cxx:1697
#define XML_PROGRESSRANGE
OUString getLanguage() const
Any SAL_CALL getCaughtException()
bool mbNullDateInitialized
Definition: xmlexp.cxx:263
std::optional< SvtSaveOptions::ODFSaneDefaultVersion > m_oOverrideODFVersion
Definition: xmlexp.cxx:246
void AddLanguageTagAttributes(sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc, const css::lang::Locale &rLocale, bool bWriteEmpty)
Add language tag attributes, deciding which are necessary.
Definition: xmlexp.cxx:943
xmloff::OFormLayerXMLExport * CreateFormExport()
Definition: xmlexp.cxx:1707
TStyleElements m_aElements
int nCount
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:909
virtual void GetViewSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1757
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::xml::sax::XAttributeList > GetXAttrList() const
Definition: xmlexp.hxx:380
const bool mbIgnoreWhitespaceInside
Definition: xmlexp.hxx:640
constexpr sal_uInt16 XML_NAMESPACE_FORM
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
Definition: xmlexp.hxx:130
Mutex aMutex
void StartElement(sal_uInt16 nPrefix, enum::xmloff::token::XMLTokenEnum eName, bool bIgnWSOutside)
Definition: xmlexp.cxx:2098
enum::xmloff::token::XMLTokenEnum meClass
Definition: xmlexp.hxx:156
constexpr OUStringLiteral XML_EXPORT_FILTER_MATH
static OUString GetGeneratorString()
OUString GetRelativeReference(const OUString &rValue)
Definition: xmlexp.cxx:2064
virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat=false) const
Definition: xmlexp.cxx:1822
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlexp.cxx:650
constexpr sal_uInt16 XML_NAMESPACE_DRAW
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
Definition: xmlexp.cxx:1840
#define XML_PROGRESSMAX
const char * sName
static void lcl_AddGrddl(SvXMLExport const &rExport, const SvXMLExportFlags)
Definition: xmlexp.cxx:1168
#define XMLERROR_FLAG_WARNING
Definition: xmlerror.hxx:35
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Record an error condition that occurred during export.
void SetSchemeOf(const OUString &rOrigFileName)
Definition: xmlexp.cxx:265
std::unique_ptr< SvXMLNumFmtExport > mpNumExport
Definition: xmlexp.hxx:142
XMLOFF_DLLPUBLIC void exportXML(OUString const &rStrName, css::uno::Any const &rValue, SvXMLExport &rExport)
constexpr OUStringLiteral XML_EXPORT_FILTER_CALC
OUString const & GetDestinationShellID() const
Definition: xmlexp.cxx:1418
rtl::Reference< XMLFontAutoStylePool > mxFontAutoStylePool
Definition: xmlexp.hxx:150
std::unique_ptr< ProgressBarHelper > mpProgressBarHelper
Definition: xmlexp.hxx:143
virtual OUString SAL_CALL getName() override
Definition: xmlexp.cxx:839
constexpr sal_uInt16 XML_NAMESPACE_CONFIG
SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
bool GetGraphicMimeTypeFromStream(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType)
Definition: xmlexp.cxx:1862
constexpr sal_uInt16 XML_NAMESPACE_XML
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2271
OUString sPrefix
UNO3_GETIMPLEMENTATION_IMPL(SvXMLExport)
bool SetNullDateOnUnitConverter()
set null date from model to unit converter, if not already done
Definition: xmlexp.cxx:2376
SAL_DLLPRIVATE void ImplExportSettings()
Definition: xmlexp.cxx:1027
constexpr sal_uInt16 XML_NAMESPACE_SVG
SvXMLExport(const css::uno::Reference< css::uno::XComponentContext > &xContext, OUString const &implementationName, sal_Int16 const eDefaultMeasureUnit, const enum::xmloff::token::XMLTokenEnum eClass, SvXMLExportFlags nExportFlag)
constexpr sal_uInt16 XML_NAMESPACE_TABLE_EXT
SAL_DLLPRIVATE void ImplExportStyles()
Definition: xmlexp.cxx:1070
virtual void Characters(const OUString &i_rCharacters)=0
constexpr sal_uInt16 XML_NAMESPACE_FO
int i
constexpr OUStringLiteral XML_MODEL_SERVICE_DRAW
Definition: xmlexp.cxx:114
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
Definition: xmlexp.cxx:1991
constexpr sal_uInt16 XML_NAMESPACE_TEXT
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) final override
Definition: xmlexp.cxx:855
RequestPriorityClass meClass
css::uno::Reference< css::xml::sax::XDocumentHandler > mxHandler
Definition: xmlexp.hxx:125
const OUString msWS
Definition: xmlexp.hxx:162
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
export meta data from an XDocumentProperties instance.
Definition: xmlmetae.hxx:49
OUString m_implementationName
Definition: xmlexp.hxx:122
tools::Long mDepth
counts depth (number of open elements/start tags)
Definition: xmlexp.cxx:258
static OUString GetMimeTypeForImageStream(const css::uno::Reference< css::io::XInputStream > &xInputStream)
const std::pair< OUString, OUString > aServiceMap[]
Definition: xmlexp.cxx:124
virtual XMLPageExport * CreatePageExport()
Definition: xmlexp.cxx:1692
float u
unsigned char sal_Bool
virtual XMLFontAutoStylePool * CreateFontAutoStylePool()
Definition: xmlexp.cxx:1702
Object Value
std::unique_ptr< SvXMLExport_Impl > mpImpl
Definition: xmlexp.hxx:119
bool setNullDate(const css::uno::Reference< css::frame::XModel > &xModel)
get the Null Date of the XModel and set it to the UnitConverter
Definition: xmluconv.cxx:352
constexpr sal_uInt16 XML_NAMESPACE_GRDDL
OUString AddEmbeddedObject(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1897
std::unique_ptr< XMLImageMapExport > mpImageMapExport
Definition: xmlexp.hxx:153
virtual void ExportContent_()=0
Override this method to export the content of .
With this class you can export a element containing its data as element o...
XMLImageMapExport & GetImageMapExport()
get the export for image maps
Definition: xmlexp.cxx:2007
constexpr sal_uInt16 XML_NAMESPACE_XHTML
constexpr sal_uInt16 XML_NAMESPACE_XSD
css::uno::Type const & get()
void exportAllSettings(const css::uno::Sequence< css::beans::PropertyValue > &aProps, const OUString &rName) const
OUString getOriginURL() const
virtual void ExportScripts_()
Override this method to export the content of .
Definition: xmlexp.cxx:1450
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
virtual ~SvXMLExport() override
Definition: xmlexp.cxx:523
constexpr sal_uInt16 XML_NAMESPACE_DC
constexpr OUStringLiteral XML_USEPRETTYPRINTING
Definition: xmlexp.cxx:119
virtual void ExportMeta_()
Override this method to export the content of .
Definition: xmlexp.cxx:1423
OUString maSrcShellID
Definition: xmlexp.cxx:251
const uno::Reference< uno::XComponentContext > m_xContext
#define XML_PROGRESSCURRENT
void SetDocHandler(const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler)
Definition: xmlexp.cxx:283
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:390
SAL_DLLPRIVATE void ImplExportContent()
Definition: xmlexp.cxx:1135
virtual void exportDataStyles()
Definition: xmlexp.cxx:1807
rtl::Reference< FragmentHandler > mxHandler
virtual void ExportAutoStyles_()=0
Override this method to export the contents of .
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
constexpr OUStringLiteral XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE
Definition: xmlexp.cxx:121
OUString maDestShellID
Definition: xmlexp.cxx:252
OUString EncodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmlexp.cxx:1936
OUString msImgFilterName
Definition: xmlexp.hxx:138
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
Definition: HatchStyle.cxx:134
SAL_DLLPRIVATE void InitCtor_()
Definition: xmlexp.cxx:289
virtual void SAL_CALL setName(const OUString &aName) override
Definition: xmlexp.cxx:844
bool isIsoODF() const
SvXMLUnitConverter maUnitConv
Definition: xmlexp.hxx:141
void IgnorableWhitespace()
Definition: xmlexp.cxx:2194
SAL_DLLPRIVATE void ImplExportMasterStyles()
Definition: xmlexp.cxx:1126
void ClearAttrList()
Definition: xmlexp.cxx:1008
#define XMLERROR_FLAG_SEVERE
Definition: xmlerror.hxx:37
virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor) override
Definition: xmlexp.cxx:755
OUString const & GetImageFilterName() const
Get clamped mimetype for image export (empty if none)
Definition: xmlexp.cxx:2385
SvtModuleOptions::EFactory meModelType
Definition: xmlexp.hxx:165
constexpr sal_uInt16 XML_NAMESPACE_TABLE
void EndElement(sal_uInt16 nPrefix, enum::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
Definition: xmlexp.cxx:2155
virtual sal_Int32 GetDocumentSpecificSettings(::std::vector< SettingsGroup > &_out_rSettings)
returns the current document settings
Definition: xmlexp.cxx:1765
std::unique_ptr< XMLErrors > mpXMLErrors
Definition: xmlexp.hxx:154
SvXMLNamespaceMap & GetNamespaceMap_()
Definition: xmlexp.hxx:183
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
SAL_DLLPRIVATE void StartElement(const sal_uInt16 nPrefix, const OUString &rName, const bool bIgnoreWhitespaceOutside)
Definition: xmlexp.cxx:2390
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3454
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:578
virtual XMLShapeExport * CreateShapeExport()
Definition: xmlexp.cxx:1678
constexpr sal_uInt16 XML_NAMESPACE_REPORT
#define XML_PROGRESSREPEAT
Handling of tokens in XML:
OUString const & GetSourceShellID() const
Definition: xmlexp.cxx:1413
#define SAL_INFO(area, stream)
void Characters(const OUString &rChars)
Definition: xmlexp.cxx:2133
rtl::Reference< SvXMLAutoStylePoolP > mxAutoStylePool
Definition: xmlexp.hxx:147
#define XMLERROR_FLAG_ERROR
Definition: xmlerror.hxx:36
bool mbOutlineStyleAsNormalListStyle
Definition: xmlexp.cxx:242
provides functionality for exporting a complete form layer.
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
css::uno::Reference< css::lang::XEventListener > mxEventListener
Definition: xmlexp.hxx:132
void ResetNamespaceMap()
Definition: xmlexp.cxx:1408
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
constexpr OUStringLiteral XML_MODEL_SERVICE_MATH
Definition: xmlexp.cxx:116
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlexp.hxx:124
uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory
Definition: xmlexp.cxx:238
Export instances of EventsSupplier services.
Reference< XComponentContext > getProcessComponentContext()
const char * name
constexpr OUStringLiteral XML_EXPORT_FILTER_WRITER
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
constexpr sal_uInt16 XML_NAMESPACE_OF
constexpr OUStringLiteral XML_MODEL_SERVICE_IMPRESS
Definition: xmlexp.cxx:115
virtual void ExportMasterStyles_()=0
Override this method to export the contents of .
sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const
Definition: xmlexp.cxx:1834
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1761
#define XMLERROR_CANCEL
Definition: xmlerror.hxx:74
OUString encodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmluconv.cxx:866
SvXMLErrorFlags mnErrorFlags
Definition: xmlexp.hxx:160
virtual void AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName, const OUString &i_rValue)=0
bool AddEmbeddedXGraphicAsBase64(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic)
Definition: xmlexp.cxx:1877
#define SAL_WARN(area, stream)
void AddAttributeList(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
Definition: xmlexp.cxx:1002
Reference< XSingleServiceFactory > xFactory
css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier
Definition: xmlexp.hxx:127
css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > mxExtHandler
Definition: xmlexp.hxx:126
void collectDataStyles(bool bFromUsedStyles)
Definition: xmlexp.cxx:1770
bool mbExportTextNumberElement
Definition: xmlexp.cxx:262
Reference< XPropertySet > PropertySetMerger_CreateInstance(const Reference< XPropertySet > &rPropSet1, const Reference< XPropertySet > &rPropSet2) noexcept
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper
Definition: xmlexp.cxx:237
SvXMLElementExport(SvXMLExport &rExp, sal_uInt16 nPrefix, const char *pName, bool bIgnWSOutside, bool bIgnWSInside)
Definition: xmlexp.cxx:2399
#define XMLERROR_SAX
Definition: xmlerror.hxx:52
void AddAttributeXmlId(css::uno::Reference< css::uno::XInterface > const &i_xIfc)
add xml:id attribute (for RDF metadata)
Definition: xmlexp.cxx:2297
constexpr sal_uInt16 XML_NAMESPACE_META
const XMLEventNameTranslation aStandardEventTable[]
a translation table for the events defined in the XEventsSupplier service (implemented in XMLEventExp...
css::uno::Reference< css::uno::XCurrentContext > NewFlagContext(const OUString &sName)
::std::stack< ::std::pair< std::unique_ptr< SvXMLNamespaceMap >, tools::Long > > mNamespaceMaps
stack of backed up namespace maps long: depth at which namespace map has been backed up into the stac...
Definition: xmlexp.cxx:256
OUString mStreamName
name of stream in package, e.g., "content.xml"
Definition: xmlexp.cxx:249
virtual void StartElement(enum::xmloff::token::XMLTokenEnum i_eName)=0
bool exportOfficeBinaryDataElement(const css::uno::Reference< css::io::XInputStream > &rIn)
SAL_DLLPRIVATE void ImplExportMeta()
Definition: xmlexp.cxx:1020
Export an ImageMap as defined by service com.sun.star.image.ImageMap to XML.
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
constexpr OUStringLiteral XML_EXPORT_FILTER_DRAW
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
Definition: xmlexp.cxx:1801
constexpr sal_uInt16 XML_NAMESPACE_OOOW
bool hasScript() const
const OUString & GetPrefixByKey(sal_uInt16 nKey) const
SvXMLExportFlags getExportFlags() const
Definition: xmlexp.hxx:478
std::unique_ptr< XMLEventExport > mpEventExport
Definition: xmlexp.hxx:152
virtual void ExportFontDecls_()
Override this method to export the font declarations The default implementation will export the conte...
Definition: xmlexp.cxx:1483
constexpr sal_uInt16 XML_NAMESPACE_STYLE
bool writeOutlineStyleAsNormalListStyle() const
Definition: xmlexp.cxx:2261
sal_uInt16 nPos
void overrideSaneDefaultVersion(SvtSaveOptions::ODFSaneDefaultVersion const)
Definition: xmluconv.cxx:128
void ExportEmbeddedOwnObject(css::uno::Reference< css::lang::XComponent > const &rComp)
Definition: xmlexp.cxx:2021
SvXMLErrorFlags
Definition: xmlerror.hxx:78
bool any2bool(const css::uno::Any &rAny)
bool isSystemLocale() const
const bool mbDoSomething
Definition: xmlexp.hxx:641
OUString getCountry() const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() final override
Definition: xmlexp.cxx:860
rtl::Reference< SvXMLAttributeList > mxAttrList
Definition: xmlexp.hxx:134
exports com.sun.star. uri
constexpr sal_uInt16 XML_NAMESPACE_FIELD
virtual void collectAutoStyles()
Definition: xmlexp.cxx:1688
void Export(css::uno::Reference< css::document::XEventsSupplier > const &xAccess, bool bUseWhitespace=true)
export the events (calls EventExport::Export(Reference) )
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: xmlexp.hxx:121
OUString msOrigFileName
Definition: xmlexp.hxx:136
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)