xref: /aoo42x/main/oox/inc/oox/xls/drawingmanager.hxx (revision 67e470da)
1*ebfcd9afSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ebfcd9afSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ebfcd9afSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ebfcd9afSAndrew Rist  * distributed with this work for additional information
6*ebfcd9afSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ebfcd9afSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ebfcd9afSAndrew Rist  * "License"); you may not use this file except in compliance
9*ebfcd9afSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ebfcd9afSAndrew Rist  *
11*ebfcd9afSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ebfcd9afSAndrew Rist  *
13*ebfcd9afSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ebfcd9afSAndrew Rist  * software distributed under the License is distributed on an
15*ebfcd9afSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ebfcd9afSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ebfcd9afSAndrew Rist  * specific language governing permissions and limitations
18*ebfcd9afSAndrew Rist  * under the License.
19*ebfcd9afSAndrew Rist  *
20*ebfcd9afSAndrew Rist  *************************************************************/
21*ebfcd9afSAndrew Rist 
22*ebfcd9afSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef OOX_XLS_DRAWINGMANAGER_HXX
25cdf0e10cSrcweir #define OOX_XLS_DRAWINGMANAGER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "oox/xls/drawingbase.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir namespace com { namespace sun { namespace star {
30cdf0e10cSrcweir     namespace drawing { class XDrawPage; }
31cdf0e10cSrcweir     namespace drawing { class XShape; }
32cdf0e10cSrcweir     namespace drawing { class XShapes; }
33cdf0e10cSrcweir } } }
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace oox { namespace drawingml { class ShapePropertyMap; } }
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace oox {
38cdf0e10cSrcweir namespace xls {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir // ============================================================================
41cdf0e10cSrcweir 
42cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_INVALID_ID        = 0;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // ============================================================================
45cdf0e10cSrcweir // Model structures for BIFF OBJ record data
46cdf0e10cSrcweir // ============================================================================
47cdf0e10cSrcweir 
48cdf0e10cSrcweir /** This structure contains line formatting attributes from an OBJ record. */
49cdf0e10cSrcweir struct BiffObjLineModel
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     sal_uInt8           mnColorIdx;         /// Index into color palette.
52cdf0e10cSrcweir     sal_uInt8           mnStyle;            /// Line dash style.
53cdf0e10cSrcweir     sal_uInt8           mnWidth;            /// Line width.
54cdf0e10cSrcweir     bool                mbAuto;             /// True = automatic line format.
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     explicit            BiffObjLineModel();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     /** Returns true, if the line formatting is visible (automatic or explicit). */
59cdf0e10cSrcweir     bool                isVisible() const;
60cdf0e10cSrcweir };
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // ============================================================================
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /** This structure contains fill formatting attributes from an OBJ record. */
65cdf0e10cSrcweir struct BiffObjFillModel
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     sal_uInt8           mnBackColorIdx;     /// Index to color palette for background color.
68cdf0e10cSrcweir     sal_uInt8           mnPattColorIdx;     /// Index to color palette for pattern foreground color.
69cdf0e10cSrcweir     sal_uInt8           mnPattern;          /// Fill pattern.
70cdf0e10cSrcweir     bool                mbAuto;             /// True = automatic fill format.
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     explicit            BiffObjFillModel();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     /** Returns true, if the fill formatting is visible (automatic or explicit). */
75cdf0e10cSrcweir     bool                isFilled() const;
76cdf0e10cSrcweir };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // ============================================================================
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /** This structure contains text formatting attributes from an OBJ record. */
81cdf0e10cSrcweir struct BiffObjTextModel
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     sal_uInt16          mnTextLen;          /// Length of the text (characters).
84cdf0e10cSrcweir     sal_uInt16          mnFormatSize;       /// Size of the formatting array (bytes).
85cdf0e10cSrcweir     sal_uInt16          mnLinkSize;         /// Size of the linked text formula (bytes).
86cdf0e10cSrcweir     sal_uInt16          mnDefFontId;        /// Font index for default font formatting.
87cdf0e10cSrcweir     sal_uInt16          mnFlags;            /// Additional flags.
88cdf0e10cSrcweir     sal_uInt16          mnOrientation;      /// Text orientation.
89cdf0e10cSrcweir     sal_uInt16          mnButtonFlags;      /// Additional flags for push buttons.
90cdf0e10cSrcweir     sal_uInt16          mnShortcut;         /// Shortcut character.
91cdf0e10cSrcweir     sal_uInt16          mnShortcutEA;       /// East-asian shortcut character.
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     explicit            BiffObjTextModel();
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     /** Reads text data from a BIFF3/BIFF4 OBJ record. */
96cdf0e10cSrcweir     void                readObj3( BiffInputStream& rStrm );
97cdf0e10cSrcweir     /** Reads text data from a BIFF5 OBJ record. */
98cdf0e10cSrcweir     void                readObj5( BiffInputStream& rStrm );
99cdf0e10cSrcweir     /** Reads text data from a BIFF8 TXO record. */
100cdf0e10cSrcweir     void                readTxo8( BiffInputStream& rStrm );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     /** Returns the horizontal alignment of the text. */
103cdf0e10cSrcweir     sal_uInt8           getHorAlign() const;
104cdf0e10cSrcweir     /** Returns the vertical alignment of the text. */
105cdf0e10cSrcweir     sal_uInt8           getVerAlign() const;
106cdf0e10cSrcweir };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir // ============================================================================
109cdf0e10cSrcweir // BIFF drawing objects
110cdf0e10cSrcweir // ============================================================================
111cdf0e10cSrcweir 
112cdf0e10cSrcweir class BiffDrawingBase;
113cdf0e10cSrcweir class BiffDrawingObjectBase;
114cdf0e10cSrcweir typedef ::boost::shared_ptr< BiffDrawingObjectBase > BiffDrawingObjectRef;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // ----------------------------------------------------------------------------
117cdf0e10cSrcweir 
118cdf0e10cSrcweir class BiffDrawingObjectContainer
119cdf0e10cSrcweir {
120cdf0e10cSrcweir public:
121cdf0e10cSrcweir     explicit            BiffDrawingObjectContainer();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     /** Returns true, if the object list is empty. */
empty() const124cdf0e10cSrcweir     inline bool         empty() const { return maObjects.empty(); }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     /** Appends the passed object to the list of objects. */
127cdf0e10cSrcweir     void                append( const BiffDrawingObjectRef& rxDrawingObj );
128cdf0e10cSrcweir     /** Tries to insert the passed object into the last group or appends it. */
129cdf0e10cSrcweir     void                insertGrouped( const BiffDrawingObjectRef& rxDrawingObj );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     /** Creates and inserts all UNO shapes into the passed shape container. */
132cdf0e10cSrcweir     void                convertAndInsert( BiffDrawingBase& rDrawing,
133cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
134cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle* pParentRect = 0 ) const;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir private:
137cdf0e10cSrcweir     typedef RefVector< BiffDrawingObjectBase > BiffDrawingObjectVector;
138cdf0e10cSrcweir     BiffDrawingObjectVector maObjects;
139cdf0e10cSrcweir };
140cdf0e10cSrcweir 
141cdf0e10cSrcweir // ============================================================================
142cdf0e10cSrcweir 
143cdf0e10cSrcweir /** Base class for all BIFF drawing objects (OBJ records). */
144cdf0e10cSrcweir class BiffDrawingObjectBase : public WorksheetHelper
145cdf0e10cSrcweir {
146cdf0e10cSrcweir public:
147cdf0e10cSrcweir     explicit            BiffDrawingObjectBase( const WorksheetHelper& rHelper );
148cdf0e10cSrcweir     virtual             ~BiffDrawingObjectBase();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     /** Reads the BIFF3 OBJ record, returns a new drawing object. */
151cdf0e10cSrcweir     static BiffDrawingObjectRef importObjBiff3( const WorksheetHelper& rHelper, BiffInputStream& rStrm );
152cdf0e10cSrcweir     /** Reads the BIFF4 OBJ record, returns a new drawing object. */
153cdf0e10cSrcweir     static BiffDrawingObjectRef importObjBiff4( const WorksheetHelper& rHelper, BiffInputStream& rStrm );
154cdf0e10cSrcweir     /** Reads the BIFF5 OBJ record, returns a new drawing object. */
155cdf0e10cSrcweir     static BiffDrawingObjectRef importObjBiff5( const WorksheetHelper& rHelper, BiffInputStream& rStrm );
156cdf0e10cSrcweir     /** Reads the BIFF8 OBJ record, returns a new drawing object. */
157cdf0e10cSrcweir     static BiffDrawingObjectRef importObjBiff8( const WorksheetHelper& rHelper, BiffInputStream& rStrm );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     /** Sets whether this is an area object (then its width and height must be greater than 0). */
setAreaObj(bool bAreaObj)160cdf0e10cSrcweir     inline void         setAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
161cdf0e10cSrcweir     /** If set to true, the object supports a simple on-click macro and/or hyperlink. */
setSimpleMacro(bool bMacro)162cdf0e10cSrcweir     inline void         setSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     /** If set to false, the UNO shape will not be created, processed, or inserted into the draw page. */
setProcessShape(bool bProcess)165cdf0e10cSrcweir     inline void         setProcessShape( bool bProcess ) { mbProcessShape = bProcess; }
166cdf0e10cSrcweir     /** If set to false, the UNO shape will be created or processed, but not be inserted into the draw page. */
setInsertShape(bool bInsert)167cdf0e10cSrcweir     inline void         setInsertShape( bool bInsert ) { mbInsertShape = bInsert; }
168cdf0e10cSrcweir     /** If set to true, a new custom UNO shape will be created while in DFF import (BIFF8 only). */
setCustomDffObj(bool bCustom)169cdf0e10cSrcweir     inline void         setCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     /** Returns the object identifier from the OBJ record. */
getObjId() const172cdf0e10cSrcweir     inline sal_uInt16   getObjId() const { return mnObjId; }
173cdf0e10cSrcweir     /** Returns the object type from the OBJ record. */
getObjType() const174cdf0e10cSrcweir     inline sal_uInt16   getObjType() const { return mnObjType; }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     /** Returns true, if the object is hidden. */
isHidden() const177cdf0e10cSrcweir     inline bool         isHidden() const { return mbHidden; }
178cdf0e10cSrcweir     /** Returns true, if the object is visible. */
isVisible() const179cdf0e10cSrcweir     inline bool         isVisible() const { return mbVisible; }
180cdf0e10cSrcweir     /** Returns true, if the object is printable. */
isPrintable() const181cdf0e10cSrcweir     inline bool         isPrintable() const { return mbPrintable; }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     /** Creates the UNO shape and inserts it into the passed shape container. */
184cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
185cdf0e10cSrcweir                         convertAndInsert( BiffDrawingBase& rDrawing,
186cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
187cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle* pParentRect = 0 ) const;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir protected:
190cdf0e10cSrcweir     /** Reads the object name in a BIFF5 OBJ record. */
191cdf0e10cSrcweir     void                readNameBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen );
192cdf0e10cSrcweir     /** Reads the macro link in a BIFF3 OBJ record. */
193cdf0e10cSrcweir     void                readMacroBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
194cdf0e10cSrcweir     /** Reads the macro link in a BIFF4 OBJ record. */
195cdf0e10cSrcweir     void                readMacroBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
196cdf0e10cSrcweir     /** Reads the macro link in a BIFF5 OBJ record. */
197cdf0e10cSrcweir     void                readMacroBiff5( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
198cdf0e10cSrcweir     /** Reads the contents of the ftMacro sub structure in an OBJ record. */
199cdf0e10cSrcweir     void                readMacroBiff8( BiffInputStream& rStrm );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     /** Converts the passed line formatting to the passed property map. */
202cdf0e10cSrcweir     void                convertLineProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows = 0 ) const;
203cdf0e10cSrcweir     /** Converts the passed fill formatting to the passed property map. */
204cdf0e10cSrcweir     void                convertFillProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const;
205cdf0e10cSrcweir     /** Converts the passed frame flags to the passed property map. */
206cdf0e10cSrcweir     void                convertFrameProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, sal_uInt16 nFrameFlags ) const;
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     /** Derived classes read the contents of the a BIFF3 OBJ record from the passed stream. */
209cdf0e10cSrcweir     virtual void        implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
210cdf0e10cSrcweir     /** Derived classes read the contents of the a BIFF4 OBJ record from the passed stream. */
211cdf0e10cSrcweir     virtual void        implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
212cdf0e10cSrcweir     /** Derived classes read the contents of the a BIFF5 OBJ record from the passed stream. */
213cdf0e10cSrcweir     virtual void        implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
214cdf0e10cSrcweir     /** Derived classes read the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
215cdf0e10cSrcweir     virtual void        implReadObjBiff8SubRec( BiffInputStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     /** Derived classes create the corresponding XShape and insert it into the passed container. */
218cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
219cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
220cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
221cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0;
222cdf0e10cSrcweir 
223cdf0e10cSrcweir private:
224cdf0e10cSrcweir     /** Reads the contents of a BIFF3 OBJ record. */
225cdf0e10cSrcweir     void                importObjBiff3( BiffInputStream& rStrm );
226cdf0e10cSrcweir     /** Reads the contents of a BIFF4 OBJ record. */
227cdf0e10cSrcweir     void                importObjBiff4( BiffInputStream& rStrm );
228cdf0e10cSrcweir     /** Reads the contents of a BIFF5 OBJ record. */
229cdf0e10cSrcweir     void                importObjBiff5( BiffInputStream& rStrm );
230cdf0e10cSrcweir     /** Reads the contents of a BIFF8 OBJ record. */
231cdf0e10cSrcweir     void                importObjBiff8( BiffInputStream& rStrm );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir private:
234cdf0e10cSrcweir     ShapeAnchor         maAnchor;       /// Position of the drawing object.
235cdf0e10cSrcweir     ::rtl::OUString     maObjName;      /// Name of the object.
236cdf0e10cSrcweir     ::rtl::OUString     maMacroName;    /// Name of an attached macro.
237cdf0e10cSrcweir     ::rtl::OUString     maHyperlink;    /// On-click hyperlink URL.
238cdf0e10cSrcweir     sal_uInt32          mnDffShapeId;   /// Shape identifier from DFF stream (BIFF8 only).
239cdf0e10cSrcweir     sal_uInt32          mnDffFlags;     /// Shape flags from DFF stream.
240cdf0e10cSrcweir     sal_uInt16          mnObjId;        /// The object identifier (unique per drawing).
241cdf0e10cSrcweir     sal_uInt16          mnObjType;      /// The object type from OBJ record.
242cdf0e10cSrcweir     bool                mbHasAnchor;    /// True = anchor has been initialized.
243cdf0e10cSrcweir     bool                mbHidden;       /// True = object is hidden.
244cdf0e10cSrcweir     bool                mbVisible;      /// True = object is visible (form controls).
245cdf0e10cSrcweir     bool                mbPrintable;    /// True = object is printable.
246cdf0e10cSrcweir     bool                mbAreaObj;      /// True = width and height must be greater than 0.
247cdf0e10cSrcweir     bool                mbAutoMargin;   /// True = set automatic text margin.
248cdf0e10cSrcweir     bool                mbSimpleMacro;  /// True = create simple macro link and hyperlink.
249cdf0e10cSrcweir     bool                mbProcessShape; /// True = object is valid, do processing and insertion.
250cdf0e10cSrcweir     bool                mbInsertShape;  /// True = insert the UNO shape into the draw page.
251cdf0e10cSrcweir     bool                mbCustomDff;    /// True = recreate UNO shape in DFF import (BIFF8 only).
252cdf0e10cSrcweir };
253cdf0e10cSrcweir 
254cdf0e10cSrcweir // ============================================================================
255cdf0e10cSrcweir 
256cdf0e10cSrcweir /** A placeholder object for unknown/unsupported object types. */
257cdf0e10cSrcweir class BiffPlaceholderObject : public BiffDrawingObjectBase
258cdf0e10cSrcweir {
259cdf0e10cSrcweir public:
260cdf0e10cSrcweir     explicit            BiffPlaceholderObject( const WorksheetHelper& rHelper );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir protected:
263cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
264cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
265cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
266cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
267cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
268cdf0e10cSrcweir };
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // ============================================================================
271cdf0e10cSrcweir 
272cdf0e10cSrcweir /** A group object that is able to contain other child objects. */
273cdf0e10cSrcweir class BiffGroupObject : public BiffDrawingObjectBase
274cdf0e10cSrcweir {
275cdf0e10cSrcweir public:
276cdf0e10cSrcweir     explicit            BiffGroupObject( const WorksheetHelper& rHelper );
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     /** Tries to insert the passed drawing object into this or a nested group. */
279cdf0e10cSrcweir     bool                tryInsert( const BiffDrawingObjectRef& rxDrawingObj );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir protected:
282cdf0e10cSrcweir     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
283cdf0e10cSrcweir     virtual void        implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
284cdf0e10cSrcweir     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
285cdf0e10cSrcweir     virtual void        implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
286cdf0e10cSrcweir     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
287cdf0e10cSrcweir     virtual void        implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
290cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
291cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
292cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
293cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir protected:
296cdf0e10cSrcweir     BiffDrawingObjectContainer maChildren;     /// All child objects contained in this group object.
297cdf0e10cSrcweir     sal_uInt16          mnFirstUngrouped;   /// Object identfier of first object not grouped into this group.
298cdf0e10cSrcweir };
299cdf0e10cSrcweir 
300cdf0e10cSrcweir // ============================================================================
301cdf0e10cSrcweir 
302cdf0e10cSrcweir /** A simple line object. */
303cdf0e10cSrcweir class BiffLineObject : public BiffDrawingObjectBase
304cdf0e10cSrcweir {
305cdf0e10cSrcweir public:
306cdf0e10cSrcweir     explicit            BiffLineObject( const WorksheetHelper& rHelper );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir protected:
309cdf0e10cSrcweir     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
310cdf0e10cSrcweir     virtual void        implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
311cdf0e10cSrcweir     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
312cdf0e10cSrcweir     virtual void        implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
313cdf0e10cSrcweir     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
314cdf0e10cSrcweir     virtual void        implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
317cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
318cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
319cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
320cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir protected:
323cdf0e10cSrcweir     BiffObjLineModel    maLineModel;    /// Line formatting.
324cdf0e10cSrcweir     sal_uInt16          mnArrows;       /// Line arrows.
325cdf0e10cSrcweir     sal_uInt8           mnStartPoint;   /// Starting point.
326cdf0e10cSrcweir };
327cdf0e10cSrcweir 
328cdf0e10cSrcweir // ============================================================================
329cdf0e10cSrcweir 
330cdf0e10cSrcweir /** A simple rectangle object (used as base class for oval objects). */
331cdf0e10cSrcweir class BiffRectObject : public BiffDrawingObjectBase
332cdf0e10cSrcweir {
333cdf0e10cSrcweir public:
334cdf0e10cSrcweir     explicit            BiffRectObject( const WorksheetHelper& rHelper );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir protected:
337cdf0e10cSrcweir     /** Reads the fill model, the line model, and frame flags. */
338cdf0e10cSrcweir     void                readFrameData( BiffInputStream& rStrm );
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     /** Converts fill formatting, line formatting, and frame style. */
341cdf0e10cSrcweir     void                convertRectProperties( ::oox::drawingml::ShapePropertyMap& rPropMap ) const;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
344cdf0e10cSrcweir     virtual void        implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
345cdf0e10cSrcweir     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
346cdf0e10cSrcweir     virtual void        implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
347cdf0e10cSrcweir     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
348cdf0e10cSrcweir     virtual void        implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
351cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
352cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
353cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
354cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir protected:
357cdf0e10cSrcweir     BiffObjFillModel    maFillModel;    /// Fill formatting.
358cdf0e10cSrcweir     BiffObjLineModel    maLineModel;    /// Line formatting.
359cdf0e10cSrcweir     sal_uInt16          mnFrameFlags;   /// Additional flags.
360cdf0e10cSrcweir };
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // ============================================================================
363cdf0e10cSrcweir 
364cdf0e10cSrcweir /** A simple oval object. */
365cdf0e10cSrcweir class BiffOvalObject : public BiffRectObject
366cdf0e10cSrcweir {
367cdf0e10cSrcweir public:
368cdf0e10cSrcweir     explicit            BiffOvalObject( const WorksheetHelper& rHelper );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir protected:
371cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
372cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
373cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
374cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
375cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
376cdf0e10cSrcweir };
377cdf0e10cSrcweir 
378cdf0e10cSrcweir // ============================================================================
379cdf0e10cSrcweir 
380cdf0e10cSrcweir /** A simple arc object. */
381cdf0e10cSrcweir class BiffArcObject : public BiffDrawingObjectBase
382cdf0e10cSrcweir {
383cdf0e10cSrcweir public:
384cdf0e10cSrcweir     explicit            BiffArcObject( const WorksheetHelper& rHelper );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir protected:
387cdf0e10cSrcweir     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
388cdf0e10cSrcweir     virtual void        implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
389cdf0e10cSrcweir     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
390cdf0e10cSrcweir     virtual void        implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
391cdf0e10cSrcweir     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
392cdf0e10cSrcweir     virtual void        implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
395cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
396cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
397cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
398cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
399cdf0e10cSrcweir 
400cdf0e10cSrcweir protected:
401cdf0e10cSrcweir     BiffObjFillModel    maFillModel;    /// Fill formatting.
402cdf0e10cSrcweir     BiffObjLineModel    maLineModel;    /// Line formatting.
403cdf0e10cSrcweir     sal_uInt8           mnQuadrant;     /// Visible quadrant of the circle.
404cdf0e10cSrcweir };
405cdf0e10cSrcweir 
406cdf0e10cSrcweir // ============================================================================
407cdf0e10cSrcweir 
408cdf0e10cSrcweir /** A simple polygon object. */
409cdf0e10cSrcweir class BiffPolygonObject : public BiffRectObject
410cdf0e10cSrcweir {
411cdf0e10cSrcweir public:
412cdf0e10cSrcweir     explicit            BiffPolygonObject( const WorksheetHelper& rHelper );
413cdf0e10cSrcweir 
414cdf0e10cSrcweir protected:
415cdf0e10cSrcweir     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
416cdf0e10cSrcweir     virtual void        implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize );
417cdf0e10cSrcweir     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
418cdf0e10cSrcweir     virtual void        implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
419cdf0e10cSrcweir 
420cdf0e10cSrcweir     /** Creates the corresponding XShape and insert it into the passed container. */
421cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
422cdf0e10cSrcweir                         implConvertAndInsert( BiffDrawingBase& rDrawing,
423cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
424cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir private:
427cdf0e10cSrcweir     /** Reads the COORDLIST record following the OBJ record. */
428cdf0e10cSrcweir     void                importCoordList( BiffInputStream& rStrm );
429cdf0e10cSrcweir 
430cdf0e10cSrcweir protected:
431cdf0e10cSrcweir     typedef ::std::vector< ::com::sun::star::awt::Point > PointVector;
432cdf0e10cSrcweir     PointVector         maCoords;       /// Coordinates relative to bounding rectangle.
433cdf0e10cSrcweir     sal_uInt16          mnPolyFlags;    /// Additional flags.
434cdf0e10cSrcweir     sal_uInt16          mnPointCount;   /// Polygon point count.
435cdf0e10cSrcweir };
436cdf0e10cSrcweir 
437cdf0e10cSrcweir // ============================================================================
438cdf0e10cSrcweir // BIFF drawing page
439cdf0e10cSrcweir // ============================================================================
440cdf0e10cSrcweir 
441cdf0e10cSrcweir /** Base class for a container for all objects on a drawing page (in a
442cdf0e10cSrcweir     spreadsheet or in an embedded chart object).
443cdf0e10cSrcweir 
444cdf0e10cSrcweir     For BIFF import, it is needed to load all drawing objects before converting
445cdf0e10cSrcweir     them to UNO shapes. There might be some dummy drawing objects (e.g. the
446cdf0e10cSrcweir     dropdown buttons of autofilters) which have to be skipped. The information,
447cdf0e10cSrcweir     that a drawing object is a dummy object, may be located after the drawing
448cdf0e10cSrcweir     objects themselves.
449cdf0e10cSrcweir 
450cdf0e10cSrcweir     The BIFF8 format stores drawing objects in the DFF stream (stored
451cdf0e10cSrcweir     fragmented in MSODRAWING records), and in the OBJ records. The DFF stream
452cdf0e10cSrcweir     fragments are collected in a single stream, and the complete stream will be
453cdf0e10cSrcweir     processed afterwards.
454cdf0e10cSrcweir  */
455cdf0e10cSrcweir class BiffDrawingBase : public WorksheetHelper
456cdf0e10cSrcweir {
457cdf0e10cSrcweir public:
458cdf0e10cSrcweir     explicit            BiffDrawingBase( const WorksheetHelper& rHelper,
459cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage );
460cdf0e10cSrcweir 
461cdf0e10cSrcweir     /** Imports a plain OBJ record (without leading DFF data). */
462cdf0e10cSrcweir     void                importObj( BiffInputStream& rStrm );
463cdf0e10cSrcweir     /** Sets the object with the passed identifier to be skipped on import. */
464cdf0e10cSrcweir     void                setSkipObj( sal_uInt16 nObjId );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     /** Final processing after import of the all drawing objects. */
467cdf0e10cSrcweir     void                finalizeImport();
468cdf0e10cSrcweir 
469cdf0e10cSrcweir     /** Creates a new UNO shape object, inserts it into the passed UNO shape
470cdf0e10cSrcweir         container, and sets the shape position and size. */
471cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
472cdf0e10cSrcweir                         createAndInsertXShape(
473cdf0e10cSrcweir                             const ::rtl::OUString& rService,
474cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
475cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir     /** Derived classes may want to know that a shape has been inserted. Will
478cdf0e10cSrcweir         be called from the convertAndInsert() implementation. */
479cdf0e10cSrcweir     virtual void        notifyShapeInserted(
480cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
481cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect ) = 0;
482cdf0e10cSrcweir 
483cdf0e10cSrcweir protected:
484cdf0e10cSrcweir     /** Appends a new drawing object to the list of raw objects (without DFF data). */
485cdf0e10cSrcweir     void                appendRawObject( const BiffDrawingObjectRef& rxDrawingObj );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir private:
488cdf0e10cSrcweir     typedef RefMap< sal_uInt16, BiffDrawingObjectBase > BiffDrawingObjectMapById;
489cdf0e10cSrcweir     typedef ::std::vector< sal_uInt16 >                 BiffObjIdVector;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
492cdf0e10cSrcweir                         mxDrawPage;         /// UNO draw page used to insert the shapes.
493cdf0e10cSrcweir     BiffDrawingObjectContainer maRawObjs;   /// Drawing objects without DFF data.
494cdf0e10cSrcweir     BiffDrawingObjectMapById maObjMapId;    /// Maps drawing objects by their object identifiers.
495cdf0e10cSrcweir     BiffObjIdVector     maSkipObjs;         /// Identifiers of all objects to be skipped.
496cdf0e10cSrcweir };
497cdf0e10cSrcweir 
498cdf0e10cSrcweir // ----------------------------------------------------------------------------
499cdf0e10cSrcweir 
500cdf0e10cSrcweir /** Drawing manager of a single sheet. */
501cdf0e10cSrcweir class BiffSheetDrawing : public BiffDrawingBase
502cdf0e10cSrcweir {
503cdf0e10cSrcweir public:
504cdf0e10cSrcweir     explicit            BiffSheetDrawing( const WorksheetHelper& rHelper );
505cdf0e10cSrcweir 
506cdf0e10cSrcweir     /** Called when a new UNO shape has been inserted into the draw page. */
507cdf0e10cSrcweir     virtual void        notifyShapeInserted(
508cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
509cdf0e10cSrcweir                             const ::com::sun::star::awt::Rectangle& rShapeRect );
510cdf0e10cSrcweir };
511cdf0e10cSrcweir 
512cdf0e10cSrcweir // ============================================================================
513cdf0e10cSrcweir 
514cdf0e10cSrcweir } // namespace xls
515cdf0e10cSrcweir } // namespace oox
516cdf0e10cSrcweir 
517cdf0e10cSrcweir #endif
518