LibreOffice Module oox (master)  1
vmlexport.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
21 #define INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
22 
23 #include <sal/config.h>
24 
25 #include <string_view>
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <editeng/outlobj.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>
38 
39 namespace com::sun::star {
40  namespace drawing {
41  class XShape;
42  }
43 }
44 
45 namespace oox::drawingml {
46  class DrawingML;
47 }
48 
49 
50 namespace sax_fastparser {
51  class FastAttributeList;
52 }
53 
54 class Point;
55 namespace tools { class Rectangle; }
56 class SdrObject;
57 
58 namespace oox::vml {
59 
62 {
63 public:
64  virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
65  virtual oox::drawingml::DrawingML& GetDrawingML() = 0;
67  virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
69  virtual OUString FindRelId(BitmapChecksum nChecksum) = 0;
71  virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId, const OUString& rFileName) = 0;
72 protected:
74  virtual ~VMLTextExport() {}
75 };
76 
78 {
81 
84 
86  sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel;
88  bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER
89  bool m_IsFollowingTextFlow = false;
90 
93 
96 
98  sal_uInt32 m_nShapeType;
99 
102 
104  OStringBuffer m_ShapeStyle;
105 
107  OStringBuffer m_TextboxStyle;
108 
110  OString m_sShapeId;
111 
113  std::vector<bool> m_aShapeTypeWritten;
114 
117 
120 
125 
128 
130  sal_uInt64 m_nShapeIDCounter;
131 
132 public:
133  VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLTextExport* pTextExport = nullptr);
134  virtual ~VMLExport() override;
135 
136  const ::sax_fastparser::FSHelperPtr&
137  GetFS() const { return m_pSerializer; }
138 
139  void SetFS(const ::sax_fastparser::FSHelperPtr& pSerializer);
140 
144  OString const & AddSdrObject( const SdrObject& rObj,
145  bool const bIsFollowingTextFlow = false,
146  sal_Int16 eHOri = -1, sal_Int16 eVOri = -1, sal_Int16 eHRel = -1,
147  sal_Int16 eVRel = -1,
148  sax_fastparser::FastAttributeList* pWrapAttrList = nullptr,
149  const bool bOOxmlExport = false );
150  OString const & AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport );
151  virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override;
152  static bool IsWaterMarkShape(const OUString& rStr);
153 
154  void SetSkipwzName(bool bSkipwzName) { m_bSkipwzName = bSkipwzName; }
155  void SetHashMarkForType(bool bUseHashMarkForType) { m_bUseHashMarkForType = bUseHashMarkForType; }
156  void OverrideShapeIDGen(bool bOverrideShapeIdGeneration,
157  const OString& sShapeIDPrefix = OString());
158  static OString GetVMLShapeTypeDefinition(std::string_view sShapeID, const bool bIsPictureFrame);
159 
160 protected:
165  void AddShapeAttribute( sal_Int32 nAttribute, const OString& sValue );
166 
167  using EscherEx::StartShape;
168  using EscherEx::EndShape;
169 
171  virtual sal_uInt32 GenerateShapeId() override;
172 
176  virtual sal_Int32 StartShape();
177 
181  virtual void EndShape( sal_Int32 nShapeElement );
182  virtual void Commit( EscherPropertyContainer& rProps, const tools::Rectangle& rRect ) override;
183 
184 private:
185 
186  virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 ) override;
187  virtual void CloseContainer() override;
188 
189  virtual sal_uInt32 EnterGroup( const OUString& rShapeName, const tools::Rectangle* pBoundRect ) override;
190  virtual void LeaveGroup() override;
191 
192  virtual void AddShape( sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId = 0 ) override;
193 
194 private:
196  OString ShapeIdString( sal_uInt32 nId );
197 
199  void AddFlipXY( );
200 
202  void AddLineDimensions( const tools::Rectangle& rRectangle );
203 
205  void AddRectangleDimensions( OStringBuffer& rBuffer, const tools::Rectangle& rRectangle, bool rbAbsolutePos = true );
206 };
207 
208 
209 } // namespace oox::vml
210 
211 #endif
212 
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference<::sax_fastparser::FastAttributeList > m_pShapeAttrList
Fill the shape attributes as they come.
Definition: vmlexport.hxx:95
virtual void EndShape(sal_uInt16 nShapeType, sal_uInt32 nShapeID)
sal_uInt64 BitmapChecksum
sal_uInt32 m_nShapeType
Remember the shape type.
Definition: vmlexport.hxx:98
const SdrObject * m_pSdrObject
The object we're exporting.
Definition: vmlexport.hxx:92
bool m_bOverrideShapeIdGeneration
There is a shapeid generation mechanism in EscherEx, but it does not seem to work so override the exi...
Definition: vmlexport.hxx:124
sal_Int16 nId
Definition: olehelper.cxx:97
virtual EscherExHostAppData * StartShape(const css::uno::Reference< css::drawing::XShape > &rShape, const tools::Rectangle *pChildAnchor)
std::vector< bool > m_aShapeTypeWritten
Remember which shape types we had already written.
Definition: vmlexport.hxx:113
OString m_sShapeId
Remember the generated shape id.
Definition: vmlexport.hxx:110
VMLTextExport * m_pTextExport
Parent exporter, used for text callback.
Definition: vmlexport.hxx:83
void SetSkipwzName(bool bSkipwzName)
Definition: vmlexport.hxx:154
void SetHashMarkForType(bool bUseHashMarkForType)
Definition: vmlexport.hxx:155
rtl::Reference< sax_fastparser::FastAttributeList > m_pWrapAttrList
Definition: vmlexport.hxx:87
exports com.sun.star. drawing
ShapeFlag
bool m_bUseHashMarkForType
Use '#' mark for type attribute (check Type Attribute of VML shape in OOXML documentation) ...
Definition: vmlexport.hxx:119
sal_uInt64 m_nShapeIDCounter
Counter for generating shape ids (used if m_bOverrideShapeIdGeneration is true)
Definition: vmlexport.hxx:130
OStringBuffer m_TextboxStyle
style for textbox
Definition: vmlexport.hxx:107
std::shared_ptr< FastSerializerHelper > FSHelperPtr
bool m_bSkipwzName
It seems useless to write out an XML_ID attribute next to XML_id which defines the actual shape id...
Definition: vmlexport.hxx:116
OStringBuffer m_ShapeStyle
Remember style, the most important shape attribute ;-)
Definition: vmlexport.hxx:104
::sax_fastparser::FSHelperPtr m_pSerializer
Fast serializer to output the data.
Definition: vmlexport.hxx:80
const ::sax_fastparser::FSHelperPtr & GetFS() const
Definition: vmlexport.hxx:137
OString m_sShapeIDPrefix
Prefix for overridden shape id generation (used if m_bOverrideShapeIdGeneration is true) ...
Definition: vmlexport.hxx:127
Interface to be implemented by the parent exporter that knows how to handle shape text...
Definition: vmlexport.hxx:61
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
ShapeFlag m_nShapeFlags
Remember the shape flags.
Definition: vmlexport.hxx:101