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