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