summaryrefslogtreecommitdiffstats
path: root/include/oox
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/oox/core/binarycodec.hxx42
-rw-r--r--include/oox/core/contexthandler.hxx115
-rw-r--r--include/oox/core/contexthandler2.hxx291
-rw-r--r--include/oox/core/fastparser.hxx118
-rw-r--r--include/oox/core/fasttokenhandler.hxx68
-rw-r--r--include/oox/core/filterbase.hxx274
-rw-r--r--include/oox/core/filterdetect.hxx172
-rw-r--r--include/oox/core/fragmenthandler.hxx139
-rw-r--r--include/oox/core/fragmenthandler2.hxx115
-rw-r--r--include/oox/core/recordparser.hxx88
-rw-r--r--include/oox/core/relations.hxx120
-rw-r--r--include/oox/core/relationshandler.hxx58
-rw-r--r--include/oox/core/xmlfilterbase.hxx297
-rw-r--r--include/oox/crypto/AgileEngine.hxx147
-rw-r--r--include/oox/crypto/CryptTools.hxx120
-rw-r--r--include/oox/crypto/CryptoEngine.hxx66
-rw-r--r--include/oox/crypto/DocumentDecryption.hxx54
-rw-r--r--include/oox/crypto/DocumentEncryption.hxx52
-rw-r--r--include/oox/crypto/Standard2007Engine.hxx61
-rw-r--r--include/oox/crypto/StrongEncryptionDataSpace.hxx76
-rw-r--r--include/oox/dllapi.h33
-rw-r--r--include/oox/drawingml/chart/chartconverter.hxx100
-rw-r--r--include/oox/drawingml/chart/datasourcemodel.hxx66
-rw-r--r--include/oox/drawingml/chart/modelbase.hxx121
-rw-r--r--include/oox/drawingml/clrscheme.hxx103
-rw-r--r--include/oox/drawingml/color.hxx167
-rw-r--r--include/oox/drawingml/connectorshapecontext.hxx59
-rw-r--r--include/oox/drawingml/diagram/diagram.hxx51
-rw-r--r--include/oox/drawingml/drawingmltypes.hxx235
-rw-r--r--include/oox/drawingml/graphicshapecontext.hxx111
-rw-r--r--include/oox/drawingml/shape.hxx430
-rw-r--r--include/oox/drawingml/shapecontext.hxx53
-rw-r--r--include/oox/drawingml/shapegroupcontext.hxx45
-rw-r--r--include/oox/drawingml/shapepropertymap.hxx168
-rw-r--r--include/oox/drawingml/theme.hxx123
-rw-r--r--include/oox/drawingml/themefragmenthandler.hxx57
-rw-r--r--include/oox/dump/dffdumper.hxx64
-rw-r--r--include/oox/dump/dumperbase.hxx1740
-rw-r--r--include/oox/dump/oledumper.hxx849
-rw-r--r--include/oox/dump/pptxdumper.hxx73
-rw-r--r--include/oox/dump/xlsbdumper.hxx90
-rw-r--r--include/oox/export/DMLPresetShapeExport.hxx140
-rw-r--r--include/oox/export/chartexport.hxx279
-rw-r--r--include/oox/export/drawingml.hxx382
-rw-r--r--include/oox/export/shapes.hxx213
-rw-r--r--include/oox/export/utils.hxx80
-rw-r--r--include/oox/export/vmlexport.hxx209
-rw-r--r--include/oox/helper/addtosequence.hxx41
-rw-r--r--include/oox/helper/attributelist.hxx192
-rw-r--r--include/oox/helper/binaryinputstream.hxx385
-rw-r--r--include/oox/helper/binaryoutputstream.hxx208
-rw-r--r--include/oox/helper/binarystreambase.hxx179
-rw-r--r--include/oox/helper/containerhelper.hxx298
-rw-r--r--include/oox/helper/grabbagstack.hxx61
-rw-r--r--include/oox/helper/graphichelper.hxx161
-rw-r--r--include/oox/helper/helper.hxx301
-rw-r--r--include/oox/helper/modelobjecthelper.hxx131
-rw-r--r--include/oox/helper/progressbar.hxx132
-rw-r--r--include/oox/helper/propertymap.hxx130
-rw-r--r--include/oox/helper/propertyset.hxx151
-rw-r--r--include/oox/helper/refmap.hxx144
-rw-r--r--include/oox/helper/refvector.hxx163
-rw-r--r--include/oox/helper/storagebase.hxx192
-rw-r--r--include/oox/helper/textinputstream.hxx121
-rw-r--r--include/oox/helper/zipstorage.hxx94
-rw-r--r--include/oox/mathml/export.hxx45
-rw-r--r--include/oox/mathml/import.hxx51
-rw-r--r--include/oox/mathml/importutils.hxx255
-rw-r--r--include/oox/ole/axbinaryreader.hxx251
-rw-r--r--include/oox/ole/axbinarywriter.hxx164
-rw-r--r--include/oox/ole/axcontrol.hxx993
-rw-r--r--include/oox/ole/axcontrolfragment.hxx76
-rw-r--r--include/oox/ole/axfontdata.hxx86
-rw-r--r--include/oox/ole/olehelper.hxx198
-rw-r--r--include/oox/ole/oleobjecthelper.hxx87
-rw-r--r--include/oox/ole/olestorage.hxx115
-rw-r--r--include/oox/ole/vbacontrol.hxx214
-rw-r--r--include/oox/ole/vbaexport.hxx155
-rw-r--r--include/oox/ole/vbahelper.hxx91
-rw-r--r--include/oox/ole/vbainputstream.hxx74
-rw-r--r--include/oox/ole/vbamodule.hxx123
-rw-r--r--include/oox/ole/vbaproject.hxx211
-rw-r--r--include/oox/ppt/animationspersist.hxx125
-rw-r--r--include/oox/ppt/backgroundproperties.hxx47
-rw-r--r--include/oox/ppt/comments.hxx117
-rw-r--r--include/oox/ppt/customshowlistcontext.hxx59
-rw-r--r--include/oox/ppt/headerfooter.hxx43
-rw-r--r--include/oox/ppt/layoutfragmenthandler.hxx48
-rw-r--r--include/oox/ppt/pptfilterhelpers.hxx99
-rw-r--r--include/oox/ppt/pptgraphicshapecontext.hxx47
-rw-r--r--include/oox/ppt/pptimport.hxx107
-rw-r--r--include/oox/ppt/pptshape.hxx98
-rw-r--r--include/oox/ppt/pptshapecontext.hxx47
-rw-r--r--include/oox/ppt/pptshapegroupcontext.hxx66
-rw-r--r--include/oox/ppt/pptshapepropertiescontext.hxx47
-rw-r--r--include/oox/ppt/presPropsfragmenthandler.hxx44
-rw-r--r--include/oox/ppt/presentationfragmenthandler.hxx74
-rw-r--r--include/oox/ppt/slidefragmenthandler.hxx63
-rw-r--r--include/oox/ppt/slidemastertextstylescontext.hxx47
-rw-r--r--include/oox/ppt/slidepersist.hxx173
-rw-r--r--include/oox/ppt/slidetimingcontext.hxx48
-rw-r--r--include/oox/ppt/slidetransition.hxx82
-rw-r--r--include/oox/ppt/slidetransitioncontext.hxx58
-rw-r--r--include/oox/ppt/soundactioncontext.hxx58
-rw-r--r--include/oox/ppt/timenode.hxx128
-rw-r--r--include/oox/ppt/timenodelistcontext.hxx71
-rw-r--r--include/oox/shape/ShapeContextHandler.hxx156
-rw-r--r--include/oox/shape/ShapeFilterBase.hxx92
-rw-r--r--include/oox/token/namespacemap.hxx49
-rw-r--r--include/oox/token/propertynames.hxx33
-rw-r--r--include/oox/token/relationship.hxx76
-rw-r--r--include/oox/token/tokenmap.hxx95
-rw-r--r--include/oox/vml/vmldrawing.hxx206
-rw-r--r--include/oox/vml/vmldrawingfragment.hxx67
-rw-r--r--include/oox/vml/vmlformatting.hxx285
-rw-r--r--include/oox/vml/vmlinputstream.hxx95
-rw-r--r--include/oox/vml/vmlshape.hxx476
-rw-r--r--include/oox/vml/vmlshapecontainer.hxx144
-rw-r--r--include/oox/vml/vmlshapecontext.hxx191
-rw-r--r--include/oox/vml/vmltextbox.hxx113
-rw-r--r--include/oox/vml/vmltextboxcontext.hxx88
121 files changed, 18749 insertions, 0 deletions
diff --git a/include/oox/core/binarycodec.hxx b/include/oox/core/binarycodec.hxx
new file mode 100644
index 000000000..e7bfbaaa4
--- /dev/null
+++ b/include/oox/core/binarycodec.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_BINARYCODEC_HXX
+#define INCLUDED_OOX_CORE_BINARYCODEC_HXX
+
+#include <sal/config.h>
+
+#include <oox/dllapi.h>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace beans { struct NamedValue; }
+}
+
+namespace oox { class AttributeList; }
+
+namespace oox::core::CodecHelper
+{
+ /** Returns the password hash if it is in the required 16-bit limit. */
+ OOX_DLLPUBLIC sal_uInt16 getPasswordHash( const AttributeList& rAttribs, sal_Int32 nElement );
+} // namespace oox::core::CodecHelper
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/contexthandler.hxx b/include/oox/core/contexthandler.hxx
new file mode 100644
index 000000000..503b36d0c
--- /dev/null
+++ b/include/oox/core/contexthandler.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_CONTEXTHANDLER_HXX
+#define INCLUDED_OOX_CORE_CONTEXTHANDLER_HXX
+
+#include <memory>
+#include <string_view>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/xml/sax/XFastContextHandler.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace xml::sax { class XFastAttributeList; }
+ namespace xml::sax { class XLocator; }
+}
+
+namespace oox { class SequenceInputStream; }
+
+namespace oox::core {
+
+class XmlFilterBase;
+struct Relation;
+class Relations;
+
+class ContextHandler;
+typedef ::rtl::Reference< ContextHandler > ContextHandlerRef;
+
+struct FragmentBaseData;
+typedef std::shared_ptr< FragmentBaseData > FragmentBaseDataRef;
+
+typedef ::cppu::WeakImplHelper< css::xml::sax::XFastContextHandler > ContextHandler_BASE;
+
+class OOX_DLLPUBLIC ContextHandler : public ContextHandler_BASE
+{
+public:
+ explicit ContextHandler( const ContextHandler& rParent );
+ virtual ~ContextHandler() override;
+
+ /** Returns the filter instance. */
+ XmlFilterBase& getFilter() const;
+ /** Returns the relations of the current fragment. */
+ const Relations& getRelations() const;
+ /** Returns the full path of the current fragment. */
+ const OUString& getFragmentPath() const;
+
+ /** Returns the full fragment path for the target of the passed relation. */
+ OUString getFragmentPathFromRelation( const Relation& rRelation ) const;
+ /** Returns the full fragment path for the passed relation identifier. */
+ OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
+ /** Returns the full fragment path for the first relation of the passed type. */
+ OUString getFragmentPathFromFirstType( std::u16string_view rType ) const;
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rType ) const;
+
+ // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
+
+ virtual void SAL_CALL startFastElement( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL startUnknownElement( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) override;
+ virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const OUString& Name ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL characters( const OUString& aChars ) override;
+
+ // record context interface -----------------------------------------------
+
+ virtual ContextHandlerRef createRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
+ virtual void startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
+ virtual void endRecord( sal_Int32 nRecId );
+
+protected:
+ /** Helper constructor for the FragmentHandler. */
+ explicit ContextHandler( const FragmentBaseDataRef& rxBaseData );
+
+ void implSetLocator( const css::uno::Reference< css::xml::sax::XLocator >& rxLocator );
+
+#ifdef _MSC_VER
+ ContextHandler() {} // workaround
+#endif
+
+private:
+ ContextHandler& operator=( const ContextHandler& ) = delete;
+
+private:
+ FragmentBaseDataRef mxBaseData; ///< Base data of the fragment.
+};
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/contexthandler2.hxx b/include/oox/core/contexthandler2.hxx
new file mode 100644
index 000000000..9843a40e9
--- /dev/null
+++ b/include/oox/core/contexthandler2.hxx
@@ -0,0 +1,291 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_CONTEXTHANDLER2_HXX
+#define INCLUDED_OOX_CORE_CONTEXTHANDLER2_HXX
+
+#include <cstddef>
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/core/contexthandler.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace xml::sax { class XFastAttributeList; }
+ namespace xml::sax { class XFastContextHandler; }
+}
+
+namespace oox {
+ class AttributeList;
+ class SequenceInputStream;
+}
+
+namespace oox::core {
+
+const sal_Int32 XML_ROOT_CONTEXT = SAL_MAX_INT32;
+
+struct ElementInfo;
+
+/** Helper class that provides a context stack.
+
+ Fragment handlers and context handlers derived from this helper class will
+ track the identifiers of the visited elements in a stack. The idea is to
+ use the same instance of a fragment handler or context handler to process
+ several nested elements in an XML stream. For that, the abstract function
+ onCreateContext() has to return 'this' for the passed element.
+
+ Derived classes have to implement the createFastChildContext(),
+ startFastElement(), characters(), and endFastElement() functions from the
+ com.sun.star.xml.sax.XFastContextHandler interface by simply forwarding
+ them to the respective implCreateChildContext(), implStartElement(),
+ implCharacters(), and implEndElement() functions of this helper. This is
+ implemented already in the classes ContextHandler2 and FragmentHandler2.
+ The new abstract functions have to be implemented according to the elements
+ to be processed.
+
+ Similarly, for binary import, derived classes have to forward the
+ createRecordContext(), startRecord(), and endRecord() functions from the
+ ContextHandler class to the implCreateRecordContext(), implStartRecord(),
+ and implEndRecord() functions of this helper. Again, this is implemented
+ already in the classes ContextHandler2 and FragmentHandler2.
+ */
+class OOX_DLLPUBLIC ContextHandler2Helper
+{
+public:
+ explicit ContextHandler2Helper( bool bEnableTrimSpace, XmlFilterBase& rFilter );
+ explicit ContextHandler2Helper( const ContextHandler2Helper& rParent );
+ virtual ~ContextHandler2Helper();
+
+ // allow instances to be stored in ::rtl::Reference
+ virtual void SAL_CALL acquire() noexcept = 0;
+ virtual void SAL_CALL release() noexcept = 0;
+
+ // interface --------------------------------------------------------------
+
+ /** Will be called to create a context handler for the passed element.
+
+ Usually 'this' can be returned to improve performance by reusing the
+ same instance to process several elements. Used by OOXML import only.
+ */
+ virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) = 0;
+
+ /** Will be called when a new element has been started.
+
+ This function is called at the context handler returned from
+ onCreateContext(), or, for root elements of an XML stream, at the
+ fragment handler itself.
+
+ The current element identifier can be accessed with getCurrentElement()
+ or isCurrentElement(). Used by OOXML import only.
+ */
+ virtual void onStartElement( const AttributeList& rAttribs ) = 0;
+
+ /** Will be called before a new child element starts, or if the current
+ element is about to be left.
+
+ This helper function collects all text fragments received by the
+ characters() function (such as encoded characters which are passed in
+ separate calls to the characters() function), and passes the
+ concatenated and trimmed string.
+
+ The current element identifier can be accessed with getCurrentElement()
+ or isCurrentElement(). Used by OOXML import only.
+ */
+ virtual void onCharacters( const OUString& rChars ) = 0;
+
+ /** Will be called when the current element is about to be left.
+
+ The current element identifier can be accessed with getCurrentElement()
+ or isCurrentElement(). Used by OOXML import only.
+ */
+ virtual void onEndElement() = 0;
+
+ /** Will be called to create a context handler for the passed record.
+
+ Usually 'this' can be returned to improve performance by reusing the
+ same instance to process several records. Used by BIFF import only.
+ */
+ virtual ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) = 0;
+
+ /** Will be called when a new record block in a binary stream has been
+ started.
+
+ The current record identifier can be accessed with getCurrentElement()
+ or isCurrentElement(). Used by BIFF import only.
+ */
+ virtual void onStartRecord( SequenceInputStream& rStrm ) = 0;
+
+ /** Will be called when the current record block is about to be left.
+
+ The current record identifier can be accessed with getCurrentElement()
+ or isCurrentElement(). Used by BIFF import only.
+ */
+ virtual void onEndRecord() = 0;
+
+ // helpers ----------------------------------------------------------------
+
+ /** Returns the identifier of the currently processed element. Ignores MCE elements in stack */
+ sal_Int32 getCurrentElement() const;
+
+ /** Returns the identifier of the currently processed element - Including MCE root elements */
+ sal_Int32 getCurrentElementWithMce() const;
+
+ /** Returns true, if nElement contains the identifier of the currently
+ processed element. */
+ bool isCurrentElement( sal_Int32 nElement ) const
+ { return getCurrentElement() == nElement; }
+
+ /** Returns true, if either nElement1 or nElement2 contain the identifier
+ of the currently processed element. */
+ bool isCurrentElement( sal_Int32 nElement1, sal_Int32 nElement2 ) const
+ { return isCurrentElement( nElement1 ) || isCurrentElement( nElement2 ); }
+
+ /** Returns the identifier of the specified parent element. */
+ sal_Int32 getParentElement( sal_Int32 nCountBack = 1 ) const;
+
+ /** Returns true, if nElement contains the identifier of the specified
+ parent element. */
+ bool isParentElement( sal_Int32 nElement, sal_Int32 nCountBack = 1 ) const
+ { return getParentElement( nCountBack ) == nElement; }
+
+ /** Returns true, if the element currently processed is the root element of
+ the context or fragment handler. */
+ bool isRootElement() const;
+
+ // implementation ---------------------------------------------------------
+
+protected:
+ /** Must be called from createFastChildContext() in derived classes. */
+ css::uno::Reference< css::xml::sax::XFastContextHandler >
+ implCreateChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs );
+
+ /** Must be called from startFastElement() in derived classes. */
+ void implStartElement(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs );
+
+ /** Must be called from characters() in derived classes. */
+ void implCharacters( std::u16string_view rChars );
+
+ /** Must be called from endFastElement() in derived classes. */
+ void implEndElement( sal_Int32 nElement );
+
+ /** Must be called from createRecordContext() in derived classes. */
+ ContextHandlerRef implCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
+
+ /** Must be called from startRecord() in derived classes. */
+ void implStartRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
+
+ /** Must be called from endRecord() in derived classes. */
+ void implEndRecord( sal_Int32 nRecId );
+
+ bool prepareMceContext( sal_Int32 nElement, const AttributeList& rAttribs );
+ XmlFilterBase& getDocFilter() const { return mrFilter; }
+
+ enum class MCE_STATE
+ {
+ Started,
+ FoundChoice
+ };
+
+ MCE_STATE getMCEState() const { return aMceState.back(); }
+ void setMCEState( MCE_STATE aState ) { aMceState.back() = aState; }
+ void addMCEState( MCE_STATE aState ) { aMceState.push_back( aState ); }
+ void removeMCEState() { aMceState.pop_back(); }
+ bool isMCEStateEmpty() const { return aMceState.empty(); }
+
+private:
+ ContextHandler2Helper& operator=( const ContextHandler2Helper& ) = delete;
+
+ ElementInfo& pushElementInfo( sal_Int32 nElement );
+ void popElementInfo();
+ void processCollectedChars();
+
+private:
+ typedef std::vector< ElementInfo > ContextStack;
+ typedef std::shared_ptr< ContextStack > ContextStackRef;
+
+ ContextStackRef mxContextStack; ///< Stack of all processed elements.
+ size_t mnRootStackSize; ///< Stack size on construction time.
+ std::vector<MCE_STATE> aMceState;
+
+protected:
+ bool mbEnableTrimSpace; ///< True = trim whitespace in characters().
+ XmlFilterBase& mrFilter;
+};
+
+class OOX_DLLPUBLIC ContextHandler2 : public ContextHandler, public ContextHandler2Helper
+{
+public:
+ explicit ContextHandler2( ContextHandler2Helper const & rParent );
+ virtual ~ContextHandler2() override;
+
+ ContextHandler2(ContextHandler2 const &) = default;
+ ContextHandler2(ContextHandler2 &&) = default;
+ ContextHandler2 & operator =(ContextHandler2 const &) = delete; // due to ContextHandler
+ ContextHandler2 & operator =(ContextHandler2 &&) = delete; // due to ContextHandler
+
+ // resolve ambiguity from base classes
+ virtual void SAL_CALL acquire() noexcept override { ContextHandler::acquire(); }
+ virtual void SAL_CALL release() noexcept override { ContextHandler::release(); }
+
+ // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
+ createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs ) final override;
+
+ virtual void SAL_CALL startFastElement(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs ) final override;
+
+ virtual void SAL_CALL characters( const OUString& rChars ) final override;
+
+ virtual void SAL_CALL endFastElement( sal_Int32 nElement ) final override;
+
+ // oox.core.ContextHandler interface --------------------------------------
+
+ virtual ContextHandlerRef createRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
+ virtual void startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
+ virtual void endRecord( sal_Int32 nRecId ) override;
+
+ // oox.core.ContextHandler2Helper interface -------------------------------
+
+ virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+ virtual void onStartElement( const AttributeList& rAttribs ) override;
+ virtual void onCharacters( const OUString& rChars ) override;
+ virtual void onEndElement() override;
+
+ virtual ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
+ virtual void onStartRecord( SequenceInputStream& rStrm ) override;
+ virtual void onEndRecord() override;
+};
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/fastparser.hxx b/include/oox/core/fastparser.hxx
new file mode 100644
index 000000000..058bd344b
--- /dev/null
+++ b/include/oox/core/fastparser.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_FASTPARSER_HXX
+#define INCLUDED_OOX_CORE_FASTPARSER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
+#include <sal/types.h>
+#include <oox/dllapi.h>
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+ namespace uno { class XComponentContext; }
+ namespace xml::sax { class XFastDocumentHandler; }
+ namespace xml::sax { class XFastParser; }
+ namespace xml::sax { class XFastTokenHandler; }
+ namespace xml::sax { struct InputSource; }
+}
+
+namespace oox {
+ struct NamespaceMap;
+ class StorageBase;
+}
+
+namespace sax_fastparser {
+ class FastSaxParser;
+}
+
+namespace oox::core {
+
+
+/** Wrapper for a fast SAX parser that works on automatically generated OOXML
+ token and namespace identifiers.
+ */
+class OOX_DLLPUBLIC FastParser
+{
+public:
+ /// @throws css::uno::RuntimeException
+ explicit FastParser();
+
+ FastParser(const FastParser&) = delete;
+ FastParser& operator=(const FastParser&) = delete;
+
+ ~FastParser();
+
+ /** Registers an OOXML namespace at the parser.
+ @throws css::lang::IllegalArgumentException
+ @throws css::uno::RuntimeException
+ */
+ void registerNamespace( sal_Int32 nNamespaceId );
+
+ /** Sets the passed document handler that will receive the SAX parser events.
+ @throws css::uno::RuntimeException
+ */
+ void setDocumentHandler(
+ const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& rxDocHandler );
+
+ void clearDocumentHandler();
+
+ /** Parses the passed SAX input source.
+ @param bCloseStream True = closes the stream in the input source after parsing.
+ @throws css::xml::sax::SAXException
+ @throws css::io::IOException
+ @throws css::uno::RuntimeException
+ */
+ void parseStream( const css::xml::sax::InputSource& rInputSource, bool bCloseStream = false );
+
+ /** Parses the passed input stream.
+ @param bCloseStream True = closes the passed stream after parsing.
+ @throws css::xml::sax::SAXException
+ @throws css::io::IOException
+ @throws css::uno::RuntimeException
+ */
+ void parseStream(
+ const css::uno::Reference< css::io::XInputStream >& rxInStream,
+ const OUString& rStreamName );
+
+ /** Parses a stream from the passed storage with the specified name.
+ @param bCloseStream True = closes the stream after parsing.
+ @throws css::xml::sax::SAXException
+ @throws css::io::IOException
+ @throws css::uno::RuntimeException
+ */
+ void parseStream( StorageBase& rStorage, const OUString& rStreamName );
+
+ const css::uno::Reference< css::xml::sax::XFastTokenHandler >&
+ getTokenHandler() const { return mxTokenHandler; }
+
+private:
+ css::uno::Reference<css::xml::sax::XFastTokenHandler> mxTokenHandler;
+ const NamespaceMap& mrNamespaceMap;
+ rtl::Reference<sax_fastparser::FastSaxParser> mxParser;
+};
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/fasttokenhandler.hxx b/include/oox/core/fasttokenhandler.hxx
new file mode 100644
index 000000000..396474b98
--- /dev/null
+++ b/include/oox/core/fasttokenhandler.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_FASTTOKENHANDLER_HXX
+#define INCLUDED_OOX_CORE_FASTTOKENHANDLER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sax/fastattribs.hxx>
+
+namespace oox { class TokenMap; }
+
+namespace oox::core {
+
+
+/** Wrapper implementing the com.sun.star.xml.sax.XFastTokenHandler API interface
+ that provides access to the tokens generated from the internal token name list.
+ */
+class OOX_DLLPUBLIC FastTokenHandler final :
+ public cppu::ImplInheritanceHelper< sax_fastparser::FastTokenHandlerBase, css::lang::XServiceInfo >
+{
+public:
+ explicit FastTokenHandler();
+ virtual ~FastTokenHandler() override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // XFastTokenHandler
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken ) override;
+ virtual sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override;
+
+ // Much faster direct C++ shortcut to the method that matters
+ virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) const override;
+
+private:
+ const TokenMap& mrTokenMap; ///< Reference to global token map singleton.
+};
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/filterbase.hxx b/include/oox/core/filterbase.hxx
new file mode 100644
index 000000000..73b8e2d8e
--- /dev/null
+++ b/include/oox/core/filterbase.hxx
@@ -0,0 +1,274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_FILTERBASE_HXX
+#define INCLUDED_OOX_CORE_FILTERBASE_HXX
+
+#include <memory>
+
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace beans { struct PropertyValue; }
+ namespace drawing { class XShape; }
+ namespace frame { class XFrame; }
+ namespace frame { class XModel; }
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XStream; }
+ namespace lang { class XComponent; }
+ namespace lang { class XMultiServiceFactory; }
+ namespace task { class XStatusIndicator; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace comphelper {
+ class SequenceAsHashMap;
+}
+namespace utl {
+ class MediaDescriptor;
+}
+
+namespace oox {
+ class GraphicHelper;
+ class ModelObjectHelper;
+}
+
+namespace oox::ole {
+ class OleObjectHelper;
+ class VbaProject;
+}
+
+namespace oox::core {
+
+enum OoxmlVersion
+{
+ ECMA_DIALECT,
+ ISOIEC_29500_2008
+};
+
+struct FilterBaseImpl;
+
+typedef ::cppu::WeakImplHelper<
+ css::lang::XServiceInfo,
+ css::lang::XInitialization,
+ css::document::XImporter,
+ css::document::XExporter,
+ css::document::XFilter >
+ FilterBase_BASE;
+
+class OOX_DLLPUBLIC FilterBase : public FilterBase_BASE, public ::cppu::BaseMutex
+{
+public:
+ /// @throws css::uno::RuntimeException
+ explicit FilterBase(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+
+ virtual ~FilterBase() override;
+
+ /** Returns true, if filter is an import filter. */
+ bool isImportFilter() const;
+ /** Returns true, if filter is an export filter. */
+ bool isExportFilter() const;
+
+ OoxmlVersion getVersion() const;
+
+ /** Derived classes implement import of the entire document. */
+ virtual bool importDocument() = 0;
+
+ /** Derived classes implement export of the entire document. */
+ virtual bool exportDocument() = 0;
+
+
+ /** Returns the component context passed in the filter constructor (always existing). */
+ const css::uno::Reference< css::uno::XComponentContext >&
+ getComponentContext() const;
+
+ /** Returns the document model (always existing). */
+ const css::uno::Reference< css::frame::XModel >&
+ getModel() const;
+
+ /** Returns the service factory provided by the document model (always existing). */
+ const css::uno::Reference< css::lang::XMultiServiceFactory >&
+ getModelFactory() const;
+
+ /** Returns the frame that will contain the document model (may be null). */
+ const css::uno::Reference< css::frame::XFrame >&
+ getTargetFrame() const;
+
+ /** Returns the status indicator (may be null). */
+ const css::uno::Reference< css::task::XStatusIndicator >&
+ getStatusIndicator() const;
+
+ /** Returns the FilterData */
+ ::comphelper::SequenceAsHashMap& getFilterData() const;
+
+ /** Returns the media descriptor. */
+ utl::MediaDescriptor& getMediaDescriptor() const;
+
+ /** Returns the URL of the imported or exported file. */
+ const OUString& getFileUrl() const;
+
+ /** Returns an absolute URL for the passed relative or absolute URL. */
+ OUString getAbsoluteUrl( const OUString& rUrl ) const;
+
+ /** Returns the base storage of the imported/exported file. */
+ StorageRef const & getStorage() const;
+
+ /** Opens and returns the specified input stream from the base storage.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to open streams from embedded substorages. If base stream
+ access has been enabled in the storage, the base stream can be
+ accessed by passing an empty string as stream name.
+ */
+ css::uno::Reference< css::io::XInputStream >
+ openInputStream( const OUString& rStreamName ) const;
+
+ /** Opens and returns the specified output stream from the base storage.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to open streams from embedded substorages. If base stream
+ access has been enabled in the storage, the base stream can be
+ accessed by passing an empty string as stream name.
+ */
+ css::uno::Reference< css::io::XOutputStream >
+ openOutputStream( const OUString& rStreamName ) const;
+
+ /** Commits changes to base storage (and substorages) */
+ void commitStorage() const;
+
+ // helpers ----------------------------------------------------------------
+
+ /** Returns a helper for the handling of graphics and graphic objects. */
+ GraphicHelper& getGraphicHelper() const;
+
+ /** Returns a helper with containers for various named drawing objects for
+ the imported document. */
+ ModelObjectHelper& getModelObjectHelper() const;
+
+ ModelObjectHelper& getModelObjectHelperForModel(
+ const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory) const;
+
+ /** Returns a helper for the handling of OLE objects. */
+ ::oox::ole::OleObjectHelper& getOleObjectHelper() const;
+
+ /** Returns the VBA project manager. */
+ ::oox::ole::VbaProject& getVbaProject() const;
+
+ /** Imports the raw binary data from the specified stream.
+ @return True, if the data could be imported from the stream. */
+ bool importBinaryData( StreamDataSequence & orDataSeq, const OUString& rStreamName );
+
+ // com.sun.star.lang.XServiceInfo interface -------------------------------
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const OUString& rServiceName ) override;
+
+ virtual css::uno::Sequence< OUString > SAL_CALL
+ getSupportedServiceNames() override;
+
+ // com.sun.star.lang.XInitialization interface ----------------------------
+
+ /** Receives user defined arguments.
+
+ @param rArgs
+ the sequence of arguments passed to the filter. The implementation
+ expects one or two arguments. The first argument shall be the
+ com.sun.star.lang.XMultiServiceFactory interface of the global
+ service factory. The optional second argument may contain a
+ sequence of com.sun.star.beans.NamedValue objects. The different
+ filter implementations may support different arguments.
+ */
+ virtual void SAL_CALL initialize(
+ const css::uno::Sequence< css::uno::Any >& rArgs ) override;
+
+ // com.sun.star.document.XImporter interface ------------------------------
+
+ virtual void SAL_CALL setTargetDocument(
+ const css::uno::Reference< css::lang::XComponent >& rxDocument ) override;
+
+ // com.sun.star.document.XExporter interface ------------------------------
+
+ virtual void SAL_CALL setSourceDocument(
+ const css::uno::Reference< css::lang::XComponent >& rxDocument ) override;
+
+ // com.sun.star.document.XFilter interface --------------------------------
+
+ virtual sal_Bool SAL_CALL filter(
+ const css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq ) override;
+
+ virtual void SAL_CALL cancel() override;
+
+ bool exportVBA() const;
+
+ bool isExportTemplate() const;
+
+protected:
+ virtual css::uno::Reference< css::io::XInputStream >
+ implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const;
+ virtual css::uno::Reference< css::io::XStream >
+ implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const;
+
+ virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor );
+
+ css::uno::Reference< css::io::XStream > const &
+ getMainDocumentStream( ) const;
+
+private:
+ void setMediaDescriptor(
+ const css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq );
+
+ /** Derived classes may create a specialized graphic helper, e.g. for
+ resolving palette colors. */
+ virtual GraphicHelper* implCreateGraphicHelper() const;
+
+ /** Derived classes create a VBA project manager object. */
+ virtual ::oox::ole::VbaProject* implCreateVbaProject() const = 0;
+
+ virtual StorageRef implCreateStorage(
+ const css::uno::Reference< css::io::XInputStream >& rxInStream ) const = 0;
+ virtual StorageRef implCreateStorage(
+ const css::uno::Reference< css::io::XStream >& rxOutStream ) const = 0;
+
+private:
+ std::unique_ptr< FilterBaseImpl > mxImpl;
+};
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/filterdetect.hxx b/include/oox/core/filterdetect.hxx
new file mode 100644
index 000000000..ec0cd81a5
--- /dev/null
+++ b/include/oox/core/filterdetect.hxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_FILTERDETECT_HXX
+#define INCLUDED_OOX_CORE_FILTERDETECT_HXX
+
+#include <vector>
+
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace beans { struct PropertyValue; }
+ namespace io { class XInputStream; }
+ namespace uno { class XComponentContext; }
+ namespace xml::sax { class XFastAttributeList; }
+ namespace xml::sax { class XFastContextHandler; }
+ namespace xml::sax { class XLocator; }
+}
+
+namespace utl { class MediaDescriptor; }
+
+namespace oox { class AttributeList; }
+
+namespace oox::core {
+
+enum class OOXMLVariant {
+ ECMA_Transitional,
+ ISO_Transitional,
+ ISO_Strict
+};
+
+
+/** Document handler specifically designed for detecting OOXML file formats.
+
+ It takes a reference to the filter string object via its constructor, and
+ puts the name of the detected filter to it, if it successfully finds one.
+ */
+class FilterDetectDocHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastDocumentHandler >
+{
+public:
+ explicit FilterDetectDocHandler( const css::uno::Reference< css::uno::XComponentContext >& rxContext, OUString& rFilter, const OUString& rFileName );
+ virtual ~FilterDetectDocHandler() override;
+
+ // XFastDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+ virtual void SAL_CALL endDocument() override;
+ virtual void SAL_CALL processingInstruction( const OUString& rTarget, const OUString& rData ) override;
+ virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& xLocator ) override;
+
+ // XFastContextHandler
+ virtual void SAL_CALL startFastElement( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL startUnknownElement( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL endFastElement( sal_Int32 Element ) override;
+ virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const OUString& Name ) override;
+ virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual css::uno::Reference< XFastContextHandler > SAL_CALL createUnknownChildContext( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL characters( const OUString& aChars ) override;
+
+private:
+ void parseRelationship( const AttributeList& rAttribs );
+
+ OUString getFilterNameFromContentType( std::u16string_view rContentType, const OUString& rFileName );
+ void parseContentTypesDefault( const AttributeList& rAttribs );
+ void parseContentTypesOverride( const AttributeList& rAttribs );
+
+private:
+ typedef ::std::vector< sal_Int32 > ContextVector;
+
+ OUString& mrFilterName;
+ OUString maFileName;
+ ContextVector maContextStack;
+ OUString maTargetPath;
+ OOXMLVariant maOOXMLVariant;
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+};
+
+
+class OOX_DLLPUBLIC FilterDetect final : public ::cppu::WeakImplHelper<css::document::XExtendedFilterDetection, css::lang::XServiceInfo>
+{
+public:
+ /// @throws css::uno::RuntimeException
+ explicit FilterDetect( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+ virtual ~FilterDetect() override;
+
+ /** Tries to extract an unencrypted ZIP package from the passed media
+ descriptor.
+
+ First, this function checks if the input stream provided by the media
+ descriptor property 'InputStream' contains a ZIP package. If yes, this
+ stream is returned.
+
+ Second, this function checks if the 'ComponentData' property exists and
+ contains a sequence of com.sun.star.beans.NamedValue. If yes, a named
+ value is searched with the name 'DecryptedPackage' and a value of type
+ com.sun.star.io.XStream. If the input stream provided by this XStream
+ contains a ZIP package, this input stream is returned.
+
+ Third, this function checks if the input stream of the media descriptor
+ contains an OLE package. If yes, it checks the existence of the streams
+ 'EncryptionInfo' and 'EncryptedPackage' and tries to decrypt the package
+ into a temporary file. This may include requesting a password from the
+ media descriptor property 'Password' or from the user, using the
+ interaction handler provided by the descriptor. On success, and if the
+ decrypted package is a ZIP package, the XStream of the temporary file
+ is stored in the property 'ComponentData' of the media descriptor and
+ its input stream is returned.
+ */
+ css::uno::Reference< css::io::XInputStream >
+ extractUnencryptedPackage( utl::MediaDescriptor& rMediaDesc ) const;
+
+ // com.sun.star.lang.XServiceInfo interface -------------------------------
+
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // com.sun.star.document.XExtendedFilterDetection interface ---------------
+
+ /** Detects MS Office 2007 file types and supports package decryption.
+
+ The following file types are detected:
+ - MS Word 2007 XML Document (*.docx, *.docm)
+ - MS Word 2007 XML Template (*.dotx, *.dotm)
+ - MS Excel 2007 XML Document (*.xlsx, *.xlsm)
+ - MS Excel 2007 BIFF12 Document (*.xlsb)
+ - MS Excel 2007 XML Template (*.xltx, *.xltm)
+ - MS Powerpoint 2007 XML Document (*.pptx, *.pptm)
+ - MS Powerpoint 2007 XML Template (*.potx, *.potm)
+
+ If the package is encrypted, the detection tries to decrypt it into a
+ temporary file. The user may be asked for a password. The XStream
+ interface of the temporary file will be stored in the 'ComponentData'
+ property of the passed media descriptor.
+ */
+ virtual OUString SAL_CALL
+ detect( css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq ) override;
+
+private:
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+};
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/fragmenthandler.hxx b/include/oox/core/fragmenthandler.hxx
new file mode 100644
index 000000000..a3263ca1f
--- /dev/null
+++ b/include/oox/core/fragmenthandler.hxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_FRAGMENTHANDLER_HXX
+#define INCLUDED_OOX_CORE_FRAGMENTHANDLER_HXX
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/relations.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+ namespace xml::sax { class XFastAttributeList; }
+ namespace xml::sax { class XFastContextHandler; }
+ namespace xml::sax { class XLocator; }
+}
+
+namespace oox::core {
+
+class XmlFilterBase;
+
+/** Base data of a fragment.
+
+ This data is stored in a separate struct to make it accessible in every
+ child context handler of the fragment.
+ */
+struct FragmentBaseData
+{
+ XmlFilterBase& mrFilter;
+ const OUString maFragmentPath;
+ css::uno::Reference< css::xml::sax::XLocator >
+ mxLocator;
+ RelationsRef mxRelations;
+
+ explicit FragmentBaseData(
+ XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ RelationsRef const & xRelations );
+};
+
+
+/** Describes record identifiers used to create contexts in a binary stream.
+
+ If a record is used to start a new context, usually the record identifier
+ increased by 1 is used to mark the end of this context, e.g. the Excel
+ record SHEETDATA == 0x0091 starts the <sheetData> context, and the record
+ SHEETDATA_END == 0x0092 ends this context. But some records are used to
+ start a new context, though there is no identifier to end this context,
+ e.g. the ROW or EXTROW records. These record identifiers can be marked by
+ setting the mnEndRecId member of this struct to -1.
+ */
+struct RecordInfo
+{
+ sal_Int32 mnStartRecId; ///< Record identifier for context start.
+ sal_Int32 mnEndRecId; ///< Record identifier for context end, -1 = no record.
+};
+
+
+typedef ::cppu::ImplInheritanceHelper< ContextHandler, css::xml::sax::XFastDocumentHandler > FragmentHandler_BASE;
+
+class OOX_DLLPUBLIC FragmentHandler : public FragmentHandler_BASE
+{
+public:
+ explicit FragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath );
+ virtual ~FragmentHandler() override;
+
+ FragmentHandler(FragmentHandler const &) = default;
+ FragmentHandler(FragmentHandler &&) = default;
+ FragmentHandler & operator =(FragmentHandler const &) = delete; // due to ContextHandler
+ FragmentHandler & operator =(FragmentHandler &&) = delete; // due to ContextHandler
+
+ /** Returns the com.sun.star.xml.sax.XFastContextHandler interface of this context. */
+ css::uno::Reference< css::xml::sax::XFastContextHandler >
+ getFastContextHandler() { return static_cast< ContextHandler* >( this ); }
+
+ // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
+
+ virtual void SAL_CALL startDocument() override;
+ virtual void SAL_CALL endDocument() override;
+ virtual void SAL_CALL processingInstruction( const OUString& rTarget, const OUString& rData ) override;
+ virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& rxLocator ) override;
+
+ // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
+
+ virtual void SAL_CALL startFastElement( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL startUnknownElement( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) override;
+ virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const OUString& Name ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+ virtual void SAL_CALL characters( const OUString& aChars ) override;
+
+ // XML stream handling ----------------------------------------------------
+
+ /** Opens the fragment stream referred by the own fragment path. Derived
+ classes may provide specialized stream implementations. */
+ virtual css::uno::Reference< css::io::XInputStream >
+ openFragmentStream() const;
+
+ // binary records ---------------------------------------------------------
+
+ virtual const RecordInfo* getRecordInfos() const;
+
+protected:
+ explicit FragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, RelationsRef xRelations );
+};
+
+typedef ::rtl::Reference< FragmentHandler > FragmentHandlerRef;
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/fragmenthandler2.hxx b/include/oox/core/fragmenthandler2.hxx
new file mode 100644
index 000000000..05b2b2d0b
--- /dev/null
+++ b/include/oox/core/fragmenthandler2.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_FRAGMENTHANDLER2_HXX
+#define INCLUDED_OOX_CORE_FRAGMENTHANDLER2_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/contexthandler2.hxx>
+#include <oox/core/fragmenthandler.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace xml::sax { class XFastAttributeList; }
+ namespace xml::sax { class XFastContextHandler; }
+}
+
+namespace oox {
+ class AttributeList;
+ class SequenceInputStream;
+}
+
+namespace oox::core {
+
+class XmlFilterBase;
+
+class OOX_DLLPUBLIC FragmentHandler2 : public FragmentHandler, public ContextHandler2Helper
+{
+public:
+ explicit FragmentHandler2(
+ XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ bool bEnableTrimSpace = true );
+ virtual ~FragmentHandler2() override;
+
+ FragmentHandler2(FragmentHandler2 const &) = default;
+ FragmentHandler2(FragmentHandler2 &&) = default;
+ FragmentHandler2 & operator =(FragmentHandler2 const &) = delete; // due to FragmentHandler
+ FragmentHandler2 & operator =(FragmentHandler2 &&) = delete; // due to FragmentHandler
+
+ // resolve ambiguity from base classes
+ virtual void SAL_CALL acquire() noexcept override { FragmentHandler::acquire(); }
+ virtual void SAL_CALL release() noexcept override { FragmentHandler::release(); }
+
+ // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
+ createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs ) final override;
+
+ virtual void SAL_CALL startFastElement(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs ) final override;
+
+ virtual void SAL_CALL characters( const OUString& rChars ) final override;
+
+ virtual void SAL_CALL endFastElement( sal_Int32 nElement ) final override;
+
+ // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
+
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ // oox.core.ContextHandler interface --------------------------------------
+
+ virtual ContextHandlerRef createRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
+ virtual void startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
+ virtual void endRecord( sal_Int32 nRecId ) override;
+
+ // oox.core.ContextHandler2Helper interface -------------------------------
+
+ virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+ virtual void onStartElement( const AttributeList& rAttribs ) override;
+ virtual void onCharacters( const OUString& rChars ) override;
+ virtual void onEndElement() override;
+
+ virtual ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
+ virtual void onStartRecord( SequenceInputStream& rStrm ) override;
+ virtual void onEndRecord() override;
+
+ // oox.core.FragmentHandler2 interface ------------------------------------
+
+ virtual void initializeImport();
+ virtual void finalizeImport();
+};
+
+typedef ::rtl::Reference< FragmentHandler2 > FragmentHandler2Ref;
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/recordparser.hxx b/include/oox/core/recordparser.hxx
new file mode 100644
index 000000000..d8525ac8e
--- /dev/null
+++ b/include/oox/core/recordparser.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_RECORDPARSER_HXX
+#define INCLUDED_OOX_CORE_RECORDPARSER_HXX
+
+#include <map>
+#include <memory>
+
+#include <oox/helper/binaryinputstream.hxx>
+#include <oox/core/fragmenthandler.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox {
+namespace core {
+
+namespace prv {
+ class ContextStack;
+ class Locator;
+}
+
+
+struct RecordInputSource
+{
+ BinaryInputStreamRef mxInStream;
+ OUString maSystemId;
+};
+
+
+class RecordParser final
+{
+public:
+ RecordParser();
+ ~RecordParser();
+
+ void setFragmentHandler( const ::rtl::Reference< FragmentHandler >& rxHandler );
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::io::IOException
+ /// @throws css::uno::RuntimeException
+ void parseStream( const RecordInputSource& rInputSource );
+
+ const RecordInputSource& getInputSource() const { return maSource; }
+
+private:
+ /** Returns a RecordInfo struct that contains the passed record identifier
+ as context start identifier. */
+ const RecordInfo* getStartRecordInfo( sal_Int32 nRecId ) const;
+ /** Returns a RecordInfo struct that contains the passed record identifier
+ as context end identifier. */
+ const RecordInfo* getEndRecordInfo( sal_Int32 nRecId ) const;
+
+private:
+ typedef ::std::map< sal_Int32, RecordInfo > RecordInfoMap;
+
+ RecordInputSource maSource;
+ ::rtl::Reference< FragmentHandler > mxHandler;
+ ::rtl::Reference< prv::Locator > mxLocator;
+ ::std::unique_ptr< prv::ContextStack > mxStack;
+ RecordInfoMap maStartMap;
+ RecordInfoMap maEndMap;
+};
+
+
+} // namespace core
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/relations.hxx b/include/oox/core/relations.hxx
new file mode 100644
index 000000000..166652afe
--- /dev/null
+++ b/include/oox/core/relations.hxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_RELATIONS_HXX
+#define INCLUDED_OOX_CORE_RELATIONS_HXX
+
+#include <cstddef>
+#include <map>
+#include <memory>
+#include <string_view>
+
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+
+namespace oox::core {
+
+
+/** Expands to an OUString containing an 'officeDocument' transitional relation type created
+ from the passed literal(!) ASCII(!) character array. */
+#define CREATE_OFFICEDOC_RELATION_TYPE( ascii ) \
+ ( u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/" ascii )
+
+/** Expands to an OUString containing an 'officeDocument' strict relation type created
+ from the passed literal(!) ASCII(!) character array. */
+#define CREATE_OFFICEDOC_RELATION_TYPE_STRICT( ascii ) \
+ ( "http://purl.oclc.org/ooxml/officeDocument/relationships/" ascii )
+
+/** Expands to an OUString containing an MS Office specific relation type
+ created from the passed literal(!) ASCII(!) character array. */
+#define CREATE_MSOFFICE_RELATION_TYPE( ascii ) \
+ ( u"http://schemas.microsoft.com/office/2006/relationships/" ascii )
+
+#define CREATE_XL_CONTENT_TYPE( ascii ) \
+ ( "application/vnd.openxmlformats-officedocument.spreadsheetml." ascii "+xml" )
+
+struct Relation
+{
+ OUString maId;
+ OUString maType;
+ OUString maTarget;
+ bool mbExternal;
+
+ Relation() : mbExternal( false ) {}
+};
+
+
+class Relations;
+typedef std::shared_ptr< Relations > RelationsRef;
+
+class OOX_DLLPUBLIC Relations
+{
+public:
+ explicit Relations( const OUString& rFragmentPath );
+
+ size_t size() const { return maMap.size(); }
+ size_t count( const OUString& rId ) const { return maMap.count( rId ); }
+ ::std::map< OUString, Relation >::const_iterator begin() const
+ {
+ return maMap.begin();
+ }
+ ::std::map< OUString, Relation >::const_iterator end() const
+ {
+ return maMap.end();
+ }
+ template<class... Args>
+ void emplace(Args&&... args)
+ {
+ maMap.emplace(std::forward<Args>(args)...);
+ }
+
+ /** Returns the path of the fragment this relations collection is related to. */
+ const OUString& getFragmentPath() const { return maFragmentPath; }
+
+ /** Returns the relation with the passed relation identifier. */
+ const Relation* getRelationFromRelId( const OUString& rId ) const;
+ /** Returns the first relation with the passed type. */
+ const Relation* getRelationFromFirstType( std::u16string_view rType ) const;
+ /** Finds all relations associated with the passed type. */
+ RelationsRef getRelationsFromTypeFromOfficeDoc( std::u16string_view rType ) const;
+
+ /** Returns the external target of the relation with the passed relation identifier. */
+ OUString getExternalTargetFromRelId( const OUString& rRelId ) const;
+ /** Returns the internal target of the relation with the passed relation identifier. */
+ OUString getInternalTargetFromRelId( const OUString& rRelId ) const;
+
+ /** Returns the full fragment path for the target of the passed relation. */
+ OUString getFragmentPathFromRelation( const Relation& rRelation ) const;
+ /** Returns the full fragment path for the passed relation identifier. */
+ OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
+ /** Returns the full fragment path for the first relation of the passed type. */
+ OUString getFragmentPathFromFirstType( std::u16string_view rType ) const;
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rType ) const;
+
+private:
+ ::std::map< OUString, Relation > maMap;
+ OUString maFragmentPath;
+};
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/relationshandler.hxx b/include/oox/core/relationshandler.hxx
new file mode 100644
index 000000000..ec8f77e92
--- /dev/null
+++ b/include/oox/core/relationshandler.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_RELATIONSHANDLER_HXX
+#define INCLUDED_OOX_CORE_RELATIONSHANDLER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/core/fragmenthandler.hxx>
+#include <oox/core/relations.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace xml::sax { class XFastAttributeList; }
+ namespace xml::sax { class XFastContextHandler; }
+}
+
+namespace oox::core {
+
+class XmlFilterBase;
+
+class RelationsFragment final : public FragmentHandler
+{
+public:
+ explicit RelationsFragment(
+ XmlFilterBase& rFilter,
+ const RelationsRef& xRelations );
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
+ createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs ) override;
+
+private:
+ RelationsRef mxRelations;
+};
+
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
new file mode 100644
index 000000000..35312fda5
--- /dev/null
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -0,0 +1,297 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CORE_XMLFILTERBASE_HXX
+#define INCLUDED_OOX_CORE_XMLFILTERBASE_HXX
+
+#include <memory>
+#include <string_view>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/core/filterbase.hxx>
+#include <oox/core/relations.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace document { class XDocumentProperties; }
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XStream; }
+ namespace text { class XText; }
+ namespace text { class XTextCursor; }
+ namespace text { class XTextField; }
+ namespace uno { class XComponentContext; }
+ namespace xml::dom { class XDocument; }
+ namespace xml::sax { class XFastSAXSerializable; }
+}
+
+namespace oox {
+ namespace drawingml { class Theme; }
+ namespace drawingml::chart { class ChartConverter; }
+ namespace drawingml::table {
+ class TableStyleList;
+ typedef std::shared_ptr< TableStyleList > TableStyleListPtr;
+ }
+ namespace vml { class Drawing; }
+}
+
+namespace rtl { template <class reference_type> class Reference; }
+
+namespace sax_fastparser {
+ class FastSerializerHelper;
+
+ typedef std::shared_ptr< FastSerializerHelper > FSHelperPtr;
+}
+
+namespace utl { class MediaDescriptor; }
+
+namespace oox::drawingml
+{
+class Shape;
+}
+
+namespace oox::core {
+
+class FragmentHandler;
+class FastParser;
+
+struct TextField {
+ css::uno::Reference< css::text::XText > xText;
+ css::uno::Reference< css::text::XTextCursor > xTextCursor;
+ css::uno::Reference< css::text::XTextField > xTextField;
+};
+typedef std::vector< TextField > TextFieldStack;
+
+struct XmlFilterBaseImpl;
+
+using ShapePairs
+ = std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>;
+using NamedShapePairs = std::map<OUString, ShapePairs>;
+
+class OOX_DLLPUBLIC XmlFilterBase : public FilterBase
+{
+public:
+ /// @throws css::uno::RuntimeException
+ explicit XmlFilterBase(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+
+ virtual ~XmlFilterBase() override;
+
+ /** Has to be implemented by each filter, returns the current theme. */
+ virtual const ::oox::drawingml::Theme* getCurrentTheme() const = 0;
+
+ /** May be implemented by filters which handle Diagrams, default returns empty ptr */
+ virtual std::shared_ptr<::oox::drawingml::Theme> getCurrentThemePtr() const;
+
+ /** Has to be implemented by each filter to return the collection of VML shapes. */
+ virtual ::oox::vml::Drawing* getVmlDrawing() = 0;
+
+ /** Has to be implemented by each filter, returns a filter-specific chart
+ converter object, that should be global per imported document. */
+ virtual ::oox::drawingml::chart::ChartConverter* getChartConverter() = 0;
+
+ /** Helper to switch chart data table - specifically for xlsx imports */
+ virtual void useInternalChartDataTable( bool /*bInternal*/ ) { }
+
+ /** Has to be implemented by each filter to return the table style list. */
+ virtual ::oox::drawingml::table::TableStyleListPtr getTableStyles() = 0;
+
+
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rPart );
+
+ /** Imports a fragment using the passed fragment handler, which contains
+ the full path to the fragment stream.
+
+ @return True, if the fragment could be imported.
+ */
+ bool importFragment( const rtl::Reference<FragmentHandler>& rxHandler );
+ bool importFragment( const rtl::Reference<FragmentHandler>& rxHandler, FastParser& rParser );
+
+ /** Imports a fragment into an xml::dom::XDocument.
+
+ @param rFragmentPath path to fragment
+
+ @return a non-empty reference to the XDocument, if the
+ fragment could be imported.
+ */
+ css::uno::Reference< css::xml::dom::XDocument> importFragment( const OUString& rFragmentPath );
+
+ /** Imports a fragment from an xml::dom::XDocument using the
+ passed fragment handler
+
+ @param rxHandler fragment handler; path to fragment is
+ ignored, input source is the rxSerializer
+
+ @param rxSerializer usually retrieved from a
+ xml::dom::XDocument, will get serialized into rxHandler
+
+ @return true, if the fragment could be imported.
+ */
+ bool importFragment( const ::rtl::Reference< FragmentHandler >& rxHandler,
+ const css::uno::Reference< css::xml::sax::XFastSAXSerializable >& rxSerializer );
+
+ /** Imports the relations fragment associated with the specified fragment.
+
+ @return The relations collection of the specified fragment.
+ */
+ RelationsRef importRelations( const OUString& rFragmentPath );
+
+ /** Adds new relation.
+
+ @param rType
+ Relation type.
+
+ @param rTarget
+ Relation target.
+
+ @return Added relation Id.
+ */
+ OUString addRelation( const OUString& rType, std::u16string_view rTarget );
+
+ /** Adds new relation to part's relations.
+
+ @param rPartName
+ Part name the relations are related to. The relations will be stored in <rPartName::path>/_rels/<rPartName::name>.rels.
+
+ @param rType
+ Relation type.
+
+ @param rTarget
+ Relation target.
+
+ @return Added relation Id.
+ */
+ OUString addRelation( const css::uno::Reference< css::io::XOutputStream >& rOutputStream, const OUString& rType, std::u16string_view rTarget, bool bExternal = false );
+
+ /** Returns a stack of used textfields, used by the pptx importer to replace links to slidepages with the real page name */
+ TextFieldStack& getTextFieldStack() const;
+
+ /** Opens and returns the specified output stream from the base storage with specified media type.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to open streams from embedded substorages. If base stream
+ access has been enabled in the storage, the base stream can be
+ accessed by passing an empty string as stream name.
+
+ @param rMediaType
+ The media type string, used in [Content_Types].xml stream in base
+ storage.
+
+ @return The opened output stream.
+ */
+ css::uno::Reference< css::io::XOutputStream >
+ openFragmentStream(
+ const OUString& rStreamName,
+ const OUString& rMediaType );
+
+ /** Opens specified output stream from the base storage with specified
+ media type and returns new fast serializer for that stream.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to open streams from embedded substorages. If base stream
+ access has been enabled in the storage, the base stream can be
+ accessed by passing an empty string as stream name.
+
+ @param rMediaType
+ The media type string, used in [Content_Types].xml stream in base
+ storage.
+
+ @return newly created serializer helper.
+ */
+ ::sax_fastparser::FSHelperPtr
+ openFragmentStreamWithSerializer(
+ const OUString& rStreamName,
+ const OUString& rMediaType );
+
+ /** Returns new unique ID for exported document.
+
+ @return newly created ID.
+ */
+ sal_Int32 GetUniqueId() { return mnMaxDocId++; }
+
+ /** Write the document properties into into the current OPC package.
+
+ @param xProperties The document properties to export.
+ */
+ void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly );
+
+ /** Write the customXml entries we are preserving (xlsx and pptx only). */
+ void exportCustomFragments();
+
+ /** Read the document properties and also the customXml entries (xlsx and pptx only). */
+ void importDocumentProperties();
+
+ static void putPropertiesToDocumentGrabBag(const css::uno::Reference<css::lang::XComponent>& xDstDoc,
+ const comphelper::SequenceAsHashMap& rProperties);
+
+ static FastParser* createParser();
+
+ bool isMSO2007Document() const;
+ bool isMSODocument() const;
+
+ /// Signal that an MSO 2007-created SmartArt was found, need to warn the
+ /// user about it.
+ void setMissingExtDrawing();
+
+ void setDiagramFontHeights(NamedShapePairs* pDiagramFontHeights);
+ NamedShapePairs* getDiagramFontHeights();
+
+ void checkDocumentProperties(
+ const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
+
+ OUString getNamespaceURL(sal_Int32 nNSID) const;
+
+protected:
+ virtual css::uno::Reference< css::io::XInputStream >
+ implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const override;
+
+ virtual css::uno::Reference< css::io::XStream >
+ implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const override;
+
+ virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor ) override;
+
+private:
+ virtual StorageRef implCreateStorage(
+ const css::uno::Reference< css::io::XInputStream >& rxInStream ) const override;
+ virtual StorageRef implCreateStorage(
+ const css::uno::Reference< css::io::XStream >& rxOutStream ) const override;
+
+ void importCustomFragments(css::uno::Reference<css::embed::XStorage> const & xDocumentStorage);
+
+private:
+ ::std::unique_ptr< XmlFilterBaseImpl > mxImpl;
+ sal_Int32 mnRelId;
+ sal_Int32 mnMaxDocId;
+ bool mbMSO2007;
+ bool mbMSO;
+protected:
+ bool mbMissingExtDrawing;
+};
+
+} // namespace oox::core
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
new file mode 100644
index 000000000..ece492871
--- /dev/null
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_AGILEENGINE_HXX
+#define INCLUDED_OOX_CRYPTO_AGILEENGINE_HXX
+
+#include <vector>
+
+#include <oox/dllapi.h>
+#include <oox/crypto/CryptTools.hxx>
+#include <oox/crypto/CryptoEngine.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class BinaryXInputStream;
+ class BinaryXOutputStream;
+}
+
+namespace oox::crypto {
+
+struct OOX_DLLPUBLIC AgileEncryptionInfo
+{
+ sal_Int32 spinCount;
+ sal_Int32 saltSize;
+ sal_Int32 keyBits;
+ sal_Int32 hashSize;
+ sal_Int32 blockSize;
+
+ OUString cipherAlgorithm;
+ OUString cipherChaining;
+ OUString hashAlgorithm;
+
+ std::vector<sal_uInt8> keyDataSalt;
+
+ // Key Encryptor
+ std::vector<sal_uInt8> saltValue;
+ std::vector<sal_uInt8> encryptedVerifierHashInput;
+ std::vector<sal_uInt8> encryptedVerifierHashValue;
+ std::vector<sal_uInt8> encryptedKeyValue;
+
+ // HMAC
+ std::vector<sal_uInt8> hmacKey;
+ std::vector<sal_uInt8> hmacHash;
+ std::vector<sal_uInt8> hmacCalculatedHash;
+ std::vector<sal_uInt8> hmacEncryptedKey; // encrypted Key
+ std::vector<sal_uInt8> hmacEncryptedValue; // encrypted Hash
+};
+
+struct OOX_DLLPUBLIC AgileEncryptionParameters
+{
+ sal_Int32 spinCount;
+ sal_Int32 saltSize;
+ sal_Int32 keyBits;
+ sal_Int32 hashSize;
+ sal_Int32 blockSize;
+
+ OUString cipherAlgorithm;
+ OUString cipherChaining;
+ OUString hashAlgorithm;
+};
+
+enum class AgileEncryptionPreset
+{
+ AES_128_SHA1,
+ AES_256_SHA512,
+};
+
+class OOX_DLLPUBLIC AgileEngine final : public CryptoEngine
+{
+private:
+ AgileEncryptionInfo mInfo;
+ AgileEncryptionPreset meEncryptionPreset;
+
+ void calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal);
+
+ void calculateBlock(
+ std::vector<sal_uInt8> const & rBlock,
+ std::vector<sal_uInt8>& rHashFinal,
+ std::vector<sal_uInt8>& rInput,
+ std::vector<sal_uInt8>& rOutput);
+
+ void encryptBlock(
+ std::vector<sal_uInt8> const & rBlock,
+ std::vector<sal_uInt8>& rHashFinal,
+ std::vector<sal_uInt8>& rInput,
+ std::vector<sal_uInt8>& rOutput);
+
+ static Crypto::CryptoType cryptoType(const AgileEncryptionInfo& rInfo);
+
+public:
+ AgileEngine();
+
+ AgileEncryptionInfo& getInfo() { return mInfo;}
+
+ void setPreset(AgileEncryptionPreset ePreset)
+ {
+ meEncryptionPreset = ePreset;
+ }
+
+ // Decryption
+
+ void decryptEncryptionKey(OUString const & rPassword);
+ bool decryptAndCheckVerifierHash(OUString const & rPassword);
+
+ bool generateEncryptionKey(OUString const & rPassword) override;
+ bool readEncryptionInfo(css::uno::Reference<css::io::XInputStream> & rxInputStream) override;
+ bool decrypt(BinaryXInputStream& aInputStream,
+ BinaryXOutputStream& aOutputStream) override;
+
+ bool checkDataIntegrity() override;
+
+ bool decryptHmacKey();
+ bool decryptHmacValue();
+
+ // Encryption
+
+ void writeEncryptionInfo(BinaryXOutputStream& rStream) override;
+
+ void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+ css::uno::Reference<css::io::XOutputStream>& rxOutputStream,
+ sal_uInt32 nSize) override;
+
+ bool setupEncryption(OUString const & rPassword) override;
+
+ bool generateAndEncryptVerifierHash(OUString const & rPassword);
+
+ bool encryptHmacKey();
+ bool encryptHmacValue();
+
+ bool encryptEncryptionKey(OUString const & rPassword);
+ void setupEncryptionParameters(AgileEncryptionParameters const & rAgileEncryptionParameters);
+ bool setupEncryptionKey(OUString const & rPassword);
+};
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/CryptTools.hxx b/include/oox/crypto/CryptTools.hxx
new file mode 100644
index 000000000..c8c142007
--- /dev/null
+++ b/include/oox/crypto/CryptTools.hxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_CRYPTTOOLS_HXX
+#define INCLUDED_OOX_CRYPTO_CRYPTTOOLS_HXX
+
+#include <oox/dllapi.h>
+#include <sal/types.h>
+
+#include <vector>
+#include <memory>
+
+namespace oox::crypto {
+
+/** Rounds up the input to the nearest multiple
+ *
+ * For example:
+ * input 1, multiple 16 = 16
+ * input 16, multiple 16 = 16
+ * input 17, multiple 16 = 32
+ * input 31, multiple 16 = 32
+ */
+template<typename T>
+T roundUp(T input, T multiple)
+{
+ if (input % multiple == 0)
+ return input;
+ return ((input / multiple) * multiple) + multiple;
+}
+
+enum class CryptoHashType
+{
+ SHA1,
+ SHA256,
+ SHA512
+};
+
+struct CryptoImpl;
+
+class OOX_DLLPUBLIC Crypto
+{
+public:
+ enum CryptoType
+ {
+ UNKNOWN,
+ AES_128_ECB,
+ AES_128_CBC,
+ AES_256_CBC,
+ };
+
+protected:
+ std::unique_ptr<CryptoImpl> mpImpl;
+
+protected:
+ Crypto();
+
+public:
+ virtual ~Crypto();
+};
+
+class Decrypt final : public Crypto
+{
+public:
+ Decrypt(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, CryptoType type);
+
+ sal_uInt32 update(
+ std::vector<sal_uInt8>& output,
+ std::vector<sal_uInt8>& input,
+ sal_uInt32 inputLength = 0);
+
+
+ static sal_uInt32 aes128ecb(
+ std::vector<sal_uInt8>& output,
+ std::vector<sal_uInt8>& input,
+ std::vector<sal_uInt8>& key );
+
+};
+
+class Encrypt final : public Crypto
+{
+public:
+ Encrypt(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, CryptoType type);
+
+ sal_uInt32 update(
+ std::vector<sal_uInt8>& output,
+ std::vector<sal_uInt8>& input,
+ sal_uInt32 inputLength = 0);
+};
+
+class OOX_DLLPUBLIC CryptoHash final : public Crypto
+{
+ sal_Int32 mnHashSize;
+public:
+ CryptoHash(std::vector<sal_uInt8>& rKey, CryptoHashType eType);
+ bool update(std::vector<sal_uInt8>& rInput, sal_uInt32 nInputLength = 0);
+ std::vector<sal_uInt8> finalize();
+};
+
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/CryptoEngine.hxx b/include/oox/crypto/CryptoEngine.hxx
new file mode 100644
index 000000000..49009ac7e
--- /dev/null
+++ b/include/oox/crypto/CryptoEngine.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_CRYPTOENGINE_HXX
+#define INCLUDED_OOX_CRYPTO_CRYPTOENGINE_HXX
+
+#include <vector>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+
+namespace oox {
+ class BinaryXInputStream;
+ class BinaryXOutputStream;
+}
+
+namespace oox::crypto {
+
+class CryptoEngine
+{
+protected:
+ std::vector<sal_uInt8> mKey;
+
+public:
+ CryptoEngine()
+ {}
+
+ virtual ~CryptoEngine()
+ {}
+
+ // Decryption
+ virtual bool readEncryptionInfo(css::uno::Reference<css::io::XInputStream> & rxInputStream) = 0;
+
+ virtual bool generateEncryptionKey(const OUString& rPassword) = 0;
+
+ virtual bool decrypt(
+ BinaryXInputStream& aInputStream,
+ BinaryXOutputStream& aOutputStream) = 0;
+
+ // Encryption
+ virtual void writeEncryptionInfo(BinaryXOutputStream & rStream) = 0;
+
+ virtual bool setupEncryption(const OUString& rPassword) = 0;
+
+ virtual void encrypt(const css::uno::Reference<css::io::XInputStream> & rxInputStream,
+ css::uno::Reference<css::io::XOutputStream> & rxOutputStream,
+ sal_uInt32 nSize) = 0;
+
+ virtual bool checkDataIntegrity() = 0;
+};
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/DocumentDecryption.hxx b/include/oox/crypto/DocumentDecryption.hxx
new file mode 100644
index 000000000..33cab866f
--- /dev/null
+++ b/include/oox/crypto/DocumentDecryption.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_DOCUMENTDECRYPTION_HXX
+#define INCLUDED_OOX_CRYPTO_DOCUMENTDECRYPTION_HXX
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace beans { struct NamedValue; }
+ namespace io { class XInputStream; }
+ namespace io { class XStream; }
+ namespace uno { class XComponentContext; }
+ namespace packages { class XPackageEncryption; }
+}
+
+namespace oox::ole { class OleStorage; }
+
+namespace oox::crypto {
+
+class DocumentDecryption
+{
+private:
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+ oox::ole::OleStorage& mrOleStorage;
+ css::uno::Sequence<css::beans::NamedValue> maStreamsSequence;
+ css::uno::Reference< css::packages::XPackageEncryption > mxPackageEncryption;
+
+public:
+ DocumentDecryption(const css::uno::Reference< css::uno::XComponentContext >& rxContext, oox::ole::OleStorage& rOleStorage);
+
+ bool decrypt(const css::uno::Reference< css::io::XStream >& xDocumentStream);
+ bool readEncryptionInfo();
+ bool generateEncryptionKey(const OUString& rPassword);
+
+ css::uno::Sequence< css::beans::NamedValue > createEncryptionData(const OUString& rPassword);
+
+};
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/DocumentEncryption.hxx b/include/oox/crypto/DocumentEncryption.hxx
new file mode 100644
index 000000000..c2a3bd4ed
--- /dev/null
+++ b/include/oox/crypto/DocumentEncryption.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_DOCUMENTENCRYPTION_HXX
+#define INCLUDED_OOX_CRYPTO_DOCUMENTENCRYPTION_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace com::sun::star {
+ namespace io { class XStream; }
+ namespace packages { class XPackageEncryption; }
+ namespace beans { struct NamedValue; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox::ole { class OleStorage; }
+
+namespace oox::crypto {
+
+class DocumentEncryption
+{
+private:
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+ css::uno::Reference< css::io::XStream > mxDocumentStream;
+ oox::ole::OleStorage& mrOleStorage;
+
+ css::uno::Reference< css::packages::XPackageEncryption > mxPackageEncryption;
+ const css::uno::Sequence< css::beans::NamedValue >& mMediaEncData;
+
+public:
+ DocumentEncryption(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ css::uno::Reference< css::io::XStream > const & xDocumentStream,
+ oox::ole::OleStorage& rOleStorage,
+ const css::uno::Sequence< css::beans::NamedValue >& rMediaEncData);
+
+ bool encrypt();
+
+};
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx
new file mode 100644
index 000000000..8a7aec3e6
--- /dev/null
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_STANDARD2007ENGINE_HXX
+#define INCLUDED_OOX_CRYPTO_STANDARD2007ENGINE_HXX
+
+#include <oox/dllapi.h>
+#include <oox/crypto/CryptoEngine.hxx>
+#include <filter/msfilter/mscodec.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class BinaryXInputStream;
+ class BinaryXOutputStream;
+}
+
+namespace oox::crypto {
+
+class OOX_DLLPUBLIC Standard2007Engine final : public CryptoEngine
+{
+ msfilter::StandardEncryptionInfo mInfo;
+
+ bool generateVerifier();
+ bool calculateEncryptionKey(const OUString& rPassword);
+
+public:
+ Standard2007Engine() = default;
+
+ bool readEncryptionInfo(css::uno::Reference<css::io::XInputStream> & rxInputStream) override;
+
+ virtual bool generateEncryptionKey(OUString const & rPassword) override;
+
+ virtual bool decrypt(
+ BinaryXInputStream& aInputStream,
+ BinaryXOutputStream& aOutputStream) override;
+
+ bool checkDataIntegrity() override;
+
+ void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+ css::uno::Reference<css::io::XOutputStream>& rxOutputStream,
+ sal_uInt32 nSize) override;
+
+ virtual void writeEncryptionInfo(BinaryXOutputStream& rStream) override;
+
+ virtual bool setupEncryption(OUString const & rPassword) override;
+
+};
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/StrongEncryptionDataSpace.hxx b/include/oox/crypto/StrongEncryptionDataSpace.hxx
new file mode 100644
index 000000000..cd7156515
--- /dev/null
+++ b/include/oox/crypto/StrongEncryptionDataSpace.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_CRYPTO_STRONGENCRYPTINDATASPACE_HXX
+#define INCLUDED_OOX_CRYPTO_STRONGENCRYPTINDATASPACE_HXX
+
+#include <sal/config.h>
+
+#include <memory>
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/packages/XPackageEncryption.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <oox/crypto/CryptoEngine.hxx>
+
+namespace com::sun::star::uno
+{
+class XComponentContext;
+}
+
+namespace oox::crypto
+{
+class StrongEncryptionDataSpace final
+ : public cppu::WeakImplHelper<css::lang::XServiceInfo, css::packages::XPackageEncryption>
+{
+ css::uno::Reference<css::uno::XComponentContext> mxContext;
+ std::unique_ptr<CryptoEngine> mCryptoEngine;
+
+ css::uno::Reference<css::io::XInputStream>
+ getStream(const css::uno::Sequence<css::beans::NamedValue>& rStreams,
+ std::u16string_view sStreamName);
+
+public:
+ StrongEncryptionDataSpace(const css::uno::Reference<css::uno::XComponentContext>& rxContext);
+
+ // Decryption
+
+ virtual sal_Bool SAL_CALL generateEncryptionKey(const OUString& rPassword) override;
+ virtual sal_Bool SAL_CALL
+ readEncryptionInfo(const css::uno::Sequence<css::beans::NamedValue>& aStreams) override;
+ virtual sal_Bool SAL_CALL
+ decrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+ css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
+
+ virtual sal_Bool SAL_CALL checkDataIntegrity() override;
+
+ // Encryption
+
+ virtual css::uno::Sequence<css::beans::NamedValue>
+ SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream) override;
+
+ virtual sal_Bool SAL_CALL
+ setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
+
+ virtual css::uno::Sequence<css::beans::NamedValue>
+ SAL_CALL createEncryptionData(const OUString& rPassword) override;
+
+ // com.sun.star.lang.XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+};
+
+} // namespace oox::crypto
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/dllapi.h b/include/oox/dllapi.h
new file mode 100644
index 000000000..a03fd0b21
--- /dev/null
+++ b/include/oox/dllapi.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DLLAPI_H
+#define INCLUDED_OOX_DLLAPI_H
+
+#include <sal/types.h>
+
+#if defined OOX_DLLIMPLEMENTATION
+#define OOX_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define OOX_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/chart/chartconverter.hxx b/include/oox/drawingml/chart/chartconverter.hxx
new file mode 100644
index 000000000..fcf3b2fee
--- /dev/null
+++ b/include/oox/drawingml/chart/chartconverter.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_CHART_CHARTCONVERTER_HXX
+#define INCLUDED_OOX_DRAWINGML_CHART_CHARTCONVERTER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace awt { struct Point; }
+ namespace awt { struct Size; }
+ namespace drawing { class XShapes; }
+ namespace chart2 { class XChartDocument; }
+ namespace chart2::data { class XDataProvider; }
+ namespace chart2::data { class XDataSequence; }
+}
+
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::drawingml::chart {
+
+struct ChartSpaceModel;
+struct DataSequenceModel;
+
+
+class OOX_DLLPUBLIC ChartConverter
+{
+public:
+ explicit ChartConverter();
+ virtual ~ChartConverter();
+
+ /** Converts the passed OOXML chart model to the passed chart2 document.
+
+ @param rChartModel The filled MSOOXML chart model structure.
+
+ @param rxChartDoc The UNO chart document model to be initialized.
+
+ @param rxExternalPage If null, all embedded shapes will be inserted
+ into the internal drawing page of the chart document. If not null,
+ all embedded shapes will be inserted into this shapes collection.
+
+ @param rChartPos The position of the chart shape in its drawing page,
+ in 1/100 mm. Will be used only, if parameter rxExternalPage is not
+ null, for correct positioning of the embedded shapes in the
+ external drawing page.
+
+ @param rChartSize The size of the chart shape in 1/100 mm. Needed for
+ calculation of position and size of the chart elements (diagram,
+ titles, legend, etc.) and embedded shapes.
+ */
+ void convertFromModel(
+ ::oox::core::XmlFilterBase& rFilter,
+ ChartSpaceModel& rChartModel,
+ const css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc,
+ const css::uno::Reference< css::drawing::XShapes >& rxExternalPage,
+ const css::awt::Point& rChartPos,
+ const css::awt::Size& rChartSize );
+
+ /** Creates an internal data provider. Derived classes may override this
+ function to create an external data provider. */
+ virtual void createDataProvider(
+ const css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc );
+
+ /** Creates a data sequence from a formula. Dummy implementation. Derived
+ classes have to override this function to actually parse the formula. */
+ virtual css::uno::Reference<css::chart2::data::XDataSequence>
+ createDataSequence(
+ const css::uno::Reference<css::chart2::data::XDataProvider>& rxDataProvider,
+ const DataSequenceModel& rDataSeq, const OUString& rRole,
+ const OUString& aRoleQualifier );
+
+private:
+ ChartConverter( const ChartConverter& ) = delete;
+ ChartConverter& operator=( const ChartConverter& ) = delete;
+};
+
+
+} // namespace oox::drawingml::chart
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/chart/datasourcemodel.hxx b/include/oox/drawingml/chart/datasourcemodel.hxx
new file mode 100644
index 000000000..49b8dcd90
--- /dev/null
+++ b/include/oox/drawingml/chart/datasourcemodel.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_CHART_DATASOURCEMODEL_HXX
+#define INCLUDED_OOX_DRAWINGML_CHART_DATASOURCEMODEL_HXX
+
+#include <map>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <oox/drawingml/chart/modelbase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+enum class SvNumFormatType : sal_Int16;
+
+namespace oox::drawingml::chart {
+
+
+struct DataSequenceModel
+{
+ typedef ::std::map< sal_Int32, css::uno::Any > AnyMap;
+
+ AnyMap maData; /// Map of values, indexed by point identifier.
+ OUString maFormula; /// Formula reference, e.g. into a spreadsheet.
+ OUString maFormatCode; /// Number format for double values.
+ sal_Int32 mnPointCount; /// Number of points in this series source.
+ sal_Int32 mnLevelCount; /// Number of category levels.
+ SvNumFormatType meFormatType; /// Type of number format in maFormatCode.
+
+ explicit DataSequenceModel();
+ ~DataSequenceModel();
+};
+
+
+struct DataSourceModel
+{
+ typedef ModelRef< DataSequenceModel > DataSequenceRef;
+
+ DataSequenceRef mxDataSeq; /// The data sequence or formula link of this source.
+
+ explicit DataSourceModel();
+ ~DataSourceModel();
+};
+
+
+} // namespace oox::drawingml::chart
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/chart/modelbase.hxx b/include/oox/drawingml/chart/modelbase.hxx
new file mode 100644
index 000000000..581713bbc
--- /dev/null
+++ b/include/oox/drawingml/chart/modelbase.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_CHART_MODELBASE_HXX
+#define INCLUDED_OOX_DRAWINGML_CHART_MODELBASE_HXX
+
+#include <memory>
+
+#include <oox/helper/refmap.hxx>
+#include <oox/helper/refvector.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::drawingml::chart {
+
+template< typename ModelType >
+class ModelRef : public std::shared_ptr< ModelType >
+{
+public:
+ ModelRef() {}
+ ModelRef( const std::shared_ptr< ModelType >& rxModel ) : std::shared_ptr< ModelType >( rxModel ) {}
+
+ bool is() const { return this->get() != nullptr; }
+
+ ModelType& create() { (*this) = std::make_shared<ModelType>(); return **this; }
+ template< typename Param1Type >
+ ModelType& create( const Param1Type& rParam1 ) { (*this) = std::make_shared<ModelType>( rParam1 ); return **this; }
+ template< typename Param1Type, typename Param2Type >
+ ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { (*this) = std::make_shared<ModelType>( rParam1, rParam2 ); return **this; }
+
+ ModelType& getOrCreate() { if( !*this ) (*this) = std::make_shared<ModelType>(); return **this; }
+ template< typename Param1Type >
+ ModelType& getOrCreate( const Param1Type& rParam1 ) { if( !*this ) (*this) = std::make_shared<ModelType>( rParam1 ); return **this; }
+};
+
+template< typename ModelType >
+class ModelVector : public RefVector< ModelType >
+{
+public:
+ typedef typename RefVector< ModelType >::value_type value_type;
+ typedef typename RefVector< ModelType >::size_type size_type;
+
+ ModelType& create() { return append( std::make_shared<ModelType>() ); }
+ template< typename Param1Type >
+ ModelType& create( const Param1Type& rParam1 ) { return append( std::make_shared<ModelType>( rParam1 ) ); }
+ template< typename Param1Type, typename Param2Type >
+ ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { return append( std::make_shared<ModelType>( rParam1, rParam2 ) ); }
+
+private:
+ ModelType& append( std::shared_ptr<ModelType> pModel )
+ {
+ assert(pModel);
+ auto pTmp = pModel.get();
+ this->push_back( std::move(pModel) );
+ return *pTmp;
+ }
+};
+
+template< typename KeyType, typename ModelType >
+class ModelMap : public RefMap< KeyType, ModelType >
+{
+public:
+ typedef typename RefMap< KeyType, ModelType >::key_type key_type;
+ typedef typename RefMap< KeyType, ModelType >::mapped_type mapped_type;
+ typedef typename RefMap< KeyType, ModelType >::value_type value_type;
+
+ ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); }
+
+private:
+ ModelType& insert( KeyType eKey, ModelType* pModel ) { (*this)[ eKey ].reset( pModel ); return *pModel; }
+};
+
+struct NumberFormat
+{
+ OUString maFormatCode; /// Number format code.
+ bool mbSourceLinked; /// True = number format linked to source data.
+
+ NumberFormat();
+
+ void setAttributes( const AttributeList& rAttribs );
+};
+
+struct LayoutModel
+{
+ double mfX; /// Left position of this object.
+ double mfY; /// Top position of this object.
+ double mfW; /// Width of this object.
+ double mfH; /// Height of this object.
+ sal_Int32 mnXMode; /// Mode for left position.
+ sal_Int32 mnYMode; /// Mode for top position.
+ sal_Int32 mnWMode; /// Mode for width.
+ sal_Int32 mnHMode; /// Mode for height.
+ sal_Int32 mnTarget; /// Layout target for plot area.
+ bool mbAutoLayout; /// True = automatic positioning.
+
+ LayoutModel();
+};
+
+} // namespace oox::drawingml::chart
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/clrscheme.hxx b/include/oox/drawingml/clrscheme.hxx
new file mode 100644
index 000000000..a4f0b6534
--- /dev/null
+++ b/include/oox/drawingml/clrscheme.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_CLRSCHEME_HXX
+#define INCLUDED_OOX_DRAWINGML_CLRSCHEME_HXX
+
+#include <cstddef>
+#include <map>
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include <oox/dllapi.h>
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <tools/color.hxx>
+
+namespace oox::drawingml {
+
+enum PredefinedClrSchemeId {
+ dk1 = 0,
+ lt1,
+ dk2,
+ lt2,
+ accent1,
+ accent2,
+ accent3,
+ accent4,
+ accent5,
+ accent6,
+ hlink,
+ folHlink,
+ Count
+};
+
+static std::map<PredefinedClrSchemeId, OUString> PredefinedClrNames =
+{
+ { dk1, "dk1" },
+ { lt1, "lt1" },
+ { dk2, "dk2" },
+ { lt2, "lt2" },
+ { accent1, "accent1" },
+ { accent2, "accent2" },
+ { accent3, "accent3" },
+ { accent4, "accent4" },
+ { accent5, "accent5" },
+ { accent6, "accent6" },
+ { hlink, "hlink" },
+ { folHlink, "folHlink" }
+};
+
+class ClrMap
+{
+ std::map < sal_Int32, sal_Int32 > maClrMap;
+
+public:
+
+ bool getColorMap( sal_Int32& nClrToken );
+ void setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken );
+};
+
+typedef std::shared_ptr< ClrMap > ClrMapPtr;
+
+class OOX_DLLPUBLIC ClrScheme
+{
+ std::vector< std::pair<sal_Int32, ::Color> > maClrScheme;
+ OUString maName;
+
+public:
+
+ bool getColor( sal_Int32 nSchemeClrToken, ::Color& rColor ) const;
+ void setColor( sal_Int32 nSchemeClrToken, ::Color nColor );
+
+ bool getColorByIndex(size_t nIndex,
+ ::Color& rColor) const;
+
+ void SetName(const OUString& rName) { maName = rName; }
+ const OUString& GetName() const { return maName; }
+
+ void ToAny(css::uno::Any& rVal) const;
+};
+
+}
+
+#endif // INCLUDED_OOX_DRAWINGML_CLRSCHEME_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx
new file mode 100644
index 000000000..b28c92698
--- /dev/null
+++ b/include/oox/drawingml/color.hxx
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_COLOR_HXX
+#define INCLUDED_OOX_DRAWINGML_COLOR_HXX
+
+#include <vector>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/helper/helper.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <tools/color.hxx>
+
+namespace oox { class GraphicHelper; }
+
+namespace oox::drawingml {
+
+
+class OOX_DLLPUBLIC Color
+{
+public:
+ Color();
+
+ /** Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error. */
+ static ::Color getDmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
+ /** Returns the RGB value for the passed VML color token, or nDefaultRgb on error. */
+ static ::Color getVmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
+ /** Returns the RGB value for the passed VML color token, or nDefaultRgb on error. */
+ static ::Color getHighlightColor(sal_Int32 nToken, ::Color nDefaultRgb);
+
+ /** Sets the color to unused state. */
+ void setUnused();
+ /** Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element. */
+ void setSrgbClr( sal_Int32 nRgb );
+ void setSrgbClr( ::Color nRgb );
+ /** Sets the percentual RGB values from the a:scrgbClr element. */
+ void setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB );
+ /** Sets the HSL values from the a:hslClr element. */
+ void setHslClr( sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum );
+ /** Sets a predefined color from the a:prstClr element. */
+ void setPrstClr( sal_Int32 nToken );
+ /** Sets a predefined color from the w:highlight element. */
+ void setHighlight(sal_Int32 nToken);
+ /** Sets a scheme color from the a:schemeClr element. */
+ void setSchemeClr( sal_Int32 nToken );
+ /** Sets the scheme name from the a:schemeClr element for interoperability purposes */
+ void setSchemeName( const OUString& sSchemeName ) { msSchemeName = sSchemeName; }
+ /** Sets a system color from the a:sysClr element. */
+ void setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb );
+ /** Sets a palette color index. */
+ void setPaletteClr( sal_Int32 nPaletteIdx );
+
+ /** Inserts the passed color transformation. */
+ void addTransformation( sal_Int32 nElement, sal_Int32 nValue = -1 );
+ /** Inserts Chart specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). */
+ void addChartTintTransformation( double fTint );
+ /** Inserts Excel specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). */
+ void addExcelTintTransformation( double fTint );
+ /** Removes all color transformations. */
+ void clearTransformations();
+ /** Removes transparence from the color. */
+ void clearTransparence();
+
+ /** Overwrites this color with the passed color, if it is used. */
+ void assignIfUsed( const Color& rColor ) { if( rColor.isUsed() ) *this = rColor; }
+
+ /** Returns true, if the color is initialized. */
+ bool isUsed() const { return meMode != COLOR_UNUSED; }
+ /** Returns true, if the color is a placeholder color in theme style lists. */
+ bool isPlaceHolder() const { return meMode == COLOR_PH; }
+ /** Returns the final RGB color value.
+ @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */
+ ::Color getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr = API_RGB_TRANSPARENT ) const;
+
+ /** Returns true, if the color is transparent. */
+ bool hasTransparency() const;
+ /** Returns the transparency of the color (0 = opaque, 100 = full transparent). */
+ sal_Int16 getTransparency() const;
+
+ /** Returns the scheme name from the a:schemeClr element for interoperability purposes */
+ const OUString& getSchemeColorName() const { return msSchemeName; }
+ sal_Int16 getSchemeColorIndex() const;
+ sal_Int16 getTintOrShade() const;
+ sal_Int16 getLumMod() const;
+ sal_Int16 getLumOff() const;
+
+ /** Returns the unaltered list of transformations for interoperability purposes */
+ const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
+
+ /** Translates between color transformation tokens and their names */
+ static OUString getColorTransformationName( sal_Int32 nElement );
+ /** Translates between color transformation token names and the corresponding token */
+ static sal_Int32 getColorTransformationToken( std::u16string_view sName );
+
+ /// Compares this color with rOther.
+ bool equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const;
+
+private:
+ /** Internal helper for getColor(). */
+ void setResolvedRgb( ::Color nRgb ) const;
+
+ /** Converts the color components to RGB values. */
+ void toRgb() const;
+ /** Converts the color components to CRGB values (gamma corrected percentage). */
+ void toCrgb() const;
+ /** Converts the color components to HSL values. */
+ void toHsl() const;
+
+private:
+ enum ColorMode
+ {
+ COLOR_UNUSED, /// Color is not used, or undefined.
+ COLOR_RGB, /// Absolute RGB (r/g/b: 0...255).
+ COLOR_CRGB, /// Relative RGB (r/g/b: 0...100000).
+ COLOR_HSL, /// HSL (hue: 0...21600000, sat/lum: 0...100000).
+ COLOR_SCHEME, /// Color from scheme.
+ COLOR_PALETTE, /// Color from application defined palette.
+ COLOR_SYSTEM, /// Color from system palette.
+ COLOR_PH, /// Placeholder color in theme style lists.
+ COLOR_FINAL /// Finalized RGB color.
+ };
+
+ struct Transformation
+ {
+ sal_Int32 mnToken;
+ sal_Int32 mnValue;
+
+ explicit Transformation( sal_Int32 nToken, sal_Int32 nValue ) : mnToken( nToken ), mnValue( nValue ) {}
+ };
+
+ mutable ColorMode meMode; /// Current color mode.
+ mutable std::vector< Transformation >
+ maTransforms; /// Color transformations.
+ mutable sal_Int32 mnC1; /// Red, red%, hue, scheme token, palette index, system token, or final RGB.
+ mutable sal_Int32 mnC2; /// Green, green%, saturation, or system default RGB.
+ mutable sal_Int32 mnC3; /// Blue, blue%, or luminance.
+ sal_Int32 mnAlpha; /// Alpha value (color opacity).
+
+ OUString msSchemeName; /// Scheme name from the a:schemeClr element for interoperability purposes
+ css::uno::Sequence< css::beans::PropertyValue >
+ maInteropTransformations; /// Unaltered list of transformations for interoperability purposes
+};
+
+} // namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/connectorshapecontext.hxx b/include/oox/drawingml/connectorshapecontext.hxx
new file mode 100644
index 000000000..c9819ae85
--- /dev/null
+++ b/include/oox/drawingml/connectorshapecontext.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX
+#define INCLUDED_OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/dllapi.h>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/shapecontext.hxx>
+#include <sal/types.h>
+#include <vector>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class ContextHandler2Helper; }
+
+namespace oox::drawingml {
+
+ struct ConnectorShapeProperties
+ {
+ bool mbStartShape;
+ OUString maDestShapeId;
+ sal_Int32 mnDestGlueId;
+ };
+
+class OOX_DLLPUBLIC ConnectorShapeContext final : public ShapeContext
+{
+ std::vector<ConnectorShapeProperties>& mrConnectorShapePropertiesList;
+ ShapePtr mpConnectorShapePtr;
+
+public:
+ ConnectorShapeContext(::oox::core::ContextHandler2Helper const& rParent,
+ const ShapePtr& pMasterShapePtr, const ShapePtr& pGroupShapePtr,
+ std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList);
+ virtual ~ConnectorShapeContext() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+};
+
+}
+
+#endif // INCLUDED_OOX_DRAWINGML_CONNECTORSHAPECONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/diagram/diagram.hxx b/include/oox/drawingml/diagram/diagram.hxx
new file mode 100644
index 000000000..b3e79d461
--- /dev/null
+++ b/include/oox/drawingml/diagram/diagram.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAM_HXX
+#define INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAM_HXX
+
+#include <rtl/ustring.hxx>
+#include <oox/core/xmlfilterbase.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <svx/svdobj.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+
+namespace oox::drawingml {
+
+/** load diagram data, and put resulting graphic into shape
+
+ This method loads the diagram data fragments from the given paths,
+ generate and layout the shapes, and push it as children into the
+ referenced shape.
+ */
+void loadDiagram( ShapePtr const & pShape,
+ core::XmlFilterBase& rFilter,
+ const OUString& rDataModelPath,
+ const OUString& rLayoutPath,
+ const OUString& rQStylePath,
+ const OUString& rColorStylePath,
+ const oox::core::Relations& rRelations );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx
new file mode 100644
index 000000000..5fe86d564
--- /dev/null
+++ b/include/oox/drawingml/drawingmltypes.hxx
@@ -0,0 +1,235 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX
+#define INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX
+
+#include <memory>
+#include <string_view>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/geometry/IntegerRectangle2D.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/style/TabAlign.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <o3tl/unit_conversion.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace drawing { struct Hatch; }
+ namespace xml::sax { class XFastAttributeList; }
+}
+
+namespace oox::drawingml {
+
+
+const sal_Int32 PER_PERCENT = 1000;
+const sal_Int32 MAX_PERCENT = 100 * PER_PERCENT;
+
+const sal_Int32 PER_DEGREE = 60000;
+const sal_Int32 MAX_DEGREE = 360 * PER_DEGREE;
+
+
+struct LineProperties;
+typedef std::shared_ptr< LineProperties > LinePropertiesPtr;
+
+struct FillProperties;
+typedef std::shared_ptr< FillProperties > FillPropertiesPtr;
+
+struct GraphicProperties;
+typedef std::shared_ptr< GraphicProperties > GraphicPropertiesPtr;
+
+struct Shape3DProperties;
+typedef std::shared_ptr< Shape3DProperties > Shape3DPropertiesPtr;
+
+struct TextCharacterProperties;
+typedef std::shared_ptr< TextCharacterProperties > TextCharacterPropertiesPtr;
+
+struct EffectProperties;
+typedef std::shared_ptr< EffectProperties > EffectPropertiesPtr;
+
+class TextBody;
+typedef std::shared_ptr< TextBody > TextBodyPtr;
+
+class TextListStyle;
+typedef std::shared_ptr< TextListStyle > TextListStylePtr;
+
+class Shape;
+typedef std::shared_ptr< Shape > ShapePtr;
+typedef std::weak_ptr< Shape > WeakShapePtr;
+
+class Theme;
+typedef std::shared_ptr< Theme > ThemePtr;
+
+
+namespace table {
+
+class TableProperties;
+typedef std::shared_ptr< TableProperties > TablePropertiesPtr;
+
+} // namespace table
+
+
+/** converts the attributes from a CT_TLPoint into an awt Point with 1/1000% */
+css::awt::Point GetPointPercent( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs );
+
+
+/** converts the attributes from a CT_Size2D into an awt Size with 1/100th mm */
+css::awt::Size GetSize2D( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
+
+/** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */
+css::geometry::IntegerRectangle2D GetRelativeRect( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
+
+/** converts EMUs into 1/100th mmm */
+sal_Int32 GetCoordinate( sal_Int32 nValue );
+
+/** converts an emu string into 1/100th mmm */
+sal_Int32 GetCoordinate( std::u16string_view sValue );
+
+/** converts 1/100mm to EMU */
+sal_Int32 GetPointFromCoordinate( sal_Int32 nValue );
+
+/** converts a ST_Percentage % string into 1/1000th of % */
+sal_Int32 GetPercent( std::u16string_view sValue );
+
+/** Converts a ST_PositiveFixedPercentage to a float. 1.0 == 100% */
+double GetPositiveFixedPercentage( const OUString& sValue );
+
+/** converts the ST_TextFontSize to point */
+float GetTextSize( std::u16string_view rValue );
+
+/** converts the ST_TextSpacingPoint to 1/100mm */
+sal_Int32 GetTextSpacingPoint( std::u16string_view sValue );
+sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue );
+
+/** */
+css::style::TabAlign GetTabAlign( ::sal_Int32 aToken );
+
+float GetFontHeight( sal_Int32 nHeight );
+
+sal_Int16 GetFontUnderline( sal_Int32 nToken );
+
+sal_Int16 GetFontStrikeout( sal_Int32 nToken );
+
+sal_Int16 GetCaseMap( sal_Int32 nToken );
+
+/** converts a paragraph align to a ParaAdjust */
+css::style::ParagraphAdjust GetParaAdjust( sal_Int32 nAlign );
+
+// Converts vertical adjust tokens to a TextVerticalAdjust item
+css::drawing::TextVerticalAdjust GetTextVerticalAdjust( sal_Int32 nToken );
+
+// Converts a TextVerticalAdjust item to string value appearing in ooxml
+OOX_DLLPUBLIC const char* GetTextVerticalAdjust( css::drawing::TextVerticalAdjust eAdjust );
+
+// Converts a Hatch object to an ooxml pattern.
+const char* GetHatchPattern( const css::drawing::Hatch& rHatch );
+
+
+// CT_IndexRange
+struct IndexRange {
+ sal_Int32 start;
+ sal_Int32 end;
+};
+
+/** retrieve the content of CT_IndexRange */
+IndexRange GetIndexRange( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
+
+/**
+* nRotation is a 100th of a degree and the return value is
+* in a 60,000th of a degree
+*
+* Also rotation is in opposite directions so multiply with -1
+*/
+inline OString calcRotationValue(sal_Int32 nRotation)
+{
+ if (nRotation > 18000) // 180 degree
+ {
+ nRotation -= 36000;
+ }
+ nRotation *= -600;
+ return OString::number(nRotation);
+}
+
+/** Converts the passed 32-bit integer value from 1/100 mm to EMUs. */
+inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
+{
+ return o3tl::convert(nValue, o3tl::Length::mm100, o3tl::Length::emu);
+}
+
+/** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */
+inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
+{
+ return o3tl::convertNarrowing<sal_Int32, o3tl::Length::emu, o3tl::Length::mm100>(nValue);
+}
+
+/** Converts the passed 64-bit integer value from EMUs to Points. */
+inline float convertEmuToPoints( sal_Int64 nValue )
+{
+ return o3tl::convert<double>(nValue, o3tl::Length::emu, o3tl::Length::pt);
+}
+
+/** Converts the passed double value from points to mm. */
+inline double convertPointToMms(double fValue)
+{
+ return o3tl::convert(fValue, o3tl::Length::pt, o3tl::Length::mm);
+}
+
+/** A structure for a point with 64-bit integer components. */
+struct EmuPoint
+{
+ sal_Int64 X;
+ sal_Int64 Y;
+
+ EmuPoint() : X( 0 ), Y( 0 ) {}
+ explicit EmuPoint( sal_Int64 nX, sal_Int64 nY ) : X( nX ), Y( nY ) {}
+};
+
+
+/** A structure for a size with 64-bit integer components. */
+struct EmuSize
+{
+ sal_Int64 Width;
+ sal_Int64 Height;
+
+ EmuSize() : Width( 0 ), Height( 0 ) {}
+ explicit EmuSize( sal_Int64 nWidth, sal_Int64 nHeight ) : Width( nWidth ), Height( nHeight ) {}
+};
+
+
+/** A structure for a rectangle with 64-bit integer components. */
+struct EmuRectangle : public EmuPoint, public EmuSize
+{
+ EmuRectangle() {}
+ explicit EmuRectangle( sal_Int64 nX, sal_Int64 nY, sal_Int64 nWidth, sal_Int64 nHeight ) : EmuPoint( nX, nY ), EmuSize( nWidth, nHeight ) {}
+
+ void setPos( const EmuPoint& rPos ) { static_cast< EmuPoint& >( *this ) = rPos; }
+ void setSize( const EmuSize& rSize ) { static_cast< EmuSize& >( *this ) = rSize; }
+};
+
+
+} // namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/graphicshapecontext.hxx b/include/oox/drawingml/graphicshapecontext.hxx
new file mode 100644
index 000000000..ffd579f00
--- /dev/null
+++ b/include/oox/drawingml/graphicshapecontext.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX
+#define INCLUDED_OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/dllapi.h>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/shapecontext.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class ContextHandler2Helper; }
+namespace oox::vml { struct OleObjectInfo; }
+
+namespace oox::drawingml {
+
+class OOX_DLLPUBLIC GraphicShapeContext : public ShapeContext
+{
+public:
+ GraphicShapeContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pMasterShapePtr, const ShapePtr& pShapePtr );
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+};
+
+
+class OOX_DLLPUBLIC GraphicalObjectFrameContext final : public ShapeContext
+{
+public:
+ GraphicalObjectFrameContext( ::oox::core::ContextHandler2Helper& rParent, const ShapePtr& pMasterShapePtr, const ShapePtr& pShapePtr, bool bEmbedShapesInChart );
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+ virtual void onEndElement() override;
+
+private:
+ bool mbEmbedShapesInChart;
+ ::oox::core::ContextHandler2Helper* mpParent;
+};
+
+
+class OleObjectGraphicDataContext final : public ShapeContext
+{
+public:
+ OleObjectGraphicDataContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pShapePtr );
+ virtual ~OleObjectGraphicDataContext() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+ virtual void onEndElement() override;
+
+private:
+ ::oox::vml::OleObjectInfo& mrOleObjectInfo;
+};
+
+
+class DiagramGraphicDataContext final
+ : public ShapeContext
+{
+public:
+ DiagramGraphicDataContext( ::oox::core::ContextHandler2Helper const & rParent, const ShapePtr& pShapePtr );
+ virtual ~DiagramGraphicDataContext() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+
+private:
+ OUString msDm;
+ OUString msLo;
+ OUString msQs;
+ OUString msCs;
+};
+
+
+struct ChartShapeInfo;
+
+class ChartGraphicDataContext final : public ShapeContext
+{
+public:
+ explicit ChartGraphicDataContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ const ShapePtr& rxShape, bool bEmbedShapes );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext(
+ sal_Int32 nElement,
+ const ::oox::AttributeList& rAttribs) override;
+
+private:
+ ChartShapeInfo& mrChartShapeInfo;
+};
+
+
+}
+
+#endif // INCLUDED_OOX_DRAWINGML_GRAPHICSHAPECONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
new file mode 100644
index 000000000..5c4f788cd
--- /dev/null
+++ b/include/oox/drawingml/shape.hxx
@@ -0,0 +1,430 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_SHAPE_HXX
+#define INCLUDED_OOX_DRAWINGML_SHAPE_HXX
+
+#include <map>
+#include <memory>
+#include <string_view>
+#include <vector>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <oox/core/xmlfilterbase.hxx>
+#include <oox/dllapi.h>
+#include <oox/drawingml/color.hxx>
+#include <oox/drawingml/connectorshapecontext.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/helper/helper.hxx>
+#include <oox/helper/propertymap.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace basegfx { class B2DHomMatrix; }
+
+namespace com::sun::star {
+ namespace awt { struct Rectangle; }
+ namespace drawing { class XShape; }
+ namespace drawing { class XShapes; }
+ namespace uno { class Any; }
+}
+
+namespace oox::core {
+ class XmlFilterBase;
+}
+
+namespace oox::vml {
+ struct OleObjectInfo;
+}
+
+namespace svx::diagram {
+ class IDiagramHelper;
+}
+
+namespace oox::drawingml {
+
+class Theme;
+struct EffectProperties;
+struct FillProperties;
+struct GraphicProperties;
+struct LineProperties;
+struct Shape3DProperties;
+
+class CustomShapeProperties;
+typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
+
+typedef ::std::map< OUString, ShapePtr > ShapeIdMap;
+
+typedef std::vector<ConnectorShapeProperties> ConnectorShapePropertiesList;
+
+struct ShapeStyleRef
+{
+ Color maPhClr;
+ sal_Int32 mnThemedIdx;
+ ShapeStyleRef() : mnThemedIdx(0) {}
+};
+
+typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
+
+/** Additional information for a chart embedded in a drawing shape. */
+struct ChartShapeInfo
+{
+ OUString maFragmentPath; ///< Path to related XML stream, e.g. for charts.
+ bool mbEmbedShapes; ///< True = load chart shapes into chart, false = load into parent drawpage.
+
+ explicit ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {}
+};
+
+/// Attributes for a linked textbox.
+struct LinkedTxbxAttr
+{
+ sal_Int32 id;
+ sal_Int32 seq;
+ LinkedTxbxAttr(): id(0),seq(0){};
+};
+
+class Diagram;
+
+class OOX_DLLPUBLIC Shape
+ : public std::enable_shared_from_this< Shape >
+{
+public:
+
+ explicit Shape( const char* pServiceType = nullptr, bool bDefaultHeight = true );
+ explicit Shape( const ShapePtr& pSourceShape );
+ Shape(Shape const &) = default;
+ virtual ~Shape();
+ Shape & operator =(Shape const &) = default;
+
+ OUString& getServiceName(){ return msServiceName; }
+ void setServiceName( const char* pServiceName );
+
+ const OUString& getDiagramDataModelID() const { return msDiagramDataModelID; }
+ void setDiagramDataModelID( const OUString& rDiagramDataModelID ) { msDiagramDataModelID = rDiagramDataModelID; }
+
+ PropertyMap& getShapeProperties(){ return maShapeProperties; }
+
+ LineProperties& getLineProperties() { return *mpLinePropertiesPtr; }
+ const LineProperties& getLineProperties() const { return *mpLinePropertiesPtr; }
+
+ FillProperties& getFillProperties() { return *mpFillPropertiesPtr; }
+ const FillProperties& getFillProperties() const { return *mpFillPropertiesPtr; }
+
+ GraphicProperties& getGraphicProperties() { return *mpGraphicPropertiesPtr; }
+ const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; }
+
+ CustomShapePropertiesPtr& getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; }
+
+ OUString& getConnectorName() { return msConnectorName; }
+ ConnectorShapePropertiesList& getConnectorShapeProperties() { return maConnectorShapePropertiesList; }
+ void setConnectorShape(bool bConnector) { mbConnector = bConnector; }
+ bool isConnectorShape() const { return mbConnector; }
+
+ void setBookmark(bool bBookmark) { mbHasBookmark = bBookmark; }
+ bool hasBookmark() const { return mbHasBookmark; }
+
+ Shape3DProperties& get3DProperties() { return *mp3DPropertiesPtr; }
+ const Shape3DProperties& get3DProperties() const { return *mp3DPropertiesPtr; }
+
+ table::TablePropertiesPtr const & getTableProperties();
+
+ EffectProperties& getEffectProperties() const { return *mpEffectPropertiesPtr; }
+
+ void setChildPosition( css::awt::Point nPosition ){ maChPosition = nPosition; }
+ void setChildSize( css::awt::Size aSize ){ maChSize = aSize; }
+
+ void setPosition( css::awt::Point nPosition ){ maPosition = nPosition; }
+ const css::awt::Point& getPosition() const { return maPosition; }
+
+ void setSize( css::awt::Size aSize ){ maSize = aSize; }
+ const css::awt::Size& getSize() const { return maSize; }
+
+ void setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
+ sal_Int32 getRotation() const { return mnRotation; }
+ void setDiagramRotation( sal_Int32 nRotation ) { mnDiagramRotation = nRotation; }
+ void setFlip( bool bFlipH, bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
+ bool getFlipH() const { return mbFlipH; }
+ bool getFlipV() const { return mbFlipV; }
+ void addChild( const ShapePtr& rChildPtr ) { maChildren.push_back( rChildPtr ); }
+ std::vector< ShapePtr >& getChildren() { return maChildren; }
+
+ void setName( const OUString& rName ) { msName = rName; }
+ const OUString& getName( ) const { return msName; }
+ void setInternalName( const OUString& rInternalName ) { msInternalName = rInternalName; }
+ const OUString& getInternalName() const { return msInternalName; }
+ void setId( const OUString& rId ) { msId = rId; }
+ const OUString& getId() const { return msId; }
+ void setDescription( const OUString& rDescr ) { msDescription = rDescr; }
+ void setHidden( bool bHidden ) { mbHidden = bHidden; }
+ void setHiddenMasterShape( bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
+ void setLocked( bool bLocked ) { mbLocked = bLocked; }
+ void setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
+ sal_Int32 getSubType() const { return mnSubType; }
+ void setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; }
+ const OptValue< sal_Int32 >& getSubTypeIndex() const { return moSubTypeIndex; }
+
+ // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
+ void setDefaults(bool bHeight);
+
+ ::oox::vml::OleObjectInfo& setOleObjectType();
+ ChartShapeInfo& setChartType( bool bEmbedShapes );
+ void setDiagramType();
+ void setTableType();
+
+ void setTextBody(const TextBodyPtr & pTextBody);
+ const TextBodyPtr& getTextBody() const { return mpTextBody;}
+ void setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle );
+ const TextListStylePtr& getMasterTextListStyle() const { return mpMasterTextListStyle; }
+
+ ShapeStyleRefMap& getShapeStyleRefs() { return maShapeStyleRefs; }
+ const ShapeStyleRefMap& getShapeStyleRefs() const { return maShapeStyleRefs; }
+ const ShapeStyleRef* getShapeStyleRef( sal_Int32 nRefType ) const;
+ bool hasShapeStyleRefs() const { return !maShapeStyleRefs.empty(); }
+
+ // addShape is creating and inserting the corresponding XShape.
+ void addShape(
+ ::oox::core::XmlFilterBase& rFilterBase,
+ const Theme* pTheme,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const basegfx::B2DHomMatrix& aTransformation,
+ const FillProperties& rShapeOrParentShapeFillProps,
+ ShapeIdMap* pShapeMap = nullptr,
+ oox::drawingml::ShapePtr pParentGroupShape = nullptr);
+
+ const css::uno::Reference< css::drawing::XShape > &
+ getXShape() const { return mxShape; }
+
+ void applyShapeReference( const Shape& rReferencedShape, bool bUseText = true );
+ const ::std::vector<OUString>&
+ getExtDrawings() const { return maExtDrawings; }
+ void addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
+ // Set font color only for extdrawings.
+ void setFontRefColorForNodes(const Color& rColor) { maFontRefColorForNodes = rColor; }
+ const Color& getFontRefColorForNodes() const { return maFontRefColorForNodes; }
+ void setLockedCanvas(bool bLockedCanvas);
+ bool getLockedCanvas() const { return mbLockedCanvas;}
+ void setWPGChild(bool bWPG);
+ bool isWPGChild() const { return mbWPGChild;}
+ void setWps(bool bWps);
+ bool getWps() const { return mbWps;}
+ void setTextBox(bool bTextBox);
+ const css::uno::Sequence<css::beans::PropertyValue> &
+ getDiagramDoms() const { return maDiagramDoms; }
+ void setDiagramDoms(const css::uno::Sequence<css::beans::PropertyValue>& rDiagramDoms) { maDiagramDoms = rDiagramDoms; }
+ css::uno::Sequence< css::uno::Sequence< css::uno::Any > >resolveRelationshipsOfTypeFromOfficeDoc(
+ core::XmlFilterBase& rFilter, const OUString& sFragment, std::u16string_view sType );
+ void setLinkedTxbxAttributes(const LinkedTxbxAttr& rhs){ maLinkedTxbxAttr = rhs; };
+ void setTxbxHasLinkedTxtBox( const bool rhs){ mbHasLinkedTxbx = rhs; };
+ const LinkedTxbxAttr& getLinkedTxbxAttributes() const { return maLinkedTxbxAttr; };
+ bool isLinkedTxbx() const { return mbHasLinkedTxbx; };
+
+ void setZOrder(sal_Int32 nZOrder) { mnZOrder = nZOrder; }
+
+ sal_Int32 getZOrder() const { return mnZOrder; }
+
+ void setZOrderOff(sal_Int32 nZOrderOff) { mnZOrderOff = nZOrderOff; }
+
+ sal_Int32 getZOrderOff() const { return mnZOrderOff; }
+
+ void setDataNodeType(sal_Int32 nDataNodeType) { mnDataNodeType = nDataNodeType; }
+
+ sal_Int32 getDataNodeType() const { return mnDataNodeType; }
+
+ void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
+
+ double getAspectRatio() const { return mfAspectRatio; }
+
+ void setVerticalShapesCount(sal_Int32 nVerticalShapesCount) { mnVerticalShapesCount = nVerticalShapesCount; }
+ sal_Int32 getVerticalShapesCount() const { return mnVerticalShapesCount; }
+
+ /// Changes reference semantics to value semantics for fill properties.
+ void cloneFillProperties();
+
+ void keepDiagramDrawing(::oox::core::XmlFilterBase& rFilterBase, const OUString& rFragmentPath);
+
+ // Allows preparation of a local Diagram helper && propagate an eventually
+ // existing one to the data holder object later
+ void prepareDiagramHelper(const std::shared_ptr< Diagram >& rDiagramPtr, const std::shared_ptr<::oox::drawingml::Theme>& rTheme);
+ void propagateDiagramHelper();
+
+ // for Writer it is necessary to migrate an existing helper to a new Shape
+ void migrateDiagramHelperToNewShape(const ShapePtr& pTarget);
+
+protected:
+
+ enum FrameType
+ {
+ FRAMETYPE_GENERIC, ///< Generic shape, no special type.
+ FRAMETYPE_OLEOBJECT, ///< OLE object embedded in a shape.
+ FRAMETYPE_CHART, ///< Chart embedded in a shape.
+ FRAMETYPE_DIAGRAM, ///< Complex diagram drawing shape.
+ FRAMETYPE_TABLE ///< A table embedded in a shape.
+ };
+
+ css::uno::Reference< css::drawing::XShape > const &
+ createAndInsert(
+ ::oox::core::XmlFilterBase& rFilterBase,
+ const OUString& rServiceName,
+ const Theme* pTheme,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ bool bClearText,
+ bool bDoNotInsertEmptyTextBody,
+ basegfx::B2DHomMatrix& aTransformation,
+ const FillProperties& rShapeOrParentShapeFillProps,
+ oox::drawingml::ShapePtr pParentGroupShape = nullptr
+ );
+
+ void addChildren(
+ ::oox::core::XmlFilterBase& rFilterBase,
+ Shape& rMaster,
+ const Theme* pTheme,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ ShapeIdMap* pShapeMap,
+ const basegfx::B2DHomMatrix& aTransformation );
+
+ void keepDiagramCompatibilityInfo();
+ void convertSmartArtToMetafile( ::oox::core::XmlFilterBase const& rFilterBase );
+
+ css::uno::Reference< css::drawing::XShape >
+ renderDiagramToGraphic( ::oox::core::XmlFilterBase const & rFilterBase );
+
+ OUString finalizeServiceName(
+ ::oox::core::XmlFilterBase& rFilter,
+ const OUString& rServiceName,
+ const css::awt::Rectangle& rShapeRect );
+
+ virtual void finalizeXShape(
+ ::oox::core::XmlFilterBase& rFilter,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes );
+
+ void putPropertyToGrabBag(
+ const OUString& sPropertyName, const css::uno::Any& aPropertyValue );
+ void putPropertyToGrabBag(
+ const css::beans::PropertyValue& pProperty );
+ void putPropertiesToGrabBag(
+ const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
+
+ FillProperties getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const;
+ LineProperties getActualLineProperties(const Theme* pTheme) const;
+ EffectProperties getActualEffectProperties(const Theme* pTheme) const;
+
+ std::vector< ShapePtr > maChildren; // only used for group shapes
+ css::awt::Size maChSize; // only used for group shapes
+ css::awt::Point maChPosition; // only used for group shapes
+
+ TextBodyPtr mpTextBody;
+ LinePropertiesPtr mpLinePropertiesPtr;
+ LinePropertiesPtr mpShapeRefLinePropPtr;
+ FillPropertiesPtr mpFillPropertiesPtr;
+ FillPropertiesPtr mpShapeRefFillPropPtr;
+ GraphicPropertiesPtr mpGraphicPropertiesPtr;
+ CustomShapePropertiesPtr mpCustomShapePropertiesPtr;
+ table::TablePropertiesPtr mpTablePropertiesPtr;
+ Shape3DPropertiesPtr mp3DPropertiesPtr;
+ EffectPropertiesPtr mpEffectPropertiesPtr;
+ EffectPropertiesPtr mpShapeRefEffectPropPtr;
+ PropertyMap maShapeProperties;
+ PropertyMap maDefaultShapeProperties;
+ TextListStylePtr mpMasterTextListStyle;
+ css::uno::Reference< css::drawing::XShape > mxShape;
+ ConnectorShapePropertiesList maConnectorShapePropertiesList;
+
+ OUString msConnectorName;
+ OUString msServiceName;
+ OUString msName;
+ OUString msInternalName; // used by diagram; not displayed in UI
+ OUString msId;
+ OUString msDescription;
+ sal_Int32 mnSubType; // if this type is not zero, then the shape is a placeholder
+ OptValue< sal_Int32 > moSubTypeIndex;
+
+ ShapeStyleRefMap maShapeStyleRefs;
+
+ css::awt::Size maSize;
+ css::awt::Point maPosition;
+ ::std::vector<OUString> maExtDrawings;
+ Color maFontRefColorForNodes;
+
+ FrameType meFrameType; ///< Type for graphic frame shapes.
+
+private:
+
+ typedef std::shared_ptr< ::oox::vml::OleObjectInfo > OleObjectInfoRef;
+ typedef std::shared_ptr< ChartShapeInfo > ChartShapeInfoRef;
+
+ OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects.
+ ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes.
+
+ sal_Int32 mnRotation;
+ sal_Int32 mnDiagramRotation; // rotates shape prior to sizing, does not affect text rotation
+ bool mbFlipH;
+ bool mbFlipV;
+ bool mbHidden;
+ bool mbHiddenMasterShape; // master shapes can be hidden in layout slides
+ // we need separate flag because we don't want
+ // to propagate it when applying reference shape
+ bool mbLocked;
+ bool mbWPGChild; // Is this shape a child of a WPG shape?
+ bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
+ bool mbWps; ///< Is this a wps shape?
+ bool mbTextBox; ///< This shape has a textbox.
+ LinkedTxbxAttr maLinkedTxbxAttr;
+ bool mbHasLinkedTxbx; // this text box has linked text box ?
+
+ css::uno::Sequence<css::beans::PropertyValue> maDiagramDoms;
+
+ /// Z-Order.
+ sal_Int32 mnZOrder = 0;
+
+ /// Z-Order offset.
+ sal_Int32 mnZOrderOff = 0;
+
+ /// Type of data node for an in-diagram shape.
+ sal_Int32 mnDataNodeType = 0;
+
+ /// Aspect ratio for an in-diagram shape.
+ double mfAspectRatio = 0;
+
+ /// Number of child shapes to be layouted vertically inside org chart in-diagram shape.
+ sal_Int32 mnVerticalShapesCount = 0;
+
+ // Is this a connector shape?
+ bool mbConnector = false;
+
+ // Is shape has bookmark?
+ bool mbHasBookmark = false;
+
+ // temporary space for DiagramHelper in preparation for collecting data
+ // Note: I tried to use a unique_ptr here, but existing constructor func does not allow that
+ svx::diagram::IDiagramHelper* mpDiagramHelper;
+
+ // association-ID to identify the Diagram ModelData
+ OUString msDiagramDataModelID;
+};
+
+}
+
+#endif // INCLUDED_OOX_DRAWINGML_SHAPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/shapecontext.hxx b/include/oox/drawingml/shapecontext.hxx
new file mode 100644
index 000000000..170f50403
--- /dev/null
+++ b/include/oox/drawingml/shapecontext.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_SHAPECONTEXT_HXX
+#define INCLUDED_OOX_DRAWINGML_SHAPECONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/contexthandler2.hxx>
+#include <oox/dllapi.h>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::drawingml {
+
+class OOX_DLLPUBLIC ShapeContext : public ::oox::core::ContextHandler2
+{
+public:
+ ShapeContext( ::oox::core::ContextHandler2Helper const & rParent, ShapePtr const & pMasterShapePtr, ShapePtr const & pShapePtr );
+ virtual ~ShapeContext() override;
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+
+ const ShapePtr& getShape() const { return mpShapePtr;}
+
+protected:
+
+ ShapePtr mpMasterShapePtr;
+ ShapePtr mpShapePtr;
+};
+
+}
+
+#endif // INCLUDED_OOX_DRAWINGML_SHAPECONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/shapegroupcontext.hxx b/include/oox/drawingml/shapegroupcontext.hxx
new file mode 100644
index 000000000..d9dfcbfa5
--- /dev/null
+++ b/include/oox/drawingml/shapegroupcontext.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/dllapi.h>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::drawingml {
+
+class OOX_DLLPUBLIC ShapeGroupContext : public ::oox::core::FragmentHandler2
+{
+public:
+ ShapeGroupContext( ::oox::core::FragmentHandler2 const & rParent, ShapePtr const & pMasterShapePtr, ShapePtr const & pGroupShapePtr );
+ virtual ~ShapeGroupContext() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+
+protected:
+ ShapePtr mpGroupShapePtr;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/shapepropertymap.hxx b/include/oox/drawingml/shapepropertymap.hxx
new file mode 100644
index 000000000..7870ddee3
--- /dev/null
+++ b/include/oox/drawingml/shapepropertymap.hxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
+#define INCLUDED_OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX
+
+#include <com/sun/star/uno/Any.hxx>
+#include <o3tl/enumarray.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/propertymap.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <tools/color.hxx>
+
+namespace oox { class ModelObjectHelper; }
+
+namespace oox::drawingml {
+
+/** Enumeration for various properties related to drawing shape formatting.
+
+ This is an abstraction for shape formatting properties that have different
+ names in various implementations, e.g. drawing shapes vs. chart objects.
+
+ If you *insert* ids into this list, then update spnCommonPropIds, spnLinearPropIds
+ and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if
+ the newly inserted enum is inside the range they cover
+ */
+enum class ShapeProperty
+{
+ LineStyle,
+ LineWidth,
+ LineColor,
+ LineTransparency,
+ LineDash, ///< Explicit line dash or name of a line dash stored in a global container.
+ LineCap,
+ LineJoint,
+ LineStart, ///< Explicit line start marker or name of a line marker stored in a global container.
+ LineStartWidth,
+ LineStartCenter,
+ LineEnd, ///< Explicit line end marker or name of a line marker stored in a global container.
+ LineEndWidth,
+ LineEndCenter,
+ FillStyle,
+ FillColor,
+ FillTransparency,
+ GradientTransparency,
+ FillGradient, ///< Explicit fill gradient or name of a fill gradient stored in a global container.
+ FillBitmap, ///< Explicit fill bitmap or name of a fill bitmap stored in a global container.
+ FillBitmapMode,
+ FillBitmapSizeX,
+ FillBitmapSizeY,
+ FillBitmapOffsetX,
+ FillBitmapOffsetY,
+ FillBitmapRectanglePoint,
+ FillHatch, ///< Explicit fill hatch or name of a fill hatch stored in a global container.
+ FillBackground,
+ FillUseSlideBackground,
+ FillBitmapName,
+ ShadowXDistance,
+ ShadowSizeX,
+ ShadowSizeY,
+ LAST = ShadowSizeY
+};
+
+typedef o3tl::enumarray<ShapeProperty, sal_Int32> ShapePropertyIds;
+
+struct OOX_DLLPUBLIC ShapePropertyInfo
+{
+ const ShapePropertyIds& mrPropertyIds;
+ bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker.
+ bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash.
+ bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient.
+ bool mbNamedFillBitmap; /// True = use named fill bitmap instead of explicit fill bitmap.
+ bool mbNamedFillHatch; /// True = use named fill hatch instead of explicit fill hatch.
+
+ static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods).
+
+ explicit ShapePropertyInfo(const ShapePropertyIds& rnPropertyIds,
+ bool bNamedLineMarker, bool bNamedLineDash,
+ bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch);
+
+ bool has(ShapeProperty ePropId) const
+ {
+ return mrPropertyIds[ePropId] >= 0;
+ }
+ sal_Int32 operator[](ShapeProperty ePropId) const
+ {
+ return mrPropertyIds[ePropId];
+ }
+};
+
+class OOX_DLLPUBLIC ShapePropertyMap : public PropertyMap
+{
+public:
+ explicit ShapePropertyMap(ModelObjectHelper& rModelObjHelper,
+ const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT );
+
+ /** Returns true, if the specified property is supported. */
+ bool supportsProperty( ShapeProperty ePropId ) const;
+
+ /** Returns true, if named line markers are supported, and the specified
+ line marker has already been inserted into the marker table. */
+ bool hasNamedLineMarkerInTable( const OUString& rMarkerName ) const;
+
+ /** Sets the specified shape property to the passed value. */
+ bool setAnyProperty( ShapeProperty ePropId, const css::uno::Any& rValue );
+
+ /** Sets the specified shape property to the passed value. */
+ template<typename Type>
+ bool setProperty(ShapeProperty ePropId, const Type& rValue)
+ {
+ return setAnyProperty(ePropId, css::uno::Any(rValue));
+ }
+ bool setProperty(ShapeProperty ePropId, const ::Color& rValue)
+ {
+ return setAnyProperty(ePropId, css::uno::Any(rValue));
+ }
+
+ using PropertyMap::setAnyProperty;
+ using PropertyMap::setProperty;
+
+private:
+ /** Sets an explicit line marker, or creates a named line marker. */
+ bool setLineMarker( sal_Int32 nPropId, const css::uno::Any& rValue );
+ /** Sets an explicit line dash, or creates a named line dash. */
+ bool setLineDash( sal_Int32 nPropId, const css::uno::Any& rValue );
+ /** Sets an explicit fill gradient, or creates a named fill gradient. */
+ bool setFillGradient( sal_Int32 nPropId, const css::uno::Any& rValue );
+ /** Creates a named transparency gradient. */
+ bool setGradientTrans( sal_Int32 nPropId, const css::uno::Any& rValue );
+ /** Sets an explicit fill bitmap, or creates a named fill bitmap. */
+ bool setFillBitmap( sal_Int32 nPropId, const css::uno::Any& rValue );
+ /** Sets an explicit fill bitmap and pushes the name to FillBitmapName */
+ bool setFillBitmapName( const css::uno::Any& rValue );
+ /** Sets an explicit fill hatch, or creates a named fill hatch. */
+ bool setFillHatch( sal_Int32 nPropId, const css::uno::Any& rValue );
+
+ // not implemented, to prevent implicit conversion from enum to int
+ css::uno::Any& operator[]( ShapeProperty ePropId ) = delete;
+ const css::uno::Any& operator[]( ShapeProperty ePropId ) const = delete;
+
+private:
+ ModelObjectHelper& mrModelObjHelper;
+ ShapePropertyInfo maShapePropInfo;
+};
+
+
+} // namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx
new file mode 100644
index 000000000..6222a4264
--- /dev/null
+++ b/include/oox/drawingml/theme.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_THEME_HXX
+#define INCLUDED_OOX_DRAWINGML_THEME_HXX
+
+#include <functional>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/drawingml/clrscheme.hxx>
+#include <oox/drawingml/shape.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/refmap.hxx>
+#include <oox/helper/refvector.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace drawing { class XDrawPage; }
+ namespace xml::dom { class XDocument; }
+}
+
+namespace oox::drawingml {
+
+struct EffectProperties;
+struct FillProperties;
+struct LineProperties;
+struct TextCharacterProperties;
+
+const sal_Int32 THEMED_STYLE_SUBTLE = 1;
+const sal_Int32 THEMED_STYLE_MODERATE = 2;
+const sal_Int32 THEMED_STYLE_INTENSE = 3;
+
+typedef RefVector< FillProperties > FillStyleList;
+typedef RefVector< LineProperties > LineStyleList;
+typedef RefVector< EffectProperties > EffectStyleList;
+typedef RefMap< sal_Int32, TextCharacterProperties > FontScheme;
+
+class TextFont;
+
+class OOX_DLLPUBLIC Theme
+{
+public:
+ void setStyleName( const OUString& rStyleName ) { maStyleName = rStyleName; }
+ void setThemeName(const OUString& rThemeName) { maThemeName = rThemeName; }
+
+ ClrScheme& getClrScheme() { return maClrScheme; }
+ const ClrScheme& getClrScheme() const { return maClrScheme; }
+
+ FillStyleList& getFillStyleList() { return maFillStyleList; }
+ const FillStyleList& getFillStyleList() const { return maFillStyleList; }
+ FillStyleList& getBgFillStyleList() { return maBgFillStyleList; }
+ const FillStyleList& getBgFillStyleList() const { return maBgFillStyleList; }
+ /** Returns the fill properties of the passed one-based themed style index. */
+ const FillProperties* getFillStyle( sal_Int32 nIndex ) const;
+
+ LineStyleList& getLineStyleList() { return maLineStyleList; }
+ const LineStyleList& getLineStyleList() const { return maLineStyleList; }
+ /** Returns the line properties of the passed one-based themed style index. */
+ const LineProperties* getLineStyle( sal_Int32 nIndex ) const;
+
+ EffectStyleList& getEffectStyleList() { return maEffectStyleList; }
+ const EffectStyleList& getEffectStyleList() const { return maEffectStyleList; }
+ const EffectProperties* getEffectStyle( sal_Int32 nIndex ) const;
+
+ FontScheme& getFontScheme() { return maFontScheme; }
+ const FontScheme& getFontScheme() const { return maFontScheme; }
+ /** Returns theme font properties by scheme type (major/minor). */
+ const TextCharacterProperties* getFontStyle( sal_Int32 nSchemeType ) const;
+ /** Returns theme font by placeholder name, e.g. the major latin theme font for the font name '+mj-lt'. */
+ const TextFont* resolveFont( const OUString& rName ) const;
+
+ Shape& getSpDef() { return maSpDef; }
+ const Shape& getSpDef() const { return maSpDef; }
+
+ Shape& getLnDef() { return maLnDef; }
+ const Shape& getLnDef() const { return maLnDef; }
+
+ Shape& getTxDef() { return maTxDef; }
+ const Shape& getTxDef() const { return maTxDef; }
+
+ const css::uno::Reference<css::xml::dom::XDocument>& getFragment() const { return mxFragment; }
+ void setFragment( const css::uno::Reference< css::xml::dom::XDocument>& xRef ) { mxFragment=xRef; }
+
+ void addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage) const;
+
+private:
+ OUString maStyleName;
+ OUString maThemeName;
+ ClrScheme maClrScheme;
+ FillStyleList maFillStyleList;
+ FillStyleList maBgFillStyleList;
+ LineStyleList maLineStyleList;
+ EffectStyleList maEffectStyleList;
+ FontScheme maFontScheme;
+ Shape maSpDef;
+ Shape maLnDef;
+ Shape maTxDef;
+ css::uno::Reference< css::xml::dom::XDocument> mxFragment;
+};
+
+
+} // namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/themefragmenthandler.hxx b/include/oox/drawingml/themefragmenthandler.hxx
new file mode 100644
index 000000000..e433c350d
--- /dev/null
+++ b/include/oox/drawingml/themefragmenthandler.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DRAWINGML_THEMEFRAGMENTHANDLER_HXX
+#define INCLUDED_OOX_DRAWINGML_THEMEFRAGMENTHANDLER_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::drawingml {
+
+class Theme;
+
+
+class OOX_DLLPUBLIC ThemeFragmentHandler final : public ::oox::core::FragmentHandler2
+{
+public:
+ explicit ThemeFragmentHandler(
+ ::oox::core::XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ Theme& rTheme );
+ virtual ~ThemeFragmentHandler() override;
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ Theme& mrTheme;
+};
+
+
+} // namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/dump/dffdumper.hxx b/include/oox/dump/dffdumper.hxx
new file mode 100644
index 000000000..e129b0a7f
--- /dev/null
+++ b/include/oox/dump/dffdumper.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DUMP_DFFDUMPER_HXX
+#define INCLUDED_OOX_DUMP_DFFDUMPER_HXX
+
+#include <oox/dump/dumperbase.hxx>
+#include <sal/types.h>
+
+#ifdef DBG_UTIL
+
+namespace oox { class BinaryInputStream; }
+
+namespace oox::dump {
+
+
+class DffStreamObject final : public SequenceRecordObjectBase
+{
+public:
+ sal_uInt16 getVer() const { return mnInstVer & 0x000F; }
+ sal_uInt16 getInst() const { return (mnInstVer & 0xFFF0) >> 4; }
+ bool isContainer() const { return getVer() == 15; }
+
+private:
+ DffStreamObject() {}
+
+ using SequenceRecordObjectBase::construct;
+
+ virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) override;
+ virtual void implWriteExtHeader() override;
+ virtual void implDumpRecordBody() override;
+
+ sal_uInt32 dumpDffSimpleColor( const String& rName );
+
+ void dumpDffOpt();
+ sal_uInt16 dumpDffOptPropHeader();
+
+ sal_uInt16 mnInstVer;
+ sal_Int32 mnRealSize;
+};
+
+
+} // namespace oox::dump
+
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/dump/dumperbase.hxx b/include/oox/dump/dumperbase.hxx
new file mode 100644
index 000000000..10d3ed78a
--- /dev/null
+++ b/include/oox/dump/dumperbase.hxx
@@ -0,0 +1,1740 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DUMP_DUMPERBASE_HXX
+#define INCLUDED_OOX_DUMP_DUMPERBASE_HXX
+
+#include <cmath>
+#include <cstddef>
+#include <map>
+#include <memory>
+#include <set>
+#include <string_view>
+#include <utility>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/util/DateTime.hpp>
+#include <oox/helper/binaryinputstream.hxx>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/string.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sal/types.h>
+
+#ifdef DBG_UTIL
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XTextOutputStream2; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+ class TextInputStream;
+}
+
+namespace oox::core {
+ class FilterBase;
+}
+
+namespace oox::dump {
+
+
+inline constexpr OUStringLiteral OOX_DUMP_UNUSED = u"unused";
+inline constexpr OUStringLiteral OOX_DUMP_UNKNOWN = u"?unknown";
+
+#define OOX_DUMP_ERRASCII( ascii ) "?err:" ascii
+
+#define OOX_DUMP_ERR_NOMAP "no-map"
+inline constexpr OUStringLiteral OOX_DUMP_ERR_NONAME = u"no-name";
+#define OOX_DUMP_ERR_STREAM "stream-error"
+
+#define OOX_DUMP_DUMPEXT ".dump"
+
+const sal_Unicode OOX_DUMP_STRQUOTE = '\'';
+const sal_Unicode OOX_DUMP_FMLASTRQUOTE = '"';
+const sal_Unicode OOX_DUMP_ADDRABS = '$';
+const sal_Unicode OOX_DUMP_R1C1ROW = 'R';
+const sal_Unicode OOX_DUMP_R1C1COL = 'C';
+const sal_Unicode OOX_DUMP_R1C1OPEN = '[';
+const sal_Unicode OOX_DUMP_R1C1CLOSE = ']';
+const sal_Unicode OOX_DUMP_RANGESEP = ':';
+const sal_Unicode OOX_DUMP_BASECLASS = 'B';
+const sal_Unicode OOX_DUMP_FUNCSEP = ',';
+const sal_Unicode OOX_DUMP_LISTSEP = ',';
+const sal_Unicode OOX_DUMP_TABSEP = '!';
+const sal_Unicode OOX_DUMP_ARRAYSEP = ';';
+const sal_Unicode OOX_DUMP_EMPTYVALUE = '~';
+const sal_Unicode OOX_DUMP_CMDPROMPT = '?';
+const sal_Unicode OOX_DUMP_PLACEHOLDER = '\x01';
+
+typedef ::std::pair< OUString, OUString > OUStringPair;
+
+typedef ::std::vector< OUString > OUStringVector;
+typedef ::std::vector< sal_Int64 > Int64Vector;
+
+
+/** Static helper functions for system file and stream access. */
+class InputOutputHelper
+{
+public:
+ // file names -------------------------------------------------------------
+
+ static OUString convertFileNameToUrl( const OUString& rFileName );
+ static sal_Int32 getFileNamePos( std::u16string_view rFileUrl );
+ static std::u16string_view getFileNameExtension( std::u16string_view rFileUrl );
+
+ // input streams ----------------------------------------------------------
+
+ static css::uno::Reference< css::io::XInputStream >
+ openInputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& rFileName );
+
+ // output streams ---------------------------------------------------------
+
+ static css::uno::Reference< css::io::XOutputStream >
+ openOutputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& rFileName );
+
+ static css::uno::Reference< css::io::XTextOutputStream2 >
+ openTextOutputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XOutputStream >& rxOutStrm,
+ rtl_TextEncoding eTextEnc );
+
+ static css::uno::Reference< css::io::XTextOutputStream2 >
+ openTextOutputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& rFileName,
+ rtl_TextEncoding eTextEnc );
+};
+
+
+class BinaryInputStreamRef : public ::oox::BinaryInputStreamRef
+{
+public:
+ BinaryInputStreamRef() {}
+
+ /*implicit*/ BinaryInputStreamRef( std::shared_ptr<BinaryInputStream> const & pInStrm ) :
+ ::oox::BinaryInputStreamRef( pInStrm ) {}
+
+ /*implicit*/ BinaryInputStreamRef( const css::uno::Reference< css::io::XInputStream >& rxInStrm ) :
+ ::oox::BinaryInputStreamRef( std::make_shared<BinaryXInputStream>( rxInStrm, true ) ) {}
+
+ template< typename StreamType >
+ /*implicit*/ BinaryInputStreamRef( const std::shared_ptr< StreamType >& rxInStrm ) :
+ ::oox::BinaryInputStreamRef( rxInStrm ) {}
+};
+
+
+/** Specifiers for atomic data types. */
+enum DataType
+{
+ DATATYPE_VOID, ///< No data type.
+ DATATYPE_INT8, ///< Signed 8-bit integer.
+ DATATYPE_UINT8, ///< Unsigned 8-bit integer.
+ DATATYPE_INT16, ///< Signed 16-bit integer.
+ DATATYPE_UINT16, ///< Unsigned 16-bit integer.
+ DATATYPE_INT32, ///< Signed 32-bit integer.
+ DATATYPE_UINT32, ///< Unsigned 32-bit integer.
+ DATATYPE_INT64, ///< Signed 64-bit integer.
+ DATATYPE_UINT64, ///< Unsigned 64-bit integer.
+ DATATYPE_FLOAT, ///< Floating-point, single precision.
+ DATATYPE_DOUBLE ///< Floating-point, double precision.
+};
+
+
+/** Specifiers for the output format of values. */
+enum FormatType
+{
+ FORMATTYPE_NONE, ///< No numeric format (e.g. show name only).
+ FORMATTYPE_DEC, ///< Decimal.
+ FORMATTYPE_HEX, ///< Hexadecimal.
+ FORMATTYPE_SHORTHEX, ///< Hexadecimal, as short as possible (no leading zeros).
+ FORMATTYPE_BIN, ///< Binary.
+ FORMATTYPE_FIX, ///< Fixed-point.
+ FORMATTYPE_BOOL ///< Boolean ('true' or 'false').
+};
+
+
+/** Describes the output format of a data item.
+
+ Data items are written in the following format:
+
+ <NAME>=<VALUE>=<NAME-FROM-LIST>
+
+ NAME is the name of the data item. The name is contained in the member
+ maItemName. If the name is empty, only the value is written (without a
+ leading equality sign).
+
+ VALUE is the numeric value of the data item. Its format is dependent on the
+ output format given in the member meFmtType. If the format type is
+ FORMATTYPE_NONE, no value is written.
+
+ NAME-FROM-LIST is a symbolic name for the current value of the data item.
+ Various types of name lists produce different names for values, which can
+ be used for enumerations or names for single bits in bitfields (see class
+ NameListBase and derived classes). The name of the list is given in the
+ member maListName. If it is empty, no name is written for the value.
+ */
+struct ItemFormat
+{
+ DataType meDataType; ///< Data type of the item.
+ FormatType meFmtType; ///< Output format for the value.
+ OUString maItemName; ///< Name of the item.
+ OUString maListName; ///< Name of a name list to be used for this item.
+
+ explicit ItemFormat();
+
+ void set( DataType eDataType, FormatType eFmtType, const OUString& rItemName );
+
+ /** Initializes the struct from a vector of strings containing the item format.
+
+ The vector must contain at least 2 strings. The struct is filled from
+ the strings in the vector in the following order:
+ 1) Data type (one of: [u]int8, [u]int16, [u]int32, [u]int64, float, double).
+ 2) Format type (one of: dec, hex, shorthex, bin, fix, bool, unused, unknown).
+ 3) Item name (optional).
+ 4) Name list name (optional).
+
+ @return Iterator pointing to the first unhandled string.
+ */
+ OUStringVector::const_iterator parse( const OUStringVector& rFormatVec );
+
+ /** Initializes the struct from a string containing the item format.
+
+ The string must have the following format:
+ DATATYPE,FORMATTYPE[,ITEMNAME[,LISTNAME]]
+
+ DATATYPE is the data type of the item (see above for possible values).
+ FORMATTYPE is the format type of the item (see above for possible values).
+ ITEMNAME is the name of the item (optional).
+ LISTNAME is the name of a name list (optional).
+
+ @return List containing remaining unhandled format strings.
+ */
+ OUStringVector parse( const OUString& rFormatStr );
+};
+
+
+/** Static helper functions for formatted output to strings. */
+class StringHelper
+{
+public:
+ // append string to string ------------------------------------------------
+
+ static void appendChar( OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount );
+ static void appendString( OUStringBuffer& rStr, const OUString& rData, sal_Int32 nWidth, sal_Unicode cFill = ' ' );
+
+ // append decimal ---------------------------------------------------------
+
+ static void appendDec( OUStringBuffer& rStr, sal_uInt8 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_Int8 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_uInt16 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_Int16 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_uInt32 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_Int32 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_uInt64 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, sal_Int64 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+ static void appendDec( OUStringBuffer& rStr, double fData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
+
+ // append hexadecimal -----------------------------------------------------
+
+ static void appendHex( OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix = true );
+ static void appendHex( OUStringBuffer& rStr, double fData, bool bPrefix = true );
+
+ // append shortened hexadecimal -------------------------------------------
+
+ static void appendShortHex( OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix = true );
+ static void appendShortHex( OUStringBuffer& rStr, double fData, bool bPrefix = true );
+
+ // append binary ----------------------------------------------------------
+
+ static void appendBin( OUStringBuffer& rStr, sal_uInt8 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_Int8 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_uInt16 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_Int16 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_uInt32 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_Int32 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_uInt64 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, sal_Int64 nData, bool bDots = true );
+ static void appendBin( OUStringBuffer& rStr, double fData, bool bDots = true );
+
+ // append fixed-point decimal ---------------------------------------------
+
+ template< typename Type >
+ static void appendFix( OUStringBuffer& rStr, Type nData, sal_Int32 nWidth = 0 );
+
+ // append formatted value -------------------------------------------------
+
+ static void appendBool( OUStringBuffer& rStr, bool bData );
+ template< typename Type >
+ static void appendValue( OUStringBuffer& rStr, Type nData, FormatType eFmtType );
+
+ // encoded text output ----------------------------------------------------
+
+ static void appendCChar( OUStringBuffer& rStr, sal_Unicode cChar, bool bPrefix = true );
+ static void appendEncChar( OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount, bool bPrefix = true );
+ static void appendEncString( OUStringBuffer& rStr, const OUString& rData, bool bPrefix = true );
+
+ // token list -------------------------------------------------------------
+
+ static void appendToken( OUStringBuffer& rStr, std::u16string_view rToken, sal_Unicode cSep = OOX_DUMP_LISTSEP );
+
+ static void appendIndex( OUStringBuffer& rStr, sal_Int64 nIdx );
+
+ static std::u16string_view getToken( std::u16string_view rData, sal_Int32& rnPos, sal_Unicode cSep = OOX_DUMP_LISTSEP );
+
+ /** Encloses the passed string with the passed characters. Uses cOpen, if cClose is NUL. */
+ static void enclose( OUStringBuffer& rStr, sal_Unicode cOpen, sal_Unicode cClose = '\0' );
+
+ // string conversion ------------------------------------------------------
+
+ static std::u16string_view trimSpaces( std::u16string_view rStr );
+ static OUString trimTrailingNul( const OUString& rStr );
+
+ static OString convertToUtf8( std::u16string_view rStr );
+ static DataType convertToDataType( std::u16string_view rStr );
+ static FormatType convertToFormatType( std::u16string_view rStr );
+
+ static bool convertFromDec( sal_Int64& ornData, std::u16string_view rData );
+ static bool convertFromHex( sal_Int64& ornData, std::u16string_view rData );
+
+ static bool convertStringToInt( sal_Int64& ornData, std::u16string_view rData );
+ static bool convertStringToDouble( double& orfData, std::u16string_view rData );
+ static bool convertStringToBool( std::u16string_view rData );
+
+ static OUStringPair convertStringToPair( const OUString& rString, sal_Unicode cSep = '=' );
+
+ // string to list conversion ----------------------------------------------
+
+ static void convertStringToStringList( OUStringVector& orVec, const OUString& rData, bool bIgnoreEmpty );
+ static void convertStringToIntList( Int64Vector& orVec, const OUString& rData, bool bIgnoreEmpty );
+};
+
+
+template< typename Type >
+void StringHelper::appendFix( OUStringBuffer& rStr, Type nData, sal_Int32 nWidth )
+{
+ appendDec( rStr, static_cast< double >( nData ) / std::pow( 2.0, 4.0 * sizeof( Type ) ), nWidth );
+}
+
+template< typename Type >
+void StringHelper::appendValue( OUStringBuffer& rStr, Type nData, FormatType eFmtType )
+{
+ switch( eFmtType )
+ {
+ case FORMATTYPE_DEC: appendDec( rStr, nData ); break;
+ case FORMATTYPE_HEX: appendHex( rStr, nData ); break;
+ case FORMATTYPE_SHORTHEX: appendShortHex( rStr, nData ); break;
+ case FORMATTYPE_BIN: appendBin( rStr, nData ); break;
+ case FORMATTYPE_FIX: appendFix( rStr, nData ); break;
+ case FORMATTYPE_BOOL: appendBool( rStr, static_cast<bool>(nData) ); break; // avoid loplugin:pointerbool warning
+ default:;
+ }
+}
+
+
+class String : public OUString
+{
+public:
+ String() {}
+ /*implicit*/ String( const OUString& rStr ) : OUString( rStr ) {}
+ /*implicit*/ String( const char* pcStr ) : OUString( OUString::createFromAscii( pcStr ? pcStr : "" ) ) {}
+ /*implicit*/ String( sal_Unicode cChar ) : OUString( cChar ) {}
+
+ bool has() const { return getLength() > 0; }
+ OUString operator()( const char* pcDefault ) const { if( has() ) return *this; return String( pcDefault ); }
+};
+
+const String EMPTY_STRING;
+
+
+/** Base class for all dumper classes.
+
+ Derived classes implement the virtual function implIsValid(). It should
+ check all members the other functions rely on. If the function
+ implIsValid() returns true, all references and pointers can be used without
+ further checking.
+
+ Overview of all classes in this header file based on this Base class:
+
+ Base
+ |
+ +----> NameListBase
+ | |
+ | +----> ConstList ------> MultiList
+ | |
+ | +----> FlagsList ------> CombiList
+ | |
+ | +----> UnitConverter
+ |
+ +----> SharedConfigData
+ |
+ +----> Config
+ |
+ +----> Output
+ |
+ +----> StorageIterator
+ |
+ +----> ObjectBase
+ |
+ +----> StorageObjectBase
+ |
+ +----> OutputObjectBase
+ | |
+ | +----> InputObjectBase
+ | |
+ | +----> BinaryStreamObject
+ | |
+ | +----> TextStreamObjectBase
+ | | |
+ | | +----> TextStreamObject
+ | | |
+ | | +----> XmlStreamObject
+ | |
+ | +----> RecordObjectBase
+ | |
+ | +----> SequenceRecordObjectBase
+ |
+ +----> DumperBase
+ */
+class Base
+{
+public:
+ virtual ~Base();
+
+ Base(Base const &) = default;
+ Base(Base &&) = default;
+ Base & operator =(Base const &) = default;
+ Base & operator =(Base &&) = default;
+
+ bool isValid() const { return implIsValid(); }
+ static bool isValid( const std::shared_ptr< Base >& rxBase ) { return rxBase && rxBase->isValid(); }
+
+protected:
+ Base() {}
+
+ virtual bool implIsValid() const = 0;
+};
+
+
+class ConfigItemBase
+{
+public:
+ virtual ~ConfigItemBase();
+ void readConfigBlock( TextInputStream& rStrm );
+
+protected:
+ ConfigItemBase() {}
+
+ virtual void implProcessConfigItemStr(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData );
+
+ virtual void implProcessConfigItemInt(
+ TextInputStream& rStrm,
+ sal_Int64 nKey,
+ const OUString& rData );
+
+ void readConfigBlockContents(
+ TextInputStream& rStrm );
+
+private:
+ enum LineType { LINETYPE_DATA, LINETYPE_END };
+
+ static LineType readConfigLine(
+ TextInputStream& rStrm,
+ OUString& orKey,
+ OUString& orData );
+
+ void processConfigItem(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData );
+};
+
+
+class SharedConfigData;
+class Config;
+
+class NameListBase;
+typedef std::shared_ptr< NameListBase > NameListRef;
+
+/** Base class of all classes providing names for specific values (name lists).
+
+ The idea is to provide a unique interface for all different methods to
+ write specific names for any values. This can be enumerations (dedicated
+ names for a subset of values), or names for bits in bit fields. Classes
+ derived from this base class implement the specific behaviour for the
+ desired purpose.
+ */
+class NameListBase : public Base, public ConfigItemBase
+{
+public:
+ typedef ::std::map< sal_Int64, OUString > OUStringMap;
+ typedef OUStringMap::const_iterator const_iterator;
+
+public:
+ virtual ~NameListBase() override;
+
+ /** Sets a name for the specified key. */
+ void setName( sal_Int64 nKey, const String& rName );
+
+ /** Include all names of the passed list. */
+ void includeList( const NameListRef& rxList );
+
+ /** Returns true, if the map contains an entry for the passed key. */
+ template< typename Type >
+ bool hasName( Type nKey ) const
+ { return maMap.count( static_cast< sal_Int64 >( nKey ) ) != 0; }
+
+ /** Returns the name for the passed key. */
+ template< typename Type >
+ OUString getName( const Config& rCfg, Type nKey ) const
+ { return implGetName( rCfg, static_cast< sal_Int64 >( nKey ) ); }
+
+ /** Returns a display name for the passed double value. */
+ OUString getName( const Config& rCfg, double fValue ) const
+ { return implGetNameDbl( rCfg, fValue ); }
+
+ /** Returns a map iterator pointing to the first contained name. */
+ const_iterator begin() const { return maMap.begin(); }
+ /** Returns a map iterator pointing one past the last contained name. */
+ const_iterator end() const { return maMap.end(); }
+
+protected:
+ explicit NameListBase( const SharedConfigData& rCfgData ) : mrCfgData( rCfgData ) {}
+
+ virtual bool implIsValid() const override;
+
+ virtual void implProcessConfigItemStr(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData ) override;
+
+ virtual void implProcessConfigItemInt(
+ TextInputStream& rStrm,
+ sal_Int64 nKey,
+ const OUString& rData ) override;
+
+ /** Derived classes set the name for the passed key. */
+ virtual void implSetName( sal_Int64 nKey, const OUString& rName ) = 0;
+ /** Derived classes generate and return the name for the passed key. */
+ virtual OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const = 0;
+ /** Derived classes generate and return the name for the passed double value. */
+ virtual OUString implGetNameDbl( const Config& rCfg, double fValue ) const = 0;
+ /** Derived classes insert all names and other settings from the passed list. */
+ virtual void implIncludeList( const NameListBase& rList ) = 0;
+
+ /** Inserts the passed name into the internal map. */
+ void insertRawName( sal_Int64 nKey, const OUString& rName );
+ /** Returns the name for the passed key, or 0, if nothing found. */
+ const OUString* findRawName( sal_Int64 nKey ) const;
+
+private:
+ /** Includes name lists, given in a comma separated list of names of the lists. */
+ void include( const OUString& rListKeys );
+ /** Excludes names from the list, given in a comma separated list of their keys. */
+ void exclude( const OUString& rKeys );
+
+private:
+ OUStringMap maMap;
+ const SharedConfigData& mrCfgData;
+};
+
+
+class ConstList : public NameListBase
+{
+public:
+ explicit ConstList( const SharedConfigData& rCfgData );
+
+ /** Enables or disables automatic quotation of returned names. */
+ void setQuoteNames( bool bQuoteNames ) { mbQuoteNames = bQuoteNames; }
+
+protected:
+ virtual void implProcessConfigItemStr(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData ) override;
+
+ /** Sets the name for the passed key. */
+ virtual void implSetName( sal_Int64 nKey, const OUString& rName ) override;
+ /** Returns the name for the passed key, or the default name, if key is not contained. */
+ virtual OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const override;
+ /** Returns the name for the passed double value. */
+ virtual OUString implGetNameDbl( const Config& rCfg, double fValue ) const override;
+ /** Inserts all names from the passed list. */
+ virtual void implIncludeList( const NameListBase& rList ) override;
+
+private:
+ OUString maDefName;
+ bool mbQuoteNames;
+};
+
+
+class MultiList : public ConstList
+{
+public:
+ explicit MultiList( const SharedConfigData& rCfgData );
+
+ void setNamesFromVec( sal_Int64 nStartKey, const OUStringVector& rNames );
+
+protected:
+ virtual void implProcessConfigItemStr(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData ) override;
+
+ virtual void implSetName( sal_Int64 nKey, const OUString& rName ) override;
+
+private:
+ bool mbIgnoreEmpty;
+};
+
+
+class FlagsList : public NameListBase
+{
+public:
+ explicit FlagsList( const SharedConfigData& rCfgData );
+
+ /** Returns the flags to be ignored on output. */
+ sal_Int64 getIgnoreFlags() const { return mnIgnore; }
+ /** Sets flags to be ignored on output. */
+ void setIgnoreFlags( sal_Int64 nIgnore ) { mnIgnore = nIgnore; }
+
+protected:
+ virtual void implProcessConfigItemStr(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData ) override;
+
+ /** Sets the name for the passed key. */
+ virtual void implSetName( sal_Int64 nKey, const OUString& rName ) override;
+ /** Returns the name for the passed key. */
+ virtual OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const override;
+ /** Returns the name for the passed double value. */
+ virtual OUString implGetNameDbl( const Config& rCfg, double fValue ) const override;
+ /** Inserts all flags from the passed list. */
+ virtual void implIncludeList( const NameListBase& rList ) override;
+
+private:
+ sal_Int64 mnIgnore;
+};
+
+
+class CombiList : public FlagsList
+{
+public:
+ explicit CombiList( const SharedConfigData& rCfgData );
+
+protected:
+ /** Sets the name for the passed key. */
+ virtual void implSetName( sal_Int64 nKey, const OUString& rName ) override;
+ /** Returns the name for the passed key. */
+ virtual OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const override;
+ /** Inserts all flags from the passed list. */
+ virtual void implIncludeList( const NameListBase& rList ) override;
+
+private:
+ struct ExtItemFormatKey
+ {
+ sal_Int64 mnKey;
+ ::std::pair< sal_Int64, sal_Int64 > maFilter;
+ explicit ExtItemFormatKey( sal_Int64 nKey ) : mnKey( nKey ), maFilter( 0, 0 ) {}
+ bool operator<( const ExtItemFormatKey& rRight ) const;
+
+ };
+ struct ExtItemFormat : public ItemFormat
+ {
+ bool mbShiftValue;
+ ExtItemFormat() : mbShiftValue( true ) {}
+ };
+ typedef ::std::map< ExtItemFormatKey, ExtItemFormat > ExtItemFormatMap;
+ ExtItemFormatMap maFmtMap;
+};
+
+
+class UnitConverter : public NameListBase
+{
+public:
+ explicit UnitConverter( const SharedConfigData& rCfgData );
+
+ void setUnitName( const String& rUnitName ) { maUnitName = rUnitName; }
+ void setFactor( double fFactor ) { mfFactor = fFactor; }
+
+protected:
+ /** Sets the name for the passed key. */
+ virtual void implSetName( sal_Int64 nKey, const OUString& rName ) override;
+ /** Returns the converted value with appended unit name. */
+ virtual OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const override;
+ /** Returns the converted value with appended unit name. */
+ virtual OUString implGetNameDbl( const Config& rCfg, double fValue ) const override;
+ /** Empty implementation. */
+ virtual void implIncludeList( const NameListBase& rList ) override;
+
+private:
+ OUString maUnitName;
+ double mfFactor;
+};
+
+
+class NameListWrapper
+{
+public:
+ NameListWrapper() {}
+ /*implicit*/ NameListWrapper( const OUString& rListName ) : maName( rListName ) {}
+ /*implicit*/ NameListWrapper( const char* pcListName ) : maName( pcListName ) {}
+ /*implicit*/ NameListWrapper( const NameListRef& rxList ) : mxList( rxList ) {}
+
+ bool isEmpty() const { return !mxList && !maName.has(); }
+ const NameListRef & getNameList( const Config& rCfg ) const;
+
+private:
+ String maName;
+ mutable NameListRef mxList;
+};
+
+const NameListWrapper NO_LIST;
+
+
+class ItemFormatMap
+{
+private:
+ ::std::map< sal_Int64, ItemFormat > maMap;
+
+public:
+ ItemFormatMap() {}
+ explicit ItemFormatMap( const NameListRef& rxNameList ) { insertFormats( rxNameList ); }
+
+ ::std::map< sal_Int64, ItemFormat >::const_iterator end() const { return maMap.end(); }
+ ::std::map< sal_Int64, ItemFormat >::const_iterator find(sal_Int64 nId) const
+ {
+ return maMap.find(nId);
+ }
+
+ void insertFormats( const NameListRef& rxNameList );
+};
+
+
+class SharedConfigData : public Base, public ConfigItemBase
+{
+public:
+ explicit SharedConfigData(
+ const OUString& rFileName,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const StorageRef& rxRootStrg,
+ const OUString& rSysFileName );
+
+ virtual ~SharedConfigData() override;
+
+ const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return mxContext; }
+ const StorageRef& getRootStorage() const { return mxRootStrg; }
+ const OUString& getSysFileName() const { return maSysFileName; }
+
+ const OUString* getOption( const OUString& rKey ) const;
+
+ template< typename ListType >
+ std::shared_ptr< ListType > createNameList( const OUString& rListName );
+ void setNameList( const OUString& rListName, const NameListRef& rxList );
+ void eraseNameList( const OUString& rListName );
+ NameListRef getNameList( const OUString& rListName ) const;
+
+protected:
+ virtual bool implIsValid() const override;
+ virtual void implProcessConfigItemStr(
+ TextInputStream& rStrm,
+ const OUString& rKey,
+ const OUString& rData ) override;
+
+private:
+ bool readConfigFile( const OUString& rFileUrl );
+ template< typename ListType >
+ void readNameList( TextInputStream& rStrm, const OUString& rListName );
+ void createShortList( const OUString& rData );
+ void createUnitConverter( const OUString& rData );
+
+private:
+ typedef ::std::set< OUString > ConfigFileSet;
+ typedef ::std::map< OUString, OUString > ConfigDataMap;
+ typedef ::std::map< OUString, NameListRef > NameListMap;
+
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+ StorageRef mxRootStrg;
+ OUString maSysFileName;
+ ConfigFileSet maConfigFiles;
+ ConfigDataMap maConfigData;
+ NameListMap maNameLists;
+ OUString maConfigPath;
+ bool mbLoaded;
+};
+
+
+template< typename ListType >
+std::shared_ptr< ListType > SharedConfigData::createNameList( const OUString& rListName )
+{
+ std::shared_ptr< ListType > xList;
+ if( !rListName.isEmpty() )
+ {
+ xList = std::make_shared<ListType>( *this );
+ setNameList( rListName, xList );
+ }
+ return xList;
+}
+
+template< typename ListType >
+void SharedConfigData::readNameList( TextInputStream& rStrm, const OUString& rListName )
+{
+ NameListRef xList = createNameList< ListType >( rListName );
+ if( xList )
+ xList->readConfigBlock( rStrm );
+}
+
+
+class Config : public Base
+{
+public:
+ explicit Config(
+ const char* pcEnvVar,
+ const ::oox::core::FilterBase& rFilter );
+ explicit Config(
+ const char* pcEnvVar,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const StorageRef& rxRootStrg,
+ const OUString& rSysFileName );
+
+ virtual ~Config() override;
+
+ Config(Config const &) = default;
+ Config(Config &&) = default;
+ Config & operator =(Config const &) = default;
+ Config & operator =(Config &&) = default;
+
+ const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return mxCfgData->getContext(); }
+ const StorageRef& getRootStorage() const { return mxCfgData->getRootStorage(); }
+ const OUString& getSysFileName() const { return mxCfgData->getSysFileName(); }
+
+ const OUString& getStringOption( const String& rKey, const OUString& rDefault ) const;
+ bool getBoolOption( const String& rKey, bool bDefault ) const;
+ template< typename Type >
+ Type getIntOption( const String& rKey, Type nDefault ) const;
+
+ bool isDumperEnabled() const;
+ bool isImportEnabled() const;
+
+ template< typename ListType >
+ std::shared_ptr< ListType > createNameList( const String& rListName );
+ void eraseNameList( const String& rListName );
+ NameListRef getNameList( const String& rListName ) const;
+
+ /** Returns the name for the passed key from the passed name list. */
+ template< typename Type >
+ OUString getName( const NameListWrapper& rListWrp, Type nKey ) const;
+ /** Returns true, if the passed name list contains an entry for the passed key. */
+ template< typename Type >
+ bool hasName( const NameListWrapper& rListWrp, Type nKey ) const;
+
+protected:
+ Config() {}
+ void construct(
+ const char* pcEnvVar,
+ const ::oox::core::FilterBase& rFilter );
+ void construct(
+ const char* pcEnvVar,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const StorageRef& rxRootStrg,
+ const OUString& rSysFileName );
+
+ virtual bool implIsValid() const override;
+ const OUString* implGetOption( const OUString& rKey ) const;
+
+private:
+ std::shared_ptr< SharedConfigData > mxCfgData;
+};
+
+typedef std::shared_ptr< Config > ConfigRef;
+
+
+template< typename Type >
+Type Config::getIntOption( const String& rKey, Type nDefault ) const
+{
+ sal_Int64 nRawData;
+ const OUString* pData = implGetOption( rKey );
+ return (pData && StringHelper::convertStringToInt( nRawData, *pData )) ?
+ static_cast< Type >( nRawData ) : nDefault;
+}
+
+template< typename ListType >
+std::shared_ptr< ListType > Config::createNameList( const String& rListName )
+{
+ return mxCfgData->createNameList< ListType >( rListName );
+}
+
+template< typename Type >
+OUString Config::getName( const NameListWrapper& rListWrp, Type nKey ) const
+{
+ NameListRef xList = rListWrp.getNameList( *this );
+ return xList ? xList->getName( *this, nKey ) : OOX_DUMP_ERR_NOMAP;
+}
+
+template< typename Type >
+bool Config::hasName( const NameListWrapper& rListWrp, Type nKey ) const
+{
+ NameListRef xList = rListWrp.getNameList( *this );
+ return xList.get() && xList->hasName( nKey );
+}
+
+
+class Output : public Base
+{
+public:
+ explicit Output(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& rFileName );
+
+
+ void newLine();
+ void emptyLine( size_t nCount = 1 );
+
+ void incIndent();
+ void decIndent();
+
+ void startTable( sal_Int32 nW1 );
+ void startTable( sal_Int32 nW1, sal_Int32 nW2 );
+ void startTable( sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 );
+ void startTable( size_t nColCount, const sal_Int32* pnColWidths );
+ void tab();
+ void tab( size_t nCol );
+ void endTable();
+
+ void resetItemIndex( sal_Int64 nIdx = 0 );
+ void startItem( const String& rItemName );
+ void contItem();
+ void endItem();
+
+ void startMultiItems();
+ void endMultiItems();
+
+ void writeChar( sal_Unicode cChar, sal_Int32 nCount = 1 );
+ void writeAscii( const char* pcStr );
+ void writeString( const OUString& rStr );
+ void writeArray( const sal_uInt8* pnData, std::size_t nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP );
+ void writeBool( bool bData );
+ void writeDateTime( const css::util::DateTime& rDateTime );
+
+ template< typename Type >
+ void writeDec( Type nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' )
+ { StringHelper::appendDec( maLine, nData, nWidth, cFill ); }
+ template< typename Type >
+ void writeHex( Type nData, bool bPrefix = true )
+ { StringHelper::appendHex( maLine, nData, bPrefix ); }
+ template< typename Type >
+ void writeShortHex( Type nData, bool bPrefix = true )
+ { StringHelper::appendShortHex( maLine, nData, bPrefix ); }
+ template< typename Type >
+ void writeBin( Type nData, bool bDots = true )
+ { StringHelper::appendBin( maLine, nData, bDots ); }
+ template< typename Type >
+ void writeFix( Type nData, sal_Int32 nWidth )
+ { StringHelper::appendFix( maLine, nData, nWidth ); }
+ template< typename Type >
+ void writeValue( Type nData, FormatType eFmtType )
+ { StringHelper::appendValue( maLine, nData, eFmtType ); }
+ template< typename Type >
+ void writeName( const Config& rCfg, Type nData, const NameListWrapper& rListWrp )
+ { writeString( rCfg.getName( rListWrp, nData ) ); }
+
+
+protected:
+ virtual bool implIsValid() const override;
+
+private:
+ void writeItemName( const String& rItemName );
+
+private:
+ css::uno::Reference< css::io::XTextOutputStream2 > mxStrm;
+ OUString maIndent;
+ OUStringBuffer maLine;
+ OUString maLastItem;
+ ::std::vector< sal_Int32 >
+ maColPos;
+ size_t mnCol;
+ size_t mnItemLevel;
+ size_t mnMultiLevel;
+ sal_Int64 mnItemIdx;
+ sal_Int32 mnLastItem;
+};
+
+typedef std::shared_ptr< Output > OutputRef;
+
+
+class IndentGuard
+{
+public:
+ explicit IndentGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.incIndent(); }
+ ~IndentGuard() { mrOut.decIndent(); }
+private:
+ IndentGuard( const IndentGuard& ) = delete;
+ IndentGuard& operator=( const IndentGuard& ) = delete;
+private:
+ Output& mrOut;
+};
+
+
+class TableGuard
+{
+public:
+ explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1 ) :
+ mrOut( *rxOut ) { mrOut.startTable( nW1 ); }
+ explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2 ) :
+ mrOut( *rxOut ) { mrOut.startTable( nW1, nW2 ); }
+ explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) :
+ mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); }
+ explicit TableGuard( const OutputRef& rxOut, size_t nColCount,
+ const sal_Int32* pnColWidths ) :
+ mrOut( *rxOut ) { mrOut.startTable( nColCount, pnColWidths ); }
+ ~TableGuard() { mrOut.endTable(); }
+ void tab( size_t nCol ) { mrOut.tab( nCol ); }
+private:
+ TableGuard( const TableGuard& ) = delete;
+ TableGuard& operator=( const TableGuard& ) = delete;
+private:
+ Output& mrOut;
+};
+
+
+class ItemGuard
+{
+public:
+ explicit ItemGuard( const OutputRef& rxOut, const String& rName ) :
+ mrOut( *rxOut ) { mrOut.startItem( rName ); }
+ ~ItemGuard() { mrOut.endItem(); }
+ void cont() { mrOut.contItem(); }
+private:
+ ItemGuard( const ItemGuard& ) = delete;
+ ItemGuard& operator=( const ItemGuard& ) = delete;
+private:
+ Output& mrOut;
+};
+
+
+class MultiItemsGuard
+{
+public:
+ explicit MultiItemsGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.startMultiItems(); }
+ ~MultiItemsGuard() { mrOut.endMultiItems(); }
+private:
+ MultiItemsGuard( const MultiItemsGuard& ) = delete;
+ MultiItemsGuard& operator=( const MultiItemsGuard& ) = delete;
+private:
+ Output& mrOut;
+};
+
+
+class StorageIterator : public Base
+{
+public:
+ explicit StorageIterator( const StorageRef& rxStrg );
+ virtual ~StorageIterator() override;
+
+ StorageIterator& operator++();
+
+ OUString getName() const;
+ bool isStream() const;
+ bool isStorage() const;
+
+private:
+ virtual bool implIsValid() const override;
+
+private:
+ StorageRef mxStrg;
+ OUStringVector maNames;
+ OUStringVector::const_iterator maIt;
+};
+
+
+class ObjectBase : public Base
+{
+public:
+ virtual ~ObjectBase() override;
+
+ ObjectBase(ObjectBase const &) = default;
+ ObjectBase(ObjectBase &&) = default;
+ ObjectBase & operator =(ObjectBase const &) = default;
+ ObjectBase & operator =(ObjectBase &&) = default;
+
+ const css::uno::Reference< css::uno::XComponentContext >&
+ getContext() const { return mxConfig->getContext(); }
+
+ void dump();
+
+
+protected:
+ ObjectBase() {}
+
+ void construct( const ConfigRef& rxConfig );
+ void construct( const ObjectBase& rParent );
+
+ virtual bool implIsValid() const override;
+ virtual void implDump();
+
+
+ Config& cfg() const { return *mxConfig; }
+
+private:
+ ConfigRef mxConfig;
+};
+
+typedef std::shared_ptr< ObjectBase > ObjectRef;
+
+
+class StorageObjectBase : public ObjectBase
+{
+protected:
+ StorageObjectBase() {}
+
+protected:
+ using ObjectBase::construct;
+ void construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath );
+ void construct( const ObjectBase& rParent );
+
+ virtual bool implIsValid() const override;
+ virtual void implDump() override;
+
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName );
+
+ virtual void implDumpStorage(
+ const StorageRef& rxStrg,
+ const OUString& rStrgPath,
+ const OUString& rSysPath );
+
+ virtual void implDumpBaseStream(
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName );
+
+ void addPreferredStream( const String& rStrmName );
+ void addPreferredStorage( const String& rStrgPath );
+
+private:
+ static OUString getSysFileName(
+ const OUString& rStrmName,
+ std::u16string_view rSysOutPath );
+
+ void extractStream(
+ StorageBase& rStrg,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName );
+ void extractStorage(
+ const StorageRef& rxStrg,
+ const OUString& rStrgPath,
+ const OUString& rSysPath );
+
+ void extractItem(
+ const StorageRef& rxStrg,
+ const OUString& rStrgPath,
+ const OUString& rItemName,
+ std::u16string_view rSysPath,
+ bool bIsStrg, bool bIsStrm );
+
+private:
+ struct PreferredItem
+ {
+ OUString maName;
+ bool mbStorage;
+
+ explicit PreferredItem( const OUString& rName, bool bStorage ) :
+ maName( rName ), mbStorage( bStorage ) {}
+ };
+ typedef ::std::vector< PreferredItem > PreferredItemVector;
+
+ StorageRef mxStrg;
+ OUString maSysPath;
+ PreferredItemVector maPreferred;
+};
+
+
+class OutputObjectBase : public ObjectBase
+{
+public:
+ virtual ~OutputObjectBase() override;
+
+ OutputObjectBase(OutputObjectBase const &) = default;
+ OutputObjectBase(OutputObjectBase &&) = default;
+ OutputObjectBase & operator =(OutputObjectBase const &) = default;
+ OutputObjectBase & operator =(OutputObjectBase &&) = default;
+
+protected:
+ OutputObjectBase() {}
+
+ using ObjectBase::construct;
+ void construct( const ObjectBase& rParent, const OUString& rSysFileName );
+ void construct( const OutputObjectBase& rParent );
+
+ virtual bool implIsValid() const override;
+
+
+ void writeEmptyItem( const String& rName );
+ void writeInfoItem( const String& rName, const String& rData );
+ void writeCharItem( const String& rName, sal_Unicode cData );
+ void writeStringItem( const String& rName, const OUString& rData );
+ void writeArrayItem( const String& rName, const sal_uInt8* pnData, std::size_t nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP );
+ void writeDateTimeItem( const String& rName, const css::util::DateTime& rDateTime );
+ void writeGuidItem( const String& rName, const OUString& rGuid );
+
+ template< typename Type >
+ void addNameToItem( Type nData, const NameListWrapper& rListWrp );
+
+ template< typename Type >
+ void writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp );
+ template< typename Type >
+ void writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ void writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ void writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ void writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ void writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ void writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ void writeValueItem( const String& rName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp = NO_LIST );
+
+ template< typename Type >
+ void writeValueItem( const ItemFormat& rItemFmt, Type nData );
+
+ template< typename Type >
+ void writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' );
+ template< typename Type >
+ void writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' );
+
+protected:
+ OutputRef mxOut;
+ OUString maSysFileName;
+};
+
+
+template< typename Type >
+void OutputObjectBase::addNameToItem( Type nData, const NameListWrapper& rListWrp )
+{
+ if( !rListWrp.isEmpty() )
+ {
+ mxOut->contItem();
+ mxOut->writeName( cfg(), nData, rListWrp );
+ }
+}
+
+template< typename Type >
+void OutputObjectBase::writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeName( cfg(), nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeDec( nData );
+ addNameToItem( nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeHex( nData );
+ addNameToItem( nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeShortHex( nData );
+ addNameToItem( nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeBin( nData );
+ addNameToItem( nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeFix( nData );
+ addNameToItem( nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeDec( nData );
+ aItem.cont();
+ mxOut->writeBool( nData != 0 );
+ addNameToItem( nData, rListWrp );
+}
+
+template< typename Type >
+void OutputObjectBase::writeValueItem( const String& rName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp )
+{
+ if( eFmtType == FORMATTYPE_BOOL )
+ writeDecBoolItem( rName, nData, rListWrp );
+ else
+ {
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeValue( nData, eFmtType );
+ addNameToItem( nData, rListWrp );
+ }
+}
+
+template< typename Type >
+void OutputObjectBase::writeValueItem( const ItemFormat& rItemFmt, Type nData )
+{
+ OString aNameUtf8 = StringHelper::convertToUtf8( rItemFmt.maItemName );
+ writeValueItem( aNameUtf8.getStr(), nData, rItemFmt.meFmtType, rItemFmt.maListName );
+}
+
+template< typename Type >
+void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeDec( nData1 );
+ mxOut->writeChar( cSep );
+ mxOut->writeDec( nData2 );
+}
+
+template< typename Type >
+void OutputObjectBase::writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep )
+{
+ ItemGuard aItem( mxOut, rName );
+ mxOut->writeHex( nData1 );
+ mxOut->writeChar( cSep );
+ mxOut->writeHex( nData2 );
+}
+
+
+class InputObjectBase : public OutputObjectBase
+{
+public:
+ virtual ~InputObjectBase() override;
+
+ InputObjectBase(InputObjectBase const &) = default;
+ InputObjectBase(InputObjectBase &&) = default;
+ InputObjectBase & operator =(InputObjectBase const &) = default;
+ InputObjectBase & operator =(InputObjectBase &&) = default;
+
+protected:
+ InputObjectBase() {}
+
+ using OutputObjectBase::construct;
+ void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
+ void construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm );
+ void construct( const InputObjectBase& rParent );
+
+ virtual bool implIsValid() const override;
+
+ void skipBlock( sal_Int64 nBytes, bool bShowSize = true );
+ void dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bStream = false );
+
+ void dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset = true );
+ void dumpRemaining( sal_Int64 nBytes );
+ void dumpRemainingTo( sal_Int64 nPos );
+ void dumpRemainingStream();
+
+ void dumpArray( const String& rName, sal_Int32 nBytes, sal_Unicode cSep = OOX_DUMP_LISTSEP );
+ void dumpUnused( sal_Int32 nBytes ) { dumpArray( OUString(OOX_DUMP_UNUSED), nBytes ); }
+ void dumpUnknown( sal_Int32 nBytes ) { dumpArray( OUString(OOX_DUMP_UNKNOWN), nBytes ); }
+
+ sal_Unicode dumpUnicode( const String& rName );
+
+ OUString dumpCharArray( const String& rName, sal_Int32 nLen, rtl_TextEncoding eTextEnc, bool bHideTrailingNul = false );
+ OUString dumpUnicodeArray( const String& rName, sal_Int32 nLen, bool bHideTrailingNul = false );
+
+ css::util::DateTime dumpFileTime( const String& rName = EMPTY_STRING );
+ OUString dumpGuid( const String& rName = EMPTY_STRING );
+
+ void dumpItem( const ItemFormat& rItemFmt );
+
+ template< typename Type >
+ Type dumpName( const String& rName, const NameListWrapper& rListWrp );
+ template< typename Type >
+ Type dumpDec( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ Type dumpHex( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ Type dumpBin( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ Type dumpFix( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ Type dumpBool( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ Type dumpValue( const ItemFormat& rItemFmt );
+
+ template< typename Type1, typename Type2 >
+ Type1 dumpName( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type1, typename Type2 >
+ Type1 dumpDec( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type1, typename Type2 >
+ Type1 dumpHex( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type1, typename Type2 >
+ Type1 dumpBin( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type1, typename Type2 >
+ Type1 dumpFix( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type1, typename Type2 >
+ Type1 dumpBool( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type1, typename Type2 >
+ Type1 dumpValue( bool bType1, const ItemFormat& rItemFmt );
+
+ template< typename Type >
+ void dumpDecPair( const String& rName, sal_Unicode cSep = ',' );
+ template< typename Type >
+ void dumpHexPair( const String& rName, sal_Unicode cSep = ',' );
+
+protected:
+ BinaryInputStreamRef mxStrm;
+};
+
+
+template< typename Type >
+Type InputObjectBase::dumpName( const String& rName, const NameListWrapper& rListWrp )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeNameItem( rName, nData, rListWrp );
+ return nData;
+}
+
+template< typename Type >
+Type InputObjectBase::dumpDec( const String& rName, const NameListWrapper& rListWrp )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeDecItem( rName, nData, rListWrp );
+ return nData;
+}
+
+template< typename Type >
+Type InputObjectBase::dumpHex( const String& rName, const NameListWrapper& rListWrp )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeHexItem( rName, nData, rListWrp );
+ return nData;
+}
+
+template< typename Type >
+Type InputObjectBase::dumpBin( const String& rName, const NameListWrapper& rListWrp )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeBinItem( rName, nData, rListWrp );
+ return nData;
+}
+
+template< typename Type >
+Type InputObjectBase::dumpFix( const String& rName, const NameListWrapper& rListWrp )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeFixItem( rName, nData, rListWrp );
+ return nData;
+}
+
+template< typename Type >
+Type InputObjectBase::dumpBool( const String& rName, const NameListWrapper& rListWrp )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeDecBoolItem( rName, nData, rListWrp );
+ return nData;
+}
+
+template< typename Type >
+Type InputObjectBase::dumpValue( const ItemFormat& rItemFmt )
+{
+ Type nData = mxStrm->readValue<Type>();
+ writeValueItem( rItemFmt, nData );
+ return nData;
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpName( bool bType1, const String& rName, const NameListWrapper& rListWrp )
+{
+ return bType1 ? dumpName< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpName< Type2 >( rName, rListWrp ) );
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpDec( bool bType1, const String& rName, const NameListWrapper& rListWrp )
+{
+ return bType1 ? dumpDec< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpDec< Type2 >( rName, rListWrp ) );
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpHex( bool bType1, const String& rName, const NameListWrapper& rListWrp )
+{
+ return bType1 ? dumpHex< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpHex< Type2 >( rName, rListWrp ) );
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpBin( bool bType1, const String& rName, const NameListWrapper& rListWrp )
+{
+ return bType1 ? dumpBin< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpBin< Type2 >( rName, rListWrp ) );
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpFix( bool bType1, const String& rName, const NameListWrapper& rListWrp )
+{
+ return bType1 ? dumpFix< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpFix< Type2 >( rName, rListWrp ) );
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpBool( bool bType1, const String& rName, const NameListWrapper& rListWrp )
+{
+ return bType1 ? dumpBool< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpBool< Type2 >( rName, rListWrp ) );
+}
+
+template< typename Type1, typename Type2 >
+Type1 InputObjectBase::dumpValue( bool bType1, const ItemFormat& rItemFmt )
+{
+ return bType1 ? dumpValue< Type1 >( rItemFmt ) : static_cast< Type1 >( dumpValue< Type2 >( rItemFmt ) );
+}
+
+template< typename Type >
+void InputObjectBase::dumpDecPair( const String& rName, sal_Unicode cSep )
+{
+ Type nData1, nData2;
+ *mxStrm >> nData1 >> nData2;
+ writeDecPairItem( rName, nData1, nData2, cSep );
+}
+
+template< typename Type >
+void InputObjectBase::dumpHexPair( const String& rName, sal_Unicode cSep )
+{
+ Type nData1, nData2;
+ *mxStrm >> nData1 >> nData2;
+ writeHexPairItem( rName, nData1, nData2, cSep );
+}
+
+
+class BinaryStreamObject final : public InputObjectBase
+{
+public:
+ explicit BinaryStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName );
+
+private:
+ void dumpBinaryStream( bool bShowOffset = true );
+
+ virtual void implDump() override;
+};
+
+
+class TextStreamObjectBase : public InputObjectBase
+{
+protected:
+ TextStreamObjectBase() {}
+
+ using InputObjectBase::construct;
+ void construct(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ rtl_TextEncoding eTextEnc,
+ const OUString& rSysFileName );
+ void construct(
+ const OutputObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ rtl_TextEncoding eTextEnc );
+
+ virtual bool implIsValid() const override;
+ virtual void implDump() override;
+
+ virtual void implDumpText( TextInputStream& rTextStrm ) = 0;
+
+private:
+ void constructTextStrmObj( rtl_TextEncoding eTextEnc );
+
+ std::shared_ptr< TextInputStream > mxTextStrm;
+};
+
+
+class TextLineStreamObject final : public TextStreamObjectBase
+{
+public:
+ explicit TextLineStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ rtl_TextEncoding eTextEnc,
+ const OUString& rSysFileName );
+
+ explicit TextLineStreamObject(
+ const OutputObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ rtl_TextEncoding eTextEnc );
+
+private:
+ virtual void implDumpText( TextInputStream& rTextStrm ) override;
+ void implDumpLine( const OUString& rLine, sal_uInt32 nLine );
+};
+
+
+class XmlStreamObject : public TextStreamObjectBase
+{
+public:
+ explicit XmlStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName );
+
+protected:
+ virtual void implDumpText( TextInputStream& rTextStrm ) override;
+};
+
+
+class RecordObjectBase : public InputObjectBase
+{
+protected:
+ RecordObjectBase() {}
+
+ using InputObjectBase::construct;
+ void construct(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxBaseStrm,
+ const OUString& rSysFileName,
+ const BinaryInputStreamRef& rxRecStrm,
+ const String& rRecNames,
+ const String& rSimpleRecs );
+
+ sal_Int64 getRecId() const { return mnRecId; }
+ sal_Int64 getRecSize() const { return mnRecSize; }
+
+ virtual bool implIsValid() const override;
+ virtual void implDump() override;
+
+ virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ) = 0;
+ virtual void implWriteExtHeader();
+ virtual void implDumpRecordBody();
+
+private:
+ void constructRecObjBase(
+ const BinaryInputStreamRef& rxBaseStrm,
+ const String& rRecNames,
+ const String& rSimpleRecs );
+
+ void writeHeader();
+
+private:
+ BinaryInputStreamRef mxBaseStrm;
+ NameListWrapper maRecNames;
+ NameListWrapper maSimpleRecs;
+ sal_Int64 mnRecPos;
+ sal_Int64 mnRecId;
+ sal_Int64 mnRecSize;
+ bool mbShowRecPos;
+ bool mbBinaryOnly;
+};
+
+
+class SequenceRecordObjectBase : public RecordObjectBase
+{
+protected:
+ SequenceRecordObjectBase() : mxRecData( std::make_shared<StreamDataSequence>() ) {}
+
+ using RecordObjectBase::construct;
+ void construct(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxBaseStrm,
+ const OUString& rSysFileName,
+ const String& rRecNames,
+ const String& rSimpleRecs );
+
+ virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ) override;
+ virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) = 0;
+
+private:
+ std::shared_ptr< StreamDataSequence > mxRecData;
+};
+
+
+/** Base class for a file dumper. Derived classes implement the implDump()
+ function to add functionality.
+ */
+class DumperBase : public ObjectBase
+{
+public:
+ virtual ~DumperBase() override;
+
+ bool isImportEnabled() const;
+
+protected:
+ DumperBase() {}
+
+ using ObjectBase::construct;
+ void construct( const ConfigRef& rxConfig );
+};
+
+
+} // namespace oox::dump
+
+#define OOX_DUMP_FILE( DumperClassName ) \
+do { \
+ DumperClassName aDumper( *this ); \
+ aDumper.dump(); \
+ if( !aDumper.isImportEnabled() ) \
+ return aDumper.isValid(); \
+} while( false )
+
+#else // DBG_UTIL
+
+#define OOX_DUMP_FILE( DumperClassName ) (void)0
+
+#endif // DBG_UTIL
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/dump/oledumper.hxx b/include/oox/dump/oledumper.hxx
new file mode 100644
index 000000000..77b3ab14c
--- /dev/null
+++ b/include/oox/dump/oledumper.hxx
@@ -0,0 +1,849 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DUMP_OLEDUMPER_HXX
+#define INCLUDED_OOX_DUMP_OLEDUMPER_HXX
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dump/dumperbase.hxx>
+#include <oox/helper/binaryinputstream.hxx>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#ifdef DBG_UTIL
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+}
+
+namespace oox::dump {
+
+
+class OleInputObjectBase : public InputObjectBase
+{
+protected:
+ OleInputObjectBase() {}
+
+ OUString dumpAnsiString32( const String& rName );
+ OUString dumpUniString32( const String& rName );
+
+ sal_Int32 dumpStdClipboardFormat( const String& rName );
+ OUString dumpAnsiString32OrStdClip( const String& rName );
+ OUString dumpUniString32OrStdClip( const String& rName );
+
+ void writeOleColorItem( const String& rName, sal_uInt32 nColor );
+ sal_uInt32 dumpOleColor( const String& rName );
+};
+
+
+class StdFontObject : public OleInputObjectBase
+{
+public:
+ explicit StdFontObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDump() override;
+};
+
+
+class StdPicObject : public OleInputObjectBase
+{
+public:
+ explicit StdPicObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDump() override;
+};
+
+
+class OleStreamObject : public OleInputObjectBase
+{
+public:
+ explicit OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
+};
+
+
+class OleCompObjObject : public OleStreamObject
+{
+public:
+ explicit OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
+
+protected:
+ virtual void implDump() override;
+};
+
+
+class OlePropertyStreamObject : public InputObjectBase
+{
+public:
+ explicit OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
+
+protected:
+ virtual void implDump() override;
+
+private:
+ void dumpSection( const OUString& rGuid, sal_uInt32 nStartPos );
+
+ void dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos );
+ void dumpCodePageProperty( sal_uInt32 nStartPos );
+ void dumpDictionaryProperty( sal_uInt32 nStartPos );
+
+ sal_uInt16 dumpPropertyContents( sal_Int32 nPropId );
+ void dumpPropertyValue( sal_Int32 nPropId, sal_uInt16 nBaseType );
+ void dumpPropertyVector( sal_Int32 nPropId, sal_uInt16 nBaseType );
+
+ sal_uInt16 dumpPropertyType();
+ void dumpBlob( sal_Int32 nPropId, const String& rName );
+ OUString dumpString8( const String& rName );
+ OUString dumpCharArray8( const String& rName, sal_Int32 nLen );
+ OUString dumpString16( const String& rName );
+ OUString dumpCharArray16( const String& rName, sal_Int32 nLen );
+ bool dumpTypedProperty( const String& rName, sal_uInt16 nExpectedType );
+ void dumpHlinks( sal_Int32 nSize );
+
+ bool startElement( sal_uInt32 nStartPos );
+ void writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos );
+ void writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos );
+
+private:
+ NameListRef mxPropIds;
+ rtl_TextEncoding meTextEnc;
+ bool mbIsUnicode;
+};
+
+
+class OleStorageObject : public StorageObjectBase
+{
+public:
+ explicit OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath );
+
+protected:
+ OleStorageObject() {}
+
+ using StorageObjectBase::construct;
+
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+};
+
+
+class ComCtlObjectBase : public OleInputObjectBase
+{
+protected:
+ explicit ComCtlObjectBase(
+ const InputObjectBase& rParent,
+ sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion,
+ bool bCommonPart, bool bComplexPart );
+
+ virtual void implDump() override;
+ virtual void implDumpProperties() = 0;
+ virtual void implDumpCommonExtra( sal_Int64 nEndPos );
+ virtual void implDumpCommonTrailing();
+
+private:
+ bool dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor = SAL_MAX_UINT16, sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
+ bool dumpComCtlSize();
+ bool dumpComCtlData( sal_uInt32& ornCommonPartSize );
+ bool dumpComCtlCommon( sal_uInt32 nPartSize );
+ bool dumpComCtlComplex();
+
+protected:
+ sal_uInt32 mnDataId5;
+ sal_uInt32 mnDataId6;
+ sal_uInt16 mnVersion;
+ bool mbCommonPart;
+ bool mbComplexPart;
+};
+
+
+class ComCtlScrollBarObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+};
+
+
+class ComCtlProgressBarObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+};
+
+
+class ComCtlSliderObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+};
+
+
+class ComCtlUpDownObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+};
+
+
+class ComCtlImageListObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+ virtual void implDumpCommonExtra( sal_Int64 nEndPos ) override;
+ virtual void implDumpCommonTrailing() override;
+};
+
+
+class ComCtlTabStripObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+ virtual void implDumpCommonExtra( sal_Int64 nEndPos ) override;
+};
+
+
+class ComCtlTreeViewObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+ virtual void implDumpCommonExtra( sal_Int64 nEndPos ) override;
+
+private:
+ sal_uInt32 mnStringFlags;
+};
+
+
+class ComCtlStatusBarObject : public ComCtlObjectBase
+{
+public:
+ explicit ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
+
+protected:
+ virtual void implDumpProperties() override;
+ virtual void implDumpCommonExtra( sal_Int64 nEndPos ) override;
+ virtual void implDumpCommonTrailing() override;
+};
+
+
+class AxPropertyObjectBase : public OleInputObjectBase
+{
+protected:
+ AxPropertyObjectBase() {}
+
+ using OleInputObjectBase::construct;
+ void construct(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ const String& rPropNameList,
+ bool b64BitPropFlags = false );
+ void construct(
+ const InputObjectBase& rParent,
+ const String& rPropNameList,
+ bool b64BitPropFlags = false );
+
+ virtual bool implIsValid() const override;
+ virtual void implDump() override;
+
+ virtual void implDumpShortProperties();
+ virtual void implDumpExtended();
+
+ bool ensureValid( bool bCondition = true );
+
+ template< typename Type >
+ void alignInput();
+
+ void setAlignAnchor();
+ bool startNextProperty();
+ OUString getPropertyName() const;
+
+ template< typename Type >
+ Type dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp = NO_LIST );
+ template< typename Type >
+ Type dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp = NO_LIST );
+
+ bool dumpBoolProperty() { return startNextProperty(); }
+ sal_Int32 dumpHmmProperty() { return dumpDecProperty< sal_Int32 >( 0, "CONV-HMM-TO-CM" ); }
+ sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OLE-MOUSEPTR" ); }
+ template< typename Type >
+ Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-BORDERSTYLE" ); }
+ template< typename Type >
+ Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-SPECIALEFFECT" ); }
+ sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "AX-ENABLED" ); }
+ sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "AX-ORIENTATION" ); }
+ sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "AX-CONV-MS" ); }
+ sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "AX-IMAGEPOS" ); }
+ sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "AX-IMAGESIZEMODE" ); }
+ sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "AX-IMAGEALIGN" ); }
+
+ sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const char* pcNameList = "AX-FLAGS" );
+ sal_uInt32 dumpColorProperty( sal_uInt32 nDefault );
+ sal_Unicode dumpUnicodeProperty();
+ void dumpUnknownProperty();
+
+ void dumpPosProperty();
+ void dumpSizeProperty();
+ void dumpGuidProperty( OUString* pValue = nullptr );
+ void dumpStringProperty( OUString* pValue = nullptr );
+ void dumpStringArrayProperty();
+ void dumpStreamProperty();
+
+ void dumpEmbeddedFont();
+ void dumpToPosition( sal_Int64 nPos );
+
+private:
+ void constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags );
+
+ void dumpVersion();
+ OUString dumpString( const String& rName, sal_uInt32 nSize, bool bArray );
+ void dumpShortProperties();
+ void dumpLargeProperties();
+
+private:
+ struct LargeProperty
+ {
+ enum LargePropertyType { PROPTYPE_POS, PROPTYPE_SIZE, PROPTYPE_GUID, PROPTYPE_STRING, PROPTYPE_STRINGARRAY };
+
+ LargePropertyType mePropType;
+ OUString maItemName;
+ sal_uInt32 mnDataSize;
+ OUString* mpItemValue;
+ explicit LargeProperty( LargePropertyType ePropType, const String& rItemName, sal_uInt32 nDataSize, OUString* pItemValue = nullptr ) :
+ mePropType( ePropType ), maItemName( rItemName ), mnDataSize( nDataSize ), mpItemValue( pItemValue ) {}
+ };
+ typedef ::std::vector< LargeProperty > LargePropertyVector;
+
+ struct StreamProperty
+ {
+ OUString maItemName;
+ sal_uInt16 mnData;
+ explicit StreamProperty( const String& rItemName, sal_uInt16 nData ) :
+ maItemName( rItemName ), mnData( nData ) {}
+ };
+
+ LargePropertyVector maLargeProps;
+ std::vector< StreamProperty >
+ maStreamProps;
+ NameListRef mxPropNames;
+ sal_Int64 mnPropertiesStart;
+ sal_Int64 mnPropertiesEnd;
+ sal_Int64 mnPropFlags;
+ sal_Int64 mnCurrProp;
+ bool mb64BitPropFlags;
+ bool mbValid;
+};
+
+
+template< typename Type >
+void AxPropertyObjectBase::alignInput()
+{
+ mxStrm->skip( (sizeof( Type ) - ((mxStrm->tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) );
+}
+
+template< typename Type >
+Type AxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp )
+{
+ if( startNextProperty() )
+ {
+ alignInput< Type >();
+ return dumpDec< Type >( getPropertyName(), rListWrp );
+ }
+ return nDefault;
+}
+
+template< typename Type >
+Type AxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp )
+{
+ if( startNextProperty() )
+ {
+ alignInput< Type >();
+ return dumpHex< Type >( getPropertyName(), rListWrp );
+ }
+ return nDefault;
+}
+
+
+class AxCFontNewObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxCFontNewObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class AxColumnInfoObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxColumnInfoObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class AxCommandButtonObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxCommandButtonObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+ virtual void implDumpExtended() override;
+};
+
+
+class AxMorphControlObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxMorphControlObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+ virtual void implDumpExtended() override;
+
+private:
+ void dumpColumnInfos();
+
+private:
+ sal_uInt16 mnColInfoCount;
+ sal_uInt8 mnCtrlType;
+};
+
+
+class AxLabelObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxLabelObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+ virtual void implDumpExtended() override;
+};
+
+
+class AxImageObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxImageObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class AxScrollBarObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxScrollBarObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class AxSpinButtonObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxSpinButtonObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class AxTabStripObject : public AxPropertyObjectBase
+{
+public:
+ explicit AxTabStripObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+ virtual void implDumpExtended() override;
+
+private:
+ sal_Int32 mnTabFlagCount;
+};
+
+
+class FormControlStreamObject : public OleInputObjectBase
+{
+public:
+ explicit FormControlStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ const OUString* pProgId = nullptr );
+ explicit FormControlStreamObject(
+ const OutputObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString* pProgId = nullptr );
+
+protected:
+ virtual void implDump() override;
+
+private:
+ void constructFormCtrlStrmObj( const OUString* pProgId );
+
+private:
+ OUString maProgId;
+ bool mbReadGuid;
+};
+
+
+struct VbaFormSiteInfo
+{
+ OUString maProgId;
+ sal_Int32 mnId;
+ sal_uInt32 mnLength;
+ bool mbInStream;
+
+ VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {}
+};
+
+
+struct VbaFormSharedData
+{
+ OUStringVector maClassInfoProgIds;
+ std::vector< VbaFormSiteInfo > maSiteInfos;
+};
+
+
+class VbaFormClassInfoObject : public AxPropertyObjectBase
+{
+public:
+ explicit VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData );
+
+protected:
+ virtual void implDumpShortProperties() override;
+
+private:
+ VbaFormSharedData& mrFormData;
+};
+
+
+class VbaFormSiteObject : public AxPropertyObjectBase
+{
+public:
+ explicit VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData );
+
+protected:
+ virtual void implDumpShortProperties() override;
+
+private:
+ VbaFormSharedData& mrFormData;
+};
+
+
+class VbaFormDesignExtObject : public AxPropertyObjectBase
+{
+public:
+ explicit VbaFormDesignExtObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class VbaFStreamObject : public AxPropertyObjectBase
+{
+public:
+ explicit VbaFStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ VbaFormSharedData& rFormData );
+
+protected:
+ virtual void implDumpShortProperties() override;
+ virtual void implDumpExtended() override;
+
+private:
+ void dumpClassInfos();
+ void dumpFormSites( sal_uInt32 nCount );
+ void dumpSiteData();
+ void dumpDesignExtender();
+
+private:
+ VbaFormSharedData& mrFormData;
+ sal_uInt32 mnFlags;
+};
+
+
+class VbaOStreamObject : public OleInputObjectBase
+{
+public:
+ explicit VbaOStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ VbaFormSharedData& rFormData );
+
+protected:
+ virtual void implDump() override;
+
+private:
+ VbaFormSharedData& mrFormData;
+};
+
+
+class VbaPageObject : public AxPropertyObjectBase
+{
+public:
+ explicit VbaPageObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+};
+
+
+class VbaMultiPageObject : public AxPropertyObjectBase
+{
+public:
+ explicit VbaMultiPageObject( const InputObjectBase& rParent );
+
+protected:
+ virtual void implDumpShortProperties() override;
+ virtual void implDumpExtended() override;
+
+private:
+ sal_Int32 mnPageCount;
+};
+
+
+class VbaXStreamObject : public InputObjectBase
+{
+public:
+ explicit VbaXStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ VbaFormSharedData& rFormData );
+
+protected:
+ virtual void implDump() override;
+
+private:
+ VbaFormSharedData& mrFormData;
+};
+
+
+class VbaContainerStorageObject : public OleStorageObject
+{
+public:
+ explicit VbaContainerStorageObject(
+ const ObjectBase& rParent,
+ const StorageRef& rxStrg,
+ const OUString& rSysPath );
+
+protected:
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+
+ virtual void implDumpStorage(
+ const StorageRef& rxStrg,
+ const OUString& rStrgPath,
+ const OUString& rSysPath ) override;
+
+private:
+ bool isFormStorage( const OUString& rStrgPath ) const;
+
+private:
+ VbaFormSharedData maFormData;
+};
+
+
+struct VbaSharedData
+{
+ typedef ::std::map< OUString, sal_Int32 > StreamOffsetMap;
+
+ StreamOffsetMap maStrmOffsets;
+ rtl_TextEncoding meTextEnc;
+
+ VbaSharedData();
+
+ bool isModuleStream( const OUString& rStrmName ) const;
+ sal_Int32 getStreamOffset( const OUString& rStrmName ) const;
+};
+
+
+class VbaDirStreamObject : public SequenceRecordObjectBase
+{
+public:
+ explicit VbaDirStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ VbaSharedData& rVbaData );
+
+protected:
+ virtual bool implIsValid() const override;
+ virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) override;
+ virtual void implDumpRecordBody() override;
+
+private:
+ OUString dumpByteString( const String& rName );
+ OUString dumpUniString( const String& rName );
+ OUString dumpByteStringWithLength( const String& rName );
+
+private:
+ VbaSharedData& mrVbaData;
+ BinaryInputStreamRef mxInStrm;
+ OUString maCurrStream;
+ sal_Int32 mnCurrOffset;
+};
+
+
+class VbaModuleStreamObject : public InputObjectBase
+{
+public:
+ explicit VbaModuleStreamObject(
+ const ObjectBase& rParent,
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName,
+ VbaSharedData& rVbaData,
+ sal_Int32 nStrmOffset );
+
+protected:
+ virtual void implDump() override;
+
+private:
+ VbaSharedData& mrVbaData;
+ sal_Int32 mnStrmOffset;
+};
+
+
+class VbaStorageObject : public OleStorageObject
+{
+public:
+ explicit VbaStorageObject(
+ const ObjectBase& rParent,
+ const StorageRef& rxStrg,
+ const OUString& rSysPath,
+ VbaSharedData& rVbaData );
+
+protected:
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+
+private:
+ VbaSharedData& mrVbaData;
+};
+
+
+class VbaFormStorageObject : public VbaContainerStorageObject
+{
+public:
+ explicit VbaFormStorageObject(
+ const ObjectBase& rParent,
+ const StorageRef& rxStrg,
+ const OUString& rSysPath,
+ VbaSharedData& rVbaData );
+
+protected:
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+
+private:
+ VbaSharedData& mrVbaData;
+};
+
+
+class VbaProjectStorageObject : public OleStorageObject
+{
+public:
+ explicit VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath );
+
+protected:
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+
+ virtual void implDumpStorage(
+ const StorageRef& rxStrg,
+ const OUString& rStrgPath,
+ const OUString& rSysPath ) override;
+
+private:
+ VbaSharedData maVbaData;
+};
+
+
+class ActiveXStorageObject : public VbaContainerStorageObject
+{
+public:
+ explicit ActiveXStorageObject(
+ const ObjectBase& rParent,
+ const StorageRef& rxStrg,
+ const OUString& rSysPath );
+
+protected:
+ virtual void implDumpBaseStream(
+ const BinaryInputStreamRef& rxStrm,
+ const OUString& rSysFileName ) override;
+};
+
+
+} // namespace oox::dump
+
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/dump/pptxdumper.hxx b/include/oox/dump/pptxdumper.hxx
new file mode 100644
index 000000000..9e12ecd48
--- /dev/null
+++ b/include/oox/dump/pptxdumper.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DUMP_PPTXDUMPER_HXX
+#define INCLUDED_OOX_DUMP_PPTXDUMPER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dump/dumperbase.hxx>
+#include <rtl/ustring.hxx>
+
+#ifdef DBG_UTIL
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox::core { class FilterBase; }
+
+namespace oox::dump::pptx {
+
+
+class RootStorageObject : public StorageObjectBase
+{
+public:
+ explicit RootStorageObject( const DumperBase& rParent );
+
+protected:
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+};
+
+
+class Dumper : public DumperBase
+{
+public:
+ explicit Dumper( const ::oox::core::FilterBase& rFilter );
+
+ explicit Dumper(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ const OUString& rSysFileName );
+
+protected:
+ virtual void implDump() override;
+};
+
+
+} // namespace oox::dump::pptx
+
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/dump/xlsbdumper.hxx b/include/oox/dump/xlsbdumper.hxx
new file mode 100644
index 000000000..96acd2616
--- /dev/null
+++ b/include/oox/dump/xlsbdumper.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_DUMP_XLSBDUMPER_HXX
+#define INCLUDED_OOX_DUMP_XLSBDUMPER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dump/dumperbase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#ifdef DBG_UTIL
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+ class BinaryInputStream;
+ class SequenceInputStream;
+}
+
+namespace oox::core { class FilterBase; }
+
+namespace oox::dump::xlsb {
+
+
+class RecordObjectBase final : public SequenceRecordObjectBase
+{
+ explicit RecordObjectBase();
+ virtual ~RecordObjectBase() override;
+
+ using SequenceRecordObjectBase::construct;
+
+ virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) override;
+};
+
+
+class RootStorageObject : public StorageObjectBase
+{
+public:
+ explicit RootStorageObject( const DumperBase& rParent );
+
+protected:
+ virtual void implDumpStream(
+ const css::uno::Reference< css::io::XInputStream >& rxStrm,
+ const OUString& rStrgPath,
+ const OUString& rStrmName,
+ const OUString& rSysFileName ) override;
+};
+
+
+class Dumper : public DumperBase
+{
+public:
+ explicit Dumper( const ::oox::core::FilterBase& rFilter );
+
+ explicit Dumper(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ const OUString& rSysFileName );
+
+protected:
+ virtual void implDump() override;
+};
+
+
+} // namespace oox::dmp::xlsb
+
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/export/DMLPresetShapeExport.hxx b/include/oox/export/DMLPresetShapeExport.hxx
new file mode 100644
index 000000000..1f650f558
--- /dev/null
+++ b/include/oox/export/DMLPresetShapeExport.hxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+#define INCLUDED_OOX_EXPORT_DMLPRESETSHAPEXPORT_HXX
+
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#include <string_view>
+
+#include <oox/export/drawingml.hxx>
+
+namespace com::sun::star::beans
+{
+struct PropertyValue;
+}
+
+namespace com::sun::star::drawing
+{
+class XShape;
+struct EnhancedCustomShapeAdjustmentValue;
+}
+
+namespace oox::core
+{
+class XmlFilterBase;
+}
+
+namespace oox::drawingml
+{
+/// Class for exporting the custom shapes to OOXML preset ones, if possible.
+/// This functionality needed for keeping the information for the office programs
+/// about the shape type, and geometry data. Before these shapes were exported
+/// with custom geometry, and they kept their geometry but has no information
+/// about the shape itself. This lead to lost textbox size/position/padding for
+/// example.
+class DMLPresetShapeExporter
+{
+private:
+ // the shape to export
+ css::uno::Reference<css::drawing::XShape> m_xShape;
+ // the DMLwriter
+ DrawingML* m_pDMLexporter;
+ // the type of the custom shape (diamond/rectangle/circle/triangle...)
+ OUString m_sPresetShapeType;
+ // True if the shape has points where its geometry can be modified
+ bool m_bHasHandleValues;
+ // The first the x the second the y coordinate, of flipping
+ std::pair<bool, bool> m_bIsFlipped;
+
+ // Custom Shape Geometry information for export:
+
+ // The adjusting values stored in this sequence:
+ css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue> m_AdjustmentValues;
+ // Shapes what have adjusting points, the range of these points
+ // and the index of the value stored in this sequence:
+ css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> m_HandleValues;
+
+ //TODO:
+ //css::awt::Rectangle m_ViewBox;
+ //css::uno::Sequence<css::beans::PropertyValue> m_Path;
+ //css::uno::Sequence<OUString> m_Equations;
+
+public:
+ DMLPresetShapeExporter() = delete;
+ ~DMLPresetShapeExporter();
+
+ DMLPresetShapeExporter(DrawingML* pDMLExporter,
+ css::uno::Reference<css::drawing::XShape> xShape);
+
+ // Writes the preset shape to the xml
+ bool WriteShape();
+
+private:
+ struct AdjustmentPointValueBase
+ {
+ std::optional<double> nMaxVal;
+ std::optional<double> nMinVal;
+ std::optional<double> nCurrVal;
+ };
+
+ typedef AdjustmentPointValueBase RadiusAdjustmentValue;
+ typedef AdjustmentPointValueBase AngleAdjustmentValue;
+ typedef AdjustmentPointValueBase XAdjustmentValue;
+ typedef AdjustmentPointValueBase YAdjustmentValue;
+
+ // Returns true, if the shape has adjusting points
+ bool HasHandleValue() const;
+
+ // Returns true if the shape flipped.
+ bool IsXFlipped() const { return m_bIsFlipped.first; };
+ bool IsYFlipped() const { return m_bIsFlipped.second; };
+
+ // Returns with the shape type, like triangle for example
+ const OUString& GetShapeType() const;
+ // Returns with the handle points
+ const css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>&
+ GetHandleValues() const;
+ // Returns with the adjustment values
+ const css::uno::Sequence<css::drawing::EnhancedCustomShapeAdjustmentValue>&
+ GetAdjustmentValues() const;
+ // Returns with the raw value of the given property of the shape geometry.
+ css::uno::Any GetHandleValueOfModificationPoint(sal_Int32 nPoint, std::u16string_view sType);
+ // Returns with the appropriate value of the handle point.
+ RadiusAdjustmentValue GetAdjustmentPointRadiusValue(sal_Int32 nPoint);
+ AngleAdjustmentValue GetAdjustmentPointAngleValue(sal_Int32 nPoint);
+ XAdjustmentValue GetAdjustmentPointXValue(sal_Int32 nPoint);
+ YAdjustmentValue GetAdjustmentPointYValue(sal_Int32 nPoint);
+
+ // Writes one adjustment point.
+ bool WriteAV(const OUString& sValName, const OUString& sVal);
+ // Opens/Closes the AVlist tag.
+ bool StartAVListWriting();
+ bool EndAVListWriting();
+
+ // Finds the given value in the sequence
+ static css::uno::Any FindHandleValue(css::uno::Sequence<css::beans::PropertyValue> aValues,
+ std::u16string_view sKey);
+ // Writes and converts the adjustment points from sdr to ooxml ones per shape type.
+ bool WriteShapeWithAVlist();
+
+}; // end of DMLPresetShapeExporter class
+
+} // end of namespace oox::drawingml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
new file mode 100644
index 000000000..6a40254f6
--- /dev/null
+++ b/include/oox/export/chartexport.hxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
+#define INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
+
+#include <set>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/dllapi.h>
+#include <oox/export/drawingml.hxx>
+#include <oox/export/shapes.hxx>
+#include <oox/export/utils.hxx>
+#include <oox/token/tokens.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sax/fshelper.hxx>
+
+namespace com::sun::star {
+ namespace beans {
+ class XPropertySet;
+ }
+ namespace chart {
+ class XDiagram;
+ class XChartDocument;
+ }
+ namespace chart2 {
+ struct RelativePosition;
+ struct RelativeSize;
+ class XDiagram;
+ class XChartDocument;
+ class XDataSeries;
+ class XChartType;
+ namespace data
+ {
+ class XDataSequence;
+ class XLabeledDataSequence;
+ }
+ }
+ namespace drawing {
+ class XShape;
+ }
+ namespace frame {
+ class XModel;
+ }
+}
+
+namespace oox {
+namespace core {
+ class XmlFilterBase;
+}}
+
+namespace oox::drawingml {
+
+enum AxesType
+{
+ AXIS_PRIMARY_X = 1,
+ AXIS_PRIMARY_Y = 2,
+ AXIS_PRIMARY_Z = 3,
+ AXIS_SECONDARY_X = 4,
+ AXIS_SECONDARY_Y = 5
+};
+
+struct AxisIdPair{
+ AxesType nAxisType;
+ sal_Int32 nAxisId;
+ sal_Int32 nCrossAx;
+
+ AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx)
+ : nAxisType(nType)
+ , nAxisId(nId)
+ , nCrossAx(nAx)
+ {}
+};
+
+/**
+ A helper container class to collect the chart data point labels and the address
+ of the cell[range] from which the labels are sourced if that is the case. This
+ is then used to write the label texts under the extension tag <c15:datalabelsRange>.
+
+ @since LibreOffice 7.3.0
+ */
+class DataLabelsRange
+{
+public:
+
+ /// type of the internal container that stores the indexed label text.
+ typedef std::map<sal_Int32, OUString> LabelsRangeMap;
+
+ /// Returns whether the container is empty or not.
+ bool empty() const;
+ /// Returns the count of labels stored.
+ size_t count() const;
+ /// Indicates whether the container has a label with index specified by nIndex.
+ bool hasLabel(sal_Int32 nIndex) const;
+ /// Returns the address of the cell[range] from which label contents are sourced.
+ const OUString & getRange() const;
+
+ /// Sets the address of the cell[range] from which label contents are sourced.
+ void setRange(const OUString& rRange);
+ /// Adds a new indexed label text.
+ void setLabel(sal_Int32 nIndex, const OUString& rText);
+
+ LabelsRangeMap::const_iterator begin() const;
+ LabelsRangeMap::const_iterator end() const;
+
+private:
+ OUString maRange;
+ LabelsRangeMap maLabels;
+};
+
+
+class OOX_DLLPUBLIC ChartExport final : public DrawingML {
+
+public:
+ // first: data sequence for label, second: data sequence for values.
+ typedef ::std::vector< AxisIdPair > AxisVector;
+
+private:
+ sal_Int32 mnXmlNamespace;
+ sal_Int32 mnSeriesCount;
+ css::uno::Reference< css::frame::XModel > mxChartModel;
+ css::uno::Reference< css::chart::XDiagram > mxDiagram;
+ css::uno::Reference< css::chart2::XDiagram > mxNewDiagram;
+ std::shared_ptr<URLTransformer> mpURLTransformer;
+
+ // members filled by InitRangeSegmentationProperties (retrieved from DataProvider)
+ bool mbHasCategoryLabels; //if the categories are only automatically generated this will be false
+
+ //css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes;
+ css::uno::Reference< css::chart2::data::XDataSequence > mxCategoriesValues;
+
+ AxisVector maAxes;
+ bool mbHasZAxis;
+ bool mbIs3DChart;
+ bool mbStacked;
+ bool mbPercent;
+ bool mbHasDateCategories;
+
+ std::set<sal_Int32> maExportedAxis;
+
+private:
+ sal_Int32 getChartType();
+
+ css::uno::Sequence< css::uno::Sequence< rtl::OUString > > getSplitCategoriesList(const OUString& rRange);
+
+ OUString parseFormula( const OUString& rRange );
+ void InitPlotArea();
+
+ void ExportContent_();
+ void exportChartSpace( const css::uno::Reference<
+ css::chart::XChartDocument >& rChartDoc,
+ bool bIncludeTable );
+ void exportChart( const css::uno::Reference<
+ css::chart::XChartDocument >& rChartDoc );
+ void exportExternalData( const css::uno::Reference<
+ css::chart::XChartDocument >& rChartDoc );
+ void exportLegend( const css::uno::Reference<
+ css::chart::XChartDocument >& rChartDoc );
+ void exportTitle( const css::uno::Reference< css::drawing::XShape >& xShape,
+ const OUString* pSubText = nullptr );
+ void exportPlotArea( const css::uno::Reference<
+ css::chart::XChartDocument >& rChartDoc );
+ void exportAdditionalShapes( const css::uno::Reference<css::chart::XChartDocument >& rChartDoc );
+ void exportFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
+ void exportSolidFill(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
+ void exportGradientFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
+ void exportBitmapFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
+ void exportHatch(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
+ void exportDataTable( );
+
+ void exportAreaChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportBarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportBubbleChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportDoughnutChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportLineChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportPieChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportRadarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportScatterChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportScatterChartSeries( const css::uno::Reference< css::chart2::XChartType >& xChartType,
+ const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>* pSeries);
+ void exportStockChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportSurfaceChart( const css::uno::Reference< css::chart2::XChartType >& xChartType );
+ void exportHiLowLines();
+ void exportUpDownBars(const css::uno::Reference< css::chart2::XChartType >& xChartType );
+
+ void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes);
+ void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType,
+ const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes);
+
+ void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType);
+ void exportCandleStickSeries(
+ const css::uno::Sequence<
+ css::uno::Reference<
+ css::chart2::XDataSeries > > & aSeriesSeq,
+ bool& rPrimaryAxes );
+ void exportSeriesText(
+ const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq );
+ void exportSeriesCategory(
+ const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_cat );
+ void exportSeriesValues(
+ const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val );
+ void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
+ void exportDataPoints(
+ const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties,
+ sal_Int32 nSeriesLength, sal_Int32 eChartType );
+ void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength,
+ sal_Int32 eChartType, DataLabelsRange& rDLblsRange );
+ void exportGrouping( bool isBar = false );
+ void exportTrendlines( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
+ void exportMarker( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
+ void exportSmooth();
+ void exportFirstSliceAng();
+
+ void exportErrorBar(const css::uno::Reference< css::beans::XPropertySet >& xErrorBarProps,
+ bool bYError);
+
+ void exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize, const bool bIsExcludingDiagramPositioning);
+
+ void exportAxes( );
+ void exportAxis(const AxisIdPair& rAxisIdPair);
+ void _exportAxis(
+ const css::uno::Reference< css::beans::XPropertySet >& xAxisProp,
+ const css::uno::Reference< css::drawing::XShape >& xAxisTitle,
+ const css::uno::Reference< css::beans::XPropertySet >& xMajorGrid,
+ const css::uno::Reference< css::beans::XPropertySet >& xMinorGrid,
+ sal_Int32 nAxisType,
+ const char* sAxisPos,
+ const AxisIdPair& rAxisIdPair );
+ void exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes = false);
+ void exportView3D();
+ bool isDeep3dChart();
+
+ void exportMissingValueTreatment(const css::uno::Reference<css::beans::XPropertySet>& xPropSet);
+
+ OUString getNumberFormatCode(sal_Int32 nKey) const;
+
+public:
+
+ ChartExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, css::uno::Reference< css::frame::XModel > const & xModel,
+ ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType );
+ virtual ~ChartExport() {}
+
+ void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer);
+
+ const css::uno::Reference< css::frame::XModel >& getModel() const { return mxChartModel; }
+
+ void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nID, sal_Int32 nChartCount );
+ void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
+
+ void ExportContent();
+ void InitRangeSegmentationProperties(
+ const css::uno::Reference<
+ css::chart2::XChartDocument > & xChartDoc );
+};
+
+}
+
+#endif // INCLUDED_OOX_EXPORT_CHARTEXPORT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
new file mode 100644
index 000000000..8b57523a5
--- /dev/null
+++ b/include/oox/export/drawingml.hxx
@@ -0,0 +1,382 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_EXPORT_DRAWINGML_HXX
+#define INCLUDED_OOX_EXPORT_DRAWINGML_HXX
+
+#include <map>
+#include <stack>
+#include <string_view>
+#include <unordered_map>
+#include <vector>
+
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <oox/dllapi.h>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/token/tokens.hxx>
+#include <oox/export/utils.hxx>
+#include <rtl/string.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sax/fshelper.hxx>
+#include <svx/msdffdef.hxx>
+#include <vcl/checksum.hxx>
+#include <vcl/graph.hxx>
+#include <tools/gen.hxx>
+#include <tools/color.hxx>
+#include <vcl/mapmod.hxx>
+#include <svx/EnhancedCustomShape2d.hxx>
+
+class Graphic;
+class SdrObjCustomShape;
+enum class SvxDateFormat;
+enum class SvxTimeFormat;
+
+namespace com::sun::star {
+namespace awt {
+ struct FontDescriptor;
+ struct Gradient;
+}
+namespace beans {
+ struct PropertyValue;
+ class XPropertySet;
+ class XPropertyState;
+}
+namespace drawing {
+ class XShape;
+ struct EnhancedCustomShapeParameterPair;
+ struct EnhancedCustomShapeParameter;
+}
+namespace graphic {
+ class XGraphic;
+}
+namespace style {
+ struct LineSpacing;
+}
+namespace text {
+ class XTextContent;
+ class XTextRange;
+ class XTextFrame;
+}
+namespace io {
+ class XOutputStream;
+}
+namespace uno {
+ class XInterface;
+}
+namespace frame {
+ class XModel;
+}
+}
+
+struct EscherConnectorListEntry;
+class OutlinerParaObject;
+namespace tools { class Rectangle; }
+
+namespace tools {
+ class PolyPolygon;
+}
+
+namespace oox {
+namespace core {
+ class XmlFilterBase;
+}
+
+namespace drawingml {
+
+class OOX_DLLPUBLIC URLTransformer
+{
+public:
+ virtual ~URLTransformer();
+
+ virtual OUString getTransformedString(const OUString& rURL) const;
+
+ virtual bool isExternalURL(const OUString& rURL) const;
+};
+
+// Our rotation is counter-clockwise and is in 100ths of a degree.
+// drawingML rotation is clockwise and is in 60000ths of a degree.
+inline sal_Int32 ExportRotateClockwisify(Degree100 input)
+{
+ return ((21600000 - input.get() * 600) % 21600000);
+}
+
+/// Interface to be implemented by the parent exporter that knows how to handle shape text.
+class OOX_DLLPUBLIC DMLTextExport
+{
+public:
+ virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
+ /// Write the contents of the textbox that is associated to this shape.
+ virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
+ /// Get textbox which belongs to the shape.
+ virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame(
+ css::uno::Reference<css::drawing::XShape> xShape) = 0;
+protected:
+ DMLTextExport() {}
+ virtual ~DMLTextExport() {}
+};
+
+class OOX_DLLPUBLIC DrawingML
+{
+
+private:
+ static std::stack<sal_Int32> mnImageCounter;
+ static std::stack<sal_Int32> mnWdpImageCounter;
+ static std::stack<std::map<OUString, OUString>> maWdpCache;
+ static sal_Int32 mnDrawingMLCount;
+ static sal_Int32 mnVmlCount;
+ static std::stack<std::unordered_map<BitmapChecksum, OUString>> maExportGraphics;
+
+ /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
+ DocumentType meDocumentType;
+ /// Parent exporter, used for text callback.
+ DMLTextExport* mpTextExport;
+
+
+protected:
+ css::uno::Any mAny;
+ ::sax_fastparser::FSHelperPtr mpFS;
+ ::oox::core::XmlFilterBase* mpFB;
+ /// If set, this is the parent of the currently handled shape.
+ css::uno::Reference<css::drawing::XShape> m_xParent;
+ bool mbIsBackgroundDark;
+
+ /// True when exporting presentation placeholder shape.
+ bool mbPlaceholder;
+
+ bool GetProperty( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& aName );
+ bool GetPropertyAndState( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
+ const css::uno::Reference< css::beans::XPropertyState >& rXPropState,
+ const OUString& aName, css::beans::PropertyState& eState );
+ OUString GetFieldValue( const css::uno::Reference< css::text::XTextRange >& rRun, bool& bIsURLField );
+ /** Gets OOXML datetime field type from LO Date format
+
+ @param eDate LO Date format
+ */
+ static OUString GetDatetimeTypeFromDate(SvxDateFormat eDate);
+ /** Gets OOXML datetime field type from LO Time format
+
+ @param eTime LO Time format
+ */
+ static OUString GetDatetimeTypeFromTime(SvxTimeFormat eTime);
+ /** Gets OOXML datetime field type from combination of LO Time and Date formats
+
+ @param eDate LO Date format
+ @param eTime LO Time format
+ */
+ static OUString GetDatetimeTypeFromDateTime(SvxDateFormat eDate, SvxTimeFormat eTime);
+
+ /// Output the media (including copying a video from vnd.sun.star.Package: to the output if necessary).
+ void WriteMediaNonVisualProperties(const css::uno::Reference<css::drawing::XShape>& xShape);
+
+ void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
+
+ const char* GetComponentDir() const;
+ const char* GetRelationCompPrefix() const;
+
+ static bool EqualGradients( css::awt::Gradient aGradient1, css::awt::Gradient aGradient2 );
+ bool IsFontworkShape(const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
+
+ void WriteGlowEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
+ void WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
+ void WriteCustomGeometryPoint(const css::drawing::EnhancedCustomShapeParameterPair& rParamPair,
+ const EnhancedCustomShape2d& rCustomShape2d,
+ const bool bReplaceGeoWidth, const bool bReplaceGeoHeight);
+ bool WriteCustomGeometrySegment(
+ const sal_Int16 eCommand, const sal_Int32 nCount,
+ const css::uno::Sequence<css::drawing::EnhancedCustomShapeParameterPair>& rPairs,
+ sal_Int32& rnPairIndex, double& rfCurrentX, double& rfCurrentY, bool& rbCurrentValid,
+ const EnhancedCustomShape2d& rCustomShape2d,
+ const bool bReplaceGeoWidth, const bool bReplaceGeoHeight);
+
+public:
+ DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = nullptr )
+ : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ), mbIsBackgroundDark( false ), mbPlaceholder(false) {}
+ void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
+ const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; }
+ ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
+ DocumentType GetDocumentType() const { return meDocumentType; }
+ /// The application-specific text exporter callback, if there is one.
+ DMLTextExport* GetTextExport() { return mpTextExport; }
+
+ void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
+ /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
+ OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false );
+
+ void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteColor( const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteGradientStop(sal_uInt16 nStop, ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT);
+ void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
+ void WriteConnectorConnections( sal_uInt32 nStartGlueId, sal_Int32 nEndGlueId, sal_Int32 nStartID, sal_Int32 nEndID );
+
+ bool WriteCharColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
+ bool WriteFillColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
+
+ void WriteSolidFill( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteSolidFill( const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+ void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+
+ void WriteGradientFill( css::awt::Gradient rGradient, css::awt::Gradient rTransparenceGradient,
+ const css::uno::Reference<css::beans::XPropertySet>& rXPropSet = css::uno::Reference<css::beans::XPropertySet>());
+
+ void WriteGrabBagGradientFill( const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops, css::awt::Gradient rGradient);
+
+ void WriteBlipOrNormalFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
+ const OUString& rURLPropName );
+ void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
+ const OUString& sURLPropName );
+ void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
+ const OUString& sURLPropName, sal_Int32 nXmlNamespace );
+
+ void WriteXGraphicBlipFill(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia = false);
+
+ void WritePattFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+ void WritePattFill(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
+ const css::drawing::Hatch& rHatch);
+
+ void WriteGraphicCropProperties(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
+ Size const & rOriginalSize, MapMode const & rMapMode);
+
+ void WriteSrcRectXGraphic(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
+ void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
+ css::uno::Reference< css::frame::XModel> const & xModel = nullptr );
+
+ void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
+ void WriteXGraphicTile(css::uno::Reference<css::beans::XPropertySet> const& rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const& rxGraphic);
+
+ void WriteLinespacing(const css::style::LineSpacing& rLineSpacing, float fFirstCharHeight);
+
+ OUString WriteXGraphicBlip(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ bool bRelPathToMedia);
+
+ void WriteImageBrightnessContrastTransparence(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet);
+
+ void WriteXGraphicBlipMode(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
+ void WriteShapeTransformation(const css::uno::Reference< css::drawing::XShape >& rXShape,
+ sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false, bool bSuppressFlipping = false, bool bFlippedBeforeRotation = false);
+ void WriteTransformation(const css::uno::Reference< css::drawing::XShape >& xShape, const tools::Rectangle& rRectangle,
+ sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0, bool bIsGroupShape = false);
+
+ void WriteText( const css::uno::Reference< css::uno::XInterface >& rXIface, bool bBodyPr, bool bText = true, sal_Int32 nXmlNamespace = 0, bool bWritePropertiesAsLstStyles = false);
+
+ /** Populates the lstStyle with the shape's text run and paragraph properties */
+ void WriteLstStyles(const css::uno::Reference<css::text::XTextContent>& rParagraph,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
+ const css::uno::Reference<css::beans::XPropertySet>& rXShapePropSet);
+ void WriteParagraph( const css::uno::Reference< css::text::XTextContent >& rParagraph,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight, const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
+ /** Writes paragraph properties
+
+ @returns true if any paragraph properties were written
+ */
+ bool WriteParagraphProperties(const css::uno::Reference< css::text::XTextContent >& rParagraph, const css::uno::Reference<css::beans::XPropertySet>& rXShapePropSet, float fFirstCharHeight, sal_Int32 nElement);
+ void WriteParagraphNumbering(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, float fFirstCharHeight,
+ sal_Int16 nLevel );
+ void WriteParagraphTabStops(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
+ void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
+ const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
+ void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
+ bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
+ sal_Int16 nScriptType = css::i18n::ScriptType::LATIN,
+ const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet = {});
+
+ void WritePresetShape( const OString& pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList );
+ void WritePresetShape( const OString& pShape );
+ void WritePresetShape( const OString& pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const css::beans::PropertyValue& rProp );
+ bool WriteCustomGeometry(
+ const css::uno::Reference<css::drawing::XShape>& rXShape,
+ const SdrObjCustomShape& rSdrObjCustomShape);
+ void WriteEmptyCustomGeometry();
+ void WritePolyPolygon(const css::uno::Reference<css::drawing::XShape>& rXShape,
+ const bool bClosed);
+ void WriteFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
+ void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+ void WriteShapeEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+ void WriteShapeEffect( std::u16string_view sName, const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps );
+ /** Populates scene3d tag
+ @param rXPropSet Prop set
+ @param bIsText True if the 3D effects are for a text body, false if it is for a shape
+ */
+ void Write3DEffects(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet, bool bIsText);
+ void WriteArtisticEffect( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+ OString WriteWdpPicture( const OUString& rFileId, const css::uno::Sequence< sal_Int8 >& rPictureData );
+ void WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rXShape, int nDiagramId);
+ void writeDiagramRels(const css::uno::Sequence<css::uno::Sequence<css::uno::Any>>& xRelSeq,
+ const css::uno::Reference<css::io::XOutputStream>& xOutStream,
+ std::u16string_view sGrabBagProperyName, int nDiagramId);
+ static void WriteFromTo(const css::uno::Reference<css::drawing::XShape>& rXShape, const css::awt::Size& aPageSize,
+ const sax_fastparser::FSHelperPtr& pDrawing);
+
+ static bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape );
+ sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, std::u16string_view propName);
+
+ static void ResetMlCounters();
+
+ static void PushExportGraphics();
+ static void PopExportGraphics();
+
+ static sal_Int32 getNewDrawingUniqueId() { return ++mnDrawingMLCount; }
+ static sal_Int32 getNewVMLUniqueId() { return ++mnVmlCount; }
+
+ // A Helper to decide the script type for given text in order to call WriteRunProperties.
+ static sal_Int16 GetScriptType(const OUString& rStr);
+
+ static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, css::awt::FontDescriptor& rFontDesc );
+
+ static ::Color ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
+
+ static const char* GetAlignment( css::style::ParagraphAdjust nAlignment );
+
+ sax_fastparser::FSHelperPtr CreateOutputStream (
+ const OUString& sFullStream,
+ std::u16string_view sRelativeStream,
+ const css::uno::Reference< css::io::XOutputStream >& xParentRelation,
+ const char* sContentType,
+ const char* sRelationshipType,
+ OUString* pRelationshipId );
+
+};
+
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
new file mode 100644
index 000000000..646d462e8
--- /dev/null
+++ b/include/oox/export/shapes.hxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_EXPORT_SHAPES_HXX
+#define INCLUDED_OOX_EXPORT_SHAPES_HXX
+
+#include <cstddef>
+#include <memory>
+#include <string_view>
+#include <unordered_map>
+
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/export/drawingml.hxx>
+#include <oox/export/utils.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sax/fshelper.hxx>
+#include <tools/fract.hxx>
+#include <vcl/mapmod.hxx>
+
+namespace com::sun::star {
+namespace beans {
+ class XPropertySet;
+}
+namespace drawing {
+ class XShape;
+}
+
+namespace embed {
+ class XEmbeddedObject;
+}
+namespace io {
+ class XInputStream;
+}
+namespace uno {
+ class XComponentContext;
+ class XInterface;
+}
+}
+
+namespace oox::core {
+ class XmlFilterBase;
+}
+
+class Graphic;
+
+namespace oox {
+
+OOX_DLLPUBLIC css::uno::Reference<css::io::XInputStream> GetOLEObjectStream(
+ css::uno::Reference<css::uno::XComponentContext> const& xContext,
+ css::uno::Reference<css::embed::XEmbeddedObject> const& xObj,
+ std::u16string_view i_rProgID,
+ OUString & o_rMediaType,
+ OUString & o_rRelationType,
+ OUString & o_rSuffix,
+ const char *& o_rpProgID);
+
+}
+
+namespace oox::drawingml {
+
+class OOX_DLLPUBLIC ShapeExport : public DrawingML {
+
+private:
+ int m_nEmbeddedObjects;
+
+public:
+ typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32> ShapeHashMap;
+
+protected:
+ sal_Int32 mnShapeIdMax;
+ bool mbUserShapes; // for chart's embedded usershapes
+
+ void WriteGraphicObjectShapePart( const css::uno::Reference< css::drawing::XShape >& xShape, const Graphic *pGraphic=nullptr );
+
+ OUString GetShapeName(const css::uno::Reference< css::drawing::XShape >& xShape);
+
+private:
+ sal_Int32 mnXmlNamespace;
+ MapMode maMapModeSrc, maMapModeDest;
+ std::shared_ptr<URLTransformer> mpURLTransformer;
+
+ css::awt::Size MapSize( const css::awt::Size& ) const;
+
+ ShapeHashMap maShapeMap;
+ ShapeHashMap* mpShapeMap;
+
+public:
+
+ ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS,
+ ShapeHashMap* pShapeMap, ::oox::core::XmlFilterBase* pFB,
+ DocumentType eDocumentType = DOCUMENT_PPTX,
+ DMLTextExport* pTextExport = nullptr,
+ bool bUserShapes = false );
+ virtual ~ShapeExport() {}
+
+ void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer);
+
+ static bool NonEmptyText( const css::uno::Reference< css::uno::XInterface >& xIface );
+
+ ShapeExport&
+ WritePolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape, bool bClosed );
+ ShapeExport&
+ WriteClosedPolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteConnectorShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteCustomShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteEllipseShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteGraphicObjectShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteGroupShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteLineShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteNonVisualDrawingProperties( const css::uno::Reference< css::drawing::XShape >& xShape, const char* sName );
+ virtual ShapeExport&
+ WriteNonVisualProperties( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteOpenPolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteRectangleShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+
+ /**
+ * Write the DrawingML for a particular shape.
+ *
+ * <p>This is the member function you want. It performs the type lookup and
+ * invokes the appropriate corresponding Write*() method for the specific
+ * type.</p>
+ *
+ * <p>To write an XShape, XShape::getShapeType() is called to determine
+ * the shape type, and the corresponding method in this table is
+ * invoked:</p>
+ *
+ * <table>
+ * <tr><th>Shape Type</th><th>Method</th></tr>
+ * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedPolyPolygonShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenPolyPolygonShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.PolyPolygonShape</tt></td> <td>ShapeExport::WriteClosedPolyPolygonShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.PolyLineShape</tt></td> <td>ShapeExport::WriteOpenPolyPolygonShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
+ * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr>
+ * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
+ * </table>
+ *
+ * <p>If the shape type is not recognized, then
+ * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p>
+ *
+ * @param xShape The shape to export as DrawingML.
+ * @return <tt>*this</tt>
+ */
+ ShapeExport& WriteShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport& WriteTextBox( const css::uno::Reference< css::uno::XInterface >& xIface, sal_Int32 nXmlNamespace, bool bWritePropertiesAsLstStyles = false );
+ virtual ShapeExport&
+ WriteTextShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ ShapeExport&
+ WriteTableShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ void WriteMathShape(css::uno::Reference<css::drawing::XShape> const& xShape);
+ ShapeExport&
+ WriteOLE2Shape( const css::uno::Reference< css::drawing::XShape >& xShape );
+ virtual ShapeExport&
+ WriteUnknownShape( const css::uno::Reference< css::drawing::XShape >& xShape );
+
+ void WriteTable( const css::uno::Reference< css::drawing::XShape >& rXShape );
+
+ void WriteTableCellProperties(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
+
+ void WriteBorderLine(const sal_Int32 XML_line, const css::table::BorderLine2& rBorderLine);
+ void WriteTableCellBorders(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
+
+ sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape );
+ sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape, ::oox::core::XmlFilterBase* pFB );
+ sal_Int32 GetShapeID( const css::uno::Reference< css::drawing::XShape >& rShape );
+ static sal_Int32 GetShapeID( const css::uno::Reference< css::drawing::XShape >& rShape, ShapeHashMap* pShapeMap );
+};
+
+}
+
+#endif // INCLUDED_OOX_EXPORT_SHAPES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/export/utils.hxx b/include/oox/export/utils.hxx
new file mode 100644
index 000000000..00fd953a0
--- /dev/null
+++ b/include/oox/export/utils.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_EXPORT_UTILS_HXX
+#define INCLUDED_OOX_EXPORT_UTILS_HXX
+
+#include <sal/config.h>
+
+#include <o3tl/unit_conversion.hxx>
+#include <rtl/string.hxx>
+#include <sal/types.h>
+
+#include <cmath>
+
+inline OString I32SHEX(sal_Int32 x)
+{
+ OString aStr = OString::number(x, 16);
+ while (aStr.getLength() < 6)
+ aStr = "0" + aStr;
+ return aStr;
+}
+
+/**
+ * @return const char* literal "true" for true value, or literal "false"
+ * for false value.
+ */
+static constexpr const char* ToPsz(bool b)
+{
+ return b ? "true" : "false";
+}
+
+/**
+ * @return literal "1" for true value, or literal "0" for false value.
+ */
+static constexpr const char* ToPsz10(bool b)
+{
+ // xlsx seems to use "1" or "0" for boolean values. I wonder it ever uses
+ // the "true" "false" variant.
+ return b ? "1" : "0";
+}
+
+static constexpr sal_Int64 PPTtoEMU( sal_Int32 nPPT )
+{
+ return o3tl::convert(nPPT, o3tl::Length::master, o3tl::Length::emu);
+}
+
+static constexpr sal_Int64 TwipsToEMU( sal_Int32 nTwips )
+{
+ return o3tl::convert(nTwips, o3tl::Length::twip, o3tl::Length::emu);
+}
+
+template <typename T>
+OString write1000thOfAPercent(T number)
+{
+ return OString::number( lround(number * 1000.0) );
+}
+
+namespace oox::drawingml {
+ enum DocumentType { DOCUMENT_DOCX, DOCUMENT_PPTX, DOCUMENT_XLSX };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx
new file mode 100644
index 000000000..fa54f27aa
--- /dev/null
+++ b/include/oox/export/vmlexport.hxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
+#define INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
+
+#include <sal/config.h>
+
+#include <string_view>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <editeng/outlobj.hxx>
+#include <filter/msfilter/escherex.hxx>
+#include <oox/dllapi.h>
+#include <rtl/strbuf.hxx>
+#include <rtl/string.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sax/fshelper.hxx>
+#include <vcl/checksum.hxx>
+#include <rtl/ref.hxx>
+
+namespace com::sun::star {
+ namespace drawing {
+ class XShape;
+ }
+}
+
+namespace oox::drawingml {
+ class DrawingML;
+}
+
+
+namespace sax_fastparser {
+ class FastAttributeList;
+}
+
+class Point;
+namespace tools { class Rectangle; }
+class SdrObject;
+
+namespace oox::vml {
+
+/// Interface to be implemented by the parent exporter that knows how to handle shape text.
+class OOX_DLLPUBLIC VMLTextExport
+{
+public:
+ virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
+ virtual oox::drawingml::DrawingML& GetDrawingML() = 0;
+ /// Write the contents of the textbox that is associated to this shape in VML format.
+ virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
+protected:
+ VMLTextExport() {}
+ virtual ~VMLTextExport() {}
+};
+
+class OOX_DLLPUBLIC VMLExport : public EscherEx
+{
+ /// Fast serializer to output the data
+ ::sax_fastparser::FSHelperPtr m_pSerializer;
+
+ /// Parent exporter, used for text callback.
+ VMLTextExport* m_pTextExport;
+
+ /// Anchoring - Writer specific properties
+ sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel;
+ rtl::Reference<sax_fastparser::FastAttributeList> m_pWrapAttrList;
+ bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER
+ bool m_IsFollowingTextFlow = false;
+
+ /// The object we're exporting.
+ const SdrObject* m_pSdrObject;
+
+ /// Fill the shape attributes as they come.
+ rtl::Reference<::sax_fastparser::FastAttributeList> m_pShapeAttrList;
+
+ /// Remember the shape type.
+ sal_uInt32 m_nShapeType;
+
+ /// Remember the shape flags.
+ ShapeFlag m_nShapeFlags;
+
+ /// Remember style, the most important shape attribute ;-)
+ OStringBuffer m_ShapeStyle;
+
+ /// style for textbox
+ OStringBuffer m_TextboxStyle;
+
+ /// Remember the generated shape id.
+ OString m_sShapeId;
+
+ /// Remember which shape types we had already written.
+ std::vector<bool> m_aShapeTypeWritten;
+
+ /// It seems useless to write out an XML_ID attribute next to XML_id which defines the actual shape id
+ bool m_bSkipwzName;
+
+ /// Use '#' mark for type attribute (check Type Attribute of VML shape in OOXML documentation)
+ bool m_bUseHashMarkForType;
+
+ /** There is a shapeid generation mechanism in EscherEx, but it does not seem to work
+ * so override the existing behavior to get actually unique ids.
+ */
+ bool m_bOverrideShapeIdGeneration;
+
+ /// Prefix for overridden shape id generation (used if m_bOverrideShapeIdGeneration is true)
+ OString m_sShapeIDPrefix;
+
+ /// Counter for generating shape ids (used if m_bOverrideShapeIdGeneration is true)
+ sal_uInt64 m_nShapeIDCounter;
+
+public:
+ VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLTextExport* pTextExport = nullptr);
+ virtual ~VMLExport() override;
+
+ const ::sax_fastparser::FSHelperPtr&
+ GetFS() const { return m_pSerializer; }
+
+ void SetFS(const ::sax_fastparser::FSHelperPtr& pSerializer);
+
+ /// Export the sdr object as VML.
+ ///
+ /// Call this when you need to export the object as VML.
+ OString const & AddSdrObject( const SdrObject& rObj,
+ bool const bIsFollowingTextFlow = false,
+ sal_Int16 eHOri = -1, sal_Int16 eVOri = -1, sal_Int16 eHRel = -1,
+ sal_Int16 eVRel = -1,
+ sax_fastparser::FastAttributeList* pWrapAttrList = nullptr,
+ const bool bOOxmlExport = false );
+ OString const & AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport );
+ virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override;
+ static bool IsWaterMarkShape(std::u16string_view rStr);
+
+ void SetSkipwzName(bool bSkipwzName) { m_bSkipwzName = bSkipwzName; }
+ void SetHashMarkForType(bool bUseHashMarkForType) { m_bUseHashMarkForType = bUseHashMarkForType; }
+ void OverrideShapeIDGen(bool bOverrideShapeIdGeneration,
+ const OString& sShapeIDPrefix = OString());
+ static OString GetVMLShapeTypeDefinition(std::string_view sShapeID, const bool bIsPictureFrame);
+
+protected:
+ /// Add an attribute to the generated <v:shape/> element.
+ ///
+ /// This should be called from within StartShape() to ensure that the
+ /// added attribute is preserved.
+ void AddShapeAttribute( sal_Int32 nAttribute, const OString& sValue );
+
+ using EscherEx::StartShape;
+ using EscherEx::EndShape;
+
+ /// Override shape ID generation when m_bOverrideShapeIdGeneration is set to true
+ virtual sal_uInt32 GenerateShapeId() override;
+
+ /// Start the shape for which we just collected the information.
+ ///
+ /// Returns the element's tag number, -1 means we wrote nothing.
+ virtual sal_Int32 StartShape();
+
+ /// End the shape.
+ ///
+ /// The parameter is just what we got from StartShape().
+ virtual void EndShape( sal_Int32 nShapeElement );
+ virtual void Commit( EscherPropertyContainer& rProps, const tools::Rectangle& rRect ) override;
+
+private:
+
+ virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 ) override;
+ virtual void CloseContainer() override;
+
+ virtual sal_uInt32 EnterGroup( const OUString& rShapeName, const tools::Rectangle* pBoundRect ) override;
+ virtual void LeaveGroup() override;
+
+ virtual void AddShape( sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId = 0 ) override;
+
+private:
+ /// Create an OString representing the id from a numerical id.
+ OString ShapeIdString( sal_uInt32 nId );
+
+ /// Add flip X and\or flip Y
+ void AddFlipXY( );
+
+ /// Add starting and ending point of a line to the m_pShapeAttrList.
+ void AddLineDimensions( const tools::Rectangle& rRectangle );
+
+ /// Add position and size to the OStringBuffer.
+ void AddRectangleDimensions( OStringBuffer& rBuffer, const tools::Rectangle& rRectangle, bool rbAbsolutePos = true );
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/addtosequence.hxx b/include/oox/helper/addtosequence.hxx
new file mode 100644
index 000000000..dbb271ca0
--- /dev/null
+++ b/include/oox/helper/addtosequence.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_ADDTOSEQUENCE_HXX
+#define INCLUDED_OOX_HELPER_ADDTOSEQUENCE_HXX
+
+#include <com/sun/star/uno/Any.hxx>
+#include <oox/dllapi.h>
+
+namespace oox
+{
+
+/** this adds an any to another any.
+ if rNewValue is empty, rOldValue is returned.
+ if rOldValue is empty, rNewValue is returned.
+ if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
+ if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
+*/
+OOX_DLLPUBLIC css::uno::Any addToSequence( const css::uno::Any& rOldValue, const css::uno::Any& rNewValue );
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx
new file mode 100644
index 000000000..27101657f
--- /dev/null
+++ b/include/oox/helper/attributelist.hxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
+#define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
+
+#include <sal/config.h>
+
+#include <string_view>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/DateTime.hpp>
+#include <oox/helper/helper.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <oox/drawingml/color.hxx>
+
+namespace com::sun::star {
+ namespace xml::sax { class XFastAttributeList; }
+}
+
+namespace sax_fastparser {
+ class FastAttributeList;
+};
+
+namespace oox {
+
+ /* Get the color tokens from their string representatives. */
+ sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName);
+
+/** Static helpers for conversion of strings to attribute values of various
+ different data types.
+ */
+class OOX_DLLPUBLIC AttributeConversion
+{
+public:
+ /** Returns the XML token identifier from the passed string. */
+ static sal_Int32 decodeToken( std::u16string_view rValue );
+
+ /** Returns the decoded string value. All characters in the format
+ '_xHHHH_' (H being a hexadecimal digit), will be decoded. */
+ static OUString decodeXString( const OUString& rValue );
+
+ /** Returns the 32-bit signed integer value from the passed string (decimal). */
+ static sal_Int32 decodeInteger( std::u16string_view rValue );
+
+ /** Returns the 32-bit unsigned integer value from the passed string (decimal). */
+ static sal_uInt32 decodeUnsigned( std::u16string_view rValue );
+
+ /** Returns the 64-bit signed integer value from the passed string (decimal). */
+ static sal_Int64 decodeHyper( std::u16string_view rValue );
+
+ /** Returns the 32-bit signed integer value from the passed string (hexadecimal). */
+ static sal_Int32 decodeIntegerHex( std::u16string_view rValue );
+};
+
+
+/** Provides access to attribute values of an element.
+
+ Wraps a com.sun.star.xml.sax.XFastAttributeList object. Provides
+ convenience functions that convert the string value of an attribute to
+ various other data types.
+ */
+class OOX_DLLPUBLIC AttributeList
+{
+public:
+ explicit AttributeList(
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs );
+
+ /** Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object. */
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >&
+ getFastAttributeList() const { return mxAttribs; }
+
+ /** Returns true, if the specified attribute is present. */
+ bool hasAttribute( sal_Int32 nAttrToken ) const;
+
+ // optional return values -------------------------------------------------
+
+ /** Returns the token identifier of the value of the specified attribute. */
+ OptValue< sal_Int32 > getToken( sal_Int32 nAttrToken ) const;
+
+ /** Returns the Color object of highlight of the text. */
+ oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const;
+
+ /** Returns the string value of the specified attribute. */
+ OptValue< OUString > getString( sal_Int32 nAttrToken ) const;
+
+ /** Returns the string value of the specified attribute. All characters in
+ the format '_xHHHH_' (H being a hexadecimal digit), will be decoded. */
+ OptValue< OUString > getXString( sal_Int32 nAttrToken ) const;
+
+ /** Returns the double value of the specified attribute. */
+ OptValue< double > getDouble( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute (decimal). */
+ OptValue< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit unsigned integer value of the specified attribute (decimal). */
+ OptValue< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 64-bit signed integer value of the specified attribute (decimal). */
+ OptValue< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal). */
+ OptValue< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const;
+
+ /** Returns the boolean value of the specified attribute. */
+ OptValue< bool > getBool( sal_Int32 nAttrToken ) const;
+
+ /** Returns the date/time value of the specified attribute. */
+ OptValue< css::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const;
+
+ // defaulted return values ------------------------------------------------
+
+ /** Returns the token identifier of the value of the specified attribute,
+ or the passed default identifier if the attribute is missing. */
+ sal_Int32 getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
+
+ /** Returns the string value of the specified attribute, or the passed
+ default string if the attribute is missing. */
+ OUString getString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
+
+ /** Returns the decoded string value of the specified attribute, or the
+ passed default string if the attribute is missing. */
+ OUString getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
+
+ const char* getChar( sal_Int32 nAttrToken ) const;
+
+
+ /** Returns the double value of the specified attribute, or the passed
+ default value if the attribute is missing or not convertible to a double. */
+ double getDouble( sal_Int32 nAttrToken, double fDefault ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute, or the
+ passed default value if the attribute is missing or not convertible to integer. */
+ sal_Int32 getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
+
+ /** Returns the 32-bit unsigned integer value of the specified attribute, or the
+ passed default value if the attribute is missing or not convertible to unsigned. */
+ sal_uInt32 getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
+
+ /** Returns the 64-bit signed integer value of the specified attribute, or the
+ passed default value if the attribute is missing or not convertible to integer. */
+ sal_Int64 getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal),
+ or the passed default value if the attribute is missing or not convertible. */
+ sal_Int32 getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
+
+ sal_uInt32 getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
+
+ /** Returns the boolean value of the specified attribute, or the passed
+ default value if the attribute is missing or not convertible to bool. */
+ bool getBool( sal_Int32 nAttrToken, bool bDefault ) const;
+
+ /** Returns the date/time value of the specified attribute, or the default
+ value if the attribute is missing or not convertible to a date/time value. */
+ css::util::DateTime getDateTime( sal_Int32 nAttrToken, const css::util::DateTime& rDefault ) const;
+
+ std::vector<sal_Int32> getTokenList(sal_Int32 nAttrToken) const;
+
+private:
+ css::uno::Reference< css::xml::sax::XFastAttributeList >
+ mxAttribs;
+ mutable sax_fastparser::FastAttributeList *mpAttribList;
+ sax_fastparser::FastAttributeList *getAttribList() const;
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/binaryinputstream.hxx b/include/oox/helper/binaryinputstream.hxx
new file mode 100644
index 000000000..e27b2def9
--- /dev/null
+++ b/include/oox/helper/binaryinputstream.hxx
@@ -0,0 +1,385 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_BINARYINPUTSTREAM_HXX
+#define INCLUDED_OOX_HELPER_BINARYINPUTSTREAM_HXX
+
+#include <cstddef>
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/helper.hxx>
+#include <rtl/string.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+}
+
+namespace oox {
+
+class BinaryOutputStream;
+
+
+/** Interface for binary input stream classes.
+
+ The binary data in the stream is assumed to be in little-endian format.
+ */
+class OOX_DLLPUBLIC BinaryInputStream : public virtual BinaryStreamBase
+{
+public:
+ /** Derived classes implement reading nBytes bytes to the passed sequence.
+ The sequence will be reallocated internally.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+
+ @return
+ Number of bytes really read.
+ */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
+
+ /** Derived classes implement reading nBytes bytes to the (preallocated!)
+ memory buffer opMem.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+
+ @return
+ Number of bytes really read.
+ */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
+
+ /** Derived classes implement seeking the stream forward by the passed
+ number of bytes. This should work for non-seekable streams too.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+ */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
+
+ /** Reads a value from the stream and converts it to platform byte order.
+ All data types supported by the ByteOrderConverter class can be used.
+ */
+ template< typename Type >
+ [[nodiscard]]
+ Type readValue();
+
+ [[nodiscard]]
+ sal_Int8 readInt8() { return readValue<sal_Int8>(); }
+ [[nodiscard]]
+ sal_uInt8 readuInt8() { return readValue<sal_uInt8>(); }
+ [[nodiscard]]
+ sal_Int16 readInt16() { return readValue<sal_Int16>(); }
+ [[nodiscard]]
+ sal_uInt16 readuInt16() { return readValue<sal_uInt16>(); }
+ [[nodiscard]]
+ sal_Int32 readInt32() { return readValue<sal_Int32>(); }
+ [[nodiscard]]
+ sal_uInt32 readuInt32() { return readValue<sal_uInt32>(); }
+ [[nodiscard]]
+ sal_Int64 readInt64() { return readValue<sal_Int64>(); }
+ [[nodiscard]]
+ float readFloat() { return readValue<float>(); }
+ [[nodiscard]]
+ double readDouble() { return readValue<double>(); }
+ [[nodiscard]]
+ unsigned char readuChar() { return readValue<unsigned char>(); }
+
+ /** Reads a (preallocated!) C array of values from the stream.
+
+ Converts all values in the array to platform byte order. All data types
+ supported by the ByteOrderConverter class can be used.
+
+ @param nElemCount
+ Number of array elements to read (NOT byte count).
+
+ @return
+ Number of array elements really read (NOT byte count).
+ */
+ template< typename Type >
+ sal_Int32 readArray( Type* opnArray, sal_Int32 nElemCount );
+
+ /** Reads a vector of values from the stream.
+
+ The vector will be resized internally. Converts all values in the
+ vector to platform byte order. All data types supported by the
+ ByteOrderConverter class can be used.
+
+ @param nElemCount
+ Number of elements to put into the vector (NOT byte count).
+
+ @return
+ Number of vector elements really read (NOT byte count).
+ */
+ template< typename Type >
+ sal_Int32 readArray( ::std::vector< Type >& orVector, sal_Int32 nElemCount );
+
+ /** Reads a NUL-terminated Unicode character array and returns the string.
+ */
+ OUString readNulUnicodeArray();
+
+ /** Reads a byte character array and returns the string.
+ NUL characters are replaced by question marks.
+
+ @param nChars
+ Number of characters (bytes) to read from the stream.
+ */
+ OString readCharArray( sal_Int32 nChars );
+
+ /** Reads a byte character array and returns a Unicode string.
+ NUL characters are replaced by question marks.
+
+ @param nChars
+ Number of characters (bytes) to read from the stream.
+
+ @param eTextEnc
+ The text encoding used to create the Unicode string.
+ */
+ OUString readCharArrayUC( sal_Int32 nChars, rtl_TextEncoding eTextEnc );
+
+ /** Reads a Unicode character array and returns the string.
+ NUL characters are replaced by question marks (default).
+
+ @param nChars
+ Number of 16-bit characters to read from the stream.
+ */
+ OUString readUnicodeArray( sal_Int32 nChars );
+
+ /** Reads a Unicode character array (may be compressed) and returns the
+ string.
+ NUL characters are replaced by question marks (default).
+
+ @param nChars
+ Number of 8-bit or 16-bit characters to read from the stream.
+
+ @param bCompressed
+ True = Character array is compressed (stored as 8-bit characters).
+ False = Character array is not compressed (stored as 16-bit characters).
+ */
+ OUString readCompressedUnicodeArray( sal_Int32 nChars, bool bCompressed );
+
+ /** Copies bytes from the current position to the passed output stream.
+ */
+ void copyToStream( BinaryOutputStream& rOutStrm );
+
+protected:
+ /** This dummy default c'tor will never call the c'tor of the virtual base
+ class BinaryStreamBase as this class cannot be instantiated directly. */
+ BinaryInputStream() : BinaryStreamBase( false ) {}
+
+private:
+ BinaryInputStream( BinaryInputStream const& ) = delete;
+ BinaryInputStream& operator=( BinaryInputStream const& ) = delete;
+};
+
+typedef std::shared_ptr< BinaryInputStream > BinaryInputStreamRef;
+
+
+template< typename Type >
+Type BinaryInputStream::readValue()
+{
+ Type ornValue = Type();
+ readMemory( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ), sizeof( Type ) );
+ ByteOrderConverter::convertLittleEndian( ornValue );
+ return ornValue;
+}
+
+template< typename Type >
+sal_Int32 BinaryInputStream::readArray( Type* opnArray, sal_Int32 nElemCount )
+{
+ sal_Int32 nRet = 0;
+ if( !mbEof )
+ {
+ sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int32 >( nElemCount, 0, SAL_MAX_INT32 / sizeof( Type ) ) * sizeof( Type );
+ nRet = readMemory( opnArray, nReadSize, sizeof( Type ) ) / sizeof( Type );
+ ByteOrderConverter::convertLittleEndianArray( opnArray, static_cast< size_t >( nRet ) );
+ }
+ return nRet;
+}
+
+template< typename Type >
+sal_Int32 BinaryInputStream::readArray( ::std::vector< Type >& orVector, sal_Int32 nElemCount )
+{
+ orVector.resize( static_cast< size_t >( nElemCount ) );
+ return orVector.empty() ? 0 : readArray(orVector.data(), nElemCount);
+}
+
+
+/** Wraps a UNO input stream and provides convenient access functions.
+
+ The binary data in the stream is assumed to be in little-endian format.
+ */
+class OOX_DLLPUBLIC BinaryXInputStream final : public BinaryXSeekableStream, public BinaryInputStream
+{
+public:
+ /** Constructs the wrapper object for the passed input stream.
+
+ @param rxInStream
+ The com.sun.star.io.XInputStream interface of the UNO input stream
+ to be wrapped.
+
+ @param bAutoClose
+ True = automatically close the wrapped input stream on destruction
+ of this wrapper or when close() is called.
+ */
+ explicit BinaryXInputStream(
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ bool bAutoClose );
+
+ virtual ~BinaryXInputStream() override;
+
+ /** Closes the input stream. Does also close the wrapped UNO input stream
+ if bAutoClose has been set to true in the constructor. */
+ virtual void close() override;
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Seeks the stream forward by the passed number of bytes. This works for
+ non-seekable streams too. */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+private:
+ StreamDataSequence maBuffer; ///< Data buffer used in readMemory() function.
+ css::uno::Reference< css::io::XInputStream >
+ mxInStrm; ///< Reference to the input stream.
+ bool mbAutoClose; ///< True = automatically close stream on destruction.
+};
+
+
+/** Wraps a StreamDataSequence and provides convenient access functions.
+
+ The binary data in the stream is assumed to be in little-endian format.
+ */
+class OOX_DLLPUBLIC SequenceInputStream final : public SequenceSeekableStream, public BinaryInputStream
+{
+public:
+ /** Constructs the wrapper object for the passed data sequence.
+
+ @attention
+ The passed data sequence MUST live at least as long as this stream
+ wrapper. The data sequence MUST NOT be changed from outside as long
+ as this stream wrapper is used to read from it.
+ */
+ explicit SequenceInputStream( const StreamDataSequence& rData );
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Seeks the stream forward by the passed number of bytes. This works for
+ non-seekable streams too. */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+private:
+ /** Returns the number of bytes available in the sequence for the passed byte count. */
+ sal_Int32 getMaxBytes( sal_Int32 nBytes ) const
+ { return getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mpData->getLength() - mnPos ); }
+};
+
+
+/** Wraps a BinaryInputStream and provides access to a specific part of the
+ stream data.
+
+ Provides access to the stream data block starting at the current position
+ of the stream, and with a specific length. If the wrapped stream is
+ seekable, this wrapper will treat the position of the wrapped stream at
+ construction time as position "0" (therefore the class name).
+
+ The passed input stream MUST live at least as long as this stream wrapper.
+ The stream MUST NOT be changed from outside as long as this stream wrapper
+ is used to read from it.
+ */
+class RelativeInputStream final : public BinaryInputStream
+{
+public:
+ /** Constructs the wrapper object for the passed stream.
+
+ @param nSize
+ If specified, restricts the amount of data that can be read from
+ the passed input stream.
+ */
+ explicit RelativeInputStream(
+ BinaryInputStream& rInStrm,
+ sal_Int64 nSize );
+
+ /** Returns the size of the data block in the wrapped stream offered by
+ this wrapper. */
+ virtual sal_Int64 size() const override;
+
+ /** Returns the current relative stream position. */
+ virtual sal_Int64 tell() const override;
+
+ /** Seeks the stream to the passed relative position, if the wrapped stream
+ is seekable. */
+ virtual void seek( sal_Int64 nPos ) override;
+
+ /** Closes the input stream but not the wrapped stream. */
+ virtual void close() override;
+
+ /** Reads nBytes bytes to the passed sequence. Does not read out of the
+ data block whose size has been specified on construction.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Reads nBytes bytes to the (existing) buffer opMem. Does not read out of
+ the data block whose size has been specified on construction.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Seeks the stream forward by the passed number of bytes. This works for
+ non-seekable streams too. Does not seek out of the data block. */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+private:
+ /** Returns the number of bytes available in the sequence for the passed byte count. */
+ sal_Int32 getMaxBytes( sal_Int32 nBytes ) const
+ { return getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnSize - mnRelPos ); }
+
+private:
+ BinaryInputStream* mpInStrm;
+ sal_Int64 mnStartPos;
+ sal_Int64 mnRelPos;
+ sal_Int64 mnSize;
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/binaryoutputstream.hxx b/include/oox/helper/binaryoutputstream.hxx
new file mode 100644
index 000000000..c1dc8ebb0
--- /dev/null
+++ b/include/oox/helper/binaryoutputstream.hxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_BINARYOUTPUTSTREAM_HXX
+#define INCLUDED_OOX_HELPER_BINARYOUTPUTSTREAM_HXX
+
+#include <cstddef>
+#include <memory>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/helper.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XOutputStream; }
+}
+
+namespace oox {
+
+
+/** Interface for binary output stream classes.
+
+ The binary data in the stream is written in little-endian format.
+ */
+class BinaryOutputStream : public virtual BinaryStreamBase
+{
+public:
+ /** Derived classes implement writing the contents of the passed data
+ sequence.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+ */
+ virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 ) = 0;
+
+ /** Derived classes implement writing the contents of the (preallocated!)
+ memory buffer pMem.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+ */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
+
+ template< typename Type >
+ void writeArray( Type* opnArray, sal_Int32 nElemCount );
+
+ template< typename Type >
+ void writeArray( const Type* opnArray, sal_Int32 nElemCount );
+
+ /** Writes a value to the stream and converts it to platform byte order.
+ All data types supported by the ByteOrderConverter class can be used.
+ */
+ template< typename Type >
+ void writeValue( Type nValue );
+
+ BinaryOutputStream& WriteInt16(sal_Int16 x) { writeValue(x); return *this; }
+ BinaryOutputStream& WriteUInt16(sal_uInt16 x) { writeValue(x); return *this; }
+ BinaryOutputStream& WriteInt32(sal_Int32 x) { writeValue(x); return *this; }
+ BinaryOutputStream& WriteUInt32(sal_uInt32 x) { writeValue(x); return *this; }
+ BinaryOutputStream& WriteInt64(sal_Int64 x) { writeValue(x); return *this; }
+
+ void writeCompressedUnicodeArray( const OUString& rString, bool bCompressed );
+
+ void writeCharArrayUC( std::u16string_view rString, rtl_TextEncoding eTextEnc );
+
+ void writeUnicodeArray( const OUString& rString );
+
+protected:
+ /** This dummy default c'tor will never call the c'tor of the virtual base
+ class BinaryStreamBase as this class cannot be instantiated directly. */
+ BinaryOutputStream() : BinaryStreamBase( false ) {}
+
+private:
+ BinaryOutputStream( BinaryOutputStream const& ) = delete;
+ BinaryOutputStream& operator=( BinaryOutputStream const& ) = delete;
+};
+
+template< typename Type >
+void BinaryOutputStream::writeArray( Type* opnArray, sal_Int32 nElemCount )
+{
+ sal_Int32 nWriteSize = getLimitedValue< sal_Int32, sal_Int32 >( nElemCount, 0, SAL_MAX_INT32 / sizeof( Type ) ) * sizeof( Type );
+ ByteOrderConverter::convertLittleEndianArray( opnArray, static_cast< size_t >( nElemCount ) );
+ writeMemory( opnArray, nWriteSize, sizeof( Type ) );
+}
+
+template< typename Type >
+void BinaryOutputStream::writeArray( const Type* opnArray, sal_Int32 nElemCount )
+{
+ std::unique_ptr<Type[]> xArray(new Type[nElemCount]);
+ std::uninitialized_copy(opnArray, opnArray + nElemCount, xArray.get());
+ writeArray(xArray.get(), nElemCount);
+}
+
+template< typename Type >
+void BinaryOutputStream::writeValue( Type nValue )
+{
+ ByteOrderConverter::convertLittleEndian( nValue );
+ writeMemory( &nValue, static_cast< sal_Int32 >( sizeof( Type ) ), sizeof( Type ) );
+}
+
+
+/** Wraps a UNO output stream and provides convenient access functions.
+
+ The binary data in the stream is written in little-endian format.
+ */
+class OOX_DLLPUBLIC BinaryXOutputStream final : public BinaryXSeekableStream, public BinaryOutputStream
+{
+public:
+ /** Constructs the wrapper object for the passed output stream.
+
+ @param rxOutStream
+ The com.sun.star.io.XOutputStream interface of the output stream to
+ be wrapped.
+
+ @param bAutoClose
+ True = automatically close the wrapped output stream on destruction
+ of this wrapper or when close() is called.
+ */
+ explicit BinaryXOutputStream(
+ const css::uno::Reference< css::io::XOutputStream >& rxOutStrm,
+ bool bAutoClose );
+
+ virtual ~BinaryXOutputStream() override;
+
+ /** Flushes and closes the output stream. Does also close the wrapped UNO
+ output stream if bAutoClose has been set to true in the constructor. */
+ void close() override;
+
+ /** Writes the passed data sequence. */
+ virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 ) override;
+
+ /** Write nBytes bytes from the (preallocated!) buffer pMem. */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+private:
+ StreamDataSequence maBuffer; ///< Data buffer used in writeMemory() function.
+ css::uno::Reference< css::io::XOutputStream >
+ mxOutStrm; ///< Reference to the output stream.
+ bool mbAutoClose; ///< True = automatically close stream on destruction.
+};
+
+
+/** Wraps a StreamDataSequence and provides convenient access functions.
+
+ The binary data in the stream is written in little-endian format. After
+ construction, the stream points to the beginning of the passed data
+ sequence. The data sequence is expanded automatically while writing to it.
+ */
+class SequenceOutputStream final : public BinaryOutputStream
+{
+public:
+ /** Constructs the wrapper object for the passed data sequence.
+
+ @attention
+ The passed data sequence MUST live at least as long as this stream
+ wrapper. The data sequence MUST NOT be changed from outside as long
+ as this stream wrapper is used to write to it.
+ */
+ explicit SequenceOutputStream( StreamDataSequence & rData );
+
+ /** Writes the passed data sequence. */
+ virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 ) override;
+
+ /** Write nBytes bytes from the (preallocated!) buffer pMem. */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Returns the size of the wrapped data sequence. */
+ virtual sal_Int64 size() const override;
+ /** Returns the current stream position. */
+ virtual sal_Int64 tell() const override;
+ /** Seeks the stream to the passed position. */
+ virtual void seek( sal_Int64 nPos ) override;
+ /** Releases the reference to the data sequence. */
+ virtual void close() override;
+
+private:
+ StreamDataSequence* mpData; ///< Wrapped data sequence.
+ sal_Int32 mnPos; ///< Current position in the sequence.
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/binarystreambase.hxx b/include/oox/helper/binarystreambase.hxx
new file mode 100644
index 000000000..8e93d1458
--- /dev/null
+++ b/include/oox/helper/binarystreambase.hxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_BINARYSTREAMBASE_HXX
+#define INCLUDED_OOX_HELPER_BINARYSTREAMBASE_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/dllapi.h>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XSeekable; }
+}
+
+namespace oox {
+
+typedef css::uno::Sequence< sal_Int8 > StreamDataSequence;
+
+
+/** Base class for binary stream classes.
+ */
+class OOX_DLLPUBLIC BinaryStreamBase
+{
+public:
+ virtual ~BinaryStreamBase();
+
+ /** Implementations return the size of the stream, if possible.
+
+ This function may be implemented for some types of unseekable streams,
+ and MUST be implemented for all seekable streams.
+
+ @return
+ The size of the stream in bytes, or -1, if not implemented.
+ */
+ virtual sal_Int64 size() const = 0;
+
+ /** Implementations return the current stream position, if possible.
+
+ This function may be implemented for some types of unseekable streams,
+ and MUST be implemented for all seekable streams.
+
+ @return
+ The current position in the stream, or -1, if not implemented.
+ */
+ virtual sal_Int64 tell() const = 0;
+
+ /** Implementations seek the stream to the passed position, if
+ the stream is seekable.
+ */
+ virtual void seek( sal_Int64 nPos ) = 0;
+
+ /** Implementations close the stream.
+ */
+ virtual void close() = 0;
+
+ /** Returns true, if the implementation supports the seek() operation.
+
+ Implementations may still implement size() and tell() even if the
+ stream is not seekable.
+ */
+ bool isSeekable() const { return mbSeekable; }
+
+ /** Returns true, if the stream position is invalid (EOF). This flag turns
+ true *after* the first attempt to seek/read beyond the stream end.
+ */
+ bool isEof() const { return mbEof; }
+
+ /** Returns the size of the remaining data available in the stream, if
+ stream supports size() and tell(), otherwise -1.
+ */
+ sal_Int64 getRemaining() const;
+
+ /** Seeks the stream to the beginning, if stream is seekable.
+ */
+ void seekToStart() { seek( 0 ); }
+
+ /** Seeks the stream forward to a position that is a multiple of the passed
+ block size, if stream is seekable.
+
+ @param nBlockSize
+ The size of the data blocks the streams needs to be aligned to.
+
+ @param nAnchorPos
+ Position in the stream the data blocks are aligned to.
+ */
+ void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos );
+
+protected:
+ explicit BinaryStreamBase( bool bSeekable ) : mbEof( false ), mbSeekable( bSeekable ) {}
+
+private:
+ BinaryStreamBase( const BinaryStreamBase& ) = delete;
+ BinaryStreamBase& operator=( const BinaryStreamBase& ) = delete;
+
+protected:
+ bool mbEof; ///< End of stream flag.
+
+private:
+ const bool mbSeekable; ///< True = implementation supports seeking.
+};
+
+
+/** Base class for binary input and output streams wrapping a UNO stream,
+ seekable via the com.sun.star.io.XSeekable interface.
+ */
+class BinaryXSeekableStream : public virtual BinaryStreamBase
+{
+public:
+ virtual ~BinaryXSeekableStream() override;
+
+ /** Returns the size of the stream, if wrapped stream is seekable, otherwise -1. */
+ virtual sal_Int64 size() const override;
+ /** Returns the current stream position, if wrapped stream is seekable, otherwise -1. */
+ virtual sal_Int64 tell() const override;
+ /** Seeks the stream to the passed position, if wrapped stream is seekable. */
+ virtual void seek( sal_Int64 nPos ) override;
+ /** Releases the reference to the UNO XSeekable interface. */
+ virtual void close() override;
+
+protected:
+ explicit BinaryXSeekableStream(
+ const css::uno::Reference< css::io::XSeekable >& rxSeekable );
+
+private:
+ css::uno::Reference< css::io::XSeekable >
+ mxSeekable; ///< Stream seeking interface.
+};
+
+
+/** Base class for binary input and output streams wrapping a
+ StreamDataSequence, which is always seekable.
+
+ The wrapped data sequence MUST live at least as long as this stream
+ wrapper. The data sequence MUST NOT be changed from outside as long as this
+ stream wrapper is used to modify it.
+ */
+class OOX_DLLPUBLIC SequenceSeekableStream : public virtual BinaryStreamBase
+{
+public:
+ /** Returns the size of the wrapped data sequence. */
+ virtual sal_Int64 size() const override;
+ /** Returns the current stream position. */
+ virtual sal_Int64 tell() const override;
+ /** Seeks the stream to the passed position. */
+ virtual void seek( sal_Int64 nPos ) override;
+ /** Releases the reference to the data sequence. */
+ virtual void close() override;
+
+protected:
+ explicit SequenceSeekableStream( const StreamDataSequence& rData );
+
+protected:
+ const StreamDataSequence* mpData; ///< Wrapped data sequence.
+ sal_Int32 mnPos; ///< Current position in the sequence.
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/containerhelper.hxx b/include/oox/helper/containerhelper.hxx
new file mode 100644
index 000000000..3b725d509
--- /dev/null
+++ b/include/oox/helper/containerhelper.hxx
@@ -0,0 +1,298 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_CONTAINERHELPER_HXX
+#define INCLUDED_OOX_HELPER_CONTAINERHELPER_HXX
+
+#include <cstddef>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace container { class XNameAccess; }
+ namespace container { class XNameContainer; }
+ namespace uno { class Any; }
+}
+
+namespace oox {
+
+
+/** A range of signed 32-bit integer values. */
+struct ValueRange
+{
+ sal_Int32 mnFirst;
+ sal_Int32 mnLast;
+
+ explicit ValueRange( sal_Int32 nValue ) : mnFirst( nValue ), mnLast( nValue ) {}
+ explicit ValueRange( sal_Int32 nFirst, sal_Int32 nLast ) : mnFirst( nFirst ), mnLast( nLast ) {}
+
+ bool operator==( const ValueRange& rRange ) const { return (mnFirst == rRange.mnFirst) && (mnLast == rRange.mnLast); }
+ bool operator!=( const ValueRange& rRange ) const { return !(*this == rRange); }
+ bool contains( const ValueRange& rRange ) const { return (mnFirst <= rRange.mnFirst) && (rRange.mnLast <= mnLast); }
+ bool intersects( const ValueRange& rRange ) const { return (mnFirst <= rRange.mnLast) && (rRange.mnFirst <= mnLast); }
+};
+
+
+typedef ::std::vector< ValueRange > ValueRangeVector;
+
+
+/** An ordered list of value ranges. The insertion operation will merge
+ consecutive value ranges.
+ */
+class OOX_DLLPUBLIC ValueRangeSet
+{
+public:
+ ValueRangeSet() {}
+
+ /** Inserts the passed value range into the range list. */
+ void insert( const ValueRange& rRange );
+
+ /** Returns the ordered list of all value ranges. */
+ const ValueRangeVector& getRanges() const { return maRanges; }
+
+private:
+ ValueRangeVector maRanges;
+};
+
+
+/** Template for a 2-dimensional array of objects.
+
+ This class template provides a similar interface to the ::std::vector
+ template.
+ */
+template< typename Type >
+class Matrix
+{
+public:
+ typedef ::std::vector< Type > container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::pointer pointer;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::const_iterator const_iterator;
+
+ Matrix() : mnWidth( 0 ) {}
+ explicit Matrix( size_type nWidth, size_type nHeight ) { resize( nWidth, nHeight ); }
+ explicit Matrix( size_type nWidth, size_type nHeight, const_reference rData ) { resize( nWidth, nHeight, rData ); }
+
+ bool empty() const { return maData.empty(); }
+ size_type size() const { return maData.size(); }
+ size_type width() const { return mnWidth; }
+ size_type height() const { return empty() ? 0 : (size() / width()); }
+
+ void clear() { resize( 0, 0 ); }
+ void resize( size_type nWidth, size_type nHeight ) { mnWidth = nWidth; maData.resize( nWidth * nHeight ); }
+ void resize( size_type nWidth, size_type nHeight, const_reference rData ) { mnWidth = nWidth; maData.resize( nWidth * nHeight, rData ); }
+
+ iterator at( size_type nX, size_type nY ) { return maData.begin() + mnWidth * nY + nX; }
+ const_iterator at( size_type nX, size_type nY ) const { return maData.begin() + mnWidth * nY + nX; }
+
+ reference operator()( size_type nX, size_type nY ) { return *at( nX, nY ); }
+ const_reference operator()( size_type nX, size_type nY ) const { return *at( nX, nY ); }
+
+ iterator begin() { return maData.begin(); }
+ const_iterator begin() const { return maData.begin(); }
+ iterator end() { return maData.end(); }
+ const_iterator end() const { return maData.end(); }
+
+ iterator row_begin( size_type nY ) { return at( 0, nY ); }
+ const_iterator row_begin( size_type nY ) const { return at( 0, nY ); }
+ iterator row_end( size_type nY ) { return at( mnWidth, nY ); }
+ const_iterator row_end( size_type nY ) const { return at( mnWidth, nY ); }
+
+ reference row_front( size_type nY ) { return (*this)( 0, nY ); }
+ const_reference row_front( size_type nY ) const { return (*this)( 0, nY ); }
+
+private:
+ container_type maData;
+ size_type mnWidth;
+};
+
+
+/** Static helper functions for improved API container handling. */
+class OOX_DLLPUBLIC ContainerHelper
+{
+public:
+
+ /** Returns a name that is not used in the passed name container.
+
+ @param rxNameAccess com.sun.star.container.XNameAccess interface of
+ the name container.
+
+ @param rSuggestedName Suggested name for the object.
+
+ @return An unused name. Will be equal to the suggested name, if not
+ contained, otherwise a numerical index will be appended.
+ */
+ static OUString getUnusedName(
+ const css::uno::Reference< css::container::XNameAccess >& rxNameAccess,
+ const OUString& rSuggestedName,
+ sal_Unicode cSeparator );
+
+ /** Inserts an object into a name container.
+
+ @param rxNameContainer com.sun.star.container.XNameContainer interface
+ of the name container.
+
+ @param rName Exact name for the object.
+
+ @param rObject The object to be inserted.
+
+ @return True = object successfully inserted.
+ */
+ static bool insertByName(
+ const css::uno::Reference< css::container::XNameContainer >& rxNameContainer,
+ const OUString& rName,
+ const css::uno::Any& rObject );
+
+ /** Inserts an object into a name container.
+
+ The function will use an unused name to insert the object, based on the
+ suggested object name. It is possible to specify whether the existing
+ object or the new inserted object will be renamed, if the container
+ already has an object with the name suggested for the new object.
+
+ @param rxNameContainer com.sun.star.container.XNameContainer interface
+ of the name container.
+
+ @param rSuggestedName Suggested name for the object.
+
+ @param rObject The object to be inserted.
+
+ The new object
+ will be inserted with a name not yet extant in the container (this
+ is done by appending a numerical index to the suggested name).
+
+ @return The final name the object is inserted with. Will always be
+ equal to the suggested name, if parameter bRenameOldExisting is
+ true.
+ */
+ static OUString insertByUnusedName(
+ const css::uno::Reference< css::container::XNameContainer >& rxNameContainer,
+ const OUString& rSuggestedName,
+ sal_Unicode cSeparator,
+ const css::uno::Any& rObject );
+
+ // std::vector and std::map element access --------------------------------
+
+ /** Returns the pointer to an existing element of the passed vector, or a
+ null pointer, if the passed index is out of bounds. */
+ template< typename VectorType >
+ static const typename VectorType::value_type*
+ getVectorElement( const VectorType& rVector, sal_Int32 nIndex );
+
+ /** Returns the pointer to an existing element of the passed vector, or a
+ null pointer, if the passed index is out of bounds. */
+ template< typename VectorType >
+ static typename VectorType::value_type*
+ getVectorElementAccess( VectorType& rVector, sal_Int32 nIndex );
+
+ /** Returns the reference to an existing element of the passed vector, or
+ the passed default value, if the passed index is out of bounds. */
+ template< typename VectorType >
+ static const typename VectorType::value_type&
+ getVectorElement( const VectorType& rVector, sal_Int32 nIndex, const typename VectorType::value_type& rDefault );
+
+ /** Returns the pointer to an existing element of the passed map, or a null
+ pointer, if an element with the passed key does not exist. */
+ template< typename MapType >
+ static const typename MapType::mapped_type*
+ getMapElement( const MapType& rMap, const typename MapType::key_type& rKey );
+
+ /** Returns the reference to an existing element of the passed map, or the
+ passed default value, if an element with the passed key does not exist. */
+ template< typename MapType >
+ static const typename MapType::mapped_type&
+ getMapElement( const MapType& rMap, const typename MapType::key_type& rKey, const typename MapType::mapped_type& rDefault );
+
+ /** Creates a UNO sequence of sequences from a matrix with copies of all elements.
+
+ @param rMatrix The matrix to be converted to a sequence of sequences.
+
+ @return A com.sun.star.uno.Sequence object containing
+ com.sun.star.uno.Sequence objects with copies of all objects
+ contained in the passed matrix.
+ */
+ template< typename MatrixType >
+ static css::uno::Sequence< css::uno::Sequence< typename MatrixType::value_type > >
+ matrixToSequenceSequence( const MatrixType& rMatrix );
+};
+
+
+template< typename VectorType >
+/*static*/ const typename VectorType::value_type* ContainerHelper::getVectorElement( const VectorType& rVector, sal_Int32 nIndex )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : nullptr;
+}
+
+template< typename VectorType >
+/*static*/ typename VectorType::value_type* ContainerHelper::getVectorElementAccess( VectorType& rVector, sal_Int32 nIndex )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : nullptr;
+}
+
+template< typename VectorType >
+/*static*/ const typename VectorType::value_type& ContainerHelper::getVectorElement( const VectorType& rVector, sal_Int32 nIndex, const typename VectorType::value_type& rDefault )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? rVector[ static_cast< size_t >( nIndex ) ] : rDefault;
+}
+
+template< typename MapType >
+/*static*/ const typename MapType::mapped_type* ContainerHelper::getMapElement( const MapType& rMap, const typename MapType::key_type& rKey )
+{
+ typename MapType::const_iterator aIt = rMap.find( rKey );
+ return (aIt == rMap.end()) ? nullptr : &aIt->second;
+}
+
+template< typename MapType >
+/*static*/ const typename MapType::mapped_type& ContainerHelper::getMapElement( const MapType& rMap, const typename MapType::key_type& rKey, const typename MapType::mapped_type& rDefault )
+{
+ typename MapType::const_iterator aIt = rMap.find( rKey );
+ return (aIt == rMap.end()) ? rDefault : aIt->second;
+}
+
+template< typename MatrixType >
+/*static*/ css::uno::Sequence< css::uno::Sequence< typename MatrixType::value_type > > ContainerHelper::matrixToSequenceSequence( const MatrixType& rMatrix )
+{
+ typedef typename MatrixType::value_type ValueType;
+ css::uno::Sequence< css::uno::Sequence< ValueType > > aSeq;
+ if( !rMatrix.empty() )
+ {
+ aSeq.realloc( static_cast< sal_Int32 >( rMatrix.height() ) );
+ auto pSeq = aSeq.getArray();
+ for( size_t nRow = 0, nHeight = rMatrix.height(); nRow < nHeight; ++nRow )
+ pSeq[ static_cast< sal_Int32 >( nRow ) ] =
+ css::uno::Sequence< ValueType >( &rMatrix.row_front( nRow ), static_cast< sal_Int32 >( rMatrix.width() ) );
+ }
+ return aSeq;
+}
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/grabbagstack.hxx b/include/oox/helper/grabbagstack.hxx
new file mode 100644
index 000000000..bd03535c9
--- /dev/null
+++ b/include/oox/helper/grabbagstack.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_HELPER_GRABBAGSTACK_HXX
+#define INCLUDED_OOX_HELPER_GRABBAGSTACK_HXX
+
+#include <stack>
+#include <vector>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace uno { class Any; }
+}
+
+namespace oox {
+
+struct GrabBagStackElement
+{
+ OUString maElementName;
+ std::vector<css::beans::PropertyValue> maPropertyList;
+};
+
+/// Tool that is useful for construction of a nested Sequence/PropertyValue hierarchy
+class OOX_DLLPUBLIC GrabBagStack final
+{
+private:
+ std::stack<GrabBagStackElement> mStack;
+ GrabBagStackElement mCurrentElement;
+
+public:
+ GrabBagStack(const OUString& aElementName);
+ ~GrabBagStack();
+
+ const OUString& getCurrentName() const { return mCurrentElement.maElementName;}
+
+ css::beans::PropertyValue getRootProperty();
+
+ void appendElement(const OUString& aName, const css::uno::Any& aAny);
+ void push(const OUString& aKey);
+ void pop();
+ void addInt32(const OUString& aElementName, sal_Int32 aIntValue);
+ void addString(const OUString& aElementName, const OUString& aStringValue);
+ bool isStackEmpty() const;
+};
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx
new file mode 100644
index 000000000..eab39beff
--- /dev/null
+++ b/include/oox/helper/graphichelper.hxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_GRAPHICHELPER_HXX
+#define INCLUDED_OOX_HELPER_GRAPHICHELPER_HXX
+
+#include <map>
+
+#include <com/sun/star/awt/DeviceInfo.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/helper.hxx>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <com/sun/star/graphic/XGraphicProvider2.hpp>
+#include <com/sun/star/graphic/XGraphicMapper.hpp>
+#include <vcl/vclptr.hxx>
+
+struct WmfExternal;
+class OutputDevice;
+
+namespace com::sun::star {
+ namespace awt { struct Point; }
+ namespace awt { struct Size; }
+ namespace awt { class XUnitConversion; }
+ namespace io { class XInputStream; }
+ namespace frame { class XFrame; }
+ namespace graphic { class XGraphic; }
+ namespace graphic { class XGraphicObject; }
+ namespace graphic { class XGraphicProvider; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+
+
+/** Provides helper functions for colors, device measurement conversion,
+ graphics, and graphic objects handling.
+ */
+class OOX_DLLPUBLIC GraphicHelper
+{
+public:
+ explicit GraphicHelper(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XFrame >& rxTargetFrame,
+ const StorageRef& rxStorage );
+ virtual ~GraphicHelper();
+
+ // Avoid implicitly defined copy constructors/assignments for the DLLPUBLIC class (they may
+ // require forward-declared classes used internally to be defined in places using GraphicHelper)
+ GraphicHelper(const GraphicHelper&) = delete;
+ GraphicHelper(GraphicHelper&&) = delete;
+ GraphicHelper& operator=(const GraphicHelper&) = delete;
+ GraphicHelper& operator=(GraphicHelper&&) = delete;
+
+ // System colors and predefined colors ------------------------------------
+
+ /** Returns a system color specified by the passed XML token identifier. */
+ ::Color getSystemColor( sal_Int32 nToken, ::Color nDefaultRgb = API_RGB_TRANSPARENT ) const;
+ /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */
+ virtual ::Color getSchemeColor( sal_Int32 nToken ) const;
+ /** Derived classes may implement to resolve a palette index to an RGB color. */
+ virtual ::Color getPaletteColor( sal_Int32 nPaletteIdx ) const;
+
+ virtual sal_Int32 getDefaultChartAreaFillStyle() const;
+
+ /** Returns chartspace automatic default border style */
+ static sal_Int32 getDefaultChartAreaLineStyle();
+
+ /** Returns chartspace automatic default border width in Emu */
+ static sal_Int16 getDefaultChartAreaLineWidth();
+
+ // Device info and device dependent unit conversion -----------------------
+
+ /** Returns information about the output device. */
+ const css::awt::DeviceInfo& getDeviceInfo() const { return maDeviceInfo;}
+
+ /** Converts the passed value from horizontal screen pixels to 1/100 mm. */
+ sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const;
+ /** Converts the passed value from vertical screen pixels to 1/100 mm. */
+ sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const;
+ /** Converts the passed size from screen pixels to 1/100 mm. */
+ css::awt::Size convertScreenPixelToHmm( const css::awt::Size& rPixel ) const;
+
+ /** Converts the passed value from 1/100 mm to horizontal screen pixels. */
+ double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const;
+ /** Converts the passed value from 1/100 mm to vertical screen pixels. */
+ double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const;
+ /** Converts the passed point from 1/100 mm to screen pixels. */
+ css::awt::Point convertHmmToScreenPixel( const css::awt::Point& rHmm ) const;
+ /** Converts the passed size from 1/100 mm to screen pixels. */
+ css::awt::Size convertHmmToScreenPixel( const css::awt::Size& rHmm ) const;
+
+ /** Converts the passed point from 1/100 mm to AppFont units. */
+ css::awt::Point convertHmmToAppFont( const css::awt::Point& rHmm ) const;
+ /** Converts the passed size from 1/100 mm to AppFont units. */
+ css::awt::Size convertHmmToAppFont( const css::awt::Size& rHmm ) const;
+
+
+ // Graphics and graphic objects ------------------------------------------
+
+ /** Imports a graphic from the passed input stream. */
+ css::uno::Reference< css::graphic::XGraphic >
+ importGraphic(
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ const WmfExternal* pExtHeader = nullptr ) const;
+
+ /** Imports a graphic from the passed binary memory block. */
+ css::uno::Reference< css::graphic::XGraphic >
+ importGraphic( const StreamDataSequence& rGraphicData ) const;
+
+ /** Imports a graphic from the storage stream with the passed path and name. */
+ css::uno::Reference< css::graphic::XGraphic >
+ importEmbeddedGraphic(
+ const OUString& rStreamName,
+ const WmfExternal* pExtHeader = nullptr ) const;
+
+ /** calculates the original size of a graphic which is necessary to be able to calculate cropping values
+ @return The original Graphic size in 100thmm */
+ css::awt::Size getOriginalSize( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ) const;
+
+ void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rxGraphicMapper);
+
+ void initializeGraphicMapperIfNeeded() const;
+private:
+
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+ css::uno::Reference< css::graphic::XGraphicProvider2 > mxGraphicProvider;
+ VclPtr<OutputDevice> mxDefaultOutputDevice;
+ css::awt::DeviceInfo maDeviceInfo; ///< Current output device info.
+ ::std::map< sal_Int32, ::Color > maSystemPalette; ///< Maps system colors (XML tokens) to RGB color values.
+ StorageRef mxStorage; ///< Storage containing embedded graphics.
+ double mfPixelPerHmmX; ///< Number of screen pixels per 1/100 mm in X direction.
+ double mfPixelPerHmmY; ///< Number of screen pixels per 1/100 mm in Y direction.
+ css::uno::Reference<css::graphic::XGraphicMapper> mxGraphicMapper;
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx
new file mode 100644
index 000000000..63718ca0e
--- /dev/null
+++ b/include/oox/helper/helper.hxx
@@ -0,0 +1,301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_HELPER_HXX
+#define INCLUDED_OOX_HELPER_HELPER_HXX
+
+#include <sal/config.h>
+
+#include <cstring>
+#include <limits>
+
+#include <o3tl/safeint.hxx>
+#include <osl/endian.h>
+#include <rtl/math.hxx>
+#include <sal/macros.h>
+#include <sal/types.h>
+#include <tools/color.hxx>
+
+namespace oox {
+
+// Helper macros ==============================================================
+
+namespace detail {
+
+//TODO: Temporary helper for STATIC_ARRAY_SELECT; ultimately, the latter should be replaced by a
+// proper function (template):
+template<typename T> constexpr std::make_unsigned_t<T> make_unsigned(T value) {
+ if constexpr (std::is_signed_v<T>) {
+ return o3tl::make_unsigned(value);
+ } else {
+ return value;
+ }
+}
+
+}
+
+/** Expands to the 'index'-th element of a STATIC data array, or to 'def', if
+ 'index' is out of the array limits. */
+#define STATIC_ARRAY_SELECT( array, index, def ) \
+ ((detail::make_unsigned(index) < SAL_N_ELEMENTS(array)) ? ((array)[static_cast<size_t>(index)]) : (def))
+
+// Common constants ===========================================================
+
+const sal_uInt8 WINDOWS_CHARSET_ANSI = 0;
+const sal_uInt8 WINDOWS_CHARSET_DEFAULT = 1;
+const sal_uInt8 WINDOWS_CHARSET_SYMBOL = 2;
+const sal_uInt8 WINDOWS_CHARSET_APPLE_ROMAN = 77;
+const sal_uInt8 WINDOWS_CHARSET_SHIFTJIS = 128;
+const sal_uInt8 WINDOWS_CHARSET_HANGEUL = 129;
+const sal_uInt8 WINDOWS_CHARSET_JOHAB = 130;
+const sal_uInt8 WINDOWS_CHARSET_GB2312 = 134;
+const sal_uInt8 WINDOWS_CHARSET_BIG5 = 136;
+const sal_uInt8 WINDOWS_CHARSET_GREEK = 161;
+const sal_uInt8 WINDOWS_CHARSET_TURKISH = 162;
+const sal_uInt8 WINDOWS_CHARSET_VIETNAMESE = 163;
+const sal_uInt8 WINDOWS_CHARSET_HEBREW = 177;
+const sal_uInt8 WINDOWS_CHARSET_ARABIC = 178;
+const sal_uInt8 WINDOWS_CHARSET_BALTIC = 186;
+const sal_uInt8 WINDOWS_CHARSET_RUSSIAN = 204;
+const sal_uInt8 WINDOWS_CHARSET_THAI = 222;
+const sal_uInt8 WINDOWS_CHARSET_EASTERN = 238;
+const sal_uInt8 WINDOWS_CHARSET_OEM = 255;
+
+
+const ::Color API_RGB_TRANSPARENT (ColorTransparency, 0xffffffff); ///< Transparent color for API calls.
+const sal_uInt32 UNSIGNED_RGB_TRANSPARENT = static_cast<sal_uInt32>(-1); ///< Transparent color for unsigned int32 places.
+const ::Color API_RGB_BLACK (0x000000); ///< Black color for API calls.
+const ::Color API_RGB_GRAY (0x808080); ///< Gray color for API calls.
+const ::Color API_RGB_WHITE (0xFFFFFF); ///< White color for API calls.
+
+const sal_Int16 API_LINE_SOLID = 0;
+const sal_Int16 API_LINE_DOTTED = 1;
+const sal_Int16 API_LINE_DASHED = 2;
+const sal_Int16 API_FINE_LINE_DASHED = 14;
+
+const sal_Int16 API_LINE_NONE = 0;
+const sal_Int16 API_LINE_HAIR = 2;
+const sal_Int16 API_LINE_THIN = 35;
+const sal_Int16 API_LINE_MEDIUM = 88;
+const sal_Int16 API_LINE_THICK = 141;
+
+const sal_Int16 API_ESCAPE_NONE = 0; ///< No escapement.
+const sal_Int16 API_ESCAPE_SUPERSCRIPT = 101; ///< Superscript: raise characters automatically (magic value 101).
+const sal_Int16 API_ESCAPE_SUBSCRIPT = -101; ///< Subscript: lower characters automatically (magic value -101).
+
+const sal_Int8 API_ESCAPEHEIGHT_NONE = 100; ///< Relative character height if not escaped.
+const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; ///< Relative character height if escaped.
+
+
+// Limitate values ------------------------------------------------------------
+
+template< typename ReturnType, typename Type >
+inline ReturnType getLimitedValue( Type nValue, Type nMin, Type nMax )
+{
+ return static_cast< ReturnType >( ::std::clamp( nValue, nMin, nMax ) );
+}
+
+template< typename ReturnType, typename Type >
+inline ReturnType getIntervalValue( Type nValue, Type nBegin, Type nEnd )
+{
+ static_assert(::std::numeric_limits< Type >::is_integer, "is integer");
+ Type nInterval = nEnd - nBegin;
+ Type nCount = (nValue < nBegin) ? -((nBegin - nValue - 1) / nInterval + 1) : ((nValue - nBegin) / nInterval);
+ return static_cast< ReturnType >( nValue - nCount * nInterval );
+}
+
+template< typename ReturnType >
+inline ReturnType getDoubleIntervalValue( double fValue, double fBegin, double fEnd )
+{
+ double fInterval = fEnd - fBegin;
+ double fCount = (fValue < fBegin) ? -(::rtl::math::approxFloor( (fBegin - fValue - 1.0) / fInterval ) + 1.0) : ::rtl::math::approxFloor( (fValue - fBegin) / fInterval );
+ return static_cast< ReturnType >( fValue - fCount * fInterval );
+}
+
+// Read from bitfields --------------------------------------------------------
+
+/** Returns true, if at least one of the bits set in nMask is set in nBitField. */
+template< typename Type >
+inline bool getFlag( Type nBitField, Type nMask )
+{
+ return (nBitField & nMask) != 0;
+}
+
+/** Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset. */
+template< typename ReturnType, typename Type >
+inline ReturnType getFlagValue( Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset )
+{
+ return getFlag( nBitField, nMask ) ? nSet : nUnset;
+}
+
+/** Extracts a value from a bit field.
+
+ Returns the data fragment from nBitField, that starts at bit nStartBit
+ (0-based, bit 0 is rightmost) with the width of nBitCount. The returned
+ value will be right-aligned (normalized).
+ For instance: extractValue<T>(0x4321,8,4) returns 3 (value in bits 8-11).
+ */
+template< typename ReturnType, typename Type >
+inline ReturnType extractValue( Type nBitField, sal_uInt8 nStartBit, sal_uInt8 nBitCount )
+{
+ sal_uInt64 nMask = 1; nMask <<= nBitCount; --nMask;
+ return static_cast< ReturnType >( nMask & (nBitField >> nStartBit) );
+}
+
+// Write to bitfields ---------------------------------------------------------
+
+/** Sets or clears (according to bSet) all set bits of nMask in ornBitField. */
+template< typename Type >
+inline void setFlag( Type& ornBitField, Type nMask, bool bSet = true )
+{
+ if( bSet ) ornBitField |= nMask; else ornBitField &= ~nMask;
+}
+
+
+/** Optional value, similar to ::std::optional<>, with convenience accessors.
+ */
+template< typename Type >
+class OptValue
+{
+public:
+ OptValue() : maValue(), mbHasValue( false ) {}
+ explicit OptValue( const Type& rValue ) : maValue( rValue ), mbHasValue( true ) {}
+ explicit OptValue( bool bHasValue, const Type& rValue ) : maValue( rValue ), mbHasValue( bHasValue ) {}
+
+ bool has() const { return mbHasValue; }
+ bool operator!() const { return !mbHasValue; }
+ bool differsFrom( const Type& rValue ) const { return mbHasValue && (maValue != rValue); }
+
+ const Type& get() const { return maValue; }
+ const Type& get( const Type& rDefValue ) const { return mbHasValue ? maValue : rDefValue; }
+
+ void set( const Type& rValue ) { maValue = rValue; mbHasValue = true; }
+ Type& use() { mbHasValue = true; return maValue; }
+
+ OptValue& operator=( const Type& rValue ) { set( rValue ); return *this; }
+ bool operator==( const OptValue& rValue ) const {
+ return ( ( !mbHasValue && rValue.mbHasValue == false ) ||
+ ( mbHasValue == rValue.mbHasValue && maValue == rValue.maValue ) );
+ }
+ void assignIfUsed( const OptValue& rValue ) { if( rValue.mbHasValue ) set( rValue.maValue ); }
+
+private:
+ Type maValue;
+ bool mbHasValue;
+};
+
+
+/** Provides platform independent functions to convert from or to little-endian
+ byte order, e.g. for reading data from or writing data to memory or a
+ binary stream.
+
+ On big-endian platforms, the byte order in the passed values is swapped,
+ this can be used for converting big-endian to and from little-endian data.
+
+ On little-endian platforms, the conversion functions are implemented empty,
+ thus compilers should completely optimize away the function call.
+ */
+class ByteOrderConverter
+{
+public:
+#ifdef OSL_BIGENDIAN
+ static void convertLittleEndian( sal_Int8& ) {} // present for usage in templates
+ static void convertLittleEndian( sal_uInt8& ) {} // present for usage in templates
+ static void convertLittleEndian( char16_t& rnValue ) { swap2( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( sal_Int16& rnValue ) { swap2( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( sal_uInt16& rnValue ) { swap2( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( sal_Int32& rnValue ) { swap4( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( sal_uInt32& rnValue ) { swap4( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( sal_Int64& rnValue ) { swap8( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( sal_uInt64& rnValue ) { swap8( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ static void convertLittleEndian( float& rfValue ) { swap4( reinterpret_cast< sal_uInt8* >( &rfValue ) ); }
+ static void convertLittleEndian( double& rfValue ) { swap8( reinterpret_cast< sal_uInt8* >( &rfValue ) ); }
+
+ template< typename Type >
+ inline static void convertLittleEndianArray( Type* pnArray, size_t nElemCount );
+
+ static void convertLittleEndianArray( sal_Int8*, size_t ) {}
+ static void convertLittleEndianArray( sal_uInt8*, size_t ) {}
+
+#else
+ template< typename Type >
+ static void convertLittleEndian( Type& ) {}
+
+ template< typename Type >
+ static void convertLittleEndianArray( Type*, size_t ) {}
+
+#endif
+
+ /** Writes a value to memory, while converting it to little-endian.
+ @param pDstBuffer The memory buffer to write the value to.
+ @param nValue The value to be written to memory in little-endian.
+ */
+ template< typename Type >
+ inline static void writeLittleEndian( void* pDstBuffer, Type nValue );
+
+#ifdef OSL_BIGENDIAN
+private:
+ inline static void swap2( sal_uInt8* pnData );
+ inline static void swap4( sal_uInt8* pnData );
+ inline static void swap8( sal_uInt8* pnData );
+#endif
+};
+
+
+template< typename Type >
+inline void ByteOrderConverter::writeLittleEndian( void* pDstBuffer, Type nValue )
+{
+ convertLittleEndian( nValue );
+ memcpy( pDstBuffer, &nValue, sizeof( Type ) );
+}
+
+#ifdef OSL_BIGENDIAN
+template< typename Type >
+inline void ByteOrderConverter::convertLittleEndianArray( Type* pnArray, size_t nElemCount )
+{
+ for( Type* pnArrayEnd = pnArray + nElemCount; pnArray != pnArrayEnd; ++pnArray )
+ convertLittleEndian( *pnArray );
+}
+
+inline void ByteOrderConverter::swap2( sal_uInt8* pnData )
+{
+ ::std::swap( pnData[ 0 ], pnData[ 1 ] );
+}
+
+inline void ByteOrderConverter::swap4( sal_uInt8* pnData )
+{
+ ::std::swap( pnData[ 0 ], pnData[ 3 ] );
+ ::std::swap( pnData[ 1 ], pnData[ 2 ] );
+}
+
+inline void ByteOrderConverter::swap8( sal_uInt8* pnData )
+{
+ ::std::swap( pnData[ 0 ], pnData[ 7 ] );
+ ::std::swap( pnData[ 1 ], pnData[ 6 ] );
+ ::std::swap( pnData[ 2 ], pnData[ 5 ] );
+ ::std::swap( pnData[ 3 ], pnData[ 4 ] );
+}
+#endif
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/modelobjecthelper.hxx b/include/oox/helper/modelobjecthelper.hxx
new file mode 100644
index 000000000..dd6100b33
--- /dev/null
+++ b/include/oox/helper/modelobjecthelper.hxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_MODELOBJECTHELPER_HXX
+#define INCLUDED_OOX_HELPER_MODELOBJECTHELPER_HXX
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace awt { struct Gradient;
+ class XBitmap; }
+ namespace graphic { class XGraphic; }
+ namespace container { class XNameContainer; }
+ namespace drawing { struct LineDash; }
+ namespace drawing { struct Hatch; }
+ namespace drawing { struct PolyPolygonBezierCoords; }
+ namespace lang { class XMultiServiceFactory; }
+}
+
+namespace oox {
+
+
+/** This helper manages named objects in a container, which is created on demand.
+ */
+class OOX_DLLPUBLIC ObjectContainer
+{
+public:
+ explicit ObjectContainer(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory,
+ const OUString& rServiceName );
+ ~ObjectContainer();
+
+ /** Returns true, if the object with the passed name exists in the container. */
+ bool hasObject( const OUString& rObjName ) const;
+
+ css::uno::Any getObject( const OUString& rObjName ) const;
+
+ /** Inserts the passed object into the container, returns its final name. */
+ OUString insertObject(
+ const OUString& rObjName,
+ const css::uno::Any& rObj,
+ bool bInsertByUnusedName );
+
+private:
+ void createContainer() const;
+
+private:
+ mutable css::uno::Reference< css::lang::XMultiServiceFactory >
+ mxModelFactory; ///< Factory to create the container.
+ mutable css::uno::Reference< css::container::XNameContainer >
+ mxContainer; ///< Container for the objects.
+ OUString maServiceName; ///< Service name to create the container.
+ sal_Int32 mnIndex; ///< Index to create unique identifiers.
+};
+
+
+/** Contains tables for named drawing objects for a document model.
+
+ Contains tables for named line markers, line dashes, fill gradients, and
+ fill bitmap URLs. The class is needed to handle different document models
+ in the same filter (e.g. embedded charts) which carry their own drawing
+ object tables.
+ */
+class OOX_DLLPUBLIC ModelObjectHelper
+{
+public:
+ explicit ModelObjectHelper(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory );
+
+ /** Returns true, if the model contains a line marker with the passed name. */
+ bool hasLineMarker( const OUString& rMarkerName ) const;
+
+ /** Inserts a new named line marker, overwrites an existing line marker
+ with the same name. Returns true, if the marker could be inserted. */
+ bool insertLineMarker(
+ const OUString& rMarkerName,
+ const css::drawing::PolyPolygonBezierCoords& rMarker );
+
+ /** Inserts a new named line dash, returns the line dash name, based on an
+ internal constant name with a new unused index appended. */
+ OUString insertLineDash( const css::drawing::LineDash& rDash );
+
+ /** Inserts a new named fill gradient, returns the gradient name, based on
+ an internal constant name with a new unused index appended. */
+ OUString insertFillGradient( const css::awt::Gradient& rGradient );
+
+ OUString insertTransGrandient( const css::awt::Gradient& rGradient );
+
+ OUString insertFillHatch( const css::drawing::Hatch& rHatch );
+
+ /** Inserts a new named fill graphic, returns the bitmap name, based on
+ an internal constant name with a new unused index appended. */
+ OUString insertFillBitmapXGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
+ css::uno::Reference<css::awt::XBitmap> getFillBitmap(OUString const & rGraphicName);
+
+private:
+ ObjectContainer maMarkerContainer; ///< Contains all named line markers (line end polygons).
+ ObjectContainer maDashContainer; ///< Contains all named line dashes.
+ ObjectContainer maGradientContainer; ///< Contains all named fill gradients.
+ ObjectContainer maTransGradContainer; ///< Contains all named transparency Gradients.
+ ObjectContainer maBitmapUrlContainer; ///< Contains all named fill bitmap URLs.
+ ObjectContainer maHatchContainer; ///< Contains all named fill hatches.
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/progressbar.hxx b/include/oox/helper/progressbar.hxx
new file mode 100644
index 000000000..e1c5c0a99
--- /dev/null
+++ b/include/oox/helper/progressbar.hxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_PROGRESSBAR_HXX
+#define INCLUDED_OOX_HELPER_PROGRESSBAR_HXX
+
+#include <memory>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace task { class XStatusIndicator; }
+}
+
+namespace oox {
+
+// Interfaces =================================================================
+
+/** Interface for progress bar classes.
+ */
+class OOX_DLLPUBLIC IProgressBar
+{
+public:
+ virtual ~IProgressBar();
+
+ /** Returns the current position of the progress bar.
+
+ @return Position of the progress bar, in the range from 0.0 (beginning
+ of the progress bar) to 1.0 (end of the progress bar) inclusive.
+ */
+ virtual double getPosition() const = 0;
+
+ /** Sets the current position of the progress bar.
+
+ @param fPosition New position of the progress bar, in the range from
+ 0.0 (beginning of the progress bar) to 1.0 (end of the progress bar)
+ inclusive.
+ */
+ virtual void setPosition( double fPosition ) = 0;
+};
+
+
+class ISegmentProgressBar;
+typedef std::shared_ptr< ISegmentProgressBar > ISegmentProgressBarRef;
+
+/** Interface for a segment in a progress bar, that is able to create sub
+ segments from itself.
+ */
+class OOX_DLLPUBLIC ISegmentProgressBar : public IProgressBar
+{
+public:
+ virtual ~ISegmentProgressBar() override;
+
+ /** Returns the length that is still free for creating sub segments. */
+ virtual double getFreeLength() const = 0;
+
+ /** Adds a new segment with the specified length. */
+ virtual ISegmentProgressBarRef createSegment( double fLength ) = 0;
+};
+
+
+/** A simple progress bar.
+ */
+class OOX_DLLPUBLIC ProgressBar final : public IProgressBar
+{
+public:
+ explicit ProgressBar(
+ const css::uno::Reference< css::task::XStatusIndicator >& rxIndicator,
+ const OUString& rText );
+
+ virtual ~ProgressBar() override;
+
+ /** Returns the current position of the progress bar. */
+ virtual double getPosition() const override;
+ /** Sets the current position of the progress bar. */
+ virtual void setPosition( double fPosition ) override;
+
+private:
+ css::uno::Reference< css::task::XStatusIndicator >
+ mxIndicator;
+ double mfPosition;
+};
+
+
+/** A progress bar containing several independent segments.
+ */
+class OOX_DLLPUBLIC SegmentProgressBar final : public ISegmentProgressBar
+{
+public:
+ explicit SegmentProgressBar(
+ const css::uno::Reference< css::task::XStatusIndicator >& rxIndicator,
+ const OUString& rText );
+
+ /** Returns the current position of the progress bar segment. */
+ virtual double getPosition() const override;
+ /** Sets the current position of the progress bar segment. */
+ virtual void setPosition( double fPosition ) override;
+
+ /** Returns the length that is still free for creating sub segments. */
+ virtual double getFreeLength() const override;
+ /** Adds a new segment with the specified length. */
+ virtual ISegmentProgressBarRef createSegment( double fLength ) override;
+
+private:
+ ProgressBar maProgress;
+ double mfFreeStart;
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/propertymap.hxx b/include/oox/helper/propertymap.hxx
new file mode 100644
index 000000000..423bb11fc
--- /dev/null
+++ b/include/oox/helper/propertymap.hxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_PROPERTYMAP_HXX
+#define INCLUDED_OOX_HELPER_PROPERTYMAP_HXX
+
+#include <map>
+#include <utility>
+#include <vector>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star::beans {
+ struct PropertyValue;
+ class XPropertySet;
+}
+
+namespace oox {
+
+
+typedef ::std::map< OUString, css::uno::Any > PropertyNameMap;
+
+/** A helper that maps property identifiers to property values.
+
+ The property identifiers are generated on compile time and refer to the
+ property name strings that are held by a static vector. The identifier to
+ name mapping is done internally while the properties are written to
+ property sets.
+ */
+class OOX_DLLPUBLIC PropertyMap
+{
+public:
+ PropertyMap();
+
+ /** Returns the name of the passed property identifier. */
+ static const OUString& getPropertyName( sal_Int32 nPropId );
+
+ /** Returns the property identifier of the passed name. */
+ static sal_Int32 getPropertyId( std::u16string_view sPropName );
+
+ /** Returns true, if the map contains a property with the passed identifier. */
+ bool hasProperty( sal_Int32 nPropId ) const;
+
+ /** Sets the specified property to the passed value. Does nothing, if the
+ identifier is invalid. */
+ bool setAnyProperty( sal_Int32 nPropId, const css::uno::Any& rValue );
+
+ /** Sets the specified property to the passed value. Does nothing, if the
+ identifier is invalid. */
+ template< typename Type >
+ bool setProperty( sal_Int32 nPropId, Type&& rValue )
+ {
+ if( nPropId < 0 )
+ return false;
+
+ maProperties[ nPropId ] <<= std::forward<Type>(rValue);
+ return true;
+ }
+
+ /** setAnyProperty should be used */
+ bool setProperty( sal_Int32, const css::uno::Any& ) = delete;
+
+ css::uno::Any getProperty( sal_Int32 nPropId );
+
+ void erase( sal_Int32 nPropId );
+
+ bool empty() const;
+
+ /** Inserts all properties contained in the passed property map. */
+ void assignUsed( const PropertyMap& rPropMap );
+
+ /** Inserts all properties contained in the passed property map */
+ void assignAll( const PropertyMap& rPropMap );
+
+ /** Returns a sequence of property values, filled with all contained properties. */
+ css::uno::Sequence< css::beans::PropertyValue >
+ makePropertyValueSequence() const;
+
+ /** Fills the passed sequences of names and anys with all contained properties. */
+ void fillSequences(
+ css::uno::Sequence< OUString >& rNames,
+ css::uno::Sequence< css::uno::Any >& rValues ) const;
+
+ void fillPropertyNameMap(PropertyNameMap& rMap) const;
+
+ /** Creates a property set supporting the XPropertySet interface and inserts all properties. */
+ css::uno::Reference< css::beans::XPropertySet >
+ makePropertySet() const;
+
+#if OSL_DEBUG_LEVEL > 0
+#ifdef DBG_UTIL
+ static void dump( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
+#endif
+ static void dumpCode( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
+ static void dumpData( const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
+#endif
+private:
+ const std::vector<OUString>* mpPropNames;
+
+protected:
+ std::map< sal_Int32, css::uno::Any > maProperties;
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/propertyset.hxx b/include/oox/helper/propertyset.hxx
new file mode 100644
index 000000000..676ec4ceb
--- /dev/null
+++ b/include/oox/helper/propertyset.hxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_PROPERTYSET_HXX
+#define INCLUDED_OOX_HELPER_PROPERTYSET_HXX
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <tools/color.hxx>
+
+namespace com::sun::star {
+ namespace beans { class XMultiPropertySet; }
+ namespace beans { class XPropertySet; }
+ namespace beans { class XPropertySetInfo; }
+}
+
+namespace oox {
+
+class PropertyMap;
+
+
+/** A wrapper for a UNO property set.
+
+ This class provides functions to silently get and set properties (without
+ exceptions, without the need to check validity of the UNO property set).
+
+ An instance is constructed with the reference to a UNO property set or any
+ other interface (the constructor will query for the
+ com.sun.star.beans.XPropertySet interface then). The reference to the
+ property set will be kept as long as the instance of this class is alive.
+
+ The functions setProperties() tries to handle all passed values at once,
+ using the com.sun.star.beans.XMultiPropertySet interface. If the
+ implementation does not support the XMultiPropertySet interface, all
+ properties are handled separately in a loop.
+ */
+class OOX_DLLPUBLIC PropertySet
+{
+public:
+ PropertySet() {}
+
+ /** Constructs a property set wrapper with the passed UNO property set. */
+ explicit PropertySet(
+ const css::uno::Reference< css::beans::XPropertySet >& rxPropSet )
+ { set( rxPropSet ); }
+
+ /** Constructs a property set wrapper after querying the XPropertySet interface. */
+ template< typename Type >
+ explicit PropertySet( const Type& rObject ) { set( rObject ); }
+
+ /** Sets the passed UNO property set and releases the old UNO property set. */
+ void set( const css::uno::Reference< css::beans::XPropertySet >& rxPropSet );
+
+ /** Queries the passed object (interface or any) for an XPropertySet and releases the old UNO property set. */
+ template< typename Type >
+ void set( const Type& rObject )
+ { set( css::uno::Reference< css::beans::XPropertySet >( rObject, css::uno::UNO_QUERY ) ); }
+
+ /** Returns true, if the contained XPropertySet interface is valid. */
+ bool is() const { return mxPropSet.is(); }
+
+ /** Returns true, if the specified property is supported by the property set. */
+ bool hasProperty( sal_Int32 nPropId ) const;
+
+ // Get properties ---------------------------------------------------------
+
+ /** Gets the specified property from the property set.
+ @return the property value, or an empty Any, if the property is missing. */
+ css::uno::Any getAnyProperty( sal_Int32 nPropId ) const;
+
+ /** Gets the specified property from the property set.
+ @return true, if the passed variable could be filled with the property value. */
+ template< typename Type >
+ bool getProperty( Type& orValue, sal_Int32 nPropId ) const
+ { return getAnyProperty( nPropId ) >>= orValue; }
+
+ /** Gets the specified boolean property from the property set.
+ @return true = property contains true; false = property contains false or error occurred. */
+ bool getBoolProperty( sal_Int32 nPropId ) const
+ { bool bValue = false; return getProperty( bValue, nPropId ) && bValue; }
+ // Set properties ---------------------------------------------------------
+
+ /** Puts the passed any into the property set. */
+ bool setAnyProperty( sal_Int32 nPropId, const css::uno::Any& rValue );
+
+ /** Puts the passed value into the property set. */
+ template< typename Type >
+ bool setProperty( sal_Int32 nPropId, const Type& rValue )
+ { return setAnyProperty( nPropId, css::uno::Any( rValue ) ); }
+ bool setProperty( sal_Int32 nPropId, ::Color rValue )
+ { return setAnyProperty( nPropId, css::uno::Any( rValue ) ); }
+
+ /** Puts the passed properties into the property set. Tries to use the XMultiPropertySet interface.
+ @param rPropNames The property names. MUST be ordered alphabetically.
+ @param rValues The related property values. */
+ void setProperties(
+ const css::uno::Sequence< OUString >& rPropNames,
+ const css::uno::Sequence< css::uno::Any >& rValues );
+
+ /** Puts the passed property map into the property set. Tries to use the XMultiPropertySet interface.
+ @param rPropertyMap The property map. */
+ void setProperties( const PropertyMap& rPropertyMap );
+
+#ifdef DBG_UTIL
+ void dump();
+#endif
+
+
+private:
+ /** Gets the specified property from the property set.
+ @return true, if the any could be filled with the property value. */
+ bool implGetPropertyValue( css::uno::Any& orValue, const OUString& rPropName ) const;
+
+ /** Puts the passed any into the property set. */
+ bool implSetPropertyValue( const OUString& rPropName, const css::uno::Any& rValue );
+
+private:
+ css::uno::Reference< css::beans::XPropertySet >
+ mxPropSet; ///< The mandatory property set interface.
+ css::uno::Reference< css::beans::XMultiPropertySet >
+ mxMultiPropSet; ///< The optional multi property set interface.
+ css::uno::Reference< css::beans::XPropertySetInfo >
+ mxPropSetInfo; ///< Property information.
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/refmap.hxx b/include/oox/helper/refmap.hxx
new file mode 100644
index 000000000..2e63af512
--- /dev/null
+++ b/include/oox/helper/refmap.hxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_REFMAP_HXX
+#define INCLUDED_OOX_HELPER_REFMAP_HXX
+
+#include <algorithm>
+#include <functional>
+#include <map>
+#include <memory>
+
+namespace oox {
+
+
+/** Template for a map of ref-counted objects with additional accessor functions.
+
+ An instance of the class RefMap< Type > stores elements of the type
+ std::shared_ptr< Type >. The new accessor functions has() and get()
+ work correctly for nonexisting keys, there is no need to check the passed
+ key before.
+ */
+template< typename KeyType, typename ObjType, typename CompType = std::less< KeyType > >
+class RefMap : public std::map< KeyType, std::shared_ptr< ObjType >, CompType >
+{
+public:
+ typedef std::map< KeyType, std::shared_ptr< ObjType >, CompType > container_type;
+ typedef typename container_type::key_type key_type;
+ typedef typename container_type::mapped_type mapped_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::key_compare key_compare;
+
+public:
+ /** Returns true, if the object associated to the passed key exists.
+ Returns false, if the key exists but points to an empty reference. */
+ bool has( key_type nKey ) const
+ {
+ const mapped_type* pxRef = getRef( nKey );
+ return pxRef && pxRef->get();
+ }
+
+ /** Returns a reference to the object associated to the passed key, or an
+ empty reference on error. */
+ mapped_type get( key_type nKey ) const
+ {
+ if( const mapped_type* pxRef = getRef( nKey ) ) return *pxRef;
+ return mapped_type();
+ }
+
+ /** Calls the passed functor for every contained object, automatically
+ skips all elements that are empty references. */
+ template< typename FunctorType >
+ void forEach( const FunctorType& rFunctor ) const
+ {
+ std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType >
+ void forEachMem( FuncType pFunc ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1, aParam1, aParam2 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 >
+ void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1, aParam1, aParam2, aParam3 ) );
+ }
+
+
+ /** Calls the passed functor for every contained object. Passes the key as
+ first argument and the object reference as second argument to rFunctor. */
+ template< typename FunctorType >
+ void forEachWithKey( const FunctorType& rFunctor ) const
+ {
+ std::for_each( this->begin(), this->end(), ForEachFunctorWithKey< FunctorType >( rFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the object key as argument to the member function. */
+ template< typename FuncType >
+ void forEachMemWithKey( FuncType pFunc ) const
+ {
+ forEachWithKey( ::std::bind( pFunc, std::placeholders::_2, std::placeholders::_1 ) );
+ }
+
+
+private:
+ template< typename FunctorType >
+ struct ForEachFunctor
+ {
+ FunctorType maFunctor;
+ explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( *rValue.second ); }
+ };
+
+ template< typename FunctorType >
+ struct ForEachFunctorWithKey
+ {
+ FunctorType maFunctor;
+ explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( rValue.first, *rValue.second ); }
+ };
+
+ const mapped_type* getRef( key_type nKey ) const
+ {
+ typename container_type::const_iterator aIt = this->find( nKey );
+ return (aIt == this->end()) ? nullptr : &aIt->second;
+ }
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/refvector.hxx b/include/oox/helper/refvector.hxx
new file mode 100644
index 000000000..018940836
--- /dev/null
+++ b/include/oox/helper/refvector.hxx
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_REFVECTOR_HXX
+#define INCLUDED_OOX_HELPER_REFVECTOR_HXX
+
+#include <algorithm>
+#include <functional>
+#include <memory>
+#include <vector>
+
+#include <sal/types.h>
+
+namespace oox {
+
+
+/** Template for a vector of ref-counted objects with additional accessor functions.
+
+ An instance of the class RefVector< Type > stores elements of the type
+ std::shared_ptr< Type >. The new accessor functions has() and get()
+ work correctly for indexes out of the current range, there is no need to
+ check the passed index before.
+ */
+template< typename ObjType >
+class RefVector : public ::std::vector< std::shared_ptr< ObjType > >
+{
+public:
+ typedef ::std::vector< std::shared_ptr< ObjType > > container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::size_type size_type;
+
+public:
+
+ /** Returns a reference to the object with the passed index, or 0 on error. */
+ value_type get( sal_Int32 nIndex ) const
+ {
+ if( const value_type* pxRef = getRef( nIndex ) ) return *pxRef;
+ return value_type();
+ }
+
+ /** Calls the passed functor for every contained object, automatically
+ skips all elements that are empty references. */
+ template< typename FunctorType >
+ void forEach( FunctorType aFunctor ) const
+ {
+ ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( aFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType >
+ void forEachMem( FuncType pFunc ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType >
+ void forEachMem( FuncType pFunc, ParamType aParam ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1, aParam ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1, aParam1, aParam2 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 >
+ void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
+ {
+ forEach( ::std::bind( pFunc, std::placeholders::_1, aParam1, aParam2, aParam3 ) );
+ }
+
+ /** Calls the passed functor for every contained object. Passes the index as
+ first argument and the object reference as second argument to rFunctor. */
+ template< typename FunctorType >
+ void forEachWithIndex( const FunctorType& rFunctor ) const
+ {
+ ::std::for_each( this->begin(), this->end(), ForEachFunctorWithIndex< FunctorType >( rFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the vector index as first argument to the member function. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEachWithIndex( ::std::bind( pFunc, std::placeholders::_2, std::placeholders::_1, aParam1, aParam2 ) );
+ }
+
+ /** Searches for an element by using the passed functor that takes a
+ constant reference of the object type (const ObjType&). */
+ template< typename FunctorType >
+ value_type findIf( const FunctorType& rFunctor ) const
+ {
+ typename container_type::const_iterator aIt = ::std::find_if( this->begin(), this->end(), FindFunctor< FunctorType >( rFunctor ) );
+ return (aIt == this->end()) ? value_type() : *aIt;
+ }
+
+private:
+ template< typename FunctorType >
+ struct ForEachFunctor
+ {
+ FunctorType maFunctor;
+ explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( *rxValue ); }
+ };
+
+ template< typename FunctorType >
+ struct ForEachFunctorWithIndex
+ {
+ FunctorType maFunctor;
+ sal_Int32 mnIndex;
+ explicit ForEachFunctorWithIndex( const FunctorType& rFunctor ) : maFunctor( rFunctor ), mnIndex( 0 ) {}
+ void operator()( const value_type& rxValue ) {
+ if( rxValue.get() ) maFunctor( mnIndex, *rxValue );
+ ++mnIndex;
+ }
+ };
+
+ template< typename FunctorType >
+ struct FindFunctor
+ {
+ FunctorType maFunctor;
+ explicit FindFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ bool operator()( const value_type& rxValue ) { return rxValue.get() && maFunctor( *rxValue ); }
+ };
+
+ const value_type* getRef( sal_Int32 nIndex ) const
+ {
+ return ((0 <= nIndex) && (static_cast< size_type >( nIndex ) < this->size())) ?
+ &(*this)[ static_cast< size_type >( nIndex ) ] : nullptr;
+ }
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/storagebase.hxx b/include/oox/helper/storagebase.hxx
new file mode 100644
index 000000000..2722ed80b
--- /dev/null
+++ b/include/oox/helper/storagebase.hxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_STORAGEBASE_HXX
+#define INCLUDED_OOX_HELPER_STORAGEBASE_HXX
+
+#include <functional>
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/refmap.hxx>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace embed { class XStorage; }
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XStream; }
+}
+
+namespace oox {
+
+
+class StorageBase;
+typedef std::shared_ptr< StorageBase > StorageRef;
+
+/** Base class for storage access implementations.
+
+ Derived classes will be used to encapsulate storage access implementations
+ for ZIP storages containing XML streams, and OLE storages containing binary
+ data streams.
+ */
+class OOX_DLLPUBLIC StorageBase
+{
+public:
+ explicit StorageBase(
+ const css::uno::Reference< css::io::XInputStream >& rxInStream,
+ bool bBaseStreamAccess );
+
+ explicit StorageBase(
+ const css::uno::Reference< css::io::XStream >& rxOutStream,
+ bool bBaseStreamAccess );
+
+ virtual ~StorageBase();
+
+ /** Returns true, if the object represents a valid storage. */
+ bool isStorage() const;
+
+ /** Returns true, if the object represents the root storage. */
+ bool isRootStorage() const;
+
+ /** Returns true, if the storage operates in read-only mode (based on an
+ input stream). */
+ bool isReadOnly() const { return mbReadOnly;}
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
+ css::uno::Reference< css::embed::XStorage >
+ getXStorage() const;
+
+ /** Returns the element name of this storage. */
+ const OUString& getName() const { return maStorageName;}
+
+ /** Returns the full path of this storage. */
+ OUString getPath() const;
+
+ /** Fills the passed vector with the names of all direct elements of this
+ storage. */
+ void getElementNames( ::std::vector< OUString >& orElementNames ) const;
+
+ /** Opens and returns the specified sub storage from the storage.
+
+ @param rStorageName
+ The name of the embedded storage. The name may contain slashes to
+ open storages from embedded substorages.
+ @param bCreateMissing
+ True = create missing sub storages (for export filters). Must be
+ false for storages based on input streams.
+ */
+ StorageRef openSubStorage( const OUString& rStorageName, bool bCreateMissing );
+
+ /** Opens and returns the specified input stream from the storage.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to open streams from embedded substorages. If base stream
+ access has been enabled in the constructor, the base stream can be
+ accessed by passing an empty string as stream name.
+ */
+ css::uno::Reference< css::io::XInputStream >
+ openInputStream( const OUString& rStreamName );
+
+ /** Opens and returns the specified output stream from the storage.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to create and open streams in embedded substorages. If base
+ stream access has been enabled in the constructor, the base stream
+ can be accessed by passing an empty string as stream name.
+ */
+ css::uno::Reference< css::io::XOutputStream >
+ openOutputStream( const OUString& rStreamName );
+
+ /** Copies the specified element from this storage to the passed
+ destination storage.
+
+ @param rElementName
+ The name of the embedded storage or stream. The name may contain
+ slashes to specify an element in an embedded substorage. In this
+ case, the element will be copied to the same substorage in the
+ destination storage.
+ */
+ void copyToStorage( StorageBase& rDestStrg, const OUString& rElementName );
+
+ /** Copies all streams of this storage and of all substorages to the passed
+ destination. */
+ void copyStorageToStorage( StorageBase& rDestStrg );
+
+ /** Commits the changes to the storage and all substorages. */
+ void commit();
+
+protected:
+ /** Special constructor for sub storage objects. */
+ explicit StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName, bool bReadOnly );
+
+private:
+ StorageBase( const StorageBase& ) = delete;
+ StorageBase& operator=( const StorageBase& ) = delete;
+
+ /** Returns true, if the object represents a valid storage. */
+ virtual bool implIsStorage() const = 0;
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
+ virtual css::uno::Reference< css::embed::XStorage >
+ implGetXStorage() const = 0;
+
+ /** Returns the names of all elements of this storage. */
+ virtual void implGetElementNames( ::std::vector< OUString >& orElementNames ) const = 0;
+
+ /** Implementation of opening a storage element. */
+ virtual StorageRef implOpenSubStorage( const OUString& rElementName, bool bCreate ) = 0;
+
+ /** Implementation of opening an input stream element. */
+ virtual css::uno::Reference< css::io::XInputStream >
+ implOpenInputStream( const OUString& rElementName ) = 0;
+
+ /** Implementation of opening an output stream element. */
+ virtual css::uno::Reference< css::io::XOutputStream >
+ implOpenOutputStream( const OUString& rElementName ) = 0;
+
+ /** Commits the current storage. */
+ virtual void implCommit() const = 0;
+
+ /** Helper that opens and caches the specified direct substorage. */
+ StorageRef getSubStorage( const OUString& rElementName, bool bCreateMissing );
+
+private:
+ RefMap< OUString, StorageBase >
+ maSubStorages; ///< Map of direct sub storages.
+ css::uno::Reference< css::io::XInputStream >
+ mxInStream; ///< Cached base input stream (to keep it alive).
+ css::uno::Reference< css::io::XStream >
+ mxOutStream; ///< Cached base output stream (to keep it alive).
+ OUString maParentPath; ///< Full path of parent storage.
+ OUString maStorageName; ///< Name of this storage, if it is a substorage.
+ bool mbBaseStreamAccess; ///< True = access base streams with empty stream name.
+ bool mbReadOnly; ///< True = storage opened read-only (based on input stream).
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/textinputstream.hxx b/include/oox/helper/textinputstream.hxx
new file mode 100644
index 000000000..4a5bcdbfe
--- /dev/null
+++ b/include/oox/helper/textinputstream.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_TEXTINPUTSTREAM_HXX
+#define INCLUDED_OOX_HELPER_TEXTINPUTSTREAM_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+ namespace io { class XTextInputStream2; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+
+class BinaryInputStream;
+
+
+class TextInputStream
+{
+public:
+ explicit TextInputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ explicit TextInputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ BinaryInputStream& rInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ ~TextInputStream();
+
+ /** Returns true, if no more text is available in the stream.
+ */
+ bool isEof() const;
+
+ /** Reads a text line from the stream.
+
+ If the last line in the stream is not terminated with line-end
+ character(s), the stream will immediately go into EOF state and return
+ the text line. Otherwise, if the last character in the stream is a
+ line-end character, the next call to this function will turn the stream
+ into EOF state and return an empty string.
+ */
+ OUString readLine();
+
+ /** Reads a text portion from the stream until the specified character is
+ found.
+
+ If the end of the stream is not terminated with the specified
+ character, the stream will immediately go into EOF state and return the
+ remaining text portion. Otherwise, if the last character in the stream
+ is the specified character (and caller specifies to read and return it,
+ see parameter bIncludeChar), the next call to this function will turn
+ the stream into EOF state and return an empty string.
+
+ @param cChar
+ The separator character to be read to.
+
+ @param bIncludeChar
+ True = if found, the specified character will be read from stream
+ and included in the returned string.
+ False = the specified character will neither be read from the
+ stream nor included in the returned string, but will be
+ returned as first character in the next call of this function
+ or readLine().
+ */
+ OUString readToChar( sal_Unicode cChar, bool bIncludeChar );
+
+
+ /** Creates a UNO text input stream object from the passed UNO input stream.
+ */
+ static css::uno::Reference< css::io::XTextInputStream2 >
+ createXTextInputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ rtl_TextEncoding eTextEnc );
+
+
+private:
+ void init(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ /** Adds the pending character in front of the passed string, if existing. */
+ OUString createFinalString( const OUString& rString );
+
+private:
+ css::uno::Reference< css::io::XTextInputStream2 >
+ mxTextStrm;
+ sal_Unicode mcPendingChar;
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/helper/zipstorage.hxx b/include/oox/helper/zipstorage.hxx
new file mode 100644
index 000000000..dec4b483e
--- /dev/null
+++ b/include/oox/helper/zipstorage.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_HELPER_ZIPSTORAGE_HXX
+#define INCLUDED_OOX_HELPER_ZIPSTORAGE_HXX
+
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace embed { class XStorage; }
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XStream; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+
+
+/** Implements stream access for ZIP storages containing XML streams. */
+class ZipStorage final : public StorageBase
+{
+public:
+ explicit ZipStorage(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStream );
+
+ explicit ZipStorage(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XStream >& rxStream );
+
+ virtual ~ZipStorage() override;
+
+private:
+ explicit ZipStorage(
+ const ZipStorage& rParentStorage,
+ const css::uno::Reference< css::embed::XStorage >& rxStorage,
+ const OUString& rElementName );
+
+ /** Returns true, if the object represents a valid storage. */
+ virtual bool implIsStorage() const override;
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
+ virtual css::uno::Reference< css::embed::XStorage >
+ implGetXStorage() const override;
+
+ /** Returns the names of all elements of this storage. */
+ virtual void implGetElementNames( ::std::vector< OUString >& orElementNames ) const override;
+
+ /** Opens and returns the specified sub storage from the storage. */
+ virtual StorageRef implOpenSubStorage( const OUString& rElementName, bool bCreateMissing ) override;
+
+ /** Opens and returns the specified input stream from the storage. */
+ virtual css::uno::Reference< css::io::XInputStream >
+ implOpenInputStream( const OUString& rElementName ) override;
+
+ /** Opens and returns the specified output stream from the storage. */
+ virtual css::uno::Reference< css::io::XOutputStream >
+ implOpenOutputStream( const OUString& rElementName ) override;
+
+ /** Commits the current storage. */
+ virtual void implCommit() const override;
+
+private:
+ css::uno::Reference< css::embed::XStorage >
+ mxStorage; ///< Storage based on input or output stream.
+};
+
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/mathml/export.hxx b/include/oox/mathml/export.hxx
new file mode 100644
index 000000000..e9589a0d1
--- /dev/null
+++ b/include/oox/mathml/export.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_OOX_MATHML_EXPORT_HXX
+#define INCLUDED_OOX_MATHML_EXPORT_HXX
+
+#include <oox/core/filterbase.hxx>
+#include <oox/dllapi.h>
+#include <oox/export/utils.hxx>
+#include <rtl/strbuf.hxx>
+#include <rtl/textenc.h>
+#include <sax/fshelper.hxx>
+
+namespace oox
+{
+
+/**
+ Interface class, StarMath will implement writeFormula*() to write out markup
+ representing the formula.
+ */
+class OOX_DLLPUBLIC FormulaExportBase
+{
+public:
+ virtual void writeFormulaOoxml(::sax_fastparser::FSHelperPtr pSerializer,
+ oox::core::OoxmlVersion version,
+ oox::drawingml::DocumentType documentType, sal_Int8 nAlign) = 0;
+ virtual void writeFormulaRtf( OStringBuffer& rBuffer, rtl_TextEncoding nEncoding ) = 0;
+ enum eFormulaAlign { INLINE, CENTER, GROUPEDCENTER, LEFT, RIGHT };
+
+protected:
+ FormulaExportBase();
+
+ ~FormulaExportBase() {}
+};
+
+} // namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/mathml/import.hxx b/include/oox/mathml/import.hxx
new file mode 100644
index 000000000..92db9a837
--- /dev/null
+++ b/include/oox/mathml/import.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_OOX_MATHML_IMPORT_HXX
+#define INCLUDED_OOX_MATHML_IMPORT_HXX
+
+#include <oox/dllapi.h>
+#include <rtl/ref.hxx>
+#include <tools/gen.hxx>
+
+namespace oox
+{
+
+namespace formulaimport
+{
+class XmlStream;
+}
+
+/**
+ Interface class, StarMath will implement readFormulaOoxml() to read OOXML
+ representing the formula and getFormulaSize() to provide the size of the resulting
+ formula.
+ */
+class OOX_DLLPUBLIC FormulaImportBase
+{
+public:
+ virtual void readFormulaOoxml( oox::formulaimport::XmlStream& stream ) = 0;
+ virtual Size getFormulaSize() const = 0;
+
+protected:
+ FormulaImportBase();
+
+ ~FormulaImportBase() {}
+};
+
+namespace core { class ContextHandler; }
+namespace drawingml { class TextParagraph; }
+
+::rtl::Reference<core::ContextHandler> CreateLazyMathBufferingContext(
+ core::ContextHandler const& rParent, drawingml::TextParagraph & rPara);
+
+} // namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/mathml/importutils.hxx b/include/oox/mathml/importutils.hxx
new file mode 100644
index 000000000..9ab79a6f0
--- /dev/null
+++ b/include/oox/mathml/importutils.hxx
@@ -0,0 +1,255 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_OOX_MATHML_IMPORTUTILS_HXX
+#define INCLUDED_OOX_MATHML_IMPORTUTILS_HXX
+
+#include <map>
+#include <string_view>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/token/tokens.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star
+{
+namespace xml::sax
+{
+class XFastAttributeList;
+}
+}
+
+namespace oox::formulaimport
+{
+// used to differentiate between tags that opening or closing
+const int TAG_OPENING = 1 << 29;
+const int TAG_CLOSING = 1 << 30;
+
+// you probably want to #define these to something shorter in the .cxx file,
+// but they must be done as macros, otherwise they wouldn't be usable for case values,
+// and macros cannot be namespaced
+#define XML_STREAM_OPENING(token) (TAG_OPENING | token)
+#define XML_STREAM_CLOSING(token) (TAG_CLOSING | token)
+
+/**
+ Class for storing a stream of xml tokens.
+
+ A part of an XML file can be parsed and stored in this stream, from which it can be read
+ as if parsed linearly. The purpose of this class is to allow simpler handling of XML
+ files, unlike the usual LO way of using callbacks, context handlers and similar needlessly
+ complicated stuff (YMMV).
+
+ The advantages of this approach is easy to read and debug code (as it is just functions
+ reading tokens one by one and calling other functions, compared to having to use callbacks
+ and temporary storage). The disadvantage is that the XML structure needs to be handled
+ manually by the code.
+
+ Note that tag identifiers are simply int values and the API does not care besides matching
+ their values to XML stream contents and requiring that the values are not as high as TAG_OPENING.
+ Be prepared for the fact that some of the functions may throw exceptions if the input
+ stream does not match the required token (TBD).
+
+ The API tries to make the common idioms as simple as possible, see the following examples.
+
+ Parse <tagone attr="value"><tagtwo>text</tagtwo></tagone> , where tagtwo is optional:
+ @code
+XmlStream::Tag tagoneTag = stream.ensureOpeningTag( tagone );
+if( attributeTag.hasAttribute( attr ))
+ ... = attributeTag.attribute( attr, defaultValueOfTheRightType );
+if( XmlStream::Tag tagtwoTag = stream.checkOpeningTag( tagtwo ))
+{
+ ... = tagtwoTag.text;
+ stream.ensureClosingTag( tagtwo );
+}
+stream.ensureClosingTag( tagone );
+ @endcode
+
+ Parse an element that may contain several sub-elements of different types in random order:
+ @code
+stream.ensureOpeningTag( element );
+while( !stream.atEnd() && stream.currentToken() != CLOSING( element ))
+ {
+ switch( stream.currentToken())
+ {
+ case OPENING( subelement1 ):
+ handleSubElement1();
+ break;
+ case OPENING( subelement2 ):
+ ... process subelement2;
+ break;
+ default:
+ stream.handleUnexpectedTag();
+ break;
+ }
+stream.ensureClosingTag( element );
+ @endcode
+
+ If there may not be a zero number of sub-elements, use a helper bool variable or use a do-while loop.
+
+ Parse an element that may contain an unknown number of sub-elements of the same type:
+ @code
+stream.ensureOpeningTag( element );
+while( !stream.atEnd() && stream.findTag( OPENING( subelement )))
+ {
+ handleSubelement();
+ }
+stream.ensureClosingTag( element );
+ @endcode
+
+ If there may not be a zero number of sub-elements, use a helper bool variable or use a do-while loop.
+
+ @since 3.5
+*/
+class OOX_DLLPUBLIC XmlStream
+{
+public:
+ XmlStream();
+ /**
+ Structure representing a list of attributes.
+ */
+ // One could theoretically use oox::AttributeList, but that complains if the passed reference is empty,
+ // which would be complicated to avoid here. Also, parsers apparently reuse the same instance of XFastAttributeList,
+ // which means using oox::AttributeList would make them all point to the one instance.
+ struct OOX_DLLPUBLIC AttributeList
+ {
+ OUString& operator[](int token);
+ OUString attribute(int token, const OUString& def) const;
+ bool attribute(int token, bool def) const;
+ sal_Unicode attribute(int token, sal_Unicode def) const;
+ // when adding more attribute() overloads, add also to XmlStream itself
+ protected:
+ std::map<int, OUString> attrs;
+ };
+ /**
+ Structure representing a tag, including its attributes and content text immediately following it.
+ */
+ struct OOX_DLLPUBLIC Tag
+ {
+ Tag(int token = XML_TOKEN_INVALID,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& attributes
+ = css::uno::Reference<css::xml::sax::XFastAttributeList>());
+ Tag(int token, const AttributeList& attribs);
+ int token; ///< tag type, or XML_TOKEN_INVALID
+ AttributeList attributes;
+ OUString text;
+ /**
+ This function returns value of the given attribute, or the passed default value if not found.
+ The type of the default value selects the return type (OUString here).
+ */
+ OUString attribute(int token, const OUString& def = OUString()) const;
+ /**
+ @overload
+ */
+ bool attribute(int token, bool def) const;
+ /**
+ @overload
+ */
+ sal_Unicode attribute(int token, sal_Unicode def) const;
+ // when adding more attribute() overloads, add also to XmlStream::AttributeList and inline below
+ /**
+ Converts to true if the tag has a valid token, false otherwise. Allows simple
+ usage in if(), for example 'if( XmlStream::Tag foo = stream.checkOpeningTag( footoken ))'.
+ */
+ operator bool() const;
+ };
+ /**
+ @return true if current position is at the end of the XML stream
+ */
+ bool atEnd() const;
+ /**
+ @return data about the current tag
+ */
+ Tag currentTag() const;
+ /**
+ @return the token for the current tag
+ */
+ int currentToken() const;
+ /**
+ Moves position to the next tag.
+ */
+ void moveToNextTag();
+ /**
+ Ensures that an opening tag with the given token is read. If the current tag does not match,
+ writes out a warning and tries to recover by skipping tags until found (or until the current element would end).
+ If found, the position in the stream is afterwards moved to the next tag.
+ @return the matching found opening tag, or empty tag if not found
+ */
+ Tag ensureOpeningTag(int token);
+ /**
+ Tries to find an opening tag with the given token. Works similarly like ensureOpeningTag(),
+ but if a matching tag is not found, the position in the stream is not altered. The primary
+ use of this function is to check for optional elements.
+ @return the matching found opening tag, or empty tag if not found
+ */
+ Tag checkOpeningTag(int token);
+ /**
+ Ensures that a closing tag with the given token is read. Like ensureOpeningTag(),
+ if not, writes out a warning and tries to recover by skipping tags until found (or until the current element would end).
+ If found, the position in the stream is afterwards moved to the next tag.
+ */
+ void ensureClosingTag(int token);
+ /**
+ Tries to find the given token, until either found (returns true) or end of current element.
+ Position in the stream is set to make the tag current (i.e. it will be the next one read).
+ */
+ bool findTag(int token);
+ /**
+ Handle the current (unexpected) tag.
+ */
+ void handleUnexpectedTag();
+
+protected:
+ Tag checkTag(int token, bool optional);
+ bool findTagInternal(int token, bool silent);
+ void skipElementInternal(int token, bool silent);
+ std::vector<Tag> tags;
+ unsigned int pos;
+};
+
+/**
+ This class is used for creating XmlStream.
+
+ Simply use this class and then pass it as XmlStream to the consumer.
+
+ @since 3.5.0
+*/
+class OOX_DLLPUBLIC XmlStreamBuilder : public XmlStream
+{
+public:
+ void appendOpeningTag(int token,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& attributes
+ = css::uno::Reference<css::xml::sax::XFastAttributeList>());
+ void appendOpeningTag(int token, const AttributeList& attribs);
+ void appendClosingTag(int token);
+ // appends the characters after the last appended token
+ void appendCharacters(std::u16string_view characters);
+};
+
+inline OUString XmlStream::Tag::attribute(int t, const OUString& def) const
+{
+ return attributes.attribute(t, def);
+}
+
+inline bool XmlStream::Tag::attribute(int t, bool def) const
+{
+ return attributes.attribute(t, def);
+}
+
+inline sal_Unicode XmlStream::Tag::attribute(int t, sal_Unicode def) const
+{
+ return attributes.attribute(t, def);
+}
+
+} // namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/axbinaryreader.hxx b/include/oox/ole/axbinaryreader.hxx
new file mode 100644
index 000000000..eb185f235
--- /dev/null
+++ b/include/oox/ole/axbinaryreader.hxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_AXBINARYREADER_HXX
+#define INCLUDED_OOX_OLE_AXBINARYREADER_HXX
+
+#include <cstddef>
+#include <utility>
+#include <vector>
+
+#include <oox/helper/binaryinputstream.hxx>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/refvector.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox::ole { struct AxFontData; }
+
+namespace oox::ole {
+
+
+/** A wrapper for a binary input stream that supports aligned read operations.
+
+ The implementation does not support seeking back the wrapped stream. All
+ seeking operations (tell, seekTo, align) are performed relative to the
+ position of the wrapped stream at construction time of this wrapper. It is
+ possible to construct this wrapper with an unseekable input stream without
+ losing any functionality.
+ */
+class AxAlignedInputStream final : public BinaryInputStream
+{
+public:
+ explicit AxAlignedInputStream( BinaryInputStream& rInStrm );
+
+ /** Returns the size of the data this stream represents, if the wrapped
+ stream supports the size() operation. */
+ virtual sal_Int64 size() const override;
+ /** Return the current relative stream position (relative to position of
+ the wrapped stream at construction time). */
+ virtual sal_Int64 tell() const override;
+ /** Seeks the stream to the passed relative position, if it is behind the
+ current position. */
+ virtual void seek( sal_Int64 nPos ) override;
+ /** Closes the input stream but not the wrapped stream. */
+ virtual void close() override;
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+ /** Seeks the stream forward by the passed number of bytes. */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Aligns the stream to a multiple of the passed size (relative to the
+ position of the wrapped stream at construction time). */
+ void align( size_t nSize );
+
+ /** Aligns the stream according to the passed type and reads a value. */
+ template< typename Type >
+ [[nodiscard]]
+ Type readAligned() { align( sizeof( Type ) ); return readValue< Type >(); }
+ /** Aligns the stream according to the passed type and skips the size of the type. */
+ template< typename Type >
+ void skipAligned() { align( sizeof( Type ) ); skip( sizeof( Type ) ); }
+
+private:
+ BinaryInputStream* mpInStrm; ///< The wrapped input stream.
+ sal_Int64 mnStrmPos; ///< Tracks relative position in the stream.
+ sal_Int64 mnStrmSize; ///< Size of the wrapped stream data.
+};
+
+
+/** A pair of integer values as a property. */
+typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData;
+
+/** An array of string values as a property. */
+typedef ::std::vector< OUString > AxArrayString;
+
+
+/** Import helper to read simple and complex ActiveX form control properties
+ from a binary input stream. */
+class AxBinaryPropertyReader
+{
+public:
+ explicit AxBinaryPropertyReader( BinaryInputStream& rInStrm, bool b64BitPropFlags = false );
+
+ /** Reads the next integer property value from the stream, if the
+ respective flag in the property mask is set. */
+ template< typename StreamType, typename DataType >
+ void readIntProperty( DataType& ornValue )
+ { if( startNextProperty() ) ornValue = maInStrm.readAligned< StreamType >(); }
+ /** Reads the next boolean property value from the stream, if the
+ respective flag in the property mask is set. */
+ void readBoolProperty( bool& orbValue, bool bReverse = false );
+ /** Reads the next pair property from the stream, if the respective flag in
+ the property mask is set. */
+ void readPairProperty( AxPairData& orPairData );
+ /** Reads the next string property from the stream, if the respective flag
+ in the property mask is set. */
+ void readStringProperty( OUString& orValue );
+ /** Reads ArrayString, an array of fmString ( compressed or uncompressed )
+ is read from the stream and inserted into rStrings */
+ void readArrayStringProperty( std::vector< OUString >& rStrings );
+ /** Reads the next GUID property from the stream, if the respective flag
+ in the property mask is set. The GUID will be enclosed in braces. */
+ void readGuidProperty( OUString& orGuid );
+ /** Reads the next font property from the stream, if the respective flag in
+ the property mask is set. */
+ void readFontProperty( AxFontData& orFontData );
+ /** Reads the next picture property from the stream, if the respective flag
+ in the property mask is set. */
+ void readPictureProperty( StreamDataSequence& orPicData );
+
+ /** Skips the next integer property value in the stream, if the respective
+ flag in the property mask is set. */
+ template< typename StreamType >
+ void skipIntProperty() { if( startNextProperty() ) maInStrm.skipAligned< StreamType >(); }
+ /** Skips the next boolean property value in the stream, if the respective
+ flag in the property mask is set. */
+ void skipBoolProperty() { (void)startNextProperty(); }
+ /** Skips the next string property in the stream, if the respective flag in
+ the property mask is set. */
+ void skipStringProperty() { readStringProperty( maDummyString ); }
+ /** Skips the next ArrayString property in the stream, if the respective flag in
+ the property mask is set. */
+ void skipArrayStringProperty() { readArrayStringProperty( maDummyArrayString ); }
+ /** Skips the next GUID property in the stream, if the respective flag in
+ the property mask is set. */
+ void skipGuidProperty() { readGuidProperty( maDummyString ); }
+ /** Skips the next picture property in the stream, if the respective flag
+ in the property mask is set. */
+ void skipPictureProperty() { readPictureProperty( maDummyPicData ); }
+ /** Has to be called for undefined properties. If the respective flag in
+ the mask is set, the property import cannot be finished successfully. */
+ void skipUndefinedProperty() { ensureValid( !startNextProperty() ); }
+
+ /** Final processing, reads contents of all complex properties. */
+ bool finalizeImport();
+
+private:
+ bool ensureValid( bool bCondition = true );
+ bool startNextProperty();
+
+private:
+ /** Base class for complex properties such as string, point, size, GUID, picture. */
+ struct ComplexProperty
+ {
+ virtual ~ComplexProperty();
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) = 0;
+ };
+
+ /** Complex property for a 32-bit value pair, e.g. point or size. */
+ struct PairProperty final : public ComplexProperty
+ {
+ AxPairData& mrPairData;
+
+ explicit PairProperty( AxPairData& rPairData ) :
+ mrPairData( rPairData ) {}
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) override;
+ };
+
+ /** Complex property for a string value. */
+ struct StringProperty final : public ComplexProperty
+ {
+ OUString& mrValue;
+ sal_uInt32 mnSize;
+
+ explicit StringProperty( OUString& rValue, sal_uInt32 nSize ) :
+ mrValue( rValue ), mnSize( nSize ) {}
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) override;
+ };
+
+ /** Complex property for an array of strings. */
+ struct ArrayStringProperty final : public ComplexProperty
+ {
+ AxArrayString& mrArray;
+ sal_uInt32 mnSize;
+ explicit ArrayStringProperty( AxArrayString& rArray, sal_uInt32 nSize ) :
+ mrArray( rArray ), mnSize( nSize ) {}
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) override;
+ };
+
+ /** Complex property for a GUID value. */
+ struct GuidProperty final : public ComplexProperty
+ {
+ OUString& mrGuid;
+
+ explicit GuidProperty( OUString& rGuid ) :
+ mrGuid( rGuid ) {}
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) override;
+ };
+
+ /** Stream property for a font structure. */
+ struct FontProperty final : public ComplexProperty
+ {
+ AxFontData& mrFontData;
+
+ explicit FontProperty( AxFontData& rFontData ) :
+ mrFontData( rFontData ) {}
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) override;
+ };
+
+ /** Stream property for a picture or mouse icon. */
+ struct PictureProperty final : public ComplexProperty
+ {
+ StreamDataSequence& mrPicData;
+
+ explicit PictureProperty( StreamDataSequence& rPicData ) :
+ mrPicData( rPicData ) {}
+ virtual bool readProperty( AxAlignedInputStream& rInStrm ) override;
+ };
+
+ typedef RefVector< ComplexProperty > ComplexPropVector;
+
+private:
+ AxAlignedInputStream maInStrm; ///< The input stream to read from.
+ ComplexPropVector maLargeProps; ///< Stores info for all used large properties.
+ ComplexPropVector maStreamProps; ///< Stores info for all used stream data properties.
+ StreamDataSequence maDummyPicData; ///< Dummy picture for unsupported properties.
+ OUString maDummyString; ///< Dummy string for unsupported properties.
+ AxArrayString maDummyArrayString; ///< Dummy strings for unsupported ArrayString properties.
+ sal_Int64 mnPropFlags; ///< Flags specifying existing properties.
+ sal_Int64 mnNextProp; ///< Next property to read.
+ sal_Int64 mnPropsEnd; ///< End position of simple/large properties.
+ bool mbValid; ///< True = stream still valid.
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/axbinarywriter.hxx b/include/oox/ole/axbinarywriter.hxx
new file mode 100644
index 000000000..eb370473a
--- /dev/null
+++ b/include/oox/ole/axbinarywriter.hxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_OOX_OLE_AXBINARYWRITER_HXX
+#define INCLUDED_OOX_OLE_AXBINARYWRITER_HXX
+
+#include <cstddef>
+#include <utility>
+
+#include <oox/helper/binaryoutputstream.hxx>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/refvector.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox::ole {
+
+
+/** A wrapper for a binary output stream that supports aligned write operations.
+
+ The implementation does support seeking back the wrapped stream. All
+ seeking operations (tell, seekTo, align) are performed relative to the
+ position of the wrapped stream at construction time of this wrapper.
+ Unlike it's reader class counterpart it is NOT possible to construct this
+ wrapper with an unseekable output stream.
+ */
+class AxAlignedOutputStream final : public BinaryOutputStream
+{
+public:
+ explicit AxAlignedOutputStream( BinaryOutputStream& rOutStrm );
+
+ /** Returns the size of the data this stream represents, if the wrapped
+ stream supports the size() operation. */
+ virtual sal_Int64 size() const override;
+ /** Return the current relative stream position (relative to position of
+ the wrapped stream at construction time). */
+ virtual sal_Int64 tell() const override;
+ /** Seeks the stream to the passed relative position, if it is behind the
+ current position. */
+ virtual void seek( sal_Int64 nPos ) override;
+ /** Closes the input stream but not the wrapped stream. */
+ virtual void close() override;
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual void writeData( const StreamDataSequence& orData, size_t nAtomSize = 1 ) override;
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+ /** Aligns the stream to a multiple of the passed size (relative to the
+ position of the wrapped stream at construction time). */
+ void align( size_t nSize );
+
+ void pad( sal_Int32 nBytes );
+
+ /** Aligns the stream according to the passed type and reads a value. */
+ template< typename Type >
+ void writeAligned( Type nVal ) { align( sizeof( Type ) ); writeValue( nVal ); }
+
+private:
+ BinaryOutputStream* mpOutStrm; ///< The wrapped input stream.
+ sal_Int64 mnStrmPos; ///< Tracks relative position in the stream.
+ sal_Int64 mnStrmSize; ///< Size of the wrapped stream data.
+ sal_Int64 mnWrappedBeginPos; ///< starting pos or wrapped stream
+};
+
+/** A pair of integer values as a property. */
+typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData;
+
+/** Export helper to write simple and complex ActiveX form control properties
+ to a binary input stream. */
+class AxBinaryPropertyWriter
+{
+public:
+ explicit AxBinaryPropertyWriter( BinaryOutputStream& rOutStrm, bool b64BitPropFlags = false );
+
+ /** Write an integer property value to the stream, the
+ respective flag in the property mask is set. */
+ template< typename StreamType, typename DataType >
+ void writeIntProperty( DataType ornValue )
+ { startNextProperty(); maOutStrm.writeAligned< StreamType >( ornValue ); }
+ /** Write a boolean property value to the stream, the
+ respective flag in the property mask is set. */
+ void writeBoolProperty( bool orbValue );
+ /** Write a pair property the stream, the respective flag in
+ the property mask is set. */
+ void writePairProperty( AxPairData& orPairData );
+ /** Write a string property to the stream, the respective flag
+ in the property mask is set. */
+ void writeStringProperty( OUString& orValue );
+
+ /** Skips the next property clears the respective
+ flag in the property mask. */
+ void skipProperty() { startNextProperty( true ); }
+
+ /** Final processing, write contents of all complex properties, writes record size */
+ void finalizeExport();
+
+private:
+ bool ensureValid();
+ void startNextProperty( bool bSkip = false );
+
+private:
+ /** Base class for complex properties such as string, point, size, GUID, picture. */
+ struct ComplexProperty
+ {
+ virtual ~ComplexProperty();
+ virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) = 0;
+ };
+
+ /** Complex property for a 32-bit value pair, e.g. point or size. */
+ struct PairProperty final : public ComplexProperty
+ {
+ AxPairData& mrPairData;
+
+ explicit PairProperty( AxPairData& rPairData ) :
+ mrPairData( rPairData ) {}
+ virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) override;
+ };
+
+ /** Complex property for a string value. */
+ struct StringProperty final : public ComplexProperty
+ {
+ OUString& mrValue;
+ sal_uInt32 mnSize;
+
+ explicit StringProperty( OUString& rValue, sal_uInt32 nSize ) :
+ mrValue( rValue ), mnSize( nSize ) {}
+ virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) override;
+ };
+
+ /** Stream property for a picture or mouse icon. */
+ struct PictureProperty final : public ComplexProperty
+ {
+ virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) override;
+ };
+
+ typedef RefVector< ComplexProperty > ComplexPropVector;
+
+private:
+ AxAlignedOutputStream maOutStrm; ///< The input stream to read from.
+ ComplexPropVector maLargeProps; ///< Stores info for all used large properties.
+ ComplexPropVector maStreamProps; ///< Stores info for all used stream data properties.
+ sal_Int16 mnBlockSize;
+ sal_Int64 mnPropFlagsStart; ///< pos of Prop flags
+ sal_Int64 mnPropFlags; ///< Flags specifying existing properties.
+ sal_Int64 mnNextProp; ///< Next property to read.
+ bool mbValid; ///< True = stream still valid.
+ bool mb64BitPropFlags;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/axcontrol.hxx b/include/oox/ole/axcontrol.hxx
new file mode 100644
index 000000000..f4fd7b6a7
--- /dev/null
+++ b/include/oox/ole/axcontrol.hxx
@@ -0,0 +1,993 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_AXCONTROL_HXX
+#define INCLUDED_OOX_OLE_AXCONTROL_HXX
+
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/propertyset.hxx>
+#include <oox/ole/axbinaryreader.hxx>
+#include <oox/ole/axfontdata.hxx>
+#include <oox/ole/olehelper.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace awt { class XControlModel; }
+ namespace container { class XIndexContainer; }
+ namespace drawing { class XDrawPage; }
+ namespace frame { class XModel; }
+ namespace form { class XFormsSupplier; }
+ namespace lang { class XMultiServiceFactory; }
+}
+
+namespace oox {
+ class BinaryInputStream;
+ class BinaryOutputStream;
+ class GraphicHelper;
+ class PropertyMap;
+}
+
+namespace oox::ole {
+
+
+#define COMCTL_GUID_SCROLLBAR_60 "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"
+#define COMCTL_GUID_PROGRESSBAR_50 "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"
+#define COMCTL_GUID_PROGRESSBAR_60 "{35053A22-8589-11D1-B16A-00C0F0283628}"
+
+const sal_uInt16 COMCTL_VERSION_50 = 5;
+const sal_uInt16 COMCTL_VERSION_60 = 6;
+
+
+#define AX_GUID_COMMANDBUTTON "{D7053240-CE69-11CD-a777-00dd01143c57}"
+#define AX_GUID_LABEL "{978C9E23-D4B0-11CE-bf2d-00aa003f40d0}"
+#define AX_GUID_IMAGE "{4C599241-6926-101B-9992-00000b65c6f9}"
+#define AX_GUID_TOGGLEBUTTON "{8BD21D60-EC42-11CE-9e0d-00aa006002f3}"
+#define AX_GUID_CHECKBOX "{8BD21D40-EC42-11CE-9e0d-00aa006002f3}"
+#define AX_GUID_OPTIONBUTTON "{8BD21D50-EC42-11CE-9e0d-00aa006002f3}"
+#define AX_GUID_TEXTBOX "{8BD21D10-EC42-11CE-9e0d-00aa006002f3}"
+#define AX_GUID_LISTBOX "{8BD21D20-EC42-11CE-9e0d-00aa006002f3}"
+#define AX_GUID_COMBOBOX "{8BD21D30-EC42-11CE-9e0d-00aa006002f3}"
+#define AX_GUID_SPINBUTTON "{79176FB0-B7F2-11CE-97ef-00aa006d2776}"
+#define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-a449-00aa004a803d}"
+#define AX_GUID_FRAME "{6E182020-F460-11CE-9bcd-00aa00608e01}"
+
+// Html control GUID(s)
+
+#define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8d67-00aa00bdce1d}"
+#define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8d67-00aa00bdce1d}"
+
+const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005;
+const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006;
+const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008;
+const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F;
+const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012;
+
+const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002;
+const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004;
+const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008;
+const sal_uInt32 AX_FLAGS_COLUMNHEADS = 0x00000400;
+const sal_uInt32 AX_FLAGS_ENTIREROWS = 0x00000800;
+const sal_uInt32 AX_FLAGS_EXISTINGENTRIES = 0x00001000;
+const sal_uInt32 AX_FLAGS_CAPTIONLEFT = 0x00002000;
+const sal_uInt32 AX_FLAGS_EDITABLE = 0x00004000;
+const sal_uInt32 AX_FLAGS_IMEMODE_MASK = 0x00078000;
+const sal_uInt32 AX_FLAGS_DRAGENABLED = 0x00080000;
+const sal_uInt32 AX_FLAGS_ENTERASNEWLINE = 0x00100000;
+const sal_uInt32 AX_FLAGS_KEEPSELECTION = 0x00200000;
+const sal_uInt32 AX_FLAGS_TABASCHARACTER = 0x00400000;
+const sal_uInt32 AX_FLAGS_WORDWRAP = 0x00800000;
+const sal_uInt32 AX_FLAGS_BORDERSSUPPRESSED = 0x02000000;
+const sal_uInt32 AX_FLAGS_SELECTLINE = 0x04000000;
+const sal_uInt32 AX_FLAGS_SINGLECHARSELECT = 0x08000000;
+const sal_uInt32 AX_FLAGS_AUTOSIZE = 0x10000000;
+const sal_uInt32 AX_FLAGS_HIDESELECTION = 0x20000000;
+const sal_uInt32 AX_FLAGS_MAXLENAUTOTAB = 0x40000000;
+const sal_uInt32 AX_FLAGS_MULTILINE = 0x80000000;
+
+const sal_Int32 AX_BORDERSTYLE_NONE = 0;
+const sal_Int32 AX_BORDERSTYLE_SINGLE = 1;
+
+const sal_Int32 AX_SPECIALEFFECT_FLAT = 0;
+const sal_Int32 AX_SPECIALEFFECT_RAISED = 1;
+const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2;
+const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3;
+const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6;
+
+const sal_Int32 AX_PICSIZE_CLIP = 0;
+const sal_Int32 AX_PICSIZE_STRETCH = 1;
+const sal_Int32 AX_PICSIZE_ZOOM = 3;
+
+const sal_Int32 AX_PICALIGN_TOPLEFT = 0;
+const sal_Int32 AX_PICALIGN_TOPRIGHT = 1;
+const sal_Int32 AX_PICALIGN_CENTER = 2;
+const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3;
+const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4;
+
+const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1;
+const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2;
+const sal_Int32 AX_DISPLAYSTYLE_COMBOBOX = 3;
+const sal_Int32 AX_DISPLAYSTYLE_CHECKBOX = 4;
+const sal_Int32 AX_DISPLAYSTYLE_OPTBUTTON = 5;
+const sal_Int32 AX_DISPLAYSTYLE_TOGGLE = 6;
+const sal_Int32 AX_DISPLAYSTYLE_DROPDOWN = 7;
+
+const sal_Int32 AX_SELECTION_SINGLE = 0;
+const sal_Int32 AX_SELECTION_MULTI = 1;
+const sal_Int32 AX_SELECTION_EXTENDED = 2;
+
+const sal_Int32 AX_SHOWDROPBUTTON_NEVER = 0;
+const sal_Int32 AX_SHOWDROPBUTTON_FOCUS = 1;
+const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS = 2;
+
+const sal_Int32 AX_SCROLLBAR_NONE = 0x00;
+const sal_Int32 AX_SCROLLBAR_HORIZONTAL = 0x01;
+const sal_Int32 AX_SCROLLBAR_VERTICAL = 0x02;
+
+
+/** Enumerates all UNO API control types supported by these filters. */
+enum ApiControlType
+{
+ API_CONTROL_BUTTON,
+ API_CONTROL_FIXEDTEXT,
+ API_CONTROL_IMAGE,
+ API_CONTROL_CHECKBOX,
+ API_CONTROL_RADIOBUTTON,
+ API_CONTROL_EDIT,
+ API_CONTROL_NUMERIC,
+ API_CONTROL_LISTBOX,
+ API_CONTROL_COMBOBOX,
+ API_CONTROL_SPINBUTTON,
+ API_CONTROL_SCROLLBAR,
+ API_CONTROL_TABSTRIP, //11
+ API_CONTROL_PROGRESSBAR,
+ API_CONTROL_GROUPBOX,
+ API_CONTROL_FRAME, // 14
+ API_CONTROL_PAGE, // 15
+ API_CONTROL_MULTIPAGE, // 16
+ API_CONTROL_DIALOG // 17
+};
+
+
+/** Specifies how a form control supports transparent background. */
+enum class ApiTransparencyMode
+{
+ NotSupported, ///< Control does not support transparency.
+ Void, ///< Transparency is enabled by missing fill color.
+};
+
+/** Specifies how a form control supports the DefaultState property. */
+enum ApiDefaultStateMode
+{
+ API_DEFAULTSTATE_BOOLEAN, ///< Control does not support tri-state, state is given as boolean.
+ API_DEFAULTSTATE_SHORT, ///< Control does not support tri-state, state is given as short.
+ API_DEFAULTSTATE_TRISTATE ///< Control supports tri-state, state is given as short.
+};
+
+
+/** A base class with useful helper functions for something that is able to
+ convert ActiveX and ComCtl form controls.
+ */
+class OOX_DLLPUBLIC ControlConverter final
+{
+public:
+ explicit ControlConverter(
+ const css::uno::Reference< css::frame::XModel >& rxDocModel,
+ const GraphicHelper& rGraphicHelper,
+ bool bDefaultColorBgr = true );
+ ~ControlConverter();
+
+ // Generic conversion -----------------------------------------------------
+
+ /** Converts the passed position in 1/100 mm to UNO properties. */
+ void convertPosition(
+ PropertyMap& rPropMap,
+ const AxPairData& rPos ) const;
+
+ /** Converts the passed size in 1/100 mm to UNO properties. */
+ void convertSize(
+ PropertyMap& rPropMap,
+ const AxPairData& rSize ) const;
+
+ /** Converts the passed encoded OLE color to UNO properties. */
+ void convertColor(
+ PropertyMap& rPropMap,
+ sal_Int32 nPropId,
+ sal_uInt32 nOleColor ) const;
+
+ static void convertToMSColor(
+ PropertySet const & rPropSet,
+ sal_Int32 nPropId,
+ sal_uInt32& nOleColor,
+ sal_uInt32 nDefault = 0 );
+
+
+ /** Converts the passed StdPic picture stream to UNO properties. */
+ void convertPicture(
+ PropertyMap& rPropMap,
+ const StreamDataSequence& rPicData ) const;
+
+ /** Converts the control orientation to UNO properties. */
+ static void convertOrientation(
+ PropertyMap& rPropMap,
+ bool bHorizontal );
+
+ static void convertToMSOrientation(
+ PropertySet const & rPropMap,
+ bool& bHorizontal );
+
+ /** Converts the vertical alignment to UNO properties. */
+ static void convertVerticalAlign(
+ PropertyMap& rPropMap,
+ sal_Int32 nVerticalAlign );
+
+ /** Converts common scrollbar settings to UNO properties. */
+ static void convertScrollBar(
+ PropertyMap& rPropMap,
+ sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
+ sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel );
+
+ /** Converts scrollability settings to UNO properties. */
+ void convertScrollabilitySettings(
+ PropertyMap& rPropMap,
+ const AxPairData& rScrollPos, const AxPairData& rScrollArea,
+ sal_Int32 nScrollBars ) const;
+
+ /** Binds the passed control model to the passed data sources. The
+ implementation will check which source types are supported. */
+ void bindToSources(
+ const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
+ const OUString& rCtrlSource,
+ const OUString& rRowSource,
+ sal_Int32 nRefSheet = 0 ) const;
+
+ // ActiveX (Forms 2.0) specific conversion --------------------------------
+
+ /** Converts the Forms 2.0 background formatting to UNO properties. */
+ void convertAxBackground(
+ PropertyMap& rPropMap,
+ sal_uInt32 nBackColor,
+ sal_uInt32 nFlags,
+ ApiTransparencyMode eTranspMode ) const;
+
+ /** Converts the Forms 2.0 border formatting to UNO properties. */
+ void convertAxBorder(
+ PropertyMap& rPropMap,
+ sal_uInt32 nBorderColor,
+ sal_Int32 nBorderStyle,
+ sal_Int32 nSpecialEffect ) const;
+
+ static void convertToAxBorder(
+ PropertySet const & rPropSet,
+ sal_uInt32& nBorderColor,
+ sal_Int32& nBorderStyle,
+ sal_Int32& nSpecialEffect );
+
+ /** Converts the Forms 2.0 special effect to UNO properties. */
+ static void convertAxVisualEffect(
+ PropertyMap& rPropMap,
+ sal_Int32 nSpecialEffect );
+
+ static void convertToAxVisualEffect(
+ PropertySet const & rPropSet,
+ sal_Int32& nSpecialEffect );
+
+ /** Converts the passed picture stream and Forms 2.0 position to UNO
+ properties. */
+ void convertAxPicture(
+ PropertyMap& rPropMap,
+ const StreamDataSequence& rPicData,
+ sal_uInt32 nPicPos ) const;
+
+ /** Converts the passed picture stream and Forms 2.0 position to UNO
+ properties. */
+ void convertAxPicture(
+ PropertyMap& rPropMap,
+ const StreamDataSequence& rPicData,
+ sal_Int32 nPicSizeMode ) const;
+
+ /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
+ properties. */
+ static void convertAxState(
+ PropertyMap& rPropMap,
+ const OUString& rValue,
+ sal_Int32 nMultiSelect,
+ ApiDefaultStateMode eDefStateMode,
+ bool bAwtModel );
+
+ static void convertToAxState(
+ PropertySet const & rPropSet,
+ OUString& rValue,
+ sal_Int32& nMultiSelect,
+ ApiDefaultStateMode eDefStateMode );
+
+ /** Converts the Forms 2.0 control orientation to UNO properties. */
+ static void convertAxOrientation(
+ PropertyMap& rPropMap,
+ const AxPairData& rSize,
+ sal_Int32 nOrientation );
+
+ static void convertToAxOrientation(
+ PropertySet const & rPropSet,
+ sal_Int32& nOrientation );
+
+private:
+ css::uno::Reference< css::frame::XModel > mxDocModel;
+ const GraphicHelper& mrGraphicHelper;
+ mutable PropertySet maAddressConverter;
+ mutable PropertySet maRangeConverter;
+ bool mbDefaultColorBgr;
+};
+
+
+/** Base class for all models of form controls. */
+class OOX_DLLPUBLIC ControlModelBase
+{
+public:
+ explicit ControlModelBase();
+ virtual ~ControlModelBase();
+
+ /** Sets this control model to AWT model mode. */
+ void setAwtModelMode() { mbAwtModel = true; }
+ /** Sets this control model to form component mode. */
+ void setFormComponentMode() { mbAwtModel = false; }
+
+ /** Returns the UNO service name used to construct the AWT control model,
+ or the control form component. */
+ OUString getServiceName() const;
+
+ /** Derived classes set specific OOXML properties at the model structure. */
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue );
+ /** Derived classes set binary data (picture, mouse icon) at the model structure. */
+ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
+ /** Derived classes import a form control model from the passed input stream. */
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0;
+ /** Derived classes export a form control model to the passed output stream. */
+ virtual void exportBinaryModel( BinaryOutputStream& /*rOutStrm*/ ) {}
+ /** Derived classes export CompObjStream contents. */
+ virtual void exportCompObj( BinaryOutputStream& /*rOutStrm*/ ) {}
+ /** Derived classes return the UNO control type enum value. */
+ virtual ApiControlType getControlType() const = 0;
+ /** Derived classes convert all control properties. */
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
+ /** Derived classes convert from uno control properties to equiv. MS values. */
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
+
+ /** Converts the control size to UNO properties. */
+ void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
+
+public: // direct access needed for legacy VML drawing controls
+ AxPairData maSize; ///< Size of the control in 1/100 mm.
+
+protected:
+ bool mbAwtModel; ///< True = AWT control model, false = form component.
+};
+
+typedef std::shared_ptr< ControlModelBase > ControlModelRef;
+
+
+/** Base class for all models of ComCtl form controls. */
+class ComCtlModelBase : public ControlModelBase
+{
+public:
+ explicit ComCtlModelBase(
+ sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion );
+
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+
+protected:
+ virtual void importControlData( BinaryInputStream& rInStrm ) = 0;
+
+private:
+ /** Returns the data part identifier according to the model version. */
+ sal_uInt32 getDataPartId() const;
+
+ static bool readPartHeader( BinaryInputStream& rInStrm,
+ sal_uInt32 nExpPartId,
+ sal_uInt16 nExpMajor = SAL_MAX_UINT16,
+ sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
+
+ bool importSizePart( BinaryInputStream& rInStrm );
+ bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize );
+ bool importComplexPart( BinaryInputStream& rInStrm );
+
+protected:
+ StdFontInfo maFontData; ///< Font formatting.
+ StreamDataSequence maMouseIcon; ///< Binary picture stream for mouse icon.
+ sal_uInt32 mnFlags; ///< Common flags for ComCtl controls.
+ const sal_uInt16 mnVersion; ///< Current version of the ComCtl control model.
+
+private:
+ sal_uInt32 mnDataPartId5; ///< Identifier for version 5.0 control data.
+ sal_uInt32 mnDataPartId6; ///< Identifier for version 6.0 control data.
+ bool mbCommonPart; ///< True = the COMCTL_COMMONDATA part exists.
+ bool mbComplexPart; ///< True = the COMCTL_COMPLEXDATA part exists.
+};
+
+
+/** Model for a ComCtl scroll bar. */
+class ComCtlScrollBarModel final : public ComCtlModelBase
+{
+public:
+ explicit ComCtlScrollBarModel( sal_uInt16 nVersion );
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+
+private:
+ virtual void importControlData( BinaryInputStream& rInStrm ) override;
+
+ sal_uInt32 mnScrollBarFlags; ///< Special flags for scroll bar model.
+ sal_Int32 mnLargeChange; ///< Increment step size (thumb).
+ sal_Int32 mnSmallChange; ///< Increment step size (buttons).
+ sal_Int32 mnMin; ///< Minimum of the value range.
+ sal_Int32 mnMax; ///< Maximum of the value range.
+ sal_Int32 mnPosition; ///< Value of the spin button.
+};
+
+
+/** Model for a ComCtl progress bar. */
+class ComCtlProgressBarModel final : public ComCtlModelBase
+{
+public:
+ explicit ComCtlProgressBarModel( sal_uInt16 nVersion );
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+
+private:
+ virtual void importControlData( BinaryInputStream& rInStrm ) override;
+
+ float mfMin; ///< Minimum of the value range.
+ float mfMax; ///< Maximum of the value range.
+ sal_uInt16 mnVertical; ///< 0 = horizontal, 1 = vertical.
+ sal_uInt16 mnSmooth; ///< 0 = progress blocks, 1 = pixel resolution.
+};
+
+
+/** Base class for all models of Form 2.0 form controls. */
+class OOX_DLLPUBLIC AxControlModelBase : public ControlModelBase
+{
+public:
+ explicit AxControlModelBase();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+};
+
+
+/** Base class for Forms 2.0 controls supporting text formatting. */
+class OOX_DLLPUBLIC AxFontDataModel : public AxControlModelBase
+{
+public:
+ explicit AxFontDataModel( bool bSupportsAlign = true );
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+
+ /** Returns the font height in points. */
+ sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); }
+
+public: // direct access needed for legacy VML drawing controls
+ AxFontData maFontData; ///< The font settings.
+
+private:
+ bool mbSupportsAlign; ///< True = UNO model supports Align property.
+};
+
+
+/** Model for a Forms 2.0 command button. */
+class OOX_DLLPUBLIC AxCommandButtonModel final : public AxFontDataModel
+{
+public:
+ explicit AxCommandButtonModel();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+
+public: // direct access needed for legacy VML drawing controls
+ StreamDataSequence maPictureData; ///< Binary picture stream.
+ OUString maCaption; ///< Visible caption of the button.
+ sal_uInt32 mnTextColor; ///< Text color.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
+ sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
+ bool mbFocusOnClick; ///< True = take focus on click.
+};
+
+
+/** Model for a Forms 2.0 label. */
+class OOX_DLLPUBLIC AxLabelModel final : public AxFontDataModel
+{
+public:
+ explicit AxLabelModel();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+
+public: // direct access needed for legacy VML drawing controls
+ OUString maCaption; ///< Visible caption of the button.
+ sal_uInt32 mnTextColor; ///< Text color.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_uInt32 mnBorderColor; ///< Flat border color.
+ sal_Int32 mnBorderStyle; ///< Flat border style.
+ sal_Int32 mnSpecialEffect; ///< 3D border effect.
+ sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
+};
+
+
+/** Model for a Forms 2.0 image. */
+class OOX_DLLPUBLIC AxImageModel final : public AxControlModelBase
+{
+public:
+ explicit AxImageModel();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+
+private:
+ StreamDataSequence maPictureData; ///< Binary picture stream.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_uInt32 mnBorderColor; ///< Flat border color.
+ sal_Int32 mnBorderStyle; ///< Flat border style.
+ sal_Int32 mnSpecialEffect; ///< 3D border effect.
+ sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
+ sal_Int32 mnPicAlign; ///< Anchor position of the picture.
+ bool mbPicTiling; ///< True = picture is repeated.
+};
+
+class OOX_DLLPUBLIC AxTabStripModel final : public AxFontDataModel
+{
+public:
+ explicit AxTabStripModel();
+
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+
+ virtual ApiControlType getControlType() const override;
+
+public:
+ sal_uInt32 mnListIndex;
+ sal_uInt32 mnTabStyle;
+ sal_uInt32 mnTabData;
+ sal_uInt32 mnVariousPropertyBits;
+ std::vector< OUString > maItems; // captions for each tab
+ std::vector< OUString > maTabNames; // names for each tab
+};
+
+
+/** Base class for a Forms 2.0 morph data control. */
+class OOX_DLLPUBLIC AxMorphDataModelBase : public AxFontDataModel
+{
+public:
+ explicit AxMorphDataModelBase();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+
+public: // direct access needed for legacy VML drawing controls
+ StreamDataSequence maPictureData; ///< Binary picture stream.
+ OUString maCaption; ///< Visible caption of the button.
+ OUString maValue; ///< Current value of the control.
+ OUString maGroupName; ///< Group name for option buttons.
+ sal_uInt32 mnTextColor; ///< Text color.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
+ sal_uInt32 mnBorderColor; ///< Flat border color.
+ sal_Int32 mnBorderStyle; ///< Flat border style.
+ sal_Int32 mnSpecialEffect; ///< 3D border effect.
+ sal_Int32 mnDisplayStyle; ///< Type of the morph control.
+ sal_Int32 mnMultiSelect; ///< Selection mode.
+ sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
+ sal_Int32 mnMatchEntry; ///< Auto completion mode.
+ sal_Int32 mnShowDropButton; ///< When to show the dropdown button.
+ sal_Int32 mnMaxLength; ///< Maximum character count.
+ sal_Int32 mnPasswordChar; ///< Password character in edit fields.
+ sal_Int32 mnListRows; ///< Number of rows in dropdown box.
+ sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
+};
+
+
+/** Model for a Forms 2.0 toggle button. */
+class OOX_DLLPUBLIC AxToggleButtonModel final : public AxMorphDataModelBase
+{
+public:
+ explicit AxToggleButtonModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a Forms 2.0 check box. */
+class OOX_DLLPUBLIC AxCheckBoxModel final : public AxMorphDataModelBase
+{
+public:
+ explicit AxCheckBoxModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a Forms 2.0 option button. */
+class OOX_DLLPUBLIC AxOptionButtonModel final : public AxMorphDataModelBase
+{
+public:
+ explicit AxOptionButtonModel();
+
+ /** Returns the group name used to goup several option buttons together. */
+ const OUString& getGroupName() const { return maGroupName; }
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a Forms 2.0 text box. */
+class OOX_DLLPUBLIC AxTextBoxModel : public AxMorphDataModelBase
+{
+public:
+ explicit AxTextBoxModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a numeric field (legacy drawing controls only). */
+class OOX_DLLPUBLIC AxNumericFieldModel final : public AxMorphDataModelBase
+{
+public:
+ explicit AxNumericFieldModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a Forms 2.0 list box. */
+class OOX_DLLPUBLIC AxListBoxModel : public AxMorphDataModelBase
+{
+public:
+ explicit AxListBoxModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a Forms 2.0 combo box. */
+class OOX_DLLPUBLIC AxComboBoxModel final : public AxMorphDataModelBase
+{
+public:
+ explicit AxComboBoxModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+};
+
+
+/** Model for a Forms 2.0 spin button. */
+class OOX_DLLPUBLIC AxSpinButtonModel final : public AxControlModelBase
+{
+public:
+ explicit AxSpinButtonModel();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+
+public: // direct access needed for legacy VML drawing controls
+ sal_uInt32 mnArrowColor; ///< Button arrow color.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_Int32 mnOrientation; ///< Orientation of the buttons.
+ sal_Int32 mnMin; ///< Minimum of the value range.
+ sal_Int32 mnMax; ///< Maximum of the value range.
+ sal_Int32 mnPosition; ///< Value of the spin button.
+ sal_Int32 mnSmallChange; ///< Increment step size.
+ sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
+};
+
+
+/** Model for a Forms 2.0 scroll bar. */
+class OOX_DLLPUBLIC AxScrollBarModel final : public AxControlModelBase
+{
+public:
+ explicit AxScrollBarModel();
+
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
+ virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
+
+public: // direct access needed for legacy VML drawing controls
+ sal_uInt32 mnArrowColor; ///< Button arrow color.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_Int32 mnOrientation; ///< Orientation of the buttons.
+ sal_Int32 mnPropThumb; ///< Proportional thumb size.
+ sal_Int32 mnMin; ///< Minimum of the value range.
+ sal_Int32 mnMax; ///< Maximum of the value range.
+ sal_Int32 mnPosition; ///< Value of the spin button.
+ sal_Int32 mnSmallChange; ///< Increment step size (buttons).
+ sal_Int32 mnLargeChange; ///< Increment step size (thumb).
+ sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
+};
+
+
+typedef ::std::vector< OUString > AxClassTable;
+
+/** Base class for ActiveX container controls. */
+class OOX_DLLPUBLIC AxContainerModelBase : public AxFontDataModel
+{
+public:
+ explicit AxContainerModelBase( bool bFontSupport = false );
+
+ /** Allows to set single properties specified by XML token identifier. */
+ virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
+ /** Reads the leading structure in the 'f' stream containing the model for
+ this control. */
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ /** Converts font settings if supported. */
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+
+ /** Reads the class table structure for embedded controls following the own
+ model from the 'f' stream. */
+ bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable );
+
+public: // direct access needed for legacy VML drawing controls
+ StreamDataSequence maPictureData; ///< Binary picture stream.
+ OUString maCaption; ///< Visible caption of the form.
+ AxPairData maLogicalSize; ///< Logical form size (scroll area).
+ AxPairData maScrollPos; ///< Scroll position.
+ sal_uInt32 mnBackColor; ///< Fill color.
+ sal_uInt32 mnTextColor; ///< Text color.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_uInt32 mnBorderColor; ///< Flat border color.
+ sal_Int32 mnBorderStyle; ///< Flat border style.
+ sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
+ sal_Int32 mnCycleType; ///< Cycle in all forms or in this form.
+ sal_Int32 mnSpecialEffect; ///< 3D border effect.
+ sal_Int32 mnPicAlign; ///< Anchor position of the picture.
+ sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
+ bool mbPicTiling; ///< True = picture is repeated.
+ bool mbFontSupport; ///< True = control supports the font property.
+};
+
+
+/** Model for a Forms 2.0 frame control. */
+class OOX_DLLPUBLIC AxFrameModel final : public AxContainerModelBase
+{
+public:
+ explicit AxFrameModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+};
+
+class OOX_DLLPUBLIC AxPageModel final : public AxContainerModelBase
+{
+public:
+ explicit AxPageModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+};
+
+class OOX_DLLPUBLIC AxMultiPageModel final : public AxContainerModelBase
+{
+public:
+ explicit AxMultiPageModel();
+
+ virtual ApiControlType getControlType() const override;
+ void importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages );
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+ std::vector<sal_uInt32> mnIDs;
+ sal_uInt32 mnActiveTab;
+ sal_uInt32 mnTabStyle;
+};
+
+
+/** Model for a Forms 2.0 user form. */
+class OOX_DLLPUBLIC AxUserFormModel final : public AxContainerModelBase
+{
+public:
+ explicit AxUserFormModel();
+
+ virtual ApiControlType getControlType() const override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+};
+
+class HtmlSelectModel final : public AxListBoxModel
+{
+ css::uno::Sequence< OUString > msListData;
+ css::uno::Sequence< sal_Int16 > msIndices;
+public:
+ HtmlSelectModel();
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+ virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
+};
+
+class HtmlTextBoxModel final : public AxTextBoxModel
+{
+public:
+ explicit HtmlTextBoxModel();
+ virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
+};
+
+
+/** A form control embedded in a document draw page. Contains a specific model
+ structure according to the type of the control. */
+class OOX_DLLPUBLIC EmbeddedControl
+{
+public:
+ explicit EmbeddedControl( const OUString& rName );
+
+ /** Creates and returns the internal control model of the specified type. */
+ template< typename ModelType >
+ inline ModelType& createModel();
+
+ /** Creates and returns the internal control model of the specified type. */
+ template< typename ModelType, typename ParamType >
+ inline ModelType& createModel( const ParamType& rParam );
+
+ /** Creates and returns the internal control model according to the passed
+ MS class identifier. */
+ ControlModelBase* createModelFromGuid( std::u16string_view rClassId );
+
+ /** Returns true, if the internal control model exists. */
+ bool hasModel() const { return bool(mxModel); }
+ /** Returns read-only access to the internal control model. */
+ const ControlModelBase* getModel() const { return mxModel.get(); }
+ /** Returns read/write access to the internal control model. */
+ ControlModelBase* getModel() { return mxModel.get(); }
+
+ /** Returns the UNO service name needed to construct the control model. */
+ OUString getServiceName() const;
+
+ /** Converts all control properties and inserts them into the passed model. */
+ bool convertProperties(
+ const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
+ const ControlConverter& rConv ) const;
+
+ void convertFromProperties(
+ const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
+ const ControlConverter& rConv );
+
+private:
+ ControlModelRef mxModel; ///< Control model containing the properties.
+ OUString maName; ///< Name of the control.
+};
+
+
+template< typename ModelType >
+inline ModelType& EmbeddedControl::createModel()
+{
+ auto xModel = std::make_shared<ModelType>();
+ mxModel = xModel;
+ xModel->setFormComponentMode();
+ return *xModel;
+}
+
+template< typename ModelType, typename ParamType >
+inline ModelType& EmbeddedControl::createModel( const ParamType& rParam )
+{
+ auto xModel = std::make_shared<ModelType>( rParam );
+ mxModel = xModel;
+ xModel->setFormComponentMode();
+ return *xModel;
+}
+
+
+/** A wrapper for a control form embedded directly in a draw page. */
+class EmbeddedForm
+{
+public:
+ explicit EmbeddedForm(
+ const css::uno::Reference< css::frame::XModel >& rxDocModel,
+ const css::uno::Reference< css::drawing::XDrawPage >& rxDrawPage,
+ const GraphicHelper& rGraphicHelper );
+
+ /** Converts the passed control and inserts the control model into the form.
+ @return The API control model, if conversion was successful. */
+ css::uno::Reference< css::awt::XControlModel >
+ convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex );
+
+ /** Returns the XIndexContainer interface of the UNO control form, if existing. */
+ const css::uno::Reference< css::container::XIndexContainer >&
+ getXForm() const { return mxFormIC; }
+
+private:
+ /** Creates the form that will hold the form controls. */
+ css::uno::Reference< css::container::XIndexContainer > const &
+ createXForm();
+
+private:
+ ControlConverter maControlConv;
+ css::uno::Reference< css::lang::XMultiServiceFactory > mxModelFactory;
+ css::uno::Reference< css::form::XFormsSupplier > mxFormsSupp;
+ css::uno::Reference< css::container::XIndexContainer > mxFormIC;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/axcontrolfragment.hxx b/include/oox/ole/axcontrolfragment.hxx
new file mode 100644
index 000000000..e6b87b416
--- /dev/null
+++ b/include/oox/ole/axcontrolfragment.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_AXCONTROLFRAGMENT_HXX
+#define INCLUDED_OOX_OLE_AXCONTROLFRAGMENT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/contexthandler2.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::ole {
+
+class ControlModelBase;
+class EmbeddedControl;
+
+
+/** Context handler for ActiveX form control model properties. */
+class AxControlPropertyContext final : public ::oox::core::ContextHandler2
+{
+public:
+ explicit AxControlPropertyContext(
+ ::oox::core::FragmentHandler2 const & rFragment,
+ ControlModelBase& rModel );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ ControlModelBase& mrModel;
+ sal_Int32 mnPropId; ///< Identifier of currently processed property.
+};
+
+
+/** Fragment handler for an embedded ActiveX form control fragment. */
+class AxControlFragment final : public ::oox::core::FragmentHandler2
+{
+public:
+ explicit AxControlFragment(
+ ::oox::core::XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ EmbeddedControl& rControl );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ EmbeddedControl& mrControl;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/axfontdata.hxx b/include/oox/ole/axfontdata.hxx
new file mode 100644
index 000000000..df3503247
--- /dev/null
+++ b/include/oox/ole/axfontdata.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_AXFONTDATA_HXX
+#define INCLUDED_OOX_OLE_AXFONTDATA_HXX
+
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <o3tl/typed_flags_set.hxx>
+
+namespace oox {
+ class BinaryInputStream;
+ class BinaryOutputStream;
+}
+
+enum class AxFontFlags {
+ NONE = 0x00000000,
+ Bold = 0x00000001,
+ Italic = 0x00000002,
+ Underline = 0x00000004,
+ Strikeout = 0x00000008,
+ Disabled = 0x00002000,
+ AutoColor = 0x40000000,
+};
+namespace o3tl {
+ template<> struct typed_flags<AxFontFlags> : is_typed_flags<AxFontFlags, 0x4000200f> {};
+}
+
+namespace oox::ole {
+
+enum class AxHorizontalAlign {
+ Left = 1, Right = 2, Center = 3
+};
+
+/** All entries of a font property. */
+struct OOX_DLLPUBLIC AxFontData
+{
+ OUString maFontName; ///< Name of the used font.
+ AxFontFlags mnFontEffects; ///< Font effect flags.
+ sal_Int32 mnFontHeight; ///< Height of the font (not really twips, see code).
+ sal_Int32 mnFontCharSet; ///< Windows character set of the font.
+ AxHorizontalAlign mnHorAlign; ///< Horizontal text alignment.
+ bool mbDblUnderline; ///< True = double underline style (legacy VML drawing controls only).
+
+ explicit AxFontData();
+
+ /** Converts the internal representation of the font height to points. */
+ sal_Int16 getHeightPoints() const;
+ /** Converts the passed font height from points to the internal representation. */
+ void setHeightPoints( sal_Int16 nPoints );
+
+ /** Reads the font data settings from the passed input stream. */
+ bool importBinaryModel( BinaryInputStream& rInStrm );
+
+ void exportBinaryModel( BinaryOutputStream& rOutStrm );
+ /** Reads the font data settings from the passed input stream that contains
+ an OLE StdFont structure. */
+ bool importStdFont( BinaryInputStream& rInStrm );
+ /** Reads the font data settings from the passed input stream depending on
+ the GUID preceding the actual font data. */
+ bool importGuidAndFont( BinaryInputStream& rInStrm );
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/olehelper.hxx b/include/oox/ole/olehelper.hxx
new file mode 100644
index 000000000..e01e60257
--- /dev/null
+++ b/include/oox/ole/olehelper.hxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_OLEHELPER_HXX
+#define INCLUDED_OOX_OLE_OLEHELPER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <filter/msfilter/msocximex.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <oox/helper/graphichelper.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <tools/ref.hxx>
+#include <memory>
+
+namespace com::sun::star {
+ namespace awt { class XControlModel; }
+ namespace awt { struct Size; }
+ namespace form { class XFormComponent; }
+ namespace frame { class XModel; }
+ namespace io { class XOutputStream; }
+ namespace uno { class XComponentContext; }
+}
+
+class SotStorage;
+class SotStorageStream;
+class SvGlobalName;
+
+namespace oox {
+ class BinaryInputStream;
+ class BinaryOutputStream;
+}
+
+namespace oox::ole {
+ class ControlModelBase;
+ class EmbeddedControl;
+
+
+#define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"
+#define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"
+
+
+const sal_uInt16 OLE_STDFONT_NORMAL = 400;
+const sal_uInt16 OLE_STDFONT_BOLD = 700;
+
+const sal_uInt8 OLE_STDFONT_ITALIC = 0x02;
+const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04;
+const sal_uInt8 OLE_STDFONT_STRIKE = 0x08;
+
+/** Stores data about a StdFont font structure. */
+struct StdFontInfo
+{
+ OUString maName; ///< Font name.
+ sal_uInt32 mnHeight; ///< Font height (1/10,000 points).
+ sal_uInt16 mnWeight; ///< Font weight (normal/bold).
+ sal_uInt16 mnCharSet; ///< Font charset.
+ sal_uInt8 mnFlags; ///< Font flags.
+
+ explicit StdFontInfo();
+ explicit StdFontInfo(
+ const OUString& rName,
+ sal_uInt32 nHeight );
+};
+
+
+/** Stores data about a StdHlink hyperlink. */
+struct StdHlinkInfo
+{
+ OUString maTarget;
+ OUString maLocation;
+ OUString maDisplay;
+};
+
+
+/** Static helper functions for OLE import/export. */
+namespace OleHelper
+{
+ /** Returns the UNO RGB color from the passed encoded OLE color.
+
+ @param bDefaultColorBgr
+ True = OLE default color type is treated as BGR color.
+ False = OLE default color type is treated as palette color.
+ */
+ OOX_DLLPUBLIC ::Color decodeOleColor(
+ const GraphicHelper& rGraphicHelper,
+ sal_uInt32 nOleColor,
+ bool bDefaultColorBgr );
+
+ /** Returns the OLE color from the passed UNO RGB color.
+ */
+ OOX_DLLPUBLIC sal_uInt32 encodeOleColor( sal_Int32 nRgbColor );
+ inline sal_uInt32 encodeOleColor( Color nRgbColor ) { return encodeOleColor(sal_Int32(nRgbColor)); }
+
+ /** Imports a GUID from the passed binary stream and returns its string
+ representation (in uppercase characters).
+ */
+ OOX_DLLPUBLIC OUString importGuid( BinaryInputStream& rInStrm );
+ OOX_DLLPUBLIC void exportGuid( BinaryOutputStream& rOutStrm, const SvGlobalName& rId );
+
+ /** Imports an OLE StdFont font structure from the current position of the
+ passed binary stream.
+ */
+ OOX_DLLPUBLIC bool importStdFont(
+ StdFontInfo& orFontInfo,
+ BinaryInputStream& rInStrm,
+ bool bWithGuid );
+
+ /** Imports an OLE StdPic picture from the current position of the passed
+ binary stream.
+ */
+ OOX_DLLPUBLIC bool importStdPic(
+ StreamDataSequence& orGraphicData,
+ BinaryInputStream& rInStrm );
+}
+
+class OOX_DLLPUBLIC OleFormCtrlExportHelper final
+{
+ std::unique_ptr<::oox::ole::EmbeddedControl> mpControl;
+ ::oox::ole::ControlModelBase* mpModel;
+ ::oox::GraphicHelper maGrfHelper;
+ css::uno::Reference< css::frame::XModel > mxDocModel;
+ css::uno::Reference< css::awt::XControlModel > mxControlModel;
+
+ OUString maName;
+ OUString maTypeName;
+ OUString maFullName;
+ OUString maGUID;
+public:
+ OleFormCtrlExportHelper( const css::uno::Reference< css::uno::XComponentContext >& rxCtx, const css::uno::Reference< css::frame::XModel >& xDocModel, const css::uno::Reference< css::awt::XControlModel >& xModel );
+ ~OleFormCtrlExportHelper();
+
+ std::u16string_view getGUID() const
+ {
+ std::u16string_view sResult;
+ if ( maGUID.getLength() > 2 )
+ sResult = maGUID.subView(1, maGUID.getLength() - 2 );
+ return sResult;
+ }
+ const OUString& getFullName() const { return maFullName; }
+ const OUString& getTypeName() const { return maTypeName; }
+ const OUString& getName() const { return maName; }
+ bool isValid() const { return mpModel != nullptr; }
+ void exportName( const css::uno::Reference< css::io::XOutputStream >& rxOut );
+ void exportCompObj( const css::uno::Reference< css::io::XOutputStream >& rxOut );
+ void exportControl( const css::uno::Reference< css::io::XOutputStream >& rxOut, const css::awt::Size& rSize, bool bAutoClose = false );
+};
+
+// ideally it would be great to get rid of SvxMSConvertOCXControls
+// however msfilter/source/msfilter/svdfppt.cxx still uses
+// SvxMSConvertOCXControls as a base class, unfortunately oox depends on
+// msfilter. Probably the solution would be to move the svdfppt.cxx
+// implementation into the sd module itself.
+class OOX_DLLPUBLIC MSConvertOCXControls : public SvxMSConvertOCXControls
+{
+protected:
+ css::uno::Reference< css::uno::XComponentContext > mxCtx;
+ ::oox::GraphicHelper maGrfHelper;
+
+ bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
+ css::uno::Reference< css::form::XFormComponent > & rxFormComp,
+ std::u16string_view rGuidString );
+ bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
+ css::uno::Reference< css::form::XFormComponent > & rxFormComp,
+ const OUString& rGuidString,
+ sal_Int32 nSize );
+public:
+ MSConvertOCXControls( const css::uno::Reference< css::frame::XModel >& rxModel );
+ virtual ~MSConvertOCXControls() override;
+ bool ReadOCXStorage( tools::SvRef<SotStorage> const & rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp );
+ bool ReadOCXCtlsStream(tools::SvRef<SotStorageStream> const & rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp,
+ sal_Int32 nPos, sal_Int32 nSize );
+ static bool WriteOCXStream( const css::uno::Reference< css::frame::XModel >& rxModel, tools::SvRef<SotStorage> const &rSrc1, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size& rSize,OUString &rName);
+ static bool WriteOCXExcelKludgeStream( const css::uno::Reference< css::frame::XModel >& rxModel, const css::uno::Reference< css::io::XOutputStream >& xOutStrm, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size& rSize,OUString &rName);
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/oleobjecthelper.hxx b/include/oox/ole/oleobjecthelper.hxx
new file mode 100644
index 000000000..5b792f204
--- /dev/null
+++ b/include/oox/ole/oleobjecthelper.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_OLEOBJECTHELPER_HXX
+#define INCLUDED_OOX_OLE_OLEOBJECTHELPER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/binarystreambase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace awt { struct Size; }
+ namespace document { class XEmbeddedObjectResolver; }
+ namespace frame { class XModel; }
+ namespace lang { class XMultiServiceFactory; }
+}
+
+namespace oox { class PropertyMap; }
+
+namespace oox::ole {
+
+
+/** Contains generic information about an OLE object. */
+struct OleObjectInfo
+{
+ StreamDataSequence maEmbeddedData; ///< Data of an embedded OLE object.
+ OUString maTargetLink; ///< Path to external data for linked OLE object.
+ OUString maProgId;
+ bool mbLinked; ///< True = linked OLE object, false = embedded OLE object.
+ bool mbShowAsIcon; ///< True = show as icon, false = show contents.
+ bool mbAutoUpdate;
+ bool mbHasPicture; ///<Ole object requires a picture element according to spec.>
+
+ explicit OleObjectInfo();
+};
+
+
+/** Helper for OLE object handling. */
+class OleObjectHelper
+{
+public:
+ explicit OleObjectHelper(
+ const css::uno::Reference<css::lang::XMultiServiceFactory>& rxModelFactory,
+ const css::uno::Reference<css::frame::XModel>& xModel);
+ ~OleObjectHelper();
+
+ bool importOleObject(
+ PropertyMap& rPropMap,
+ const OleObjectInfo& rOleObject,
+ const css::awt::Size& rObjSize );
+
+private:
+ css::uno::Reference<css::frame::XModel> m_xModel;
+ css::uno::Reference< css::document::XEmbeddedObjectResolver > mxResolver;
+ sal_Int32 mnObjectId;
+};
+
+
+OOX_DLLPUBLIC void SaveInteropProperties(
+ css::uno::Reference<css::frame::XModel> const& xModel,
+ OUString const& rObjectName, OUString const* pOldObjectName,
+ OUString const& rProgId);
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/olestorage.hxx b/include/oox/ole/olestorage.hxx
new file mode 100644
index 000000000..b7ac512f1
--- /dev/null
+++ b/include/oox/ole/olestorage.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_OLESTORAGE_HXX
+#define INCLUDED_OOX_OLE_OLESTORAGE_HXX
+
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/storagebase.hxx>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace container { class XNameContainer; }
+ namespace embed { class XStorage; }
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XStream; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox::ole {
+
+
+/** Implements stream access for binary OLE storages. */
+class OOX_DLLPUBLIC OleStorage final : public StorageBase
+{
+public:
+ explicit OleStorage(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStream,
+ bool bBaseStreamAccess );
+
+ explicit OleStorage(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XStream >& rxOutStream,
+ bool bBaseStreamAccess );
+
+ virtual ~OleStorage() override;
+
+private:
+ explicit OleStorage(
+ const OleStorage& rParentStorage,
+ const css::uno::Reference< css::container::XNameContainer >& rxStorage,
+ const OUString& rElementName,
+ bool bReadOnly );
+ explicit OleStorage(
+ const OleStorage& rParentStorage,
+ const css::uno::Reference< css::io::XStream >& rxOutStream,
+ const OUString& rElementName );
+
+ /** Initializes the API storage object for input. */
+ void initStorage( const css::uno::Reference< css::io::XInputStream >& rxInStream );
+ /** Initializes the API storage object for input/output. */
+ void initStorage( const css::uno::Reference< css::io::XStream >& rxOutStream );
+
+ /** Returns true, if the object represents a valid storage. */
+ virtual bool implIsStorage() const override;
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage.
+
+ @attention
+ This function is not implemented for binary OLE storages.
+ */
+ virtual css::uno::Reference< css::embed::XStorage >
+ implGetXStorage() const override;
+
+ /** Returns the names of all elements of this storage. */
+ virtual void implGetElementNames( ::std::vector< OUString >& orElementNames ) const override;
+
+ /** Opens and returns the specified sub storage from the storage. */
+ virtual StorageRef implOpenSubStorage( const OUString& rElementName, bool bCreateMissing ) override;
+
+ /** Opens and returns the specified input stream from the storage. */
+ virtual css::uno::Reference< css::io::XInputStream >
+ implOpenInputStream( const OUString& rElementName ) override;
+
+ /** Opens and returns the specified output stream from the storage. */
+ virtual css::uno::Reference< css::io::XOutputStream >
+ implOpenOutputStream( const OUString& rElementName ) override;
+
+ /** Commits the current storage. */
+ virtual void implCommit() const override;
+
+private:
+ css::uno::Reference< css::uno::XComponentContext >
+ mxContext; ///< Component context with service manager.
+ css::uno::Reference< css::container::XNameContainer >
+ mxStorage; ///< Access to elements of this sub storage.
+ const OleStorage* mpParentStorage; ///< Parent OLE storage that contains this storage.
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/vbacontrol.hxx b/include/oox/ole/vbacontrol.hxx
new file mode 100644
index 000000000..c0afd6ae7
--- /dev/null
+++ b/include/oox/ole/vbacontrol.hxx
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_VBACONTROL_HXX
+#define INCLUDED_OOX_OLE_VBACONTROL_HXX
+
+#include <memory>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/helper/refvector.hxx>
+#include <oox/ole/axbinaryreader.hxx>
+#include <oox/ole/axcontrol.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace awt { class XControlModel; }
+ namespace container { class XNameContainer; }
+ namespace frame { class XModel; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+ class BinaryInputStream;
+ class GraphicHelper;
+ class PropertyMap;
+ class StorageBase;
+}
+
+namespace oox::ole {
+
+
+/** Common properties for all controls that are part of a VBA user form or of
+ another container control in a VBA user form. */
+class VbaSiteModel final
+{
+public:
+ explicit VbaSiteModel();
+ ~VbaSiteModel();
+
+ /** Allows to set single properties specified by XML token identifier. */
+ void importProperty( sal_Int32 nPropId, const OUString& rValue );
+ /** Imports the site model data from the passed input stream. */
+ bool importBinaryModel( BinaryInputStream& rInStrm );
+ /** Moves the control relative to its current position by the passed distance. */
+ void moveRelative( const AxPairData& rDistance );
+
+ /** Returns the programmatical name of the control. */
+ const OUString& getName() const { return maName; }
+ /** Returns the position of the control in its parent. */
+ const AxPairData& getPosition() const { return maPos; }
+ /** Returns the unique identifier of this control. */
+ sal_Int32 getId() const { return mnId; }
+ /** Returns true, if this control is a container control. */
+ bool isContainer() const;
+ /** Returns the length of the stream data for stream based controls. */
+ sal_uInt32 getStreamLength() const;
+ /** Returns the name of the substorage for the container control data. */
+ OUString getSubStorageName() const;
+ /** Returns the tab index of the control. */
+ sal_Int16 getTabIndex() const { return mnTabIndex; }
+
+ /** Tries to create the control model according to the site model. */
+ ControlModelRef createControlModel( const AxClassTable& rClassTable ) const;
+ /** Converts all form site properties. */
+ void convertProperties(
+ PropertyMap& rPropMap,
+ const ControlConverter& rConv,
+ ApiControlType eCtrlType,
+ sal_Int32 nCtrlIndex ) const;
+ const OUString& getControlSource() const { return maControlSource; }
+ const OUString& getRowSource() const { return maRowSource; }
+private:
+ OUString maName; ///< Name of the control.
+ OUString maTag; ///< User defined tag.
+ OUString maToolTip; ///< Tool tip for the control.
+ OUString maControlSource; ///< Linked cell for the control value in a spreadsheet.
+ OUString maRowSource; ///< Source data for the control in a spreadsheet.
+
+ AxPairData maPos; ///< Position in parent container.
+ sal_Int32 mnId; ///< Control identifier.
+ sal_Int32 mnHelpContextId; ///< Help context identifier.
+ sal_uInt32 mnFlags; ///< Various flags.
+ sal_uInt32 mnStreamLen; ///< Size of control stream data.
+ sal_Int16 mnTabIndex; ///< Tab order index.
+ sal_uInt16 mnClassIdOrCache; ///< Class name identifier or GUID cache index.
+ sal_uInt16 mnGroupId; ///< Group identifier for grouped controls.
+};
+
+typedef std::shared_ptr< VbaSiteModel > VbaSiteModelRef;
+
+
+/** A control that is embedded in a VBA user form or in another container
+ control in a VBA user form.
+
+ The control may be a 'simple' control with its data stored in the 'o'
+ stream, or it may be a container control with its data stored in an own
+ substorage.
+ */
+class VbaFormControl
+{
+public:
+ explicit VbaFormControl();
+ virtual ~VbaFormControl();
+
+ /** Imports the model from the passed stream or storage, depending on the
+ control's type. Imports all embedded controls, if this is a container. */
+ void importModelOrStorage(
+ BinaryInputStream& rInStrm,
+ StorageBase& rStrg,
+ const AxClassTable& rClassTable );
+
+ /** Returns the programmatical name of the control. */
+ OUString getControlName() const;
+
+ /** Creates the UNO control model, inserts it into the passed container,
+ and converts all control properties. */
+ void createAndConvert(
+ sal_Int32 nCtrlIndex,
+ const css::uno::Reference< css::container::XNameContainer >& rxParentNC,
+ const ControlConverter& rConv ) const;
+
+protected:
+ /** Creates and imports the control model containing properties of the control. */
+ void importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable );
+ /** Creates and imports the control model, and imports all embedded
+ controls from the passed substorage. */
+ void importStorage( StorageBase& rStrg, const AxClassTable& rClassTable );
+
+ /** Converts all control properties, and inserts and converts embedded controls. */
+ bool convertProperties(
+ const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
+ const ControlConverter& rConv,
+ sal_Int32 nCtrlIndex ) const;
+
+private:
+ typedef RefVector< VbaFormControl > VbaFormControlVector;
+ typedef VbaFormControlVector::value_type VbaFormControlRef;
+
+ /** Creates the control model according to the current site model. */
+ void createControlModel( const AxClassTable& rClassTable );
+ /** Imports the site model data containing common properties of the control. */
+ bool importSiteModel( BinaryInputStream& rInStrm );
+
+ /** Imports the site models of all embedded controls from the 'f' stream. */
+ void importEmbeddedSiteModels( BinaryInputStream& rInStrm );
+ /* Final processing of all embedded controls after import. */
+ void finalizeEmbeddedControls();
+
+ /** Moves the control relative to its current position by the passed distance. */
+ void moveRelative( const AxPairData& rDistance );
+ /** Moves all embedded controls from their relative position in this
+ control to an absolute position in the parent of this control. */
+ void moveEmbeddedToAbsoluteParent();
+
+ /** Functor for comparing controls by their tab index. */
+ static bool compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight );
+
+protected:
+ VbaSiteModelRef mxSiteModel; ///< Common control properties.
+ ControlModelRef mxCtrlModel; ///< Specific control properties.
+
+private:
+ VbaFormControlVector maControls; ///< All embedded form controls.
+ AxClassTable maClassTable; ///< Class identifiers for exotic embedded controls.
+};
+
+
+class VbaUserForm final : public VbaFormControl
+{
+public:
+ explicit VbaUserForm(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxDocModel,
+ const GraphicHelper& rGraphicHelper,
+ bool bDefaultColorBgr );
+
+ /** Imports the form and its embedded controls, and inserts the form with
+ all its controls into the passed dialog library. */
+ void importForm(
+ const css::uno::Reference< css::container::XNameContainer >& rxDialogLib,
+ StorageBase& rVbaFormStrg,
+ const OUString& rModuleName,
+ rtl_TextEncoding eTextEnc );
+
+private:
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+ css::uno::Reference< css::frame::XModel > mxDocModel;
+ ControlConverter maConverter;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
new file mode 100644
index 000000000..04d9f7512
--- /dev/null
+++ b/include/oox/ole/vbaexport.hxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_OOX_OLE_VBAEXPORT_HXX
+#define INCLUDED_OOX_OLE_VBAEXPORT_HXX
+
+#include <cstddef>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+class SotStorage;
+class SvStream;
+class SvMemoryStream;
+
+namespace com::sun::star {
+ namespace container { class XNameContainer; }
+ namespace frame { class XModel; }
+ namespace script { class XLibraryContainer; }
+}
+
+class OOX_DLLPUBLIC VbaExport
+{
+public:
+ VbaExport(css::uno::Reference<css::frame::XModel> const & xModel);
+
+ void exportVBA(SotStorage* pRootStorage);
+
+ bool containsVBAProject();
+
+private:
+
+ css::uno::Reference<css::container::XNameContainer>
+ getBasicLibrary() const;
+
+ css::uno::Reference<css::script::XLibraryContainer>
+ getLibraryContainer() const;
+
+ OUString getProjectName() const;
+ rtl_TextEncoding getVBATextEncoding() const;
+
+ css::uno::Reference<css::frame::XModel> mxModel;
+};
+
+class VBACompressionChunk
+{
+public:
+
+ VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, std::size_t nChunkSize);
+
+ void write();
+
+private:
+ SvStream& mrCompressedStream;
+ const sal_uInt8* mpUncompressedData;
+ sal_uInt8* mpCompressedChunkStream;
+
+ // same as DecompressedChunkEnd in the spec
+ std::size_t mnChunkSize;
+
+ // CompressedCurrent according to the spec
+ sal_uInt64 mnCompressedCurrent;
+
+ // CompressedEnd according to the spec
+ sal_uInt64 mnCompressedEnd;
+
+ // DecompressedCurrent according to the spec
+ sal_uInt64 mnDecompressedCurrent;
+
+ // DecompressedEnd according to the spec
+ sal_uInt64 mnDecompressedEnd;
+
+ static void PackCompressedChunkSize(size_t nSize, sal_uInt16& rHeader);
+
+ static void PackCompressedChunkFlag(bool bCompressed, sal_uInt16& rHeader);
+
+ static void PackCompressedChunkSignature(sal_uInt16& rHeader);
+
+ void compressTokenSequence();
+
+ void compressToken(size_t index, sal_uInt8& nFlagByte);
+
+ static void SetFlagBit(size_t index, bool bVal, sal_uInt8& rFlag);
+
+ sal_uInt16 CopyToken(size_t nLength, size_t nOffset);
+
+ void match(size_t& rLength, size_t& rOffset);
+
+ void CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOffsetMask,
+ sal_uInt16& rBitCount, sal_uInt16& rMaximumLength);
+
+ void writeRawChunk();
+
+ sal_uInt16 handleHeader(bool bCompressed);
+};
+
+class OOX_DLLPUBLIC VBACompression
+{
+public:
+ VBACompression(SvStream& rCompressedStream,
+ SvMemoryStream& rUncompressedStream);
+
+ void write();
+
+private:
+ SvStream& mrCompressedStream;
+ SvMemoryStream& mrUncompressedStream;
+};
+
+class OOX_DLLPUBLIC VBAEncryption
+{
+public:
+ VBAEncryption(const sal_uInt8* pData,
+ const sal_uInt16 nLength,
+ SvStream& rEncryptedData,
+ sal_uInt8 nProjKey,
+ rtl_TextEncoding eTextEncoding);
+
+ void write();
+
+ static sal_uInt8 calculateProjKey(const OUString& rString);
+
+private:
+ const sal_uInt8* mpData; // an array of bytes to be obfuscated
+ const sal_uInt16 mnLength; // the length of Data
+ SvStream& mrEncryptedData; // Encrypted Data Structure
+ sal_uInt8 mnUnencryptedByte1; // the last unencrypted byte read or written
+ sal_uInt8 mnEncryptedByte1; // the last encrypted byte read or written
+ sal_uInt8 mnEncryptedByte2; // the next-to-last encrypted byte read or written
+ sal_Unicode mnProjKey; // a project-specific encryption key
+ sal_uInt8 mnIgnoredLength; // the length in bytes of IgnoredEnc
+
+ sal_uInt8 mnSeed; // the seed value
+ sal_uInt8 mnVersionEnc; // the version encoding
+ rtl_TextEncoding meTextEncoding; // the VBA text encoding on export
+
+ void writeSeed();
+ void writeVersionEnc();
+ void writeProjKeyEnc();
+ void writeIgnoredEnc();
+ void writeDataLengthEnc();
+ void writeDataEnc();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/vbahelper.hxx b/include/oox/ole/vbahelper.hxx
new file mode 100644
index 000000000..248d09810
--- /dev/null
+++ b/include/oox/ole/vbahelper.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_VBAHELPER_HXX
+#define INCLUDED_OOX_OLE_VBAHELPER_HXX
+
+#include <oox/helper/binarystreambase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class BinaryInputStream; }
+
+namespace oox::ole {
+
+// Directory stream record identifiers ========================================
+
+const sal_uInt16 VBA_ID_MODULECOOKIE = 0x002C;
+const sal_uInt16 VBA_ID_MODULEDOCSTRING = 0x001C;
+const sal_uInt16 VBA_ID_MODULEDOCSTRINGUNICODE = 0x0048;
+const sal_uInt16 VBA_ID_MODULEEND = 0x002B;
+const sal_uInt16 VBA_ID_MODULEHELPCONTEXT = 0x001E;
+const sal_uInt16 VBA_ID_MODULENAME = 0x0019;
+const sal_uInt16 VBA_ID_MODULENAMEUNICODE = 0x0047;
+const sal_uInt16 VBA_ID_MODULEOFFSET = 0x0031;
+const sal_uInt16 VBA_ID_MODULEPRIVATE = 0x0028;
+const sal_uInt16 VBA_ID_MODULEREADONLY = 0x0025;
+const sal_uInt16 VBA_ID_MODULESTREAMNAME = 0x001A;
+const sal_uInt16 VBA_ID_MODULESTREAMNAMEUNICODE = 0x0032;
+const sal_uInt16 VBA_ID_MODULETYPEDOCUMENT = 0x0022;
+const sal_uInt16 VBA_ID_MODULETYPEPROCEDURAL = 0x0021;
+const sal_uInt16 VBA_ID_PROJECTCODEPAGE = 0x0003;
+const sal_uInt16 VBA_ID_PROJECTEND = 0x0010;
+const sal_uInt16 VBA_ID_PROJECTMODULES = 0x000F;
+const sal_uInt16 VBA_ID_PROJECTNAME = 0x0004;
+const sal_uInt16 VBA_ID_PROJECTVERSION = 0x0009;
+
+
+/** Static helper functions for the VBA filters. */
+namespace VbaHelper
+{
+ /** Reads the next record from the VBA directory stream 'dir'.
+
+ @param rnRecId (out parameter) The record identifier of the new record.
+ @param rRecData (out parameter) The contents of the new record.
+ @param rInStrm The 'dir' stream.
+
+ @return True = next record successfully read. False on any error, or
+ if the stream is EOF.
+ */
+ bool readDirRecord(
+ sal_uInt16& rnRecId,
+ StreamDataSequence& rRecData,
+ BinaryInputStream& rInStrm );
+
+ /** Extracts a key/value pair from a string separated by an equality sign.
+
+ @param rKey (out parameter) The key before the separator.
+ @param rValue (out parameter) The value following the separator.
+ @param rCodeLine The source key/value pair.
+
+ @return True = Equality sign separator found, and the returned key and
+ value are not empty. False otherwise.
+ */
+ bool extractKeyValue(
+ OUString& rKey,
+ OUString& rValue,
+ std::u16string_view rKeyValue );
+}
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/vbainputstream.hxx b/include/oox/ole/vbainputstream.hxx
new file mode 100644
index 000000000..4f2f78d81
--- /dev/null
+++ b/include/oox/ole/vbainputstream.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_VBAINPUTSTREAM_HXX
+#define INCLUDED_OOX_OLE_VBAINPUTSTREAM_HXX
+
+#include <cstddef>
+#include <vector>
+
+#include <oox/helper/binaryinputstream.hxx>
+#include <oox/helper/binarystreambase.hxx>
+#include <sal/types.h>
+
+namespace oox::ole {
+
+
+/** A non-seekable input stream that implements run-length decompression. */
+class VbaInputStream final : public BinaryInputStream
+{
+public:
+ explicit VbaInputStream( BinaryInputStream& rInStrm );
+
+ /** Returns -1, stream size is not determinable. */
+ virtual sal_Int64 size() const override;
+ /** Returns -1, stream position is not tracked. */
+ virtual sal_Int64 tell() const override;
+ /** Does nothing, stream is not seekable. */
+ virtual void seek( sal_Int64 nPos ) override;
+ /** Closes the input stream but not the wrapped stream. */
+ virtual void close() override;
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+ /** Seeks the stream forward by the passed number of bytes. */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
+
+private:
+ /** If no data left in chunk buffer, reads the next chunk from stream. */
+ bool updateChunk();
+
+private:
+ typedef ::std::vector< sal_uInt8 > ChunkBuffer;
+
+ BinaryInputStream* mpInStrm;
+ ChunkBuffer maChunk;
+ size_t mnChunkPos;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/vbamodule.hxx b/include/oox/ole/vbamodule.hxx
new file mode 100644
index 000000000..573552766
--- /dev/null
+++ b/include/oox/ole/vbamodule.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_VBAMODULE_HXX
+#define INCLUDED_OOX_OLE_VBAMODULE_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <vector>
+
+namespace com::sun::star {
+ namespace container { class XNameAccess; }
+ namespace container { class XNameContainer; }
+ namespace frame { class XModel; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+ class BinaryInputStream;
+ class StorageBase;
+}
+
+namespace oox::ole {
+
+/** Stores, which key shortcut maps to which VBA macro method. */
+struct VbaMacroKeyAndMethodBinding
+{
+ // This describes a key combination in "raw" VBA Macro form, that
+ // still needs translated to a key event that can be used in
+ // LibreOffice.
+ OUString msApiKey;
+ // The name of the macro method
+ OUString msMethodName;
+};
+
+class VbaModule
+{
+public:
+ explicit VbaModule(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxDocModel,
+ const OUString& rName,
+ rtl_TextEncoding eTextEnc,
+ bool bExecutable );
+
+ /** Returns the module type (com.sun.star.script.ModuleType constant). */
+ sal_Int32 getType() const { return mnType; }
+ /** Sets the passed module type. */
+ void setType( sal_Int32 nType ) { mnType = nType; }
+
+ /** Returns the name of the module. */
+ const OUString& getName() const { return maName; }
+ /** Returns the stream name of the module. */
+ const OUString& getStreamName() const { return maStreamName; }
+
+ /** Imports all records for this module until the MODULEEND record. */
+ void importDirRecords( BinaryInputStream& rDirStrm );
+
+ /** Imports the VBA source code into the passed Basic library. */
+ void createAndImportModule(
+ StorageBase& rVbaStrg,
+ const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
+ const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA );
+ /** Creates an empty Basic module in the passed Basic library. */
+ void createEmptyModule(
+ const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
+ const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
+
+ void registerShortcutKeys();
+
+private:
+ /** Reads and returns the VBA source code from the passed storage. */
+ OUString readSourceCode( StorageBase& rVbaStrg );
+
+ /** Creates a new Basic module and inserts it into the passed Basic library. */
+ void createModule(
+ std::u16string_view rVBASourceCode,
+ const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
+ const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
+
+private:
+ css::uno::Reference< css::uno::XComponentContext >
+ mxContext; ///< Component context with service manager.
+ css::uno::Reference< css::frame::XModel >
+ mxDocModel; ///< Document model used to import/export the VBA project.
+ OUString maName;
+ OUString maStreamName;
+ OUString maDocString;
+ rtl_TextEncoding meTextEnc;
+ sal_Int32 mnType;
+ sal_uInt32 mnOffset;
+ bool mbReadOnly;
+ bool mbPrivate;
+ bool mbExecutable;
+
+ /** Keys and VBA macro method bindings */
+ std::vector<VbaMacroKeyAndMethodBinding> maKeyBindings;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ole/vbaproject.hxx b/include/oox/ole/vbaproject.hxx
new file mode 100644
index 000000000..4a9b3e1a4
--- /dev/null
+++ b/include/oox/ole/vbaproject.hxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_OLE_VBAPROJECT_HXX
+#define INCLUDED_OOX_OLE_VBAPROJECT_HXX
+
+#include <functional>
+#include <map>
+#include <string_view>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/refmap.hxx>
+#include <oox/helper/refvector.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace container { class XNameContainer; }
+ namespace frame { class XModel; }
+ namespace script { class XLibraryContainer; }
+ namespace script::vba { class XVBAMacroResolver; }
+ namespace uno { class XComponentContext; }
+ namespace uno { class XInterface; }
+ namespace io { class XInputStream; }
+}
+
+namespace oox {
+ class GraphicHelper;
+ class StorageBase;
+}
+
+namespace oox::ole {
+
+class VbaModule;
+
+class VbaFilterConfig
+{
+public:
+ explicit VbaFilterConfig(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ std::u16string_view rConfigCompName );
+ ~VbaFilterConfig();
+
+ /** Returns true, if the VBA source code and forms should be imported. */
+ bool isImportVba() const;
+ /** Returns true, if the VBA source code should be imported executable. */
+ bool isImportVbaExecutable() const;
+ /** Returns true, if the VBA source code and forms should be exported. */
+ bool isExportVba() const;
+
+private:
+ css::uno::Reference< css::uno::XInterface >
+ mxConfigAccess;
+};
+
+
+/** Base class for objects that attach a macro to a specific action.
+
+ Purpose is to collect objects that need to attach a VBA macro to an action.
+ The VBA project will be loaded at a very late point of the document import
+ process, because it depends on an initialized core document model (e.g.
+ spreadsheet codenames). Some objects that want to attach a VBA macro to an
+ action (e.g. mouse click action for drawing shapes) are loaded long before
+ the VBA project. The drawback is that in most cases macros are specified
+ without module name, or the VBA project name is part of the macro name.
+ In the former case, all code modules have to be scanned for the macro to be
+ able to create a valid script URL.
+
+ The import code will register these requests to attach a VBA macro with an
+ instance of a class derived from this base class. The derived class will
+ store all information needed to finally attach the macro to the action,
+ once the VBA project has been imported.
+ */
+class OOX_DLLPUBLIC VbaMacroAttacherBase
+{
+public:
+ explicit VbaMacroAttacherBase( const OUString& rMacroName );
+ virtual ~VbaMacroAttacherBase();
+
+ /** Resolves the internal macro name to the related macro URL, and attaches
+ the macro to the object. */
+ void resolveAndAttachMacro(
+ const css::uno::Reference< css::script::vba::XVBAMacroResolver >& rxResolver );
+
+private:
+ /** Called after the VBA project has been imported. Derived classes will
+ attach the passed script to the object represented by this instance. */
+ virtual void attachMacro( const OUString& rScriptUrl ) = 0;
+
+private:
+ OUString maMacroName;
+};
+
+typedef std::shared_ptr< VbaMacroAttacherBase > VbaMacroAttacherRef;
+
+
+class OOX_DLLPUBLIC VbaProject : public VbaFilterConfig
+{
+public:
+ explicit VbaProject(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxDocModel,
+ std::u16string_view rConfigCompName );
+ virtual ~VbaProject();
+
+ /** Imports the entire VBA project from the passed storage.
+
+ @param rVbaPrjStrg The root storage of the entire VBA project.
+ */
+ void importVbaProject(
+ StorageBase& rVbaPrjStrg,
+ const GraphicHelper& rGraphicHelper );
+
+ bool importVbaProject(
+ StorageBase& rVbaPrjStrg );
+
+ /// Imports VBA data for a VBA project, e.g. word/vbaData.xml.
+ void importVbaData(const css::uno::Reference<css::io::XInputStream>& xInputStream);
+
+ /** Reads vba module related information from the project streams */
+ void readVbaModules( StorageBase& rVbaPrjStrg );
+ /** Imports (and creates) vba modules and user forms from the vba project records previously read.
+ Note: ( expects that readVbaModules was already called ) */
+ void importModulesAndForms( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper );
+ /** Registers a macro attacher object. For details, see description of the
+ VbaMacroAttacherBase class. */
+ void registerMacroAttacher( const VbaMacroAttacherRef& rxAttacher );
+
+ /** Attaches VBA macros to objects registered via registerMacroAttacher(). */
+ void attachMacros();
+
+ void setOleOverridesSink( css::uno::Reference< css::container::XNameContainer > const & rxOleOverridesSink ){ mxOleOverridesSink = rxOleOverridesSink; }
+
+protected:
+ /** Registers a dummy module that will be created when the VBA project is
+ imported. */
+ void addDummyModule( const OUString& rName, sal_Int32 nType );
+
+ /** Called when the import process of the VBA project has been started. */
+ virtual void prepareImport();
+
+private:
+ VbaProject( const VbaProject& ) = delete;
+ VbaProject& operator=( const VbaProject& ) = delete;
+
+ /** Returns the Basic or dialog library container. */
+ css::uno::Reference< css::script::XLibraryContainer >
+ getLibraryContainer( sal_Int32 nPropId );
+ /** Opens a Basic or dialog library, creates missing if not found. */
+ css::uno::Reference< css::container::XNameContainer >
+ openLibrary( sal_Int32 nPropId );
+ /** Creates and returns the Basic library of the document used for import. */
+ css::uno::Reference< css::container::XNameContainer > const &
+ createBasicLibrary();
+ /** Creates and returns the dialog library of the document used for import. */
+ css::uno::Reference< css::container::XNameContainer > const &
+ createDialogLibrary();
+
+ /** Imports the VBA code modules and forms. */
+ void importVba(
+ StorageBase& rVbaPrjStrg,
+ const GraphicHelper& rGraphicHelper );
+
+ /** Copies the entire VBA project storage to the passed document model. */
+ void copyStorage( StorageBase& rVbaPrjStrg );
+
+private:
+ typedef RefVector< VbaMacroAttacherBase > MacroAttacherVector;
+ typedef ::std::map< OUString, sal_Int32 > DummyModuleMap;
+
+ css::uno::Reference< css::uno::XComponentContext >
+ mxContext; ///< Component context with service manager.
+ css::uno::Reference< css::frame::XModel >
+ mxDocModel; ///< Document model used to import/export the VBA project.
+ css::uno::Reference< css::container::XNameContainer >
+ mxBasicLib; ///< The Basic library of the document used for import.
+ css::uno::Reference< css::container::XNameContainer >
+ mxDialogLib; ///< The dialog library of the document used for import.
+ MacroAttacherVector maMacroAttachers; ///< Objects that want to attach a VBA macro to an action.
+ DummyModuleMap maDummyModules; ///< Additional empty modules created on import.
+ OUString maPrjName; ///< Name of the VBA project.
+ css::uno::Reference< css::container::XNameContainer >
+ mxOleOverridesSink;
+ typedef RefMap< OUString, VbaModule > VbaModuleMap;
+ VbaModuleMap maModules;
+ VbaModuleMap maModulesByStrm;
+};
+
+
+} // namespace oox::ole
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/animationspersist.hxx b/include/oox/ppt/animationspersist.hxx
new file mode 100644
index 000000000..8c8bb766d
--- /dev/null
+++ b/include/oox/ppt/animationspersist.hxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef INCLUDED_OOX_PPT_ANIMATIONSPERSIST_HXX
+#define INCLUDED_OOX_PPT_ANIMATIONSPERSIST_HXX
+
+#include <array>
+#include <vector>
+#include <memory>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox::ppt {
+
+ enum {
+ NP_TO = 0,
+ NP_FROM, NP_BY, NP_USERDATA, NP_ATTRIBUTENAME,
+ NP_ACCELERATION, NP_AUTOREVERSE, NP_DECELERATE, NP_DURATION, NP_FILL,
+ NP_REPEATCOUNT, NP_REPEATDURATION, NP_RESTART,
+ NP_DIRECTION, NP_COLORINTERPOLATION, NP_CALCMODE, NP_TRANSFORMTYPE,
+ NP_PATH,
+ NP_ENDSYNC, NP_ITERATETYPE, NP_ITERATEINTERVAL,
+ NP_SUBITEM, NP_TARGET, NP_COMMAND, NP_PARAMETER,
+ NP_VALUES, NP_FORMULA, NP_KEYTIMES, NP_DISPLAY,
+ NP_HIDEDURINGSHOW,
+ NP_ISNARRATION,
+ NP_SIZE_
+ };
+
+ typedef std::array< css::uno::Any, NP_SIZE_ > NodePropertyMap;
+
+
+ /** data for CT_TLShapeTargetElement */
+ struct ShapeTargetElement
+ {
+ ShapeTargetElement()
+ : mnType(0)
+ , mnRangeType(0)
+ {
+ maRange.start = maRange.end = 0;
+ }
+ void convert( css::uno::Any & aAny, sal_Int16 & rSubType ) const;
+
+ sal_Int32 mnType;
+ sal_Int32 mnRangeType;
+ drawingml::IndexRange maRange;
+ OUString msSubShapeId;
+ };
+
+
+ /** data for CT_TLTimeTargetElement */
+ struct AnimTargetElement
+ {
+ AnimTargetElement()
+ : mnType( 0 )
+ {}
+ /** convert to a set of properties */
+ css::uno::Any convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const;
+
+ sal_Int32 mnType;
+ OUString msValue;
+ ShapeTargetElement maShapeTarget;
+ };
+
+ typedef std::shared_ptr< AnimTargetElement > AnimTargetElementPtr;
+
+ struct AnimationCondition;
+
+ typedef std::vector< AnimationCondition > AnimationConditionList;
+
+ /** data for CT_TLTimeCondition */
+ struct AnimationCondition
+ {
+ AnimationCondition()
+ : mnType( 0 )
+ {}
+
+ css::uno::Any convert(const SlidePersistPtr & pSlide) const;
+ static css::uno::Any convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l);
+
+ AnimTargetElementPtr & getTarget()
+ { if(!mpTarget) mpTarget = std::make_shared<AnimTargetElement>(); return mpTarget; }
+ css::uno::Any maValue;
+ sal_Int32 mnType;
+ private:
+ AnimTargetElementPtr mpTarget;
+ };
+
+
+ struct TimeAnimationValue
+ {
+ OUString msFormula;
+ OUString msTime;
+ css::uno::Any maValue;
+ };
+
+ typedef ::std::vector< TimeAnimationValue > TimeAnimationValueList;
+
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/backgroundproperties.hxx b/include/oox/ppt/backgroundproperties.hxx
new file mode 100644
index 000000000..35a209b30
--- /dev/null
+++ b/include/oox/ppt/backgroundproperties.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_BACKGROUNDPROPERTIES_HXX
+#define INCLUDED_OOX_PPT_BACKGROUNDPROPERTIES_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::drawingml { struct FillProperties; }
+
+namespace oox::ppt {
+
+
+class BackgroundPropertiesContext final : public ::oox::core::FragmentHandler2
+{
+public:
+ BackgroundPropertiesContext( ::oox::core::FragmentHandler2 const & rParent, ::oox::drawingml::FillProperties& rFillProperties );
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+private:
+ ::oox::drawingml::FillProperties& mrFillProperties;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_BACKGROUNDPROPERTIES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/comments.hxx b/include/oox/ppt/comments.hxx
new file mode 100644
index 000000000..10cad1270
--- /dev/null
+++ b/include/oox/ppt/comments.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+#ifndef INCLUDED_OOX_PPT_COMMENTS_HXX
+#define INCLUDED_OOX_PPT_COMMENTS_HXX
+
+#include <vector>
+
+#include <com/sun/star/util/DateTime.hpp>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox::ppt {
+
+struct CommentAuthor
+{
+ OUString clrIdx;
+ OUString id;
+ OUString initials;
+ OUString lastIdx;
+ OUString name;
+};
+
+class CommentAuthorList
+{
+ private:
+ std::vector<CommentAuthor> cmAuthorLst;
+
+ public:
+ void setValues(const CommentAuthorList& list);
+
+ void addAuthor(const CommentAuthor& _author)
+ {
+ cmAuthorLst.push_back(_author);
+ }
+
+ friend class Comment;
+};
+
+class Comment
+{
+ private:
+ OUString authorId;
+ OUString dt;
+ OUString idx;
+ OUString x;
+ OUString y;
+ OUString text;
+ css::util::DateTime aDateTime;
+
+ void setDateTime (const OUString& datetime);
+
+ public:
+ void setAuthorId(const OUString& _aId)
+ {
+ authorId = _aId;
+ }
+ void setdt(const OUString& _dt)
+ {
+ dt=_dt;
+ setDateTime(_dt);
+ }
+ void setidx(const OUString& _idx)
+ {
+ idx=_idx;
+ }
+ void setPoint(const OUString& _x, const OUString& _y)
+ {
+ x=_x;
+ y=_y;
+ }
+ void setText(const OUString& _text)
+ {
+ text = _text;
+ }
+ const OUString& get_text() const
+ {
+ return text;
+ }
+ const css::util::DateTime& getDateTime() const
+ {
+ return aDateTime;
+ }
+ sal_Int32 getIntX() const
+ {
+ return x.toInt32();
+ }
+ sal_Int32 getIntY() const
+ {
+ return y.toInt32();
+ }
+ OUString getAuthor ( const CommentAuthorList& list );
+};
+
+class CommentList
+{
+ public:
+ std::vector<Comment> cmLst;
+ int getSize () const
+ {
+ return static_cast<int>(cmLst.size());
+ }
+ const Comment& getCommentAtIndex (int index);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/customshowlistcontext.hxx b/include/oox/ppt/customshowlistcontext.hxx
new file mode 100644
index 000000000..d79cfc637
--- /dev/null
+++ b/include/oox/ppt/customshowlistcontext.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_CUSTOMSHOWLISTCONTEXT_HXX
+#define INCLUDED_OOX_PPT_CUSTOMSHOWLISTCONTEXT_HXX
+
+#include <vector>
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::ppt {
+
+
+ struct CustomShow
+ {
+ OUString maCustomShowName;
+ OUString mnId;
+ std::vector< OUString >maSldLst;
+ };
+
+ /** CT_ */
+ class CustomShowListContext final : public ::oox::core::FragmentHandler2
+ {
+ std::vector< CustomShow >& mrCustomShowList;
+
+ public:
+ CustomShowListContext( ::oox::core::FragmentHandler2 const & rParent,
+ std::vector< CustomShow >& rCustomShowList );
+
+ virtual ~CustomShowListContext( ) override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+ };
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/headerfooter.hxx b/include/oox/ppt/headerfooter.hxx
new file mode 100644
index 000000000..e304f3c6e
--- /dev/null
+++ b/include/oox/ppt/headerfooter.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_HEADERFOOTER_HXX
+#define INCLUDED_OOX_PPT_HEADERFOOTER_HXX
+
+namespace oox::ppt {
+
+ struct HeaderFooter
+ {
+ bool mbSlideNumber;
+ bool mbHeader;
+ bool mbFooter;
+ bool mbDateTime;
+
+ HeaderFooter()
+ : mbSlideNumber( true )
+ , mbHeader( true )
+ , mbFooter( true )
+ , mbDateTime( true ) {};
+ };
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/layoutfragmenthandler.hxx b/include/oox/ppt/layoutfragmenthandler.hxx
new file mode 100644
index 000000000..41fb7a85b
--- /dev/null
+++ b/include/oox/ppt/layoutfragmenthandler.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_LAYOUTFRAGMENTHANDLER_HXX
+#define INCLUDED_OOX_PPT_LAYOUTFRAGMENTHANDLER_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/ppt/slidefragmenthandler.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::ppt {
+
+class LayoutFragmentHandler final : public SlideFragmentHandler
+{
+public:
+ LayoutFragmentHandler(::oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath,
+ const SlidePersistPtr& pMasterPersistPtr);
+ virtual ~LayoutFragmentHandler() override;
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_LAYOUTFRAGMENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptfilterhelpers.hxx b/include/oox/ppt/pptfilterhelpers.hxx
new file mode 100644
index 000000000..58547d9e7
--- /dev/null
+++ b/include/oox/ppt/pptfilterhelpers.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTFILTERHELPERS_HXX
+#define INCLUDED_OOX_PPT_PPTFILTERHELPERS_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Any.hxx>
+
+namespace com::sun::star {
+ namespace animations { class XAnimationNode; }
+}
+
+namespace oox::ppt {
+
+ // conversion of MS to OOo attributes.
+ enum class AnimationAttributeEnum
+ {
+ PPT_X, PPT_Y, PPT_W, PPT_H, PPT_C, R, XSHEAR, FILLCOLOR, FILLTYPE,
+ FILLON, STROKECOLOR, STROKEON, STYLECOLOR, STYLEROTATION, FONTWEIGHT,
+ STYLEUNDERLINE, STYLEFONTFAMILY, STYLEFONTSIZE, STYLEFONTSTYLE,
+ STYLEVISIBILITY, STYLEOPACITY, UNKNOWN
+ };
+
+ struct ImplAttributeNameConversion
+ {
+ AnimationAttributeEnum meAttribute;
+ const char* mpMSName;
+ const char* mpAPIName;
+ };
+
+ OOX_DLLPUBLIC const ImplAttributeNameConversion *getAttributeConversionList();
+
+ struct OOX_DLLPUBLIC transition
+ {
+ const char* mpName;
+ sal_Int16 mnType;
+ sal_Int16 mnSubType;
+ bool mbDirection; // true: default geometric direction
+
+ static const transition* getList();
+ static const transition* find( std::u16string_view rName );
+ };
+
+ struct OOX_DLLPUBLIC convert_subtype
+ {
+ sal_Int32 mnID;
+ const char* mpStrSubType;
+
+ static const convert_subtype* getList();
+ };
+
+ struct OOX_DLLPUBLIC preset_mapping
+ {
+ sal_Int32 mnPresetClass;
+ sal_Int32 mnPresetId;
+ const char* mpStrPresetId;
+
+ static const preset_mapping* getList();
+ };
+
+ OOX_DLLPUBLIC OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId, sal_Int32 nPresetSubType );
+
+ OOX_DLLPUBLIC void fixMainSequenceTiming( const css::uno::Reference< css::animations::XAnimationNode >& xNode );
+
+ OOX_DLLPUBLIC void fixInteractiveSequenceTiming( const css::uno::Reference< css::animations::XAnimationNode >& xNode );
+
+ /** convert attribute values of the animation target so that LibreOffice understand.
+ */
+ OOX_DLLPUBLIC bool convertAnimationValue(AnimationAttributeEnum eAttribute, css::uno::Any& rValue);
+
+ /** convert the measure string to LibreOffice format.
+ * i.e. convert occurrence of #{0,1}ppt_[xywh] to x,y, width, height.
+ */
+ OOX_DLLPUBLIC bool convertMeasure(OUString& rString);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptgraphicshapecontext.hxx b/include/oox/ppt/pptgraphicshapecontext.hxx
new file mode 100644
index 000000000..bdc1f7d77
--- /dev/null
+++ b/include/oox/ppt/pptgraphicshapecontext.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTGRAPHICSHAPECONTEXT_HXX
+#define INCLUDED_OOX_PPT_PPTGRAPHICSHAPECONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/graphicshapecontext.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class ContextHandler2Helper; }
+
+namespace oox::ppt {
+
+class PPTGraphicShapeContext final : public ::oox::drawingml::GraphicShapeContext
+{
+ SlidePersistPtr mpSlidePersistPtr;
+
+public:
+ PPTGraphicShapeContext( ::oox::core::ContextHandler2Helper const & rParent, const SlidePersistPtr& rSlidePersistPtr, const oox::drawingml::ShapePtr& pMasterShapePtr, const oox::drawingml::ShapePtr& pShapePtr );
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+};
+
+}
+
+#endif // OOX_PPT_PPTGRAPHICSHAPEGROUPCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptimport.hxx b/include/oox/ppt/pptimport.hxx
new file mode 100644
index 000000000..2d7367c4c
--- /dev/null
+++ b/include/oox/ppt/pptimport.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTIMPORT_HXX
+#define INCLUDED_OOX_PPT_PPTIMPORT_HXX
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/core/filterbase.hxx>
+#include <oox/core/xmlfilterbase.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/theme.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace beans { struct PropertyValue; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox {
+ class GraphicHelper;
+ namespace drawingml::chart { class ChartConverter; }
+ namespace ole { class VbaProject; }
+ namespace vml { class Drawing; }
+}
+
+namespace oox::ppt {
+
+
+class PowerPointImport final : public oox::core::XmlFilterBase
+{
+public:
+ /// @throws css::uno::RuntimeException
+ PowerPointImport( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+ virtual ~PowerPointImport() override;
+
+ // from FilterBase
+ virtual bool importDocument() override;
+ virtual bool exportDocument() noexcept override;
+
+ virtual const ::oox::drawingml::Theme* getCurrentTheme() const override;
+ virtual ::oox::vml::Drawing* getVmlDrawing() override;
+ virtual oox::drawingml::table::TableStyleListPtr getTableStyles() override;
+ virtual ::oox::drawingml::chart::ChartConverter* getChartConverter() override;
+
+ const SlidePersistPtr& getActualSlidePersist() const { return mpActualSlidePersist; };
+ void setActualSlidePersist( SlidePersistPtr pActualSlidePersist ){ mpActualSlidePersist = pActualSlidePersist; };
+ std::map< OUString, oox::drawingml::ThemePtr >& getThemes(){ return maThemes; };
+ std::vector< SlidePersistPtr >& getDrawPages(){ return maDrawPages; };
+ std::vector< SlidePersistPtr >& getMasterPages(){ return maMasterPages; };
+ std::vector< SlidePersistPtr >& getNotesPages(){ return maNotesPages; };
+
+ virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& rDescriptor ) override;
+
+ ::Color getSchemeColor( sal_Int32 nToken ) const;
+ virtual std::shared_ptr<::oox::drawingml::Theme> getCurrentThemePtr() const override;
+
+#if OSL_DEBUG_LEVEL > 0
+ static XmlFilterBase* mpDebugFilterBase;
+#endif
+
+private:
+ virtual GraphicHelper* implCreateGraphicHelper() const override;
+ virtual ::oox::ole::VbaProject* implCreateVbaProject() const override;
+ virtual OUString SAL_CALL getImplementationName() override;
+
+private:
+ OUString maTableStyleListPath;
+ oox::drawingml::table::TableStyleListPtr mpTableStyleList;
+
+ SlidePersistPtr mpActualSlidePersist;
+ std::map< OUString, oox::drawingml::ThemePtr > maThemes;
+
+ std::vector< SlidePersistPtr > maDrawPages;
+ std::vector< SlidePersistPtr > maMasterPages;
+ std::vector< SlidePersistPtr > maNotesPages;
+
+ std::shared_ptr< ::oox::drawingml::chart::ChartConverter > mxChartConv;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_PPTIMPORT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptshape.hxx b/include/oox/ppt/pptshape.hxx
new file mode 100644
index 000000000..ead382b52
--- /dev/null
+++ b/include/oox/ppt/pptshape.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTSHAPE_HXX
+#define INCLUDED_OOX_PPT_PPTSHAPE_HXX
+
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/drawingml/shape.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace basegfx { class B2DHomMatrix; }
+
+namespace com::sun::star {
+ namespace awt { struct Rectangle; }
+ namespace drawing { class XShapes; }
+}
+
+namespace oox {
+ namespace core { class XmlFilterBase; }
+ namespace drawingml { class Theme; }
+ template <typename Type> class OptValue;
+}
+
+namespace oox::ppt {
+
+class PPTShape final : public oox::drawingml::Shape
+{
+ OUString msModelId; // fallback dgs smartart shape reference
+ ShapeLocation meShapeLocation; // placeholdershapes (mnSubType != 0) on Master are never displayed
+ bool mbReferenced; // placeholdershapes on Layout are displayed only, if they are not referenced
+ // placeholdershapes on Slide are displayed always
+ oox::drawingml::ShapePtr mpPlaceholder;
+ /// Set if spPr tag is non empty for the shape
+ bool mbHasNoninheritedShapeProperties;
+
+ bool IsPlaceHolderCandidate(const SlidePersist& rSlidePersist) const;
+
+public:
+
+ PPTShape( const oox::ppt::ShapeLocation eShapeLocation,
+ const char* pServiceType );
+ virtual ~PPTShape() override;
+
+ using oox::drawingml::Shape::addShape;
+ // addShape is creating and inserting the corresponding XShape.
+ void addShape(
+ oox::core::XmlFilterBase& rFilterBase,
+ const SlidePersist& rPersist,
+ const oox::drawingml::Theme* pTheme,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ basegfx::B2DHomMatrix& aTransformation,
+ ::oox::drawingml::ShapeIdMap* pShapeMap );
+
+ ShapeLocation getShapeLocation() const { return meShapeLocation; };
+ void setReferenced( bool bReferenced ){ mbReferenced = bReferenced; };
+ void setPlaceholder( oox::drawingml::ShapePtr pPlaceholder ) { mpPlaceholder = pPlaceholder; }
+ void setModelId( const OUString& rId ) { msModelId = rId; }
+
+ /// Flags shape as having a non-empty spPr tag
+ void setHasNoninheritedShapeProperties() { mbHasNoninheritedShapeProperties = true; }
+ /// Returns whether or not the shape had a non-empty spPr tag
+ bool hasNonInheritedShapeProperties() const { return mbHasNoninheritedShapeProperties; }
+
+ static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nFirstSubType,
+ const sal_Int32 nSecondSubType, const OptValue< sal_Int32 >& oSubTypeIndex,
+ std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly = false );
+ static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx,
+ std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly = false );
+
+ static oox::drawingml::TextListStylePtr getSubTypeTextListStyle( const SlidePersist& rSlidePersist, sal_Int32 nSubType );
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_PPTSHAPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptshapecontext.hxx b/include/oox/ppt/pptshapecontext.hxx
new file mode 100644
index 000000000..5d5277502
--- /dev/null
+++ b/include/oox/ppt/pptshapecontext.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTSHAPECONTEXT_HXX
+#define INCLUDED_OOX_PPT_PPTSHAPECONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/shapecontext.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class ContextHandler2Helper; }
+
+namespace oox::ppt {
+
+class PPTShapeContext final : public ::oox::drawingml::ShapeContext
+{
+ SlidePersistPtr mpSlidePersistPtr;
+
+public:
+ PPTShapeContext( ::oox::core::ContextHandler2Helper const & rParent, const SlidePersistPtr& rSlidePersistPtr, const oox::drawingml::ShapePtr& pMasterShapePtr, const oox::drawingml::ShapePtr& pShapePtr );
+ virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_PPTSHAPECONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptshapegroupcontext.hxx b/include/oox/ppt/pptshapegroupcontext.hxx
new file mode 100644
index 000000000..89f8ca65d
--- /dev/null
+++ b/include/oox/ppt/pptshapegroupcontext.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTSHAPEGROUPCONTEXT_HXX
+#define INCLUDED_OOX_PPT_PPTSHAPEGROUPCONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/shapegroupcontext.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class AttributeList;
+ namespace core { class ContextHandler2Helper; }
+ namespace drawingml { class Color; }
+}
+
+namespace oox::ppt {
+
+class PPTShapeGroupContext final : public ::oox::drawingml::ShapeGroupContext
+{
+ SlidePersistPtr mpSlidePersistPtr;
+ ShapeLocation meShapeLocation;
+ oox::drawingml::ShapePtr pGraphicShape;
+
+ void applyFontRefColor(const oox::drawingml::ShapePtr& pShape, const oox::drawingml::Color& rFontRefColor);
+
+public:
+ PPTShapeGroupContext(
+ ::oox::core::FragmentHandler2 const & rParent,
+ const oox::ppt::SlidePersistPtr& rSlidePersistPtr,
+ const oox::ppt::ShapeLocation eShapeLocation,
+ const oox::drawingml::ShapePtr& pMasterShapePtr,
+ const oox::drawingml::ShapePtr& pGroupShapePtr );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+
+ void importExtDrawings();
+
+protected:
+
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_PPTSHAPEGROUPCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/pptshapepropertiescontext.hxx b/include/oox/ppt/pptshapepropertiescontext.hxx
new file mode 100644
index 000000000..124d7545d
--- /dev/null
+++ b/include/oox/ppt/pptshapepropertiescontext.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PPTSHAPEPROPERTIESCONTEXT_HXX
+#define INCLUDED_OOX_PPT_PPTSHAPEPROPERTIESCONTEXT_HXX
+
+#include <drawingml/shapepropertiescontext.hxx>
+#include <oox/core/contexthandler.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class AttributeList;
+ namespace core { class ContextHandler2Helper; }
+ namespace drawingml { class Shape; }
+}
+
+namespace oox::ppt {
+
+class PPTShapePropertiesContext final : public ::oox::drawingml::ShapePropertiesContext
+{
+public:
+ PPTShapePropertiesContext( ::oox::core::ContextHandler2Helper const & rParent, ::oox::drawingml::Shape& rShape );
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_PPTSHAPEPROPERTIESCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/presPropsfragmenthandler.hxx b/include/oox/ppt/presPropsfragmenthandler.hxx
new file mode 100644
index 000000000..18a2a97aa
--- /dev/null
+++ b/include/oox/ppt/presPropsfragmenthandler.hxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_OOX_PPT_PRESPROPSFRAGMENTHANDLER_HXX
+#define INCLUDED_OOX_PPT_PRESPROPSFRAGMENTHANDLER_HXX
+
+#include <oox/core/fragmenthandler2.hxx>
+
+namespace oox
+{
+namespace core
+{
+class XmlFilterBase;
+}
+
+namespace ppt
+{
+class PresPropsFragmentHandler final : public core::FragmentHandler2
+{
+public:
+ PresPropsFragmentHandler(core::XmlFilterBase& rFilter, const OUString& rFragmentPath);
+ virtual ~PresPropsFragmentHandler() override;
+ virtual void finalizeImport() override;
+ virtual core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken,
+ const AttributeList& rAttribs) override;
+
+private:
+ bool m_bLoop = false;
+ bool m_bTiming = true;
+ OUString m_sId;
+ OUString m_sSt;
+};
+} // namespace ppt
+} // namespace oox
+
+#endif // INCLUDED_OOX_PPT_PRESPROPSFRAGMENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/oox/ppt/presentationfragmenthandler.hxx b/include/oox/ppt/presentationfragmenthandler.hxx
new file mode 100644
index 000000000..a9bb5bb67
--- /dev/null
+++ b/include/oox/ppt/presentationfragmenthandler.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_PRESENTATIONFRAGMENTHANDLER_HXX
+#define INCLUDED_OOX_PPT_PRESENTATIONFRAGMENTHANDLER_HXX
+
+#include <vector>
+
+#include <com/sun/star/awt/Size.hpp>
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/ppt/customshowlistcontext.hxx>
+#include <oox/ppt/comments.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::ppt {
+
+class PresentationFragmentHandler final : public ::oox::core::FragmentHandler2
+{
+public:
+ PresentationFragmentHandler(::oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath);
+ virtual ~PresentationFragmentHandler() noexcept override;
+ virtual void finalizeImport() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+private:
+ void importSlide( const ::oox::core::FragmentHandlerRef& rSlideFragmentHandler,
+ const oox::ppt::SlidePersistPtr& rPersist );
+ void importSlide(sal_uInt32 nSlide, bool bFirstSlide, bool bImportNotes);
+ void saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, sal_Int32 nThemeIdx);
+ void importCustomSlideShow(std::vector<CustomShow>& rCustomShowList);
+
+ std::vector< OUString > maSlideMasterVector;
+ std::vector< OUString > maSlidesVector;
+ std::vector< OUString > maNotesMasterVector;
+ ::oox::drawingml::TextListStylePtr mpTextListStyle;
+
+ css::awt::Size maSlideSize;
+ css::awt::Size maNotesSize;
+
+ std::vector< CustomShow > maCustomShowList;
+
+ CommentAuthorList maAuthorList;
+ bool mbCommentAuthorsRead; // read commentAuthors.xml only once
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_PRESENTATIONFRAGMENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/slidefragmenthandler.hxx b/include/oox/ppt/slidefragmenthandler.hxx
new file mode 100644
index 000000000..b7d1d59b3
--- /dev/null
+++ b/include/oox/ppt/slidefragmenthandler.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_SLIDEFRAGMENTHANDLER_HXX
+#define INCLUDED_OOX_PPT_SLIDEFRAGMENTHANDLER_HXX
+
+#include <vector>
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/helper/propertymap.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::ppt {
+
+class SlideFragmentHandler : public ::oox::core::FragmentHandler2
+{
+public:
+ SlideFragmentHandler( ::oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath, const SlidePersistPtr& pPersistPtr, const ShapeLocation eShapeLocation );
+ virtual ~SlideFragmentHandler() override;
+
+ virtual void finalizeImport() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+ virtual void onCharacters( const OUString& rChars ) override;
+
+ const ::std::vector< OUString>& getCharVector() const { return maCharVector; }
+
+protected:
+ SlidePersistPtr mpSlidePersistPtr;
+ ShapeLocation meShapeLocation;
+
+private:
+ OUString maSlideName;
+ PropertyMap maSlideProperties;
+ ::std::vector< OUString> maCharVector; // handle char in OnCharacters
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_SLIDEFRAGMENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/slidemastertextstylescontext.hxx b/include/oox/ppt/slidemastertextstylescontext.hxx
new file mode 100644
index 000000000..4d051ab8e
--- /dev/null
+++ b/include/oox/ppt/slidemastertextstylescontext.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_SLIDEMASTERTEXTSTYLESCONTEXT_HXX
+#define INCLUDED_OOX_PPT_SLIDEMASTERTEXTSTYLESCONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::ppt {
+
+class SlideMasterTextStylesContext final : public oox::core::FragmentHandler2
+{
+public:
+ SlideMasterTextStylesContext( ::oox::core::FragmentHandler2 const & rParent, SlidePersistPtr const & pSlidePersistPtr );
+ virtual ~SlideMasterTextStylesContext() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+private:
+ SlidePersistPtr mpSlidePersistPtr;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_SLIDEMASTERTEXTSTYLESCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/slidepersist.hxx b/include/oox/ppt/slidepersist.hxx
new file mode 100644
index 000000000..4ba48637c
--- /dev/null
+++ b/include/oox/ppt/slidepersist.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_SLIDEPERSIST_HXX
+#define INCLUDED_OOX_PPT_SLIDEPERSIST_HXX
+
+#include <vector>
+#include <map>
+#include <memory>
+
+#include <cppuhelper/weakref.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/drawingml/clrscheme.hxx>
+#include <oox/drawingml/color.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/drawingml/shape.hxx>
+#include <oox/ppt/comments.hxx>
+#include <oox/ppt/headerfooter.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace animations { class XAnimationNode; }
+ namespace drawing { class XDrawPage; }
+}
+
+namespace oox::core { class XmlFilterBase; }
+namespace oox::vml { class Drawing; }
+
+namespace oox::ppt {
+
+enum ShapeLocation
+{
+ Master,
+ Layout,
+ Slide
+};
+
+
+class TimeNode;
+class SlidePersist;
+
+typedef std::shared_ptr< SlidePersist > SlidePersistPtr;
+
+class SlidePersist : public std::enable_shared_from_this< SlidePersist >
+{
+
+public:
+ SlidePersist( oox::core::XmlFilterBase& rFilter, bool bMaster, bool bNotes,
+ const css::uno::Reference< css::drawing::XDrawPage >&,
+ oox::drawingml::ShapePtr const & pShapesPtr, const ::oox::drawingml::TextListStylePtr & );
+ ~SlidePersist();
+
+
+ const css::uno::Reference< css::drawing::XDrawPage >& getPage() const { return mxPage; };
+
+#if OSL_DEBUG_LEVEL > 0
+ static css::uno::WeakReference< css::drawing::XDrawPage > mxDebugPage;
+#endif
+
+ void setMasterPersist( SlidePersistPtr pMasterPersistPtr ){ mpMasterPagePtr = pMasterPersistPtr; }
+ const SlidePersistPtr& getMasterPersist() const { return mpMasterPagePtr; }
+
+ void setPath( const OUString& rPath ) { maPath = rPath; }
+ const OUString& getPath() const { return maPath; }
+
+ void setLayoutPath( const OUString& rLayoutPath ) { maLayoutPath = rLayoutPath; }
+ const OUString& getLayoutPath() const { return maLayoutPath; }
+
+ void setTheme( const oox::drawingml::ThemePtr& rThemePtr ){ mpThemePtr = rThemePtr; }
+ const oox::drawingml::ThemePtr& getTheme() const { return mpThemePtr; }
+
+ void setClrMap( const oox::drawingml::ClrMapPtr pClrMapPtr ){ mpClrMapPtr = pClrMapPtr; }
+ const oox::drawingml::ClrMapPtr& getClrMap() const { return mpClrMapPtr; }
+
+ void setBackgroundProperties( const oox::drawingml::FillPropertiesPtr& rFillPropertiesPtr ){ mpBackgroundPropertiesPtr = rFillPropertiesPtr; }
+ const oox::drawingml::FillPropertiesPtr& getBackgroundProperties() const { return mpBackgroundPropertiesPtr; }
+ oox::drawingml::Color& getBackgroundColor() { return maBackgroundColor; }
+
+ bool isMasterPage() const { return mbMaster; }
+ bool isNotesPage() const { return mbNotes; }
+
+ void setLayoutValueToken( sal_Int32 nLayoutValueToken ) { mnLayoutValueToken = nLayoutValueToken; }
+ sal_Int16 getLayoutFromValueToken() const;
+
+
+ const oox::drawingml::TextListStylePtr& getDefaultTextStyle() const { return maDefaultTextStylePtr; }
+ const oox::drawingml::TextListStylePtr& getTitleTextStyle() const { return maTitleTextStylePtr; }
+ const oox::drawingml::TextListStylePtr& getBodyTextStyle() const { return maBodyTextStylePtr; }
+ const oox::drawingml::TextListStylePtr& getNotesTextStyle() const { return maNotesTextStylePtr; }
+ const oox::drawingml::TextListStylePtr& getOtherTextStyle() const { return maOtherTextStylePtr; }
+
+ const oox::drawingml::ShapePtr& getShapes() const { return maShapesPtr; }
+ void hideShapesAsMasterShapes();
+ ::std::vector< std::shared_ptr< TimeNode > >& getTimeNodeList() { return maTimeNodeList; }
+ oox::ppt::HeaderFooter& getHeaderFooter(){ return maHeaderFooter; };
+
+ oox::vml::Drawing* getDrawing() { return mpDrawingPtr.get(); }
+
+ void createXShapes( oox::core::XmlFilterBase& rFilterBase );
+ void createBackground( const oox::core::XmlFilterBase& rFilterBase );
+ void applyTextStyles( const oox::core::XmlFilterBase& rFilterBase );
+
+ std::map< OUString, css::uno::Reference< css::animations::XAnimationNode > >& getAnimNodesMap() { return maAnimNodesMap; };
+ css::uno::Reference<css::animations::XAnimationNode> getAnimationNode(const OUString& sId) const;
+ ::oox::drawingml::ShapePtr getShape( const OUString & id ) { return maShapeMap[ id ]; }
+ ::oox::drawingml::ShapeIdMap& getShapeMap() { return maShapeMap; }
+
+ CommentList& getCommentsList() { return maCommentsList; }
+ CommentAuthorList& getCommentAuthors() { return maCommentAuthors; }
+
+ void createConnectorShapeConnection();
+
+ void addURLShapeId(const OUString& rShapeId) { maURLShapeId.push_back(rShapeId); }
+ std::vector<OUString>& getURLShapeId() { return maURLShapeId; }
+
+private:
+ OUString maPath;
+ OUString maLayoutPath;
+ std::shared_ptr< oox::vml::Drawing > mpDrawingPtr;
+ css::uno::Reference< css::drawing::XDrawPage > mxPage;
+ oox::drawingml::ThemePtr mpThemePtr; // the theme that is used
+ oox::drawingml::ClrMapPtr mpClrMapPtr; // color mapping (if any)
+ SlidePersistPtr mpMasterPagePtr;
+
+ oox::drawingml::ShapePtr maShapesPtr;
+ oox::drawingml::Color maBackgroundColor;
+ oox::drawingml::FillPropertiesPtr mpBackgroundPropertiesPtr;
+ ::std::vector< std::shared_ptr< TimeNode > > maTimeNodeList;
+
+ oox::ppt::HeaderFooter maHeaderFooter;
+ sal_Int32 mnLayoutValueToken;
+ bool mbMaster;
+ bool mbNotes;
+
+ oox::drawingml::TextListStylePtr maDefaultTextStylePtr;
+ oox::drawingml::TextListStylePtr maTitleTextStylePtr;
+ oox::drawingml::TextListStylePtr maBodyTextStylePtr;
+ oox::drawingml::TextListStylePtr maNotesTextStylePtr;
+ oox::drawingml::TextListStylePtr maOtherTextStylePtr;
+
+ std::map< OUString, css::uno::Reference< css::animations::XAnimationNode > > maAnimNodesMap;
+ std::map< OUString, ::oox::drawingml::ShapePtr > maShapeMap;
+
+ // slide comments
+ CommentList maCommentsList;
+ CommentAuthorList maCommentAuthors;
+
+ std::vector<OUString> maConnectorShapeId;
+ std::vector<OUString> maURLShapeId;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_SLIDEPERSIST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/slidetimingcontext.hxx b/include/oox/ppt/slidetimingcontext.hxx
new file mode 100644
index 000000000..7b147ab85
--- /dev/null
+++ b/include/oox/ppt/slidetimingcontext.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_SLIDETIMINGCONTEXT_HXX
+#define INCLUDED_OOX_PPT_SLIDETIMINGCONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/ppt/timenode.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::ppt {
+
+class SlideTimingContext final : public ::oox::core::FragmentHandler2
+{
+public:
+ SlideTimingContext( ::oox::core::FragmentHandler2 const & rParent, TimeNodePtrList & aTimeNodeList ) noexcept;
+ virtual ~SlideTimingContext() noexcept override;
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+private:
+ TimeNodePtrList & maTimeNodeList;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_SLIDETIMINGCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/slidetransition.hxx b/include/oox/ppt/slidetransition.hxx
new file mode 100644
index 000000000..01603b9fa
--- /dev/null
+++ b/include/oox/ppt/slidetransition.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef INCLUDED_OOX_PPT_SLIDETRANSITION_HXX
+#define INCLUDED_OOX_PPT_SLIDETRANSITION_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/presentation/AnimationSpeed.hpp>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace animations { class XTransitionFilter; }
+}
+
+namespace oox { class PropertyMap; }
+
+namespace oox::ppt {
+
+ class SlideTransition
+ {
+ public:
+ SlideTransition();
+ explicit SlideTransition(std::u16string_view );
+
+ void setSlideProperties( PropertyMap& props );
+ void setTransitionFilterProperties( const css::uno::Reference< css::animations::XTransitionFilter > & xFilter );
+
+ /// Set one of standard values for slide transition duration
+ void setOoxTransitionSpeed( sal_Int32 nToken );
+ /// Set slide transition time directly
+ void setOoxTransitionSpeed( double fDuration );
+ void setMode( bool bMode )
+ { mbMode = bMode; }
+ void setOoxAdvanceTime( sal_Int32 nAdvanceTime )
+ { mnAdvanceTime = nAdvanceTime; }
+
+ static sal_Int16 ooxToOdpDirection( ::sal_Int32 nOoxType );
+ static sal_Int16 ooxToOdpEightDirections( ::sal_Int32 nOoxType );
+ static sal_Int16 ooxToOdpCornerDirections( ::sal_Int32 nOoxType );
+ static sal_Int16 ooxToOdpBorderDirections( ::sal_Int32 nOoxType );
+ static sal_Int16 ooxToOdpSideDirections( ::sal_Int32 nOoxType );
+ static bool ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType );
+
+ void setOoxTransitionType( ::sal_Int32 OoxType,
+ ::sal_Int32 param1, ::sal_Int32 param2 );
+
+ void setPresetTransition(std::u16string_view sPresetTransition);
+
+ private:
+ ::sal_Int16 mnTransitionType;
+ ::sal_Int16 mnTransitionSubType;
+ bool mbTransitionDirectionNormal;
+ css::presentation::AnimationSpeed mnAnimationSpeed;
+ double mfTransitionDurationInSeconds;
+ bool mbMode; /**< https://api.libreoffice.org/docs/common/ref/com/sun/star/animations/XTransitionFilter.html Mode property */
+ ::sal_Int32 mnAdvanceTime;
+ ::sal_Int32 mnTransitionFadeColor;
+ };
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/slidetransitioncontext.hxx b/include/oox/ppt/slidetransitioncontext.hxx
new file mode 100644
index 000000000..f28b763c6
--- /dev/null
+++ b/include/oox/ppt/slidetransitioncontext.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_SLIDETRANSITIONCONTEXT_HXX
+#define INCLUDED_OOX_PPT_SLIDETRANSITIONCONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/ppt/slidetransition.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class AttributeList;
+ class PropertyMap;
+}
+
+namespace oox::ppt {
+
+ class SlideTransitionContext final : public ::oox::core::FragmentHandler2
+ {
+ public:
+ SlideTransitionContext( ::oox::core::FragmentHandler2 const & rParent,
+ const AttributeList& rAttributes,
+ PropertyMap & aProperties ) noexcept;
+ virtual ~SlideTransitionContext() noexcept override;
+
+ virtual void onEndElement() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+
+ private:
+ PropertyMap& maSlideProperties;
+ bool mbHasTransition;
+ bool mbHasTransitionDuration;
+ SlideTransition maTransition;
+ };
+
+}
+
+#endif // INCLUDED_OOX_PPT_SLIDETRANSITIONCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/soundactioncontext.hxx b/include/oox/ppt/soundactioncontext.hxx
new file mode 100644
index 000000000..4bf66a5f7
--- /dev/null
+++ b/include/oox/ppt/soundactioncontext.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef INCLUDED_OOX_PPT_SOUNDACTIONCONTEXT_HXX
+#define INCLUDED_OOX_PPT_SOUNDACTIONCONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class AttributeList;
+ class PropertyMap;
+}
+
+namespace oox::ppt {
+
+class SoundActionContext final : public ::oox::core::FragmentHandler2
+{
+public:
+ SoundActionContext( ::oox::core::FragmentHandler2 const & rParent, PropertyMap & aProperties ) noexcept;
+ virtual ~SoundActionContext() noexcept override;
+
+ virtual void onEndElement() override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+private:
+ PropertyMap& maSlideProperties;
+ bool mbHasStartSound;
+ bool mbLoopSound;
+ bool mbStopSound;
+ OUString msSndName;
+};
+
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/timenode.hxx b/include/oox/ppt/timenode.hxx
new file mode 100644
index 000000000..195e4472e
--- /dev/null
+++ b/include/oox/ppt/timenode.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef INCLUDED_OOX_PPT_TIMENODE_HXX
+#define INCLUDED_OOX_PPT_TIMENODE_HXX
+
+#include <vector>
+#include <map>
+#include <memory>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/ppt/slidetransition.hxx>
+#include <oox/ppt/slidepersist.hxx>
+#include <oox/ppt/animationspersist.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace animations { class XAnimationNode; }
+}
+
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::ppt {
+
+ class TimeNode;
+
+ typedef std::shared_ptr< TimeNode > TimeNodePtr;
+ typedef std::vector< TimeNodePtr > TimeNodePtrList;
+
+ class TimeNode final
+ {
+ public:
+ typedef ::std::map< OUString, css::uno::Any > UserDataMap;
+
+ TimeNode( sal_Int16 nNodeType );
+ ~TimeNode();
+
+ NodePropertyMap & getNodeProperties() { return maNodeProperties; }
+ UserDataMap & getUserData() { return maUserData; }
+ TimeNodePtrList & getChildren()
+ { return maChildren; }
+
+ void setId( sal_Int32 nId );
+
+ void addNode(
+ const ::oox::core::XmlFilterBase& rFilter,
+ const css::uno::Reference< css::animations::XAnimationNode >& rxNode,
+ const SlidePersistPtr & slide);
+ // data setters
+ void setTo( const css::uno::Any & aTo );
+ void setFrom( const css::uno::Any & aFrom );
+ void setBy( const css::uno::Any & aBy );
+ void setTransitionFilter( const SlideTransition & aTransition)
+ { maTransitionFilter = aTransition; }
+
+ void setNode(
+ const ::oox::core::XmlFilterBase& rFilter,
+ const css::uno::Reference< css::animations::XAnimationNode >& xNode,
+ const SlidePersistPtr & pSlide,
+ const css::uno::Reference< css::animations::XAnimationNode >& xParent);
+
+ AnimTargetElementPtr const & getTarget()
+ {
+ if( !mpTarget )
+ mpTarget = std::make_shared<AnimTargetElement>();
+ return mpTarget;
+ }
+
+ AnimationConditionList &getStartCondition()
+ { return maStCondList; }
+ AnimationConditionList &getEndCondition()
+ { return maEndCondList; }
+ AnimationConditionList &getNextCondition()
+ { return maNextCondList; }
+ AnimationConditionList &getPrevCondition()
+ { return maPrevCondList; }
+ AnimationCondition & getEndSyncValue()
+ { mbHasEndSyncValue = true; return maEndSyncValue; }
+ private:
+
+ static OUString getServiceName( sal_Int16 nNodeType );
+
+ static css::uno::Reference< css::animations::XAnimationNode >
+ createAndInsert(
+ const ::oox::core::XmlFilterBase& rFilter,
+ const OUString& rServiceName,
+ const css::uno::Reference< css::animations::XAnimationNode >& rxNode );
+
+ const sal_Int16 mnNodeType;
+
+ TimeNodePtrList maChildren;
+
+ OUString msId;
+ NodePropertyMap maNodeProperties;
+ UserDataMap maUserData; // a sequence to be stored as "UserData" property
+ SlideTransition maTransitionFilter;
+ AnimTargetElementPtr mpTarget;
+ bool mbHasEndSyncValue; // set to true if we try to get the endSync.
+ AnimationCondition maEndSyncValue;
+ AnimationConditionList maStCondList, maEndCondList;
+ AnimationConditionList maPrevCondList, maNextCondList;
+ };
+
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/ppt/timenodelistcontext.hxx b/include/oox/ppt/timenodelistcontext.hxx
new file mode 100644
index 000000000..82e7e67b9
--- /dev/null
+++ b/include/oox/ppt/timenodelistcontext.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_PPT_TIMENODELISTCONTEXT_HXX
+#define INCLUDED_OOX_PPT_TIMENODELISTCONTEXT_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/ppt/timenode.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace xml::sax { class XFastAttributeList; }
+}
+
+namespace oox { class AttributeList; }
+
+namespace oox::ppt {
+
+
+ class TimeNodeContext : public ::oox::core::FragmentHandler2
+ {
+ public:
+ virtual ~TimeNodeContext() noexcept override;
+
+ static rtl::Reference<TimeNodeContext> makeContext( ::oox::core::FragmentHandler2 const & rParent, sal_Int32 aElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode );
+
+ protected:
+ TimeNodeContext( ::oox::core::FragmentHandler2 const & rParent, sal_Int32 aElement, const TimeNodePtr & pNode ) noexcept;
+
+ sal_Int32 mnElement;
+ TimeNodePtr mpNode;
+ };
+
+
+/** FastParser context for XML_tnLst, XML_subTnLst and XML_childTnLst */
+class TimeNodeListContext final : public ::oox::core::FragmentHandler2
+{
+public:
+ TimeNodeListContext( ::oox::core::FragmentHandler2 const & rParent, TimeNodePtrList & aList ) noexcept;
+
+ virtual ~TimeNodeListContext() noexcept override;
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override;
+
+
+private:
+ TimeNodePtrList & maList;
+};
+
+}
+
+#endif // INCLUDED_OOX_PPT_TIMENODELISTCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/shape/ShapeContextHandler.hxx b/include/oox/shape/ShapeContextHandler.hxx
new file mode 100644
index 000000000..2e108d8cd
--- /dev/null
+++ b/include/oox/shape/ShapeContextHandler.hxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <memory>
+#include <stack>
+#include <cppuhelper/implbase.hxx>
+#include <oox/drawingml/graphicshapecontext.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/core/xmlfilterbase.hxx>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/graphic/XGraphicMapper.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+namespace oox::shape {
+
+class ShapeFilterBase;
+
+class ShapeFragmentHandler final : public core::FragmentHandler2
+{
+public:
+ typedef rtl::Reference<ShapeFragmentHandler> Pointer_t;
+
+ explicit ShapeFragmentHandler(core::XmlFilterBase& rFilter,
+ const OUString& rFragmentPath )
+ : FragmentHandler2(rFilter, rFragmentPath)
+ {
+ }
+};
+
+class OOX_DLLPUBLIC ShapeContextHandler final :
+ public ::cppu::WeakImplHelper< css::xml::sax::XFastContextHandler >
+{
+public:
+ explicit ShapeContextHandler(const rtl::Reference<ShapeFilterBase>& xFilterBase);
+
+ virtual ~ShapeContextHandler() override;
+
+ // css::xml::sax::XFastContextHandler:
+ virtual void SAL_CALL startFastElement
+ (::sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
+
+ virtual void SAL_CALL startUnknownElement
+ (const OUString & Namespace,
+ const OUString & Name,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
+
+ virtual void SAL_CALL endFastElement(::sal_Int32 Element) override;
+
+ virtual void SAL_CALL endUnknownElement
+ (const OUString & Namespace,
+ const OUString & Name) override;
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
+ createFastChildContext
+ (::sal_Int32 Element,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
+
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
+ createUnknownChildContext
+ (const OUString & Namespace,
+ const OUString & Name,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
+
+ virtual void SAL_CALL characters(const OUString & aChars) override;
+
+ css::uno::Reference< css::drawing::XShape > getShape();
+
+ void setDrawPage(const css::uno::Reference< css::drawing::XDrawPage > & the_value);
+
+ void setModel(const css::uno::Reference< css::frame::XModel > & the_value);
+
+ void setRelationFragmentPath(const OUString & the_value);
+
+ sal_Int32 getStartToken() const;
+ void popStartToken();
+ void pushStartToken( sal_Int32 _starttoken );
+
+ void setPosition(const css::awt::Point& rPosition);
+
+ const bool& getFullWPGSupport() { return m_bFullWPGSUpport; }
+ void setFullWPGSupport(bool bUse) { m_bFullWPGSUpport = bUse; }
+
+ bool isWordProcessingGroupShape() const { return mxWpgContext ? true : false; }
+
+ void setDocumentProperties(const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
+ void setMediaDescriptor(const css::uno::Sequence<css::beans::PropertyValue>& rMediaDescriptor);
+
+ void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rGraphicMapper);
+
+ void setTheme(const oox::drawingml::ThemePtr& pTheme) { mpThemePtr = pTheme; }
+ const oox::drawingml::ThemePtr& getTheme() const { return mpThemePtr; }
+
+private:
+ ShapeContextHandler(ShapeContextHandler const &) = delete;
+ void operator =(ShapeContextHandler const &) = delete;
+
+ // Special stack which always has at least one element.
+ // In case of group shapes with embedded content it will have more element than one.
+ std::stack<sal_uInt32> mnStartTokenStack;
+
+ css::awt::Point maPosition;
+ bool m_bFullWPGSUpport; // Is this DrawingML shape supposed to be processed as WPG?
+
+ drawingml::ShapePtr mpShape;
+ std::shared_ptr< vml::Drawing > mpDrawing;
+
+ typedef rtl::Reference<drawingml::GraphicShapeContext>
+ GraphicShapeContextPtr;
+ css::uno::Reference<XFastContextHandler> mxDrawingFragmentHandler;
+ css::uno::Reference<XFastContextHandler> mxGraphicShapeContext;
+ css::uno::Reference<XFastContextHandler> mxDiagramShapeContext;
+ css::uno::Reference<XFastContextHandler> mxLockedCanvasContext;
+ css::uno::Reference<XFastContextHandler> mxWpsContext;
+ css::uno::Reference<css::drawing::XShape> mxSavedShape;
+ css::uno::Reference<XFastContextHandler> mxWpgContext;
+ css::uno::Reference<XFastContextHandler> mxChartShapeContext;
+ css::uno::Reference<css::document::XDocumentProperties> mxDocumentProperties;
+ css::uno::Sequence<css::beans::PropertyValue> maMediaDescriptor;
+
+ ::rtl::Reference< ShapeFilterBase > mxShapeFilterBase;
+ drawingml::ThemePtr mpThemePtr;
+ css::uno::Reference<css::drawing::XDrawPage> mxDrawPage;
+ OUString msRelationFragmentPath;
+
+ css::uno::Reference<XFastContextHandler> const & getGraphicShapeContext(::sal_Int32 Element);
+ css::uno::Reference<XFastContextHandler> const & getChartShapeContext(::sal_Int32 Element);
+ css::uno::Reference<XFastContextHandler> const & getDrawingShapeContext();
+ css::uno::Reference<XFastContextHandler> const & getDiagramShapeContext();
+ css::uno::Reference<XFastContextHandler> const & getLockedCanvasContext(sal_Int32 nElement);
+ css::uno::Reference<XFastContextHandler> const & getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement);
+ css::uno::Reference<XFastContextHandler> const & getWpgContext(sal_Int32 nElement);
+ css::uno::Reference<XFastContextHandler> getContextHandler(sal_Int32 nElement = 0);
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/shape/ShapeFilterBase.hxx b/include/oox/shape/ShapeFilterBase.hxx
new file mode 100644
index 000000000..477060fa6
--- /dev/null
+++ b/include/oox/shape/ShapeFilterBase.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_SHAPE_SHAPEFILTERBASE_HXX
+#define INCLUDED_OOX_SHAPE_SHAPEFILTERBASE_HXX
+
+#include <memory>
+#include <oox/dllapi.h>
+#include <oox/vml/vmldrawing.hxx>
+#include <oox/core/xmlfilterbase.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <com/sun/star/graphic/XGraphicMapper.hpp>
+#include <rtl/ref.hxx>
+#include <tools/color.hxx>
+
+namespace oox::drawingml::table {
+
+class TableStyleList;
+typedef std::shared_ptr< TableStyleList > TableStyleListPtr;
+
+}
+
+namespace oox::shape {
+
+class OOX_DLLPUBLIC ShapeFilterBase final : public core::XmlFilterBase
+{
+public:
+ typedef rtl::Reference<ShapeFilterBase> Pointer_t;
+
+ /// @throws css::uno::RuntimeException
+ explicit ShapeFilterBase(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+
+ virtual ~ShapeFilterBase() override;
+
+ /** Has to be implemented by each filter, returns the current theme. */
+ virtual const ::oox::drawingml::Theme* getCurrentTheme() const override;
+
+ /** May be implemented by filters which handle Diagrams, default returns empty ptr */
+ virtual std::shared_ptr<::oox::drawingml::Theme> getCurrentThemePtr() const override;
+
+ void setCurrentTheme(const ::oox::drawingml::ThemePtr& pTheme);
+
+ /** Has to be implemented by each filter to return the collection of VML shapes. */
+ virtual ::oox::vml::Drawing* getVmlDrawing() override;
+
+ /** Has to be implemented by each filter to return TableStyles. */
+ virtual ::oox::drawingml::table::TableStyleListPtr getTableStyles() override;
+
+ virtual ::oox::drawingml::chart::ChartConverter* getChartConverter() override;
+
+ virtual bool importDocument() override { return true; }
+ virtual bool exportDocument() override { return true; }
+
+ ::Color getSchemeColor( sal_Int32 nToken ) const;
+
+ void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rxGraphicMapper)
+ {
+ mxGraphicMapper = rxGraphicMapper;
+ }
+
+private:
+ virtual ::oox::ole::VbaProject* implCreateVbaProject() const override;
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual GraphicHelper* implCreateGraphicHelper() const override;
+
+ std::shared_ptr< ::oox::drawingml::chart::ChartConverter > mxChartConv;
+ ::oox::drawingml::ThemePtr mpTheme;
+ css::uno::Reference<css::graphic::XGraphicMapper> mxGraphicMapper;
+};
+
+} // namespace oox::shape
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/token/namespacemap.hxx b/include/oox/token/namespacemap.hxx
new file mode 100644
index 000000000..c02a39ba7
--- /dev/null
+++ b/include/oox/token/namespacemap.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_TOKEN_NAMESPACEMAP_HXX
+#define INCLUDED_OOX_TOKEN_NAMESPACEMAP_HXX
+
+#include <map>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox
+{
+/** A map that contains all XML namespace URLs used in the filters. */
+struct NamespaceMap
+{
+ std::map<sal_Int32, OUString> maTransitionalNamespaceMap;
+ std::map<sal_Int32, OUString> maStrictNamespaceMap;
+
+ NamespaceMap();
+
+ typedef std::map<sal_Int32, OUString>::iterator iterator;
+ typedef std::map<sal_Int32, OUString>::const_iterator const_iterator;
+};
+
+/** Thread-safe singleton of a map of all supported XML namespace URLs. */
+NamespaceMap& StaticNamespaceMap();
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/token/propertynames.hxx b/include/oox/token/propertynames.hxx
new file mode 100644
index 000000000..91e07cbdd
--- /dev/null
+++ b/include/oox/token/propertynames.hxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <vector>
+
+#include <rtl/ustring.hxx>
+
+namespace oox
+{
+/** A vector that contains all predefined property names used in the filters. */
+/** Thread-safe singleton of a vector of all supported property names. */
+const std::vector<OUString>& GetPropertyNameVector();
+
+} // namespace oox
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/token/relationship.hxx b/include/oox/token/relationship.hxx
new file mode 100644
index 000000000..3c3a4336f
--- /dev/null
+++ b/include/oox/token/relationship.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_OOX_TOKEN_RELATIONSHIP_HXX
+#define INCLUDED_OOX_TOKEN_RELATIONSHIP_HXX
+
+#include <oox/dllapi.h>
+
+#include <rtl/ustring.hxx>
+
+namespace oox
+{
+enum class Relationship
+{
+ ACTIVEXCONTROLBINARY,
+ CHART,
+ CHARTUSERSHAPES,
+ COMMENTS,
+ COMMENTAUTHORS,
+ COMMENTSEXTENDED,
+ CONTROL,
+ CTRLPROP,
+ CUSTOMXML,
+ CUSTOMXMLPROPS,
+ DIAGRAMCOLORS,
+ DIAGRAMDATA,
+ DIAGRAMDRAWING,
+ DIAGRAMLAYOUT,
+ DIAGRAMQUICKSTYLE,
+ DRAWING,
+ ENDNOTES,
+ EXTERNALLINKPATH,
+ FONT,
+ FONTTABLE,
+ FOOTER,
+ FOOTNOTES,
+ GLOSSARYDOCUMENT,
+ HDPHOTO,
+ HEADER,
+ HYPERLINK,
+ IMAGE,
+ MEDIA,
+ NOTESMASTER,
+ NOTESSLIDE,
+ NUMBERING,
+ OFFICEDOCUMENT,
+ OLEOBJECT,
+ PACKAGE,
+ PRESPROPS,
+ SETTINGS,
+ SHAREDSTRINGS,
+ SLIDE,
+ SLIDELAYOUT,
+ SLIDEMASTER,
+ STYLES,
+ THEME,
+ VBAPROJECT,
+ VIDEO,
+ AUDIO,
+ VMLDRAWING,
+ WORDVBADATA,
+ WORKSHEET
+};
+
+OUString OOX_DLLPUBLIC getRelationship(Relationship eRelationship);
+}
+
+#endif // INCLUDED_OOX_TOKEN_RELATIONSHIP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/token/tokenmap.hxx b/include/oox/token/tokenmap.hxx
new file mode 100644
index 000000000..db71c24c2
--- /dev/null
+++ b/include/oox/token/tokenmap.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_TOKEN_TOKENMAP_HXX
+#define INCLUDED_OOX_TOKEN_TOKENMAP_HXX
+
+#include <sal/config.h>
+
+#include <string_view>
+#include <vector>
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <oox/token/tokens.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/log.hxx>
+#include <sal/types.h>
+
+namespace oox {
+
+
+class TokenMap
+{
+public:
+ explicit TokenMap();
+ ~TokenMap();
+
+ /** Returns the token identifier for the passed Unicode token name. */
+ static sal_Int32 getTokenFromUnicode( std::u16string_view rUnicodeName );
+
+ /** Returns the UTF8 name of the passed token identifier as byte sequence. */
+ css::uno::Sequence< sal_Int8 > const &
+ getUtf8TokenName( sal_Int32 nToken ) const
+ {
+ SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "oox", "Wrong nToken parameter");
+ if (0 <= nToken && nToken < XML_TOKEN_COUNT)
+ return maTokenNames[ nToken ];
+ return EMPTY_BYTE_SEQ;
+ }
+
+ /** Returns the token identifier for the passed UTF8 token name. */
+ sal_Int32 getTokenFromUtf8(
+ const css::uno::Sequence< sal_Int8 >& rUtf8Name ) const
+ {
+ return getTokenFromUTF8( reinterpret_cast< const char * >(
+ rUtf8Name.getConstArray() ),
+ rUtf8Name.getLength() );
+ }
+
+ /** Returns the token identifier for a UTF8 string passed in pToken */
+ sal_Int32 getTokenFromUTF8( const char *pToken, sal_Int32 nLength ) const
+ {
+ // 50% of OOXML tokens are primarily 1 lower-case character, a-z
+ if( nLength == 1)
+ {
+ char c = pToken[0];
+ if (c >= 'a' && c <= 'z')
+ return mnAlphaTokens[ c - 'a' ];
+ }
+ return getTokenPerfectHash( pToken, nLength );
+ }
+
+private:
+ static sal_Int32 getTokenPerfectHash( const char *pToken, sal_Int32 nLength );
+ static const css::uno::Sequence< sal_Int8 > EMPTY_BYTE_SEQ;
+
+ std::vector< css::uno::Sequence< sal_Int8 > >
+ maTokenNames;
+ sal_Int32 mnAlphaTokens[26];
+};
+
+
+TokenMap& StaticTokenMap();
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmldrawing.hxx b/include/oox/vml/vmldrawing.hxx
new file mode 100644
index 000000000..a11bfef0d
--- /dev/null
+++ b/include/oox/vml/vmldrawing.hxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLDRAWING_HXX
+#define INCLUDED_OOX_VML_VMLDRAWING_HXX
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/ole/oleobjecthelper.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace awt { struct Rectangle; }
+ namespace drawing { class XDrawPage; }
+ namespace drawing { class XShape; }
+ namespace drawing { class XShapes; }
+}
+
+namespace oox {
+ namespace core { class XmlFilterBase; }
+ namespace ole { class EmbeddedControl; }
+ namespace ole { class EmbeddedForm; }
+ namespace vml { class ShapeContainer; }
+}
+
+namespace oox::vml {
+
+class ShapeBase;
+
+
+/** Enumerates different types of VML drawings. */
+enum DrawingType
+{
+ VMLDRAWING_WORD, ///< Word: One shape per drawing.
+ VMLDRAWING_EXCEL, ///< Excel: OLE objects are part of VML.
+ VMLDRAWING_POWERPOINT ///< PowerPoint: OLE objects are part of DrawingML.
+};
+
+
+/** Contains information about an OLE object embedded in a draw page. */
+struct OOX_DLLPUBLIC OleObjectInfo : public ::oox::ole::OleObjectInfo
+{
+ OUString maShapeId; ///< Shape identifier for shape lookup.
+ OUString maName; ///< Programmatical name of the OLE object.
+ bool mbAutoLoad;
+ const bool mbDmlShape; ///< True = DrawingML shape (PowerPoint), false = VML shape (Excel/Word).
+
+ explicit OleObjectInfo( bool bDmlShape = false );
+
+ /** Sets the string representation of the passed numeric shape identifier. */
+ void setShapeId( sal_Int32 nShapeId );
+};
+
+// =========================================/===================================
+
+/** Contains information about a form control embedded in a draw page. */
+struct OOX_DLLPUBLIC ControlInfo
+{
+ OUString maShapeId; ///< Shape identifier for shape lookup.
+ OUString maFragmentPath; ///< Path to the fragment describing the form control properties.
+ OUString maName; ///< Programmatical name of the form control.
+ bool mbTextContentShape; ///< Whether this control shape will be imported to Writer or not (has AnchorType property or not).
+
+ explicit ControlInfo();
+
+ /** Sets the string representation of the passed numeric shape identifier. */
+ void setShapeId( sal_Int32 nShapeId );
+};
+
+
+/** Represents the collection of VML shapes for a complete draw page. */
+class OOX_DLLPUBLIC Drawing
+{
+public:
+ explicit Drawing(
+ ::oox::core::XmlFilterBase& rFilter,
+ const css::uno::Reference< css::drawing::XDrawPage >& rxDrawPage,
+ DrawingType eType );
+
+ virtual ~Drawing();
+
+ /** Returns the filter object that imports/exports this VML drawing. */
+ ::oox::core::XmlFilterBase& getFilter() const { return mrFilter; }
+ /** Returns the application type containing the drawing. */
+ DrawingType getType() const { return meType; }
+ /** Returns read/write access to the container of shapes and templates. */
+ ShapeContainer& getShapes() { return *mxShapes; }
+ /** Returns read access to the container of shapes and templates. */
+ const ShapeContainer& getShapes() const { return *mxShapes; }
+ /** Returns the form object used to process ActiveX form controls. */
+ ::oox::ole::EmbeddedForm& getControlForm() const;
+
+ /** Registers a block of shape identifiers reserved by this drawing. Block
+ size is 1024, shape identifiers are one-based (block 1 => 1025-2048). */
+ void registerBlockId( sal_Int32 nBlockId );
+ /** Registers the passed embedded OLE object. The related shape will then
+ load the OLE object data from the specified fragment. */
+ void registerOleObject( const OleObjectInfo& rOleObject );
+ /** Registers the passed embedded form control. The related shape will then
+ load the control properties from the specified fragment. */
+ void registerControl( const ControlInfo& rControl );
+
+ /** Final processing after import of the fragment. */
+ void finalizeFragmentImport();
+
+ /** Creates and inserts all UNO shapes into the draw page. The virtual
+ function notifyXShapeInserted() will be called for each new shape. */
+ void convertAndInsert() const;
+
+ /** Returns the local shape index from the passed global shape identifier. */
+ sal_Int32 getLocalShapeIndex( const OUString& rShapeId ) const;
+ /** Returns the registered info structure for an OLE object, if extant. */
+ const OleObjectInfo* getOleObjectInfo( const OUString& rShapeId ) const;
+ /** Returns the registered info structure for a form control, if extant. */
+ const ControlInfo* getControlInfo( const OUString& rShapeId ) const;
+
+ /** Creates a new UNO shape object, inserts it into the passed UNO shape
+ container, and sets the shape position and size. */
+ css::uno::Reference< css::drawing::XShape >
+ createAndInsertXShape(
+ const OUString& rService,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const;
+
+ /** Creates a new UNO shape object for a form control, inserts the control
+ model into the form, and the shape into the passed UNO shape container. */
+ css::uno::Reference< css::drawing::XShape >
+ createAndInsertXControlShape(
+ const ::oox::ole::EmbeddedControl& rControl,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect,
+ sal_Int32& rnCtrlIndex ) const;
+
+ /** Derived classes may disable conversion of specific shapes. */
+ virtual bool isShapeSupported( const ShapeBase& rShape ) const;
+
+ /** Derived classes may return additional base names for automatic shape
+ name creation. */
+ virtual OUString getShapeBaseName( const ShapeBase& rShape ) const;
+
+ /** Derived classes may calculate the shape rectangle from a non-standard
+ anchor information string. */
+ virtual bool convertClientAnchor(
+ css::awt::Rectangle& orShapeRect,
+ const OUString& rShapeAnchor ) const;
+
+ /** Derived classes create a UNO shape according to the passed shape model.
+ Called for shape models that specify being under host control. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ createAndInsertClientXShape(
+ const ShapeBase& rShape,
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const;
+
+ /** Derived classes may want to know that a UNO shape has been inserted.
+ Will be called from the convertAndInsert() implementation.
+ @param bGroupChild True = inserted into a group shape,
+ false = inserted directly into this drawing. */
+ virtual void notifyXShapeInserted(
+ const css::uno::Reference< css::drawing::XShape >& rxShape,
+ const css::awt::Rectangle& rShapeRect,
+ const ShapeBase& rShape, bool bGroupChild );
+
+private:
+ typedef ::std::vector< sal_Int32 > BlockIdVector;
+ typedef ::std::map< OUString, OleObjectInfo > OleObjectInfoMap;
+ typedef ::std::map< OUString, ControlInfo > ControlInfoMap;
+
+ ::oox::core::XmlFilterBase& mrFilter; ///< Filter object that imports/exports the VML drawing.
+ css::uno::Reference< css::drawing::XDrawPage >
+ mxDrawPage; ///< UNO draw page used to insert the shapes.
+ mutable std::unique_ptr<::oox::ole::EmbeddedForm> mxCtrlForm; ///< The control form used to process embedded controls.
+ mutable BlockIdVector maBlockIds; ///< Block identifiers used by this drawing.
+ std::unique_ptr<ShapeContainer> mxShapes; ///< All shapes and shape templates.
+ OleObjectInfoMap maOleObjects; ///< Info about all embedded OLE objects, mapped by shape id.
+ ControlInfoMap maControls; ///< Info about all embedded form controls, mapped by control name.
+ const DrawingType meType; ///< Application type containing the drawing.
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmldrawingfragment.hxx b/include/oox/vml/vmldrawingfragment.hxx
new file mode 100644
index 000000000..f7fa4d0bd
--- /dev/null
+++ b/include/oox/vml/vmldrawingfragment.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLDRAWINGFRAGMENT_HXX
+#define INCLUDED_OOX_VML_VMLDRAWINGFRAGMENT_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/fragmenthandler2.hxx>
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XInputStream; }
+}
+
+namespace oox { class AttributeList; }
+namespace oox::core { class XmlFilterBase; }
+
+namespace oox::vml {
+
+class Drawing;
+
+
+class OOX_DLLPUBLIC DrawingFragment : public ::oox::core::FragmentHandler2
+{
+public:
+ explicit DrawingFragment(
+ ::oox::core::XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ Drawing& rDrawing );
+
+ virtual css::uno::Reference< css::io::XInputStream >
+ openFragmentStream() const override;
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+ virtual void finalizeImport() override;
+
+private:
+ Drawing& mrDrawing;
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx
new file mode 100644
index 000000000..3f7bbe60a
--- /dev/null
+++ b/include/oox/vml/vmlformatting.hxx
@@ -0,0 +1,285 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLFORMATTING_HXX
+#define INCLUDED_OOX_VML_VMLFORMATTING_HXX
+
+#include <sal/config.h>
+
+#include <string_view>
+#include <utility>
+#include <vector>
+
+#include <com/sun/star/drawing/PolygonFlags.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/helper.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <tools/degree.hxx>
+
+namespace com::sun::star {
+ namespace awt { struct Point; }
+ namespace drawing { class XShape; }
+}
+
+namespace oox {
+ class GraphicHelper;
+ namespace drawingml { class Color; }
+ namespace drawingml { class ShapePropertyMap; }
+}
+
+namespace oox::vml {
+
+
+typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair;
+typedef ::std::pair< double, double > DoublePair;
+
+
+namespace ConversionHelper
+{
+ /** Returns two values contained in rValue separated by cSep.
+ */
+ OOX_DLLPUBLIC bool separatePair(
+ std::u16string_view& orValue1, std::u16string_view& orValue2,
+ std::u16string_view rValue, sal_Unicode cSep );
+
+ /** Returns the boolean value from the passed string of a VML attribute.
+ Supported values: 'f', 't', 'false', 'true'. False for anything else.
+ */
+ OOX_DLLPUBLIC bool decodeBool( std::u16string_view rValue );
+
+ /** Converts the passed VML percentage measure string to a normalized
+ floating-point value.
+
+ @param rValue The VML percentage value. This is a floating-point value
+ with optional following '%' or 'f' sign. If the sign is missing, the
+ floating point value will be returned unmodified. If the '%' sign
+ is present, the value will be divided by 100. If the 'f' sign is present,
+ the value will be divided by 65536.
+ */
+ OOX_DLLPUBLIC double decodePercent(
+ std::u16string_view rValue,
+ double fDefValue );
+
+ /** Converts the passed VML rotation value to degrees.
+ See DffPropertyReader::Fix16ToAngle(): in VML, positive rotation
+ angles are clockwise, we have them as counter-clockwise.
+ Additionally, VML type is 0..360, our is 0..36000.
+
+ @param rValue The VML rotation value. This is a floating-point value
+ with optional 'fd' suffix. If the suffix is missing, the floating
+ point value will be returned unmodified. If the 'fd' suffix is
+ present, the value will be divided by 65536.
+ */
+ OOX_DLLPUBLIC Degree100 decodeRotation( std::u16string_view rValue );
+
+ /** Converts the passed VML measure string to EMU (English Metric Units).
+
+ @param rGraphicHelper The graphic helper needed to perform pixel
+ conversion according to the current output device.
+
+ @param rValue The VML measure value. This is a floating-point value
+ with optional measure string following the value.
+
+ @param nRefValue Reference value needed for percentage measure.
+
+ @param bPixelX Set to true if the value is oriented horizontally (e.g.
+ X coordinates, widths). Set to false if the value is oriented
+ vertically (e.g. Y coordinates, heights). This is needed because
+ output devices may specify different width and height for a pixel.
+
+ @param bDefaultAsPixel Set to true if omitted measure unit means
+ pixel. Set to false if omitted measure unit means EMU.
+ */
+ OOX_DLLPUBLIC sal_Int64 decodeMeasureToEmu(
+ const GraphicHelper& rGraphicHelper,
+ std::u16string_view rValue,
+ sal_Int32 nRefValue,
+ bool bPixelX,
+ bool bDefaultAsPixel );
+
+ /** Converts the passed VML measure string to 1/100 mm.
+
+ @param rGraphicHelper See above.
+ @param rValue See above.
+ @param nRefValue See above.
+ @param bPixelX See above.
+ @param bDefaultAsPixel See above.
+ */
+ OOX_DLLPUBLIC sal_Int32 decodeMeasureToHmm(
+ const GraphicHelper& rGraphicHelper,
+ std::u16string_view rValue,
+ sal_Int32 nRefValue,
+ bool bPixelX,
+ bool bDefaultAsPixel );
+
+/** Converts the passed VML measure string to Twip.
+
+ @param rGraphicHelper See above.
+ @param rValue See above.
+ @param nRefValue See above.
+ @param bPixelX See above.
+ @param bDefaultAsPixel See above.
+ */
+OOX_DLLPUBLIC sal_Int32 decodeMeasureToTwip(const GraphicHelper& rGraphicHelper,
+ std::u16string_view rValue, sal_Int32 nRefValue,
+ bool bPixelX, bool bDefaultAsPixel);
+
+ /** Converts VML color attributes to a DrawingML color.
+
+ @param roVmlColor The VML string representation of the color. If
+ existing, this can be a 3-digit or 6-digit hexadecimal RGB value
+ with leading '#' character, a predefined color name (e.g. 'black',
+ 'red', etc.), the index into an application defined color palette
+ in brackets with leading color name (e.g. 'red [9]' or
+ 'windowColor [64]'), or a color modifier used in one-color
+ gradients (e.g. 'fill darken(128)' or 'fill lighten(0)').
+
+ @param roVmlOpacity The opacity of the color. If existing, this should
+ be a floating-point value in the range [0.0;1.0].
+
+ @param nDefaultRgb Default RGB color used if the parameter roVmlColor
+ is empty.
+
+ @param nPrimaryRgb If set to something else than API_RGB_TRANSPARENT,
+ specifies the color to be used to resolve the color modifiers used
+ in one-color gradients.
+
+ @return The resulting DrawingML color.
+ */
+ OOX_DLLPUBLIC ::oox::drawingml::Color decodeColor(
+ const GraphicHelper& rGraphicHelper,
+ const OptValue< OUString >& roVmlColor,
+ const OptValue< double >& roVmlOpacity,
+ ::Color nDefaultRgb,
+ ::Color nPrimaryRgb = API_RGB_TRANSPARENT );
+
+ /** Converts VML path string into point and flag vectors.
+
+ @param rPoints The point vector to fill with coordinates.
+
+ @param rFlags The flag vector to fill. PolygonFlags_NORMAL indicates
+ a corresponding plain shape coordinate in rPoints and
+ PolygonFlags_CONTROL indicates a bezier curve control point.
+
+ @param rPath The VML path string.
+
+ @param rGraphicHelper See above.
+ */
+ OOX_DLLPUBLIC void decodeVmlPath(
+ ::std::vector< ::std::vector< css::awt::Point > >& rPoints,
+ ::std::vector< ::std::vector< css::drawing::PolygonFlags > >& rFlags,
+ const OUString& rPath );
+}
+
+
+/** The stroke arrow model structure contains all properties for a line end arrow. */
+struct StrokeArrowModel
+{
+ OptValue< sal_Int32 > moArrowType;
+ OptValue< sal_Int32 > moArrowWidth;
+ OptValue< sal_Int32 > moArrowLength;
+
+ void assignUsed( const StrokeArrowModel& rSource );
+};
+
+
+/** The stroke model structure contains all shape border properties. */
+struct StrokeModel
+{
+ OptValue< bool > moStroked; ///< Shape border line on/off.
+ StrokeArrowModel maStartArrow; ///< Start line arrow style.
+ StrokeArrowModel maEndArrow; ///< End line arrow style.
+ OptValue< OUString > moColor; ///< Solid line color.
+ OptValue< double > moOpacity; ///< Solid line color opacity.
+ OptValue< OUString > moWeight; ///< Line width.
+ OptValue< OUString > moDashStyle; ///< Line dash (predefined or manually).
+ OptValue< sal_Int32 > moLineStyle; ///< Line style (single, double, ...).
+ OptValue< sal_Int32 > moEndCap; ///< Type of line end cap.
+ OptValue< sal_Int32 > moJoinStyle; ///< Type of line join.
+
+ void assignUsed( const StrokeModel& rSource );
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(
+ ::oox::drawingml::ShapePropertyMap& rPropMap,
+ const GraphicHelper& rGraphicHelper ) const;
+};
+
+
+/** The fill model structure contains all shape fill properties. */
+struct OOX_DLLPUBLIC FillModel
+{
+ OptValue< bool > moFilled; ///< Shape fill on/off.
+ OptValue< OUString > moColor; ///< Solid fill color.
+ OptValue< double > moOpacity; ///< Solid fill color opacity.
+ OptValue< OUString > moColor2; ///< End color of gradient.
+ OptValue< double > moOpacity2; ///< End color opacity of gradient.
+ OptValue< sal_Int32 > moType; ///< Fill type.
+ OptValue< sal_Int32 > moAngle; ///< Gradient rotation angle.
+ OptValue< double > moFocus; ///< Linear gradient focus of second color.
+ OptValue< DoublePair > moFocusPos; ///< Rectangular gradient focus position of second color.
+ OptValue< DoublePair > moFocusSize; ///< Rectangular gradient focus size of second color.
+ OptValue< OUString > moBitmapPath; ///< Path to fill bitmap fragment.
+ OptValue< bool > moRotate; ///< True = rotate gradient/bitmap with shape.
+
+ void assignUsed( const FillModel& rSource );
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(
+ ::oox::drawingml::ShapePropertyMap& rPropMap,
+ const GraphicHelper& rGraphicHelper ) const;
+};
+
+
+/** The shadow model structure contains all shape shadow properties. */
+struct OOX_DLLPUBLIC ShadowModel
+{
+ bool mbHasShadow; ///< Is a v:shadow element seen?
+ OptValue<bool> moShadowOn; ///< Is the element turned on?
+ OptValue<OUString> moColor; ///< Specifies the color of the shadow.
+ OptValue<OUString> moOffset; ///< Specifies the shadow's offset from the shape's location.
+ OptValue<double> moOpacity; ///< Specifies the opacity of the shadow.
+
+ ShadowModel();
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const;
+};
+
+/** The shadow model structure contains all shape textpath properties. */
+struct TextpathModel
+{
+ OptValue<OUString> moString; ///< Specifies the string of the textpath.
+ OptValue<OUString> moStyle; ///< Specifies the style of the textpath.
+ OptValue<bool> moTrim; ///< Specifies whether extra space is removed above and below the text
+
+ TextpathModel();
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, const css::uno::Reference<css::drawing::XShape>& xShape,
+ const GraphicHelper& rGraphicHelper) const;
+};
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmlinputstream.hxx b/include/oox/vml/vmlinputstream.hxx
new file mode 100644
index 000000000..df074834f
--- /dev/null
+++ b/include/oox/vml/vmlinputstream.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLINPUTSTREAM_HXX
+#define INCLUDED_OOX_VML_VMLINPUTSTREAM_HXX
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/string.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace io { class XTextInputStream2; }
+ namespace uno { class XComponentContext; }
+}
+
+namespace oox::vml {
+
+
+/** An input stream class for VML streams, implementing the UNO interface
+ com.sun.star.io.XInputStream needed by the Expat XML parsers.
+
+ This stream reads the data from the input stream passed to the constructor,
+ and parses all XML elements for features unsupported by the current Expat
+ XML parser:
+
+ 1) All elements that have the form '<![inst]>' where 'inst' is any string
+ not containing the characters '<' and '>' are stripped from the input
+ stream.
+
+ 2) Multiple occurrences of the same attribute in an element but the last
+ are removed.
+
+ 3) Line breaks represented by a single <br> element (without matching
+ </br> element) are replaced by a literal LF character.
+ */
+class InputStream final : public ::cppu::WeakImplHelper< css::io::XInputStream >
+{
+public:
+ explicit InputStream(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rxInStrm );
+ virtual ~InputStream() override;
+
+ virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& rData, sal_Int32 nBytesToRead ) override;
+ virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& rData, sal_Int32 nMaxBytesToRead ) override;
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override;
+ virtual sal_Int32 SAL_CALL available() override;
+ virtual void SAL_CALL closeInput() override;
+
+private:
+ /// @throws css::io::IOException
+ /// @throws css::uno::RuntimeException
+ void updateBuffer();
+ /// @throws css::io::IOException
+ /// @throws css::uno::RuntimeException
+ OString readToElementBegin();
+ /// @throws css::io::IOException
+ /// @throws css::uno::RuntimeException
+ OString readToElementEnd();
+
+private:
+ css::uno::Reference< css::io::XTextInputStream2 >
+ mxTextStrm;
+ css::uno::Sequence< sal_Unicode > maOpeningBracket;
+ css::uno::Sequence< sal_Unicode > maClosingBracket;
+ OString maBuffer;
+ sal_Int32 mnBufferPos;
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
new file mode 100644
index 000000000..7a17bda51
--- /dev/null
+++ b/include/oox/vml/vmlshape.hxx
@@ -0,0 +1,476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLSHAPE_HXX
+#define INCLUDED_OOX_VML_VMLSHAPE_HXX
+
+#include <memory>
+#include <vector>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/helper.hxx>
+#include <oox/vml/vmlformatting.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace awt { struct Rectangle; }
+ namespace drawing { class XShape; }
+ namespace drawing { class XShapes; }
+ namespace graphic { class XGraphic; }
+}
+
+namespace oox::vml {
+
+class Drawing;
+struct ShapeParentAnchor;
+class ShapeContainer;
+class TextBox;
+
+const sal_Int32 VML_CLIENTDATA_UNCHECKED = 0;
+const sal_Int32 VML_CLIENTDATA_CHECKED = 1;
+const sal_Int32 VML_CLIENTDATA_MIXED = 2;
+
+const sal_Int32 VML_CLIENTDATA_TEXT = 0;
+const sal_Int32 VML_CLIENTDATA_INTEGER = 1;
+const sal_Int32 VML_CLIENTDATA_NUMBER = 2;
+const sal_Int32 VML_CLIENTDATA_REFERENCE = 3;
+const sal_Int32 VML_CLIENTDATA_FORMULA = 4;
+
+
+/** The shape model structure contains all properties shared by all types of shapes. */
+struct ShapeTypeModel
+{
+ OUString maShapeId; ///< Unique identifier of the shape.
+ OUString maLegacyId; ///< Plaintext identifier of the shape.
+ OUString maShapeName; ///< Name of the shape, if present.
+ OptValue< sal_Int32 > moShapeType; ///< Builtin shape type identifier.
+
+ OptValue< Int32Pair > moCoordPos; ///< Top-left position of coordinate system for children scaling.
+ OptValue< Int32Pair > moCoordSize; ///< Size of coordinate system for children scaling.
+ OUString maPosition; ///< Position type of the shape.
+ OUString maZIndex; ///< ZIndex of the shape
+ OUString maLeft; ///< X position of the shape bounding box (number with unit).
+ OUString maTop; ///< Y position of the shape bounding box (number with unit).
+ OUString maWidth; ///< Width of the shape bounding box (number with unit).
+ OUString maHeight; ///< Height of the shape bounding box (number with unit).
+ OUString maMarginLeft; ///< X position of the shape bounding box to shape anchor (number with unit).
+ OUString maMarginTop; ///< Y position of the shape bounding box to shape anchor (number with unit).
+ OUString maPositionHorizontalRelative; ///< The X position is relative to this.
+ OUString maPositionVerticalRelative; ///< The Y position is relative to this.
+ OUString maPositionHorizontal; ///< The X position orientation (default: absolute).
+ OUString maPositionVertical; ///< The Y position orientation.
+ OUString maWidthPercent; ///< The width in percents of the WidthRelative
+ OUString maHeightPercent; ///< The height in percents of the HeightRelative
+ OUString maWidthRelative; ///< To what the width is relative
+ OUString maHeightRelative; ///< To what the height is relative
+ OUString maRotation; ///< Rotation of the shape, in degrees.
+ OUString maFlip; ///< Flip type of the shape (can be "x" or "y").
+ bool mbAutoHeight; ///< If true, the height value is a minimum value (mostly used for textboxes)
+ bool mbVisible; ///< Visible or Hidden
+ OUString maWrapStyle; ///< Wrapping mode for text.
+ OUString maArcsize; ///< round rectangles arc size
+ OUString maEditAs; ///< Edit As type (e.g. "canvas" etc)
+ OUString maAdjustments; ///< Shape adjustment values
+
+ StrokeModel maStrokeModel; ///< Border line formatting.
+ FillModel maFillModel; ///< Shape fill formatting.
+ ShadowModel maShadowModel; ///< Shape shadow formatting.
+ TextpathModel maTextpathModel; ///< Shape textpath formatting.
+
+ OptValue< OUString > moGraphicPath; ///< Path to a graphic for this shape.
+ OptValue< OUString > moGraphicTitle; ///< Title of the graphic.
+ OptValue< OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated.
+ OptValue< OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated.
+ OptValue< OUString > moWrapType; ///< How to wrap the text around the object
+ OptValue< OUString > moWrapSide; ///< On which side to wrap the text around the object
+ OUString maVTextAnchor; ///< How the text inside the shape is anchored vertically.
+ OUString maWrapDistanceLeft; ///< Distance from the left side of the shape to the text that wraps around it.
+ OUString maWrapDistanceRight; ///< Distance from the right side of the shape to the text that wraps around it.
+ OUString maWrapDistanceTop; ///< Distance from the top of the shape to the text that wraps around it.
+ OUString maWrapDistanceBottom; ///< Distance from the bottom of the shape to the text that wraps around it.
+ OptValue<OUString> moCropBottom; ///< Specifies the how much to crop the image from the bottom up as a fraction of picture size.
+ OptValue<OUString> moCropLeft; ///< Specifies how much to crop the image from the left in as a fraction of picture size.
+ OptValue<OUString> moCropRight; ///< Specifies how much to crop the image from the right in as a fraction of picture size.
+ OptValue<OUString> moCropTop; ///< Specifies how much to crop the image from the top down as a fraction of picture size.
+ OUString maLayoutFlowAlt; ///< Specifies the alternate layout flow for text in textboxes.
+
+ /// An adjustment for the intensity of all colors, i.e. contrast, on a 0..0x10000 scale.
+ sal_Int32 mnGain = 0x10000;
+
+ /// The image brightness, on a 0..0x10000 scale.
+ sal_Int16 mnBlacklevel = 0;
+
+ explicit ShapeTypeModel();
+
+ void assignUsed( const ShapeTypeModel& rSource );
+};
+
+
+/** A shape template contains all formatting properties of shapes and can serve
+ as templates for several shapes in a drawing. */
+class SAL_DLLPUBLIC_RTTI ShapeType
+{
+public:
+ explicit ShapeType( Drawing& rDrawing );
+ virtual ~ShapeType();
+
+ /** Returns read/write access to the shape template model structure. */
+ ShapeTypeModel& getTypeModel() { return maTypeModel; }
+ /** Returns read access to the shape template model structure. */
+ const ShapeTypeModel& getTypeModel() const { return maTypeModel; }
+
+ /** Returns the shape identifier (which is unique through the containing drawing). */
+ const OUString& getShapeId() const { return maTypeModel.maShapeId; }
+ /** Returns the application defined shape type. */
+ sal_Int32 getShapeType() const;
+ /** Returns the fragment path to the embedded graphic used by this shape. */
+ OUString getGraphicPath() const;
+
+ const Drawing& getDrawing() const { return mrDrawing; }
+
+protected:
+ /** Returns the coordinate system of this shape. */
+ css::awt::Rectangle getCoordSystem() const;
+ /** Returns the absolute shape rectangle according to the passed anchor. */
+ css::awt::Rectangle getRectangle( const ShapeParentAnchor* pParentAnchor ) const;
+ /** Returns the absolute shape rectangle. */
+ virtual css::awt::Rectangle getAbsRectangle() const;
+ /** Returns the rectangle relative to the parent coordinate system. */
+ virtual css::awt::Rectangle getRelRectangle() const;
+
+protected:
+ Drawing& mrDrawing; ///< The VML drawing page that contains this shape.
+ ShapeTypeModel maTypeModel; ///< The model structure containing shape type data.
+};
+
+
+/** Excel specific shape client data (such as cell anchor). */
+struct ClientData
+{
+ OUString maAnchor; ///< Cell anchor as comma-separated string.
+ OUString maFmlaMacro; ///< Link to macro associated to the control.
+ OUString maFmlaPict; ///< Target cell range of picture links.
+ OUString maFmlaLink; ///< Link to value cell associated to the control.
+ OUString maFmlaRange; ///< Link to cell range used as data source for the control.
+ OUString maFmlaGroup; ///< Link to value cell associated to a group of option buttons.
+ sal_Int32 mnObjType; ///< Type of the shape.
+ sal_Int32 mnTextHAlign; ///< Horizontal text alignment.
+ sal_Int32 mnTextVAlign; ///< Vertical text alignment.
+ sal_Int32 mnCol; ///< Column index for spreadsheet cell note.
+ sal_Int32 mnRow; ///< Row index for spreadsheet cell note.
+ sal_Int32 mnChecked; ///< State for checkboxes and option buttons.
+ sal_Int32 mnDropStyle; ///< Drop down box style (read-only or editable).
+ sal_Int32 mnDropLines; ///< Number of lines in drop down box.
+ sal_Int32 mnVal; ///< Current value of spin buttons and scroll bars.
+ sal_Int32 mnMin; ///< Minimum value of spin buttons and scroll bars.
+ sal_Int32 mnMax; ///< Maximum value of spin buttons and scroll bars.
+ sal_Int32 mnInc; ///< Small increment of spin buttons and scroll bars.
+ sal_Int32 mnPage; ///< Large increment of spin buttons and scroll bars.
+ sal_Int32 mnSelType; ///< Listbox selection type.
+ sal_Int32 mnVTEdit; ///< Data type of the textbox.
+ bool mbPrintObject; ///< True = print the object.
+ bool mbVisible; ///< True = cell note is visible.
+ bool mbDde; ///< True = object is linked through DDE.
+ bool mbNo3D; ///< True = flat style, false = 3D style.
+ bool mbNo3D2; ///< True = flat style, false = 3D style (listboxes and dropdowns).
+ bool mbMultiLine; ///< True = textbox allows line breaks.
+ bool mbVScroll; ///< True = textbox has a vertical scrollbar.
+ bool mbSecretEdit; ///< True = textbox is a password edit field.
+
+ explicit ClientData();
+};
+
+
+struct ShapeModel
+{
+ typedef ::std::vector< css::awt::Point > PointVector;
+
+ OUString maType; ///< Shape template with default properties.
+ PointVector maPoints; ///< Points for the polyline shape.
+ std::unique_ptr<TextBox> mxTextBox; ///< Text contents and properties.
+ std::unique_ptr<ClientData> mxClientData; ///< Excel specific client data.
+ OUString maLegacyDiagramPath;///< Legacy Diagram Fragment Path
+ OUString maFrom; ///< Start point for line shape.
+ OUString maTo; ///< End point for line shape.
+ OUString maControl1; ///< Bezier control point 1
+ OUString maControl2; ///< Bezier control point 2
+ OUString maVmlPath; ///< VML path for this shape
+ bool mbIsSignatureLine; ///< Shape is a signature line
+ OUString maSignatureId; ///< ID of the signature
+ OUString maSignatureLineSuggestedSignerName;
+ OUString maSignatureLineSuggestedSignerTitle;
+ OUString maSignatureLineSuggestedSignerEmail;
+ OUString maSignatureLineSigningInstructions;
+ bool mbSignatureLineShowSignDate;
+ bool mbSignatureLineCanAddComment;
+ bool mbInGroup;
+ OUString maHyperlink; ///< The hyperlink assigned to the shape
+
+ explicit ShapeModel();
+ ~ShapeModel();
+
+ /** Creates and returns a new shape textbox structure. */
+ TextBox& createTextBox(ShapeTypeModel& rModel);
+ /** Creates and returns a new shape client data structure. */
+ ClientData& createClientData();
+};
+
+
+/** A shape object that is part of a drawing. May inherit properties from a
+ shape template. */
+class OOX_DLLPUBLIC ShapeBase : public ShapeType
+{
+public:
+ /** Returns read/write access to the shape model structure. */
+ ShapeModel& getShapeModel() { return maShapeModel; }
+ /** Returns read access to the shape model structure. */
+ const ShapeModel& getShapeModel() const { return maShapeModel; }
+
+ /** Returns read access to the shape textbox. */
+ const TextBox* getTextBox() const { return maShapeModel.mxTextBox.get(); }
+ /** Returns read access to the shape client data structure. */
+ const ClientData* getClientData() const { return maShapeModel.mxClientData.get(); }
+
+ /** Final processing after import of the drawing fragment. */
+ virtual void finalizeFragmentImport();
+
+ /** Returns the real shape name if existing, or a generated shape name. */
+ OUString getShapeName() const;
+
+ /** Returns the shape template with the passed identifier from the child shapes. */
+ virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const;
+ /** Returns the shape with the passed identifier from the child shapes. */
+ virtual const ShapeBase* getChildById( const OUString& rShapeId ) const;
+
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ css::uno::Reference< css::drawing::XShape >
+ convertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const ShapeParentAnchor* pParentAnchor = nullptr ) const;
+
+ /** Converts position and formatting into the passed existing XShape. */
+ void convertFormatting(
+ const css::uno::Reference< css::drawing::XShape >& rxShape ) const;
+
+ void setContainer(ShapeContainer* pContainer);
+ ShapeContainer* getContainer() const;
+
+protected:
+ explicit ShapeBase( Drawing& rDrawing );
+
+ /** Derived classes create the corresponding XShape and insert it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const = 0;
+
+ /** Always called after implConvertAndInsert for the same task.*/
+ virtual css::uno::Reference<css::drawing::XShape> finalImplConvertAndInsert(
+ const css::uno::Reference<css::drawing::XShape>& rxShape) const
+ {
+ return rxShape;
+ };
+
+ /** Calculates the final shape rectangle according to the passed anchor,
+ if present, otherwise according to the own anchor settings. */
+ css::awt::Rectangle calcShapeRectangle(
+ const ShapeParentAnchor* pParentAnchor ) const;
+
+ /** Converts common shape properties such as formatting attributes. */
+ void convertShapeProperties(
+ const css::uno::Reference< css::drawing::XShape >& rxShape ) const;
+
+protected:
+ ShapeModel maShapeModel; ///< The model structure containing shape data.
+ ShapeContainer* mpContainer = nullptr;
+};
+
+
+/** A simple shape object based on a specific UNO shape service. */
+class SimpleShape : public ShapeBase
+{
+public:
+ explicit SimpleShape( Drawing& rDrawing, const OUString& rService );
+
+ void setService( const OUString& aService ) { maService = aService; }
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+ virtual css::uno::Reference<css::drawing::XShape> finalImplConvertAndInsert(
+ const css::uno::Reference<css::drawing::XShape>& rxShape) const override;
+ /** Used by both RectangleShape and ComplexShape. */
+ css::uno::Reference<css::drawing::XShape>createEmbeddedPictureObject(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const;
+
+ css::uno::Reference<css::drawing::XShape>createPictureObject(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) const;
+
+private:
+ OUString maService; ///< Name of the UNO shape service.
+};
+
+
+/** A rectangular shape object. */
+class RectangleShape final : public SimpleShape
+{
+public:
+ explicit RectangleShape( Drawing& rDrawing );
+private:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference<css::drawing::XShape>
+ implConvertAndInsert(
+ const css::uno::Reference<css::drawing::XShapes>& rxShapes,
+ const css::awt::Rectangle& rShapeRect) const override;
+};
+
+
+/** An oval shape object. */
+class EllipseShape final : public SimpleShape
+{
+public:
+ explicit EllipseShape( Drawing& rDrawing );
+};
+
+
+/** A polygon shape object. */
+class PolyLineShape final : public SimpleShape
+{
+public:
+ explicit PolyLineShape( Drawing& rDrawing );
+
+private:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+};
+
+/** A Line shape object. */
+class LineShape final : public SimpleShape
+{
+public:
+ explicit LineShape( Drawing& rDrawing );
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+
+
+private:
+ /** Returns the absolute shape rectangle. */
+ virtual css::awt::Rectangle getAbsRectangle() const override;
+ /** Returns the rectangle relative to the parent coordinate system. */
+ virtual css::awt::Rectangle getRelRectangle() const override;
+};
+
+/** Bezier shape object that supports to, from, control1 and control2
+ attribute or path attribute specification */
+class BezierShape final : public SimpleShape
+{
+public:
+ explicit BezierShape( Drawing& rDrawing );
+
+private:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+};
+
+
+/** A shape object with custom geometry. */
+class CustomShape : public SimpleShape
+{
+public:
+ explicit CustomShape( Drawing& rDrawing );
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+};
+
+
+/** A complex shape object. This can be a picture shape, a custom shape, an OLE
+ object, or an ActiveX form control. */
+class ComplexShape final : public CustomShape
+{
+public:
+ explicit ComplexShape( Drawing& rDrawing );
+
+private:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+};
+
+
+/** A group shape that extends the basic shape by a container of child shapes. */
+class GroupShape final : public ShapeBase
+{
+public:
+ explicit GroupShape( Drawing& rDrawing );
+ virtual ~GroupShape() override;
+
+ /** Returns read/write access to the container of child shapes and templates. */
+ ShapeContainer& getChildren() { return *mxChildren; }
+ /** Returns read access to the container of child shapes and templates. */
+ const ShapeContainer& getChildren() const { return *mxChildren; }
+
+ /** Final processing after import of the drawing fragment. */
+ virtual void finalizeFragmentImport() override;
+
+ /** Returns the shape template with the passed identifier from the child shapes. */
+ virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const override;
+ /** Returns the shape with the passed identifier from the child shapes. */
+ virtual const ShapeBase* getChildById( const OUString& rShapeId ) const override;
+
+private:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual css::uno::Reference< css::drawing::XShape >
+ implConvertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const css::awt::Rectangle& rShapeRect ) const override;
+
+private:
+ std::unique_ptr<ShapeContainer> mxChildren; ///< Shapes and templates that are part of this group.
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmlshapecontainer.hxx b/include/oox/vml/vmlshapecontainer.hxx
new file mode 100644
index 000000000..6f50730bc
--- /dev/null
+++ b/include/oox/vml/vmlshapecontainer.hxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLSHAPECONTAINER_HXX
+#define INCLUDED_OOX_VML_VMLSHAPECONTAINER_HXX
+
+#include <cstddef>
+#include <functional>
+#include <memory>
+#include <stack>
+
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/helper/refmap.hxx>
+#include <oox/helper/refvector.hxx>
+#include <rtl/ustring.hxx>
+
+namespace com::sun::star {
+ namespace drawing { class XShapes; }
+}
+
+namespace oox::vml {
+
+class Drawing;
+class ShapeType;
+class ShapeBase;
+
+
+struct ShapeParentAnchor
+{
+ css::awt::Rectangle maShapeRect;
+ css::awt::Rectangle maCoordSys;
+};
+
+
+/** Container that holds a list of shapes and shape templates. */
+class ShapeContainer
+{
+public:
+ explicit ShapeContainer( Drawing& rDrawing );
+ ~ShapeContainer();
+
+ /** Returns the drawing this shape container is part of. */
+ Drawing& getDrawing() { return mrDrawing; }
+
+ /** Creates and returns a new shape template object. */
+ std::shared_ptr<ShapeType> createShapeType();
+ /** Creates and returns a new shape object of the specified type. */
+ template< typename ShapeT >
+ std::shared_ptr<ShapeT> createShape();
+
+ /** Final processing after import of the drawing fragment. */
+ void finalizeFragmentImport();
+
+ /** Returns true, if this container does not contain any shapes. */
+ bool empty() const { return maShapes.empty(); }
+
+ /** Returns the shape template with the passed identifier.
+ Searches in all group shapes too. */
+ const ShapeType* getShapeTypeById( const OUString& rShapeId ) const;
+ /** Returns the shape with the passed identifier.
+ Searches in all group shapes too. */
+ const ShapeBase* getShapeById( const OUString& rShapeId ) const;
+
+ /** Searches for a shape by using the passed functor that takes a constant
+ reference of a ShapeBase object. */
+ template< typename Functor >
+ const ShapeBase* findShape( const Functor& rFunctor ) const;
+
+ /**
+ (Word only) Returns the last shape in the collection, if it is after the last
+ mark from pushMark(), and removes it.
+ */
+ std::shared_ptr< ShapeBase > takeLastShape();
+ /**
+ Adds a recursion mark to the stack. It is possible that a shape contains <w:txbxContent>
+ which contains another shape, and writerfilter needs to know which shape is from the inner
+ ooxml context and which from the outer ooxml context, while it is necessary to keep
+ at least shape types across such blocks. Therefore this function marks beginning
+ of each shape xml block, and takeLastShape() returns only shapes from this block.
+ */
+ void pushMark();
+ /**
+ Removes a recursion mark.
+ */
+ void popMark();
+
+ /** Creates and inserts all UNO shapes into the passed container. */
+ void convertAndInsert(
+ const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+ const ShapeParentAnchor* pParentAnchor = nullptr ) const;
+
+private:
+ typedef RefVector< ShapeType > ShapeTypeVector;
+ typedef RefVector< ShapeBase > ShapeVector;
+ typedef RefMap< OUString, ShapeType > ShapeTypeMap;
+ typedef RefMap< OUString, ShapeBase > ShapeMap;
+
+ Drawing& mrDrawing; ///< The VML drawing page that contains this shape.
+ ShapeTypeVector maTypes; ///< All shape templates.
+ ShapeVector maShapes; ///< All shape definitions.
+ ShapeTypeMap maTypesById; ///< All shape templates mapped by identifier.
+ ShapeMap maShapesById; ///< All shape definitions mapped by identifier.
+ std::stack< size_t > markStack; ///< Recursion marks from pushMark()/popMark().
+};
+
+
+template< typename ShapeT >
+std::shared_ptr<ShapeT> ShapeContainer::createShape()
+{
+ auto xShape = std::make_shared<ShapeT>( mrDrawing );
+ xShape->setContainer(this);
+ maShapes.push_back( xShape );
+ return xShape;
+}
+
+template< typename Functor >
+const ShapeBase* ShapeContainer::findShape( const Functor& rFunctor ) const
+{
+ return maShapes.findIf( rFunctor ).get();
+}
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmlshapecontext.hxx b/include/oox/vml/vmlshapecontext.hxx
new file mode 100644
index 000000000..ce838297c
--- /dev/null
+++ b/include/oox/vml/vmlshapecontext.hxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLSHAPECONTEXT_HXX
+#define INCLUDED_OOX_VML_VMLSHAPECONTEXT_HXX
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/contexthandler2.hxx>
+#include <oox/helper/helper.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox { class AttributeList; }
+
+namespace oox::vml {
+
+class Drawing;
+
+struct ShapeTypeModel;
+class ShapeType;
+
+struct ClientData;
+struct ShapeModel;
+class ShapeBase;
+class GroupShape;
+class RectangleShape;
+
+class ShapeContainer;
+
+
+class ShapeLayoutContext final : public ::oox::core::ContextHandler2
+{
+public:
+ explicit ShapeLayoutContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ Drawing& rDrawing );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ Drawing& mrDrawing;
+};
+
+
+class ClientDataContext final : public ::oox::core::ContextHandler2
+{
+public:
+ explicit ClientDataContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ ClientData& rClientData,
+ const AttributeList& rAttribs );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+ virtual void onCharacters( const OUString& rChars ) override;
+ virtual void onEndElement() override;
+
+private:
+ ClientData& mrClientData;
+ OUString maElementText;
+};
+
+
+class ShapeContextBase : public ::oox::core::ContextHandler2
+{
+public:
+ static ::oox::core::ContextHandlerRef
+ createShapeContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ ShapeContainer& rShapes,
+ sal_Int32 nElement,
+ const AttributeList& rAttribs );
+
+protected:
+ explicit ShapeContextBase( ::oox::core::ContextHandler2Helper const & rParent );
+};
+
+
+class ShapeTypeContext : public ShapeContextBase
+{
+public:
+ explicit ShapeTypeContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ std::shared_ptr<ShapeType> const& pShapeType,
+ const AttributeList& rAttribs );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ /** Processes the 'style' attribute. */
+ void setStyle( std::u16string_view rStyle );
+
+ /** Resolve a relation identifier to a fragment path. */
+ OptValue< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const;
+
+private:
+ std::shared_ptr<ShapeType> m_pShapeType;
+ ShapeTypeModel& mrTypeModel;
+};
+
+
+class ShapeContext : public ShapeTypeContext
+{
+public:
+ explicit ShapeContext(::oox::core::ContextHandler2Helper const& rParent,
+ const std::shared_ptr<ShapeBase>& pShape, const AttributeList& rAttribs);
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ /** Processes the 'points' attribute. */
+ void setPoints( std::u16string_view rPoints );
+ /** Processes the 'from' attribute. */
+ void setFrom( const OUString& rPoints );
+ /** Processes the 'to' attribute. */
+ void setTo( const OUString& rPoints );
+ /** Processes the 'control1' attribute. */
+ void setControl1( const OUString& rPoints );
+ /** Processes the 'control2' attribute. */
+ void setControl2( const OUString& rPoints );
+ /** Processes the 'path' attribute. */
+ void setVmlPath( const OUString& rPath );
+ /** Processes the 'href' attribute. */
+ void setHyperlink( const OUString& rHyperlink );
+
+private:
+ ShapeBase& mrShape;
+ ShapeModel& mrShapeModel;
+};
+
+
+class GroupShapeContext final : public ShapeContext
+{
+public:
+ explicit GroupShapeContext(::oox::core::ContextHandler2Helper const& rParent,
+ const std::shared_ptr<GroupShape>& pShape,
+ const AttributeList& rAttribs);
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+
+private:
+ ShapeContainer& mrShapes;
+};
+
+
+class RectangleShapeContext final : public ShapeContext
+{
+public:
+ explicit RectangleShapeContext(::oox::core::ContextHandler2Helper const& rParent,
+ const AttributeList& rAttribs,
+ const std::shared_ptr<RectangleShape>& pShape);
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+};
+
+class ControlShapeContext final : public ShapeContextBase
+{
+public:
+ explicit ControlShapeContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ ShapeContainer& rShapes,
+ const AttributeList& rAttribs );
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx
new file mode 100644
index 000000000..fb6983315
--- /dev/null
+++ b/include/oox/vml/vmltextbox.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLTEXTBOX_HXX
+#define INCLUDED_OOX_VML_VMLTEXTBOX_HXX
+
+#include <cstddef>
+#include <vector>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <oox/dllapi.h>
+#include <oox/helper/helper.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace com::sun::star {
+ namespace drawing { class XShape; }
+}
+
+namespace oox::vml {
+
+struct ShapeTypeModel;
+
+
+/// A text paragraph in a textbox.
+struct TextParagraphModel
+{
+ OptValue<OUString> moParaAdjust; ///< Paragraph adjust (left, center, right, etc.)
+ OptValue<OUString> moParaStyleName;
+};
+
+/** Font settings for a text portion in a textbox. */
+struct OOX_DLLPUBLIC TextFontModel
+{
+ OptValue< OUString > moName; ///< Font name.
+ OptValue< OUString > moNameAsian; ///< Asian font name.
+ OptValue< OUString > moNameComplex; ///< Complex font name.
+ OptValue< OUString > moColor; ///< Font color, HTML encoded, sort of.
+ OptValue< sal_Int32 > monSize; ///< Font size in twips.
+ OptValue< sal_Int32 > monUnderline; ///< Single or double underline.
+ OptValue< sal_Int32 > monEscapement; ///< Subscript or superscript.
+ OptValue< bool > mobBold;
+ OptValue< bool > mobItalic;
+ OptValue< bool > mobStrikeout;
+ OptValue<sal_Int32> monSpacing;
+
+ explicit TextFontModel();
+};
+
+
+/** A text portion in a textbox with the same formatting for all characters. */
+struct TextPortionModel
+{
+ TextParagraphModel maParagraph;
+ TextFontModel maFont;
+ OUString maText;
+
+ explicit TextPortionModel( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText );
+};
+
+
+/** The textbox contains all text contents and properties. */
+class OOX_DLLPUBLIC TextBox
+{
+public:
+ explicit TextBox(ShapeTypeModel& rTypeModel);
+
+ /** Appends a new text portion to the textbox. */
+ void appendPortion( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText );
+
+ /** Returns the current number of text portions. */
+ size_t getPortionCount() const { return maPortions.size(); }
+ /** Returns the font settings of the first text portion. */
+ const TextFontModel* getFirstFont() const;
+ /** Returns the entire text of all text portions. */
+ OUString getText() const;
+ void convert(const css::uno::Reference<css::drawing::XShape>& xShape) const;
+
+ ShapeTypeModel& mrTypeModel;
+ /// Text distance from the border (inset attribute of v:textbox), valid only if set.
+ bool borderDistanceSet;
+ int borderDistanceLeft, borderDistanceTop, borderDistanceRight, borderDistanceBottom;
+ OUString maLayoutFlow;
+ OUString msNextTextbox;
+
+private:
+ typedef ::std::vector< TextPortionModel > PortionVector;
+
+ PortionVector maPortions;
+};
+
+
+} // namespace oox::vml
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx
new file mode 100644
index 000000000..d5c3dde86
--- /dev/null
+++ b/include/oox/vml/vmltextboxcontext.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_OOX_VML_VMLTEXTBOXCONTEXT_HXX
+#define INCLUDED_OOX_VML_VMLTEXTBOXCONTEXT_HXX
+
+#include <cstddef>
+
+#include <oox/core/contexthandler.hxx>
+#include <oox/core/contexthandler2.hxx>
+#include <oox/vml/vmltextbox.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+namespace oox {
+ class AttributeList;
+ class GraphicHelper;
+
+namespace vml {
+
+
+class TextPortionContext final : public ::oox::core::ContextHandler2
+{
+public:
+ explicit TextPortionContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ TextBox& rTextBox,
+ TextParagraphModel const & rParagraph,
+ const TextFontModel& rParentFont,
+ sal_Int32 nElement,
+ const AttributeList& rAttribs );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+ virtual void onCharacters( const OUString& rChars ) override;
+ virtual void onStartElement(const AttributeList& rAttribs) override;
+ virtual void onEndElement() override;
+
+private:
+ TextBox& mrTextBox;
+ TextParagraphModel maParagraph;
+ TextFontModel maFont;
+ size_t mnInitialPortions;
+};
+
+
+class TextBoxContext final : public ::oox::core::ContextHandler2
+{
+public:
+ explicit TextBoxContext(
+ ::oox::core::ContextHandler2Helper const & rParent,
+ TextBox& rTextBox,
+ const AttributeList& rAttribs,
+ const GraphicHelper& graphicHelper );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
+ virtual void onStartElement(const AttributeList& rAttribs) override;
+ virtual void onEndElement() override;
+
+private:
+ TextBox& mrTextBox;
+ TextParagraphModel maParagraph;
+};
+
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */