Bump version to 6.4-15
[LibreOffice.git] / include / oox / vml / vmldrawing.hxx
blob40c3ba20de90feed74d6d1b3786351c5b42ebd00
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_VML_VMLDRAWING_HXX
21 #define INCLUDED_OOX_VML_VMLDRAWING_HXX
23 #include <map>
24 #include <memory>
25 #include <vector>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <oox/dllapi.h>
29 #include <oox/ole/oleobjecthelper.hxx>
30 #include <rtl/ustring.hxx>
31 #include <sal/types.h>
33 namespace com { namespace sun { namespace star {
34 namespace awt { struct Rectangle; }
35 namespace drawing { class XDrawPage; }
36 namespace drawing { class XShape; }
37 namespace drawing { class XShapes; }
38 } } }
40 namespace oox {
41 namespace core { class XmlFilterBase; }
42 namespace ole { class EmbeddedControl; }
43 namespace ole { class EmbeddedForm; }
44 namespace vml { class ShapeContainer; }
47 namespace oox {
48 namespace vml {
50 class ShapeBase;
53 /** Enumerates different types of VML drawings. */
54 enum DrawingType
56 VMLDRAWING_WORD, ///< Word: One shape per drawing.
57 VMLDRAWING_EXCEL, ///< Excel: OLE objects are part of VML.
58 VMLDRAWING_POWERPOINT ///< PowerPoint: OLE objects are part of DrawingML.
62 /** Contains information about an OLE object embedded in a draw page. */
63 struct OOX_DLLPUBLIC OleObjectInfo : public ::oox::ole::OleObjectInfo
65 OUString maShapeId; ///< Shape identifier for shape lookup.
66 OUString maName; ///< Programmatical name of the OLE object.
67 bool mbAutoLoad;
68 const bool mbDmlShape; ///< True = DrawingML shape (PowerPoint), false = VML shape (Excel/Word).
70 explicit OleObjectInfo( bool bDmlShape = false );
72 /** Sets the string representation of the passed numeric shape identifier. */
73 void setShapeId( sal_Int32 nShapeId );
76 // =========================================/===================================
78 /** Contains information about a form control embedded in a draw page. */
79 struct OOX_DLLPUBLIC ControlInfo
81 OUString maShapeId; ///< Shape identifier for shape lookup.
82 OUString maFragmentPath; ///< Path to the fragment describing the form control properties.
83 OUString maName; ///< Programmatical name of the form control.
84 bool mbTextContentShape; ///< Whether this control shape will be imported to Writer or not (has AnchorType property or not).
86 explicit ControlInfo();
88 /** Sets the string representation of the passed numeric shape identifier. */
89 void setShapeId( sal_Int32 nShapeId );
93 /** Represents the collection of VML shapes for a complete draw page. */
94 class OOX_DLLPUBLIC Drawing
96 public:
97 explicit Drawing(
98 ::oox::core::XmlFilterBase& rFilter,
99 const css::uno::Reference< css::drawing::XDrawPage >& rxDrawPage,
100 DrawingType eType );
102 virtual ~Drawing();
104 /** Returns the filter object that imports/exports this VML drawing. */
105 ::oox::core::XmlFilterBase& getFilter() const { return mrFilter; }
106 /** Returns the application type containing the drawing. */
107 DrawingType getType() const { return meType; }
108 /** Returns read/write access to the container of shapes and templates. */
109 ShapeContainer& getShapes() { return *mxShapes; }
110 /** Returns read access to the container of shapes and templates. */
111 const ShapeContainer& getShapes() const { return *mxShapes; }
112 /** Returns the form object used to process ActiveX form controls. */
113 ::oox::ole::EmbeddedForm& getControlForm() const;
115 /** Registers a block of shape identifiers reserved by this drawing. Block
116 size is 1024, shape identifiers are one-based (block 1 => 1025-2048). */
117 void registerBlockId( sal_Int32 nBlockId );
118 /** Registers the passed embedded OLE object. The related shape will then
119 load the OLE object data from the specified fragment. */
120 void registerOleObject( const OleObjectInfo& rOleObject );
121 /** Registers the passed embedded form control. The related shape will then
122 load the control properties from the specified fragment. */
123 void registerControl( const ControlInfo& rControl );
125 /** Final processing after import of the fragment. */
126 void finalizeFragmentImport();
128 /** Creates and inserts all UNO shapes into the draw page. The virtual
129 function notifyXShapeInserted() will be called for each new shape. */
130 void convertAndInsert() const;
132 /** Returns the local shape index from the passed global shape identifier. */
133 sal_Int32 getLocalShapeIndex( const OUString& rShapeId ) const;
134 /** Returns the registered info structure for an OLE object, if extant. */
135 const OleObjectInfo* getOleObjectInfo( const OUString& rShapeId ) const;
136 /** Returns the registered info structure for a form control, if extant. */
137 const ControlInfo* getControlInfo( const OUString& rShapeId ) const;
139 /** Creates a new UNO shape object, inserts it into the passed UNO shape
140 container, and sets the shape position and size. */
141 css::uno::Reference< css::drawing::XShape >
142 createAndInsertXShape(
143 const OUString& rService,
144 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
145 const css::awt::Rectangle& rShapeRect ) const;
147 /** Creates a new UNO shape object for a form control, inserts the control
148 model into the form, and the shape into the passed UNO shape container. */
149 css::uno::Reference< css::drawing::XShape >
150 createAndInsertXControlShape(
151 const ::oox::ole::EmbeddedControl& rControl,
152 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
153 const css::awt::Rectangle& rShapeRect,
154 sal_Int32& rnCtrlIndex ) const;
156 /** Derived classes may disable conversion of specific shapes. */
157 virtual bool isShapeSupported( const ShapeBase& rShape ) const;
159 /** Derived classes may return additional base names for automatic shape
160 name creation. */
161 virtual OUString getShapeBaseName( const ShapeBase& rShape ) const;
163 /** Derived classes may calculate the shape rectangle from a non-standard
164 anchor information string. */
165 virtual bool convertClientAnchor(
166 css::awt::Rectangle& orShapeRect,
167 const OUString& rShapeAnchor ) const;
169 /** Derived classes create a UNO shape according to the passed shape model.
170 Called for shape models that specify being under host control. */
171 virtual css::uno::Reference< css::drawing::XShape >
172 createAndInsertClientXShape(
173 const ShapeBase& rShape,
174 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
175 const css::awt::Rectangle& rShapeRect ) const;
177 /** Derived classes may want to know that a UNO shape has been inserted.
178 Will be called from the convertAndInsert() implementation.
179 @param bGroupChild True = inserted into a group shape,
180 false = inserted directly into this drawing. */
181 virtual void notifyXShapeInserted(
182 const css::uno::Reference< css::drawing::XShape >& rxShape,
183 const css::awt::Rectangle& rShapeRect,
184 const ShapeBase& rShape, bool bGroupChild );
186 private:
187 typedef ::std::vector< sal_Int32 > BlockIdVector;
188 typedef ::std::map< OUString, OleObjectInfo > OleObjectInfoMap;
189 typedef ::std::map< OUString, ControlInfo > ControlInfoMap;
191 ::oox::core::XmlFilterBase& mrFilter; ///< Filter object that imports/exports the VML drawing.
192 css::uno::Reference< css::drawing::XDrawPage >
193 mxDrawPage; ///< UNO draw page used to insert the shapes.
194 mutable std::unique_ptr<::oox::ole::EmbeddedForm> mxCtrlForm; ///< The control form used to process embedded controls.
195 mutable BlockIdVector maBlockIds; ///< Block identifiers used by this drawing.
196 std::unique_ptr<ShapeContainer> mxShapes; ///< All shapes and shape templates.
197 OleObjectInfoMap maOleObjects; ///< Info about all embedded OLE objects, mapped by shape id.
198 ControlInfoMap maControls; ///< Info about all embedded form controls, mapped by control name.
199 const DrawingType meType; ///< Application type containing the drawing.
203 } // namespace vml
204 } // namespace oox
206 #endif
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */