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>, 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)
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  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  return;
1512 
1513  // export (fill-)gradient-styles
1514  try
1515  {
1516  uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
1517  if( xGradient.is() )
1518  {
1519  XMLGradientStyleExport aGradientStyle( *this );
1520 
1521  if( xGradient->hasElements() )
1522  {
1523  const uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1524  for( const OUString& rStrName : aNamesSeq )
1525  {
1526  try
1527  {
1528  uno::Any aValue = xGradient->getByName( rStrName );
1529 
1530  aGradientStyle.exportXML( rStrName, aValue );
1531  }
1532  catch(const container::NoSuchElementException&)
1533  {
1534  }
1535  }
1536  }
1537  }
1538  }
1539  catch(const lang::ServiceNotRegisteredException&)
1540  {
1541  }
1542 
1543  // export (fill-)hatch-styles
1544  try
1545  {
1546  uno::Reference< container::XNameAccess > xHatch( xFact->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY );
1547  if( xHatch.is() )
1548  {
1549  XMLHatchStyleExport aHatchStyle( *this );
1550 
1551  if( xHatch->hasElements() )
1552  {
1553  const uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1554  for( const OUString& rStrName : aNamesSeq )
1555  {
1556  try
1557  {
1558  uno::Any aValue = xHatch->getByName( rStrName );
1559 
1560  aHatchStyle.exportXML( rStrName, aValue );
1561  }
1562  catch(const container::NoSuchElementException&)
1563  {}
1564  }
1565  }
1566  }
1567  }
1568  catch(const lang::ServiceNotRegisteredException&)
1569  {
1570  }
1571 
1572  // export (fill-)bitmap-styles
1573  try
1574  {
1575  uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
1576  if( xBitmap.is() )
1577  {
1578  if( xBitmap->hasElements() )
1579  {
1580  const uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1581  for( const OUString& rStrName : aNamesSeq )
1582  {
1583  try
1584  {
1585  uno::Any aValue = xBitmap->getByName( rStrName );
1586 
1587  XMLImageStyle::exportXML( rStrName, aValue, *this );
1588  }
1589  catch(const container::NoSuchElementException&)
1590  {
1591  }
1592  }
1593  }
1594  }
1595  }
1596  catch(const lang::ServiceNotRegisteredException&)
1597  {
1598  }
1599 
1600  // export transparency-gradient -styles
1601  try
1602  {
1603  uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY );
1604  if( xTransGradient.is() )
1605  {
1606  XMLTransGradientStyleExport aTransGradientstyle( *this );
1607 
1608  if( xTransGradient->hasElements() )
1609  {
1610  const uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1611  for( const OUString& rStrName : aNamesSeq )
1612  {
1613  try
1614  {
1615  uno::Any aValue = xTransGradient->getByName( rStrName );
1616 
1617  aTransGradientstyle.exportXML( rStrName, aValue );
1618  }
1619  catch(const container::NoSuchElementException&)
1620  {
1621  }
1622  }
1623  }
1624  }
1625  }
1626  catch(const lang::ServiceNotRegisteredException&)
1627  {
1628  }
1629 
1630  // export marker-styles
1631  try
1632  {
1633  uno::Reference< container::XNameAccess > xMarker( xFact->createInstance("com.sun.star.drawing.MarkerTable"), uno::UNO_QUERY );
1634  if( xMarker.is() )
1635  {
1636  XMLMarkerStyleExport aMarkerStyle( *this );
1637 
1638  if( xMarker->hasElements() )
1639  {
1640  const uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1641  for( const OUString& rStrName : aNamesSeq )
1642  {
1643  try
1644  {
1645  uno::Any aValue = xMarker->getByName( rStrName );
1646 
1647  aMarkerStyle.exportXML( rStrName, aValue );
1648  }
1649  catch(const container::NoSuchElementException&)
1650  {
1651  }
1652  }
1653  }
1654  }
1655  }
1656  catch(const lang::ServiceNotRegisteredException&)
1657  {
1658  }
1659 
1660  // export dash-styles
1661  try
1662  {
1663  uno::Reference< container::XNameAccess > xDashes( xFact->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
1664  if( xDashes.is() )
1665  {
1666  XMLDashStyleExport aDashStyle( *this );
1667 
1668  if( xDashes->hasElements() )
1669  {
1670  const uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1671  for( const OUString& rStrName : aNamesSeq )
1672  {
1673  try
1674  {
1675  uno::Any aValue = xDashes->getByName( rStrName );
1676 
1677  aDashStyle.exportXML( rStrName, aValue );
1678  }
1679  catch(const container::NoSuchElementException&)
1680  {
1681  }
1682  }
1683  }
1684  }
1685  }
1686  catch(const lang::ServiceNotRegisteredException&)
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  return;
1736 
1737  uno::Reference<container::XIndexAccess> xIndexAccess;
1738  xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1739  {
1740  // tdf#130559: don't export preview view data if active
1741  css::uno::ContextLayer layer(comphelper::NewFlagContext("NoPreviewData"));
1742  xIndexAccess = xViewDataSupplier->getViewData();
1743  }
1744  bool bAdd = false;
1745  uno::Any aAny;
1746  if(xIndexAccess.is() && xIndexAccess->hasElements() )
1747  {
1748  sal_Int32 nCount = xIndexAccess->getCount();
1749  for (sal_Int32 i = 0; i < nCount; i++)
1750  {
1751  aAny = xIndexAccess->getByIndex(i);
1752  uno::Sequence<beans::PropertyValue> aProps;
1753  if( aAny >>= aProps )
1754  {
1755  if( aProps.hasElements() )
1756  {
1757  bAdd = true;
1758  break;
1759  }
1760  }
1761  }
1762  }
1763 
1764  if( bAdd )
1765  {
1766  sal_Int32 nOldLength(rProps.getLength());
1767  rProps.realloc(nOldLength + 1);
1768  beans::PropertyValue aProp;
1769  aProp.Name = "Views";
1770  aProp.Value <<= xIndexAccess;
1771  rProps[nOldLength] = aProp;
1772  }
1773 }
1774 
1775 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1776 {
1777 }
1778 
1779 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1780 {
1781 }
1782 
1783 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::vector< SettingsGroup >& )
1784 {
1785  return 0;
1786 }
1787 
1788 void SvXMLExport::collectDataStyles(bool bFromUsedStyles)
1789 {
1790  Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetModel(), uno::UNO_QUERY);
1791  if (!xStyleFamiliesSupplier.is())
1792  return;
1793 
1794  Reference<container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
1795  if (!xStylesFamilies.is())
1796  return;
1797 
1798  Reference<container::XIndexAccess> xCellStyles(xStylesFamilies->getByName("CellStyles"), uno::UNO_QUERY);
1799  if (!xCellStyles.is())
1800  return;
1801 
1802  sal_Int32 nCount(xCellStyles->getCount());
1803  for (sal_Int32 i = 0; i < nCount; ++i)
1804  {
1805  Reference<style::XStyle> xStyle(xCellStyles->getByIndex(i), uno::UNO_QUERY);
1806  if (bFromUsedStyles && !xStyle->isInUse())
1807  continue;
1808 
1809  Reference<beans::XPropertySet> xCellProperties(xStyle, uno::UNO_QUERY);
1810  if (xCellProperties.is())
1811  {
1812  sal_Int32 nNumberFormat = 0;
1813  if (xCellProperties->getPropertyValue("NumberFormat") >>= nNumberFormat)
1814  addDataStyle(nNumberFormat);
1815  }
1816  }
1817 }
1818 
1819 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ )
1820 {
1821  if(mpNumExport)
1822  mpNumExport->SetUsed(nNumberFormat);
1823 }
1824 
1826 {
1827  if(mpNumExport)
1828  mpNumExport->Export(false);
1829 }
1830 
1832 {
1833  if(mpNumExport)
1834  mpNumExport->Export(true);
1835 
1836  if (mxFormExport.is())
1837  mxFormExport->exportAutoControlNumberStyles();
1838 }
1839 
1840 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ ) const
1841 {
1842  OUString sTemp;
1843  if(mpNumExport)
1844  sTemp = mpNumExport->GetStyleName(nNumberFormat);
1845  return sTemp;
1846 }
1847 
1848 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1849 {
1850 }
1851 
1852 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1853 {
1854  return ( mpNumExport != nullptr )
1855  ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1856 }
1857 
1858 OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName)
1859 {
1860  OUString sURL;
1861 
1862  Graphic aGraphic(rxGraphic);
1863  OUString aOriginURL = aGraphic.getOriginURL();
1864 
1865  if (!aOriginURL.isEmpty())
1866  {
1867  sURL = GetRelativeReference(aOriginURL);
1868  }
1869  else
1870  {
1871  if (mxGraphicStorageHandler.is())
1872  {
1874  sURL = mxGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutMimeType, rRequestedName);
1875  }
1876  }
1877  return sURL;
1878 }
1879 
1880 bool SvXMLExport::GetGraphicMimeTypeFromStream(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType)
1881 {
1882  if (mxGraphicStorageHandler.is())
1883  {
1884  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1885  if (xInputStream.is())
1886  {
1888  return true;
1889  }
1890  }
1891 
1892  return false;
1893 }
1894 
1895 bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic> const & rxGraphic)
1896 {
1899  {
1900  Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1901  if (xInputStream.is())
1902  {
1903  Graphic aGraphic(rxGraphic);
1904  if (aGraphic.getOriginURL().isEmpty()) // don't add the base64 if the origin URL is set (image is from an external URL)
1905  {
1906  XMLBase64Export aBase64Exp(*this);
1907  return aBase64Exp.exportOfficeBinaryDataElement(xInputStream);
1908  }
1909  }
1910  }
1911 
1912  return false;
1913 }
1914 
1915 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
1916 {
1917  OUString sRet;
1918  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1919  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1920  if (bSupportedURL && mxEmbeddedResolver.is())
1921  {
1922  sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(rEmbeddedObjectURL);
1923  }
1924  else
1925  sRet = GetRelativeReference( rEmbeddedObjectURL );
1926 
1927  return sRet;
1928 }
1929 
1930 bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
1931 {
1932  bool bRet = false;
1933  bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1934  rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1935  if (bSupportedURL && mxEmbeddedResolver.is())
1936  {
1938  if( xNA.is() )
1939  {
1940  Any aAny = xNA->getByName( rEmbeddedObjectURL );
1942  aAny >>= xIn;
1943  if( xIn.is() )
1944  {
1945  XMLBase64Export aBase64Exp( *this );
1946  bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1947  }
1948  }
1949  }
1950 
1951  return bRet;
1952 }
1953 
1955  const OUString& rName,
1956  bool *pEncoded ) const
1957 {
1958  return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
1959 }
1960 
1962 {
1963  if (!mpProgressBarHelper)
1964  {
1966 
1967  if (mxExportInfo.is())
1968  {
1969  uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1970  if (xPropertySetInfo.is())
1971  {
1972  OUString sProgressRange(XML_PROGRESSRANGE);
1973  OUString sProgressMax(XML_PROGRESSMAX);
1974  OUString sProgressCurrent(XML_PROGRESSCURRENT);
1975  OUString sRepeat(XML_PROGRESSREPEAT);
1976  if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1977  xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1978  xPropertySetInfo->hasPropertyByName(sProgressRange))
1979  {
1980  uno::Any aAny;
1981  sal_Int32 nProgressMax(0);
1982  sal_Int32 nProgressCurrent(0);
1983  sal_Int32 nProgressRange(0);
1984  aAny = mxExportInfo->getPropertyValue(sProgressRange);
1985  if (aAny >>= nProgressRange)
1986  mpProgressBarHelper->SetRange(nProgressRange);
1987  aAny = mxExportInfo->getPropertyValue(sProgressMax);
1988  if (aAny >>= nProgressMax)
1989  mpProgressBarHelper->SetReference(nProgressMax);
1990  aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
1991  if (aAny >>= nProgressCurrent)
1992  mpProgressBarHelper->SetValue(nProgressCurrent);
1993  }
1994  if (xPropertySetInfo->hasPropertyByName(sRepeat))
1995  {
1996  uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
1997  if (aAny.getValueType() == cppu::UnoType<bool>::get())
1998  mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1999  else {
2000  SAL_WARN("xmloff.core", "why is it no boolean?" );
2001  }
2002  }
2003  }
2004  }
2005  }
2006  return mpProgressBarHelper.get();
2007 }
2008 
2010 {
2011  if( nullptr == mpEventExport)
2012  {
2013  // create EventExport on demand
2014  mpEventExport.reset( new XMLEventExport(*this) );
2015 
2016  // and register standard handlers + names
2017  mpEventExport->AddHandler("StarBasic", std::make_unique<XMLStarBasicExportHandler>());
2018  mpEventExport->AddHandler("Script", std::make_unique<XMLScriptExportHandler>());
2019  mpEventExport->AddTranslationTable(aStandardEventTable);
2020  }
2021 
2022  return *mpEventExport;
2023 }
2024 
2026 {
2027  // image map export, create on-demand
2028  if( nullptr == mpImageMapExport )
2029  {
2030  mpImageMapExport.reset( new XMLImageMapExport(*this) );
2031  }
2032 
2033  return *mpImageMapExport;
2034 }
2035 
2036 // XUnoTunnel & co
2038 
2039 void SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent > const & rComp )
2040 {
2041  OUString sFilterService;
2042 
2043  Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2044  if( xServiceInfo.is() )
2045  {
2046  const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
2047  while( pEntry->sModelService )
2048  {
2049  OUString sModelService( pEntry->sModelService,
2050  pEntry->nModelServiceLen,
2051  RTL_TEXTENCODING_ASCII_US );
2052  if( xServiceInfo->supportsService( sModelService ) )
2053  {
2054  sFilterService = OUString( pEntry->sFilterService,
2055  pEntry->nFilterServiceLen,
2056  RTL_TEXTENCODING_ASCII_US );
2057  break;
2058  }
2059  pEntry++;
2060  }
2061  }
2062 
2063  SAL_WARN_IF( !sFilterService.getLength(), "xmloff.core", "no export filter for own object" );
2064 
2065  if( sFilterService.isEmpty() )
2066  return;
2067 
2068  Reference < XDocumentHandler > xHdl =
2070 
2071  Sequence < Any > aArgs( 1 );
2072  aArgs[0] <<= xHdl;
2073 
2074  Reference< document::XExporter > xExporter(
2075  m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(sFilterService, aArgs, m_xContext),
2076  UNO_QUERY);
2077  SAL_WARN_IF( !xExporter.is(), "xmloff.core", "can't instantiate export filter component for own object" );
2078  if( !xExporter.is() )
2079  return;
2080 
2081  xExporter->setSourceDocument( rComp );
2082 
2083  Reference<XFilter> xFilter( xExporter, UNO_QUERY );
2084 
2085  Sequence < PropertyValue > aMediaDesc( 0 );
2086  xFilter->filter( aMediaDesc );
2087 }
2088 
2089 OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
2090 {
2091  OUString sValue( rValue );
2092  // #i65474# handling of fragment URLs ("#...") is undefined
2093  // they are stored 'as is'
2094  uno::Reference< uri::XUriReference > xUriRef;
2095  if(!sValue.isEmpty() && sValue[0] != '#')
2096  {
2097  try
2098  {
2099  xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
2100  if( xUriRef.is() && !xUriRef->isAbsolute() )
2101  {
2102  //#i61943# relative URLs need special handling
2103  INetURLObject aTemp( mpImpl->msPackageURI );
2104  bool bWasAbsolute = false;
2105  sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
2106  }
2107  }
2108  catch(const uno::Exception&)
2109  {
2110  }
2111  }
2112  if( xUriRef.is() )//no conversion for empty values or for fragments
2113  {
2114  //conversion for matching schemes only
2115  if( xUriRef->getScheme() == mpImpl->msPackageURIScheme )
2116  {
2117  sValue = INetURLObject::GetRelURL( msOrigFileName, sValue );
2118  }
2119  }
2120  return sValue;
2121 }
2122 
2123 void SvXMLExport::StartElement(sal_uInt16 nPrefix,
2125  bool bIgnWSOutside )
2126 {
2127  StartElement(GetNamespaceMap_().GetQNameByKey( nPrefix,
2128  GetXMLToken(eName) ), bIgnWSOutside);
2129 }
2130 
2131 void SvXMLExport::StartElement(const OUString& rName,
2132  bool bIgnWSOutside )
2133 {
2134  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) != SvXMLErrorFlags::DO_NOTHING)
2135  {
2136  try
2137  {
2138  if( bIgnWSOutside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY))
2139  mxHandler->ignorableWhitespace( msWS );
2140  mxHandler->startElement( rName, GetXAttrList() );
2141  }
2142  catch (const SAXInvalidCharacterException& e)
2143  {
2144  Sequence<OUString> aPars { rName };
2145  SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2146  }
2147  catch (const SAXException& e)
2148  {
2149  Sequence<OUString> aPars { rName };
2151  aPars, e.Message, nullptr );
2152  }
2153  }
2154  ClearAttrList();
2155  ++mpImpl->mDepth; // increment nesting depth counter
2156 }
2157 
2158 void SvXMLExport::Characters(const OUString& rChars)
2159 {
2160  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2161  return;
2162 
2163  try
2164  {
2165  mxHandler->characters(rChars);
2166  }
2167  catch (const SAXInvalidCharacterException& e)
2168  {
2169  Sequence<OUString> aPars { rChars };
2170  SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2171  }
2172  catch (const SAXException& e)
2173  {
2174  Sequence<OUString> aPars { rChars };
2176  aPars, e.Message, nullptr );
2177  }
2178 }
2179 
2180 void SvXMLExport::EndElement(sal_uInt16 nPrefix,
2182  bool bIgnWSInside )
2183 {
2184  EndElement(GetNamespaceMap_().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
2185  bIgnWSInside);
2186 }
2187 
2188 void SvXMLExport::EndElement(const OUString& rName,
2189  bool bIgnWSInside )
2190 {
2191  // decrement nesting depth counter & (maybe) restore namespace map
2192  --mpImpl->mDepth;
2193  if (!mpImpl->mNamespaceMaps.empty() &&
2194  (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
2195  {
2196  mpNamespaceMap = std::move(mpImpl->mNamespaceMaps.top().first);
2197  mpImpl->mNamespaceMaps.pop();
2198  }
2199  SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() &&
2200  (mpImpl->mNamespaceMaps.top().second >= mpImpl->mDepth), "xmloff.core", "SvXMLExport: NamespaceMaps corrupted");
2201 
2202  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2203  return;
2204 
2205  try
2206  {
2207  if( bIgnWSInside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY))
2208  mxHandler->ignorableWhitespace( msWS );
2209  mxHandler->endElement( rName );
2210  }
2211  catch (const SAXException& e)
2212  {
2213  Sequence<OUString> aPars { rName };
2215  aPars, e.Message, nullptr );
2216  }
2217 }
2218 
2220 {
2221  if ((mnExportFlags & SvXMLExportFlags::PRETTY) != SvXMLExportFlags::PRETTY)
2222  return;
2223 
2224  if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING)
2225  return;
2226 
2227  try
2228  {
2229  mxHandler->ignorableWhitespace( msWS );
2230  }
2231  catch (const SAXException& e)
2232  {
2233  Sequence<OUString> aPars(0);
2235  aPars, e.Message, nullptr );
2236  }
2237 }
2238 
2240  sal_Int32 nId,
2241  const Sequence<OUString>& rMsgParams,
2242  const OUString& rExceptionMessage,
2243  const Reference<XLocator>& rLocator )
2244 {
2245  // allow multi-threaded access to the cancel() method
2246  static osl::Mutex aMutex;
2247  osl::MutexGuard aGuard(aMutex);
2248 
2249  // maintain error flags
2250  if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
2252  if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
2254  if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
2256 
2257  // create error list on demand
2258  if ( mpXMLErrors == nullptr )
2259  mpXMLErrors.reset( new XMLErrors() );
2260 
2261  // save error information
2262  mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
2263 }
2264 
2266  sal_Int32 nId,
2267  const Sequence<OUString>& rMsgParams)
2268 {
2269  SetError( nId, rMsgParams, "", nullptr );
2270 }
2271 
2273 {
2274  mxModel.clear();
2275  // Shapes in Writer cannot be named via context menu (#i51726#)
2277  mxEventListener.clear();
2278 }
2279 
2280 
2282 {
2283  return mpImpl->maInterfaceToIdentifierMapper;
2284 }
2285 
2286 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
2288 {
2289  return mpImpl->mbOutlineStyleAsNormalListStyle;
2290 }
2291 
2292 uno::Reference< embed::XStorage > const & SvXMLExport::GetTargetStorage() const
2293 {
2294  return mpImpl->mxTargetStorage;
2295 }
2296 
2298 {
2299  if( mpImpl )
2300  return mpImpl->maSaveOptions.GetODFSaneDefaultVersion();
2301 
2302  // fatal error, use current version as default
2304 }
2305 
2306 void
2308  sal_uInt16 const nLegacyPrefix, OUString const& rValue)
2309 {
2310  switch (getSaneDefaultVersion()) {
2311  case SvtSaveOptions::ODFSVER_011: // fall through
2312  case SvtSaveOptions::ODFSVER_010: break;
2313  default: // ODF 1.2: xml:id
2315  }
2316  // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
2317  // backward compatibility: in ODF 1.2 write _both_ id attrs
2318  AddAttribute(nLegacyPrefix, XML_ID, rValue);
2319  // FIXME: this function simply assumes that rValue is unique
2320 }
2321 
2322 void
2323 SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
2324 {
2325  // check version >= 1.2
2326  switch (getSaneDefaultVersion()) {
2327  case SvtSaveOptions::ODFSVER_011: // fall through
2328  case SvtSaveOptions::ODFSVER_010: return;
2329  default: break;
2330  }
2331  const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2332  uno::UNO_QUERY);
2333 //FIXME not yet...
2334  if ( !xMeta.is() )
2335  return;
2336 
2337  const beans::StringPair mdref( xMeta->getMetadataReference() );
2338  if ( mdref.Second.isEmpty() )
2339  return;
2340 
2341  const OUString streamName = mpImpl->mStreamName;
2342  if ( !streamName.isEmpty() )
2343  {
2344  if ( streamName == mdref.First )
2345  {
2346  AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2347  }
2348  else
2349  {
2350  SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name");
2351  }
2352  }
2353  else
2354  {
2355  // FIXME: this is ugly
2356  // there is no stream name (e.g. XSLT, flat-xml format)!
2357  // but how do we ensure uniqueness in this case?
2358  // a) just omit styles.xml ids -- they are unlikely anyway...
2359  // b) somehow find out whether we are currently exporting styles
2360  // or content, and prefix "s" or "c" => unique
2361  if ( mdref.First == "content.xml" )
2362  {
2363  AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2364  }
2365  else
2366  {
2367  SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id");
2368  }
2369  }
2370 }
2371 
2372 void
2374  uno::Reference<text::XTextContent> const & i_xTextContent)
2375 {
2376  // check version >= 1.2
2377  switch (getSaneDefaultVersion()) {
2378  case SvtSaveOptions::ODFSVER_011: // fall through
2379  case SvtSaveOptions::ODFSVER_010: return;
2380  default: break;
2381  }
2382 
2383  const uno::Reference<rdf::XMetadatable> xMeta(
2384  i_xTextContent, uno::UNO_QUERY);
2385  if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty())
2386  {
2387  return; // no xml:id => no RDFa
2388  }
2389 
2390  if (!mpImpl->mpRDFaHelper)
2391  {
2392  mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
2393  }
2394  mpImpl->mpRDFaHelper->AddRDFa(xMeta);
2395 }
2396 
2398 {
2399  return mpImpl->mbExportTextNumberElement;
2400 }
2401 
2403 {
2404  // if the null date has already been set, don't set it again (performance)
2405  if (!mpImpl->mbNullDateInitialized)
2406  mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel());
2407 
2408  return mpImpl->mbNullDateInitialized;
2409 }
2410 
2411 OUString const & SvXMLExport::GetImageFilterName() const
2412 {
2413  return msImgFilterName;
2414 }
2415 
2417  const sal_uInt16 nPrefixKey,
2418  const OUString& rLName,
2419  const bool bIgnoreWhitespaceOutside )
2420 {
2421  maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
2422  mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside);
2423 }
2424 
2426  SvXMLExport& rExp,
2427  sal_uInt16 nPrefixKey,
2428  const char *pLName,
2429  bool bIWSOutside,
2430  bool bIWSInside )
2431  : mrExport( rExp )
2432  , maElementName()
2433  , mbIgnoreWhitespaceInside( bIWSInside )
2434  , mbDoSomething( true )
2435 {
2436  const OUString sLName( OUString::createFromAscii( pLName ) );
2437  StartElement( nPrefixKey, sLName, bIWSOutside );
2438 }
2439 
2441  SvXMLExport& rExp,
2442  sal_uInt16 nPrefixKey,
2443  const OUString& rLName,
2444  bool bIWSOutside,
2445  bool bIWSInside )
2446  : mrExport( rExp )
2447  , maElementName()
2448  , mbIgnoreWhitespaceInside( bIWSInside )
2449  , mbDoSomething( true )
2450 {
2451  StartElement( nPrefixKey, rLName, bIWSOutside );
2452 }
2453 
2455  SvXMLExport& rExp,
2456  sal_uInt16 nPrefixKey,
2457  enum XMLTokenEnum eLName,
2458  bool bIWSOutside,
2459  bool bIWSInside )
2460  : mrExport( rExp )
2461  , maElementName()
2462  , mbIgnoreWhitespaceInside( bIWSInside )
2463  , mbDoSomething( true )
2464 {
2465  StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2466 }
2467 
2469  SvXMLExport& rExp,
2470  bool bDoSth,
2471  sal_uInt16 nPrefixKey,
2472  enum XMLTokenEnum eLName,
2473  bool bIWSOutside,
2474  bool bIWSInside )
2475  : mrExport( rExp )
2476  , maElementName()
2477  , mbIgnoreWhitespaceInside( bIWSInside )
2478  , mbDoSomething( bDoSth )
2479 {
2480  if ( mbDoSomething )
2481  StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside );
2482 }
2483 
2485  SvXMLExport& rExp,
2486  const OUString& rQName,
2487  bool bIWSOutside,
2488  bool bIWSInside )
2489  : mrExport( rExp )
2490  , maElementName()
2491  , mbIgnoreWhitespaceInside( bIWSInside )
2492  , mbDoSomething( true )
2493 {
2494  maElementName = rQName;
2495  rExp.StartElement( rQName, bIWSOutside );
2496 }
2497 
2499 {
2500  if ( mbDoSomething )
2501  {
2503  }
2504 }
2505 
2506 /* 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:2292
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:1215
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlexp.cxx:2281
constexpr sal_uInt16 XML_NAMESPACE_DRAW_EXT
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:2272
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
virtual void exportAutoDataStyles()
Definition: xmlexp.cxx:1831
#define XML_USEPRETTYPRINTING
Definition: xmlexp.cxx:117
OUString msPackageURI
Definition: xmlexp.cxx:255
constexpr sal_uInt16 XML_NAMESPACE_OOOC
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)
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: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:2373
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:2397
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:1691
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:1730
bool AddEmbeddedObjectAsBase64(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1930
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:1234
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:2307
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_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: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:1848
virtual void EndElement(const bool i_bIgnoreWhitespace)=0
#define SERVICE_MAP_ENTRY(app)
Definition: xmlexp.cxx:134
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlexp.cxx:1961
SchXMLExportHelper * CreateChartExport()
Definition: xmlexp.cxx:1715
#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:1775
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:2123
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:2089
virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat=false) const
Definition: xmlexp.cxx:1840
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
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:1858
#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
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_CONFIG
bool GetGraphicMimeTypeFromStream(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType)
Definition: xmlexp.cxx:1880
constexpr sal_uInt16 XML_NAMESPACE_XML
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
Definition: xmlexp.cxx:2297
OUString sPrefix
UNO3_GETIMPLEMENTATION_IMPL(SvXMLExport)
bool SetNullDateOnUnitConverter()
set null date from model to unit converter, if not already done
Definition: xmlexp.cxx:2402
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:2009
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
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
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:305
constexpr sal_uInt16 XML_NAMESPACE_GRDDL
OUString AddEmbeddedObject(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1915
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:2025
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:1468
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:1441
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:1825
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:1954
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:2219
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:2411
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:2180
virtual sal_Int32 GetDocumentSpecificSettings(::std::vector< SettingsGroup > &_out_rSettings)
returns the current document settings
Definition: xmlexp.cxx:1783
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:2416
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:3378
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:576
virtual XMLShapeExport * CreateShapeExport()
Definition: xmlexp.cxx:1696
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:1431
#define SAL_INFO(area, stream)
void Characters(const OUString &rChars)
Definition: xmlexp.cxx:2158
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:1426
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:1852
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1779
#define XMLERROR_CANCEL
Definition: xmlerror.hxx:74
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:1895
#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:1788
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:2425
#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:2323
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)
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:1819
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:1501
constexpr sal_uInt16 XML_NAMESPACE_STYLE
bool writeOutlineStyleAsNormalListStyle() const
Definition: xmlexp.cxx:2287
sal_uInt16 nPos
void ExportEmbeddedOwnObject(css::uno::Reference< css::lang::XComponent > const &rComp)
Definition: xmlexp.cxx:2039
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: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)