android: Update app-specific/MIME type icons
[LibreOffice.git] / include / oox / export / vmlexport.hxx
blobf6b9869dae7a1cdf82e3cfb6978e95976268e7f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
21 #define INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
23 #include <sal/config.h>
25 #include <string_view>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <editeng/outlobj.hxx>
29 #include <filter/msfilter/escherex.hxx>
30 #include <oox/dllapi.h>
31 #include <rtl/strbuf.hxx>
32 #include <rtl/string.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
35 #include <sax/fshelper.hxx>
36 #include <vcl/checksum.hxx>
37 #include <rtl/ref.hxx>
39 namespace com::sun::star {
40 namespace drawing {
41 class XShape;
45 namespace oox::drawingml {
46 class DrawingML;
50 namespace sax_fastparser {
51 class FastAttributeList;
54 class Point;
55 namespace tools { class Rectangle; }
56 class SdrObject;
58 namespace oox::vml {
60 /// Interface to be implemented by the parent exporter that knows how to handle shape text.
61 class OOX_DLLPUBLIC VMLTextExport
63 public:
64 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
65 virtual oox::drawingml::DrawingML& GetDrawingML() = 0;
66 /// Write the contents of the textbox that is associated to this shape in VML format.
67 virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
68 protected:
69 VMLTextExport() {}
70 virtual ~VMLTextExport() {}
73 class OOX_DLLPUBLIC VMLExport : public EscherEx
75 /// Fast serializer to output the data
76 ::sax_fastparser::FSHelperPtr m_pSerializer;
78 /// Parent exporter, used for text callback.
79 VMLTextExport* m_pTextExport;
81 /// Anchoring - Writer specific properties
82 sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel;
83 rtl::Reference<sax_fastparser::FastAttributeList> m_pWrapAttrList;
84 bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER
85 bool m_IsFollowingTextFlow = false;
87 /// The object we're exporting.
88 const SdrObject* m_pSdrObject;
90 /// Fill the shape attributes as they come.
91 rtl::Reference<::sax_fastparser::FastAttributeList> m_pShapeAttrList;
93 /// Remember the shape type.
94 sal_uInt32 m_nShapeType;
96 /// Remember the shape flags.
97 ShapeFlag m_nShapeFlags;
99 /// Remember style, the most important shape attribute ;-)
100 OStringBuffer m_ShapeStyle;
102 /// style for textbox
103 OStringBuffer m_TextboxStyle;
105 /// Remember the generated shape id.
106 OString m_sShapeId;
108 /// Remember which shape types we had already written.
109 std::vector<bool> m_aShapeTypeWritten;
111 /// It seems useless to write out an XML_ID attribute next to XML_id which defines the actual shape id
112 bool m_bSkipwzName;
114 /// Use '#' mark for type attribute (check Type Attribute of VML shape in OOXML documentation)
115 bool m_bUseHashMarkForType;
117 /** There is a shapeid generation mechanism in EscherEx, but it does not seem to work
118 * so override the existing behavior to get actually unique ids.
120 bool m_bOverrideShapeIdGeneration;
122 /// Prefix for overridden shape id generation (used if m_bOverrideShapeIdGeneration is true)
123 OString m_sShapeIDPrefix;
125 /// Counter for generating shape ids (used if m_bOverrideShapeIdGeneration is true)
126 sal_uInt64 m_nShapeIDCounter;
128 public:
129 VMLExport( ::sax_fastparser::FSHelperPtr pSerializer, VMLTextExport* pTextExport = nullptr);
130 virtual ~VMLExport() override;
132 const ::sax_fastparser::FSHelperPtr&
133 GetFS() const { return m_pSerializer; }
135 void SetFS(const ::sax_fastparser::FSHelperPtr& pSerializer);
137 /// Export the sdr object as VML.
139 /// Call this when you need to export the object as VML.
140 OString const & AddSdrObject( const SdrObject& rObj,
141 bool const bIsFollowingTextFlow = false,
142 sal_Int16 eHOri = -1, sal_Int16 eVOri = -1, sal_Int16 eHRel = -1,
143 sal_Int16 eVRel = -1,
144 sax_fastparser::FastAttributeList* pWrapAttrList = nullptr,
145 const bool bOOxmlExport = false, sal_uInt32 nId = 0);
146 OString const & AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport );
147 virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override;
148 static bool IsWaterMarkShape(std::u16string_view rStr);
150 void SetSkipwzName(bool bSkipwzName) { m_bSkipwzName = bSkipwzName; }
151 void SetHashMarkForType(bool bUseHashMarkForType) { m_bUseHashMarkForType = bUseHashMarkForType; }
152 void OverrideShapeIDGen(bool bOverrideShapeIdGeneration,
153 const OString& sShapeIDPrefix = OString());
154 static OString GetVMLShapeTypeDefinition(std::string_view sShapeID, const bool bIsPictureFrame);
156 protected:
157 /// Add an attribute to the generated <v:shape/> element.
159 /// This should be called from within StartShape() to ensure that the
160 /// added attribute is preserved.
161 void AddShapeAttribute(sal_Int32 nAttribute, std::string_view sValue);
163 using EscherEx::StartShape;
164 using EscherEx::EndShape;
166 /// Override shape ID generation when m_bOverrideShapeIdGeneration is set to true
167 virtual sal_uInt32 GenerateShapeId() override;
169 /// Start the shape for which we just collected the information.
171 /// Returns the element's tag number, -1 means we wrote nothing.
172 virtual sal_Int32 StartShape();
174 /// End the shape.
176 /// The parameter is just what we got from StartShape().
177 virtual void EndShape( sal_Int32 nShapeElement );
178 virtual void Commit( EscherPropertyContainer& rProps, const tools::Rectangle& rRect ) override;
180 private:
182 virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 ) override;
183 virtual void CloseContainer() override;
185 virtual sal_uInt32 EnterGroup( const OUString& rShapeName, const tools::Rectangle* pBoundRect ) override;
186 virtual void LeaveGroup() override;
188 virtual void AddShape( sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId = 0 ) override;
190 private:
191 /// Create an OString representing the id from a numerical id.
192 OString ShapeIdString( sal_uInt32 nId );
194 /// Add flip X and\or flip Y
195 void AddFlipXY( );
197 /// Add starting and ending point of a line to the m_pShapeAttrList.
198 void AddLineDimensions( const tools::Rectangle& rRectangle );
200 /// Add position and size to the OStringBuffer.
201 void AddRectangleDimensions( OStringBuffer& rBuffer, const tools::Rectangle& rRectangle, bool rbAbsolutePos = true );
205 } // namespace oox::vml
207 #endif
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */