Bump version to 6.4-15
[LibreOffice.git] / include / oox / export / vmlexport.hxx
blob83b5b91c0d41b782b2db2686d15d205762584df8
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 <com/sun/star/uno/Reference.hxx>
24 #include <editeng/outlobj.hxx>
25 #include <filter/msfilter/escherex.hxx>
26 #include <oox/dllapi.h>
27 #include <rtl/strbuf.hxx>
28 #include <rtl/string.hxx>
29 #include <rtl/ustring.hxx>
30 #include <sal/types.h>
31 #include <sax/fshelper.hxx>
32 #include <vcl/checksum.hxx>
34 namespace com { namespace sun { namespace star {
35 namespace drawing {
36 class XShape;
38 }}}
40 namespace oox {
41 namespace drawingml {
42 class DrawingML;
46 namespace sax_fastparser {
47 class FastAttributeList;
50 class Point;
51 namespace tools { class Rectangle; }
52 class SdrObject;
54 namespace oox {
56 namespace vml {
58 /// Interface to be implemented by the parent exporter that knows how to handle shape text.
59 class OOX_DLLPUBLIC VMLTextExport
61 public:
62 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
63 virtual oox::drawingml::DrawingML& GetDrawingML() = 0;
64 /// Write the contents of the textbox that is associated to this shape in VML format.
65 virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
66 /// Look up the RelId of a graphic based on its checksum.
67 virtual OUString FindRelId(BitmapChecksum nChecksum) = 0;
68 /// Store the RelId of a graphic based on its checksum.
69 virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) = 0;
70 protected:
71 VMLTextExport() {}
72 virtual ~VMLTextExport() {}
75 class OOX_DLLPUBLIC VMLExport : public EscherEx
77 /// Fast serializer to output the data
78 ::sax_fastparser::FSHelperPtr m_pSerializer;
80 /// Parent exporter, used for text callback.
81 VMLTextExport* m_pTextExport;
83 /// Anchoring.
84 sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel;
85 bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER
87 /// The object we're exporting.
88 const SdrObject* m_pSdrObject;
90 /// Fill the shape attributes as they come.
91 ::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 /// Remember the generated shape id.
103 OString m_sShapeId;
105 /// Remember which shape types we had already written.
106 std::vector<bool> m_aShapeTypeWritten;
108 /// It seems useless to write out an XML_ID attribute next to XML_id which defines the actual shape id
109 bool m_bSkipwzName;
111 /// Use '#' mark for type attribute (check Type Attribute of VML shape in OOXML documentation)
112 bool m_bUseHashMarkForType;
114 /** There is a shapeid generation mechanism in EscherEx, but it does not seem to work
115 * so override the existing behavior to get actually unique ids.
117 bool m_bOverrideShapeIdGeneration;
119 /// Prefix for overridden shape id generation (used if m_bOverrideShapeIdGeneration is true)
120 OString m_sShapeIDPrefix;
122 /// Counter for generating shape ids (used if m_bOverrideShapeIdGeneration is true)
123 sal_uInt64 m_nShapeIDCounter;
125 public:
126 VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLTextExport* pTextExport = nullptr);
127 virtual ~VMLExport() override;
129 const ::sax_fastparser::FSHelperPtr&
130 GetFS() const { return m_pSerializer; }
132 void SetFS(const ::sax_fastparser::FSHelperPtr& pSerializer);
134 /// Export the sdr object as VML.
136 /// Call this when you need to export the object as VML.
137 OString const & AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri = -1,
138 sal_Int16 eVOri = -1, sal_Int16 eHRel = -1,
139 sal_Int16 eVRel = -1, const bool bOOxmlExport = false );
140 OString const & AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport );
141 virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override;
142 static bool IsWaterMarkShape(const OUString& rStr);
144 void SetSkipwzName(bool bSkipwzName) { m_bSkipwzName = bSkipwzName; }
145 void SetHashMarkForType(bool bUseHashMarkForType) { m_bUseHashMarkForType = bUseHashMarkForType; }
146 void OverrideShapeIDGen(bool bOverrideShapeIdGeneration,
147 const OString& sShapeIDPrefix = OString());
149 protected:
150 /// Add an attribute to the generated <v:shape/> element.
152 /// This should be called from within StartShape() to ensure that the
153 /// added attribute is preserved.
154 void AddShapeAttribute( sal_Int32 nAttribute, const OString& sValue );
156 using EscherEx::StartShape;
157 using EscherEx::EndShape;
159 /// Override shape ID generation when m_bOverrideShapeIdGeneration is set to true
160 virtual sal_uInt32 GenerateShapeId() override;
162 /// Start the shape for which we just collected the information.
164 /// Returns the element's tag number, -1 means we wrote nothing.
165 virtual sal_Int32 StartShape();
167 /// End the shape.
169 /// The parameter is just what we got from StartShape().
170 virtual void EndShape( sal_Int32 nShapeElement );
171 virtual void Commit( EscherPropertyContainer& rProps, const tools::Rectangle& rRect ) override;
173 private:
175 virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 ) override;
176 virtual void CloseContainer() override;
178 virtual sal_uInt32 EnterGroup( const OUString& rShapeName, const tools::Rectangle* pBoundRect ) override;
179 virtual void LeaveGroup() override;
181 virtual void AddShape( sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId = 0 ) override;
183 private:
184 /// Create an OString representing the id from a numerical id.
185 OString ShapeIdString( sal_uInt32 nId );
187 /// Add flip X and\or flip Y
188 void AddFlipXY( );
190 /// Add starting and ending point of a line to the m_pShapeAttrList.
191 void AddLineDimensions( const tools::Rectangle& rRectangle );
193 /// Add position and size to the OStringBuffer.
194 void AddRectangleDimensions( OStringBuffer& rBuffer, const tools::Rectangle& rRectangle, bool rbAbsolutePos = true );
197 } // namespace vml
199 } // namespace oox
201 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */