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 : : #include "drawingmanager.hxx"
30 : :
31 : : #include <com/sun/star/awt/Rectangle.hpp>
32 : : #include <com/sun/star/drawing/CircleKind.hpp>
33 : : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
34 : : #include <com/sun/star/drawing/PolygonKind.hpp>
35 : : #include <com/sun/star/drawing/XShapes.hpp>
36 : : #include "oox/core/filterbase.hxx"
37 : : #include "oox/drawingml/fillproperties.hxx"
38 : : #include "oox/drawingml/lineproperties.hxx"
39 : : #include "oox/drawingml/shapepropertymap.hxx"
40 : : #include "oox/helper/containerhelper.hxx"
41 : : #include "oox/token/tokens.hxx"
42 : : #include "biffinputstream.hxx"
43 : : #include "unitconverter.hxx"
44 : :
45 : : namespace oox {
46 : : namespace xls {
47 : :
48 : : // ============================================================================
49 : :
50 : : using namespace ::com::sun::star::awt;
51 : : using namespace ::com::sun::star::drawing;
52 : : using namespace ::com::sun::star::lang;
53 : : using namespace ::com::sun::star::uno;
54 : : using namespace ::oox::drawingml;
55 : :
56 : : using ::rtl::OUString;
57 : :
58 : : // ============================================================================
59 : :
60 : : namespace {
61 : :
62 : : // OBJ record -----------------------------------------------------------------
63 : :
64 : : const sal_uInt16 BIFF_OBJTYPE_GROUP = 0;
65 : : const sal_uInt16 BIFF_OBJTYPE_LINE = 1;
66 : : const sal_uInt16 BIFF_OBJTYPE_RECTANGLE = 2;
67 : : const sal_uInt16 BIFF_OBJTYPE_OVAL = 3;
68 : : const sal_uInt16 BIFF_OBJTYPE_ARC = 4;
69 : : const sal_uInt16 BIFF_OBJTYPE_CHART = 5;
70 : : const sal_uInt16 BIFF_OBJTYPE_TEXT = 6;
71 : : const sal_uInt16 BIFF_OBJTYPE_BUTTON = 7;
72 : : const sal_uInt16 BIFF_OBJTYPE_PICTURE = 8;
73 : : const sal_uInt16 BIFF_OBJTYPE_POLYGON = 9; // new in BIFF4
74 : : const sal_uInt16 BIFF_OBJTYPE_CHECKBOX = 11; // new in BIFF5
75 : : const sal_uInt16 BIFF_OBJTYPE_OPTIONBUTTON = 12;
76 : : const sal_uInt16 BIFF_OBJTYPE_EDIT = 13;
77 : : const sal_uInt16 BIFF_OBJTYPE_LABEL = 14;
78 : : const sal_uInt16 BIFF_OBJTYPE_DIALOG = 15;
79 : : const sal_uInt16 BIFF_OBJTYPE_SPIN = 16;
80 : : const sal_uInt16 BIFF_OBJTYPE_SCROLLBAR = 17;
81 : : const sal_uInt16 BIFF_OBJTYPE_LISTBOX = 18;
82 : : const sal_uInt16 BIFF_OBJTYPE_GROUPBOX = 19;
83 : : const sal_uInt16 BIFF_OBJTYPE_DROPDOWN = 20;
84 : : const sal_uInt16 BIFF_OBJTYPE_NOTE = 25; // new in BIFF8
85 : : const sal_uInt16 BIFF_OBJTYPE_DRAWING = 30;
86 : : const sal_uInt16 BIFF_OBJTYPE_UNKNOWN = 0xFFFF; // for internal use only
87 : :
88 : : const sal_uInt16 BIFF_OBJ_HIDDEN = 0x0100;
89 : : const sal_uInt16 BIFF_OBJ_VISIBLE = 0x0200;
90 : : const sal_uInt16 BIFF_OBJ_PRINTABLE = 0x0400;
91 : :
92 : : // line formatting ------------------------------------------------------------
93 : :
94 : : const sal_uInt8 BIFF_OBJ_LINE_AUTOCOLOR = 64;
95 : :
96 : : const sal_uInt8 BIFF_OBJ_LINE_SOLID = 0;
97 : : const sal_uInt8 BIFF_OBJ_LINE_DASH = 1;
98 : : const sal_uInt8 BIFF_OBJ_LINE_DOT = 2;
99 : : const sal_uInt8 BIFF_OBJ_LINE_DASHDOT = 3;
100 : : const sal_uInt8 BIFF_OBJ_LINE_DASHDOTDOT = 4;
101 : : const sal_uInt8 BIFF_OBJ_LINE_MEDTRANS = 5;
102 : : const sal_uInt8 BIFF_OBJ_LINE_DARKTRANS = 6;
103 : : const sal_uInt8 BIFF_OBJ_LINE_LIGHTTRANS = 7;
104 : : const sal_uInt8 BIFF_OBJ_LINE_NONE = 255;
105 : :
106 : : const sal_uInt8 BIFF_OBJ_LINE_HAIR = 0;
107 : : const sal_uInt8 BIFF_OBJ_LINE_THIN = 1;
108 : : const sal_uInt8 BIFF_OBJ_LINE_MEDIUM = 2;
109 : : const sal_uInt8 BIFF_OBJ_LINE_THICK = 3;
110 : :
111 : : const sal_uInt8 BIFF_OBJ_LINE_AUTO = 0x01;
112 : :
113 : : const sal_uInt8 BIFF_OBJ_ARROW_NONE = 0;
114 : : const sal_uInt8 BIFF_OBJ_ARROW_OPEN = 1;
115 : : const sal_uInt8 BIFF_OBJ_ARROW_FILLED = 2;
116 : : const sal_uInt8 BIFF_OBJ_ARROW_OPENBOTH = 3;
117 : : const sal_uInt8 BIFF_OBJ_ARROW_FILLEDBOTH = 4;
118 : :
119 : : const sal_uInt8 BIFF_OBJ_ARROW_NARROW = 0;
120 : : const sal_uInt8 BIFF_OBJ_ARROW_MEDIUM = 1;
121 : : const sal_uInt8 BIFF_OBJ_ARROW_WIDE = 2;
122 : :
123 : : const sal_uInt8 BIFF_OBJ_LINE_TL = 0;
124 : : const sal_uInt8 BIFF_OBJ_LINE_TR = 1;
125 : : const sal_uInt8 BIFF_OBJ_LINE_BR = 2;
126 : : const sal_uInt8 BIFF_OBJ_LINE_BL = 3;
127 : :
128 : : const sal_uInt8 BIFF_OBJ_ARC_TR = 0;
129 : : const sal_uInt8 BIFF_OBJ_ARC_TL = 1;
130 : : const sal_uInt8 BIFF_OBJ_ARC_BL = 2;
131 : : const sal_uInt8 BIFF_OBJ_ARC_BR = 3;
132 : :
133 : : const sal_uInt16 BIFF_OBJ_POLY_CLOSED = 0x0100;
134 : :
135 : : // fill formatting ------------------------------------------------------------
136 : :
137 : : const sal_uInt8 BIFF_OBJ_FILL_AUTOCOLOR = 65;
138 : :
139 : : const sal_uInt8 BIFF_OBJ_PATT_NONE = 0;
140 : : const sal_uInt8 BIFF_OBJ_PATT_SOLID = 1;
141 : :
142 : : const sal_uInt8 BIFF_OBJ_FILL_AUTO = 0x01;
143 : :
144 : : // text formatting ------------------------------------------------------------
145 : :
146 : : const sal_uInt8 BIFF_OBJ_HOR_LEFT = 1;
147 : : const sal_uInt8 BIFF_OBJ_HOR_CENTER = 2;
148 : : const sal_uInt8 BIFF_OBJ_HOR_RIGHT = 3;
149 : : const sal_uInt8 BIFF_OBJ_HOR_JUSTIFY = 4;
150 : :
151 : : const sal_uInt8 BIFF_OBJ_VER_TOP = 1;
152 : : const sal_uInt8 BIFF_OBJ_VER_CENTER = 2;
153 : : const sal_uInt8 BIFF_OBJ_VER_BOTTOM = 3;
154 : : const sal_uInt8 BIFF_OBJ_VER_JUSTIFY = 4;
155 : :
156 : : const sal_uInt16 BIFF_OBJ_ORIENT_NONE = 0;
157 : : const sal_uInt16 BIFF_OBJ_ORIENT_STACKED = 1; /// Stacked top to bottom.
158 : : const sal_uInt16 BIFF_OBJ_ORIENT_90CCW = 2; /// 90 degr. counterclockwise.
159 : : const sal_uInt16 BIFF_OBJ_ORIENT_90CW = 3; /// 90 degr. clockwise.
160 : :
161 : : const sal_uInt16 BIFF_OBJ_TEXT_AUTOSIZE = 0x0080;
162 : : const sal_uInt16 BIFF_OBJ_TEXT_LOCKED = 0x0200;
163 : :
164 : : const sal_Int32 BIFF_OBJ_TEXT_MARGIN = 20000; /// Automatic text margin (EMUs).
165 : :
166 : : // BIFF8 OBJ sub records ------------------------------------------------------
167 : :
168 : : const sal_uInt16 BIFF_OBJCMO_PRINTABLE = 0x0010; /// Object printable.
169 : : const sal_uInt16 BIFF_OBJCMO_AUTOLINE = 0x2000; /// Automatic line formatting.
170 : : const sal_uInt16 BIFF_OBJCMO_AUTOFILL = 0x4000; /// Automatic fill formatting.
171 : :
172 : : // ----------------------------------------------------------------------------
173 : :
174 : : } // namespace
175 : :
176 : : // ============================================================================
177 : : // Model structures for BIFF OBJ record data
178 : : // ============================================================================
179 : :
180 : 0 : BiffObjLineModel::BiffObjLineModel() :
181 : : mnColorIdx( BIFF_OBJ_LINE_AUTOCOLOR ),
182 : : mnStyle( BIFF_OBJ_LINE_SOLID ),
183 : : mnWidth( BIFF_OBJ_LINE_HAIR ),
184 : 0 : mbAuto( true )
185 : : {
186 : 0 : }
187 : :
188 : 0 : BiffInputStream& operator>>( BiffInputStream& rStrm, BiffObjLineModel& rModel )
189 : : {
190 : : sal_uInt8 nFlags;
191 [ # # ][ # # ]: 0 : rStrm >> rModel.mnColorIdx >> rModel.mnStyle >> rModel.mnWidth >> nFlags;
[ # # ][ # # ]
192 : 0 : rModel.mbAuto = getFlag( nFlags, BIFF_OBJ_LINE_AUTO );
193 : 0 : return rStrm;
194 : : }
195 : :
196 : : // ============================================================================
197 : :
198 : 0 : BiffObjFillModel::BiffObjFillModel() :
199 : : mnBackColorIdx( BIFF_OBJ_LINE_AUTOCOLOR ),
200 : : mnPattColorIdx( BIFF_OBJ_FILL_AUTOCOLOR ),
201 : : mnPattern( BIFF_OBJ_PATT_SOLID ),
202 : 0 : mbAuto( true )
203 : : {
204 : 0 : }
205 : :
206 : 0 : BiffInputStream& operator>>( BiffInputStream& rStrm, BiffObjFillModel& rModel )
207 : : {
208 : : sal_uInt8 nFlags;
209 [ # # ][ # # ]: 0 : rStrm >> rModel.mnBackColorIdx >> rModel.mnPattColorIdx >> rModel.mnPattern >> nFlags;
[ # # ][ # # ]
210 : 0 : rModel.mbAuto = getFlag( nFlags, BIFF_OBJ_FILL_AUTO );
211 : 0 : return rStrm;
212 : : }
213 : :
214 : : // ============================================================================
215 : : // BIFF drawing objects
216 : : // ============================================================================
217 : :
218 : 0 : BiffDrawingObjectContainer::BiffDrawingObjectContainer()
219 : : {
220 : 0 : }
221 : :
222 : 0 : void BiffDrawingObjectContainer::convertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle* pParentRect ) const
223 : : {
224 : 0 : maObjects.forEachMem( &BiffDrawingObjectBase::convertAndInsert, ::boost::ref( rDrawing ), ::boost::cref( rxShapes ), pParentRect );
225 : 0 : }
226 : :
227 : : // ============================================================================
228 : :
229 : 0 : BiffDrawingObjectBase::BiffDrawingObjectBase( const WorksheetHelper& rHelper ) :
230 : : WorksheetHelper( rHelper ),
231 : : maAnchor( rHelper ),
232 : : mnDffShapeId( 0 ),
233 : : mnDffFlags( 0 ),
234 : : mnObjId( BIFF_OBJ_INVALID_ID ),
235 : : mnObjType( BIFF_OBJTYPE_UNKNOWN ),
236 : : mbHasAnchor( false ),
237 : : mbHidden( false ),
238 : : mbVisible( true ),
239 : : mbPrintable( true ),
240 : : mbAreaObj( false ),
241 : : mbAutoMargin( true ),
242 : : mbSimpleMacro( true ),
243 : : mbProcessShape( true ),
244 : : mbInsertShape( true ),
245 [ # # ]: 0 : mbCustomDff( false )
246 : : {
247 : 0 : }
248 : :
249 [ # # ]: 0 : BiffDrawingObjectBase::~BiffDrawingObjectBase()
250 : : {
251 [ # # ]: 0 : }
252 : :
253 : 0 : Reference< XShape > BiffDrawingObjectBase::convertAndInsert( BiffDrawingBase& rDrawing,
254 : : const Reference< XShapes >& rxShapes, const Rectangle* pParentRect ) const
255 : : {
256 : 0 : Reference< XShape > xShape;
257 [ # # ][ # # ]: 0 : if( rxShapes.is() && mbProcessShape && !mbHidden ) // TODO: support for hidden objects?
[ # # ][ # # ]
258 : : {
259 : : // base class 'ShapeAnchor' calculates the shape rectangle in 1/100 mm
260 : : // in BIFF3-BIFF5, all shapes have absolute anchor (also children of group shapes)
261 [ # # ][ # # ]: 0 : Rectangle aShapeRect = maAnchor.calcAnchorRectHmm( getDrawPageSize() );
262 : :
263 : : // convert the shape, if the calculated rectangle is not empty
264 : 0 : bool bHasWidth = aShapeRect.Width > 0;
265 : 0 : bool bHasHeight = aShapeRect.Height > 0;
266 [ # # ][ # # ]: 0 : if( mbAreaObj ? (bHasWidth && bHasHeight) : (bHasWidth || bHasHeight) )
[ # # ][ # # ]
[ # # ][ # # ]
267 : : {
268 [ # # ][ # # ]: 0 : xShape = implConvertAndInsert( rDrawing, rxShapes, aShapeRect );
269 : : /* Notify the drawing that a new shape has been inserted (but not
270 : : for children of group shapes). For convenience, pass the
271 : : rectangle that contains position and size of the shape. */
272 [ # # ][ # # ]: 0 : if( !pParentRect && xShape.is() )
[ # # ]
273 [ # # ]: 0 : rDrawing.notifyShapeInserted( xShape, aShapeRect );
274 : : }
275 : : }
276 : 0 : return xShape;
277 : : }
278 : :
279 : 0 : void BiffDrawingObjectBase::convertLineProperties( ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows ) const
280 : : {
281 [ # # ]: 0 : if( rLineModel.mbAuto )
282 : : {
283 : 0 : BiffObjLineModel aAutoModel;
284 : 0 : aAutoModel.mbAuto = false;
285 [ # # ]: 0 : convertLineProperties( rPropMap, aAutoModel, nArrows );
286 : 0 : return;
287 : : }
288 : :
289 : : /* Convert line formatting to DrawingML line formatting and let the
290 : : DrawingML code do the hard work. */
291 [ # # ]: 0 : LineProperties aLineProps;
292 : :
293 [ # # ]: 0 : if( rLineModel.mnStyle == BIFF_OBJ_LINE_NONE )
294 : : {
295 [ # # ]: 0 : aLineProps.maLineFill.moFillType = XML_noFill;
296 : : }
297 : : else
298 : : {
299 [ # # ]: 0 : aLineProps.maLineFill.moFillType = XML_solidFill;
300 [ # # ]: 0 : aLineProps.maLineFill.maFillColor.setPaletteClr( rLineModel.mnColorIdx );
301 [ # # ]: 0 : aLineProps.moLineCompound = XML_sng;
302 [ # # ]: 0 : aLineProps.moLineCap = XML_flat;
303 [ # # ]: 0 : aLineProps.moLineJoint = XML_round;
304 : :
305 : : // line width: use 0.35 mm per BIFF line width step
306 : 0 : sal_Int32 nLineWidth = 0;
307 [ # # # # ]: 0 : switch( rLineModel.mnWidth )
308 : : {
309 : : default:
310 : 0 : case BIFF_OBJ_LINE_HAIR: nLineWidth = 0; break;
311 : 0 : case BIFF_OBJ_LINE_THIN: nLineWidth = 20; break;
312 : 0 : case BIFF_OBJ_LINE_MEDIUM: nLineWidth = 40; break;
313 : 0 : case BIFF_OBJ_LINE_THICK: nLineWidth = 60; break;
314 : : }
315 [ # # ][ # # ]: 0 : aLineProps.moLineWidth = getLimitedValue< sal_Int32, sal_Int64 >( convertHmmToEmu( nLineWidth ), 0, SAL_MAX_INT32 );
316 : :
317 : : // dash style and transparency
318 [ # # # # : 0 : switch( rLineModel.mnStyle )
# # # # ]
319 : : {
320 : : default:
321 : : case BIFF_OBJ_LINE_SOLID:
322 [ # # ]: 0 : aLineProps.moPresetDash = XML_solid;
323 : 0 : break;
324 : : case BIFF_OBJ_LINE_DASH:
325 [ # # ]: 0 : aLineProps.moPresetDash = XML_lgDash;
326 : 0 : break;
327 : : case BIFF_OBJ_LINE_DOT:
328 [ # # ]: 0 : aLineProps.moPresetDash = XML_dot;
329 : 0 : break;
330 : : case BIFF_OBJ_LINE_DASHDOT:
331 [ # # ]: 0 : aLineProps.moPresetDash = XML_lgDashDot;
332 : 0 : break;
333 : : case BIFF_OBJ_LINE_DASHDOTDOT:
334 [ # # ]: 0 : aLineProps.moPresetDash = XML_lgDashDotDot;
335 : 0 : break;
336 : : case BIFF_OBJ_LINE_MEDTRANS:
337 [ # # ]: 0 : aLineProps.moPresetDash = XML_solid;
338 [ # # ]: 0 : aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 50 * PER_PERCENT );
339 : 0 : break;
340 : : case BIFF_OBJ_LINE_DARKTRANS:
341 [ # # ]: 0 : aLineProps.moPresetDash = XML_solid;
342 [ # # ]: 0 : aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 75 * PER_PERCENT );
343 : 0 : break;
344 : : case BIFF_OBJ_LINE_LIGHTTRANS:
345 [ # # ]: 0 : aLineProps.moPresetDash = XML_solid;
346 [ # # ]: 0 : aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 25 * PER_PERCENT );
347 : 0 : break;
348 : : }
349 : :
350 : : // line ends
351 : 0 : bool bLineStart = false;
352 : 0 : bool bLineEnd = false;
353 : 0 : bool bFilled = false;
354 [ # # # # : 0 : switch( extractValue< sal_uInt8 >( nArrows, 0, 4 ) )
# ]
355 : : {
356 : 0 : case BIFF_OBJ_ARROW_OPEN: bLineStart = false; bLineEnd = true; bFilled = false; break;
357 : 0 : case BIFF_OBJ_ARROW_OPENBOTH: bLineStart = true; bLineEnd = true; bFilled = false; break;
358 : 0 : case BIFF_OBJ_ARROW_FILLED: bLineStart = false; bLineEnd = true; bFilled = true; break;
359 : 0 : case BIFF_OBJ_ARROW_FILLEDBOTH: bLineStart = true; bLineEnd = true; bFilled = true; break;
360 : : }
361 [ # # ][ # # ]: 0 : if( bLineStart || bLineEnd )
362 : : {
363 : : // arrow type (open or closed)
364 [ # # ]: 0 : sal_Int32 nArrowType = bFilled ? XML_triangle : XML_arrow;
365 [ # # ][ # # ]: 0 : aLineProps.maStartArrow.moArrowType = bLineStart ? nArrowType : XML_none;
366 [ # # ][ # # ]: 0 : aLineProps.maEndArrow.moArrowType = bLineEnd ? nArrowType : XML_none;
367 : :
368 : : // arrow width
369 : 0 : sal_Int32 nArrowWidth = XML_med;
370 [ # # # # ]: 0 : switch( extractValue< sal_uInt8 >( nArrows, 4, 4 ) )
371 : : {
372 : 0 : case BIFF_OBJ_ARROW_NARROW: nArrowWidth = XML_sm; break;
373 : 0 : case BIFF_OBJ_ARROW_MEDIUM: nArrowWidth = XML_med; break;
374 : 0 : case BIFF_OBJ_ARROW_WIDE: nArrowWidth = XML_lg; break;
375 : : }
376 [ # # ]: 0 : aLineProps.maStartArrow.moArrowWidth = aLineProps.maEndArrow.moArrowWidth = nArrowWidth;
377 : :
378 : : // arrow length
379 : 0 : sal_Int32 nArrowLength = XML_med;
380 [ # # # # ]: 0 : switch( extractValue< sal_uInt8 >( nArrows, 8, 4 ) )
381 : : {
382 : 0 : case BIFF_OBJ_ARROW_NARROW: nArrowLength = XML_sm; break;
383 : 0 : case BIFF_OBJ_ARROW_MEDIUM: nArrowLength = XML_med; break;
384 : 0 : case BIFF_OBJ_ARROW_WIDE: nArrowLength = XML_lg; break;
385 : : }
386 [ # # ]: 0 : aLineProps.maStartArrow.moArrowLength = aLineProps.maEndArrow.moArrowLength = nArrowLength;
387 : : }
388 : : }
389 : :
390 [ # # ][ # # ]: 0 : aLineProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() );
[ # # ][ # # ]
391 : : }
392 : :
393 : 0 : void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const
394 : : {
395 [ # # ]: 0 : if( rFillModel.mbAuto )
396 : : {
397 : 0 : BiffObjFillModel aAutoModel;
398 : 0 : aAutoModel.mbAuto = false;
399 [ # # ]: 0 : convertFillProperties( rPropMap, aAutoModel );
400 : 0 : return;
401 : : }
402 : :
403 : : /* Convert fill formatting to DrawingML fill formatting and let the
404 : : DrawingML code do the hard work. */
405 [ # # ]: 0 : FillProperties aFillProps;
406 : :
407 [ # # ]: 0 : if( rFillModel.mnPattern == BIFF_OBJ_PATT_NONE )
408 : : {
409 [ # # ]: 0 : aFillProps.moFillType = XML_noFill;
410 : : }
411 : : else
412 : : {
413 : : const sal_Int32 spnPatternPresets[] = {
414 : : XML_TOKEN_INVALID, XML_TOKEN_INVALID, XML_pct50, XML_pct50, XML_pct25,
415 : : XML_dkHorz, XML_dkVert, XML_dkDnDiag, XML_dkUpDiag, XML_smCheck, XML_trellis,
416 : : XML_ltHorz, XML_ltVert, XML_ltDnDiag, XML_ltUpDiag, XML_smGrid, XML_diagCross,
417 : 0 : XML_pct20, XML_pct10 };
418 [ # # ]: 0 : sal_Int32 nPatternPreset = STATIC_ARRAY_SELECT( spnPatternPresets, rFillModel.mnPattern, XML_TOKEN_INVALID );
419 [ # # ]: 0 : if( nPatternPreset == XML_TOKEN_INVALID )
420 : : {
421 [ # # ]: 0 : aFillProps.moFillType = XML_solidFill;
422 [ # # ]: 0 : aFillProps.maFillColor.setPaletteClr( rFillModel.mnPattColorIdx );
423 : : }
424 : : else
425 : : {
426 [ # # ]: 0 : aFillProps.moFillType = XML_pattFill;
427 [ # # ]: 0 : aFillProps.maPatternProps.maPattFgColor.setPaletteClr( rFillModel.mnPattColorIdx );
428 [ # # ]: 0 : aFillProps.maPatternProps.maPattBgColor.setPaletteClr( rFillModel.mnBackColorIdx );
429 [ # # ]: 0 : aFillProps.maPatternProps.moPattPreset = nPatternPreset;
430 : : }
431 : : #if 0
432 : : static const sal_uInt8 sppnPatterns[][ 8 ] =
433 : : {
434 : : { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 },
435 : : { 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD },
436 : : { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 },
437 : : { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 },
438 : : { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC },
439 : : { 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99 },
440 : : { 0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99 },
441 : : { 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33 },
442 : : { 0xCC, 0xFF, 0x33, 0xFF, 0xCC, 0xFF, 0x33, 0xFF },
443 : : { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00 },
444 : : { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 },
445 : : { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 },
446 : : { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 },
447 : : { 0xFF, 0x11, 0x11, 0x11, 0xFF, 0x11, 0x11, 0x11 },
448 : : { 0xAA, 0x44, 0xAA, 0x11, 0xAA, 0x44, 0xAA, 0x11 },
449 : : { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
450 : : { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 }
451 : : };
452 : : const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, STATIC_ARRAY_SIZE( sppnPatterns ) ) ];
453 : : // create 2-colored 8x8 DIB
454 : : SvMemoryStream aMemStrm;
455 : : // { 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 }
456 : : aMemStrm << sal_uInt32( 12 ) << sal_Int16( 8 ) << sal_Int16( 8 ) << sal_uInt16( 1 ) << sal_uInt16( 1 );
457 : : aMemStrm << sal_uInt8( 0xFF ) << sal_uInt8( 0xFF ) << sal_uInt8( 0xFF );
458 : : aMemStrm << sal_uInt8( 0x00 ) << sal_uInt8( 0x00 ) << sal_uInt8( 0x00 );
459 : : for( size_t nIdx = 0; nIdx < 8; ++nIdx )
460 : : aMemStrm << sal_uInt32( pnPattern[ nIdx ] ); // 32-bit little-endian
461 : : aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
462 : : Bitmap aBitmap;
463 : : aBitmap.Read( aMemStrm, FALSE );
464 : : XOBitmap aXOBitmap( aBitmap );
465 : : aXOBitmap.Bitmap2Array();
466 : : aXOBitmap.SetBitmapType( XBITMAP_8X8 );
467 : : if( aXOBitmap.GetBackgroundColor().GetColor() == COL_BLACK )
468 : : ::std::swap( aPattColor, aBackColor );
469 : : aXOBitmap.SetPixelColor( aPattColor );
470 : : aXOBitmap.SetBackgroundColor( aBackColor );
471 : : rSdrObj.SetMergedItem( XFillStyleItem( XFILL_BITMAP ) );
472 : : rSdrObj.SetMergedItem( XFillBitmapItem( EMPTY_STRING, aXOBitmap ) );
473 : : #endif
474 : : }
475 : :
476 [ # # ][ # # ]: 0 : aFillProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() );
[ # # ][ # # ]
477 : : }
478 : :
479 : : // ============================================================================
480 : : // BIFF drawing page
481 : : // ============================================================================
482 : :
483 : 0 : BiffDrawingBase::BiffDrawingBase( const WorksheetHelper& rHelper, const Reference< XDrawPage >& rxDrawPage ) :
484 : : WorksheetHelper( rHelper ),
485 [ # # ][ # # ]: 0 : mxDrawPage( rxDrawPage )
[ # # ]
486 : : {
487 : 0 : }
488 : :
489 : 0 : void BiffDrawingBase::finalizeImport()
490 : : {
491 [ # # ]: 0 : Reference< XShapes > xShapes( mxDrawPage, UNO_QUERY );
492 : : OSL_ENSURE( xShapes.is(), "BiffDrawingBase::finalizeImport - no shapes container" );
493 [ # # ]: 0 : if( !xShapes.is() )
494 : 0 : return;
495 : :
496 : : // process list of objects to be skipped
497 [ # # ][ # # ]: 0 : for( BiffObjIdVector::const_iterator aIt = maSkipObjs.begin(), aEnd = maSkipObjs.end(); aIt != aEnd; ++aIt )
[ # # ][ # # ]
[ # # ]
498 [ # # ][ # # ]: 0 : if( BiffDrawingObjectBase* pDrawingObj = maObjMapId.get( *aIt ).get() )
[ # # ][ # # ]
499 : 0 : pDrawingObj->setProcessShape( false );
500 : :
501 : : // process drawing objects without DFF data
502 [ # # ][ # # ]: 0 : maRawObjs.convertAndInsert( *this, xShapes );
503 : : }
504 : :
505 : : // ============================================================================
506 : :
507 : 0 : BiffSheetDrawing::BiffSheetDrawing( const WorksheetHelper& rHelper ) :
508 [ # # ]: 0 : BiffDrawingBase( rHelper, rHelper.getDrawPage() )
509 : : {
510 : 0 : }
511 : :
512 : 0 : void BiffSheetDrawing::notifyShapeInserted( const Reference< XShape >& /*rxShape*/, const Rectangle& rShapeRect )
513 : : {
514 : : // collect all shape positions in the WorksheetHelper base class
515 : 0 : extendShapeBoundingBox( rShapeRect );
516 : 0 : }
517 : :
518 : : // ============================================================================
519 : :
520 : : } // namespace xls
521 [ + - ][ + - ]: 24 : } // namespace oox
522 : :
523 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|