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