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_VML_VMLDRAWING_HXX
21 #define INCLUDED_OOX_VML_VMLDRAWING_HXX
26 #include <oox/ole/axcontrol.hxx>
27 #include <oox/ole/oleobjecthelper.hxx>
28 #include <oox/vml/vmlshapecontainer.hxx>
29 #include <oox/dllapi.h>
31 namespace com
{ namespace sun
{ namespace star
{
32 namespace awt
{ struct Rectangle
; }
33 namespace awt
{ class XControlModel
; }
34 namespace drawing
{ class XDrawPage
; }
35 namespace drawing
{ class XShape
; }
36 namespace drawing
{ class XShapes
; }
40 namespace core
{ class XmlFilterBase
; }
41 namespace ole
{ class EmbeddedControl
; }
52 /** Enumerates different types of VML drawings. */
55 VMLDRAWING_WORD
, ///< Word: One shape per drawing.
56 VMLDRAWING_EXCEL
, ///< Excel: OLE objects are part of VML.
57 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.
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.
85 explicit ControlInfo();
87 /** Sets the string representation of the passed numeric shape identifier. */
88 void setShapeId( sal_Int32 nShapeId
);
93 /** Represents the collection of VML shapes for a complete draw page. */
94 class OOX_DLLPUBLIC Drawing
98 ::oox::core::XmlFilterBase
& rFilter
,
99 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& rxDrawPage
,
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 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
142 createAndInsertXShape(
143 const OUString
& rService
,
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
145 const ::com::sun::star::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 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
150 createAndInsertXControlShape(
151 const ::oox::ole::EmbeddedControl
& rControl
,
152 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
153 const ::com::sun::star::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
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 ::com::sun::star::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 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
172 createAndInsertClientXShape(
173 const ShapeBase
& rShape
,
174 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
175 const ::com::sun::star::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 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& rxShape
,
183 const ::com::sun::star::awt::Rectangle
& rShapeRect
,
184 const ShapeBase
& rShape
, bool bGroupChild
);
187 typedef ::std::vector
< sal_Int32
> BlockIdVector
;
188 typedef ::std::unique_ptr
< ::oox::ole::EmbeddedForm
> EmbeddedFormPtr
;
189 typedef ::std::unique_ptr
< ShapeContainer
> ShapeContainerPtr
;
190 typedef ::std::map
< OUString
, OleObjectInfo
> OleObjectInfoMap
;
191 typedef ::std::map
< OUString
, ControlInfo
> ControlInfoMap
;
193 ::oox::core::XmlFilterBase
& mrFilter
; ///< Filter object that imports/exports the VML drawing.
194 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>
195 mxDrawPage
; ///< UNO draw page used to insert the shapes.
196 mutable EmbeddedFormPtr mxCtrlForm
; ///< The control form used to process embedded controls.
197 mutable BlockIdVector maBlockIds
; ///< Block identifiers used by this drawing.
198 ShapeContainerPtr mxShapes
; ///< All shapes and shape templates.
199 OleObjectInfoMap maOleObjects
; ///< Info about all embedded OLE objects, mapped by shape id.
200 ControlInfoMap maControls
; ///< Info about all embedded form controls, mapped by control name.
201 const DrawingType meType
; ///< Application type containing the drawing.
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */