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