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 
27 #include <osl/mutex.hxx>
28 #include <tools/urlobj.hxx>
29 #include <vcl/graph.hxx>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
34 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
35 #include <com/sun/star/text/XTextContent.hpp>
36 #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
37 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
38 #include <com/sun/star/uri/UriReferenceFactory.hpp>
39 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
40 #include <com/sun/star/util/MeasureUnit.hpp>
44 #include <xmloff/attrlist.hxx>
45 #include <xmloff/namespacemap.hxx>
46 #include <xmloff/xmluconv.hxx>
47 #include <xmloff/xmlnamespace.hxx>
48 #include <xmloff/xmltoken.hxx>
49 #include <xmloff/xmlexp.hxx>
50 #include <xmloff/xmlnumfe.hxx>
51 #include <xmloff/xmlmetae.hxx>
58 #include <com/sun/star/document/XEventsSupplier.hpp>
59 #include <com/sun/star/document/XViewDataSupplier.hpp>
60 #include <com/sun/star/frame/XModel.hpp>
61 #include <xmloff/GradientStyle.hxx>
62 #include <xmloff/HatchStyle.hxx>
63 #include <xmloff/ImageStyle.hxx>
64 #include <TransGradientStyle.hxx>
65 #include <xmloff/MarkerStyle.hxx>
66 #include <xmloff/DashStyle.hxx>
68 #include <XMLImageMapExport.hxx>
69 #include <XMLBase64Export.hxx>
70 #include <xmloff/xmlerror.hxx>
71 #include <com/sun/star/style/XStyle.hpp>
72 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
73 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
74 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
75 #include <com/sun/star/beans/PropertyAttribute.hpp>
78 #include <XMLBasicExportFilter.hxx>
79 #include <cppuhelper/exc_hlp.hxx>
80 #include <cppuhelper/implbase.hxx>
82 #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>, tools::Long > > mNamespaceMaps;
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  {
609  Reference < XInterface > xIfc =
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  static const OUStringLiteral sOutlineStyleAsNormalListStyle(
720  u"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  static const OUStringLiteral sExportTextNumberElement(
732  u"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)
1100  return;
1101 
1102  static OUString sStyleNames( "StyleNames" );
1103  static OUString sStyleFamilies( "StyleFamilies" );
1104  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1105  if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) )
1106  {
1107  Sequence<sal_Int32> aStyleFamilies;
1108  Sequence<OUString> aStyleNames;
1109  mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
1110  mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) );
1111  mxExportInfo->setPropertyValue( sStyleFamilies,
1112  makeAny( aStyleFamilies ) );
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  {
1157  true, true );
1158  {
1159  XMLTokenEnum eClass = meClass;
1160  if( XML_TEXT_GLOBAL == eClass )
1161  {
1163  GetXMLToken( XML_TRUE ) );
1164  eClass = XML_TEXT;
1165  }
1166  if ( XML_GRAPHICS == eClass )
1167  eClass = XML_DRAWING;
1168  // <office:body ...>
1170  SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID,
1171  XML_NAMESPACE_OFFICE, eClass,
1172  true, true );
1173 
1174  ExportContent_();
1175  }
1176  }
1177 }
1178 
1180 {
1181 }
1182 
1183 static void
1184 lcl_AddGrddl(SvXMLExport const & rExport, const SvXMLExportFlags /*nExportMode*/)
1185 {
1186  // check version >= 1.2
1187  switch (rExport.getSaneDefaultVersion()) {
1188  case SvtSaveOptions::ODFSVER_011: // fall through
1189  case SvtSaveOptions::ODFSVER_010: return;
1190  default: break;
1191  }
1192 
1193  // #i115030#: disabled, the XSLT is not finished, and not available via HTTP
1194 #if 0
1195  if (SvXMLExportFlags::SETTINGS != nExportMode) // meta, content, styles
1196  {
1198  OUString("http://FIXME") );
1199  }
1200 #endif
1201 }
1202 
1204 {
1205  uno::Reference< embed::XEncryptionProtectedSource2 > xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
1206 
1207  if (xEncr.is() && xEncr->hasEncryptionData() && mxExtHandler.is())
1208  {
1209  mxExtHandler->comment(OStringToOUString(comphelper::xml::makeXMLChaff(), RTL_TEXTENCODING_ASCII_US));
1210  }
1211 }
1212 
1213 auto SvXMLExport::GetODFVersionAttributeValue() const -> char const*
1214 {
1215  char const* pVersion(nullptr);
1216  switch (getSaneDefaultVersion())
1217  {
1218  case SvtSaveOptions::ODFSVER_013_EXTENDED: [[fallthrough]];
1219  case SvtSaveOptions::ODFSVER_013: pVersion = "1.3"; break;
1220  case SvtSaveOptions::ODFSVER_012_EXTENDED: [[fallthrough]];
1221  case SvtSaveOptions::ODFSVER_012_EXT_COMPAT: [[fallthrough]];
1222  case SvtSaveOptions::ODFSVER_012: pVersion = "1.2"; break;
1223  case SvtSaveOptions::ODFSVER_011: pVersion = "1.1"; break;
1224  case SvtSaveOptions::ODFSVER_010: break;
1225 
1226  default:
1227  assert(!"xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1228  }
1229  return pVersion;
1230 }
1231 
1233 {
1234  bool bOwnGraphicResolver = false;
1235  bool bOwnEmbeddedResolver = false;
1236 
1237  if (!mxGraphicStorageHandler.is() || !mxEmbeddedResolver.is())
1238  {
1239  Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
1240  if( xFactory.is() )
1241  {
1242  try
1243  {
1244  if (!mxGraphicStorageHandler.is())
1245  {
1246  mxGraphicStorageHandler.set(xFactory->createInstance( "com.sun.star.document.ExportGraphicStorageHandler"), UNO_QUERY);
1247  bOwnGraphicResolver = mxGraphicStorageHandler.is();
1248  }
1249 
1250  if( !mxEmbeddedResolver.is() )
1251  {
1252  mxEmbeddedResolver.set(
1253  xFactory->createInstance( "com.sun.star.document.ExportEmbeddedObjectResolver" ), UNO_QUERY);
1254  bOwnEmbeddedResolver = mxEmbeddedResolver.is();
1255  }
1256  }
1257  catch(const css::uno::Exception&)
1258  {
1259  }
1260  }
1261  }
1263  {
1264  try
1265  {
1266  static ::comphelper::PropertyMapEntry const aInfoMap[] =
1267  {
1268  { OUString("Class"), 0,
1270  PropertyAttribute::MAYBEVOID, 0},
1271  { OUString(), 0, css::uno::Type(), 0, 0 }
1272  };
1273  Reference< XPropertySet > xConvPropSet(
1275  new ::comphelper::PropertySetInfo( aInfoMap ) ) );
1276 
1277  xConvPropSet->setPropertyValue( "Class", Any(GetXMLToken( eClass )) );
1278 
1279  Reference< XPropertySet > xPropSet =
1280  mxExportInfo.is()
1282  xConvPropSet )
1283  : xConvPropSet;
1284 
1285  Sequence<Any> aArgs( 3 );
1286  aArgs[0] <<= mxHandler;
1287  aArgs[1] <<= xPropSet;
1288  aArgs[2] <<= mxModel;
1289 
1290  // get filter component
1292  m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.Oasis2OOoTransformer", aArgs, m_xContext),
1293  UNO_QUERY);
1294  SAL_WARN_IF(!xTmpDocHandler.is(), "xmloff.core", "can't instantiate OASIS transformer component" );
1295  if( xTmpDocHandler.is() )
1296  {
1297  mxHandler = xTmpDocHandler;
1298  mxExtHandler.set( mxHandler, UNO_QUERY );
1299  }
1300  }
1301  catch(const css::uno::Exception&)
1302  {
1303  }
1304  }
1305 
1306  mxHandler->startDocument();
1307 
1309 
1310  // <office:document ...>
1311  CheckAttrList();
1312 
1313  // namespace attributes
1314  // ( The namespace decls should be first attributes in the element;
1315  // some faulty XML parsers (JAXP1.1) have a problem with this,
1316  // also it's more elegant )
1317  sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
1318  while( USHRT_MAX != nPos )
1319  {
1320  mxAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
1321  mpNamespaceMap->GetNameByKey( nPos ) );
1322  nPos = mpNamespaceMap->GetNextKey( nPos );
1323  }
1324 
1325  // office:version = ...
1326  const char*const pVersion = GetODFVersionAttributeValue();
1327 
1328  if (pVersion)
1329  {
1331  OUString::createFromAscii(pVersion) );
1332  }
1333 
1334  {
1335  enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
1337 
1338  lcl_AddGrddl(*this, nExportMode);
1339 
1340  if( SvXMLExportFlags::META == nExportMode )
1341  {
1342  // export only meta
1343  eRootService = XML_DOCUMENT_META;
1344  }
1345  else if ( SvXMLExportFlags::SETTINGS == nExportMode )
1346  {
1347  // export only settings
1348  eRootService = XML_DOCUMENT_SETTINGS;
1349  }
1350  else if( SvXMLExportFlags::STYLES == nExportMode )
1351  {
1352  // export only styles
1353  eRootService = XML_DOCUMENT_STYLES;
1354  }
1355  else if( SvXMLExportFlags::CONTENT == nExportMode )
1356  {
1357  // export only content
1358  eRootService = XML_DOCUMENT_CONTENT;
1359  }
1360  else
1361  {
1362  // the god'ol one4all element
1363  eRootService = XML_DOCUMENT;
1364  // office:mimetype = ... (only for stream containing the content)
1365  if( eClass != XML_TOKEN_INVALID )
1366  {
1367  OUString aTmp = "application/vnd.oasis.opendocument." + GetXMLToken( eClass );
1369  }
1370  }
1371 
1372  SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, true, true );
1373 
1374  // meta information
1376  ImplExportMeta();
1377 
1378  // settings
1381 
1382  // scripts
1384  ExportScripts_();
1385 
1386  // font declarations
1388  ExportFontDecls_();
1389 
1390  // styles
1392  ImplExportStyles();
1393 
1394  // autostyles
1397 
1398  // masterstyles
1401 
1402  // content
1405  }
1406 
1407  mxHandler->endDocument();
1408 
1409  if( bOwnGraphicResolver )
1410  {
1411  uno::Reference<XComponent> xComp(mxGraphicStorageHandler, UNO_QUERY);
1412  xComp->dispose();
1413  }
1414 
1415  if( bOwnEmbeddedResolver )
1416  {
1417  Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
1418  xComp->dispose();
1419  }
1420 
1421  return ERRCODE_NONE;
1422 }
1423 
1425 {
1426  mpNamespaceMap.reset( new SvXMLNamespaceMap );
1427 }
1428 
1429 OUString const & SvXMLExport::GetSourceShellID() const
1430 {
1431  return mpImpl->maSrcShellID;
1432 }
1433 
1434 OUString const & SvXMLExport::GetDestinationShellID() const
1435 {
1436  return mpImpl->maDestShellID;
1437 }
1438 
1440 {
1441  OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
1442  Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
1443  UNO_QUERY);
1444  if (xDocPropsSupplier.is()) {
1445  Reference<XDocumentProperties> xDocProps(
1446  xDocPropsSupplier->getDocumentProperties());
1447  if (!xDocProps.is()) throw;
1448  // update generator here
1449  xDocProps->setGenerator(generator);
1450  rtl::Reference<SvXMLMetaExport> pMeta = new SvXMLMetaExport(*this, xDocProps);
1451  pMeta->Export();
1452  } else {
1453  // office:meta
1455  true, true );
1456  {
1457  // BM: #i60323# export generator even if xInfoProp is empty (which is the
1458  // case for charts). The generator does not depend on xInfoProp
1460  true, true );
1461  Characters(generator);
1462  }
1463  }
1464 }
1465 
1467 {
1468  SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, true, true );
1469 
1470  // export Basic macros (only for FlatXML)
1472  {
1473  OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) + ":Basic" );
1475 
1476  SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, true, true );
1477 
1478  // initialize Basic
1479  if ( mxModel.is() )
1480  {
1481  Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
1482  if ( xPSet.is() )
1483  xPSet->getPropertyValue("BasicLibraries");
1484  }
1485 
1486  Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
1487  Reference< document::XXMLBasicExporter > xExporter = document::XMLOasisBasicExporter::createWithHandler( m_xContext, xHdl );
1488 
1489  xExporter->setSourceDocument( mxModel );
1490  Sequence< PropertyValue > aMediaDesc( 0 );
1491  xExporter->filter( aMediaDesc );
1492  }
1493 
1494  // export document events
1495  Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
1496  GetEventExport().Export( xEvents );
1497 }
1498 
1500 {
1501  if( mxFontAutoStylePool.is() )
1502  mxFontAutoStylePool->exportXML();
1503 }
1504 
1506 {
1507  uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
1508  if( !xFact.is())
1509  return;
1510 
1511  // export (fill-)gradient-styles
1512  try
1513  {
1514  uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
1515  if( xGradient.is() )
1516  {
1517  XMLGradientStyleExport aGradientStyle( *this );
1518 
1519  if( xGradient->hasElements() )
1520  {
1521  const uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1522  for( const OUString& rStrName : aNamesSeq )
1523  {
1524  try
1525  {
1526  uno::Any aValue = xGradient->getByName( rStrName );
1527 
1528  aGradientStyle.exportXML( rStrName, aValue );
1529  }
1530  catch(const container::NoSuchElementException&)
1531  {
1532  }
1533  }
1534  }
1535  }
1536  }
1537  catch(const lang::ServiceNotRegisteredException&)
1538  {
1539  }
1540 
1541  // export (fill-)hatch-styles
1542  try
1543  {
1544  uno::Reference< container::XNameAccess > xHatch( xFact->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY );
1545  if( xHatch.is() )
1546  {
1547  XMLHatchStyleExport aHatchStyle( *this );
1548 
1549  if( xHatch->hasElements() )
1550  {
1551  const uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1552  for( const OUString& rStrName : aNamesSeq )
1553  {
1554  try
1555  {
1556  uno::Any aValue = xHatch->getByName( rStrName );
1557 
1558  aHatchStyle.exportXML( rStrName, aValue );
1559  }
1560  catch(const container::NoSuchElementException&)
1561  {}
1562  }
1563  }
1564  }
1565  }
1566  catch(const lang::ServiceNotRegisteredException&)
1567  {
1568  }
1569 
1570  // export (fill-)bitmap-styles
1571  try
1572  {
1573  uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
1574  if( xBitmap.is() )
1575  {
1576  if( xBitmap->hasElements() )
1577  {
1578  const uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1579  for( const OUString& rStrName : aNamesSeq )
1580  {
1581  try
1582  {
1583  uno::Any aValue = xBitmap->getByName( rStrName );
1584 
1585  XMLImageStyle::exportXML( rStrName, aValue, *this );
1586  }
1587  catch(const container::NoSuchElementException&)
1588  {
1589  }
1590  }
1591  }
1592  }
1593  }
1594  catch(const lang::ServiceNotRegisteredException&)
1595  {
1596  }
1597 
1598  // export transparency-gradient -styles
1599  try
1600  {
1601  uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY );
1602  if( xTransGradient.is() )
1603  {
1604  XMLTransGradientStyleExport aTransGradientstyle( *this );
1605 
1606  if( xTransGradient->hasElements() )
1607  {
1608  const uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1609  for( const OUString& rStrName : aNamesSeq )
1610  {
1611  try
1612  {
1613  uno::Any aValue = xTransGradient->getByName( rStrName );
1614 
1615  aTransGradientstyle.exportXML( rStrName, aValue );
1616  }
1617  catch(const container::NoSuchElementException&)
1618  {
1619  }
1620  }
1621  }
1622  }
1623  }
1624  catch(const lang::ServiceNotRegisteredException&)
1625  {
1626  }
1627 
1628  // export marker-styles
1629  try
1630  {
1631  uno::Reference< container::XNameAccess > xMarker( xFact->createInstance("com.sun.star.drawing.MarkerTable"), uno::UNO_QUERY );
1632  if( xMarker.is() )
1633  {
1634  XMLMarkerStyleExport aMarkerStyle( *this );
1635 
1636  if( xMarker->hasElements() )
1637  {
1638  const uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1639  for( const OUString& rStrName : aNamesSeq )
1640  {
1641  try
1642  {
1643  uno::Any aValue = xMarker->getByName( rStrName );
1644 
1645  aMarkerStyle.exportXML( rStrName, aValue );
1646  }
1647  catch(const container::NoSuchElementException&)
1648  {
1649  }
1650  }
1651  }
1652  }
1653  }
1654  catch(const lang::ServiceNotRegisteredException&)
1655  {
1656  }
1657 
1658  // export dash-styles
1659  try
1660  {
1661  uno::Reference< container::XNameAccess > xDashes( xFact->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
1662  if( xDashes.is() )
1663  {
1664  XMLDashStyleExport aDashStyle( *this );
1665 
1666  if( xDashes->hasElements() )
1667  {
1668  const uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1669  for( const OUString& rStrName : aNamesSeq )
1670  {
1671  try
1672  {
1673  uno::Any aValue = xDashes->getByName( rStrName );
1674 
1675  aDashStyle.exportXML( rStrName, aValue );
1676  }
1677  catch(const container::NoSuchElementException&)
1678  {
1679  }
1680  }
1681  }
1682  }
1683  }
1684  catch(const lang::ServiceNotRegisteredException&)
1685  {
1686  }
1687 }
1688 
1690 {
1691  return new XMLTextParagraphExport( *this, *GetAutoStylePool() );
1692 }
1693 
1695 {
1696  return new XMLShapeExport(*this);
1697 }
1698 
1700 {
1701  return new SvXMLAutoStylePoolP(*this);
1702 }
1703 
1705 {
1706 }
1707 
1709 {
1710  return new XMLPageExport( *this );
1711 }
1712 
1714 {
1715  return new SchXMLExportHelper(*this, *GetAutoStylePool());
1716 }
1717 
1719 {
1720  return new XMLFontAutoStylePool( *this );
1721 }
1722 
1724 {
1725  return new xmloff::OFormLayerXMLExport(*this);
1726 }
1727 
1728 void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1729 {
1730  GetViewSettings(rProps);
1731  uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1732  if(!xViewDataSupplier.is())
1733  return;
1734 
1735  uno::Reference<container::XIndexAccess> xIndexAccess;
1736  xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1737  {
1738  // tdf#130559: don't export preview view data if active
1739  css::uno::ContextLayer layer(comphelper::NewFlagContext("NoPreviewData"));
1740  xIndexAccess = xViewDataSupplier->getViewData();
1741  }
1742  bool bAdd = false;
1743  uno::Any aAny;
1744  if(xIndexAccess.is() && xIndexAccess->hasElements() )
1745  {
1746  sal_Int32 nCount = xIndexAccess->getCount();
1747  for (sal_Int32 i = 0; i < nCount; i++)
1748  {
1749  aAny = xIndexAccess->getByIndex(i);
1750  uno::Sequence<beans::PropertyValue> aProps;
1751  if( aAny >>= aProps )
1752  {
1753  if( aProps.hasElements() )
1754  {
1755  bAdd = true;
1756  break;
1757  }
1758  }
1759  }
1760  }
1761 
1762  if( bAdd )
1763  {
1764  sal_Int32 nOldLength(rProps.getLength());
1765  rProps.realloc(nOldLength + 1);
1766  beans::PropertyValue aProp;
1767  aProp.Name = "Views";
1768  aProp.Value <<= xIndexAccess;
1769  rProps[nOldLength] = aProp;
1770  }
1771 }
1772 
1773 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1774 {
1775 }
1776 
1777 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1778 {
1779 }
1780 
1781 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::vector< SettingsGroup >& )
1782 {
1783  return 0;
1784 }
1785 
1786 void SvXMLExport::collectDataStyles(bool bFromUsedStyles)
1787 {
1788  Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetModel(), uno::UNO_QUERY);
1789  if (!xStyleFamiliesSupplier.is())
1790  return;
1791 
1792  Reference<container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
1793  if (!xStylesFamilies.is())
1794  return;
1795 
1796  Reference<container::XIndexAccess> xCellStyles(xStylesFamilies->getByName("CellStyles"), uno::UNO_QUERY);
1797  if (!xCellStyles.is())
1798  return;
1799 
1800  sal_Int32 nCount(xCellStyles->getCount());
1801  for (sal_Int32 i = 0; i < nCount; ++i)
1802  {
1803  Reference<style::XStyle> xStyle(xCellStyles->getByIndex(i), uno::UNO_QUERY);
1804  if (bFromUsedStyles && !xStyle->isInUse())
1805  continue;
1806 
1807  Reference<beans::XPropertySet> xCellProperties(xStyle, uno::UNO_QUERY);
1808  if (xCellProperties.is())
1809  {
1810  sal_Int32 nNumberFormat = 0;
1811  if (xCellProperties->getPropertyValue("NumberFormat") >>= nNumberFormat)
1812  addDataStyle(nNumberFormat);
1813  }
1814  }
1815 }
1816 
1817 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ )
1818 {
1819  if(mpNumExport)
1820  mpNumExport->SetUsed(nNumberFormat);
1821 }
1822 
1824 {
1825  if(mpNumExport)
1826  mpNumExport->Export(false);
1827 }
1828 
1830 {
1831  if(mpNumExport)
1832  mpNumExport->Export(true);
1833 
1834  if (mxFormExport.is())
1835  mxFormExport->exportAutoControlNumberStyles();
1836 }
1837 
1838 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ ) const
1839 {
1840  OUString sTemp;
1841  if(mpNumExport)
1842  sTemp = mpNumExport->GetStyleName(nNumberFormat);
1843  return sTemp;
1844 }
1845 
1846 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1847 {
1848 }
1849 
1850 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1851 {
1852  return ( mpNumExport != nullptr )
1853  ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1854 }
1855 
1856 OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName)
1857 {
1858  OUString sURL;
1859 
1860  Graphic aGraphic(rxGraphic);
1861  OUString aOriginURL = aGraphic.getOriginURL();
1862 
1863  if (!aOriginURL.isEmpty())
1864  {
1865  sURL = GetRelativeReference(aOriginURL);
1866  }
1867  else
1868  {
1869  if (mxGraphicStorageHandler.is())
1870  {
1872  sURL = mxGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutMimeType, rRequestedName);
1873  }
1874  }
1875  return sURL;
1876 }
1877 
1878 bool SvXMLExport::GetGraphicMimeTypeFromStream(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType)
1879 {
1880  if (mxGraphicStorageHandler.is())
1881  {
1882  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1883  if (xInputStream.is())
1884  {
1886  return true;
1887  }
1888  }
1889 
1890  return false;
1891 }
1892 
1893 bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic> const & rxGraphic)
1894 {
1897  {
1898  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1899  if (xInputStream.is())
1900  {
1901  Graphic aGraphic(rxGraphic);
1902  if (aGraphic.getOriginURL().isEmpty()) // don't add the base64 if the origin URL is set (image is from an external URL)
1903  {
1904  XMLBase64Export aBase64Exp(*this);
1905  return aBase64Exp.exportOfficeBinaryDataElement(xInputStream);
1906  }
1907  }
1908  }
1909 
1910  return false;
1911 }
1912 
1913 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
1914 {
1915  OUString sRet;
1916  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1917  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1918  if (bSupportedURL && mxEmbeddedResolver.is())
1919  {
1920  sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(rEmbeddedObjectURL);
1921  }
1922  else
1923  sRet = GetRelativeReference( rEmbeddedObjectURL );
1924 
1925  return sRet;
1926 }
1927 
1928 bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
1929 {
1930  bool bRet = false;
1931  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1932  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1933  if (bSupportedURL && mxEmbeddedResolver.is())
1934  {
1936  if( xNA.is() )
1937  {
1938  Any aAny = xNA->getByName( rEmbeddedObjectURL );
1940  aAny >>= xIn;
1941  if( xIn.is() )
1942  {
1943  XMLBase64Export aBase64Exp( *this );
1944  bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1945  }
1946  }
1947  }
1948 
1949  return bRet;
1950 }
1951 
1953  const OUString& rName,
1954  bool *pEncoded ) const
1955 {
1956  return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
1957 }
1958 
1960 {
1961  if (!mpProgressBarHelper)
1962  {
1964 
1965  if (mxExportInfo.is())
1966  {
1967  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1968  if (xPropertySetInfo.is())
1969  {
1970  OUString sProgressRange(XML_PROGRESSRANGE);
1971  OUString sProgressMax(XML_PROGRESSMAX);
1972  OUString sProgressCurrent(XML_PROGRESSCURRENT);
1973  OUString sRepeat(XML_PROGRESSREPEAT);
1974  if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1975  xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1976  xPropertySetInfo->hasPropertyByName(sProgressRange))
1977  {
1978  uno::Any aAny;
1979  sal_Int32 nProgressMax(0);
1980  sal_Int32 nProgressCurrent(0);
1981  sal_Int32 nProgressRange(0);
1982  aAny = mxExportInfo->getPropertyValue(sProgressRange);
1983  if (aAny >>= nProgressRange)
1984  mpProgressBarHelper->SetRange(nProgressRange);
1985  aAny = mxExportInfo->getPropertyValue(sProgressMax);
1986  if (aAny >>= nProgressMax)
1987  mpProgressBarHelper->SetReference(nProgressMax);
1988  aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
1989  if (aAny >>= nProgressCurrent)
1990  mpProgressBarHelper->SetValue(nProgressCurrent);
1991  }
1992  if (xPropertySetInfo->hasPropertyByName(sRepeat))
1993  {
1994  uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
1995  if (aAny.getValueType() == cppu::UnoType<bool>::get())
1996  mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1997  else {
1998  SAL_WARN("xmloff.core", "why is it no boolean?" );
1999  }
2000  }
2001  }
2002  }
2003  }
2004  return mpProgressBarHelper.get();
2005 }
2006 
2008 {
2009  if( nullptr == mpEventExport)
2010  {
2011  // create EventExport on demand
2012  mpEventExport.reset( new XMLEventExport(*this) );
2013 
2014  // and register standard handlers + names
2015  mpEventExport->AddHandler("StarBasic", std::make_unique<XMLStarBasicExportHandler>());
2016  mpEventExport->AddHandler("Script", std::make_unique<XMLScriptExportHandler>());
2017  mpEventExport->AddTranslationTable(aStandardEventTable);
2018  }
2019 
2020  return *mpEventExport;
2021 }
2022 
2024 {
2025  // image map export, create on-demand
2026  if( nullptr == mpImageMapExport )
2027  {
2028  mpImageMapExport.reset( new XMLImageMapExport(*this) );
2029  }
2030 
2031  return *mpImageMapExport;
2032 }
2033 
2034 // XUnoTunnel & co
2036 
2037 void SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent > const & rComp )
2038 {
2039  OUString sFilterService;
2040 
2041  Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2042  if( xServiceInfo.is() )
2043  {
2044  const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
2045  while( pEntry->sModelService )
2046  {
2047  OUString sModelService( pEntry->sModelService,
2048  pEntry->nModelServiceLen,
2049  RTL_TEXTENCODING_ASCII_US );
2050  if( xServiceInfo->supportsService( sModelService ) )
2051  {
2052  sFilterService = OUString( pEntry->sFilterService,
2053  pEntry->nFilterServiceLen,
2054  RTL_TEXTENCODING_ASCII_US );
2055  break;
2056  }
2057  pEntry++;
2058  }
2059  }
2060 
2061  SAL_WARN_IF( !sFilterService.getLength(), "xmloff.core", "no export filter for own object" );
2062 
2063  if( sFilterService.isEmpty() )
2064  return;
2065 
2066  Reference < XDocumentHandler > xHdl =
2068 
2069  Sequence < Any > aArgs( 1 );
2070  aArgs[0] <<= xHdl;
2071 
2072  Reference< document::XExporter > xExporter(
2073  m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(sFilterService, aArgs, m_xContext),
2074  UNO_QUERY);
2075  SAL_WARN_IF( !xExporter.is(), "xmloff.core", "can't instantiate export filter component for own object" );
2076  if( !xExporter.is() )
2077  return;
2078 
2079  xExporter->setSourceDocument( rComp );
2080 
2081  Reference<XFilter> xFilter( xExporter, UNO_QUERY );
2082 
2083  Sequence < PropertyValue > aMediaDesc( 0 );
2084  xFilter->filter( aMediaDesc );
2085 }
2086 
2087 OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
2088 {
2089  OUString sValue( rValue );
2090  // #i65474# handling of fragment URLs ("#...") is undefined
2091  // they are stored 'as is'
2092  uno::Reference< uri::XUriReference > xUriRef;
2093  if(!sValue.isEmpty() && sValue[0] != '#')
2094  {
2095  try
2096  {
2097  xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
2098  if( xUriRef.is() && !xUriRef->isAbsolute() )
2099  {
2100  //#i61943# relative URLs need special handling
2101  INetURLObject aTemp( mpImpl->msPackageURI );
2102  bool bWasAbsolute = false;
2103  sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
2104  }
2105  }
2106  catch(const uno::Exception&)
2107  {
2108  }
2109  }
2110  if( xUriRef.is() )//no conversion for empty values or for fragments
2111  {
2112  //conversion for matching schemes only
2113  if( xUriRef->getScheme() == mpImpl->msPackageURIScheme )
2114  {
2115  sValue = INetURLObject::GetRelURL( msOrigFileName, sValue );
2116  }
2117  }
2118  return sValue;
2119 }
2120 
2121 void SvXMLExport::StartElement(sal_uInt16 nPrefix,
2123  bool bIgnWSOutside )
2124 {
2125  StartElement(GetNamespaceMap_().GetQNameByKey( nPrefix,
2126  GetXMLToken(eName) ), bIgnWSOutside);
2127 }
2128 
2129 void SvXMLExport::StartElement(const OUString& rName,
2130  bool bIgnWSOutside )
2131 {
2132  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) != SvXMLErrorFlags::DO_NOTHING)
2133  {
2134  try
2135  {
2136  if( bIgnWSOutside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY))
2137  mxHandler->ignorableWhitespace( msWS );
2138  mxHandler->startElement( rName, GetXAttrList() );
2139  }
2140  catch (const SAXInvalidCharacterException& e)
2141  {
2142  Sequence<OUString> aPars { rName };
2143  SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2144  }
2145  catch (const SAXException& e)
2146  {
2147  Sequence<OUString> aPars { rName };
2149  aPars, e.Message, nullptr );
2150  }
2151  }
2152  ClearAttrList();
2153  ++mpImpl->mDepth; // increment nesting depth counter
2154 }
2155 
2156 void SvXMLExport::Characters(const OUString& rChars)
2157 {
2158  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2159  return;
2160 
2161  try
2162  {
2163  mxHandler->characters(rChars);
2164  }
2165  catch (const SAXInvalidCharacterException& e)
2166  {
2167  Sequence<OUString> aPars { rChars };
2168  SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2169  }
2170  catch (const SAXException& e)
2171  {
2172  Sequence<OUString> aPars { rChars };
2174  aPars, e.Message, nullptr );
2175  }
2176 }
2177 
2178 void SvXMLExport::EndElement(sal_uInt16 nPrefix,
2180  bool bIgnWSInside )
2181 {
2182  EndElement(GetNamespaceMap_().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
2183  bIgnWSInside);
2184 }
2185 
2186 void SvXMLExport::EndElement(const OUString& rName,
2187  bool bIgnWSInside )
2188 {
2189  // decrement nesting depth counter & (maybe) restore namespace map
2190  --mpImpl->mDepth;
2191  if (!mpImpl->mNamespaceMaps.empty() &&
2192  (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
2193  {
2194  mpNamespaceMap = std::move(mpImpl->mNamespaceMaps.top().first);
2195  mpImpl->mNamespaceMaps.pop();
2196  }
2197  SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() &&
2198  (mpImpl->mNamespaceMaps.top().second >= mpImpl->mDepth), "xmloff.core", "SvXMLExport: NamespaceMaps corrupted");
2199 
2200  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2201  return;
2202 
2203  try
2204  {
2205  if( bIgnWSInside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY))
2206  mxHandler->ignorableWhitespace( msWS );
2207  mxHandler->endElement( rName );
2208  }
2209  catch (const SAXException& e)
2210  {
2211  Sequence<OUString> aPars { rName };
2213  aPars, e.Message, nullptr );
2214  }
2215 }
2216 
2218 {
2219  if ((mnExportFlags & SvXMLExportFlags::PRETTY) != SvXMLExportFlags::PRETTY)
2220  return;
2221 
2222  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2223  return;
2224 
2225  try
2226  {
2227  mxHandler->ignorableWhitespace( msWS );
2228  }
2229  catch (const SAXException& e)
2230  {
2231  Sequence<OUString> aPars(0);
2233  aPars, e.Message, nullptr );
2234  }
2235 }
2236 
2238  sal_Int32 nId,
2239  const Sequence<OUString>& rMsgParams,
2240  const OUString& rExceptionMessage,
2241  const Reference<XLocator>& rLocator )
2242 {
2243  // allow multi-threaded access to the cancel() method
2244  static osl::Mutex aMutex;
2245  osl::MutexGuard aGuard(aMutex);
2246 
2247  // maintain error flags
2248  if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
2250  if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
2252  if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
2254 
2255  // create error list on demand
2256  if ( mpXMLErrors == nullptr )
2257  mpXMLErrors.reset( new XMLErrors() );
2258 
2259  // save error information
2260  mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
2261 }
2262 
2264  sal_Int32 nId,
2265  const Sequence<OUString>& rMsgParams)
2266 {
2267  SetError( nId, rMsgParams, "", nullptr );
2268 }
2269 
2271 {
2272  mxModel.clear();
2273  // Shapes in Writer cannot be named via context menu (#i51726#)
2275  mxEventListener.clear();
2276 }
2277 
2278 
2280 {
2281  return mpImpl->maInterfaceToIdentifierMapper;
2282 }
2283 
2284 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
2286 {
2287  return mpImpl->mbOutlineStyleAsNormalListStyle;
2288 }
2289 
2290 uno::Reference< embed::XStorage > const & SvXMLExport::GetTargetStorage() const
2291 {
2292  return mpImpl->mxTargetStorage;
2293 }
2294 
2296 {
2297  if( mpImpl )
2298  return mpImpl->maSaveOptions.GetODFSaneDefaultVersion();
2299 
2300  // fatal error, use current version as default
2302 }
2303 
2304 void
2306  sal_uInt16 const nLegacyPrefix, OUString const& rValue)
2307 {
2308  switch (getSaneDefaultVersion()) {
2309  case SvtSaveOptions::ODFSVER_011: // fall through
2310  case SvtSaveOptions::ODFSVER_010: break;
2311  default: // ODF 1.2: xml:id
2313  }
2314  // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
2315  // backward compatibility: in ODF 1.2 write _both_ id attrs
2316  AddAttribute(nLegacyPrefix, XML_ID, rValue);
2317  // FIXME: this function simply assumes that rValue is unique
2318 }
2319 
2320 void
2321 SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
2322 {
2323  // check version >= 1.2
2324  switch (getSaneDefaultVersion()) {
2325  case SvtSaveOptions::ODFSVER_011: // fall through
2326  case SvtSaveOptions::ODFSVER_010: return;
2327  default: break;
2328  }
2329  const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2330  uno::UNO_QUERY);
2331 //FIXME not yet...
2332  if ( !xMeta.is() )
2333  return;
2334 
2335  const beans::StringPair mdref( xMeta->getMetadataReference() );
2336  if ( mdref.Second.isEmpty() )
2337  return;
2338 
2339  const OUString streamName = mpImpl->mStreamName;
2340  if ( !streamName.isEmpty() )
2341  {
2342  if ( streamName == mdref.First )
2343  {
2344  AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2345  }
2346  else
2347  {
2348  SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name");
2349  }
2350  }
2351  else
2352  {
2353  // FIXME: this is ugly
2354  // there is no stream name (e.g. XSLT, flat-xml format)!
2355  // but how do we ensure uniqueness in this case?
2356  // a) just omit styles.xml ids -- they are unlikely anyway...
2357  // b) somehow find out whether we are currently exporting styles
2358  // or content, and prefix "s" or "c" => unique
2359  if ( mdref.First == "content.xml" )
2360  {
2361  AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2362  }
2363  else
2364  {
2365  SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id");
2366  }
2367  }
2368 }
2369 
2370 void
2372  uno::Reference<text::XTextContent> const & i_xTextContent)
2373 {
2374  // check version >= 1.2
2375  switch (getSaneDefaultVersion()) {
2376  case SvtSaveOptions::ODFSVER_011: // fall through
2377  case SvtSaveOptions::ODFSVER_010: return;
2378  default: break;
2379  }
2380 
2381  const uno::Reference<rdf::XMetadatable> xMeta(
2382  i_xTextContent, uno::UNO_QUERY);
2383  if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty())
2384  {
2385  return; // no xml:id => no RDFa
2386  }
2387 
2388  if (!mpImpl->mpRDFaHelper)
2389  {
2390  mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
2391  }
2392  mpImpl->mpRDFaHelper->AddRDFa(xMeta);
2393 }
2394 
2396 {
2397  return mpImpl->mbExportTextNumberElement;
2398 }
2399 
2401 {
2402  // if the null date has already been set, don't set it again (performance)
2403  if (!mpImpl->mbNullDateInitialized)
2404  mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel());
2405 
2406  return mpImpl->mbNullDateInitialized;
2407 }
2408 
2409 OUString const & SvXMLExport::GetImageFilterName() const
2410 {
2411  return msImgFilterName;
2412 }
2413 
2415  const sal_uInt16 nPrefixKey,
2416  const OUString& rLName,
2417  const bool bIgnoreWhitespaceOutside )
2418 {
2419  maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
2420  mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside);
2421 }
2422 
2424  SvXMLExport& rExp,
2425  sal_uInt16 nPrefixKey,
2426  const char *pLName,
2427  bool bIWSOutside,
2428  bool bIWSInside )
2429  : mrExport( rExp )
2430  , maElementName()
2431  , mbIgnoreWhitespaceInside( bIWSInside )
2432  , mbDoSomething( true )
2433 {
2434  const OUString sLName( OUString::createFromAscii( pLName ) );
2435  StartElement( nPrefixKey, sLName, bIWSOutside );
2436 }
2437 
2439  SvXMLExport& rExp,
2440  sal_uInt16 nPrefixKey,
2441  const OUString& rLName,
2442  bool bIWSOutside,
2443  bool bIWSInside )
2444  : mrExport( rExp )
2445  , maElementName()
2446  , mbIgnoreWhitespaceInside( bIWSInside )
2447  , mbDoSomething( true )
2448 {
2449  StartElement( nPrefixKey, rLName, bIWSOutside );
2450 }
2451 
2453  SvXMLExport& rExp,
2454  sal_uInt16 nPrefixKey,
2455  enum XMLTokenEnum eLName,
2456  bool bIWSOutside,
2457  bool bIWSInside )
2458  : mrExport( rExp )
2459  , maElementName()
2460  , mbIgnoreWhitespaceInside( bIWSInside )
2461  , mbDoSomething( true )
2462 {
2463  StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2464 }
2465 
2467  SvXMLExport& rExp,
2468  bool bDoSth,
2469  sal_uInt16 nPrefixKey,
2470  enum XMLTokenEnum eLName,
2471  bool bIWSOutside,
2472  bool bIWSInside )
2473  : mrExport( rExp )
2474  , maElementName()
2475  , mbIgnoreWhitespaceInside( bIWSInside )
2476  , mbDoSomething( bDoSth )
2477 {
2478  if ( mbDoSomething )
2479  StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside );
2480 }
2481 
2483  SvXMLExport& rExp,
2484  const OUString& rQName,
2485  bool bIWSOutside,
2486  bool bIWSInside )
2487  : mrExport( rExp )
2488  , maElementName()
2489  , mbIgnoreWhitespaceInside( bIWSInside )
2490  , mbDoSomething( true )
2491 {
2492  maElementName = rQName;
2493  rExp.StartElement( rQName, bIWSOutside );
2494 }
2495 
2497 {
2498  if ( mbDoSomething )
2499  {
2501  }
2502 }
2503 
2504 /* 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:2290
constexpr sal_uInt16 XML_NAMESPACE_MATH
#define XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE
Definition: xmlexp.cxx:119
SvXMLExportFlags mnExportFlags
Definition: xmlexp.hxx:156
sal_uInt16 GetKeyByPrefix(const OUString &rPrefix) const
virtual OUString SAL_CALL getImplementationName() final override
Definition: xmlexp.cxx:836
URL aURL
FieldUnit
OUString sMessage
OUString maElementName
Definition: xmlexp.hxx:637
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
#define XML_WRITTENNUMBERSTYLES
Definition: xmlnumfe.hxx:35
constexpr sal_uInt16 XML_NAMESPACE_XFORMS
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_DR3D
char const * GetODFVersionAttributeValue() const
returns value of ODF version attribute
Definition: xmlexp.cxx:1213
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlexp.cxx:2279
constexpr sal_uInt16 XML_NAMESPACE_DRAW_EXT
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:80
::std::unique_ptr< ::xmloff::RDFaExportHelper > mpRDFaHelper
Definition: xmlexp.cxx:276
virtual void DisposingModel()
Definition: xmlexp.cxx:2270
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
virtual void exportAutoDataStyles()
Definition: xmlexp.cxx:1829
#define XML_USEPRETTYPRINTING
Definition: xmlexp.cxx:117
OUString msPackageURI
Definition: xmlexp.cxx:255
constexpr sal_uInt16 XML_NAMESPACE_OOOC
void addChaffWhenEncryptedStorage()
Definition: xmlexp.cxx:1203
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:394
static EFactory ClassifyFactoryByModel(const css::uno::Reference< css::frame::XModel > &xModel)
long Long
void CheckAttrList()
Definition: xmlexp.cxx:1030
constexpr sal_uInt16 XML_NAMESPACE_FORMX
SvXMLExportFlags
Definition: xmlexp.hxx:89
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:1699
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:2371
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
bool exportTextNumberElement() const
Definition: xmlexp.cxx:2395
SvXMLExport & mrExport
Definition: xmlexp.hxx:636
OUString getScript() const
css::uno::Reference< css::xml::sax::XAttributeList > GetXAttrList()
Definition: xmlexp.hxx:381
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_OOO
css::uno::Reference< css::frame::XModel2 > mxModel
virtual XMLTextParagraphExport * CreateTextParagraphExport()
Definition: xmlexp.cxx:1689
virtual css::uno::Reference< css::uno::XComponentContext > GetComponentContext() const =0
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
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:1728
bool AddEmbeddedObjectAsBase64(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1928
constexpr sal_uInt16 XML_NAMESPACE_CSS3TEXT
CALC
std::unique_ptr< SvXMLNamespaceMap > mpNamespaceMap
Definition: xmlexp.hxx:137
OString makeXMLChaff()
OUString msFilterName
Definition: xmlexp.hxx:135
css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver
Definition: xmlexp.hxx:127
constexpr sal_uInt16 XML_NAMESPACE_NUMBER
virtual ErrCode exportDoc(enum::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID)
Definition: xmlexp.cxx:1232
constexpr sal_uInt16 XML_NAMESPACE_DOM
void SAL_DLLPRIVATE AddAttributeIdLegacy(sal_uInt16 const nLegacyPrefix, OUString const &rValue)
add xml:id and legacy namespace id
Definition: xmlexp.cxx:2305
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:1505
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_CALC_EXT
const sal_uInt16 XML_NAMESPACE_UNKNOWN
uno::Reference< embed::XStorage > mxTargetStorage
Definition: xmlexp.cxx:260
constexpr sal_uInt16 XML_NAMESPACE_XSI
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
virtual void SetBodyAttributes()
Definition: xmlexp.cxx:1179
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:1846
virtual void EndElement(const bool i_bIgnoreWhitespace)=0
#define SERVICE_MAP_ENTRY(app)
Definition: xmlexp.cxx:134
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlexp.cxx:1959
SchXMLExportHelper * CreateChartExport()
Definition: xmlexp.cxx:1713
#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:1723
TStyleElements m_aElements
int nCount
virtual void GetViewSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1773
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
constexpr sal_uInt16 XML_NAMESPACE_FORM
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:2121
enum::xmloff::token::XMLTokenEnum meClass
Definition: xmlexp.hxx:153
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:2087
virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat=false) const
Definition: xmlexp.cxx:1838
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlexp.cxx:636
constexpr sal_uInt16 XML_NAMESPACE_DRAW
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
Definition: xmlexp.cxx:1856
#define XML_PROGRESSMAX
const char * sName
static void lcl_AddGrddl(SvXMLExport const &rExport, const SvXMLExportFlags)
Definition: xmlexp.cxx:1184
#define XMLERROR_FLAG_WARNING
Definition: xmlerror.hxx:35
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Record an error condition that occurred during export.
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
void SetSchemeOf(const OUString &rOrigFileName)
Definition: xmlexp.cxx:281
std::unique_ptr< SvXMLNumFmtExport > mpNumExport
Definition: xmlexp.hxx:139
OUString const & GetDestinationShellID() const
Definition: xmlexp.cxx:1434
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_CONFIG
bool GetGraphicMimeTypeFromStream(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType)
Definition: xmlexp.cxx:1878
constexpr sal_uInt16 XML_NAMESPACE_XML
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2295
OUString sPrefix
UNO3_GETIMPLEMENTATION_IMPL(SvXMLExport)
bool SetNullDateOnUnitConverter()
set null date from model to unit converter, if not already done
Definition: xmlexp.cxx:2400
SAL_DLLPRIVATE void ImplExportSettings()
Definition: xmlexp.cxx:1043
WRITER
sal_uInt16 char * pName
constexpr sal_uInt16 XML_NAMESPACE_SVG
SvXMLExport(const css::uno::Reference< css::uno::XComponentContext > &xContext, OUString const &implementationName, sal_Int16 const eDefaultMeasureUnit, const enum::xmloff::token::XMLTokenEnum eClass, SvXMLExportFlags nExportFlag)
void AddAttributeASCII(sal_uInt16 nPrefix, const char *pName, const char *pValue)
Definition: xmlexp.cxx:898
constexpr sal_uInt16 XML_NAMESPACE_TABLE_EXT
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
constexpr sal_uInt16 XML_NAMESPACE_FO
int i
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
Definition: xmlexp.cxx:2007
constexpr sal_uInt16 XML_NAMESPACE_TEXT
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:49
OUString m_implementationName
Definition: xmlexp.hxx:120
tools::Long mDepth
counts depth (number of open elements/start tags)
Definition: xmlexp.cxx:274
static OUString GetMimeTypeForImageStream(const css::uno::Reference< css::io::XInputStream > &xInputStream)
virtual XMLPageExport * CreatePageExport()
Definition: xmlexp.cxx:1708
float u
unsigned char sal_Bool
virtual XMLFontAutoStylePool * CreateFontAutoStylePool()
Definition: xmlexp.cxx:1718
Object Value
std::unique_ptr< SvXMLExport_Impl > mpImpl
Definition: xmlexp.hxx:117
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:337
constexpr sal_uInt16 XML_NAMESPACE_GRDDL
OUString AddEmbeddedObject(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1913
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:2023
constexpr sal_uInt16 XML_NAMESPACE_XHTML
constexpr sal_uInt16 XML_NAMESPACE_XSD
css::uno::Type const & get()
void exportAllSettings(const css::uno::Sequence< css::beans::PropertyValue > &aProps, const OUString &rName) const
OUString getOriginURL() const
virtual void ExportScripts_()
Override this method to export the content of .
Definition: xmlexp.cxx:1466
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
virtual ~SvXMLExport() override
Definition: xmlexp.cxx:509
constexpr sal_uInt16 XML_NAMESPACE_DC
virtual void ExportMeta_()
Override this method to export the content of .
Definition: xmlexp.cxx:1439
OUString maSrcShellID
Definition: xmlexp.cxx:267
const uno::Reference< uno::XComponentContext > m_xContext
#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
virtual void exportDataStyles()
Definition: xmlexp.cxx:1823
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:1952
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
bool isIsoODF() const
void IgnorableWhitespace()
Definition: xmlexp.cxx:2217
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:2409
SvtModuleOptions::EFactory meModelType
Definition: xmlexp.hxx:162
constexpr sal_uInt16 XML_NAMESPACE_TABLE
void EndElement(sal_uInt16 nPrefix, enum::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
Definition: xmlexp.cxx:2178
virtual sal_Int32 GetDocumentSpecificSettings(::std::vector< SettingsGroup > &_out_rSettings)
returns the current document settings
Definition: xmlexp.cxx:1781
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:2414
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3424
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:576
virtual XMLShapeExport * CreateShapeExport()
Definition: xmlexp.cxx:1694
constexpr sal_uInt16 XML_NAMESPACE_REPORT
#define XML_PROGRESSREPEAT
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Handling of tokens in XML:
OUString const & GetSourceShellID() const
Definition: xmlexp.cxx:1429
#define SAL_INFO(area, stream)
void Characters(const OUString &rChars)
Definition: xmlexp.cxx:2156
rtl::Reference< SvXMLAutoStylePoolP > mxAutoStylePool
Definition: xmlexp.hxx:144
#define XMLERROR_FLAG_ERROR
Definition: xmlerror.hxx:36
bool mbOutlineStyleAsNormalListStyle
Definition: xmlexp.cxx:258
provides functionality for exporting a complete form layer.
css::uno::Reference< css::lang::XEventListener > mxEventListener
Definition: xmlexp.hxx:130
void ResetNamespaceMap()
Definition: xmlexp.cxx:1424
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlexp.hxx: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_OF
IMPRESS
virtual void ExportMasterStyles_()=0
Override this method to export the contents of .
sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const
Definition: xmlexp.cxx:1850
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1777
#define XMLERROR_CANCEL
Definition: xmlerror.hxx:74
OUString encodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
Definition: xmluconv.cxx:851
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:1893
#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:1786
bool mbExportTextNumberElement
Definition: xmlexp.cxx:278
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper
Definition: xmlexp.cxx:253
SvXMLElementExport(SvXMLExport &rExp, sal_uInt16 nPrefix, const char *pName, bool bIgnWSOutside, bool bIgnWSInside)
Definition: xmlexp.cxx:2423
#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:2321
constexpr sal_uInt16 XML_NAMESPACE_META
const XMLEventNameTranslation aStandardEventTable[]
a translation table for the events defined in the XEventsSupplier service (implemented in XMLEventExp...
css::uno::Reference< css::uno::XCurrentContext > NewFlagContext(const OUString &sName)
::std::stack< ::std::pair< std::unique_ptr< SvXMLNamespaceMap >, tools::Long > > mNamespaceMaps
stack of backed up namespace maps long: depth at which namespace map has been backed up into the stac...
Definition: xmlexp.cxx:272
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)
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
Definition: xmlexp.cxx:1817
constexpr sal_uInt16 XML_NAMESPACE_OOOW
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
#define XML_EMBEDDEDOBJECT_URL_BASE
Definition: xmlexp.cxx:120
bool hasScript() const
const OUString & GetPrefixByKey(sal_uInt16 nKey) const
SvXMLExportFlags getExportFlags() const
Definition: xmlexp.hxx:476
std::unique_ptr< XMLEventExport > mpEventExport
Definition: xmlexp.hxx:149
virtual void ExportFontDecls_()
Override this method to export the font declarations The default implementation will export the conte...
Definition: xmlexp.cxx:1499
constexpr sal_uInt16 XML_NAMESPACE_STYLE
bool writeOutlineStyleAsNormalListStyle() const
Definition: xmlexp.cxx:2285
sal_uInt16 nPos
void ExportEmbeddedOwnObject(css::uno::Reference< css::lang::XComponent > const &rComp)
Definition: xmlexp.cxx:2037
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
rtl::Reference< SvXMLAttributeList > mxAttrList
Definition: xmlexp.hxx:132
exports com.sun.star. uri
constexpr sal_uInt16 XML_NAMESPACE_FIELD
virtual void collectAutoStyles()
Definition: xmlexp.cxx:1704
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)