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 constexpr 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 constexpr 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 static constexpr OUStringLiteral aPreferredPrefix(u"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 while( nKey != USHRT_MAX )
880 {
881 sPrefix = aPreferredPrefix + OUString::number(++n);
883 }
884
885 if (mpImpl->mNamespaceMaps.empty()
886 || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
887 {
888 // top was created for lower depth... need a new namespace map!
889 auto pNew = new SvXMLNamespaceMap( *mpNamespaceMap );
890 mpImpl->mNamespaceMaps.push(
891 ::std::make_pair(std::move(mpNamespaceMap), mpImpl->mDepth) );
892 mpNamespaceMap.reset( pNew );
893 }
894
895 // add the namespace to the map and as attribute
896 mpNamespaceMap->Add( sPrefix, i_rNamespace );
897 AddAttribute( GetXMLToken(XML_XMLNS) + ":" + sPrefix, i_rNamespace );
898 }
899 else
900 {
901 // If there is a prefix for the namespace, reuse that.
903 }
904 return sPrefix;
905}
906
907void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
908 const OUString& rValue )
909{
910 AddAttribute(GetNamespaceMap_().GetQNameByKey(nPrefixKey, rName), rValue);
911}
912
913void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
914 enum XMLTokenEnum eName,
915 const OUString& rValue )
916{
917 AddAttribute(nPrefixKey, GetXMLToken(eName), rValue);
918}
919
920void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
921 enum XMLTokenEnum eName,
922 enum XMLTokenEnum eValue)
923{
924 AddAttribute(nPrefixKey, eName, GetXMLToken(eValue));
925}
926
927void SvXMLExport::AddAttribute( const OUString& rQName,
928 const OUString& rValue )
929{
930 mxAttrList->AddAttribute(
931 rQName,
932 rValue );
933}
934
935void SvXMLExport::AddAttribute( const OUString& rQName,
937{
938 AddAttribute(rQName, GetXMLToken(eValue));
939}
940
941void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
942 const css::lang::Locale& rLocale, bool bWriteEmpty )
943{
944 if (rLocale.Variant.isEmpty())
945 {
946 // Per convention The BCP 47 string is always stored in Variant, if
947 // that is empty we have a plain language-country combination, no need
948 // to convert to LanguageTag first. Also catches the case of empty
949 // locale denoting system locale.
950 xmloff::token::XMLTokenEnum eLanguage, eCountry;
951 eLanguage = XML_LANGUAGE;
952 eCountry = XML_COUNTRY;
953 if (bWriteEmpty || !rLocale.Language.isEmpty())
954 AddAttribute( nPrefix, eLanguage, rLocale.Language);
955 if (bWriteEmpty || !rLocale.Country.isEmpty())
956 AddAttribute( nPrefix, eCountry, rLocale.Country);
957 }
958 else
959 {
960 LanguageTag aLanguageTag( rLocale);
961 AddLanguageTagAttributes( nPrefix, nPrefixRfc, aLanguageTag, bWriteEmpty);
962 }
963}
964
965void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
966 const LanguageTag& rLanguageTag, bool bWriteEmpty )
967{
968 if (rLanguageTag.isIsoODF())
969 {
970 if (bWriteEmpty || !rLanguageTag.isSystemLocale())
971 {
972 AddAttribute( nPrefix, XML_LANGUAGE, rLanguageTag.getLanguage());
974 AddAttribute( nPrefix, XML_SCRIPT, rLanguageTag.getScript());
975 if (bWriteEmpty || !rLanguageTag.getCountry().isEmpty())
976 AddAttribute( nPrefix, XML_COUNTRY, rLanguageTag.getCountry());
977 }
978 }
979 else
980 {
982 AddAttribute( nPrefixRfc, XML_RFC_LANGUAGE_TAG, rLanguageTag.getBcp47());
983 // Also in case of non-pure-ISO tag store best matching fo: attributes
984 // for consumers not handling *:rfc-language-tag, ensuring that only
985 // valid ISO codes are stored. Here the bWriteEmpty parameter has no
986 // meaning.
987 OUString aLanguage, aScript, aCountry;
988 rLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
989 if (!aLanguage.isEmpty())
990 {
991 AddAttribute( nPrefix, XML_LANGUAGE, aLanguage);
992 if (!aScript.isEmpty() && getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
993 AddAttribute( nPrefix, XML_SCRIPT, aScript);
994 if (!aCountry.isEmpty())
995 AddAttribute( nPrefix, XML_COUNTRY, aCountry);
996 }
997 }
998}
999
1000void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1001{
1002 if( xAttrList.is())
1003 mxAttrList->AppendAttributeList( xAttrList );
1004}
1005
1007{
1008 mxAttrList->Clear();
1009}
1010
1011#ifdef DBG_UTIL
1013{
1014 SAL_WARN_IF( mxAttrList->getLength(), "xmloff.core", "XMLExport::CheckAttrList: list is not empty" );
1015}
1016#endif
1017
1019{
1020 CheckAttrList();
1021
1022 ExportMeta_();
1023}
1024
1026{
1027 CheckAttrList();
1028
1029 ::std::vector< SettingsGroup > aSettings;
1030 sal_Int32 nSettingsCount = 0;
1031
1032 // view settings
1033 uno::Sequence< beans::PropertyValue > aViewSettings;
1034 GetViewSettingsAndViews( aViewSettings );
1035 aSettings.emplace_back( XML_VIEW_SETTINGS, aViewSettings );
1036 nSettingsCount += aViewSettings.getLength();
1037
1038 // configuration settings
1039 uno::Sequence<beans::PropertyValue> aConfigSettings;
1040 GetConfigurationSettings( aConfigSettings );
1041 aSettings.emplace_back( XML_CONFIGURATION_SETTINGS, aConfigSettings );
1042 nSettingsCount += aConfigSettings.getLength();
1043
1044 // any document specific settings
1045 nSettingsCount += GetDocumentSpecificSettings( aSettings );
1046
1047 {
1048 SvXMLElementExport aElem( *this,
1049 nSettingsCount != 0,
1051 true, true );
1052
1053 SettingsExportFacade aSettingsExportContext( *this );
1054 XMLSettingsExportHelper aSettingsExportHelper( aSettingsExportContext );
1055
1056 for (auto const& settings : aSettings)
1057 {
1058 if ( !settings.aSettings.hasElements() )
1059 continue;
1060
1061 const OUString& sSettingsName( GetXMLToken( settings.eGroupName ) );
1062 OUString sQName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO, sSettingsName );
1063 aSettingsExportHelper.exportAllSettings( settings.aSettings, sQName );
1064 }
1065 }
1066}
1067
1069{
1070 CheckAttrList();
1071
1072 {
1073 // <style:styles>
1075 true, true );
1076
1077 ExportStyles_( false );
1078 }
1079
1080 // transfer style names (+ families) TO other components (if appropriate)
1082 return;
1083
1084 static constexpr OUStringLiteral sStyleNames( u"StyleNames" );
1085 static constexpr OUStringLiteral sStyleFamilies( u"StyleFamilies" );
1086 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1087 if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) )
1088 {
1089 Sequence<sal_Int32> aStyleFamilies;
1090 Sequence<OUString> aStyleNames;
1091 mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
1092 mxExportInfo->setPropertyValue( sStyleNames, Any( aStyleNames ) );
1093 mxExportInfo->setPropertyValue( sStyleFamilies,
1094 Any( aStyleFamilies ) );
1095 }
1096}
1097
1099{
1100 // transfer style names (+ families) FROM other components (if appropriate)
1101 OUString sStyleNames( "StyleNames" );
1102 OUString sStyleFamilies( "StyleFamilies" );
1104 && mxExportInfo.is()
1105 && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
1106 && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
1107 {
1108 Sequence<sal_Int32> aStyleFamilies;
1109 mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies;
1110 Sequence<OUString> aStyleNames;
1111 mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames;
1112 mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames );
1113 }
1114
1115 {
1116 // <style:automatic-styles>
1118 XML_AUTOMATIC_STYLES, true, true );
1119
1121 }
1122}
1123
1125{
1126 // <style:master-styles>
1128 true, true );
1129
1131}
1132
1134{
1135 CheckAttrList();
1136
1137 {
1139 true, true );
1140 {
1141 XMLTokenEnum eClass = meClass;
1142 if( XML_TEXT_GLOBAL == eClass )
1143 {
1145 GetXMLToken( XML_TRUE ) );
1146 eClass = XML_TEXT;
1147 }
1148 if ( XML_GRAPHICS == eClass )
1149 eClass = XML_DRAWING;
1150 // <office:body ...>
1153 XML_NAMESPACE_OFFICE, eClass,
1154 true, true );
1155
1157 }
1158 }
1159}
1160
1162{
1163}
1164
1165static void
1166lcl_AddGrddl(SvXMLExport const & rExport, const SvXMLExportFlags /*nExportMode*/)
1167{
1168 // check version >= 1.2
1169 switch (rExport.getSaneDefaultVersion()) {
1170 case SvtSaveOptions::ODFSVER_011: // fall through
1171 case SvtSaveOptions::ODFSVER_010: return;
1172 default: break;
1173 }
1174
1175 // #i115030#: disabled, the XSLT is not finished, and not available via HTTP
1176#if 0
1177 if (SvXMLExportFlags::SETTINGS != nExportMode) // meta, content, styles
1178 {
1180 OUString("http://FIXME") );
1181 }
1182#endif
1183}
1184
1186{
1187 uno::Reference< embed::XEncryptionProtectedSource2 > xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
1188
1189 if (xEncr.is() && xEncr->hasEncryptionData() && mxExtHandler.is())
1190 {
1191 mxExtHandler->comment(OStringToOUString(comphelper::xml::makeXMLChaff(), RTL_TEXTENCODING_ASCII_US));
1192 }
1193}
1194
1196{
1197 char const* pVersion(nullptr);
1198 switch (getSaneDefaultVersion())
1199 {
1200 case SvtSaveOptions::ODFSVER_013_EXTENDED: [[fallthrough]];
1201 case SvtSaveOptions::ODFSVER_013: pVersion = "1.3"; break;
1202 case SvtSaveOptions::ODFSVER_012_EXTENDED: [[fallthrough]];
1203 case SvtSaveOptions::ODFSVER_012_EXT_COMPAT: [[fallthrough]];
1204 case SvtSaveOptions::ODFSVER_012: pVersion = "1.2"; break;
1205 case SvtSaveOptions::ODFSVER_011: pVersion = "1.1"; break;
1206 case SvtSaveOptions::ODFSVER_010: break;
1207
1208 default:
1209 assert(!"xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1210 }
1211 return pVersion;
1212}
1213
1215{
1216 bool bOwnGraphicResolver = false;
1217 bool bOwnEmbeddedResolver = false;
1218
1220 {
1221 Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
1222 if( xFactory.is() )
1223 {
1224 try
1225 {
1226 if (!mxGraphicStorageHandler.is())
1227 {
1228 mxGraphicStorageHandler.set(xFactory->createInstance( "com.sun.star.document.ExportGraphicStorageHandler"), UNO_QUERY);
1229 bOwnGraphicResolver = mxGraphicStorageHandler.is();
1230 }
1231
1232 if( !mxEmbeddedResolver.is() )
1233 {
1235 xFactory->createInstance( "com.sun.star.document.ExportEmbeddedObjectResolver" ), UNO_QUERY);
1236 bOwnEmbeddedResolver = mxEmbeddedResolver.is();
1237 }
1238 }
1239 catch(const css::uno::Exception&)
1240 {
1241 }
1242 }
1243 }
1245 {
1246 try
1247 {
1248 static ::comphelper::PropertyMapEntry const aInfoMap[] =
1249 {
1250 { OUString("Class"), 0,
1252 PropertyAttribute::MAYBEVOID, 0},
1253 };
1254 Reference< XPropertySet > xConvPropSet(
1255 ::comphelper::GenericPropertySet_CreateInstance(
1256 new ::comphelper::PropertySetInfo( aInfoMap ) ) );
1257
1258 xConvPropSet->setPropertyValue( "Class", Any(GetXMLToken( eClass )) );
1259
1260 Reference< XPropertySet > xPropSet =
1261 mxExportInfo.is()
1263 xConvPropSet )
1264 : xConvPropSet;
1265
1266 Sequence<Any> aArgs{ Any(mxHandler), Any(xPropSet), Any(mxModel) };
1267 // get filter component
1268 Reference< xml::sax::XDocumentHandler > xTmpDocHandler(
1269 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.Oasis2OOoTransformer", aArgs, m_xContext),
1270 UNO_QUERY);
1271 SAL_WARN_IF(!xTmpDocHandler.is(), "xmloff.core", "can't instantiate OASIS transformer component" );
1272 if( xTmpDocHandler.is() )
1273 {
1274 mxHandler = xTmpDocHandler;
1275 mxExtHandler.set( mxHandler, UNO_QUERY );
1276 }
1277 }
1278 catch(const css::uno::Exception&)
1279 {
1280 }
1281 }
1282
1283 mxHandler->startDocument();
1284
1286
1287 // <office:document ...>
1288 CheckAttrList();
1289
1290 // namespace attributes
1291 // ( The namespace decls should be first attributes in the element;
1292 // some faulty XML parsers (JAXP1.1) have a problem with this,
1293 // also it's more elegant )
1294 sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
1295 while( USHRT_MAX != nPos )
1296 {
1297 mxAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
1298 mpNamespaceMap->GetNameByKey( nPos ) );
1299 nPos = mpNamespaceMap->GetNextKey( nPos );
1300 }
1301
1302 // office:version = ...
1303 const char*const pVersion = GetODFVersionAttributeValue();
1304
1305 if (pVersion)
1306 {
1308 OUString::createFromAscii(pVersion) );
1309 }
1310
1311 {
1312 enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
1314
1315 lcl_AddGrddl(*this, nExportMode);
1316
1317 if( SvXMLExportFlags::META == nExportMode )
1318 {
1319 // export only meta
1320 eRootService = XML_DOCUMENT_META;
1321 }
1322 else if ( SvXMLExportFlags::SETTINGS == nExportMode )
1323 {
1324 // export only settings
1325 eRootService = XML_DOCUMENT_SETTINGS;
1326 }
1327 else if( SvXMLExportFlags::STYLES == nExportMode )
1328 {
1329 // export only styles
1330 eRootService = XML_DOCUMENT_STYLES;
1331 }
1332 else if( SvXMLExportFlags::CONTENT == nExportMode )
1333 {
1334 // export only content
1335 eRootService = XML_DOCUMENT_CONTENT;
1336 }
1337 else
1338 {
1339 // the god'ol one4all element
1340 eRootService = XML_DOCUMENT;
1341 // office:mimetype = ... (only for stream containing the content)
1342 if( eClass != XML_TOKEN_INVALID )
1343 {
1344 OUString aTmp = "application/vnd.oasis.opendocument." + GetXMLToken( eClass );
1346 }
1347 }
1348
1349 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, true, true );
1350
1351 // meta information
1354
1355 // settings
1358
1359 // scripts
1362
1363 // font declarations
1366
1367 // styles
1370
1371 // autostyles
1374
1375 // masterstyles
1378
1379 // content
1382 }
1383
1384 mxHandler->endDocument();
1385
1386 if( bOwnGraphicResolver )
1387 {
1388 uno::Reference<XComponent> xComp(mxGraphicStorageHandler, UNO_QUERY);
1389 xComp->dispose();
1390 }
1391
1392 if( bOwnEmbeddedResolver )
1393 {
1394 Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
1395 xComp->dispose();
1396 }
1397
1398 return ERRCODE_NONE;
1399}
1400
1402{
1403 mpNamespaceMap->Clear();
1404}
1405
1406OUString const & SvXMLExport::GetSourceShellID() const
1407{
1408 return mpImpl->maSrcShellID;
1409}
1410
1412{
1413 return mpImpl->maDestShellID;
1414}
1415
1417{
1418 OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
1419 Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
1420 UNO_QUERY);
1421 if (xDocPropsSupplier.is()) {
1422 Reference<XDocumentProperties> xDocProps(
1423 xDocPropsSupplier->getDocumentProperties());
1424 if (!xDocProps.is()) throw;
1425 // update generator here
1426 xDocProps->setGenerator(generator);
1427 rtl::Reference<SvXMLMetaExport> pMeta = new SvXMLMetaExport(*this, xDocProps);
1428 pMeta->Export();
1429 } else {
1430 // office:meta
1432 true, true );
1433 {
1434 // BM: #i60323# export generator even if xInfoProp is empty (which is the
1435 // case for charts). The generator does not depend on xInfoProp
1437 true, true );
1438 Characters(generator);
1439 }
1440 }
1441}
1442
1444{
1445 SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, true, true );
1446
1447 // export Basic macros (only for FlatXML)
1449 {
1450 OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) + ":Basic" );
1452
1453 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, true, true );
1454
1455 // initialize Basic
1456 if ( mxModel.is() )
1457 {
1458 Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
1459 if ( xPSet.is() )
1460 xPSet->getPropertyValue("BasicLibraries");
1461 }
1462
1463 Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
1464 Reference< document::XXMLBasicExporter > xExporter = document::XMLOasisBasicExporter::createWithHandler( m_xContext, xHdl );
1465
1466 xExporter->setSourceDocument( mxModel );
1467 Sequence< PropertyValue > aMediaDesc( 0 );
1468 xExporter->filter( aMediaDesc );
1469 }
1470
1471 // export document events
1472 Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
1473 GetEventExport().Export( xEvents );
1474}
1475
1477{
1478 if( mxFontAutoStylePool.is() )
1479 mxFontAutoStylePool->exportXML();
1480}
1481
1483{
1484 uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
1485 if( !xFact.is())
1486 return;
1487
1488 // export (fill-)gradient-styles
1489 try
1490 {
1491 uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
1492 if( xGradient.is() )
1493 {
1494 XMLGradientStyleExport aGradientStyle( *this );
1495
1496 if( xGradient->hasElements() )
1497 {
1498 const uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1499 for( const OUString& rStrName : aNamesSeq )
1500 {
1501 try
1502 {
1503 uno::Any aValue = xGradient->getByName( rStrName );
1504
1505 aGradientStyle.exportXML( rStrName, aValue );
1506 }
1507 catch(const container::NoSuchElementException&)
1508 {
1509 }
1510 }
1511 }
1512 }
1513 }
1514 catch(const lang::ServiceNotRegisteredException&)
1515 {
1516 }
1517
1518 // export (fill-)hatch-styles
1519 try
1520 {
1521 uno::Reference< container::XNameAccess > xHatch( xFact->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY );
1522 if( xHatch.is() )
1523 {
1524 XMLHatchStyleExport aHatchStyle( *this );
1525
1526 if( xHatch->hasElements() )
1527 {
1528 const uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1529 for( const OUString& rStrName : aNamesSeq )
1530 {
1531 try
1532 {
1533 uno::Any aValue = xHatch->getByName( rStrName );
1534
1535 aHatchStyle.exportXML( rStrName, aValue );
1536 }
1537 catch(const container::NoSuchElementException&)
1538 {}
1539 }
1540 }
1541 }
1542 }
1543 catch(const lang::ServiceNotRegisteredException&)
1544 {
1545 }
1546
1547 // export (fill-)bitmap-styles
1548 try
1549 {
1550 uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
1551 if( xBitmap.is() )
1552 {
1553 if( xBitmap->hasElements() )
1554 {
1555 const uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1556 for( const OUString& rStrName : aNamesSeq )
1557 {
1558 try
1559 {
1560 uno::Any aValue = xBitmap->getByName( rStrName );
1561
1562 XMLImageStyle::exportXML( rStrName, aValue, *this );
1563 }
1564 catch(const container::NoSuchElementException&)
1565 {
1566 }
1567 }
1568 }
1569 }
1570 }
1571 catch(const lang::ServiceNotRegisteredException&)
1572 {
1573 }
1574
1575 // export transparency-gradient -styles
1576 try
1577 {
1578 uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY );
1579 if( xTransGradient.is() )
1580 {
1581 XMLTransGradientStyleExport aTransGradientstyle( *this );
1582
1583 if( xTransGradient->hasElements() )
1584 {
1585 const uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1586 for( const OUString& rStrName : aNamesSeq )
1587 {
1588 try
1589 {
1590 uno::Any aValue = xTransGradient->getByName( rStrName );
1591
1592 aTransGradientstyle.exportXML( rStrName, aValue );
1593 }
1594 catch(const container::NoSuchElementException&)
1595 {
1596 }
1597 }
1598 }
1599 }
1600 }
1601 catch(const lang::ServiceNotRegisteredException&)
1602 {
1603 }
1604
1605 // export marker-styles
1606 try
1607 {
1608 uno::Reference< container::XNameAccess > xMarker( xFact->createInstance("com.sun.star.drawing.MarkerTable"), uno::UNO_QUERY );
1609 if( xMarker.is() )
1610 {
1611 XMLMarkerStyleExport aMarkerStyle( *this );
1612
1613 if( xMarker->hasElements() )
1614 {
1615 const uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1616 for( const OUString& rStrName : aNamesSeq )
1617 {
1618 try
1619 {
1620 uno::Any aValue = xMarker->getByName( rStrName );
1621
1622 aMarkerStyle.exportXML( rStrName, aValue );
1623 }
1624 catch(const container::NoSuchElementException&)
1625 {
1626 }
1627 }
1628 }
1629 }
1630 }
1631 catch(const lang::ServiceNotRegisteredException&)
1632 {
1633 }
1634
1635 // export dash-styles
1636 try
1637 {
1638 uno::Reference< container::XNameAccess > xDashes( xFact->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
1639 if( xDashes.is() )
1640 {
1641 XMLDashStyleExport aDashStyle( *this );
1642
1643 if( xDashes->hasElements() )
1644 {
1645 const uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1646 for( const OUString& rStrName : aNamesSeq )
1647 {
1648 try
1649 {
1650 uno::Any aValue = xDashes->getByName( rStrName );
1651
1652 aDashStyle.exportXML( rStrName, aValue );
1653 }
1654 catch(const container::NoSuchElementException&)
1655 {
1656 }
1657 }
1658 }
1659 }
1660 }
1661 catch(const lang::ServiceNotRegisteredException&)
1662 {
1663 }
1664}
1665
1667{
1668 return new XMLTextParagraphExport( *this, *GetAutoStylePool() );
1669}
1670
1672{
1673 return new XMLShapeExport(*this);
1674}
1675
1677{
1678 return new SvXMLAutoStylePoolP(*this);
1679}
1680
1682{
1683}
1684
1686{
1687 return new XMLPageExport( *this );
1688}
1689
1691{
1692// WASM_CHART change
1693// TODO: With Chart extracted this cannot really happen since
1694// no Chart could've been added at all
1695#if !ENABLE_WASM_STRIP_CHART
1696 return new SchXMLExportHelper(*this, *GetAutoStylePool());
1697#else
1698 return nullptr;
1699#endif
1700}
1701
1703{
1704 return new XMLFontAutoStylePool( *this );
1705}
1706
1708{
1709 return new xmloff::OFormLayerXMLExport(*this);
1710}
1711
1712void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1713{
1714 GetViewSettings(rProps);
1715 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1716 if(!xViewDataSupplier.is())
1717 return;
1718
1719 uno::Reference<container::XIndexAccess> xIndexAccess;
1720 xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1721 {
1722 // tdf#130559: don't export preview view data if active
1723 static constexpr OUStringLiteral sNoPreviewData = u"NoPreviewData";
1724 css::uno::ContextLayer layer(comphelper::NewFlagContext(sNoPreviewData));
1725 xIndexAccess = xViewDataSupplier->getViewData();
1726 }
1727 bool bAdd = false;
1728 uno::Any aAny;
1729 if(xIndexAccess.is() && xIndexAccess->hasElements() )
1730 {
1731 sal_Int32 nCount = xIndexAccess->getCount();
1732 for (sal_Int32 i = 0; i < nCount; i++)
1733 {
1734 aAny = xIndexAccess->getByIndex(i);
1735 uno::Sequence<beans::PropertyValue> aProps;
1736 if( aAny >>= aProps )
1737 {
1738 if( aProps.hasElements() )
1739 {
1740 bAdd = true;
1741 break;
1742 }
1743 }
1744 }
1745 }
1746
1747 if( bAdd )
1748 {
1749 sal_Int32 nOldLength(rProps.getLength());
1750 rProps.realloc(nOldLength + 1);
1751 rProps.getArray()[nOldLength] = comphelper::makePropertyValue("Views", xIndexAccess);
1752 }
1753}
1754
1755void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1756{
1757}
1758
1759void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1760{
1761}
1762
1763sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::vector< SettingsGroup >& )
1764{
1765 return 0;
1766}
1767
1768void SvXMLExport::collectDataStyles(bool bFromUsedStyles)
1769{
1770 Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetModel(), uno::UNO_QUERY);
1771 if (!xStyleFamiliesSupplier.is())
1772 return;
1773
1774 Reference<container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
1775 if (!xStylesFamilies.is())
1776 return;
1777
1778 Reference<container::XIndexAccess> xCellStyles(xStylesFamilies->getByName("CellStyles"), uno::UNO_QUERY);
1779 if (!xCellStyles.is())
1780 return;
1781
1782 sal_Int32 nCount(xCellStyles->getCount());
1783 for (sal_Int32 i = 0; i < nCount; ++i)
1784 {
1785 Reference<style::XStyle> xStyle(xCellStyles->getByIndex(i), uno::UNO_QUERY);
1786 if (bFromUsedStyles && !xStyle->isInUse())
1787 continue;
1788
1789 Reference<beans::XPropertySet> xCellProperties(xStyle, uno::UNO_QUERY);
1790 if (xCellProperties.is())
1791 {
1792 sal_Int32 nNumberFormat = 0;
1793 if (xCellProperties->getPropertyValue("NumberFormat") >>= nNumberFormat)
1794 addDataStyle(nNumberFormat);
1795 }
1796 }
1797}
1798
1799void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ )
1800{
1801 if(mpNumExport)
1802 mpNumExport->SetUsed(nNumberFormat);
1803}
1804
1806{
1807 if(mpNumExport)
1808 mpNumExport->Export(false);
1809}
1810
1812{
1813 if(mpNumExport)
1814 mpNumExport->Export(true);
1815
1816 if (mxFormExport.is())
1817 mxFormExport->exportAutoControlNumberStyles();
1818}
1819
1820OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool /*bTimeFormat*/ ) const
1821{
1822 OUString sTemp;
1823 if(mpNumExport)
1824 sTemp = mpNumExport->GetStyleName(nNumberFormat);
1825 return sTemp;
1826}
1827
1828void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1829{
1830}
1831
1832sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1833{
1834 return ( mpNumExport != nullptr )
1835 ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1836}
1837
1838OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName)
1839{
1840 OUString sURL;
1841
1842 Graphic aGraphic(rxGraphic);
1843 OUString aOriginURL = aGraphic.getOriginURL();
1844
1845 if (!aOriginURL.isEmpty())
1846 {
1847 sURL = GetRelativeReference(aOriginURL);
1848 }
1849 else
1850 {
1851 if (mxGraphicStorageHandler.is())
1852 {
1854 sURL = mxGraphicStorageHandler->saveGraphicByName(rxGraphic, rOutMimeType, rRequestedName);
1855 }
1856 }
1857 return sURL;
1858}
1859
1860bool SvXMLExport::GetGraphicMimeTypeFromStream(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType)
1861{
1862 if (mxGraphicStorageHandler.is())
1863 {
1864 Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1865 if (xInputStream.is())
1866 {
1868 return true;
1869 }
1870 }
1871
1872 return false;
1873}
1874
1875bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic> const & rxGraphic)
1876{
1879 {
1880 Reference<XInputStream> xInputStream(mxGraphicStorageHandler->createInputStream(rxGraphic));
1881 if (xInputStream.is())
1882 {
1883 Graphic aGraphic(rxGraphic);
1884 if (aGraphic.getOriginURL().isEmpty()) // don't add the base64 if the origin URL is set (image is from an external URL)
1885 {
1886 XMLBase64Export aBase64Exp(*this);
1887 return aBase64Exp.exportOfficeBinaryDataElement(xInputStream);
1888 }
1889 }
1890 }
1891
1892 return false;
1893}
1894
1895OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
1896{
1897 OUString sRet;
1898 bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1899 rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1900 if (bSupportedURL && mxEmbeddedResolver.is())
1901 {
1902 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(rEmbeddedObjectURL);
1903 }
1904 else
1905 sRet = GetRelativeReference( rEmbeddedObjectURL );
1906
1907 return sRet;
1908}
1909
1910bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
1911{
1912 bool bRet = false;
1913 bool bSupportedURL = rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECT_URL_BASE) ||
1914 rEmbeddedObjectURL.startsWith(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
1915 if (bSupportedURL && mxEmbeddedResolver.is())
1916 {
1917 Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1918 if( xNA.is() )
1919 {
1920 Any aAny = xNA->getByName( rEmbeddedObjectURL );
1921 Reference < XInputStream > xIn;
1922 aAny >>= xIn;
1923 if( xIn.is() )
1924 {
1925 XMLBase64Export aBase64Exp( *this );
1926 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1927 }
1928 }
1929 }
1930
1931 return bRet;
1932}
1933
1935 const OUString& rName,
1936 bool *pEncoded ) const
1937{
1938 return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
1939}
1940
1942{
1944 {
1946
1947 if (mxExportInfo.is())
1948 {
1949 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1950 if (xPropertySetInfo.is())
1951 {
1952 OUString sProgressRange(XML_PROGRESSRANGE);
1953 OUString sProgressMax(XML_PROGRESSMAX);
1954 OUString sProgressCurrent(XML_PROGRESSCURRENT);
1955 OUString sRepeat(XML_PROGRESSREPEAT);
1956 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1957 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1958 xPropertySetInfo->hasPropertyByName(sProgressRange))
1959 {
1960 uno::Any aAny;
1961 sal_Int32 nProgressMax(0);
1962 sal_Int32 nProgressCurrent(0);
1963 sal_Int32 nProgressRange(0);
1964 aAny = mxExportInfo->getPropertyValue(sProgressRange);
1965 if (aAny >>= nProgressRange)
1966 mpProgressBarHelper->SetRange(nProgressRange);
1967 aAny = mxExportInfo->getPropertyValue(sProgressMax);
1968 if (aAny >>= nProgressMax)
1969 mpProgressBarHelper->SetReference(nProgressMax);
1970 aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
1971 if (aAny >>= nProgressCurrent)
1972 mpProgressBarHelper->SetValue(nProgressCurrent);
1973 }
1974 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1975 {
1976 uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
1977 if (aAny.getValueType() == cppu::UnoType<bool>::get())
1978 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1979 else {
1980 SAL_WARN("xmloff.core", "why is it no boolean?" );
1981 }
1982 }
1983 }
1984 }
1985 }
1986 return mpProgressBarHelper.get();
1987}
1988
1990{
1991 if( nullptr == mpEventExport)
1992 {
1993 // create EventExport on demand
1994 mpEventExport.reset( new XMLEventExport(*this) );
1995
1996 // and register standard handlers + names
1997 mpEventExport->AddHandler("StarBasic", std::make_unique<XMLStarBasicExportHandler>());
1998 mpEventExport->AddHandler("Script", std::make_unique<XMLScriptExportHandler>());
1999 mpEventExport->AddTranslationTable(aStandardEventTable);
2000 }
2001
2002 return *mpEventExport;
2003}
2004
2006{
2007 // image map export, create on-demand
2008 if( nullptr == mpImageMapExport )
2009 {
2010 mpImageMapExport.reset( new XMLImageMapExport(*this) );
2011 }
2012
2013 return *mpImageMapExport;
2014}
2015
2016void SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent > const & rComp )
2017{
2018 OUString sFilterService;
2019
2020 Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2021 if( xServiceInfo.is() )
2022 {
2023 for (const auto& [sModelService, sMatchingFilterService] : aServiceMap)
2024 {
2025 if( xServiceInfo->supportsService( sModelService ) )
2026 {
2027 sFilterService = sMatchingFilterService;
2028 break;
2029 }
2030 }
2031 }
2032
2033 SAL_WARN_IF( !sFilterService.getLength(), "xmloff.core", "no export filter for own object" );
2034
2035 if( sFilterService.isEmpty() )
2036 return;
2037
2038 Reference < XDocumentHandler > xHdl =
2040
2041 Sequence < Any > aArgs{ Any(xHdl) };
2042 Reference< document::XExporter > xExporter(
2043 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(sFilterService, aArgs, m_xContext),
2044 UNO_QUERY);
2045 SAL_WARN_IF( !xExporter.is(), "xmloff.core", "can't instantiate export filter component for own object" );
2046 if( !xExporter.is() )
2047 return;
2048
2049 xExporter->setSourceDocument( rComp );
2050
2051 Reference<XFilter> xFilter( xExporter, UNO_QUERY );
2052
2053 Sequence < PropertyValue > aMediaDesc( 0 );
2054 xFilter->filter( aMediaDesc );
2055}
2056
2057OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
2058{
2059 OUString sValue( rValue );
2060 // #i65474# handling of fragment URLs ("#...") is undefined
2061 // they are stored 'as is'
2062 uno::Reference< uri::XUriReference > xUriRef;
2063 if(!sValue.isEmpty() && sValue[0] != '#')
2064 {
2065 try
2066 {
2067 xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
2068 if( xUriRef.is() && !xUriRef->isAbsolute() )
2069 {
2070 //#i61943# relative URLs need special handling
2071 INetURLObject aTemp( mpImpl->msPackageURI );
2072 bool bWasAbsolute = false;
2073 sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
2074 }
2075 }
2076 catch(const uno::Exception&)
2077 {
2078 }
2079 }
2080 if( xUriRef.is() )//no conversion for empty values or for fragments
2081 {
2082 //conversion for matching schemes only
2083 if( xUriRef->getScheme() == mpImpl->msPackageURIScheme )
2084 {
2085 sValue = INetURLObject::GetRelURL( msOrigFileName, sValue );
2086 }
2087 }
2088 return sValue;
2089}
2090
2091void SvXMLExport::StartElement(sal_uInt16 nPrefix,
2093 bool bIgnWSOutside )
2094{
2095 StartElement(GetNamespaceMap_().GetQNameByKey( nPrefix,
2096 GetXMLToken(eName) ), bIgnWSOutside);
2097}
2098
2099void SvXMLExport::StartElement(const OUString& rName,
2100 bool bIgnWSOutside )
2101{
2103 {
2104 try
2105 {
2107 mxHandler->ignorableWhitespace( msWS );
2108 mxHandler->startElement( rName, GetXAttrList() );
2109 }
2110 catch (const SAXInvalidCharacterException& e)
2111 {
2112 Sequence<OUString> aPars { rName };
2113 SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2114 }
2115 catch (const SAXException& e)
2116 {
2117 Sequence<OUString> aPars { rName };
2119 aPars, e.Message, nullptr );
2120 }
2121 }
2122 ClearAttrList();
2123 ++mpImpl->mDepth; // increment nesting depth counter
2124}
2125
2126void SvXMLExport::Characters(const OUString& rChars)
2127{
2129 return;
2130
2131 try
2132 {
2133 mxHandler->characters(rChars);
2134 }
2135 catch (const SAXInvalidCharacterException& e)
2136 {
2137 Sequence<OUString> aPars { rChars };
2138 SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr );
2139 }
2140 catch (const SAXException& e)
2141 {
2142 Sequence<OUString> aPars { rChars };
2144 aPars, e.Message, nullptr );
2145 }
2146}
2147
2148void SvXMLExport::EndElement(sal_uInt16 nPrefix,
2150 bool bIgnWSInside )
2151{
2152 EndElement(GetNamespaceMap_().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
2153 bIgnWSInside);
2154}
2155
2156void SvXMLExport::EndElement(const OUString& rName,
2157 bool bIgnWSInside )
2158{
2159 // decrement nesting depth counter & (maybe) restore namespace map
2160 --mpImpl->mDepth;
2161 if (!mpImpl->mNamespaceMaps.empty() &&
2162 (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
2163 {
2164 mpNamespaceMap = std::move(mpImpl->mNamespaceMaps.top().first);
2165 mpImpl->mNamespaceMaps.pop();
2166 }
2167 SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() &&
2168 (mpImpl->mNamespaceMaps.top().second >= mpImpl->mDepth), "xmloff.core", "SvXMLExport: NamespaceMaps corrupted");
2169
2171 return;
2172
2173 try
2174 {
2176 mxHandler->ignorableWhitespace( msWS );
2177 mxHandler->endElement( rName );
2178 }
2179 catch (const SAXException& e)
2180 {
2181 Sequence<OUString> aPars { rName };
2183 aPars, e.Message, nullptr );
2184 }
2185}
2186
2188{
2190 return;
2191
2193 return;
2194
2195 try
2196 {
2197 mxHandler->ignorableWhitespace( msWS );
2198 }
2199 catch (const SAXException& e)
2200 {
2202 {}, e.Message, nullptr );
2203 }
2204}
2205
2207 sal_Int32 nId,
2208 const Sequence<OUString>& rMsgParams,
2209 const OUString& rExceptionMessage,
2210 const Reference<XLocator>& rLocator )
2211{
2212 // allow multi-threaded access to the cancel() method
2213 static std::mutex aMutex;
2214 std::scoped_lock aGuard(aMutex);
2215
2216 // maintain error flags
2217 if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
2219 if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
2221 if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
2223
2224 // create error list on demand
2225 if ( mpXMLErrors == nullptr )
2226 mpXMLErrors.reset( new XMLErrors() );
2227
2228 // save error information
2229 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
2230}
2231
2233 sal_Int32 nId,
2234 const Sequence<OUString>& rMsgParams)
2235{
2236 SetError( nId, rMsgParams, "", nullptr );
2237}
2238
2240{
2241 mxModel.clear();
2242 // Shapes in Writer cannot be named via context menu (#i51726#)
2244 mxEventListener.clear();
2245}
2246
2247
2249{
2250 return mpImpl->maInterfaceToIdentifierMapper;
2251}
2252
2253// Written OpenDocument file format doesn't fit to the created text document (#i69627#)
2255{
2256 return mpImpl->mbOutlineStyleAsNormalListStyle;
2257}
2258
2259uno::Reference< embed::XStorage > const & SvXMLExport::GetTargetStorage() const
2260{
2261 return mpImpl->mxTargetStorage;
2262}
2263
2265{
2266 if (mpImpl->m_oOverrideODFVersion)
2267 {
2268 return *mpImpl->m_oOverrideODFVersion;
2269 }
2270 return GetODFSaneDefaultVersion();
2271}
2272
2273void
2275 sal_uInt16 const nLegacyPrefix, OUString const& rValue)
2276{
2277 switch (getSaneDefaultVersion()) {
2278 case SvtSaveOptions::ODFSVER_011: // fall through
2279 case SvtSaveOptions::ODFSVER_010: break;
2280 default: // ODF 1.2: xml:id
2282 }
2283 // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
2284 // backward compatibility: in ODF 1.2 write _both_ id attrs
2285 AddAttribute(nLegacyPrefix, XML_ID, rValue);
2286 // FIXME: this function simply assumes that rValue is unique
2287}
2288
2289void
2290SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
2291{
2292 // check version >= 1.2
2293 switch (getSaneDefaultVersion()) {
2294 case SvtSaveOptions::ODFSVER_011: // fall through
2295 case SvtSaveOptions::ODFSVER_010: return;
2296 default: break;
2297 }
2298 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2299 uno::UNO_QUERY);
2300//FIXME not yet...
2301 if ( !xMeta.is() )
2302 return;
2303
2304 const beans::StringPair mdref( xMeta->getMetadataReference() );
2305 if ( mdref.Second.isEmpty() )
2306 return;
2307
2308 const OUString streamName = mpImpl->mStreamName;
2309 if ( !streamName.isEmpty() )
2310 {
2311 if ( streamName == mdref.First )
2312 {
2313 AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2314 }
2315 else
2316 {
2317 SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name");
2318 }
2319 }
2320 else
2321 {
2322 // FIXME: this is ugly
2323 // there is no stream name (e.g. XSLT, flat-xml format)!
2324 // but how do we ensure uniqueness in this case?
2325 // a) just omit styles.xml ids -- they are unlikely anyway...
2326 // b) somehow find out whether we are currently exporting styles
2327 // or content, and prefix "s" or "c" => unique
2328 if ( mdref.First == "content.xml" )
2329 {
2330 AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2331 }
2332 else
2333 {
2334 SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id");
2335 }
2336 }
2337}
2338
2339void
2341 uno::Reference<text::XTextContent> const & i_xTextContent)
2342{
2343 // check version >= 1.2
2344 switch (getSaneDefaultVersion()) {
2345 case SvtSaveOptions::ODFSVER_011: // fall through
2346 case SvtSaveOptions::ODFSVER_010: return;
2347 default: break;
2348 }
2349
2350 const uno::Reference<rdf::XMetadatable> xMeta(
2351 i_xTextContent, uno::UNO_QUERY);
2352 if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty())
2353 {
2354 return; // no xml:id => no RDFa
2355 }
2356
2357 if (!mpImpl->mpRDFaHelper)
2358 {
2359 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
2360 }
2361 mpImpl->mpRDFaHelper->AddRDFa(xMeta);
2362}
2363
2365{
2366 return mpImpl->mbExportTextNumberElement;
2367}
2368
2370{
2371 // if the null date has already been set, don't set it again (performance)
2372 if (!mpImpl->mbNullDateInitialized)
2373 mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel());
2374
2375 return mpImpl->mbNullDateInitialized;
2376}
2377
2378OUString const & SvXMLExport::GetImageFilterName() const
2379{
2380 return msImgFilterName;
2381}
2382
2384 const sal_uInt16 nPrefixKey,
2385 const OUString& rLName,
2386 const bool bIgnoreWhitespaceOutside )
2387{
2388 maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
2389 mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside);
2390}
2391
2393 SvXMLExport& rExp,
2394 sal_uInt16 nPrefixKey,
2395 const char *pLName,
2396 bool bIWSOutside,
2397 bool bIWSInside )
2398 : mrExport( rExp )
2399 , mbIgnoreWhitespaceInside( bIWSInside )
2400 , mbDoSomething( true )
2401{
2402 const OUString sLName( OUString::createFromAscii( pLName ) );
2403 StartElement( nPrefixKey, sLName, bIWSOutside );
2404}
2405
2407 SvXMLExport& rExp,
2408 sal_uInt16 nPrefixKey,
2409 const OUString& rLName,
2410 bool bIWSOutside,
2411 bool bIWSInside )
2412 : mrExport( rExp )
2413 , mbIgnoreWhitespaceInside( bIWSInside )
2414 , mbDoSomething( true )
2415{
2416 StartElement( nPrefixKey, rLName, bIWSOutside );
2417}
2418
2420 SvXMLExport& rExp,
2421 sal_uInt16 nPrefixKey,
2422 enum XMLTokenEnum eLName,
2423 bool bIWSOutside,
2424 bool bIWSInside )
2425 : mrExport( rExp )
2426 , mbIgnoreWhitespaceInside( bIWSInside )
2427 , mbDoSomething( true )
2428{
2429 StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2430}
2431
2433 SvXMLExport& rExp,
2434 bool bDoSth,
2435 sal_uInt16 nPrefixKey,
2436 enum XMLTokenEnum eLName,
2437 bool bIWSOutside,
2438 bool bIWSInside )
2439 : mrExport( rExp )
2440 , mbIgnoreWhitespaceInside( bIWSInside )
2441 , mbDoSomething( bDoSth )
2442{
2443 if ( mbDoSomething )
2444 StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside );
2445}
2446
2448 SvXMLExport& rExp,
2449 const OUString& rQName,
2450 bool bIWSOutside,
2451 bool bIWSInside )
2452 : mrExport( rExp )
2453 , mbIgnoreWhitespaceInside( bIWSInside )
2454 , mbDoSomething( true )
2455{
2456 maElementName = rQName;
2457 rExp.StartElement( rQName, bIWSOutside );
2458}
2459
2461{
2462 if ( mbDoSomething )
2463 {
2465 }
2466}
2467
2468/* 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:2392
SAL_DLLPRIVATE void StartElement(const sal_uInt16 nPrefix, const OUString &rName, const bool bIgnoreWhitespaceOutside)
Definition: xmlexp.cxx:2383
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:1755
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:1124
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlexp.cxx:1941
virtual void DisposingModel()
Definition: xmlexp.cxx:2239
OUString const & GetDestinationShellID() const
Definition: xmlexp.cxx:1411
char const * GetODFVersionAttributeValue() const
returns value of ODF version attribute
Definition: xmlexp.cxx:1195
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlexp.hxx:122
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlexp.cxx:2248
SAL_DLLPRIVATE void InitCtor_()
Definition: xmlexp.cxx:291
virtual XMLFontAutoStylePool * CreateFontAutoStylePool()
Definition: xmlexp.cxx:1702
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:1712
OUString const & GetSourceShellID() const
Definition: xmlexp.cxx:1406
virtual ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID)
Definition: xmlexp.cxx:1214
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlexp.cxx:652
bool exportTextNumberElement() const
Definition: xmlexp.cxx:2364
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:1482
OUString GetRelativeReference(const OUString &rValue)
Definition: xmlexp.cxx:2057
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:2290
void AddAttributeList(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
Definition: xmlexp.cxx:1000
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
Definition: xmlexp.cxx:1989
void StartElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSOutside)
Definition: xmlexp.cxx:2091
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:907
void Characters(const OUString &rChars)
Definition: xmlexp.cxx:2126
SAL_DLLPRIVATE void ImplExportSettings()
Definition: xmlexp.cxx:1025
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:1860
virtual void exportAnnotationMeta(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: xmlexp.cxx:1828
void collectDataStyles(bool bFromUsedStyles)
Definition: xmlexp.cxx:1768
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:1895
sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const
Definition: xmlexp.cxx:1832
SvXMLUnitConverter maUnitConv
Definition: xmlexp.hxx:139
rtl::Reference< comphelper::AttributeList > mxAttrList
Definition: xmlexp.hxx:132
virtual void exportDataStyles()
Definition: xmlexp.cxx:1805
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:1676
virtual sal_Int32 GetDocumentSpecificSettings(::std::vector< SettingsGroup > &_out_rSettings)
returns the current document settings
Definition: xmlexp.cxx:1763
SchXMLExportHelper * CreateChartExport()
Definition: xmlexp.cxx:1690
enum ::xmloff::token::XMLTokenEnum meClass
Definition: xmlexp.hxx:154
void ClearAttrList()
Definition: xmlexp.cxx:1006
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:2274
virtual void ExportMeta_()
Override this method to export the content of <office:meta>.
Definition: xmlexp.cxx:1416
virtual void SAL_CALL cancel() override
Definition: xmlexp.cxx:833
virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat=false) const
Definition: xmlexp.cxx:1820
virtual XMLPageExport * CreatePageExport()
Definition: xmlexp.cxx:1685
virtual void ExportFontDecls_()
Override this method to export the font declarations The default implementation will export the conte...
Definition: xmlexp.cxx:1476
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:1018
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:2264
void IgnorableWhitespace()
Definition: xmlexp.cxx:2187
void addChaffWhenEncryptedStorage()
Definition: xmlexp.cxx:1185
virtual void exportAutoDataStyles()
Definition: xmlexp.cxx:1811
SAL_DLLPRIVATE void ImplExportStyles()
Definition: xmlexp.cxx:1068
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:1934
bool AddEmbeddedXGraphicAsBase64(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic)
Definition: xmlexp.cxx:1875
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:2259
virtual void SetBodyAttributes()
Definition: xmlexp.cxx:1161
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:1443
void CheckAttrList()
Definition: xmlexp.cxx:1012
bool writeOutlineStyleAsNormalListStyle() const
Definition: xmlexp.cxx:2254
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
Definition: xmlexp.cxx:1799
XMLImageMapExport & GetImageMapExport()
get the export for image maps
Definition: xmlexp.cxx:2005
virtual void collectAutoStyles()
Definition: xmlexp.cxx:1681
virtual XMLTextParagraphExport * CreateTextParagraphExport()
Definition: xmlexp.cxx:1666
OUString const & GetImageFilterName() const
Get clamped mimetype for image export (empty if none)
Definition: xmlexp.cxx:2378
void ExportEmbeddedOwnObject(css::uno::Reference< css::lang::XComponent > const &rComp)
Definition: xmlexp.cxx:2016
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:941
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:391
SvXMLExportFlags mnExportFlags
Definition: xmlexp.hxx:157
bool AddEmbeddedObjectAsBase64(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1910
virtual XMLShapeExport * CreateShapeExport()
Definition: xmlexp.cxx:1671
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:2340
void EndElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
Definition: xmlexp.cxx:2148
css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier
Definition: xmlexp.hxx:125
xmloff::OFormLayerXMLExport * CreateFormExport()
Definition: xmlexp.cxx:1707
SAL_DLLPRIVATE void ImplExportContent()
Definition: xmlexp.cxx:1133
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:1838
bool SetNullDateOnUnitConverter()
set null date from model to unit converter, if not already done
Definition: xmlexp.cxx:2369
void ResetNamespaceMap()
Definition: xmlexp.cxx:1401
SAL_DLLPRIVATE void ImplExportAutoStyles()
Definition: xmlexp.cxx:1098
OUString msFilterName
Definition: xmlexp.hxx:135
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps)
Definition: xmlexp.cxx:1759
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:832
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:365
void overrideSaneDefaultVersion(SvtSaveOptions::ODFSaneDefaultVersion const)
Definition: xmluconv.cxx:130
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
FieldUnit
OUString sName
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)
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:704
@ XML_CONFIGURATION_SETTINGS
Definition: xmltoken.hxx:497
@ XML_AUTOMATIC_STYLES
Definition: xmltoken.hxx:303
@ XML_DOCUMENT_CONTENT
Definition: xmltoken.hxx:702
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
std::mutex aMutex
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:1166
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