1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <oox/dllapi.h>
24 #include <oox/export/drawingml.hxx>
25 #include <sax/fshelper.hxx>
26 #include <filter/msfilter/escherex.hxx>
27 #include <editeng/outlobj.hxx>
34 /// Interface to be implemented by the parent exporter that knows how to handle shape text.
35 class OOX_DLLPUBLIC VMLTextExport
38 virtual void WriteOutliner(const OutlinerParaObject
& rParaObj
) = 0;
39 virtual oox::drawingml::DrawingML
& GetDrawingML() = 0;
40 /// Write the contents of the textbox that is associated to this shape in VML format.
41 virtual void WriteVMLTextBox(css::uno::Reference
<css::drawing::XShape
> xShape
) = 0;
42 /// Look up the RelId of a graphic based on its checksum.
43 virtual OUString
FindRelId(BitmapChecksum nChecksum
) = 0;
44 /// Store the RelId of a graphic based on its checksum.
45 virtual void CacheRelId(BitmapChecksum nChecksum
, const OUString
& rRelId
) = 0;
48 virtual ~VMLTextExport() {}
51 class OOX_DLLPUBLIC VMLExport
: public EscherEx
53 /// Fast serializer to output the data
54 ::sax_fastparser::FSHelperPtr m_pSerializer
;
56 /// Parent exporter, used for text callback.
57 VMLTextExport
* m_pTextExport
;
60 sal_Int16 m_eHOri
, m_eVOri
, m_eHRel
, m_eVRel
;
63 const Point
* m_pNdTopLeft
;
65 /// The object we're exporting.
66 const SdrObject
* m_pSdrObject
;
68 /// Fill the shape attributes as they come.
69 ::sax_fastparser::FastAttributeList
*m_pShapeAttrList
;
71 /// Remember the shape type.
72 sal_uInt32 m_nShapeType
;
74 /// Remember the shape flags.
75 sal_uInt32 m_nShapeFlags
;
77 /// Remember style, the most important shape attribute ;-)
78 OStringBuffer
*m_pShapeStyle
;
80 /// Remember which shape types we had already written.
81 bool *m_pShapeTypeWritten
;
84 VMLExport( ::sax_fastparser::FSHelperPtr pSerializer
, VMLTextExport
* pTextExport
= 0 );
87 ::sax_fastparser::FSHelperPtr
88 GetFS() { return m_pSerializer
; }
90 void SetFS(::sax_fastparser::FSHelperPtr pSerializer
);
92 /// Export the sdr object as VML.
94 /// Call this when you need to export the object as VML.
95 sal_uInt32
AddSdrObject( const SdrObject
& rObj
, sal_Int16 eHOri
= -1,
96 sal_Int16 eVOri
= -1, sal_Int16 eHRel
= -1,
97 sal_Int16 eVRel
= -1, const Point
* pNdTopLeft
= 0, const bool bOOxmlExport
= false );
98 virtual void AddSdrObjectVMLObject( const SdrObject
& rObj
) SAL_OVERRIDE
;
99 static bool IsWaterMarkShape(const OUString
& rStr
);
101 /// Add an attribute to the generated <v:shape/> element.
103 /// This should be called from within StartShape() to ensure that the
104 /// added attribute is preserved.
105 void AddShapeAttribute( sal_Int32 nAttribute
, const OString
& sValue
);
107 using EscherEx::StartShape
;
108 using EscherEx::EndShape
;
110 /// Start the shape for which we just collected the information.
112 /// Returns the element's tag number, -1 means we wrote nothing.
113 virtual sal_Int32
StartShape();
117 /// The parameter is just what we got from StartShape().
118 virtual void EndShape( sal_Int32 nShapeElement
);
119 virtual void Commit( EscherPropertyContainer
& rProps
, const Rectangle
& rRect
) SAL_OVERRIDE
;
123 virtual void OpenContainer( sal_uInt16 nEscherContainer
, int nRecInstance
= 0 ) SAL_OVERRIDE
;
124 virtual void CloseContainer() SAL_OVERRIDE
;
126 virtual sal_uInt32
EnterGroup( const OUString
& rShapeName
, const Rectangle
* pBoundRect
= 0 ) SAL_OVERRIDE
;
127 virtual void LeaveGroup() SAL_OVERRIDE
;
129 virtual void AddShape( sal_uInt32 nShapeType
, sal_uInt32 nShapeFlags
, sal_uInt32 nShapeId
= 0 ) SAL_OVERRIDE
;
132 /// Create an OString representing the id from a numerical id.
133 static OString
ShapeIdString( sal_uInt32 nId
);
135 /// Add flip X and\or flip Y
138 /// Add starting and ending point of a line to the m_pShapeAttrList.
139 void AddLineDimensions( const Rectangle
& rRectangle
);
141 /// Add position and size to the OStringBuffer.
142 void AddRectangleDimensions( OStringBuffer
& rBuffer
, const Rectangle
& rRectangle
, bool rbAbsolutePos
= true );
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */