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