Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef OOX_XLS_DRAWINGMANAGER_HXX
30 : : #define OOX_XLS_DRAWINGMANAGER_HXX
31 : :
32 : : #include "drawingbase.hxx"
33 : :
34 : : namespace com { namespace sun { namespace star {
35 : : namespace drawing { class XDrawPage; }
36 : : namespace drawing { class XShape; }
37 : : namespace drawing { class XShapes; }
38 : : } } }
39 : :
40 : : namespace oox { namespace drawingml { class ShapePropertyMap; } }
41 : :
42 : : namespace oox {
43 : : namespace xls {
44 : :
45 : : // ============================================================================
46 : :
47 : : const sal_uInt16 BIFF_OBJ_INVALID_ID = 0;
48 : :
49 : : // ============================================================================
50 : : // Model structures for BIFF OBJ record data
51 : : // ============================================================================
52 : :
53 : : /** This structure contains line formatting attributes from an OBJ record. */
54 : : struct BiffObjLineModel
55 : : {
56 : : sal_uInt8 mnColorIdx; /// Index into color palette.
57 : : sal_uInt8 mnStyle; /// Line dash style.
58 : : sal_uInt8 mnWidth; /// Line width.
59 : : bool mbAuto; /// True = automatic line format.
60 : :
61 : : explicit BiffObjLineModel();
62 : : };
63 : :
64 : : // ============================================================================
65 : :
66 : : /** This structure contains fill formatting attributes from an OBJ record. */
67 : : struct BiffObjFillModel
68 : : {
69 : : sal_uInt8 mnBackColorIdx; /// Index to color palette for background color.
70 : : sal_uInt8 mnPattColorIdx; /// Index to color palette for pattern foreground color.
71 : : sal_uInt8 mnPattern; /// Fill pattern.
72 : : bool mbAuto; /// True = automatic fill format.
73 : :
74 : : explicit BiffObjFillModel();
75 : : };
76 : :
77 : : // ============================================================================
78 : : // BIFF drawing objects
79 : : // ============================================================================
80 : :
81 : : class BiffDrawingBase;
82 : : class BiffDrawingObjectBase;
83 : : typedef ::boost::shared_ptr< BiffDrawingObjectBase > BiffDrawingObjectRef;
84 : :
85 : : // ----------------------------------------------------------------------------
86 : :
87 : 0 : class BiffDrawingObjectContainer
88 : : {
89 : : public:
90 : : explicit BiffDrawingObjectContainer();
91 : :
92 : : /** Returns true, if the object list is empty. */
93 : : inline bool empty() const { return maObjects.empty(); }
94 : :
95 : : /** Creates and inserts all UNO shapes into the passed shape container. */
96 : : void convertAndInsert( BiffDrawingBase& rDrawing,
97 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
98 : : const ::com::sun::star::awt::Rectangle* pParentRect = 0 ) const;
99 : :
100 : : private:
101 : : typedef RefVector< BiffDrawingObjectBase > BiffDrawingObjectVector;
102 : : BiffDrawingObjectVector maObjects;
103 : : };
104 : :
105 : : // ============================================================================
106 : :
107 : : /** Base class for all BIFF drawing objects (OBJ records). */
108 : : class BiffDrawingObjectBase : public WorksheetHelper
109 : : {
110 : : public:
111 : : explicit BiffDrawingObjectBase( const WorksheetHelper& rHelper );
112 : : virtual ~BiffDrawingObjectBase();
113 : :
114 : : /** Sets whether this is an area object (then its width and height must be greater than 0). */
115 : : inline void setAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
116 : : /** If set to true, the object supports a simple on-click macro and/or hyperlink. */
117 : : inline void setSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
118 : :
119 : : /** If set to false, the UNO shape will not be created, processed, or inserted into the draw page. */
120 : 0 : inline void setProcessShape( bool bProcess ) { mbProcessShape = bProcess; }
121 : : /** If set to false, the UNO shape will be created or processed, but not be inserted into the draw page. */
122 : : inline void setInsertShape( bool bInsert ) { mbInsertShape = bInsert; }
123 : : /** If set to true, a new custom UNO shape will be created while in DFF import (BIFF8 only). */
124 : : inline void setCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
125 : :
126 : : /** Returns the object identifier from the OBJ record. */
127 : : inline sal_uInt16 getObjId() const { return mnObjId; }
128 : : /** Returns the object type from the OBJ record. */
129 : : inline sal_uInt16 getObjType() const { return mnObjType; }
130 : :
131 : : /** Returns true, if the object is hidden. */
132 : : inline bool isHidden() const { return mbHidden; }
133 : : /** Returns true, if the object is visible. */
134 : : inline bool isVisible() const { return mbVisible; }
135 : : /** Returns true, if the object is printable. */
136 : : inline bool isPrintable() const { return mbPrintable; }
137 : :
138 : : /** Creates the UNO shape and inserts it into the passed shape container. */
139 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
140 : : convertAndInsert( BiffDrawingBase& rDrawing,
141 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
142 : : const ::com::sun::star::awt::Rectangle* pParentRect = 0 ) const;
143 : :
144 : : protected:
145 : : /** Converts the passed line formatting to the passed property map. */
146 : : void convertLineProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows = 0 ) const;
147 : : /** Converts the passed fill formatting to the passed property map. */
148 : : void convertFillProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const;
149 : :
150 : : /** Derived classes create the corresponding XShape and insert it into the passed container. */
151 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
152 : : implConvertAndInsert( BiffDrawingBase& rDrawing,
153 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
154 : : const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0;
155 : :
156 : : private:
157 : : ShapeAnchor maAnchor; /// Position of the drawing object.
158 : : ::rtl::OUString maObjName; /// Name of the object.
159 : : ::rtl::OUString maMacroName; /// Name of an attached macro.
160 : : ::rtl::OUString maHyperlink; /// On-click hyperlink URL.
161 : : sal_uInt32 mnDffShapeId; /// Shape identifier from DFF stream (BIFF8 only).
162 : : sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
163 : : sal_uInt16 mnObjId; /// The object identifier (unique per drawing).
164 : : sal_uInt16 mnObjType; /// The object type from OBJ record.
165 : : bool mbHasAnchor; /// True = anchor has been initialized.
166 : : bool mbHidden; /// True = object is hidden.
167 : : bool mbVisible; /// True = object is visible (form controls).
168 : : bool mbPrintable; /// True = object is printable.
169 : : bool mbAreaObj; /// True = width and height must be greater than 0.
170 : : bool mbAutoMargin; /// True = set automatic text margin.
171 : : bool mbSimpleMacro; /// True = create simple macro link and hyperlink.
172 : : bool mbProcessShape; /// True = object is valid, do processing and insertion.
173 : : bool mbInsertShape; /// True = insert the UNO shape into the draw page.
174 : : bool mbCustomDff; /// True = recreate UNO shape in DFF import (BIFF8 only).
175 : : };
176 : :
177 : : // ============================================================================
178 : : // BIFF drawing page
179 : : // ============================================================================
180 : :
181 : : /** Base class for a container for all objects on a drawing page (in a
182 : : spreadsheet or in an embedded chart object).
183 : :
184 : : For BIFF import, it is needed to load all drawing objects before converting
185 : : them to UNO shapes. There might be some dummy drawing objects (e.g. the
186 : : dropdown buttons of autofilters) which have to be skipped. The information,
187 : : that a drawing object is a dummy object, may be located after the drawing
188 : : objects themselves.
189 : :
190 : : The BIFF8 format stores drawing objects in the DFF stream (stored
191 : : fragmented in MSODRAWING records), and in the OBJ records. The DFF stream
192 : : fragments are collected in a single stream, and the complete stream will be
193 : : processed afterwards.
194 : : */
195 [ # # ]: 0 : class BiffDrawingBase : public WorksheetHelper
196 : : {
197 : : public:
198 : : explicit BiffDrawingBase( const WorksheetHelper& rHelper,
199 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage );
200 : :
201 : : /** Sets the object with the passed identifier to be skipped on import. */
202 : : void setSkipObj( sal_uInt16 nObjId );
203 : :
204 : : /** Final processing after import of the all drawing objects. */
205 : : void finalizeImport();
206 : :
207 : : /** Derived classes may want to know that a shape has been inserted. Will
208 : : be called from the convertAndInsert() implementation. */
209 : : virtual void notifyShapeInserted(
210 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
211 : : const ::com::sun::star::awt::Rectangle& rShapeRect ) = 0;
212 : :
213 : : private:
214 : : typedef RefMap< sal_uInt16, BiffDrawingObjectBase > BiffDrawingObjectMapById;
215 : : typedef ::std::vector< sal_uInt16 > BiffObjIdVector;
216 : :
217 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
218 : : mxDrawPage; /// UNO draw page used to insert the shapes.
219 : : BiffDrawingObjectContainer maRawObjs; /// Drawing objects without DFF data.
220 : : BiffDrawingObjectMapById maObjMapId; /// Maps drawing objects by their object identifiers.
221 : : BiffObjIdVector maSkipObjs; /// Identifiers of all objects to be skipped.
222 : : };
223 : :
224 : : // ----------------------------------------------------------------------------
225 : :
226 : : /** Drawing manager of a single sheet. */
227 [ # # ]: 0 : class BiffSheetDrawing : public BiffDrawingBase
228 : : {
229 : : public:
230 : : explicit BiffSheetDrawing( const WorksheetHelper& rHelper );
231 : :
232 : : /** Called when a new UNO shape has been inserted into the draw page. */
233 : : virtual void notifyShapeInserted(
234 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
235 : : const ::com::sun::star::awt::Rectangle& rShapeRect );
236 : : };
237 : :
238 : : // ============================================================================
239 : :
240 : : } // namespace xls
241 : : } // namespace oox
242 : :
243 : : #endif
244 : :
245 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|