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 <config_wasm_strip.h>
21 
22 #include <memory>
23 #include <sal/config.h>
24 #include <sal/log.hxx>
25 
26 #include <mutex>
27 #include <stack>
28 #include <optional>
29 #include <utility>
30 
32 #include <tools/urlobj.hxx>
33 #include <vcl/graph.hxx>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/io/XInputStream.hpp>
37 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
38 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
39 #include <com/sun/star/text/XTextContent.hpp>
40 #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
41 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
42 #include <com/sun/star/uri/UriReferenceFactory.hpp>
43 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
44 #include <com/sun/star/util/MeasureUnit.hpp>
49 #include <xmloff/attrlist.hxx>
50 #include <xmloff/namespacemap.hxx>
51 #include <xmloff/xmluconv.hxx>
52 #include <xmloff/xmlnamespace.hxx>
53 #include <xmloff/xmltoken.hxx>
54 #include <xmloff/xmlexp.hxx>
55 #include <xmloff/xmlnumfe.hxx>
56 #include <xmloff/xmlmetae.hxx>
63 #include <com/sun/star/document/XEventsSupplier.hpp>
64 #include <com/sun/star/document/XViewDataSupplier.hpp>
65 #include <com/sun/star/frame/XModel.hpp>
66 #include <com/sun/star/frame/XModule.hpp>
67 #include <xmloff/GradientStyle.hxx>
68 #include <xmloff/HatchStyle.hxx>
69 #include <xmloff/ImageStyle.hxx>
70 #include <TransGradientStyle.hxx>
71 #include <xmloff/MarkerStyle.hxx>
72 #include <xmloff/DashStyle.hxx>
74 #include <XMLImageMapExport.hxx>
75 #include <XMLBase64Export.hxx>
76 #include <xmloff/xmlerror.hxx>
77 #include <com/sun/star/style/XStyle.hpp>
78 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
79 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
80 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
81 #include <com/sun/star/beans/PropertyAttribute.hpp>
84 #include <XMLBasicExportFilter.hxx>
85 #include <cppuhelper/exc_hlp.hxx>
86 #include <cppuhelper/implbase.hxx>
88 #include <comphelper/extract.hxx>
90 #include <PropertySetMerger.hxx>
91 
93 #include <com/sun/star/document/XDocumentProperties.hpp>
94 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
95 #include <com/sun/star/document/XMLOasisBasicExporter.hpp>
96 #include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
97 #include <com/sun/star/document/XGraphicStorageHandler.hpp>
98 #include <com/sun/star/rdf/XMetadatable.hpp>
99 #include <RDFaExportHelper.hxx>
100 
101 #include <comphelper/xmltools.hxx>
103 
104 using namespace ::com::sun::star;
105 using namespace ::com::sun::star::uno;
106 using namespace ::com::sun::star::frame;
107 using namespace ::com::sun::star::container;
108 using namespace ::com::sun::star::lang;
109 using namespace ::com::sun::star::document;
110 using namespace ::com::sun::star::beans;
111 using namespace ::com::sun::star::xml::sax;
112 using namespace ::com::sun::star::io;
113 using namespace ::xmloff::token;
114 
115 constexpr OUStringLiteral XML_MODEL_SERVICE_WRITER = u"com.sun.star.text.TextDocument";
116 constexpr OUStringLiteral XML_MODEL_SERVICE_CALC = u"com.sun.star.sheet.SpreadsheetDocument";
117 constexpr OUStringLiteral XML_MODEL_SERVICE_DRAW = u"com.sun.star.drawing.DrawingDocument";
118 constexpr OUStringLiteral XML_MODEL_SERVICE_IMPRESS = u"com.sun.star.presentation.PresentationDocument";
119 constexpr OUStringLiteral XML_MODEL_SERVICE_MATH = u"com.sun.star.formula.FormulaProperties";
120 constexpr OUStringLiteral XML_MODEL_SERVICE_CHART = u"com.sun.star.chart.ChartDocument";
121 
122 constexpr OUStringLiteral XML_USEPRETTYPRINTING = u"UsePrettyPrinting";
123 
124 constexpr OUStringLiteral XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE = u"vnd.sun.star.GraphicObject:";
125 constexpr OUStringLiteral XML_EMBEDDEDOBJECT_URL_BASE = u"vnd.sun.star.EmbeddedObject:";
126 
127 const std::pair<OUString, OUString> aServiceMap[] = {
130  { XML_MODEL_SERVICE_IMPRESS, XML_EXPORT_FILTER_IMPRESS }, // Impress supports DrawingDocument,
131  { XML_MODEL_SERVICE_DRAW, XML_EXPORT_FILTER_DRAW }, // too, so it must appear before Draw
134 };
135 
136 namespace {
137 
138 class SettingsExportFacade : public ::xmloff::XMLSettingsExportContext
139 {
140 public:
141  explicit SettingsExportFacade( SvXMLExport& i_rExport )
142  :m_rExport( i_rExport )
143  {
144  }
145 
146  virtual ~SettingsExportFacade()
147  {
148  }
149 
150  virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
151  const OUString& i_rValue ) override;
152  virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
153  enum ::xmloff::token::XMLTokenEnum i_eValue ) override;
154 
155  virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName ) override;
156  virtual void EndElement( const bool i_bIgnoreWhitespace ) override;
157 
158  virtual void Characters( const OUString& i_rCharacters ) override;
159 
160  virtual css::uno::Reference< css::uno::XComponentContext >
161  GetComponentContext() const override;
162 private:
163  SvXMLExport& m_rExport;
164  ::std::stack< OUString > m_aElements;
165 };
166 
167 }
168 
169 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const OUString& i_rValue )
170 {
171  m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_rValue );
172 }
173 
174 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue )
175 {
176  m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_eValue );
177 }
178 
179 void SettingsExportFacade::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName )
180 {
181  const OUString sElementName( m_rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_CONFIG, GetXMLToken( i_eName ) ) );
182  m_rExport.StartElement( sElementName, true/*i_bIgnoreWhitespace*/ );
183  m_aElements.push( sElementName );
184 }
185 
186 void SettingsExportFacade::EndElement( const bool i_bIgnoreWhitespace )
187 {
188  const OUString sElementName( m_aElements.top() );
189  m_rExport.EndElement( sElementName, i_bIgnoreWhitespace );
190  m_aElements.pop();
191 }
192 
193 void SettingsExportFacade::Characters( const OUString& i_rCharacters )
194 {
195  m_rExport.GetDocHandler()->characters( i_rCharacters );
196 }
197 
198 Reference< XComponentContext > SettingsExportFacade::GetComponentContext() const
199 {
200  return m_rExport.getComponentContext();
201 }
202 
203 namespace {
204 
205 class SvXMLExportEventListener : public cppu::WeakImplHelper<
206  css::lang::XEventListener >
207 {
208 private:
209  SvXMLExport* pExport;
210 
211 public:
212  explicit SvXMLExportEventListener(SvXMLExport* pExport);
213 
214  // XEventListener
215  virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) override;
216 };
217 
218 }
219 
220 SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport)
221  : pExport(pTempExport)
222 {
223 }
224 
225 // XEventListener
226 void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& )
227 {
228  if (pExport)
229  {
230  pExport->DisposingModel();
231  pExport = nullptr;
232  }
233 }
234 
236 {
237 public:
239 
241  uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory;
242  OUString msPackageURI;
244  // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
246 
247  uno::Reference< embed::XStorage > mxTargetStorage;
248 
249  std::optional<SvtSaveOptions::ODFSaneDefaultVersion> m_oOverrideODFVersion;
250 
252  OUString mStreamName;
253 
254  OUString maSrcShellID;
255  OUString maDestShellID;
256 
259  ::std::stack< ::std::pair< std::unique_ptr<SvXMLNamespaceMap>, tools::Long > > mNamespaceMaps;
262 
263  ::std::unique_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper;
264 
267 
268  void SetSchemeOf( std::u16string_view rOrigFileName )
269  {
270  size_t nSep = rOrigFileName.find(':');
271  if( nSep != std::u16string_view::npos )
272  msPackageURIScheme = rOrigFileName.substr( 0, nSep );
273  }
274 };
275 
277 : mxUriReferenceFactory( uri::UriReferenceFactory::create(comphelper::getProcessComponentContext()) ),
278  // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
279  mbOutlineStyleAsNormalListStyle( false ),
280  mDepth( 0 ),
281  mbExportTextNumberElement( false ),
282  mbNullDateInitialized( false )
283 {
284 }
285 
286 void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler )
287 {
288  mxHandler = rHandler;
289  mxExtHandler.set( mxHandler, UNO_QUERY );
290 }
291 
293 {
294  // note: it is not necessary to add XML_NP_XML (it is declared implicitly)
296  {
299  }
301  {
303  }
305  {
307  }
309  {
311  }
312 
314  {
317  }
319  {
321  }
322 
323  // namespaces for documents
325  {
338 
340  {
341  mpNamespaceMap->Add(
343  mpNamespaceMap->Add(
345  mpNamespaceMap->Add(
347  mpNamespaceMap->Add(
351  }
352  }
354  {
357  }
359  {
362  }
364  {
369  }
370 
371  // RDFa: needed for content and header/footer styles
373  {
376  }
377  // GRDDL: to convert RDFa and meta.xml to RDF
379  {
382  }
383  // CSS Text Level 3 for distributed text justification.
385  {
386  mpNamespaceMap->Add(
388  }
389 
390  if (mxModel.is() && !mxEventListener.is())
391  {
392  mxEventListener.set( new SvXMLExportEventListener(this));
393  mxModel->addEventListener(mxEventListener);
394  }
395 
396  // Determine model type (#i51726#)
398 }
399 
400 // Shapes in Writer cannot be named via context menu (#i51726#)
402 {
404 
405  if ( !mxModel.is() )
406  return;
407 
409 
410  // note: MATH documents will throw NotInitializedException; maybe unit test problem
412  {
413  uno::Reference<frame::XModule> const xModule(mxModel, uno::UNO_QUERY);
414  bool const isBaseForm(xModule.is() &&
415  xModule->getIdentifier() == "com.sun.star.sdb.FormDesign");
416  if (isBaseForm)
417  {
418  switch (GetODFSaneDefaultVersion())
419  {
421  SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2");
422  mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED;
424  break;
426  SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2");
427  mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012;
429  break;
430  default:
431  break;
432  }
433  }
434  }
435 }
436 
438  const uno::Reference< uno::XComponentContext >& xContext,
439  OUString const & implementationName,
440  sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
441  const enum XMLTokenEnum eClass, SvXMLExportFlags nExportFlags )
442 : mpImpl( new SvXMLExport_Impl ),
443  m_xContext(xContext), m_implementationName(implementationName),
444  mxAttrList( new SvXMLAttributeList ),
445  mpNamespaceMap( new SvXMLNamespaceMap ),
446  mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
447  maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()),
448  meClass( eClass ),
449  mnExportFlags( nExportFlags ),
450  mnErrorFlags( SvXMLErrorFlags::NO ),
451  msWS( GetXMLToken(XML_WS) ),
452  mbSaveLinkedSections(true),
453  mbAutoStylesCollected(false)
454 {
455  SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
456  InitCtor_();
457 }
458 
460  const css::uno::Reference< css::uno::XComponentContext >& xContext,
461  OUString const & implementationName,
462  const OUString &rFileName,
463  sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
464  const uno::Reference< xml::sax::XDocumentHandler > & rHandler)
465 : mpImpl( new SvXMLExport_Impl ),
466  m_xContext(xContext), m_implementationName(implementationName),
467  mxHandler( rHandler ),
468  mxExtHandler( rHandler, uno::UNO_QUERY ),
469  mxAttrList( new SvXMLAttributeList ),
470  msOrigFileName( rFileName ),
471  mpNamespaceMap( new SvXMLNamespaceMap ),
472  mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
473  maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()),
475  mnExportFlags( SvXMLExportFlags::NONE ),
476  mnErrorFlags( SvXMLErrorFlags::NO ),
477  msWS( GetXMLToken(XML_WS) ),
478  mbSaveLinkedSections(true),
479  mbAutoStylesCollected(false)
480 {
481  SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
482  mpImpl->SetSchemeOf( msOrigFileName );
483  InitCtor_();
484 
485  if (mxNumberFormatsSupplier.is())
487 }
488 
490  const css::uno::Reference< css::uno::XComponentContext >& xContext,
491  OUString const & implementationName,
492  const OUString &rFileName,
493  const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
494  const Reference< XModel >& rModel,
495  FieldUnit const eDefaultFieldUnit,
496  SvXMLExportFlags nExportFlag)
497 : mpImpl( new SvXMLExport_Impl ),
498  m_xContext(xContext), m_implementationName(implementationName),
499  mxModel( rModel ),
500  mxHandler( rHandler ),
501  mxExtHandler( rHandler, uno::UNO_QUERY ),
502  mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
503  mxAttrList( new SvXMLAttributeList ),
504  msOrigFileName( rFileName ),
505  mpNamespaceMap( new SvXMLNamespaceMap ),
506  mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
507  maUnitConv( xContext,
508  util::MeasureUnit::MM_100TH,
509  SvXMLUnitConverter::GetMeasureUnit(eDefaultFieldUnit),
510  getSaneDefaultVersion()),
512  mnExportFlags( nExportFlag ),
513  mnErrorFlags( SvXMLErrorFlags::NO ),
514  msWS( GetXMLToken(XML_WS) ),
515  mbSaveLinkedSections(true),
516  mbAutoStylesCollected(false)
517 {
518  SAL_WARN_IF(!xContext.is(), "xmloff.core", "got no service manager" );
519  mpImpl->SetSchemeOf( msOrigFileName );
520  InitCtor_();
521 
522  if (mxNumberFormatsSupplier.is())
524 }
525 
527 {
528  mpXMLErrors.reset();
529  mpImageMapExport.reset();
530  mpEventExport.reset();
531  mpNamespaceMap.reset();
533  {
534  if (mxExportInfo.is())
535  {
536  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
537  if (xPropertySetInfo.is())
538  {
540  {
541  static constexpr OUStringLiteral sProgressMax(XML_PROGRESSMAX);
542  static constexpr OUStringLiteral sProgressCurrent(XML_PROGRESSCURRENT);
543  static constexpr OUStringLiteral sRepeat(XML_PROGRESSREPEAT);
544  if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
545  xPropertySetInfo->hasPropertyByName(sProgressCurrent))
546  {
547  sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
548  sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
549  mxExportInfo->setPropertyValue(sProgressMax, uno::Any(nProgressMax));
550  mxExportInfo->setPropertyValue(sProgressCurrent, uno::Any(nProgressCurrent));
551  }
552  if (xPropertySetInfo->hasPropertyByName(sRepeat))
553  mxExportInfo->setPropertyValue(sRepeat, css::uno::Any(mpProgressBarHelper->GetRepeat()));
554  }
556  {
557  static constexpr OUStringLiteral sWrittenNumberFormats(XML_WRITTENNUMBERSTYLES);
558  if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
559  {
560  mxExportInfo->setPropertyValue(sWrittenNumberFormats, Any(mpNumExport->GetWasUsed()));
561  }
562  }
563  }
564  }
565  mpProgressBarHelper.reset();
566  mpNumExport.reset();
567  }
568 
569  if (mxEventListener.is() && mxModel.is())
570  mxModel->removeEventListener(mxEventListener);
571 }
572 
573 // XExporter
574 void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
575 {
576  mxModel.set( xDoc, UNO_QUERY );
577  if( !mxModel.is() )
578  throw lang::IllegalArgumentException();
579  if (mxModel.is() && ! mxEventListener.is())
580  {
581  mxEventListener.set( new SvXMLExportEventListener(this));
582  mxModel->addEventListener(mxEventListener);
583  }
584 
585  if(!mxNumberFormatsSupplier.is() )
586  {
587  mxNumberFormatsSupplier.set(mxModel, css::uno::UNO_QUERY);
588  if(mxNumberFormatsSupplier.is() && mxHandler.is())
590  }
591  if (mxExportInfo.is())
592  {
593  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
594  if (xPropertySetInfo.is())
595  {
596  OUString sUsePrettyPrinting(XML_USEPRETTYPRINTING);
597  if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting))
598  {
599  uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting);
600  if (::cppu::any2bool(aAny))
602  else
604  }
605 
607  {
608  OUString sWrittenNumberFormats(XML_WRITTENNUMBERSTYLES);
609  if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
610  {
611  uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats);
612  uno::Sequence<sal_Int32> aWasUsed;
613  if(aAny >>= aWasUsed)
614  mpNumExport->SetWasUsed(aWasUsed);
615  }
616  }
617  }
618  }
619 
620  // namespaces for user defined attributes
621  Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
622  if( xFactory.is() )
623  {
624  try
625  {
626  Reference < XInterface > xIfc =
627  xFactory->createInstance("com.sun.star.xml.NamespaceMap");
628  if( xIfc.is() )
629  {
630  Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY );
631  if( xNamespaceMap.is() )
632  {
633  const Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() );
634  for( OUString const & prefix : aPrefixes )
635  {
636  OUString aURL;
637  if( xNamespaceMap->getByName( prefix ) >>= aURL )
638  GetNamespaceMap_().Add( prefix, aURL );
639  }
640  }
641  }
642  }
643  catch(const css::uno::Exception&)
644  {
645  }
646  }
647 
648  // Determine model type (#i51726#)
650 }
651 
652 // XInitialize
653 void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments )
654 {
655  // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
656 
657  for( const auto& rAny : aArguments )
658  {
659  Reference<XInterface> xValue;
660  rAny >>= xValue;
661 
662  // status indicator
663  uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
664  if ( xTmpStatus.is() )
665  mxStatusIndicator = xTmpStatus;
666 
667  // graphic storage handler
668  uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(xValue, UNO_QUERY);
669  if (xGraphicStorageHandler.is())
670  mxGraphicStorageHandler = xGraphicStorageHandler;
671 
672  // object resolver
673  uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
674  xValue, UNO_QUERY );
675  if ( xTmpObjectResolver.is() )
676  mxEmbeddedResolver = xTmpObjectResolver;
677 
678  // document handler
679  uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler(
680  xValue, UNO_QUERY );
681  if( xTmpDocHandler.is() )
682  {
683  mxHandler = xTmpDocHandler;
684  rAny >>= mxExtHandler;
685 
686  if (mxNumberFormatsSupplier.is() && mpNumExport == nullptr)
688  }
689 
690  // property set to transport data across
691  uno::Reference<beans::XPropertySet> xTmpPropertySet(
692  xValue, UNO_QUERY );
693  if( xTmpPropertySet.is() )
694  mxExportInfo = xTmpPropertySet;
695  }
696 
697  if( !mxExportInfo.is() )
698  return;
699 
700  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
701  mxExportInfo->getPropertySetInfo();
702  static constexpr OUStringLiteral sBaseURI = u"BaseURI";
703  if( xPropertySetInfo->hasPropertyByName(sBaseURI) )
704  {
705  uno::Any aAny = mxExportInfo->getPropertyValue(sBaseURI);
706  aAny >>= msOrigFileName;
707  mpImpl->msPackageURI = msOrigFileName;
708  mpImpl->SetSchemeOf( msOrigFileName );
709  }
710  OUString sRelPath;
711  static constexpr OUStringLiteral sStreamRelPath = u"StreamRelPath";
712  if( xPropertySetInfo->hasPropertyByName(sStreamRelPath) )
713  {
714  uno::Any aAny = mxExportInfo->getPropertyValue(sStreamRelPath);
715  aAny >>= sRelPath;
716  }
717  OUString sName;
718  static constexpr OUStringLiteral sStreamName = u"StreamName";
719  if( xPropertySetInfo->hasPropertyByName(sStreamName) )
720  {
721  uno::Any aAny = mxExportInfo->getPropertyValue(sStreamName);
722  aAny >>= sName;
723  }
724  if( !msOrigFileName.isEmpty() && !sName.isEmpty() )
725  {
726  INetURLObject aBaseURL( msOrigFileName );
727  if( !sRelPath.isEmpty() )
728  aBaseURL.insertName( sRelPath );
729  aBaseURL.insertName( sName );
731  }
732  mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
733 
734  // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
735  static const OUStringLiteral sOutlineStyleAsNormalListStyle(
736  u"OutlineStyleAsNormalListStyle" );
737  if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) )
738  {
739  uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle );
740  aAny >>= mpImpl->mbOutlineStyleAsNormalListStyle;
741  }
742 
743  OUString sTargetStorage( "TargetStorage" );
744  if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) )
745  mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage;
746 
747  static const OUStringLiteral sExportTextNumberElement(
748  u"ExportTextNumberElement" );
749  if( xPropertySetInfo->hasPropertyByName( sExportTextNumberElement ) )
750  {
751  uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement );
752  aAny >>= mpImpl->mbExportTextNumberElement;
753  }
754 }
755 
756 // XFilter
757 sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
758 {
759  // check for xHandler first... should have been supplied in initialize
760  if( !mxHandler.is() )
761  return false;
762 
763  try
764  {
765  const SvXMLExportFlags nTest =
767  if( (mnExportFlags & nTest) == nTest && msOrigFileName.isEmpty() )
768  {
769  // evaluate descriptor only for flat files and if a base URI
770  // has not been provided already
771 
772  for( const auto& rProp : aDescriptor )
773  {
774  const OUString& rPropName = rProp.Name;
775  const Any& rValue = rProp.Value;
776 
777  if ( rPropName == "FileName" )
778  {
779  if( !(rValue >>= msOrigFileName ) )
780  return false;
781  }
782  else if ( rPropName == "FilterName" )
783  {
784  if( !(rValue >>= msFilterName ) )
785  return false;
786  }
787  }
788  }
789 
790  for( const auto& rProp : aDescriptor )
791  {
792  const OUString& rPropName = rProp.Name;
793  const Any& rValue = rProp.Value;
794 
795  if (rPropName == "SourceShellID")
796  {
797  if (!(rValue >>= mpImpl->maSrcShellID))
798  return false;
799  }
800  else if (rPropName == "DestinationShellID")
801  {
802  if (!(rValue >>= mpImpl->maDestShellID))
803  return false;
804  }
805  else if( rPropName == "ImageFilter")
806  {
807  if (!(rValue >>= msImgFilterName))
808  return false;
809  }
810  }
811 
812 
813  exportDoc( meClass );
814  }
815  catch(const uno::Exception& e)
816  {
817  // We must catch exceptions, because according to the
818  // API definition export must not throw one!
819  css::uno::Any ex(cppu::getCaughtException());
820  OUString sMessage( ex.getValueTypeName() + ": \"" + e.Message + "\"");
821  if (e.Context.is())
822  {
823  const char* pContext = typeid(*e.Context).name();
824  sMessage += " (context: " + OUString::createFromAscii(pContext) + " )";
825  }
827  Sequence<OUString>(), sMessage, nullptr );
828  }
829 
830  // return true only if no error occurred
832 }
833 
834 void SAL_CALL SvXMLExport::cancel()
835 {
836  // stop export
837  Sequence<OUString> aEmptySeq;
839 }
840 
841 OUString SAL_CALL SvXMLExport::getName( )
842 {
843  return msFilterName;
844 }
845 
846 void SAL_CALL SvXMLExport::setName( const OUString& )
847 {
848  // do nothing, because it is not possible to set the FilterName
849 }
850 
851 // XServiceInfo
853 {
854  return m_implementationName;
855 }
856 
857 sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName )
858 {
859  return cppu::supportsService(this, rServiceName);
860 }
861 
862 uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
863 {
864  return { "com.sun.star.document.ExportFilter", "com.sun.star.xml.XMLExportFilter" };
865 }
866 
867 OUString
868 SvXMLExport::EnsureNamespace(OUString const & i_rNamespace)
869 {
870  OUString const aPreferredPrefix("gen");
871  OUString sPrefix;
872  sal_uInt16 nKey( GetNamespaceMap_().GetKeyByName( i_rNamespace ) );
873  if( XML_NAMESPACE_UNKNOWN == nKey )
874  {
875  // There is no prefix for the namespace, so
876  // we have to generate one and have to add it.
877  sPrefix = aPreferredPrefix;
878  nKey = GetNamespaceMap_().GetKeyByPrefix( sPrefix );
879  sal_Int32 n( 0 );
880  OUStringBuffer buf;
881  while( nKey != USHRT_MAX )
882  {
883  buf.append( aPreferredPrefix );
884  buf.append( ++n );
885  sPrefix = buf.makeStringAndClear();
886  nKey = GetNamespaceMap_().GetKeyByPrefix( sPrefix );
887  }
888 
889  if (mpImpl->mNamespaceMaps.empty()
890  || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
891  {
892  // top was created for lower depth... need a new namespace map!
893  auto pNew = new SvXMLNamespaceMap( *mpNamespaceMap );
894  mpImpl->mNamespaceMaps.push(
895  ::std::make_pair(std::move(mpNamespaceMap), mpImpl->mDepth) );
896  mpNamespaceMap.reset( pNew );
897  }
898 
899  // add the namespace to the map and as attribute
900  mpNamespaceMap->Add( sPrefix, i_rNamespace );
901  AddAttribute( GetXMLToken(XML_XMLNS) + ":" + sPrefix, i_rNamespace );
902  }
903  else
904  {
905  // If there is a prefix for the namespace, reuse that.
906  sPrefix = GetNamespaceMap_().GetPrefixByKey( nKey );
907  }
908  return sPrefix;
909 }
910 
911 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
912  const OUString& rValue )
913 {
914  AddAttribute(GetNamespaceMap_().GetQNameByKey(nPrefixKey, rName), rValue);
915 }
916 
917 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
918  enum XMLTokenEnum eName,
919  const OUString& rValue )
920 {
921  AddAttribute(nPrefixKey, GetXMLToken(eName), rValue);
922 }
923 
924 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
925  enum XMLTokenEnum eName,
926  enum XMLTokenEnum eValue)
927 {
928  AddAttribute(nPrefixKey, eName, GetXMLToken(eValue));
929 }
930 
931 void SvXMLExport::AddAttribute( const OUString& rQName,
932  const OUString& rValue )
933 {
934  mxAttrList->AddAttribute(
935  rQName,
936  rValue );
937 }
938 
939 void SvXMLExport::AddAttribute( const OUString& rQName,
941 {
942  AddAttribute(rQName, GetXMLToken(eValue));
943 }
944 
945 void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
946  const css::lang::Locale& rLocale, bool bWriteEmpty )
947 {
948  if (rLocale.Variant.isEmpty())
949  {
950  // Per convention The BCP 47 string is always stored in Variant, if
951  // that is empty we have a plain language-country combination, no need
952  // to convert to LanguageTag first. Also catches the case of empty
953  // locale denoting system locale.
954  xmloff::token::XMLTokenEnum eLanguage, eCountry;
955  eLanguage = XML_LANGUAGE;
956  eCountry = XML_COUNTRY;
957  if (bWriteEmpty || !rLocale.Language.isEmpty())
958  AddAttribute( nPrefix, eLanguage, rLocale.Language);
959  if (bWriteEmpty || !rLocale.Country.isEmpty())
960  AddAttribute( nPrefix, eCountry, rLocale.Country);
961  }
962  else
963  {
964  LanguageTag aLanguageTag( rLocale);
965  AddLanguageTagAttributes( nPrefix, nPrefixRfc, aLanguageTag, bWriteEmpty);
966  }
967 }
968 
969 void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
970  const LanguageTag& rLanguageTag, bool bWriteEmpty )
971 {
972  if (rLanguageTag.isIsoODF())
973  {
974  if (bWriteEmpty || !rLanguageTag.isSystemLocale())
975  {
976  AddAttribute( nPrefix, XML_LANGUAGE, rLanguageTag.getLanguage());
978  AddAttribute( nPrefix, XML_SCRIPT, rLanguageTag.getScript());
979  if (bWriteEmpty || !rLanguageTag.getCountry().isEmpty())
980  AddAttribute( nPrefix, XML_COUNTRY, rLanguageTag.getCountry());
981  }
982  }
983  else
984  {
986  AddAttribute( nPrefixRfc, XML_RFC_LANGUAGE_TAG, rLanguageTag.getBcp47());
987  // Also in case of non-pure-ISO tag store best matching fo: attributes
988  // for consumers not handling *:rfc-language-tag, ensuring that only
989  // valid ISO codes are stored. Here the bWriteEmpty parameter has no
990  // meaning.
991  OUString aLanguage, aScript, aCountry;
992  rLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
993  if (!aLanguage.isEmpty())
994  {
995  AddAttribute( nPrefix, XML_LANGUAGE, aLanguage);
996  if (!aScript.isEmpty() && getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
997  AddAttribute( nPrefix, XML_SCRIPT, aScript);
998  if (!aCountry.isEmpty())
999  AddAttribute( nPrefix, XML_COUNTRY, aCountry);
1000  }
1001  }
1002 }
1003 
1004 void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1005 {
1006  if( xAttrList.is())
1007  mxAttrList->AppendAttributeList( xAttrList );
1008 }
1009 
1011 {
1012  mxAttrList->Clear();
1013 }
1014 
1015 #ifdef DBG_UTIL
1017 {
1018  SAL_WARN_IF( mxAttrList->getLength(), "xmloff.core", "XMLExport::CheckAttrList: list is not empty" );
1019 }
1020 #endif
1021 
1023 {
1024  CheckAttrList();
1025 
1026  ExportMeta_();
1027 }
1028 
1030 {
1031  CheckAttrList();
1032 
1033  ::std::vector< SettingsGroup > aSettings;
1034  sal_Int32 nSettingsCount = 0;
1035 
1036  // view settings
1037  uno::Sequence< beans::PropertyValue > aViewSettings;
1038  GetViewSettingsAndViews( aViewSettings );
1039  aSettings.emplace_back( XML_VIEW_SETTINGS, aViewSettings );
1040  nSettingsCount += aViewSettings.getLength();
1041 
1042  // configuration settings
1043  uno::Sequence<beans::PropertyValue> aConfigSettings;
1044  GetConfigurationSettings( aConfigSettings );
1045  aSettings.emplace_back( XML_CONFIGURATION_SETTINGS, aConfigSettings );
1046  nSettingsCount += aConfigSettings.getLength();
1047 
1048  // any document specific settings
1049  nSettingsCount += GetDocumentSpecificSettings( aSettings );
1050 
1051  {
1052  SvXMLElementExport aElem( *this,
1053  nSettingsCount != 0,
1055  true, true );
1056 
1057  SettingsExportFacade aSettingsExportContext( *this );
1058  XMLSettingsExportHelper aSettingsExportHelper( aSettingsExportContext );
1059 
1060  for (auto const& settings : aSettings)
1061  {
1062  if ( !settings.aSettings.hasElements() )
1063  continue;
1064 
1065  const OUString& sSettingsName( GetXMLToken( settings.eGroupName ) );
1066  OUString sQName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO, sSettingsName );
1067  aSettingsExportHelper.exportAllSettings( settings.aSettings, sQName );
1068  }
1069  }
1070 }
1071 
1073 {
1074  CheckAttrList();
1075 
1076  {
1077  // <style:styles>
1079  true, true );
1080 
1081  ExportStyles_( false );
1082  }
1083 
1084  // transfer style names (+ families) TO other components (if appropriate)
1086  return;
1087 
1088  static constexpr OUStringLiteral sStyleNames( u"StyleNames" );
1089  static constexpr OUStringLiteral sStyleFamilies( u"StyleFamilies" );
1090  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1091  if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) )
1092  {
1093  Sequence<sal_Int32> aStyleFamilies;
1094  Sequence<OUString> aStyleNames;
1095  mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
1096  mxExportInfo->setPropertyValue( sStyleNames, Any( aStyleNames ) );
1097  mxExportInfo->setPropertyValue( sStyleFamilies,
1098  Any( aStyleFamilies ) );
1099  }
1100 }
1101 
1103 {
1104  // transfer style names (+ families) FROM other components (if appropriate)
1105  OUString sStyleNames( "StyleNames" );
1106  OUString sStyleFamilies( "StyleFamilies" );
1108  && mxExportInfo.is()
1109  && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
1110  && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
1111  {
1112  Sequence<sal_Int32> aStyleFamilies;
1113  mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies;
1114  Sequence<OUString> aStyleNames;
1115  mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames;
1116  mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames );
1117  }
1118 
1119  {
1120  // <style:automatic-styles>
1122  XML_AUTOMATIC_STYLES, true, true );
1123 
1125  }
1126 }
1127 
1129 {
1130  // <style:master-styles>
1132  true, true );
1133 
1135 }
1136 
1138 {
1139  CheckAttrList();
1140 
1141  {
1143  true, true );
1144  {
1145  XMLTokenEnum eClass = meClass;
1146  if( XML_TEXT_GLOBAL == eClass )
1147  {
1149  GetXMLToken( XML_TRUE ) );
1150  eClass = XML_TEXT;
1151  }
1152  if ( XML_GRAPHICS == eClass )
1153  eClass = XML_DRAWING;
1154  // <office:body ...>
1156  SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID,
1157  XML_NAMESPACE_OFFICE, eClass,
1158  true, true );
1159 
1160  ExportContent_();
1161  }
1162  }
1163 }
1164 
1166 {
1167 }
1168 
1169 static void
1170 lcl_AddGrddl(SvXMLExport const & rExport, const SvXMLExportFlags /*nExportMode*/)
1171 {
1172  // check version >= 1.2
1173  switch (rExport.getSaneDefaultVersion()) {
1174  case SvtSaveOptions::ODFSVER_011: // fall through
1175  case SvtSaveOptions::ODFSVER_010: return;
1176  default: break;
1177  }
1178 
1179  // #i115030#: disabled, the XSLT is not finished, and not available via HTTP
1180 #if 0
1181  if (SvXMLExportFlags::SETTINGS != nExportMode) // meta, content, styles
1182  {
1184  OUString("http://FIXME") );
1185  }
1186 #endif
1187 }
1188 
1190 {
1191  uno::Reference< embed::XEncryptionProtectedSource2 > xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
1192 
1193  if (xEncr.is() && xEncr->hasEncryptionData() && mxExtHandler.is())
1194  {
1195  mxExtHandler->comment(OStringToOUString(comphelper::xml::makeXMLChaff(), RTL_TEXTENCODING_ASCII_US));
1196  }
1197 }
1198 
1199 auto SvXMLExport::GetODFVersionAttributeValue() const -> char const*
1200 {
1201  char const* pVersion(nullptr);
1202  switch (getSaneDefaultVersion())
1203  {
1204  case SvtSaveOptions::ODFSVER_013_EXTENDED: [[fallthrough]];
1205  case SvtSaveOptions::ODFSVER_013: pVersion = "1.3"; break;
1206  case SvtSaveOptions::ODFSVER_012_EXTENDED: [[fallthrough]];
1207  case SvtSaveOptions::ODFSVER_012_EXT_COMPAT: [[fallthrough]];
1208  case SvtSaveOptions::ODFSVER_012: pVersion = "1.2"; break;
1209  case SvtSaveOptions::ODFSVER_011: pVersion = "1.1"; break;
1210  case SvtSaveOptions::ODFSVER_010: break;
1211 
1212  default:
1213  assert(!"xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1214  }
1215  return pVersion;
1216 }
1217 
1219 {
1220  bool bOwnGraphicResolver = false;
1221  bool bOwnEmbeddedResolver = false;
1222 
1223  if (!mxGraphicStorageHandler.is() || !mxEmbeddedResolver.is())
1224  {
1225  Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
1226  if( xFactory.is() )
1227  {
1228  try
1229  {
1230  if (!mxGraphicStorageHandler.is())
1231  {
1232  mxGraphicStorageHandler.set(xFactory->createInstance( "com.sun.star.document.ExportGraphicStorageHandler"), UNO_QUERY);
1233  bOwnGraphicResolver = mxGraphicStorageHandler.is();
1234  }
1235 
1236  if( !mxEmbeddedResolver.is() )
1237  {
1238  mxEmbeddedResolver.set(
1239  xFactory->createInstance( "com.sun.star.document.ExportEmbeddedObjectResolver" ), UNO_QUERY);
1240  bOwnEmbeddedResolver = mxEmbeddedResolver.is();
1241  }
1242  }
1243  catch(const css::uno::Exception&)
1244  {
1245  }
1246  }
1247  }
1249  {
1250  try
1251  {
1252  static ::comphelper::PropertyMapEntry const aInfoMap[] =
1253  {
1254  { OUString("Class"), 0,
1256  PropertyAttribute::MAYBEVOID, 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->Clear();
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 // WASM_CHART change
1697 // TODO: With Chart extracted this cannot really happen since
1698 // no Chart could've been added at all
1699 #if !ENABLE_WASM_STRIP_CHART
1700  return new SchXMLExportHelper(*this, *GetAutoStylePool());
1701 #else
1702  return nullptr;
1703 #endif
1704 }
1705 
1707 {
1708  return new XMLFontAutoStylePool( *this );
1709 }
1710 
1712 {
1713  return new xmloff::OFormLayerXMLExport(*this);
1714 }
1715 
1716 void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1717 {
1718  GetViewSettings(rProps);
1719  uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1720  if(!xViewDataSupplier.is())
1721  return;
1722 
1723  uno::Reference<container::XIndexAccess> xIndexAccess;
1724  xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1725  {
1726  // tdf#130559: don't export preview view data if active
1727  static constexpr OUStringLiteral sNoPreviewData = u"NoPreviewData";
1728  css::uno::ContextLayer layer(comphelper::NewFlagContext(sNoPreviewData));
1729  xIndexAccess = xViewDataSupplier->getViewData();
1730  }
1731  bool bAdd = false;
1732  uno::Any aAny;
1733  if(xIndexAccess.is() && xIndexAccess->hasElements() )
1734  {
1735  sal_Int32 nCount = xIndexAccess->getCount();
1736  for (sal_Int32 i = 0; i < nCount; i++)
1737  {
1738  aAny = xIndexAccess->getByIndex(i);
1739  uno::Sequence<beans::PropertyValue> aProps;
1740  if( aAny >>= aProps )
1741  {
1742  if( aProps.hasElements() )
1743  {
1744  bAdd = true;
1745  break;
1746  }
1747  }
1748  }
1749  }
1750 
1751  if( bAdd )
1752  {
1753  sal_Int32 nOldLength(rProps.getLength());
1754  rProps.realloc(nOldLength + 1);
1755  rProps.getArray()[nOldLength] = comphelper::makePropertyValue("Views", xIndexAccess);
1756  }
1757 }
1758 
1759 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1760 {
1761 }
1762 
1763 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1764 {
1765 }
1766 
1767 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::vector< SettingsGroup >& )
1768 {
1769  return 0;
1770 }
1771 
1772 void SvXMLExport::collectDataStyles(bool bFromUsedStyles)
1773 {
1774  Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetModel(), uno::UNO_QUERY);
1775  if (!xStyleFamiliesSupplier.is())
1776  return;
1777 
1778  Reference<container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
1779  if (!xStylesFamilies.is())
1780  return;
1781 
1782  Reference<container::XIndexAccess> xCellStyles(xStylesFamilies->getByName("CellStyles"), uno::UNO_QUERY);
1783  if (!xCellStyles.is())
1784  return;
1785 
1786  sal_Int32 nCount(xCellStyles->getCount());
1787  for (sal_Int32 i = 0; i < nCount; ++i)
1788  {
1789  Reference<style::XStyle> xStyle(xCellStyles->getByIndex(i), uno::UNO_QUERY);
1790  if (bFromUsedStyles && !xStyle->isInUse())
1791  continue;
1792 
1793  Reference<beans::XPropertySet> xCellProperties(xStyle, uno::UNO_QUERY);
1794  if (xCellProperties.is())
1795  {
1796  sal_Int32 nNumberFormat = 0;
1797  if (xCellProperties->getPropertyValue("NumberFormat") >>= nNumberFormat)
1798  addDataStyle(nNumberFormat);
1799  }
1800  }
1801 }
1802 
1803 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ )
1804 {
1805  if(mpNumExport)
1806  mpNumExport->SetUsed(nNumberFormat);
1807 }
1808 
1810 {
1811  if(mpNumExport)
1812  mpNumExport->Export(false);
1813 }
1814 
1816 {
1817  if(mpNumExport)
1818  mpNumExport->Export(true);
1819 
1820  if (mxFormExport.is())
1821  mxFormExport->exportAutoControlNumberStyles();
1822 }
1823 
1824 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ ) const
1825 {
1826  OUString sTemp;
1827  if(mpNumExport)
1828  sTemp = mpNumExport->GetStyleName(nNumberFormat);
1829  return sTemp;
1830 }
1831 
1832 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1833 {
1834 }
1835 
1836 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1837 {
1838  return ( mpNumExport != nullptr )
1839  ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1840 }
1841 
1842 OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName)
1843 {
1844  OUString sURL;
1845 
1846  Graphic aGraphic(rxGraphic);
1847  OUString aOriginURL = aGraphic.getOriginURL();
1848 
1849  if (!aOriginURL.isEmpty())
1850  {
1851  sURL = GetRelativeReference(aOriginURL);
1852  }
1853  else
1854  {
1855  if (mxGraphicStorageHandler.is())
1856  {
1858  sURL = mxGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutMimeType, rRequestedName);
1859  }
1860  }
1861  return sURL;
1862 }
1863 
1864 bool SvXMLExport::GetGraphicMimeTypeFromStream(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType)
1865 {
1866  if (mxGraphicStorageHandler.is())
1867  {
1868  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1869  if (xInputStream.is())
1870  {
1872  return true;
1873  }
1874  }
1875 
1876  return false;
1877 }
1878 
1879 bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic> const & rxGraphic)
1880 {
1883  {
1884  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1885  if (xInputStream.is())
1886  {
1887  Graphic aGraphic(rxGraphic);
1888  if (aGraphic.getOriginURL().isEmpty()) // don't add the base64 if the origin URL is set (image is from an external URL)
1889  {
1890  XMLBase64Export aBase64Exp(*this);
1891  return aBase64Exp.exportOfficeBinaryDataElement(xInputStream);
1892  }
1893  }
1894  }
1895 
1896  return false;
1897 }
1898 
1899 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
1900 {
1901  OUString sRet;
1902  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1903  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1904  if (bSupportedURL && mxEmbeddedResolver.is())
1905  {
1906  sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(rEmbeddedObjectURL);
1907  }
1908  else
1909  sRet = GetRelativeReference( rEmbeddedObjectURL );
1910 
1911  return sRet;
1912 }
1913 
1914 bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
1915 {
1916  bool bRet = false;
1917  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1918  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1919  if (bSupportedURL && mxEmbeddedResolver.is())
1920  {
1922  if( xNA.is() )
1923  {
1924  Any aAny = xNA->getByName( rEmbeddedObjectURL );
1926  aAny >>= xIn;
1927  if( xIn.is() )
1928  {
1929  XMLBase64Export aBase64Exp( *this );
1930  bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1931  }
1932  }
1933  }
1934 
1935  return bRet;
1936 }
1937 
1939  const OUString& rName,
1940  bool *pEncoded ) const
1941 {
1942  return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
1943 }
1944 
1946 {
1947  if (!mpProgressBarHelper)
1948  {
1950 
1951  if (mxExportInfo.is())
1952  {
1953  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1954  if (xPropertySetInfo.is())
1955  {
1956  OUString sProgressRange(XML_PROGRESSRANGE);
1957  OUString sProgressMax(XML_PROGRESSMAX);
1958  OUString sProgressCurrent(XML_PROGRESSCURRENT);
1959  OUString sRepeat(XML_PROGRESSREPEAT);
1960  if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1961  xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1962  xPropertySetInfo->hasPropertyByName(sProgressRange))
1963  {
1964  uno::Any aAny;
1965  sal_Int32 nProgressMax(0);
1966  sal_Int32 nProgressCurrent(0);
1967  sal_Int32 nProgressRange(0);
1968  aAny = mxExportInfo->getPropertyValue(sProgressRange);
1969  if (aAny >>= nProgressRange)
1970  mpProgressBarHelper->SetRange(nProgressRange);
1971  aAny = mxExportInfo->getPropertyValue(sProgressMax);
1972  if (aAny >>= nProgressMax)
1973  mpProgressBarHelper->SetReference(nProgressMax);
1974  aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
1975  if (aAny >>= nProgressCurrent)
1976  mpProgressBarHelper->SetValue(nProgressCurrent);
1977  }
1978  if (xPropertySetInfo->hasPropertyByName(sRepeat))
1979  {
1980  uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
1981  if (aAny.getValueType() == cppu::UnoType<bool>::get())
1982  mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1983  else {
1984  SAL_WARN("xmloff.core", "why is it no boolean?" );
1985  }
1986  }
1987  }
1988  }
1989  }
1990  return mpProgressBarHelper.get();
1991 }
1992 
1994 {
1995  if( nullptr == mpEventExport)
1996  {
1997  // create EventExport on demand
1998  mpEventExport.reset( new XMLEventExport(*this) );
1999 
2000  // and register standard handlers + names
2001  mpEventExport->AddHandler("StarBasic", std::make_unique<XMLStarBasicExportHandler>());
2002  mpEventExport->AddHandler("Script", std::make_unique<XMLScriptExportHandler>());
2003  mpEventExport->AddTranslationTable(aStandardEventTable);
2004  }
2005 
2006  return *mpEventExport;
2007 }
2008 
2010 {
2011  // image map export, create on-demand
2012  if( nullptr == mpImageMapExport )
2013  {
2014  mpImageMapExport.reset( new XMLImageMapExport(*this) );
2015  }
2016 
2017  return *mpImageMapExport;
2018 }
2019 
2020 // XUnoTunnel & co
2022 
2023 void SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent > const & rComp )
2024 {
2025  OUString sFilterService;
2026 
2027  Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2028  if( xServiceInfo.is() )
2029  {
2030  for (const auto& [sModelService, sMatchingFilterService] : aServiceMap)
2031  {
2032  if( xServiceInfo->supportsService( sModelService ) )
2033  {
2034  sFilterService = sMatchingFilterService;
2035  break;
2036  }
2037  }
2038  }
2039 
2040  SAL_WARN_IF( !sFilterService.getLength(), "xmloff.core", "no export filter for own object" );
2041 
2042  if( sFilterService.isEmpty() )
2043  return;
2044 
2045  Reference < XDocumentHandler > xHdl =
2047 
2048  Sequence < Any > aArgs{ Any(xHdl) };
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 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:852
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:179
constexpr OUStringLiteral XML_EMBEDDEDOBJECT_URL_BASE
Definition: xmlexp.cxx:125
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:1199
::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:263
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:1815
constexpr OUStringLiteral XML_PROGRESSCURRENT
OUString msPackageURI
Definition: xmlexp.cxx:242
constexpr sal_uInt16 XML_NAMESPACE_OOOC
void addChaffWhenEncryptedStorage()
Definition: xmlexp.cxx:1189
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:1016
constexpr sal_uInt16 XML_NAMESPACE_FORMX
SvXMLExportFlags
Definition: xmlexp.hxx:91
constexpr OUStringLiteral XML_MODEL_SERVICE_CALC
Definition: xmlexp.cxx:116
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:574
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:868
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:120
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:243
void GetViewSettingsAndViews(css::uno::Sequence< css::beans::PropertyValue > &rProps)
Definition: xmlexp.cxx:1716
constexpr OUStringLiteral XML_MODEL_SERVICE_WRITER
Definition: xmlexp.cxx:115
bool AddEmbeddedObjectAsBase64(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1914
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:1218
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
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:1102
SAL_DLLPRIVATE void DetermineModelType_()
Definition: xmlexp.cxx:401
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:247
constexpr sal_uInt16 XML_NAMESPACE_XSI
virtual void SetBodyAttributes()
Definition: xmlexp.cxx:1165
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:834
virtual void exportAnnotationMeta(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: xmlexp.cxx:1832
virtual void EndElement(const bool i_bIgnoreWhitespace)=0
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlexp.cxx:1945
SchXMLExportHelper * CreateChartExport()
Definition: xmlexp.cxx:1694
OUString getLanguage() const
Any SAL_CALL getCaughtException()
bool mbNullDateInitialized
Definition: xmlexp.cxx:266
std::optional< SvtSaveOptions::ODFSaneDefaultVersion > m_oOverrideODFVersion
Definition: xmlexp.cxx:249
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:945
xmloff::OFormLayerXMLExport * CreateFormExport()
Definition: xmlexp.cxx:1711
TStyleElements m_aElements
int nCount
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:911
virtual void GetViewSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1759
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:1824
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:653
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:1842
const char * sName
static void lcl_AddGrddl(SvXMLExport const &rExport, const SvXMLExportFlags)
Definition: xmlexp.cxx:1170
#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.
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:841
constexpr sal_uInt16 XML_NAMESPACE_CONFIG
SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
bool GetGraphicMimeTypeFromStream(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType)
Definition: xmlexp.cxx:1864
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:1029
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:1072
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:117
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
Definition: xmlexp.cxx:1993
constexpr sal_uInt16 XML_NAMESPACE_TEXT
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) final override
Definition: xmlexp.cxx:857
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:261
static OUString GetMimeTypeForImageStream(const css::uno::Reference< css::io::XInputStream > &xInputStream)
const std::pair< OUString, OUString > aServiceMap[]
Definition: xmlexp.cxx:127
virtual XMLPageExport * CreatePageExport()
Definition: xmlexp.cxx:1689
static OUString GetRelURL(std::u16string_view rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
float u
unsigned char sal_Bool
virtual XMLFontAutoStylePool * CreateFontAutoStylePool()
Definition: xmlexp.cxx:1706
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:363
constexpr sal_uInt16 XML_NAMESPACE_GRDDL
OUString AddEmbeddedObject(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1899
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:2009
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:526
constexpr sal_uInt16 XML_NAMESPACE_DC
constexpr OUStringLiteral XML_USEPRETTYPRINTING
Definition: xmlexp.cxx:122
virtual void ExportMeta_()
Override this method to export the content of .
Definition: xmlexp.cxx:1420
OUString maSrcShellID
Definition: xmlexp.cxx:254
const uno::Reference< uno::XComponentContext > m_xContext
void SetDocHandler(const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler)
Definition: xmlexp.cxx:286
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:390
SAL_DLLPRIVATE void ImplExportContent()
Definition: xmlexp.cxx:1137
virtual void exportDataStyles()
Definition: xmlexp.cxx:1809
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:124
OUString maDestShellID
Definition: xmlexp.cxx:255
OUString EncodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmlexp.cxx:1938
void SetSchemeOf(std::u16string_view rOrigFileName)
Definition: xmlexp.cxx:268
OUString msImgFilterName
Definition: xmlexp.hxx:138
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
Definition: HatchStyle.cxx:126
SAL_DLLPRIVATE void InitCtor_()
Definition: xmlexp.cxx:292
virtual void SAL_CALL setName(const OUString &aName) override
Definition: xmlexp.cxx:846
bool isIsoODF() const
SvXMLUnitConverter maUnitConv
Definition: xmlexp.hxx:141
void IgnorableWhitespace()
Definition: xmlexp.cxx:2194
SAL_DLLPRIVATE void ImplExportMasterStyles()
Definition: xmlexp.cxx:1128
void ClearAttrList()
Definition: xmlexp.cxx:1010
#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:757
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:1767
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:3517
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:2133
rtl::Reference< SvXMLAutoStylePoolP > mxAutoStylePool
Definition: xmlexp.hxx:147
#define XMLERROR_FLAG_ERROR
Definition: xmlerror.hxx:36
bool mbOutlineStyleAsNormalListStyle
Definition: xmlexp.cxx:245
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:119
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlexp.hxx:124
uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory
Definition: xmlexp.cxx:241
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:118
virtual void ExportMasterStyles_()=0
Override this method to export the contents of .
sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const
Definition: xmlexp.cxx:1836
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1763
#define XMLERROR_CANCEL
Definition: xmlerror.hxx:74
OUString encodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmluconv.cxx:818
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:1879
#define SAL_WARN(area, stream)
void AddAttributeList(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
Definition: xmlexp.cxx:1004
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:1772
bool mbExportTextNumberElement
Definition: xmlexp.cxx:265
Reference< XPropertySet > PropertySetMerger_CreateInstance(const Reference< XPropertySet > &rPropSet1, const Reference< XPropertySet > &rPropSet2) noexcept
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper
Definition: xmlexp.cxx:240
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:259
OUString mStreamName
name of stream in package, e.g., "content.xml"
Definition: xmlexp.cxx:252
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:1022
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:1803
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: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:2023
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:862
rtl::Reference< SvXMLAttributeList > mxAttrList
Definition: xmlexp.hxx:134
bool m_bDetectedRangeSegmentation false
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