Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "stylesbuffer.hxx"
21 :
22 : #include <com/sun/star/awt/FontDescriptor.hpp>
23 : #include <com/sun/star/awt/FontFamily.hpp>
24 : #include <com/sun/star/awt/FontPitch.hpp>
25 : #include <com/sun/star/awt/FontSlant.hpp>
26 : #include <com/sun/star/awt/FontStrikeout.hpp>
27 : #include <com/sun/star/awt/FontType.hpp>
28 : #include <com/sun/star/awt/FontWeight.hpp>
29 : #include <com/sun/star/awt/FontUnderline.hpp>
30 : #include <com/sun/star/awt/XDevice.hpp>
31 : #include <com/sun/star/awt/XFont2.hpp>
32 : #include <com/sun/star/container/XIndexAccess.hpp>
33 : #include <com/sun/star/container/XNameAccess.hpp>
34 : #include <com/sun/star/style/XStyle.hpp>
35 : #include <com/sun/star/text/WritingMode2.hpp>
36 : #include <com/sun/star/text/XText.hpp>
37 : #include <com/sun/star/table/BorderLineStyle.hpp>
38 : #include <com/sun/star/table/CellVertJustify2.hpp>
39 : #include <com/sun/star/table/CellJustifyMethod.hpp>
40 : #include <com/sun/star/table/TableBorder.hpp>
41 : #include <editeng/justifyitem.hxx>
42 : #include <editeng/frmdiritem.hxx>
43 : #include <editeng/fontitem.hxx>
44 : #include <editeng/postitem.hxx>
45 : #include <editeng/fhgtitem.hxx>
46 : #include <editeng/wghtitem.hxx>
47 : #include <editeng/udlnitem.hxx>
48 : #include <editeng/colritem.hxx>
49 : #include <editeng/crossedoutitem.hxx>
50 : #include <editeng/contouritem.hxx>
51 : #include <editeng/escapementitem.hxx>
52 : #include <editeng/shdditem.hxx>
53 : #include <editeng/eeitem.hxx>
54 : #include <editeng/boxitem.hxx>
55 : #include <editeng/lineitem.hxx>
56 : #include <editeng/brushitem.hxx>
57 : #include <svx/rotmodit.hxx>
58 : #include <tools/fontenum.hxx>
59 : #include <toolkit/helper/vclunohelper.hxx>
60 : #include <rtl/tencinfo.h>
61 : #include <rtl/ustrbuf.hxx>
62 : #include <oox/core/filterbase.hxx>
63 : #include <oox/helper/attributelist.hxx>
64 : #include <oox/helper/containerhelper.hxx>
65 : #include <oox/helper/propertymap.hxx>
66 : #include <oox/helper/propertyset.hxx>
67 : #include "biffinputstream.hxx"
68 : #include "condformatbuffer.hxx"
69 : #include "excelhandlers.hxx"
70 : #include "themebuffer.hxx"
71 : #include "unitconverter.hxx"
72 : #include "document.hxx"
73 : #include "stlpool.hxx"
74 : #include "docpool.hxx"
75 : #include "ftools.hxx"
76 : #include "scitems.hxx"
77 : #include "attrib.hxx"
78 : #include "globstr.hrc"
79 : #include "xlconst.hxx"
80 :
81 : using ::com::sun::star::table::BorderLine2;
82 : namespace oox {
83 : namespace xls {
84 :
85 : using namespace com::sun::star;
86 : using namespace ::com::sun::star::awt;
87 : using namespace ::com::sun::star::container;
88 : using namespace ::com::sun::star::style;
89 : using namespace ::com::sun::star::table;
90 : using namespace ::com::sun::star::text;
91 : using namespace ::com::sun::star::uno;
92 :
93 : using ::oox::core::FilterBase;
94 :
95 : namespace {
96 :
97 : // OOXML constants ------------------------------------------------------------
98 :
99 : // OOXML predefined color indexes (also used in BIFF3-BIFF8)
100 : const sal_Int32 OOX_COLOR_USEROFFSET = 0; /// First user defined color in palette (OOXML/BIFF12).
101 : const sal_Int32 BIFF_COLOR_USEROFFSET = 8; /// First user defined color in palette (BIFF3-BIFF8).
102 :
103 : // OOXML font family (also used in BIFF)
104 : const sal_Int32 OOX_FONTFAMILY_NONE = 0;
105 : const sal_Int32 OOX_FONTFAMILY_ROMAN = 1;
106 : const sal_Int32 OOX_FONTFAMILY_SWISS = 2;
107 : const sal_Int32 OOX_FONTFAMILY_MODERN = 3;
108 : const sal_Int32 OOX_FONTFAMILY_SCRIPT = 4;
109 : const sal_Int32 OOX_FONTFAMILY_DECORATIVE = 5;
110 :
111 : // OOXML cell text direction (also used in BIFF)
112 : const sal_Int32 OOX_XF_TEXTDIR_CONTEXT = 0;
113 : const sal_Int32 OOX_XF_TEXTDIR_LTR = 1;
114 : const sal_Int32 OOX_XF_TEXTDIR_RTL = 2;
115 :
116 : // OOXML cell rotation (also used in BIFF)
117 : const sal_Int32 OOX_XF_ROTATION_NONE = 0;
118 : const sal_Int32 OOX_XF_ROTATION_STACKED = 255;
119 :
120 : // OOXML cell indentation
121 : const sal_Int32 OOX_XF_INDENT_NONE = 0;
122 :
123 : // OOXML built-in cell styles (also used in BIFF)
124 : const sal_Int32 OOX_STYLE_NORMAL = 0; /// Default cell style.
125 : const sal_Int32 OOX_STYLE_ROWLEVEL = 1; /// RowLevel_x cell style.
126 : const sal_Int32 OOX_STYLE_COLLEVEL = 2; /// ColLevel_x cell style.
127 :
128 : // BIFF12 constants -----------------------------------------------------------
129 :
130 : // BIFF12 color types
131 : const sal_uInt8 BIFF12_COLOR_AUTO = 0;
132 : const sal_uInt8 BIFF12_COLOR_INDEXED = 1;
133 : const sal_uInt8 BIFF12_COLOR_RGB = 2;
134 : const sal_uInt8 BIFF12_COLOR_THEME = 3;
135 :
136 : // BIFF12 diagonal borders
137 : const sal_uInt8 BIFF12_BORDER_DIAG_TLBR = 0x01; /// Top-left to bottom-right.
138 : const sal_uInt8 BIFF12_BORDER_DIAG_BLTR = 0x02; /// Bottom-left to top-right.
139 :
140 : // BIFF12 gradient fill
141 : const sal_Int32 BIFF12_FILL_GRADIENT = 40;
142 :
143 : // BIFF12 XF flags
144 : const sal_uInt32 BIFF12_XF_WRAPTEXT = 0x00400000;
145 : const sal_uInt32 BIFF12_XF_JUSTLASTLINE = 0x00800000;
146 : const sal_uInt32 BIFF12_XF_SHRINK = 0x01000000;
147 : const sal_uInt32 BIFF12_XF_LOCKED = 0x10000000;
148 : const sal_uInt32 BIFF12_XF_HIDDEN = 0x20000000;
149 :
150 : // BIFF12 XF attribute used flags
151 : const sal_uInt16 BIFF12_XF_NUMFMT_USED = 0x0001;
152 : const sal_uInt16 BIFF12_XF_FONT_USED = 0x0002;
153 : const sal_uInt16 BIFF12_XF_ALIGN_USED = 0x0004;
154 : const sal_uInt16 BIFF12_XF_BORDER_USED = 0x0008;
155 : const sal_uInt16 BIFF12_XF_AREA_USED = 0x0010;
156 : const sal_uInt16 BIFF12_XF_PROT_USED = 0x0020;
157 :
158 : // BIFF12 DXF constants
159 : const sal_uInt16 BIFF12_DXF_FILL_PATTERN = 0;
160 : const sal_uInt16 BIFF12_DXF_FILL_FGCOLOR = 1;
161 : const sal_uInt16 BIFF12_DXF_FILL_BGCOLOR = 2;
162 : const sal_uInt16 BIFF12_DXF_FILL_GRADIENT = 3;
163 : const sal_uInt16 BIFF12_DXF_FILL_STOP = 4;
164 : const sal_uInt16 BIFF12_DXF_FONT_COLOR = 5;
165 : const sal_uInt16 BIFF12_DXF_BORDER_TOP = 6;
166 : const sal_uInt16 BIFF12_DXF_BORDER_BOTTOM = 7;
167 : const sal_uInt16 BIFF12_DXF_BORDER_LEFT = 8;
168 : const sal_uInt16 BIFF12_DXF_BORDER_RIGHT = 9;
169 : const sal_uInt16 BIFF12_DXF_FONT_NAME = 24;
170 : const sal_uInt16 BIFF12_DXF_FONT_WEIGHT = 25;
171 : const sal_uInt16 BIFF12_DXF_FONT_UNDERLINE = 26;
172 : const sal_uInt16 BIFF12_DXF_FONT_ESCAPEMENT = 27;
173 : const sal_uInt16 BIFF12_DXF_FONT_ITALIC = 28;
174 : const sal_uInt16 BIFF12_DXF_FONT_STRIKE = 29;
175 : const sal_uInt16 BIFF12_DXF_FONT_OUTLINE = 30;
176 : const sal_uInt16 BIFF12_DXF_FONT_SHADOW = 31;
177 : const sal_uInt16 BIFF12_DXF_FONT_HEIGHT = 36;
178 : const sal_uInt16 BIFF12_DXF_FONT_SCHEME = 37;
179 : const sal_uInt16 BIFF12_DXF_NUMFMT_CODE = 38;
180 : const sal_uInt16 BIFF12_DXF_NUMFMT_ID = 41;
181 :
182 : // BIFF12 CELLSTYLE flags
183 : const sal_uInt16 BIFF12_CELLSTYLE_BUILTIN = 0x0001;
184 : const sal_uInt16 BIFF12_CELLSTYLE_HIDDEN = 0x0002;
185 : const sal_uInt16 BIFF12_CELLSTYLE_CUSTOM = 0x0004;
186 :
187 : // BIFF constants -------------------------------------------------------------
188 :
189 : // BIFF font flags, also used in BIFF12
190 : const sal_uInt16 BIFF_FONTFLAG_ITALIC = 0x0002;
191 : const sal_uInt16 BIFF_FONTFLAG_STRIKEOUT = 0x0008;
192 : const sal_uInt16 BIFF_FONTFLAG_OUTLINE = 0x0010;
193 : const sal_uInt16 BIFF_FONTFLAG_SHADOW = 0x0020;
194 :
195 : // BIFF font weight
196 : const sal_uInt16 BIFF_FONTWEIGHT_BOLD = 450;
197 :
198 : // BIFF font underline, also used in BIFF12
199 : const sal_uInt8 BIFF_FONTUNDERL_NONE = 0;
200 : const sal_uInt8 BIFF_FONTUNDERL_SINGLE = 1;
201 : const sal_uInt8 BIFF_FONTUNDERL_DOUBLE = 2;
202 : const sal_uInt8 BIFF_FONTUNDERL_SINGLE_ACC = 33;
203 : const sal_uInt8 BIFF_FONTUNDERL_DOUBLE_ACC = 34;
204 :
205 0 : sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm )
206 : {
207 : sal_uInt8 nR, nG, nB, nA;
208 0 : rStrm >> nR >> nG >> nB >> nA;
209 0 : sal_Int32 nValue = nA;
210 0 : nValue <<= 8;
211 0 : nValue |= nR;
212 0 : nValue <<= 8;
213 0 : nValue |= nG;
214 0 : nValue <<= 8;
215 0 : nValue |= nB;
216 0 : return nValue;
217 : }
218 :
219 : } // namespace
220 :
221 44 : ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) :
222 88 : GraphicHelper( rHelper.getBaseFilter().getComponentContext(), rHelper.getBaseFilter().getTargetFrame(), rHelper.getBaseFilter().getStorage() ),
223 88 : WorkbookHelper( rHelper )
224 : {
225 44 : }
226 :
227 488 : sal_Int32 ExcelGraphicHelper::getSchemeColor( sal_Int32 nToken ) const
228 : {
229 488 : if( getFilterType() == FILTER_OOXML )
230 488 : return getTheme().getColorByToken( nToken );
231 0 : return GraphicHelper::getSchemeColor( nToken );
232 : }
233 :
234 371 : sal_Int32 ExcelGraphicHelper::getPaletteColor( sal_Int32 nPaletteIdx ) const
235 : {
236 371 : return getStyles().getPaletteColor( nPaletteIdx );
237 : }
238 :
239 0 : void Color::setAuto()
240 : {
241 0 : clearTransformations();
242 0 : setSchemeClr( XML_phClr );
243 0 : }
244 :
245 60 : void Color::setRgb( sal_Int32 nRgbValue, double fTint )
246 : {
247 60 : clearTransformations();
248 60 : setSrgbClr( nRgbValue & 0xFFFFFF );
249 60 : if( fTint != 0.0 ) addExcelTintTransformation( fTint );
250 60 : }
251 :
252 22 : void Color::setTheme( sal_Int32 nThemeIdx, double fTint )
253 : {
254 22 : clearTransformations();
255 : static const sal_Int32 spnColorTokens[] = {
256 : XML_lt1, XML_dk1, XML_lt2, XML_dk2, XML_accent1, XML_accent2,
257 : XML_accent3, XML_accent4, XML_accent5, XML_accent6, XML_hlink, XML_folHlink };
258 22 : setSchemeClr( STATIC_ARRAY_SELECT( spnColorTokens, nThemeIdx, XML_TOKEN_INVALID ) );
259 22 : if( fTint != 0.0 ) addExcelTintTransformation( fTint );
260 22 : }
261 :
262 720 : void Color::setIndexed( sal_Int32 nPaletteIdx, double fTint )
263 : {
264 720 : clearTransformations();
265 720 : setPaletteClr( nPaletteIdx );
266 720 : if( fTint != 0.0 ) addExcelTintTransformation( fTint );
267 720 : }
268 :
269 102 : void Color::importColor( const AttributeList& rAttribs )
270 : {
271 102 : if( rAttribs.getBool( XML_auto, false ) )
272 0 : setAuto();
273 102 : else if( rAttribs.hasAttribute( XML_rgb ) )
274 60 : setRgb( rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT ), rAttribs.getDouble( XML_tint, 0.0 ) );
275 42 : else if( rAttribs.hasAttribute( XML_theme ) )
276 22 : setTheme( rAttribs.getInteger( XML_theme, -1 ), rAttribs.getDouble( XML_tint, 0.0 ) );
277 20 : else if( rAttribs.hasAttribute( XML_indexed ) )
278 20 : setIndexed( rAttribs.getInteger( XML_indexed, -1 ), rAttribs.getDouble( XML_tint, 0.0 ) );
279 : else
280 : {
281 : OSL_FAIL( "Color::importColor - unknown color type" );
282 0 : setAuto();
283 : }
284 102 : }
285 :
286 0 : void Color::importColor( SequenceInputStream& rStrm )
287 : {
288 : sal_uInt8 nFlags, nIndex;
289 : sal_Int16 nTint;
290 0 : rStrm >> nFlags >> nIndex >> nTint;
291 :
292 : // scale tint from signed 16-bit to double range -1.0 ... 1.0
293 0 : double fTint = nTint;
294 0 : if( nTint < 0 )
295 0 : fTint /= -SAL_MIN_INT16;
296 0 : else if( nTint > 0 )
297 0 : fTint /= SAL_MAX_INT16;
298 :
299 0 : switch( extractValue< sal_uInt8 >( nFlags, 1, 7 ) )
300 : {
301 : case BIFF12_COLOR_AUTO:
302 0 : setAuto();
303 0 : rStrm.skip( 4 );
304 0 : break;
305 : case BIFF12_COLOR_INDEXED:
306 0 : setIndexed( nIndex, fTint );
307 0 : rStrm.skip( 4 );
308 0 : break;
309 : case BIFF12_COLOR_RGB:
310 0 : setRgb( lclReadRgbColor( rStrm ), fTint );
311 0 : break;
312 : case BIFF12_COLOR_THEME:
313 0 : setTheme( nIndex, fTint );
314 0 : rStrm.skip( 4 );
315 0 : break;
316 : default:
317 : OSL_FAIL( "Color::importColor - unknown color type" );
318 0 : setAuto();
319 0 : rStrm.skip( 4 );
320 : }
321 0 : }
322 :
323 0 : void Color::importColorId( SequenceInputStream& rStrm )
324 : {
325 0 : setIndexed( rStrm.readInt32() );
326 0 : }
327 :
328 0 : SequenceInputStream& operator>>( SequenceInputStream& rStrm, Color& orColor )
329 : {
330 0 : orColor.importColor( rStrm );
331 0 : return rStrm;
332 : }
333 :
334 : namespace {
335 :
336 : /** Standard EGA colors, bright. */
337 : #define PALETTE_EGA_COLORS_LIGHT \
338 : 0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF
339 : /** Standard EGA colors, dark. */
340 : #define PALETTE_EGA_COLORS_DARK \
341 : 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080
342 :
343 : /** Default color table for BIFF2. */
344 : static const sal_Int32 spnDefColors2[] =
345 : {
346 : /* 0 */ PALETTE_EGA_COLORS_LIGHT
347 : };
348 :
349 : /** Default color table for BIFF3/BIFF4. */
350 : static const sal_Int32 spnDefColors3[] =
351 : {
352 : /* 0 */ PALETTE_EGA_COLORS_LIGHT,
353 : /* 8 */ PALETTE_EGA_COLORS_LIGHT,
354 : /* 16 */ PALETTE_EGA_COLORS_DARK
355 : };
356 :
357 : /** Default color table for BIFF5. */
358 : static const sal_Int32 spnDefColors5[] =
359 : {
360 : /* 0 */ PALETTE_EGA_COLORS_LIGHT,
361 : /* 8 */ PALETTE_EGA_COLORS_LIGHT,
362 : /* 16 */ PALETTE_EGA_COLORS_DARK,
363 : /* 24 */ 0x8080FF, 0x802060, 0xFFFFC0, 0xA0E0E0, 0x600080, 0xFF8080, 0x0080C0, 0xC0C0FF,
364 : /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
365 : /* 40 */ 0x00CFFF, 0x69FFFF, 0xE0FFE0, 0xFFFF80, 0xA6CAF0, 0xDD9CB3, 0xB38FEE, 0xE3E3E3,
366 : /* 48 */ 0x2A6FF9, 0x3FB8CD, 0x488436, 0x958C41, 0x8E5E42, 0xA0627A, 0x624FAC, 0x969696,
367 : /* 56 */ 0x1D2FBE, 0x286676, 0x004500, 0x453E01, 0x6A2813, 0x85396A, 0x4A3285, 0x424242
368 : };
369 :
370 : /** Default color table for BIFF8/BIFF12/OOXML. */
371 : static const sal_Int32 spnDefColors8[] =
372 : {
373 : /* 0 */ PALETTE_EGA_COLORS_LIGHT,
374 : /* 8 */ PALETTE_EGA_COLORS_LIGHT,
375 : /* 16 */ PALETTE_EGA_COLORS_DARK,
376 : /* 24 */ 0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF,
377 : /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
378 : /* 40 */ 0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99,
379 : /* 48 */ 0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696,
380 : /* 56 */ 0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333
381 : };
382 :
383 : #undef PALETTE_EGA_COLORS_LIGHT
384 : #undef PALETTE_EGA_COLORS_DARK
385 :
386 : } // namespace
387 :
388 44 : ColorPalette::ColorPalette( const WorkbookHelper& rHelper )
389 : : WorkbookHelper(rHelper)
390 44 : , mnAppendIndex(0)
391 : {
392 : // default colors
393 44 : switch( getFilterType() )
394 : {
395 : case FILTER_OOXML:
396 44 : maColors.insert( maColors.begin(), spnDefColors8, STATIC_ARRAY_END( spnDefColors8 ) );
397 44 : mnAppendIndex = OOX_COLOR_USEROFFSET;
398 44 : break;
399 : case FILTER_BIFF:
400 0 : switch( getBiff() )
401 : {
402 0 : case BIFF2: maColors.insert( maColors.begin(), spnDefColors2, STATIC_ARRAY_END( spnDefColors2 ) ); break;
403 : case BIFF3:
404 0 : case BIFF4: maColors.insert( maColors.begin(), spnDefColors3, STATIC_ARRAY_END( spnDefColors3 ) ); break;
405 0 : case BIFF5: maColors.insert( maColors.begin(), spnDefColors5, STATIC_ARRAY_END( spnDefColors5 ) ); break;
406 0 : case BIFF8: maColors.insert( maColors.begin(), spnDefColors8, STATIC_ARRAY_END( spnDefColors8 ) ); break;
407 0 : case BIFF_UNKNOWN: break;
408 : }
409 0 : mnAppendIndex = BIFF_COLOR_USEROFFSET;
410 0 : break;
411 0 : case FILTER_UNKNOWN: break;
412 : }
413 44 : }
414 :
415 456 : void ColorPalette::importPaletteColor( const AttributeList& rAttribs )
416 : {
417 456 : appendColor( rAttribs.getIntegerHex( XML_rgb, API_RGB_WHITE ) );
418 456 : }
419 :
420 0 : void ColorPalette::importPaletteColor( SequenceInputStream& rStrm )
421 : {
422 0 : sal_Int32 nRgb = lclReadRgbColor( rStrm );
423 0 : appendColor( nRgb & 0xFFFFFF );
424 0 : }
425 :
426 371 : sal_Int32 ColorPalette::getColor( sal_Int32 nPaletteIdx ) const
427 : {
428 371 : sal_Int32 nColor = API_RGB_TRANSPARENT;
429 371 : if( const sal_Int32* pnPaletteColor = ContainerHelper::getVectorElement( maColors, nPaletteIdx ) )
430 : {
431 1 : nColor = *pnPaletteColor;
432 : }
433 370 : else switch( nPaletteIdx )
434 : {
435 : case OOX_COLOR_WINDOWTEXT3:
436 : case OOX_COLOR_WINDOWTEXT:
437 326 : case OOX_COLOR_CHWINDOWTEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_windowText ); break;
438 : case OOX_COLOR_WINDOWBACK3:
439 : case OOX_COLOR_WINDOWBACK:
440 44 : case OOX_COLOR_CHWINDOWBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_window ); break;
441 0 : case OOX_COLOR_BUTTONBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_btnFace ); break;
442 0 : case OOX_COLOR_CHBORDERAUTO: nColor = API_RGB_BLACK; /* really always black? */ break;
443 0 : case OOX_COLOR_NOTEBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoBk ); break;
444 0 : case OOX_COLOR_NOTETEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoText ); break;
445 0 : case OOX_COLOR_FONTAUTO: nColor = API_RGB_TRANSPARENT; break;
446 : default: OSL_FAIL( "ColorPalette::getColor - unknown color index" );
447 : }
448 371 : return nColor;
449 : }
450 :
451 456 : void ColorPalette::appendColor( sal_Int32 nRGBValue )
452 : {
453 456 : if( mnAppendIndex < maColors.size() )
454 456 : maColors[ mnAppendIndex ] = nRGBValue;
455 : else
456 0 : maColors.push_back( nRGBValue );
457 456 : ++mnAppendIndex;
458 456 : }
459 :
460 : namespace {
461 :
462 588 : void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDesc, bool bHasGlyphs )
463 : {
464 588 : if( bHasGlyphs )
465 : {
466 350 : rFontName.maName = rFontDesc.Name;
467 350 : rFontName.mnFamily = rFontDesc.Family;
468 : // API font descriptor contains rtl_TextEncoding constants
469 350 : rFontName.mnTextEnc = rFontDesc.CharSet;
470 : }
471 : else
472 : {
473 238 : rFontName = ApiScriptFontName();
474 : }
475 588 : }
476 :
477 : } // namespace
478 :
479 88 : FontModel::FontModel() :
480 : mnScheme( XML_none ),
481 : mnFamily( OOX_FONTFAMILY_NONE ),
482 : mnCharSet( WINDOWS_CHARSET_DEFAULT ),
483 : mfHeight( 0.0 ),
484 : mnUnderline( XML_none ),
485 : mnEscapement( XML_baseline ),
486 : mbBold( false ),
487 : mbItalic( false ),
488 : mbStrikeout( false ),
489 : mbOutline( false ),
490 88 : mbShadow( false )
491 : {
492 88 : }
493 :
494 0 : void FontModel::setBiff12Scheme( sal_uInt8 nScheme )
495 : {
496 : static const sal_Int32 spnSchemes[] = { XML_none, XML_major, XML_minor };
497 0 : mnScheme = STATIC_ARRAY_SELECT( spnSchemes, nScheme, XML_none );
498 0 : }
499 :
500 0 : void FontModel::setBiffHeight( sal_uInt16 nHeight )
501 : {
502 0 : mfHeight = nHeight / 20.0; // convert twips to points
503 0 : }
504 :
505 0 : void FontModel::setBiffWeight( sal_uInt16 nWeight )
506 : {
507 0 : mbBold = nWeight >= BIFF_FONTWEIGHT_BOLD;
508 0 : }
509 :
510 0 : void FontModel::setBiffUnderline( sal_uInt16 nUnderline )
511 : {
512 0 : switch( nUnderline )
513 : {
514 0 : case BIFF_FONTUNDERL_NONE: mnUnderline = XML_none; break;
515 0 : case BIFF_FONTUNDERL_SINGLE: mnUnderline = XML_single; break;
516 0 : case BIFF_FONTUNDERL_DOUBLE: mnUnderline = XML_double; break;
517 0 : case BIFF_FONTUNDERL_SINGLE_ACC: mnUnderline = XML_singleAccounting; break;
518 0 : case BIFF_FONTUNDERL_DOUBLE_ACC: mnUnderline = XML_doubleAccounting; break;
519 0 : default: mnUnderline = XML_none;
520 : }
521 0 : }
522 :
523 0 : void FontModel::setBiffEscapement( sal_uInt16 nEscapement )
524 : {
525 : static const sal_Int32 spnEscapes[] = { XML_baseline, XML_superscript, XML_subscript };
526 0 : mnEscapement = STATIC_ARRAY_SELECT( spnEscapes, nEscapement, XML_baseline );
527 0 : }
528 :
529 196 : ApiFontUsedFlags::ApiFontUsedFlags( bool bAllUsed ) :
530 : mbNameUsed( bAllUsed ),
531 : mbColorUsed( bAllUsed ),
532 : mbSchemeUsed( bAllUsed ),
533 : mbHeightUsed( bAllUsed ),
534 : mbUnderlineUsed( bAllUsed ),
535 : mbEscapementUsed( bAllUsed ),
536 : mbWeightUsed( bAllUsed ),
537 : mbPostureUsed( bAllUsed ),
538 : mbStrikeoutUsed( bAllUsed ),
539 : mbOutlineUsed( bAllUsed ),
540 196 : mbShadowUsed( bAllUsed )
541 : {
542 196 : }
543 :
544 826 : ApiScriptFontName::ApiScriptFontName() :
545 : mnFamily( ::com::sun::star::awt::FontFamily::DONTKNOW ),
546 826 : mnTextEnc( RTL_TEXTENCODING_DONTKNOW )
547 : {
548 826 : }
549 :
550 196 : ApiFontData::ApiFontData() :
551 : maDesc(
552 : "Calibri",
553 : 220, // height 11 points
554 : 0,
555 : OUString(),
556 : ::com::sun::star::awt::FontFamily::DONTKNOW,
557 : RTL_TEXTENCODING_DONTKNOW,
558 : ::com::sun::star::awt::FontPitch::DONTKNOW,
559 : 100.0,
560 : ::com::sun::star::awt::FontWeight::NORMAL,
561 : ::com::sun::star::awt::FontSlant_NONE,
562 : ::com::sun::star::awt::FontUnderline::NONE,
563 : ::com::sun::star::awt::FontStrikeout::NONE,
564 : 0.0,
565 : sal_False,
566 : sal_False,
567 : ::com::sun::star::awt::FontType::DONTKNOW ),
568 : mnColor( API_RGB_TRANSPARENT ),
569 : mnEscapement( API_ESCAPE_NONE ),
570 : mnEscapeHeight( API_ESCAPEHEIGHT_NONE ),
571 : mbOutline( false ),
572 196 : mbShadow( false )
573 : {
574 196 : maLatinFont.maName = maDesc.Name;
575 196 : }
576 :
577 140 : Font::Font( const WorkbookHelper& rHelper, bool bDxf ) :
578 : WorkbookHelper( rHelper ),
579 140 : maModel( rHelper.getTheme().getDefaultFontModel() ),
580 140 : maUsedFlags( !bDxf ),
581 420 : mbDxf( bDxf )
582 : {
583 140 : }
584 :
585 56 : Font::Font( const WorkbookHelper& rHelper, const FontModel& rModel ) :
586 : WorkbookHelper( rHelper ),
587 : maModel( rModel ),
588 : maUsedFlags( true ),
589 56 : mbDxf( false )
590 : {
591 56 : }
592 :
593 529 : void Font::importAttribs( sal_Int32 nElement, const AttributeList& rAttribs )
594 : {
595 529 : const FontModel& rDefModel = getTheme().getDefaultFontModel();
596 529 : switch( nElement )
597 : {
598 : case XLS_TOKEN( name ): // when in <font> element
599 : case XLS_TOKEN( rFont ): // when in <rPr> element
600 140 : if( rAttribs.hasAttribute( XML_val ) )
601 : {
602 140 : maModel.maName = rAttribs.getXString( XML_val, OUString() );
603 140 : maUsedFlags.mbNameUsed = true;
604 : }
605 140 : break;
606 : case XLS_TOKEN( scheme ):
607 21 : maModel.mnScheme = rAttribs.getToken( XML_val, rDefModel.mnScheme );
608 21 : break;
609 : case XLS_TOKEN( family ):
610 137 : maModel.mnFamily = rAttribs.getInteger( XML_val, rDefModel.mnFamily );
611 137 : break;
612 : case XLS_TOKEN( charset ):
613 29 : maModel.mnCharSet = rAttribs.getInteger( XML_val, rDefModel.mnCharSet );
614 29 : break;
615 : case XLS_TOKEN( sz ):
616 140 : maModel.mfHeight = rAttribs.getDouble( XML_val, rDefModel.mfHeight );
617 140 : maUsedFlags.mbHeightUsed = true;
618 140 : break;
619 : case XLS_TOKEN( color ):
620 49 : maModel.maColor.importColor( rAttribs );
621 49 : maUsedFlags.mbColorUsed = true;
622 49 : break;
623 : case XLS_TOKEN( u ):
624 1 : maModel.mnUnderline = rAttribs.getToken( XML_val, XML_single );
625 1 : maUsedFlags.mbUnderlineUsed = true;
626 1 : break;
627 : case XLS_TOKEN( vertAlign ):
628 0 : maModel.mnEscapement = rAttribs.getToken( XML_val, XML_baseline );
629 0 : maUsedFlags.mbEscapementUsed = true;
630 0 : break;
631 : case XLS_TOKEN( b ):
632 10 : maModel.mbBold = rAttribs.getBool( XML_val, true );
633 10 : maUsedFlags.mbWeightUsed = true;
634 10 : break;
635 : case XLS_TOKEN( i ):
636 2 : maModel.mbItalic = rAttribs.getBool( XML_val, true );
637 2 : maUsedFlags.mbPostureUsed = true;
638 2 : break;
639 : case XLS_TOKEN( strike ):
640 0 : maModel.mbStrikeout = rAttribs.getBool( XML_val, true );
641 0 : maUsedFlags.mbStrikeoutUsed = true;
642 0 : break;
643 : case XLS_TOKEN( outline ):
644 0 : maModel.mbOutline = rAttribs.getBool( XML_val, true );
645 0 : maUsedFlags.mbOutlineUsed = true;
646 0 : break;
647 : case XLS_TOKEN( shadow ):
648 0 : maModel.mbShadow = rAttribs.getBool( XML_val, true );
649 0 : maUsedFlags.mbShadowUsed = true;
650 0 : break;
651 : }
652 529 : }
653 :
654 0 : void Font::importFont( SequenceInputStream& rStrm )
655 : {
656 : SAL_WARN_IF( mbDxf, "sc", "Font::importFont - unexpected conditional formatting flag" );
657 :
658 : sal_uInt16 nHeight, nFlags, nWeight, nEscapement;
659 : sal_uInt8 nUnderline, nFamily, nCharSet, nScheme;
660 0 : rStrm >> nHeight >> nFlags >> nWeight >> nEscapement >> nUnderline >> nFamily >> nCharSet;
661 0 : rStrm.skip( 1 );
662 0 : rStrm >> maModel.maColor >> nScheme >> maModel.maName;
663 :
664 : // equal constants in all BIFFs for weight, underline, and escapement
665 0 : maModel.setBiff12Scheme( nScheme );
666 0 : maModel.setBiffHeight( nHeight );
667 0 : maModel.setBiffWeight( nWeight );
668 0 : maModel.setBiffUnderline( nUnderline );
669 0 : maModel.setBiffEscapement( nEscapement );
670 0 : maModel.mnFamily = nFamily;
671 0 : maModel.mnCharSet = nCharSet;
672 : // equal flags in all BIFFs
673 0 : maModel.mbItalic = getFlag( nFlags, BIFF_FONTFLAG_ITALIC );
674 0 : maModel.mbStrikeout = getFlag( nFlags, BIFF_FONTFLAG_STRIKEOUT );
675 0 : maModel.mbOutline = getFlag( nFlags, BIFF_FONTFLAG_OUTLINE );
676 0 : maModel.mbShadow = getFlag( nFlags, BIFF_FONTFLAG_SHADOW );
677 0 : }
678 :
679 0 : void Font::importDxfName( SequenceInputStream& rStrm )
680 : {
681 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfName - missing conditional formatting flag" );
682 0 : maModel.maName = BiffHelper::readString( rStrm, false );
683 0 : maUsedFlags.mbColorUsed = true;
684 0 : }
685 :
686 0 : void Font::importDxfColor( SequenceInputStream& rStrm )
687 : {
688 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfColor - missing conditional formatting flag" );
689 0 : rStrm >> maModel.maColor;
690 0 : maUsedFlags.mbColorUsed = true;
691 0 : }
692 :
693 0 : void Font::importDxfScheme( SequenceInputStream& rStrm )
694 : {
695 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfScheme - missing conditional formatting flag" );
696 0 : maModel.setBiff12Scheme( rStrm.readuInt8() );
697 0 : maUsedFlags.mbSchemeUsed = true;
698 0 : }
699 :
700 0 : void Font::importDxfHeight( SequenceInputStream& rStrm )
701 : {
702 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfHeight - missing conditional formatting flag" );
703 0 : maModel.setBiffHeight( rStrm.readuInt16() );
704 0 : maUsedFlags.mbHeightUsed = true;
705 0 : }
706 :
707 0 : void Font::importDxfWeight( SequenceInputStream& rStrm )
708 : {
709 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfWeight - missing conditional formatting flag" );
710 0 : maModel.setBiffWeight( rStrm.readuInt16() );
711 0 : maUsedFlags.mbWeightUsed = true;
712 0 : }
713 :
714 0 : void Font::importDxfUnderline( SequenceInputStream& rStrm )
715 : {
716 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfUnderline - missing conditional formatting flag" );
717 0 : maModel.setBiffUnderline( rStrm.readuInt16() );
718 0 : maUsedFlags.mbUnderlineUsed = true;
719 0 : }
720 :
721 0 : void Font::importDxfEscapement( SequenceInputStream& rStrm )
722 : {
723 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfEscapement - missing conditional formatting flag" );
724 0 : maModel.setBiffEscapement( rStrm.readuInt16() );
725 0 : maUsedFlags.mbEscapementUsed = true;
726 0 : }
727 :
728 0 : void Font::importDxfFlag( sal_Int32 nElement, SequenceInputStream& rStrm )
729 : {
730 : SAL_WARN_IF( !mbDxf, "sc", "Font::importDxfFlag - missing conditional formatting flag" );
731 0 : bool bFlag = rStrm.readuInt8() != 0;
732 0 : switch( nElement )
733 : {
734 : case XML_i:
735 0 : maModel.mbItalic = bFlag;
736 0 : maUsedFlags.mbPostureUsed = true;
737 0 : break;
738 : case XML_strike:
739 0 : maModel.mbStrikeout = bFlag;
740 0 : maUsedFlags.mbStrikeoutUsed = true;
741 0 : break;
742 : case XML_outline:
743 0 : maModel.mbOutline = bFlag;
744 0 : maUsedFlags.mbOutlineUsed = true;
745 0 : break;
746 : case XML_shadow:
747 0 : maModel.mbShadow = bFlag;
748 0 : maUsedFlags.mbShadowUsed = true;
749 0 : break;
750 : default:
751 : OSL_FAIL( "Font::importDxfFlag - unexpected element identifier" );
752 : }
753 0 : }
754 :
755 196 : void Font::finalizeImport()
756 : {
757 : namespace cssawt = ::com::sun::star::awt;
758 :
759 : // font name
760 196 : maApiData.maDesc.Name = maModel.maName;
761 :
762 : // font family
763 196 : switch( maModel.mnFamily )
764 : {
765 74 : case OOX_FONTFAMILY_NONE: maApiData.maDesc.Family = cssawt::FontFamily::DONTKNOW; break;
766 0 : case OOX_FONTFAMILY_ROMAN: maApiData.maDesc.Family = cssawt::FontFamily::ROMAN; break;
767 122 : case OOX_FONTFAMILY_SWISS: maApiData.maDesc.Family = cssawt::FontFamily::SWISS; break;
768 0 : case OOX_FONTFAMILY_MODERN: maApiData.maDesc.Family = cssawt::FontFamily::MODERN; break;
769 0 : case OOX_FONTFAMILY_SCRIPT: maApiData.maDesc.Family = cssawt::FontFamily::SCRIPT; break;
770 0 : case OOX_FONTFAMILY_DECORATIVE: maApiData.maDesc.Family = cssawt::FontFamily::DECORATIVE; break;
771 : }
772 :
773 : // character set (API font descriptor uses rtl_TextEncoding in member CharSet!)
774 196 : if( (0 <= maModel.mnCharSet) && (maModel.mnCharSet <= SAL_MAX_UINT8) )
775 : maApiData.maDesc.CharSet = static_cast< sal_Int16 >(
776 196 : rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maModel.mnCharSet ) ) );
777 :
778 : // color, height, weight, slant, strikeout, outline, shadow
779 196 : maApiData.mnColor = maModel.maColor.getColor( getBaseFilter().getGraphicHelper() );
780 196 : maApiData.maDesc.Height = static_cast< sal_Int16 >( maModel.mfHeight * 20.0 );
781 196 : maApiData.maDesc.Weight = maModel.mbBold ? cssawt::FontWeight::BOLD : cssawt::FontWeight::NORMAL;
782 196 : maApiData.maDesc.Slant = maModel.mbItalic ? cssawt::FontSlant_ITALIC : cssawt::FontSlant_NONE;
783 196 : maApiData.maDesc.Strikeout = maModel.mbStrikeout ? cssawt::FontStrikeout::SINGLE : cssawt::FontStrikeout::NONE;
784 196 : maApiData.mbOutline = maModel.mbOutline;
785 196 : maApiData.mbShadow = maModel.mbShadow;
786 :
787 : // underline
788 196 : switch( maModel.mnUnderline )
789 : {
790 0 : case XML_double: maApiData.maDesc.Underline = cssawt::FontUnderline::DOUBLE; break;
791 0 : case XML_doubleAccounting: maApiData.maDesc.Underline = cssawt::FontUnderline::DOUBLE; break;
792 195 : case XML_none: maApiData.maDesc.Underline = cssawt::FontUnderline::NONE; break;
793 1 : case XML_single: maApiData.maDesc.Underline = cssawt::FontUnderline::SINGLE; break;
794 0 : case XML_singleAccounting: maApiData.maDesc.Underline = cssawt::FontUnderline::SINGLE; break;
795 : }
796 :
797 : // escapement
798 196 : switch( maModel.mnEscapement )
799 : {
800 : case XML_baseline:
801 196 : maApiData.mnEscapement = API_ESCAPE_NONE;
802 196 : maApiData.mnEscapeHeight = API_ESCAPEHEIGHT_NONE;
803 196 : break;
804 : case XML_superscript:
805 0 : maApiData.mnEscapement = API_ESCAPE_SUPERSCRIPT;
806 0 : maApiData.mnEscapeHeight = API_ESCAPEHEIGHT_DEFAULT;
807 0 : break;
808 : case XML_subscript:
809 0 : maApiData.mnEscapement = API_ESCAPE_SUBSCRIPT;
810 0 : maApiData.mnEscapeHeight = API_ESCAPEHEIGHT_DEFAULT;
811 0 : break;
812 : }
813 :
814 : // supported script types
815 196 : if( maUsedFlags.mbNameUsed )
816 : {
817 196 : PropertySet aDocProps( getDocument() );
818 392 : Reference< XDevice > xDevice( aDocProps.getAnyProperty( PROP_ReferenceDevice ), UNO_QUERY );
819 196 : if( xDevice.is() )
820 : {
821 196 : Reference< XFont2 > xFont( xDevice->getFont( maApiData.maDesc ), UNO_QUERY );
822 196 : if( xFont.is() )
823 : {
824 : // #91658# CJK fonts
825 : bool bHasAsian =
826 1176 : xFont->hasGlyphs( OUString( sal_Unicode( 0x3041 ) ) ) || // 3040-309F: Hiragana
827 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x30A1 ) ) ) || // 30A0-30FF: Katakana
828 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x3111 ) ) ) || // 3100-312F: Bopomofo
829 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x3131 ) ) ) || // 3130-318F: Hangul Compatibility Jamo
830 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x3301 ) ) ) || // 3300-33FF: CJK Compatibility
831 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x3401 ) ) ) || // 3400-4DBF: CJK Unified Ideographs Extension A
832 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x4E01 ) ) ) || // 4E00-9FAF: CJK Unified Ideographs
833 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0x7E01 ) ) ) || // 4E00-9FAF: CJK unified ideographs
834 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0xA001 ) ) ) || // A001-A48F: Yi Syllables
835 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0xAC01 ) ) ) || // AC00-D7AF: Hangul Syllables
836 980 : xFont->hasGlyphs( OUString( sal_Unicode( 0xCC01 ) ) ) || // AC00-D7AF: Hangul Syllables
837 1568 : xFont->hasGlyphs( OUString( sal_Unicode( 0xF901 ) ) ) || // F900-FAFF: CJK Compatibility Ideographs
838 588 : xFont->hasGlyphs( OUString( sal_Unicode( 0xFF71 ) ) ); // FF00-FFEF: Halfwidth/Fullwidth Forms
839 : // #113783# CTL fonts
840 : bool bHasCmplx =
841 868 : xFont->hasGlyphs( OUString( sal_Unicode( 0x05D1 ) ) ) || // 0590-05FF: Hebrew
842 364 : xFont->hasGlyphs( OUString( sal_Unicode( 0x0631 ) ) ) || // 0600-06FF: Arabic
843 364 : xFont->hasGlyphs( OUString( sal_Unicode( 0x0721 ) ) ) || // 0700-074F: Syriac
844 364 : xFont->hasGlyphs( OUString( sal_Unicode( 0x0911 ) ) ) || // 0900-0DFF: Indic scripts
845 364 : xFont->hasGlyphs( OUString( sal_Unicode( 0x0E01 ) ) ) || // 0E00-0E7F: Thai
846 364 : xFont->hasGlyphs( OUString( sal_Unicode( 0xFB21 ) ) ) || // FB1D-FB4F: Hebrew Presentation Forms
847 952 : xFont->hasGlyphs( OUString( sal_Unicode( 0xFB51 ) ) ) || // FB50-FDFF: Arabic Presentation Forms-A
848 280 : xFont->hasGlyphs( OUString( sal_Unicode( 0xFE71 ) ) ); // FE70-FEFF: Arabic Presentation Forms-B
849 : // Western fonts
850 : bool bHasLatin =
851 504 : (!bHasAsian && !bHasCmplx) ||
852 504 : xFont->hasGlyphs( OUString( 'A' ) );
853 :
854 196 : lclSetFontName( maApiData.maLatinFont, maApiData.maDesc, bHasLatin );
855 196 : lclSetFontName( maApiData.maAsianFont, maApiData.maDesc, bHasAsian );
856 196 : lclSetFontName( maApiData.maCmplxFont, maApiData.maDesc, bHasCmplx );
857 196 : }
858 196 : }
859 : }
860 196 : }
861 :
862 44 : const FontDescriptor& Font::getFontDescriptor() const
863 : {
864 44 : return maApiData.maDesc;
865 : }
866 :
867 198 : bool Font::needsRichTextFormat() const
868 : {
869 198 : return maApiData.mnEscapement != API_ESCAPE_NONE;
870 : }
871 107 : ::FontFamily lcl_getFontFamily( sal_Int32 nFamily )
872 : {
873 : namespace cssawt = ::com::sun::star::awt;
874 :
875 107 : ::FontFamily eScFamily = FAMILY_DONTKNOW;
876 107 : switch( nFamily )
877 : {
878 : case cssawt::FontFamily::DONTKNOW:
879 8 : eScFamily = FAMILY_DONTKNOW;
880 8 : break;
881 : case cssawt::FontFamily::ROMAN:
882 0 : eScFamily = FAMILY_ROMAN;
883 0 : break;
884 : case cssawt::FontFamily::SWISS:
885 99 : eScFamily = FAMILY_SWISS;
886 99 : break;
887 : case cssawt::FontFamily::MODERN:
888 0 : eScFamily = FAMILY_MODERN;
889 0 : break;
890 : case cssawt::FontFamily::SCRIPT:
891 0 : eScFamily = FAMILY_SCRIPT;
892 0 : break;
893 : case cssawt::FontFamily::DECORATIVE:
894 0 : eScFamily = FAMILY_DECORATIVE;
895 0 : break;
896 : }
897 107 : return eScFamily;
898 : }
899 :
900 75 : void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool bSkipPoolDefs ) const
901 : {
902 75 : bool bEdit = ( ePropType == FONT_PROPTYPE_TEXT );
903 : namespace cssawt = ::com::sun::star::awt;
904 75 : if ( maUsedFlags.mbNameUsed )
905 : {
906 75 : if( !maApiData.maLatinFont.maName.isEmpty() )
907 : {
908 75 : rtl_TextEncoding eFontEnc = maApiData.maLatinFont.mnTextEnc;
909 : // taken from binary importer
910 0 : rtl_TextEncoding eTempTextEnc = (bEdit && (eFontEnc == getTextEncoding())) ?
911 75 : ScfTools::GetSystemTextEncoding() : eFontEnc;
912 :
913 : SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maLatinFont.mnFamily ), maApiData.maLatinFont.maName, OUString(),
914 75 : PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT );
915 75 : ScfTools::PutItem( rItemSet, aFontItem, bEdit ? EE_CHAR_FONTINFO : ATTR_FONT, bSkipPoolDefs );
916 : }
917 75 : if( !maApiData.maAsianFont.maName.isEmpty() )
918 : {
919 0 : rtl_TextEncoding eFontEnc = maApiData.maAsianFont.mnTextEnc;
920 : // taken from binary importer
921 0 : rtl_TextEncoding eTempTextEnc = (bEdit && (eFontEnc == getTextEncoding())) ?
922 0 : ScfTools::GetSystemTextEncoding() : eFontEnc;
923 : SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maAsianFont.mnFamily ), maApiData.maAsianFont.maName, OUString(),
924 0 : PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT );
925 0 : ScfTools::PutItem( rItemSet, aFontItem, bEdit ? EE_CHAR_FONTINFO_CJK : ATTR_CJK_FONT, bSkipPoolDefs );
926 : }
927 75 : if( !maApiData.maCmplxFont.maName.isEmpty() )
928 : {
929 32 : rtl_TextEncoding eFontEnc = maApiData.maCmplxFont.mnTextEnc;
930 : // taken from binary importer
931 0 : rtl_TextEncoding eTempTextEnc = (bEdit && (eFontEnc == getTextEncoding())) ?
932 32 : ScfTools::GetSystemTextEncoding() : eFontEnc;
933 : SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maCmplxFont.mnFamily ), maApiData.maCmplxFont.maName, OUString(),
934 32 : PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT );
935 32 : ScfTools::PutItem( rItemSet, aFontItem, bEdit ? EE_CHAR_FONTINFO_CTL : ATTR_CTL_FONT, bSkipPoolDefs );
936 : }
937 : }
938 : // font height
939 75 : if( maUsedFlags.mbHeightUsed )
940 : {
941 75 : sal_Int32 nHeight = maApiData.maDesc.Height;
942 : // do we use EXC_FONTITEM_HF ( or is it just relevant for the binary filter )
943 75 : if( bEdit/* && (eType != EXC_FONTITEM_HF) */) // do not convert header/footer height
944 0 : nHeight = (nHeight * 127 + 36) / EXC_POINTS_PER_INCH; // 1 in == 72 pt
945 75 : SvxFontHeightItem aHeightItem( nHeight, 100, ATTR_FONT_HEIGHT );
946 75 : ScfTools::PutItem( rItemSet, aHeightItem, bEdit ? EE_CHAR_FONTHEIGHT : ATTR_FONT_HEIGHT, bSkipPoolDefs );
947 75 : ScfTools::PutItem( rItemSet, aHeightItem, bEdit ? EE_CHAR_FONTHEIGHT_CJK : ATTR_CJK_FONT_HEIGHT, bSkipPoolDefs );
948 75 : ScfTools::PutItem( rItemSet, aHeightItem, bEdit ? EE_CHAR_FONTHEIGHT_CTL : ATTR_CTL_FONT_HEIGHT, bSkipPoolDefs );
949 : }
950 : // font weight
951 75 : if( maUsedFlags.mbWeightUsed )
952 : {
953 67 : ::FontWeight fWeight = VCLUnoHelper::ConvertFontWeight( maApiData.maDesc.Weight );
954 67 : SvxWeightItem aWeightItem( fWeight, ATTR_FONT_WEIGHT );
955 67 : ScfTools::PutItem( rItemSet, aWeightItem, bEdit ? EE_CHAR_WEIGHT : ATTR_FONT_WEIGHT, bSkipPoolDefs );
956 67 : ScfTools::PutItem( rItemSet, aWeightItem, bEdit ? EE_CHAR_WEIGHT_CTL : ATTR_CTL_FONT_WEIGHT, bSkipPoolDefs );
957 67 : ScfTools::PutItem( rItemSet, aWeightItem, bEdit ? EE_CHAR_WEIGHT_CJK : ATTR_CJK_FONT_WEIGHT, bSkipPoolDefs );
958 : }
959 : // font posture
960 75 : if( maUsedFlags.mbPostureUsed )
961 : {
962 67 : SvxPostureItem aPostItem( ( maApiData.maDesc.Slant == cssawt::FontSlant_ITALIC ) ? ITALIC_NORMAL : ITALIC_NONE, ATTR_FONT_POSTURE);
963 67 : ScfTools::PutItem( rItemSet, aPostItem, bEdit ? EE_CHAR_ITALIC : ATTR_FONT_POSTURE, bSkipPoolDefs );
964 67 : ScfTools::PutItem( rItemSet, aPostItem, bEdit ? EE_CHAR_ITALIC_CJK : ATTR_CJK_FONT_POSTURE, bSkipPoolDefs );
965 67 : ScfTools::PutItem( rItemSet, aPostItem, bEdit ? EE_CHAR_ITALIC_CTL : ATTR_CTL_FONT_POSTURE, bSkipPoolDefs );
966 : }
967 : // character color
968 75 : if( maUsedFlags.mbColorUsed )
969 : {
970 75 : ScfTools::PutItem( rItemSet,SvxColorItem( maApiData.mnColor, bEdit ? EE_CHAR_COLOR : ATTR_FONT_COLOR ) , bSkipPoolDefs );
971 : }
972 : // underline style
973 75 : if( maUsedFlags.mbUnderlineUsed )
974 : {
975 : ::FontUnderline eScUnderl;
976 67 : if ( maApiData.maDesc.Underline == cssawt::FontUnderline::DOUBLE )
977 0 : eScUnderl = UNDERLINE_DOUBLE;
978 67 : else if ( maApiData.maDesc.Underline == cssawt::FontUnderline::SINGLE )
979 2 : eScUnderl = UNDERLINE_SINGLE;
980 : else
981 65 : eScUnderl = UNDERLINE_NONE;
982 67 : SvxUnderlineItem aUnderlItem( eScUnderl, ATTR_FONT_UNDERLINE );
983 67 : ScfTools::PutItem( rItemSet, aUnderlItem, bEdit ? EE_CHAR_UNDERLINE : ATTR_FONT_UNDERLINE, bSkipPoolDefs );
984 : }
985 : // strike out style
986 75 : if( maUsedFlags.mbStrikeoutUsed )
987 : {
988 67 : ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEdit ? EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT ), ATTR_FONT_CROSSEDOUT, bSkipPoolDefs );
989 : }
990 :
991 : // outline style
992 75 : if( maUsedFlags.mbOutlineUsed )
993 : {
994 67 : ScfTools::PutItem( rItemSet, SvxContourItem( maApiData.mbOutline, ATTR_FONT_CONTOUR ), bEdit ? EE_CHAR_OUTLINE : ATTR_FONT_CONTOUR, bSkipPoolDefs );
995 : }
996 :
997 : // shadow style
998 75 : if( maUsedFlags.mbShadowUsed )
999 : {
1000 67 : ScfTools::PutItem( rItemSet, SvxShadowedItem( maApiData.mbShadow, ATTR_FONT_SHADOWED ), bEdit ? EE_CHAR_SHADOW : ATTR_FONT_SHADOWED, bSkipPoolDefs );
1001 : }
1002 75 : if( maUsedFlags.mbEscapementUsed )
1003 : {
1004 67 : SvxEscapement eScEscapem = SVX_ESCAPEMENT_OFF;
1005 67 : if ( maApiData.mnEscapement == API_ESCAPE_SUPERSCRIPT )
1006 0 : eScEscapem = SVX_ESCAPEMENT_SUPERSCRIPT;
1007 67 : else if ( maApiData.mnEscapement == API_ESCAPE_SUBSCRIPT )
1008 0 : eScEscapem = SVX_ESCAPEMENT_SUBSCRIPT;
1009 67 : if( ePropType == FONT_PROPTYPE_TEXT && bEdit )
1010 : {
1011 : // #TODO handle EscapementHeight
1012 0 : rItemSet.Put( SvxEscapementItem( eScEscapem, EE_CHAR_ESCAPEMENT ) );
1013 : }
1014 : }
1015 75 : }
1016 :
1017 57 : void Font::writeToPropertyMap( PropertyMap& rPropMap, FontPropertyType ePropType ) const
1018 : {
1019 : // font name properties
1020 57 : if( maUsedFlags.mbNameUsed )
1021 : {
1022 57 : if( !maApiData.maLatinFont.maName.isEmpty() )
1023 : {
1024 57 : rPropMap.setProperty( PROP_CharFontName, maApiData.maLatinFont.maName);
1025 57 : rPropMap.setProperty( PROP_CharFontFamily, maApiData.maLatinFont.mnFamily);
1026 57 : rPropMap.setProperty( PROP_CharFontCharSet, maApiData.maLatinFont.mnTextEnc);
1027 : }
1028 57 : if( !maApiData.maAsianFont.maName.isEmpty() )
1029 : {
1030 0 : rPropMap.setProperty( PROP_CharFontNameAsian, maApiData.maAsianFont.maName);
1031 0 : rPropMap.setProperty( PROP_CharFontFamilyAsian, maApiData.maAsianFont.mnFamily);
1032 0 : rPropMap.setProperty( PROP_CharFontCharSetAsian, maApiData.maAsianFont.mnTextEnc);
1033 : }
1034 57 : if( !maApiData.maCmplxFont.maName.isEmpty() )
1035 : {
1036 57 : rPropMap.setProperty( PROP_CharFontNameComplex, maApiData.maCmplxFont.maName);
1037 57 : rPropMap.setProperty( PROP_CharFontFamilyComplex, maApiData.maCmplxFont.mnFamily);
1038 57 : rPropMap.setProperty( PROP_CharFontCharSetComplex, maApiData.maCmplxFont.mnTextEnc);
1039 : }
1040 : }
1041 : // font height
1042 57 : if( maUsedFlags.mbHeightUsed )
1043 : {
1044 57 : float fHeight = static_cast< float >( maApiData.maDesc.Height / 20.0 ); // twips to points
1045 57 : rPropMap.setProperty( PROP_CharHeight, fHeight);
1046 57 : rPropMap.setProperty( PROP_CharHeightAsian, fHeight);
1047 57 : rPropMap.setProperty( PROP_CharHeightComplex, fHeight);
1048 : }
1049 : // font weight
1050 57 : if( maUsedFlags.mbWeightUsed )
1051 : {
1052 57 : float fWeight = maApiData.maDesc.Weight;
1053 57 : rPropMap.setProperty( PROP_CharWeight, fWeight);
1054 57 : rPropMap.setProperty( PROP_CharWeightAsian, fWeight);
1055 57 : rPropMap.setProperty( PROP_CharWeightComplex, fWeight);
1056 : }
1057 : // font posture
1058 57 : if( maUsedFlags.mbPostureUsed )
1059 : {
1060 57 : rPropMap.setProperty( PROP_CharPosture, maApiData.maDesc.Slant);
1061 57 : rPropMap.setProperty( PROP_CharPostureAsian, maApiData.maDesc.Slant);
1062 57 : rPropMap.setProperty( PROP_CharPostureComplex, maApiData.maDesc.Slant);
1063 : }
1064 : // character color
1065 57 : if( maUsedFlags.mbColorUsed )
1066 57 : rPropMap.setProperty( PROP_CharColor, maApiData.mnColor);
1067 : // underline style
1068 57 : if( maUsedFlags.mbUnderlineUsed )
1069 57 : rPropMap.setProperty( PROP_CharUnderline, maApiData.maDesc.Underline);
1070 : // strike out style
1071 57 : if( maUsedFlags.mbStrikeoutUsed )
1072 57 : rPropMap.setProperty( PROP_CharStrikeout, maApiData.maDesc.Strikeout);
1073 : // outline style
1074 57 : if( maUsedFlags.mbOutlineUsed )
1075 57 : rPropMap.setProperty( PROP_CharContoured, maApiData.mbOutline);
1076 : // shadow style
1077 57 : if( maUsedFlags.mbShadowUsed )
1078 57 : rPropMap.setProperty( PROP_CharShadowed, maApiData.mbShadow);
1079 : // escapement
1080 57 : if( maUsedFlags.mbEscapementUsed )
1081 : {
1082 57 : rPropMap.setProperty( PROP_CharEscapement, maApiData.mnEscapement);
1083 57 : if( ePropType == FONT_PROPTYPE_TEXT )
1084 57 : rPropMap.setProperty( PROP_CharEscapementHeight, maApiData.mnEscapeHeight);
1085 : }
1086 57 : }
1087 :
1088 57 : void Font::writeToPropertySet( PropertySet& rPropSet, FontPropertyType ePropType ) const
1089 : {
1090 57 : PropertyMap aPropMap;
1091 57 : writeToPropertyMap( aPropMap, ePropType );
1092 57 : rPropSet.setProperties( aPropMap );
1093 57 : }
1094 :
1095 603 : AlignmentModel::AlignmentModel() :
1096 : mnHorAlign( XML_general ),
1097 : mnVerAlign( XML_bottom ),
1098 : mnTextDir( OOX_XF_TEXTDIR_CONTEXT ),
1099 : mnRotation( OOX_XF_ROTATION_NONE ),
1100 : mnIndent( OOX_XF_INDENT_NONE ),
1101 : mbWrapText( false ),
1102 : mbShrink( false ),
1103 603 : mbJustLastLine( false )
1104 : {
1105 603 : }
1106 :
1107 0 : void AlignmentModel::setBiffHorAlign( sal_uInt8 nHorAlign )
1108 : {
1109 : static const sal_Int32 spnHorAligns[] = {
1110 : XML_general, XML_left, XML_center, XML_right,
1111 : XML_fill, XML_justify, XML_centerContinuous, XML_distributed };
1112 0 : mnHorAlign = STATIC_ARRAY_SELECT( spnHorAligns, nHorAlign, XML_general );
1113 0 : }
1114 :
1115 0 : void AlignmentModel::setBiffVerAlign( sal_uInt8 nVerAlign )
1116 : {
1117 : static const sal_Int32 spnVerAligns[] = {
1118 : XML_top, XML_center, XML_bottom, XML_justify, XML_distributed };
1119 0 : mnVerAlign = STATIC_ARRAY_SELECT( spnVerAligns, nVerAlign, XML_bottom );
1120 0 : }
1121 :
1122 603 : ApiAlignmentData::ApiAlignmentData() :
1123 : meHorJustify( ::com::sun::star::table::CellHoriJustify_STANDARD ),
1124 : mnHorJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO ),
1125 : mnVerJustify( ::com::sun::star::table::CellVertJustify2::STANDARD ),
1126 : mnVerJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO ),
1127 : meOrientation( ::com::sun::star::table::CellOrientation_STANDARD ),
1128 : mnRotation( 0 ),
1129 : mnWritingMode( ::com::sun::star::text::WritingMode2::PAGE ),
1130 : mnIndent( 0 ),
1131 : mbWrapText( false ),
1132 603 : mbShrink( false )
1133 : {
1134 603 : }
1135 :
1136 72 : bool operator==( const ApiAlignmentData& rLeft, const ApiAlignmentData& rRight )
1137 : {
1138 : return
1139 144 : (rLeft.meHorJustify == rRight.meHorJustify) &&
1140 144 : (rLeft.mnHorJustifyMethod == rRight.mnHorJustifyMethod) &&
1141 144 : (rLeft.mnVerJustify == rRight.mnVerJustify) &&
1142 144 : (rLeft.mnVerJustifyMethod == rRight.mnVerJustifyMethod) &&
1143 144 : (rLeft.meOrientation == rRight.meOrientation) &&
1144 144 : (rLeft.mnRotation == rRight.mnRotation) &&
1145 144 : (rLeft.mnWritingMode == rRight.mnWritingMode) &&
1146 144 : (rLeft.mnIndent == rRight.mnIndent) &&
1147 216 : (rLeft.mbWrapText == rRight.mbWrapText) &&
1148 144 : (rLeft.mbShrink == rRight.mbShrink);
1149 : }
1150 :
1151 603 : Alignment::Alignment( const WorkbookHelper& rHelper ) :
1152 603 : WorkbookHelper( rHelper )
1153 : {
1154 603 : }
1155 :
1156 62 : void Alignment::importAlignment( const AttributeList& rAttribs )
1157 : {
1158 62 : maModel.mnHorAlign = rAttribs.getToken( XML_horizontal, XML_general );
1159 62 : maModel.mnVerAlign = rAttribs.getToken( XML_vertical, XML_bottom );
1160 62 : maModel.mnTextDir = rAttribs.getInteger( XML_readingOrder, OOX_XF_TEXTDIR_CONTEXT );
1161 62 : maModel.mnRotation = rAttribs.getInteger( XML_textRotation, OOX_XF_ROTATION_NONE );
1162 62 : maModel.mnIndent = rAttribs.getInteger( XML_indent, OOX_XF_INDENT_NONE );
1163 62 : maModel.mbWrapText = rAttribs.getBool( XML_wrapText, false );
1164 62 : maModel.mbShrink = rAttribs.getBool( XML_shrinkToFit, false );
1165 62 : maModel.mbJustLastLine = rAttribs.getBool( XML_justifyLastLine, false );
1166 62 : }
1167 :
1168 0 : void Alignment::setBiff12Data( sal_uInt32 nFlags )
1169 : {
1170 0 : maModel.setBiffHorAlign( extractValue< sal_uInt8 >( nFlags, 16, 3 ) );
1171 0 : maModel.setBiffVerAlign( extractValue< sal_uInt8 >( nFlags, 19, 3 ) );
1172 0 : maModel.mnTextDir = extractValue< sal_Int32 >( nFlags, 26, 2 );
1173 0 : maModel.mnRotation = extractValue< sal_Int32 >( nFlags, 0, 8 );
1174 0 : maModel.mnIndent = extractValue< sal_uInt8 >( nFlags, 8, 8 );
1175 0 : maModel.mbWrapText = getFlag( nFlags, BIFF12_XF_WRAPTEXT );
1176 0 : maModel.mbShrink = getFlag( nFlags, BIFF12_XF_SHRINK );
1177 0 : maModel.mbJustLastLine = getFlag( nFlags, BIFF12_XF_JUSTLASTLINE );
1178 0 : }
1179 :
1180 603 : void Alignment::finalizeImport()
1181 : {
1182 : namespace csstab = ::com::sun::star::table;
1183 : namespace csstxt = ::com::sun::star::text;
1184 :
1185 : // horizontal alignment
1186 603 : switch( maModel.mnHorAlign )
1187 : {
1188 3 : case XML_center: maApiData.meHorJustify = csstab::CellHoriJustify_CENTER; break;
1189 0 : case XML_centerContinuous: maApiData.meHorJustify = csstab::CellHoriJustify_CENTER; break;
1190 0 : case XML_distributed: maApiData.meHorJustify = csstab::CellHoriJustify_BLOCK; break;
1191 0 : case XML_fill: maApiData.meHorJustify = csstab::CellHoriJustify_REPEAT; break;
1192 598 : case XML_general: maApiData.meHorJustify = csstab::CellHoriJustify_STANDARD; break;
1193 0 : case XML_justify: maApiData.meHorJustify = csstab::CellHoriJustify_BLOCK; break;
1194 2 : case XML_left: maApiData.meHorJustify = csstab::CellHoriJustify_LEFT; break;
1195 0 : case XML_right: maApiData.meHorJustify = csstab::CellHoriJustify_RIGHT; break;
1196 : }
1197 :
1198 603 : if (maModel.mnHorAlign == XML_distributed)
1199 0 : maApiData.mnHorJustifyMethod = csstab::CellJustifyMethod::DISTRIBUTE;
1200 :
1201 : // vertical alignment
1202 603 : switch( maModel.mnVerAlign )
1203 : {
1204 600 : case XML_bottom: maApiData.mnVerJustify = csstab::CellVertJustify2::BOTTOM; break;
1205 1 : case XML_center: maApiData.mnVerJustify = csstab::CellVertJustify2::CENTER; break;
1206 0 : case XML_distributed: maApiData.mnVerJustify = csstab::CellVertJustify2::BLOCK; break;
1207 0 : case XML_justify: maApiData.mnVerJustify = csstab::CellVertJustify2::BLOCK; break;
1208 2 : case XML_top: maApiData.mnVerJustify = csstab::CellVertJustify2::TOP; break;
1209 : }
1210 :
1211 603 : if (maModel.mnVerAlign == XML_distributed)
1212 0 : maApiData.mnVerJustifyMethod = csstab::CellJustifyMethod::DISTRIBUTE;
1213 :
1214 : /* indentation: expressed as number of blocks of 3 space characters in
1215 : OOXML/BIFF12, and as multiple of 10 points in BIFF8. */
1216 603 : sal_Int32 nIndent = 0;
1217 603 : switch( getFilterType() )
1218 : {
1219 603 : case FILTER_OOXML: nIndent = getUnitConverter().scaleToMm100( 3.0 * maModel.mnIndent, UNIT_SPACE ); break;
1220 0 : case FILTER_BIFF: nIndent = getUnitConverter().scaleToMm100( 10.0 * maModel.mnIndent, UNIT_POINT ); break;
1221 0 : case FILTER_UNKNOWN: break;
1222 : }
1223 603 : if( (0 <= nIndent) && (nIndent <= SAL_MAX_INT16) )
1224 603 : maApiData.mnIndent = static_cast< sal_Int16 >( nIndent );
1225 :
1226 : // complex text direction
1227 603 : switch( maModel.mnTextDir )
1228 : {
1229 603 : case OOX_XF_TEXTDIR_CONTEXT: maApiData.mnWritingMode = csstxt::WritingMode2::PAGE; break;
1230 0 : case OOX_XF_TEXTDIR_LTR: maApiData.mnWritingMode = csstxt::WritingMode2::LR_TB; break;
1231 0 : case OOX_XF_TEXTDIR_RTL: maApiData.mnWritingMode = csstxt::WritingMode2::RL_TB; break;
1232 : }
1233 :
1234 : // rotation: 0-90 means 0 to 90 degrees ccw, 91-180 means 1 to 90 degrees cw, 255 means stacked
1235 603 : sal_Int32 nOoxRot = maModel.mnRotation;
1236 603 : maApiData.mnRotation = ((0 <= nOoxRot) && (nOoxRot <= 90)) ?
1237 : (100 * nOoxRot) :
1238 1206 : (((91 <= nOoxRot) && (nOoxRot <= 180)) ? (100 * (450 - nOoxRot)) : 0);
1239 :
1240 : // "Orientation" property used for character stacking
1241 : maApiData.meOrientation = (nOoxRot == OOX_XF_ROTATION_STACKED) ?
1242 603 : csstab::CellOrientation_STACKED : csstab::CellOrientation_STANDARD;
1243 :
1244 : // alignment flags (#i84960 automatic line break, if vertically justified/distributed)
1245 603 : maApiData.mbWrapText = maModel.mbWrapText || (maModel.mnVerAlign == XML_distributed) || (maModel.mnVerAlign == XML_justify);
1246 603 : maApiData.mbShrink = maModel.mbShrink;
1247 :
1248 603 : }
1249 :
1250 51 : ::SvxCellVerJustify Alignment::GetScVerAlign() const
1251 : {
1252 : namespace csstab = ::com::sun::star::table;
1253 51 : ::SvxCellVerJustify nVert = ::SVX_VER_JUSTIFY_STANDARD;
1254 51 : switch ( maApiData.mnVerJustify )
1255 : {
1256 : case csstab::CellVertJustify2::BOTTOM:
1257 48 : nVert = ::SVX_VER_JUSTIFY_BOTTOM;
1258 48 : break;
1259 : case csstab::CellVertJustify2::CENTER:
1260 1 : nVert = ::SVX_VER_JUSTIFY_CENTER;
1261 1 : break;
1262 : case csstab::CellVertJustify2::TOP:
1263 2 : nVert = ::SVX_VER_JUSTIFY_TOP;
1264 2 : break;
1265 : case csstab::CellVertJustify2::BLOCK:
1266 0 : nVert = ::SVX_VER_JUSTIFY_BLOCK;
1267 0 : break;
1268 : case csstab::CellVertJustify2::STANDARD:
1269 : default:
1270 0 : nVert = ::SVX_VER_JUSTIFY_STANDARD;
1271 0 : break;
1272 : }
1273 51 : return nVert;
1274 : }
1275 :
1276 51 : ::SvxCellHorJustify Alignment::GetScHorAlign() const
1277 : {
1278 : namespace csstab = ::com::sun::star::table;
1279 51 : ::SvxCellHorJustify nHori = ::SVX_HOR_JUSTIFY_STANDARD;
1280 51 : switch( maApiData.meHorJustify )
1281 : {
1282 : case csstab::CellHoriJustify_LEFT:
1283 2 : nHori = ::SVX_HOR_JUSTIFY_LEFT;
1284 2 : break;
1285 : case csstab::CellHoriJustify_CENTER:
1286 3 : nHori = ::SVX_HOR_JUSTIFY_CENTER;
1287 3 : break;
1288 : case csstab::CellHoriJustify_RIGHT:
1289 0 : nHori = ::SVX_HOR_JUSTIFY_RIGHT;
1290 0 : break;
1291 : case csstab::CellHoriJustify_BLOCK:
1292 0 : nHori = ::SVX_HOR_JUSTIFY_BLOCK;
1293 0 : break;
1294 : case csstab::CellHoriJustify_REPEAT:
1295 0 : nHori = ::SVX_HOR_JUSTIFY_REPEAT;
1296 0 : break;
1297 : case csstab::CellHoriJustify_STANDARD:
1298 : default:
1299 46 : nHori = ::SVX_HOR_JUSTIFY_STANDARD;
1300 46 : break;
1301 : }
1302 51 : return nHori;
1303 : }
1304 :
1305 51 : ::SvxFrameDirection Alignment::GetScFrameDir() const
1306 : {
1307 : namespace csstxt = ::com::sun::star::text;
1308 51 : ::SvxFrameDirection eFrameDir = ::FRMDIR_ENVIRONMENT;
1309 51 : switch( maApiData.mnWritingMode )
1310 : {
1311 : case csstxt::WritingMode2::PAGE:
1312 51 : eFrameDir = ::FRMDIR_ENVIRONMENT;
1313 51 : break;
1314 : case csstxt::WritingMode2::LR_TB:
1315 0 : eFrameDir = ::FRMDIR_HORI_LEFT_TOP;
1316 0 : break;
1317 : case csstxt::WritingMode2::RL_TB:
1318 0 : eFrameDir = ::FRMDIR_HORI_RIGHT_TOP;
1319 0 : break;
1320 : default:
1321 : OSL_FAIL( "GetScFrameDir - unknown CTL text direction" );
1322 : }
1323 51 : return eFrameDir;
1324 : }
1325 :
1326 51 : void Alignment::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
1327 : {
1328 : namespace csstab = ::com::sun::star::table;
1329 : // horizontal alignment
1330 51 : ScfTools::PutItem( rItemSet, SvxHorJustifyItem( GetScHorAlign(), ATTR_HOR_JUSTIFY ), bSkipPoolDefs );
1331 51 : ScfTools::PutItem( rItemSet, SvxJustifyMethodItem( ( maApiData.mnHorJustifyMethod == csstab::CellJustifyMethod::DISTRIBUTE ) ? ::SVX_JUSTIFY_METHOD_DISTRIBUTE : ::SVX_JUSTIFY_METHOD_AUTO, ATTR_HOR_JUSTIFY_METHOD ), bSkipPoolDefs );
1332 51 : ScfTools::PutItem( rItemSet, SvxVerJustifyItem( GetScVerAlign(), ATTR_VER_JUSTIFY ), bSkipPoolDefs );
1333 : // vertical alignment
1334 51 : ScfTools::PutItem( rItemSet, SvxJustifyMethodItem( ( maApiData.mnVerJustifyMethod == csstab::CellJustifyMethod::DISTRIBUTE ) ? ::SVX_JUSTIFY_METHOD_DISTRIBUTE : ::SVX_JUSTIFY_METHOD_AUTO, ATTR_VER_JUSTIFY_METHOD ), bSkipPoolDefs );
1335 :
1336 : // CTL text direction
1337 51 : ScfTools::PutItem( rItemSet, SvxFrameDirectionItem( GetScFrameDir(), ATTR_WRITINGDIR ), bSkipPoolDefs );
1338 : // set an angle in the range from -90 to 90 degrees
1339 51 : ScfTools::PutItem( rItemSet, SfxInt32Item( ATTR_ROTATE_VALUE, maApiData.mnRotation ), bSkipPoolDefs );
1340 : // Orientation
1341 51 : ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_STACKED, maApiData.meOrientation == csstab::CellOrientation_STACKED ), bSkipPoolDefs );
1342 : // indent
1343 51 : ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, maApiData.mnIndent ), bSkipPoolDefs );
1344 : // line wrap
1345 51 : ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_LINEBREAK, maApiData.mbWrapText ), bSkipPoolDefs );
1346 51 : ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_SHRINKTOFIT, maApiData.mbShrink ), bSkipPoolDefs );
1347 51 : }
1348 :
1349 0 : void Alignment::writeToPropertyMap( PropertyMap& rPropMap ) const
1350 : {
1351 0 : rPropMap.setProperty( PROP_HoriJustify, maApiData.meHorJustify);
1352 0 : rPropMap.setProperty( PROP_HoriJustifyMethod, maApiData.mnHorJustifyMethod);
1353 0 : rPropMap.setProperty( PROP_VertJustify, maApiData.mnVerJustify);
1354 0 : rPropMap.setProperty( PROP_VertJustifyMethod, maApiData.mnVerJustifyMethod);
1355 0 : rPropMap.setProperty( PROP_WritingMode, maApiData.mnWritingMode);
1356 0 : rPropMap.setProperty( PROP_RotateAngle, maApiData.mnRotation);
1357 0 : rPropMap.setProperty( PROP_Orientation, maApiData.meOrientation);
1358 0 : rPropMap.setProperty( PROP_ParaIndent, maApiData.mnIndent);
1359 0 : rPropMap.setProperty( PROP_IsTextWrapped, maApiData.mbWrapText);
1360 0 : rPropMap.setProperty( PROP_ShrinkToFit, maApiData.mbShrink);
1361 0 : }
1362 :
1363 603 : ProtectionModel::ProtectionModel() :
1364 : mbLocked( true ), // default in Excel and Calc
1365 603 : mbHidden( false )
1366 : {
1367 603 : }
1368 :
1369 603 : ApiProtectionData::ApiProtectionData() :
1370 603 : maCellProt( sal_True, sal_False, sal_False, sal_False )
1371 : {
1372 603 : }
1373 :
1374 74 : bool operator==( const ApiProtectionData& rLeft, const ApiProtectionData& rRight )
1375 : {
1376 : return
1377 148 : (rLeft.maCellProt.IsLocked == rRight.maCellProt.IsLocked) &&
1378 148 : (rLeft.maCellProt.IsFormulaHidden == rRight.maCellProt.IsFormulaHidden) &&
1379 222 : (rLeft.maCellProt.IsHidden == rRight.maCellProt.IsHidden) &&
1380 148 : (rLeft.maCellProt.IsPrintHidden == rRight.maCellProt.IsPrintHidden);
1381 : }
1382 :
1383 603 : Protection::Protection( const WorkbookHelper& rHelper ) :
1384 603 : WorkbookHelper( rHelper )
1385 : {
1386 603 : }
1387 :
1388 58 : void Protection::importProtection( const AttributeList& rAttribs )
1389 : {
1390 58 : maModel.mbLocked = rAttribs.getBool( XML_locked, true );
1391 58 : maModel.mbHidden = rAttribs.getBool( XML_hidden, false );
1392 58 : }
1393 :
1394 0 : void Protection::setBiff12Data( sal_uInt32 nFlags )
1395 : {
1396 0 : maModel.mbLocked = getFlag( nFlags, BIFF12_XF_LOCKED );
1397 0 : maModel.mbHidden = getFlag( nFlags, BIFF12_XF_HIDDEN );
1398 0 : }
1399 :
1400 603 : void Protection::finalizeImport()
1401 : {
1402 603 : maApiData.maCellProt.IsLocked = maModel.mbLocked;
1403 603 : maApiData.maCellProt.IsFormulaHidden = maModel.mbHidden;
1404 603 : }
1405 :
1406 1 : void Protection::writeToPropertyMap( PropertyMap& rPropMap ) const
1407 : {
1408 1 : rPropMap.setProperty( PROP_CellProtection, maApiData.maCellProt);
1409 1 : }
1410 :
1411 49 : void Protection::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
1412 : {
1413 49 : ScfTools::PutItem( rItemSet, ScProtectionAttr( maApiData.maCellProt.IsLocked, maApiData.maCellProt.IsFormulaHidden ), bSkipPoolDefs );
1414 49 : }
1415 :
1416 : namespace {
1417 :
1418 4 : bool lcl_isBorder(const ::com::sun::star::table::BorderLine& rBorder)
1419 : {
1420 4 : return (rBorder.InnerLineWidth > 0) || (rBorder.OuterLineWidth > 0);
1421 : }
1422 :
1423 : }
1424 :
1425 350 : BorderLineModel::BorderLineModel( bool bDxf ) :
1426 : mnStyle( XML_none ),
1427 350 : mbUsed( !bDxf )
1428 : {
1429 350 : maColor.setIndexed( OOX_COLOR_WINDOWTEXT );
1430 350 : }
1431 :
1432 0 : void BorderLineModel::setBiffStyle( sal_Int32 nLineStyle )
1433 : {
1434 : static const sal_Int32 spnStyleIds[] = {
1435 : XML_none, XML_thin, XML_medium, XML_dashed,
1436 : XML_dotted, XML_thick, XML_double, XML_hair,
1437 : XML_mediumDashed, XML_dashDot, XML_mediumDashDot, XML_dashDotDot,
1438 : XML_mediumDashDotDot, XML_slantDashDot };
1439 0 : mnStyle = STATIC_ARRAY_SELECT( spnStyleIds, nLineStyle, XML_none );
1440 0 : }
1441 :
1442 70 : BorderModel::BorderModel( bool bDxf ) :
1443 : maLeft( bDxf ),
1444 : maRight( bDxf ),
1445 : maTop( bDxf ),
1446 : maBottom( bDxf ),
1447 : maDiagonal( bDxf ),
1448 : mbDiagTLtoBR( false ),
1449 70 : mbDiagBLtoTR( false )
1450 : {
1451 70 : }
1452 :
1453 70 : ApiBorderData::ApiBorderData() :
1454 : mbBorderUsed( false ),
1455 70 : mbDiagUsed( false )
1456 : {
1457 70 : }
1458 :
1459 1 : bool ApiBorderData::hasAnyOuterBorder() const
1460 : {
1461 : return
1462 2 : ( ( lcl_isBorder( maTop ) && maTop.OuterLineWidth > 0 ) ) ||
1463 2 : ( ( lcl_isBorder( maBottom ) && maBottom.OuterLineWidth > 0 ) ) ||
1464 3 : ( ( lcl_isBorder( maLeft ) && maLeft.OuterLineWidth > 0 ) ) ||
1465 2 : ( ( lcl_isBorder( maRight ) && maRight.OuterLineWidth > 0 ) );
1466 : }
1467 :
1468 : namespace {
1469 :
1470 0 : bool operator==( const BorderLine& rLeft, const BorderLine& rRight )
1471 : {
1472 : return
1473 0 : (rLeft.Color == rRight.Color) &&
1474 0 : (rLeft.InnerLineWidth == rRight.InnerLineWidth) &&
1475 0 : (rLeft.OuterLineWidth == rRight.OuterLineWidth) &&
1476 0 : (rLeft.LineDistance == rRight.LineDistance);
1477 : }
1478 :
1479 : } // namespace
1480 :
1481 0 : bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight )
1482 : {
1483 : return
1484 0 : (rLeft.maLeft == rRight.maLeft) &&
1485 0 : (rLeft.maRight == rRight.maRight) &&
1486 0 : (rLeft.maTop == rRight.maTop) &&
1487 0 : (rLeft.maBottom == rRight.maBottom) &&
1488 0 : (rLeft.maTLtoBR == rRight.maTLtoBR) &&
1489 0 : (rLeft.maBLtoTR == rRight.maBLtoTR) &&
1490 0 : (rLeft.mbBorderUsed == rRight.mbBorderUsed) &&
1491 0 : (rLeft.mbDiagUsed == rRight.mbDiagUsed);
1492 : }
1493 :
1494 : namespace {
1495 :
1496 280 : inline void lclSetBorderLineWidth( BorderLine& rBorderLine,
1497 : sal_Int16 nOuter, sal_Int16 nDist = API_LINE_NONE, sal_Int16 nInner = API_LINE_NONE )
1498 : {
1499 280 : rBorderLine.OuterLineWidth = nOuter;
1500 280 : rBorderLine.LineDistance = nDist;
1501 280 : rBorderLine.InnerLineWidth = nInner;
1502 280 : }
1503 :
1504 : } // namespace
1505 :
1506 70 : Border::Border( const WorkbookHelper& rHelper, bool bDxf ) :
1507 : WorkbookHelper( rHelper ),
1508 : maModel( bDxf ),
1509 70 : mbDxf( bDxf )
1510 : {
1511 70 : }
1512 :
1513 70 : void Border::importBorder( const AttributeList& rAttribs )
1514 : {
1515 70 : maModel.mbDiagTLtoBR = rAttribs.getBool( XML_diagonalDown, false );
1516 70 : maModel.mbDiagBLtoTR = rAttribs.getBool( XML_diagonalUp, false );
1517 70 : }
1518 :
1519 350 : void Border::importStyle( sal_Int32 nElement, const AttributeList& rAttribs )
1520 : {
1521 350 : if( BorderLineModel* pBorderLine = getBorderLine( nElement ) )
1522 : {
1523 350 : pBorderLine->mnStyle = rAttribs.getToken( XML_style, XML_none );
1524 350 : pBorderLine->mbUsed = true;
1525 : }
1526 350 : }
1527 :
1528 17 : void Border::importColor( sal_Int32 nElement, const AttributeList& rAttribs )
1529 : {
1530 17 : if( BorderLineModel* pBorderLine = getBorderLine( nElement ) )
1531 17 : pBorderLine->maColor.importColor( rAttribs );
1532 17 : }
1533 :
1534 0 : void Border::importBorder( SequenceInputStream& rStrm )
1535 : {
1536 0 : sal_uInt8 nFlags = rStrm.readuInt8();
1537 0 : maModel.mbDiagTLtoBR = getFlag( nFlags, BIFF12_BORDER_DIAG_TLBR );
1538 0 : maModel.mbDiagBLtoTR = getFlag( nFlags, BIFF12_BORDER_DIAG_BLTR );
1539 0 : maModel.maTop.setBiffStyle( rStrm.readuInt16() );
1540 0 : rStrm >> maModel.maTop.maColor;
1541 0 : maModel.maBottom.setBiffStyle( rStrm.readuInt16() );
1542 0 : rStrm >> maModel.maBottom.maColor;
1543 0 : maModel.maLeft.setBiffStyle( rStrm.readuInt16() );
1544 0 : rStrm >> maModel.maLeft.maColor;
1545 0 : maModel.maRight.setBiffStyle( rStrm.readuInt16() );
1546 0 : rStrm >> maModel.maRight.maColor;
1547 0 : maModel.maDiagonal.setBiffStyle( rStrm.readuInt16() );
1548 0 : rStrm >> maModel.maDiagonal.maColor;
1549 0 : }
1550 :
1551 0 : void Border::importDxfBorder( sal_Int32 nElement, SequenceInputStream& rStrm )
1552 : {
1553 : SAL_WARN_IF( !mbDxf, "sc", "Border::importDxfBorder - missing conditional formatting flag" );
1554 0 : if( BorderLineModel* pBorderLine = getBorderLine( nElement ) )
1555 : {
1556 : sal_uInt16 nStyle;
1557 0 : rStrm >> pBorderLine->maColor >> nStyle;
1558 0 : pBorderLine->setBiffStyle( nStyle );
1559 0 : pBorderLine->mbUsed = true;
1560 : }
1561 0 : }
1562 :
1563 70 : void Border::finalizeImport( bool bRTL )
1564 : {
1565 70 : if ( bRTL )
1566 : {
1567 0 : BorderLineModel aTmp = maModel.maLeft;
1568 0 : maModel.maLeft = maModel.maRight;
1569 0 : maModel.maRight = aTmp;
1570 : }
1571 70 : maApiData.mbBorderUsed = maModel.maLeft.mbUsed || maModel.maRight.mbUsed || maModel.maTop.mbUsed || maModel.maBottom.mbUsed;
1572 70 : maApiData.mbDiagUsed = maModel.maDiagonal.mbUsed;
1573 :
1574 70 : convertBorderLine( maApiData.maLeft, maModel.maLeft );
1575 70 : convertBorderLine( maApiData.maRight, maModel.maRight );
1576 70 : convertBorderLine( maApiData.maTop, maModel.maTop );
1577 70 : convertBorderLine( maApiData.maBottom, maModel.maBottom );
1578 :
1579 70 : if( maModel.mbDiagTLtoBR )
1580 0 : convertBorderLine( maApiData.maTLtoBR, maModel.maDiagonal );
1581 70 : if( maModel.mbDiagBLtoTR )
1582 0 : convertBorderLine( maApiData.maBLtoTR, maModel.maDiagonal );
1583 70 : }
1584 :
1585 81 : void Border::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
1586 : {
1587 81 : if( maApiData.mbBorderUsed )
1588 : {
1589 81 : SvxBoxItem aBoxItem( ATTR_BORDER );
1590 81 : ::editeng::SvxBorderLine aLine;
1591 :
1592 81 : if (SvxBoxItem::LineToSvxLine(maApiData.maLeft, aLine, false))
1593 : {
1594 3 : aBoxItem.SetLine( &aLine, BOX_LINE_LEFT );
1595 : }
1596 81 : if (SvxBoxItem::LineToSvxLine(maApiData.maRight, aLine, false))
1597 : {
1598 3 : aBoxItem.SetLine( &aLine, BOX_LINE_RIGHT );
1599 : }
1600 81 : if (SvxBoxItem::LineToSvxLine(maApiData.maTop, aLine, false))
1601 : {
1602 28 : aBoxItem.SetLine( &aLine, BOX_LINE_TOP );
1603 : }
1604 81 : if (SvxBoxItem::LineToSvxLine(maApiData.maBottom, aLine, false))
1605 : {
1606 3 : aBoxItem.SetLine( &aLine, BOX_LINE_BOTTOM );
1607 : }
1608 81 : ScfTools::PutItem( rItemSet, aBoxItem, bSkipPoolDefs );
1609 : }
1610 81 : if ( maApiData.mbDiagUsed )
1611 : {
1612 81 : SvxLineItem aTLBRItem( ATTR_BORDER_TLBR );
1613 162 : SvxLineItem aBLTRItem( ATTR_BORDER_BLTR );
1614 81 : ::editeng::SvxBorderLine aLine;
1615 81 : if (SvxBoxItem::LineToSvxLine(maApiData.maTLtoBR, aLine, false))
1616 : {
1617 0 : aTLBRItem.SetLine( &aLine );
1618 : }
1619 81 : if (SvxBoxItem::LineToSvxLine(maApiData.maBLtoTR, aLine, false))
1620 : {
1621 0 : aBLTRItem.SetLine( &aLine );
1622 : }
1623 81 : ScfTools::PutItem( rItemSet, aTLBRItem, bSkipPoolDefs );
1624 162 : ScfTools::PutItem( rItemSet, aBLTRItem, bSkipPoolDefs );
1625 : }
1626 81 : }
1627 :
1628 0 : void Border::writeToPropertyMap( PropertyMap& rPropMap ) const
1629 : {
1630 0 : if( maApiData.mbBorderUsed )
1631 : {
1632 0 : rPropMap.setProperty( PROP_LeftBorder, maApiData.maLeft);
1633 0 : rPropMap.setProperty( PROP_RightBorder, maApiData.maRight);
1634 0 : rPropMap.setProperty( PROP_TopBorder, maApiData.maTop);
1635 0 : rPropMap.setProperty( PROP_BottomBorder, maApiData.maBottom);
1636 : }
1637 0 : if( maApiData.mbDiagUsed )
1638 : {
1639 0 : rPropMap.setProperty( PROP_DiagonalTLBR, maApiData.maTLtoBR);
1640 0 : rPropMap.setProperty( PROP_DiagonalBLTR, maApiData.maBLtoTR);
1641 : }
1642 0 : }
1643 :
1644 0 : bool Border::hasBorder() const
1645 : {
1646 0 : if (lcl_isBorder(maApiData.maBottom))
1647 0 : return true;
1648 :
1649 0 : if (lcl_isBorder(maApiData.maTop))
1650 0 : return true;
1651 :
1652 0 : if (lcl_isBorder(maApiData.maLeft))
1653 0 : return true;
1654 :
1655 0 : if (lcl_isBorder(maApiData.maRight))
1656 0 : return true;
1657 :
1658 0 : return false;
1659 : }
1660 :
1661 367 : BorderLineModel* Border::getBorderLine( sal_Int32 nElement )
1662 : {
1663 367 : switch( nElement )
1664 : {
1665 71 : case XLS_TOKEN( left ): return &maModel.maLeft;
1666 0 : case XLS_TOKEN( start ): return &maModel.maLeft;
1667 71 : case XLS_TOKEN( right ): return &maModel.maRight;
1668 0 : case XLS_TOKEN( end ): return &maModel.maRight;
1669 84 : case XLS_TOKEN( top ): return &maModel.maTop;
1670 71 : case XLS_TOKEN( bottom ): return &maModel.maBottom;
1671 70 : case XLS_TOKEN( diagonal ): return &maModel.maDiagonal;
1672 : }
1673 0 : return 0;
1674 : }
1675 :
1676 280 : bool Border::convertBorderLine( BorderLine2& rBorderLine, const BorderLineModel& rModel )
1677 : {
1678 280 : rBorderLine.Color = rModel.maColor.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK );
1679 280 : switch( rModel.mnStyle )
1680 : {
1681 : case XML_dashDot:
1682 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
1683 2 : rBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT;
1684 2 : break;
1685 : case XML_dashDotDot:
1686 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
1687 2 : rBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT_DOT;
1688 2 : break;
1689 : case XML_dashed:
1690 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
1691 2 : rBorderLine.LineStyle = table::BorderLineStyle::FINE_DASHED;
1692 2 : break;
1693 : case XML_dotted:
1694 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
1695 2 : rBorderLine.LineStyle = table::BorderLineStyle::DOTTED;
1696 2 : break;
1697 : case XML_double:
1698 2 : lclSetBorderLineWidth( rBorderLine, 10, 30, 10 );
1699 2 : rBorderLine.LineStyle = table::BorderLineStyle::DOUBLE_THIN;
1700 2 : break;
1701 2 : case XML_hair: lclSetBorderLineWidth( rBorderLine, API_LINE_HAIR ); break;
1702 2 : case XML_medium: lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM ); break;
1703 : case XML_mediumDashDot:
1704 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );
1705 2 : rBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT;
1706 2 : break;
1707 : case XML_mediumDashDotDot:
1708 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );
1709 2 : rBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT_DOT;
1710 2 : break;
1711 : case XML_mediumDashed:
1712 2 : lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );
1713 2 : rBorderLine.LineStyle = table::BorderLineStyle::DASHED;
1714 2 : break;
1715 251 : case XML_none: lclSetBorderLineWidth( rBorderLine, API_LINE_NONE ); break;
1716 : case XML_slantDashDot:
1717 1 : lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );
1718 1 : rBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT;
1719 1 : break;
1720 2 : case XML_thick: lclSetBorderLineWidth( rBorderLine, API_LINE_THICK ); break;
1721 6 : case XML_thin: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break;
1722 0 : default: lclSetBorderLineWidth( rBorderLine, API_LINE_NONE ); break;
1723 : }
1724 280 : return rModel.mbUsed;
1725 : }
1726 :
1727 :
1728 90 : PatternFillModel::PatternFillModel( bool bDxf ) :
1729 : mnPattern( XML_none ),
1730 90 : mbPattColorUsed( !bDxf ),
1731 90 : mbFillColorUsed( !bDxf ),
1732 270 : mbPatternUsed( !bDxf )
1733 : {
1734 90 : maPatternColor.setIndexed( OOX_COLOR_WINDOWTEXT );
1735 90 : maFillColor.setIndexed( OOX_COLOR_WINDOWBACK );
1736 90 : }
1737 :
1738 0 : void PatternFillModel::setBiffPattern( sal_Int32 nPattern )
1739 : {
1740 : static const sal_Int32 spnPatternIds[] = {
1741 : XML_none, XML_solid, XML_mediumGray, XML_darkGray,
1742 : XML_lightGray, XML_darkHorizontal, XML_darkVertical, XML_darkDown,
1743 : XML_darkUp, XML_darkGrid, XML_darkTrellis, XML_lightHorizontal,
1744 : XML_lightVertical, XML_lightDown, XML_lightUp, XML_lightGrid,
1745 : XML_lightTrellis, XML_gray125, XML_gray0625 };
1746 0 : mnPattern = STATIC_ARRAY_SELECT( spnPatternIds, nPattern, XML_none );
1747 0 : }
1748 :
1749 0 : GradientFillModel::GradientFillModel() :
1750 : mnType( XML_linear ),
1751 : mfAngle( 0.0 ),
1752 : mfLeft( 0.0 ),
1753 : mfRight( 0.0 ),
1754 : mfTop( 0.0 ),
1755 0 : mfBottom( 0.0 )
1756 : {
1757 0 : }
1758 :
1759 0 : void GradientFillModel::readGradient( SequenceInputStream& rStrm )
1760 : {
1761 : sal_Int32 nType;
1762 0 : rStrm >> nType >> mfAngle >> mfLeft >> mfRight >> mfTop >> mfBottom;
1763 : static const sal_Int32 spnTypes[] = { XML_linear, XML_path };
1764 0 : mnType = STATIC_ARRAY_SELECT( spnTypes, nType, XML_TOKEN_INVALID );
1765 0 : }
1766 :
1767 0 : void GradientFillModel::readGradientStop( SequenceInputStream& rStrm, bool bDxf )
1768 : {
1769 0 : Color aColor;
1770 : double fPosition;
1771 0 : if( bDxf )
1772 : {
1773 0 : rStrm.skip( 2 );
1774 0 : rStrm >> fPosition >> aColor;
1775 : }
1776 : else
1777 : {
1778 0 : rStrm >> aColor >> fPosition;
1779 : }
1780 0 : if( !rStrm.isEof() && (fPosition >= 0.0) )
1781 0 : maColors[ fPosition ] = aColor;
1782 0 : }
1783 :
1784 90 : ApiSolidFillData::ApiSolidFillData() :
1785 : mnColor( API_RGB_TRANSPARENT ),
1786 : mbTransparent( true ),
1787 90 : mbUsed( false )
1788 : {
1789 90 : }
1790 :
1791 0 : bool operator==( const ApiSolidFillData& rLeft, const ApiSolidFillData& rRight )
1792 : {
1793 : return
1794 0 : (rLeft.mnColor == rRight.mnColor) &&
1795 0 : (rLeft.mbTransparent == rRight.mbTransparent) &&
1796 0 : (rLeft.mbUsed == rRight.mbUsed);
1797 : }
1798 :
1799 : namespace {
1800 :
1801 138 : inline sal_Int32 lclGetMixedColorComp( sal_Int32 nPatt, sal_Int32 nFill, sal_Int32 nAlpha )
1802 : {
1803 138 : return ((nPatt - nFill) * nAlpha) / 0x80 + nFill;
1804 : }
1805 :
1806 46 : sal_Int32 lclGetMixedColor( sal_Int32 nPattColor, sal_Int32 nFillColor, sal_Int32 nAlpha )
1807 : {
1808 : return
1809 92 : (lclGetMixedColorComp( nPattColor & 0xFF0000, nFillColor & 0xFF0000, nAlpha ) & 0xFF0000) |
1810 46 : (lclGetMixedColorComp( nPattColor & 0x00FF00, nFillColor & 0x00FF00, nAlpha ) & 0x00FF00) |
1811 46 : (lclGetMixedColorComp( nPattColor & 0x0000FF, nFillColor & 0x0000FF, nAlpha ) & 0x0000FF);
1812 : }
1813 :
1814 : } // namespace
1815 :
1816 90 : Fill::Fill( const WorkbookHelper& rHelper, bool bDxf ) :
1817 : WorkbookHelper( rHelper ),
1818 90 : mbDxf( bDxf )
1819 : {
1820 90 : }
1821 :
1822 90 : void Fill::importPatternFill( const AttributeList& rAttribs )
1823 : {
1824 90 : mxPatternModel.reset( new PatternFillModel( mbDxf ) );
1825 90 : mxPatternModel->mnPattern = rAttribs.getToken( XML_patternType, XML_none );
1826 90 : if( mbDxf )
1827 0 : mxPatternModel->mbPatternUsed = rAttribs.hasAttribute( XML_patternType );
1828 90 : }
1829 :
1830 2 : void Fill::importFgColor( const AttributeList& rAttribs )
1831 : {
1832 : OSL_ENSURE( mxPatternModel.get(), "Fill::importFgColor - missing pattern data" );
1833 2 : if( mxPatternModel.get() )
1834 : {
1835 2 : mxPatternModel->maPatternColor.importColor( rAttribs );
1836 2 : mxPatternModel->mbPattColorUsed = true;
1837 : }
1838 2 : }
1839 :
1840 2 : void Fill::importBgColor( const AttributeList& rAttribs )
1841 : {
1842 : OSL_ENSURE( mxPatternModel.get(), "Fill::importBgColor - missing pattern data" );
1843 2 : if( mxPatternModel.get() )
1844 : {
1845 2 : mxPatternModel->maFillColor.importColor( rAttribs );
1846 2 : mxPatternModel->mbFillColorUsed = true;
1847 : }
1848 2 : }
1849 :
1850 0 : void Fill::importGradientFill( const AttributeList& rAttribs )
1851 : {
1852 0 : mxGradientModel.reset( new GradientFillModel );
1853 0 : mxGradientModel->mnType = rAttribs.getToken( XML_type, XML_linear );
1854 0 : mxGradientModel->mfAngle = rAttribs.getDouble( XML_degree, 0.0 );
1855 0 : mxGradientModel->mfLeft = rAttribs.getDouble( XML_left, 0.0 );
1856 0 : mxGradientModel->mfRight = rAttribs.getDouble( XML_right, 0.0 );
1857 0 : mxGradientModel->mfTop = rAttribs.getDouble( XML_top, 0.0 );
1858 0 : mxGradientModel->mfBottom = rAttribs.getDouble( XML_bottom, 0.0 );
1859 0 : }
1860 :
1861 0 : void Fill::importColor( const AttributeList& rAttribs, double fPosition )
1862 : {
1863 : OSL_ENSURE( mxGradientModel.get(), "Fill::importColor - missing gradient data" );
1864 0 : if( mxGradientModel.get() && (fPosition >= 0.0) )
1865 0 : mxGradientModel->maColors[ fPosition ].importColor( rAttribs );
1866 0 : }
1867 :
1868 0 : void Fill::importFill( SequenceInputStream& rStrm )
1869 : {
1870 : SAL_WARN_IF( mbDxf, "sc", "Fill::importFill - unexpected conditional formatting flag" );
1871 0 : sal_Int32 nPattern = rStrm.readInt32();
1872 0 : if( nPattern == BIFF12_FILL_GRADIENT )
1873 : {
1874 0 : mxGradientModel.reset( new GradientFillModel );
1875 : sal_Int32 nStopCount;
1876 0 : rStrm.skip( 16 );
1877 0 : mxGradientModel->readGradient( rStrm );
1878 0 : rStrm >> nStopCount;
1879 0 : for( sal_Int32 nStop = 0; (nStop < nStopCount) && !rStrm.isEof(); ++nStop )
1880 0 : mxGradientModel->readGradientStop( rStrm, false );
1881 : }
1882 : else
1883 : {
1884 0 : mxPatternModel.reset( new PatternFillModel( mbDxf ) );
1885 0 : mxPatternModel->setBiffPattern( nPattern );
1886 0 : rStrm >> mxPatternModel->maPatternColor >> mxPatternModel->maFillColor;
1887 : }
1888 0 : }
1889 :
1890 0 : void Fill::importDxfPattern( SequenceInputStream& rStrm )
1891 : {
1892 : SAL_WARN_IF( !mbDxf, "sc", "Fill::importDxfPattern - missing conditional formatting flag" );
1893 0 : if( !mxPatternModel )
1894 0 : mxPatternModel.reset( new PatternFillModel( mbDxf ) );
1895 0 : mxPatternModel->setBiffPattern( rStrm.readuInt8() );
1896 0 : mxPatternModel->mbPatternUsed = true;
1897 0 : }
1898 :
1899 0 : void Fill::importDxfFgColor( SequenceInputStream& rStrm )
1900 : {
1901 : SAL_WARN_IF( !mbDxf, "sc", "Fill::importDxfFgColor - missing conditional formatting flag" );
1902 0 : if( !mxPatternModel )
1903 0 : mxPatternModel.reset( new PatternFillModel( mbDxf ) );
1904 0 : mxPatternModel->maPatternColor.importColor( rStrm );
1905 0 : mxPatternModel->mbPattColorUsed = true;
1906 0 : }
1907 :
1908 0 : void Fill::importDxfBgColor( SequenceInputStream& rStrm )
1909 : {
1910 : SAL_WARN_IF( !mbDxf, "sc", "Fill::importDxfBgColor - missing conditional formatting flag" );
1911 0 : if( !mxPatternModel )
1912 0 : mxPatternModel.reset( new PatternFillModel( mbDxf ) );
1913 0 : mxPatternModel->maFillColor.importColor( rStrm );
1914 0 : mxPatternModel->mbFillColorUsed = true;
1915 0 : }
1916 :
1917 0 : void Fill::importDxfGradient( SequenceInputStream& rStrm )
1918 : {
1919 : SAL_WARN_IF( !mbDxf, "sc", "Fill::importDxfGradient - missing conditional formatting flag" );
1920 0 : if( !mxGradientModel )
1921 0 : mxGradientModel.reset( new GradientFillModel );
1922 0 : mxGradientModel->readGradient( rStrm );
1923 0 : }
1924 :
1925 0 : void Fill::importDxfStop( SequenceInputStream& rStrm )
1926 : {
1927 : SAL_WARN_IF( !mbDxf, "sc", "Fill::importDxfStop - missing conditional formatting flag" );
1928 0 : if( !mxGradientModel )
1929 0 : mxGradientModel.reset( new GradientFillModel );
1930 0 : mxGradientModel->readGradientStop( rStrm, true );
1931 0 : }
1932 :
1933 90 : void Fill::finalizeImport()
1934 : {
1935 90 : const GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper();
1936 :
1937 90 : if( mxPatternModel.get() )
1938 : {
1939 : // finalize the OOXML data struct
1940 90 : PatternFillModel& rModel = *mxPatternModel;
1941 90 : if( mbDxf )
1942 : {
1943 0 : if( rModel.mbFillColorUsed && (!rModel.mbPatternUsed || (rModel.mnPattern == XML_solid)) )
1944 : {
1945 0 : rModel.maPatternColor = rModel.maFillColor;
1946 0 : rModel.mnPattern = XML_solid;
1947 0 : rModel.mbPattColorUsed = rModel.mbPatternUsed = true;
1948 : }
1949 0 : else if( !rModel.mbFillColorUsed && rModel.mbPatternUsed && (rModel.mnPattern == XML_solid) )
1950 : {
1951 0 : rModel.mbPatternUsed = false;
1952 : }
1953 : }
1954 :
1955 : // convert to API fill settings
1956 90 : maApiData.mbUsed = rModel.mbPatternUsed;
1957 90 : if( rModel.mnPattern == XML_none )
1958 : {
1959 44 : maApiData.mnColor = API_RGB_TRANSPARENT;
1960 44 : maApiData.mbTransparent = true;
1961 : }
1962 : else
1963 : {
1964 46 : sal_Int32 nAlpha = 0x80;
1965 46 : switch( rModel.mnPattern )
1966 : {
1967 0 : case XML_darkDown: nAlpha = 0x40; break;
1968 0 : case XML_darkGray: nAlpha = 0x60; break;
1969 0 : case XML_darkGrid: nAlpha = 0x40; break;
1970 0 : case XML_darkHorizontal: nAlpha = 0x40; break;
1971 0 : case XML_darkTrellis: nAlpha = 0x60; break;
1972 0 : case XML_darkUp: nAlpha = 0x40; break;
1973 0 : case XML_darkVertical: nAlpha = 0x40; break;
1974 0 : case XML_gray0625: nAlpha = 0x08; break;
1975 44 : case XML_gray125: nAlpha = 0x10; break;
1976 0 : case XML_lightDown: nAlpha = 0x20; break;
1977 0 : case XML_lightGray: nAlpha = 0x20; break;
1978 0 : case XML_lightGrid: nAlpha = 0x38; break;
1979 0 : case XML_lightHorizontal: nAlpha = 0x20; break;
1980 0 : case XML_lightTrellis: nAlpha = 0x30; break;
1981 0 : case XML_lightUp: nAlpha = 0x20; break;
1982 0 : case XML_lightVertical: nAlpha = 0x20; break;
1983 0 : case XML_mediumGray: nAlpha = 0x40; break;
1984 2 : case XML_solid: nAlpha = 0x80; break;
1985 : }
1986 :
1987 46 : sal_Int32 nWinTextColor = rGraphicHelper.getSystemColor( XML_windowText );
1988 46 : sal_Int32 nWinColor = rGraphicHelper.getSystemColor( XML_window );
1989 :
1990 46 : if( !rModel.mbPattColorUsed )
1991 0 : rModel.maPatternColor.setAuto();
1992 46 : sal_Int32 nPattColor = rModel.maPatternColor.getColor( rGraphicHelper, nWinTextColor );
1993 :
1994 46 : if( !rModel.mbFillColorUsed )
1995 0 : rModel.maFillColor.setAuto();
1996 46 : sal_Int32 nFillColor = rModel.maFillColor.getColor( rGraphicHelper, nWinColor );
1997 :
1998 46 : maApiData.mnColor = lclGetMixedColor( nPattColor, nFillColor, nAlpha );
1999 46 : maApiData.mbTransparent = false;
2000 : }
2001 : }
2002 0 : else if( mxGradientModel.get() && !mxGradientModel->maColors.empty() )
2003 : {
2004 0 : GradientFillModel& rModel = *mxGradientModel;
2005 0 : maApiData.mbUsed = true; // no support for differential attributes
2006 0 : GradientFillModel::ColorMap::const_iterator aIt = rModel.maColors.begin();
2007 : OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" );
2008 0 : maApiData.mnColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE );
2009 0 : if( ++aIt != rModel.maColors.end() )
2010 : {
2011 : OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" );
2012 0 : sal_Int32 nEndColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE );
2013 0 : maApiData.mnColor = lclGetMixedColor( maApiData.mnColor, nEndColor, 0x40 );
2014 0 : maApiData.mbTransparent = false;
2015 : }
2016 : }
2017 90 : }
2018 :
2019 50 : void Fill::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
2020 : {
2021 50 : if( maApiData.mbUsed )
2022 : {
2023 50 : SvxBrushItem aBrushItem( ATTR_BACKGROUND );
2024 50 : if ( maApiData.mbTransparent )
2025 : {
2026 48 : aBrushItem.SetColor( ::Color( COL_TRANSPARENT ) );
2027 : }
2028 : else
2029 : {
2030 2 : aBrushItem.SetColor( maApiData.mnColor );
2031 : }
2032 50 : ScfTools::PutItem( rItemSet, aBrushItem, bSkipPoolDefs );
2033 : }
2034 50 : }
2035 :
2036 0 : void Fill::writeToPropertyMap( PropertyMap& rPropMap ) const
2037 : {
2038 0 : if( maApiData.mbUsed )
2039 : {
2040 0 : rPropMap.setProperty( PROP_CellBackColor, maApiData.mnColor);
2041 0 : rPropMap.setProperty( PROP_IsCellBackgroundTransparent, maApiData.mbTransparent);
2042 : }
2043 0 : }
2044 :
2045 603 : XfModel::XfModel() :
2046 : mnStyleXfId( -1 ),
2047 : mnFontId( -1 ),
2048 : mnNumFmtId( -1 ),
2049 : mnBorderId( -1 ),
2050 : mnFillId( -1 ),
2051 : mbCellXf( true ),
2052 : mbFontUsed( false ),
2053 : mbNumFmtUsed( false ),
2054 : mbAlignUsed( false ),
2055 : mbProtUsed( false ),
2056 : mbBorderUsed( false ),
2057 603 : mbAreaUsed( false )
2058 : {
2059 603 : }
2060 :
2061 603 : Xf::Xf( const WorkbookHelper& rHelper ) :
2062 : WorkbookHelper( rHelper ),
2063 : maAlignment( rHelper ),
2064 : maProtection( rHelper ),
2065 : meRotationRef( ::com::sun::star::table::CellVertJustify2::STANDARD ),
2066 603 : mpStyleSheet( NULL )
2067 : {
2068 603 : }
2069 :
2070 603 : void Xf::importXf( const AttributeList& rAttribs, bool bCellXf )
2071 : {
2072 603 : maModel.mbCellXf = bCellXf;
2073 603 : maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, -1 );
2074 603 : maModel.mnFontId = rAttribs.getInteger( XML_fontId, -1 );
2075 603 : maModel.mnNumFmtId = rAttribs.getInteger( XML_numFmtId, -1 );
2076 603 : maModel.mnBorderId = rAttribs.getInteger( XML_borderId, -1 );
2077 603 : maModel.mnFillId = rAttribs.getInteger( XML_fillId, -1 );
2078 :
2079 : /* Default value of the apply*** attributes is dependent on context:
2080 : true in cellStyleXfs element, false in cellXfs element... */
2081 603 : maModel.mbAlignUsed = rAttribs.getBool( XML_applyAlignment, !maModel.mbCellXf );
2082 603 : maModel.mbProtUsed = rAttribs.getBool( XML_applyProtection, !maModel.mbCellXf );
2083 603 : maModel.mbFontUsed = rAttribs.getBool( XML_applyFont, !maModel.mbCellXf );
2084 603 : maModel.mbNumFmtUsed = rAttribs.getBool( XML_applyNumberFormat, !maModel.mbCellXf );
2085 603 : maModel.mbBorderUsed = rAttribs.getBool( XML_applyBorder, !maModel.mbCellXf );
2086 603 : maModel.mbAreaUsed = rAttribs.getBool( XML_applyFill, !maModel.mbCellXf );
2087 603 : }
2088 :
2089 62 : void Xf::importAlignment( const AttributeList& rAttribs )
2090 : {
2091 62 : maAlignment.importAlignment( rAttribs );
2092 62 : }
2093 :
2094 58 : void Xf::importProtection( const AttributeList& rAttribs )
2095 : {
2096 58 : maProtection.importProtection( rAttribs );
2097 58 : }
2098 :
2099 0 : void Xf::importXf( SequenceInputStream& rStrm, bool bCellXf )
2100 : {
2101 0 : maModel.mbCellXf = bCellXf;
2102 0 : maModel.mnStyleXfId = rStrm.readuInt16();
2103 0 : maModel.mnNumFmtId = rStrm.readuInt16();
2104 0 : maModel.mnFontId = rStrm.readuInt16();
2105 0 : maModel.mnFillId = rStrm.readuInt16();
2106 0 : maModel.mnBorderId = rStrm.readuInt16();
2107 0 : sal_uInt32 nFlags = rStrm.readuInt32();
2108 0 : maAlignment.setBiff12Data( nFlags );
2109 0 : maProtection.setBiff12Data( nFlags );
2110 : // used flags, see comments in Xf::setBiffUsedFlags()
2111 0 : sal_uInt16 nUsedFlags = rStrm.readuInt16();
2112 0 : maModel.mbFontUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_FONT_USED );
2113 0 : maModel.mbNumFmtUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_NUMFMT_USED );
2114 0 : maModel.mbAlignUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_ALIGN_USED );
2115 0 : maModel.mbProtUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_PROT_USED );
2116 0 : maModel.mbBorderUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_BORDER_USED );
2117 0 : maModel.mbAreaUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_AREA_USED );
2118 0 : }
2119 :
2120 603 : void Xf::finalizeImport()
2121 : {
2122 : // alignment and protection
2123 603 : maAlignment.finalizeImport();
2124 603 : maProtection.finalizeImport();
2125 603 : }
2126 :
2127 296 : FontRef Xf::getFont() const
2128 : {
2129 296 : return getStyles().getFont( maModel.mnFontId );
2130 : }
2131 :
2132 325 : void Xf::applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2,
2133 : sal_Int32 nNumFmtId )
2134 : {
2135 325 : createPattern();
2136 325 : ScPatternAttr& rPat = *mpPattern;
2137 325 : ScDocument& rDoc = getScDocument();
2138 325 : if ( isCellXf() )
2139 : {
2140 325 : StylesBuffer& rStyles = getStyles();
2141 325 : rStyles.createCellStyle( maModel.mnStyleXfId );
2142 :
2143 325 : mpStyleSheet = rStyles.getCellStyleSheet( maModel.mnStyleXfId );
2144 325 : if ( mpStyleSheet )
2145 : {
2146 : //rDoc.ApplySelectionStyle( static_cast<ScStyleSheet&>(*mpStyleSheet), rMarkData );
2147 325 : rPat.SetStyleSheet(mpStyleSheet, false);
2148 : }
2149 : else
2150 : {
2151 0 : ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
2152 0 : if (pStylePool)
2153 : {
2154 : ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(
2155 : pStylePool->Find(
2156 0 : ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA));
2157 :
2158 0 : if (pStyleSheet)
2159 0 : rPat.SetStyleSheet( pStyleSheet, false );
2160 : }
2161 : }
2162 : }
2163 325 : if ( nNumFmtId >= 0 )
2164 : {
2165 0 : ScPatternAttr aNumPat(rDoc.GetPool());
2166 0 : getStyles().writeNumFmtToItemSet( aNumPat.GetItemSet(), nNumFmtId );
2167 0 : rPat.GetItemSet().Put(aNumPat.GetItemSet());
2168 : }
2169 325 : if (rPat.GetStyleName())
2170 : {
2171 : // Check for a gap between the last entry and this one.
2172 325 : bool bHasGap = false;
2173 325 : if (rAttrs.empty() && nRow1 > 0)
2174 : // First attribute range doesn't start at row 0.
2175 70 : bHasGap = true;
2176 :
2177 325 : if (!rAttrs.empty() && rAttrs.back().nRow + 1 < nRow1)
2178 38 : bHasGap = true;
2179 :
2180 325 : if (bHasGap)
2181 : {
2182 : // Fill this gap with the default pattern.
2183 : ScAttrEntry aEntry;
2184 108 : aEntry.nRow = nRow1 - 1;
2185 108 : aEntry.pPattern = rDoc.GetDefPattern();
2186 108 : rAttrs.push_back(aEntry);
2187 : }
2188 :
2189 : ScAttrEntry aEntry;
2190 325 : aEntry.nRow = nRow2;
2191 325 : aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat));
2192 325 : rAttrs.push_back(aEntry);
2193 : }
2194 325 : }
2195 :
2196 62 : void Xf::writeToPropertyMap( PropertyMap& rPropMap ) const
2197 : {
2198 62 : StylesBuffer& rStyles = getStyles();
2199 :
2200 : // create and set cell style
2201 62 : if( isCellXf() )
2202 62 : rPropMap.setProperty( PROP_CellStyle, rStyles.createCellStyle( maModel.mnStyleXfId ));
2203 :
2204 62 : if( maModel.mbFontUsed )
2205 0 : rStyles.writeFontToPropertyMap( rPropMap, maModel.mnFontId );
2206 62 : if( maModel.mbNumFmtUsed )
2207 0 : rStyles.writeNumFmtToPropertyMap( rPropMap, maModel.mnNumFmtId );
2208 62 : if( maModel.mbAlignUsed )
2209 0 : maAlignment.writeToPropertyMap( rPropMap );
2210 62 : if( maModel.mbProtUsed )
2211 1 : maProtection.writeToPropertyMap( rPropMap );
2212 62 : if( maModel.mbBorderUsed )
2213 0 : rStyles.writeBorderToPropertyMap( rPropMap, maModel.mnBorderId );
2214 62 : if( maModel.mbAreaUsed )
2215 0 : rStyles.writeFillToPropertyMap( rPropMap, maModel.mnFillId );
2216 62 : if( maModel.mbAlignUsed || maModel.mbBorderUsed )
2217 0 : rPropMap.setProperty( PROP_RotateReference, meRotationRef);
2218 :
2219 62 : sal_Int32 eRotRef = ::com::sun::star::table::CellVertJustify2::STANDARD;
2220 62 : if (maModel.mbBorderUsed && rStyles.hasBorder(maModel.mnBorderId) && maAlignment.getApiData().mnRotation)
2221 0 : eRotRef = ::com::sun::star::table::CellVertJustify2::BOTTOM;
2222 62 : rPropMap.setProperty( PROP_RotateReference, eRotRef);
2223 62 : }
2224 :
2225 62 : void Xf::writeToPropertySet( PropertySet& rPropSet ) const
2226 : {
2227 62 : PropertyMap aPropMap;
2228 62 : writeToPropertyMap( aPropMap );
2229 62 : rPropSet.setProperties( aPropMap );
2230 62 : }
2231 :
2232 : const ::ScPatternAttr&
2233 378 : Xf::createPattern( bool bSkipPoolDefs )
2234 : {
2235 378 : if( mpPattern.get() )
2236 250 : return *mpPattern;
2237 128 : mpPattern.reset( new ::ScPatternAttr( getScDocument().GetPool() ) );
2238 128 : SfxItemSet& rItemSet = mpPattern->GetItemSet();
2239 : /* Enables the used flags, if the formatting attributes differ from the
2240 : style XF. In cell XFs Excel uses the cell attributes, if they differ
2241 : from the parent style XF (even if the used flag is switched off).
2242 : #109899# ...or if the respective flag is not set in parent style XF.
2243 : */
2244 128 : StylesBuffer& rStyles = getStyles();
2245 :
2246 128 : const Xf* pStyleXf = isCellXf() ? rStyles.getStyleXf( maModel.mnStyleXfId ).get() : 0;
2247 128 : if( pStyleXf && !mpStyleSheet )
2248 : {
2249 75 : rStyles.createCellStyle( maModel.mnStyleXfId );
2250 75 : mpStyleSheet = rStyles.getCellStyleSheet( maModel.mnStyleXfId );
2251 : OSL_ENSURE( mpStyleSheet, "Xf::createPattern - no parentStyle created" );
2252 :
2253 75 : const XfModel& rStyleData = pStyleXf->maModel;
2254 75 : if( !maModel.mbFontUsed )
2255 56 : maModel.mbFontUsed = !rStyleData.mbFontUsed || (maModel.mnFontId != rStyleData.mnFontId);
2256 75 : if( !maModel.mbNumFmtUsed )
2257 66 : maModel.mbNumFmtUsed = !rStyleData.mbNumFmtUsed || (maModel.mnNumFmtId != rStyleData.mnNumFmtId);
2258 75 : if( !maModel.mbAlignUsed )
2259 72 : maModel.mbAlignUsed = !rStyleData.mbAlignUsed || !(maAlignment.getApiData() == pStyleXf->maAlignment.getApiData());
2260 75 : if( !maModel.mbProtUsed )
2261 74 : maModel.mbProtUsed = !rStyleData.mbProtUsed || !(maProtection.getApiData() == pStyleXf->maProtection.getApiData());
2262 75 : if( !maModel.mbBorderUsed )
2263 42 : maModel.mbBorderUsed = !rStyleData.mbBorderUsed || !rStyles.equalBorders( maModel.mnBorderId, rStyleData.mnBorderId );
2264 75 : if( !maModel.mbAreaUsed )
2265 73 : maModel.mbAreaUsed = !rStyleData.mbAreaUsed || !rStyles.equalFills( maModel.mnFillId, rStyleData.mnFillId );
2266 : }
2267 : // cell protection
2268 128 : if( maModel.mbProtUsed )
2269 : {
2270 49 : maProtection.fillToItemSet( rItemSet, bSkipPoolDefs );
2271 : }
2272 :
2273 : // font
2274 128 : if( maModel.mbFontUsed )
2275 : {
2276 67 : rStyles.writeFontToItemSet( rItemSet, maModel.mnFontId, bSkipPoolDefs );
2277 : }
2278 :
2279 : // value format
2280 128 : if( maModel.mbNumFmtUsed )
2281 : {
2282 63 : rStyles.writeNumFmtToItemSet( rItemSet, maModel.mnNumFmtId, bSkipPoolDefs );
2283 : }
2284 : // alignment
2285 128 : if( maModel.mbAlignUsed )
2286 : {
2287 51 : maAlignment.fillToItemSet( rItemSet, bSkipPoolDefs );
2288 : }
2289 :
2290 : // border
2291 128 : if( maModel.mbBorderUsed )
2292 : {
2293 81 : rStyles.writeBorderToItemSet( rItemSet, maModel.mnBorderId, bSkipPoolDefs );
2294 : }
2295 :
2296 : // area
2297 128 : if( maModel.mbAreaUsed )
2298 : {
2299 50 : rStyles.writeFillToItemSet( rItemSet, maModel.mnFillId, bSkipPoolDefs );
2300 : }
2301 :
2302 : /* #i38709# Decide which rotation reference mode to use. If any outer
2303 : border line of the cell is set (either explicitly or via cell style),
2304 : and the cell contents are rotated, set rotation reference to bottom of
2305 : cell. This causes the borders to be painted rotated with the text. */
2306 128 : if( const Alignment* pAlignment = maModel.mbAlignUsed ? &maAlignment : (pStyleXf ? &pStyleXf->maAlignment : 0) )
2307 : {
2308 123 : SvxRotateMode eRotateMode = SVX_ROTATE_MODE_STANDARD;
2309 123 : sal_Int32 nBorderId = maModel.mbBorderUsed ? maModel.mnBorderId : (pStyleXf ? pStyleXf->maModel.mnBorderId : -1);
2310 123 : if( const Border* pBorder = rStyles.getBorder( nBorderId ).get() )
2311 : {
2312 123 : if( (pAlignment->getApiData().mnRotation != 0) && pBorder->getApiData().hasAnyOuterBorder() )
2313 : {
2314 0 : meRotationRef = ::com::sun::star::table::CellVertJustify2::BOTTOM;
2315 0 : eRotateMode = SVX_ROTATE_MODE_BOTTOM;
2316 : }
2317 : }
2318 123 : ScfTools::PutItem( rItemSet, SvxRotateModeItem( eRotateMode, ATTR_ROTATE_MODE ), bSkipPoolDefs );
2319 : }
2320 :
2321 128 : return *mpPattern;
2322 : }
2323 :
2324 58 : Dxf::Dxf( const WorkbookHelper& rHelper ) :
2325 58 : WorkbookHelper( rHelper )
2326 : {
2327 58 : }
2328 :
2329 8 : FontRef Dxf::createFont( bool bAlwaysNew )
2330 : {
2331 8 : if( bAlwaysNew || !mxFont )
2332 8 : mxFont.reset( new Font( *this, true ) );
2333 8 : return mxFont;
2334 : }
2335 :
2336 0 : BorderRef Dxf::createBorder( bool bAlwaysNew )
2337 : {
2338 0 : if( bAlwaysNew || !mxBorder )
2339 0 : mxBorder.reset( new Border( *this, true ) );
2340 0 : return mxBorder;
2341 : }
2342 :
2343 0 : FillRef Dxf::createFill( bool bAlwaysNew )
2344 : {
2345 0 : if( bAlwaysNew || !mxFill )
2346 0 : mxFill.reset( new Fill( *this, true ) );
2347 0 : return mxFill;
2348 : }
2349 :
2350 58 : void Dxf::importNumFmt( const AttributeList& rAttribs )
2351 : {
2352 : // don't propagate number formats defined in Dxf entries
2353 : // they can have the same id ( but different format codes ) as those
2354 : // defined globally earlier. We discard the id defined in XML_numFmtId
2355 : // and generate one ourselves ( this assumes that the normal numberformat
2356 : // import has already taken place )
2357 58 : sal_Int32 nNumFmtId = getStyles().nextFreeNumFmtId();
2358 58 : OUString aFmtCode = rAttribs.getXString( XML_formatCode, OUString() );
2359 58 : mxNumFmt = getStyles().createNumFmt( nNumFmtId, aFmtCode );
2360 58 : }
2361 :
2362 0 : void Dxf::importDxf( SequenceInputStream& rStrm )
2363 : {
2364 0 : sal_Int32 nNumFmtId = -1;
2365 0 : OUString aFmtCode;
2366 : sal_uInt16 nRecCount;
2367 0 : rStrm.skip( 4 ); // flags
2368 0 : rStrm >> nRecCount;
2369 0 : for( sal_uInt16 nRec = 0; !rStrm.isEof() && (nRec < nRecCount); ++nRec )
2370 : {
2371 : sal_uInt16 nSubRecId, nSubRecSize;
2372 0 : sal_Int64 nRecEnd = rStrm.tell();
2373 0 : rStrm >> nSubRecId >> nSubRecSize;
2374 0 : nRecEnd += nSubRecSize;
2375 0 : switch( nSubRecId )
2376 : {
2377 0 : case BIFF12_DXF_FILL_PATTERN: createFill( false )->importDxfPattern( rStrm ); break;
2378 0 : case BIFF12_DXF_FILL_FGCOLOR: createFill( false )->importDxfFgColor( rStrm ); break;
2379 0 : case BIFF12_DXF_FILL_BGCOLOR: createFill( false )->importDxfBgColor( rStrm ); break;
2380 0 : case BIFF12_DXF_FILL_GRADIENT: createFill( false )->importDxfGradient( rStrm ); break;
2381 0 : case BIFF12_DXF_FILL_STOP: createFill( false )->importDxfStop( rStrm ); break;
2382 0 : case BIFF12_DXF_FONT_COLOR: createFont( false )->importDxfColor( rStrm ); break;
2383 0 : case BIFF12_DXF_BORDER_TOP: createBorder( false )->importDxfBorder( XLS_TOKEN( top ), rStrm ); break;
2384 0 : case BIFF12_DXF_BORDER_BOTTOM: createBorder( false )->importDxfBorder( XLS_TOKEN( bottom ), rStrm ); break;
2385 0 : case BIFF12_DXF_BORDER_LEFT: createBorder( false )->importDxfBorder( XLS_TOKEN( left ), rStrm ); break;
2386 0 : case BIFF12_DXF_BORDER_RIGHT: createBorder( false )->importDxfBorder( XLS_TOKEN( right ), rStrm ); break;
2387 0 : case BIFF12_DXF_FONT_NAME: createFont( false )->importDxfName( rStrm ); break;
2388 0 : case BIFF12_DXF_FONT_WEIGHT: createFont( false )->importDxfWeight( rStrm ); break;
2389 0 : case BIFF12_DXF_FONT_UNDERLINE: createFont( false )->importDxfUnderline( rStrm ); break;
2390 0 : case BIFF12_DXF_FONT_ESCAPEMENT: createFont( false )->importDxfEscapement( rStrm ); break;
2391 0 : case BIFF12_DXF_FONT_ITALIC: createFont( false )->importDxfFlag( XML_i, rStrm ); break;
2392 0 : case BIFF12_DXF_FONT_STRIKE: createFont( false )->importDxfFlag( XML_strike, rStrm ); break;
2393 0 : case BIFF12_DXF_FONT_OUTLINE: createFont( false )->importDxfFlag( XML_outline, rStrm ); break;
2394 0 : case BIFF12_DXF_FONT_SHADOW: createFont( false )->importDxfFlag( XML_shadow, rStrm ); break;
2395 0 : case BIFF12_DXF_FONT_HEIGHT: createFont( false )->importDxfHeight( rStrm ); break;
2396 0 : case BIFF12_DXF_FONT_SCHEME: createFont( false )->importDxfScheme( rStrm ); break;
2397 0 : case BIFF12_DXF_NUMFMT_CODE: aFmtCode = BiffHelper::readString( rStrm, false ); break;
2398 0 : case BIFF12_DXF_NUMFMT_ID: nNumFmtId = rStrm.readuInt16(); break;
2399 : }
2400 0 : rStrm.seek( nRecEnd );
2401 : }
2402 : OSL_ENSURE( !rStrm.isEof() && (rStrm.getRemaining() == 0), "Dxf::importDxf - unexpected remaining data" );
2403 0 : mxNumFmt = getStyles().createNumFmt( nNumFmtId, aFmtCode );
2404 0 : }
2405 :
2406 58 : void Dxf::finalizeImport()
2407 : {
2408 58 : if( mxFont.get() )
2409 8 : mxFont->finalizeImport();
2410 58 : bool bRTL = false;
2411 : // number format already finalized by the number formats buffer
2412 58 : if( mxAlignment.get() )
2413 : {
2414 0 : mxAlignment->finalizeImport();
2415 : // how do we detect RTL when text dir is OOX_XF_CONTEXT? ( seems you
2416 : // would need access to the cell content, which we don't here )
2417 0 : if ( mxAlignment->getModel().mnTextDir == OOX_XF_TEXTDIR_RTL )
2418 0 : bRTL = true;
2419 : }
2420 58 : if( mxProtection.get() )
2421 0 : mxProtection->finalizeImport();
2422 58 : if( mxBorder.get() )
2423 : {
2424 0 : mxBorder->finalizeImport( bRTL );
2425 : }
2426 58 : if( mxFill.get() )
2427 0 : mxFill->finalizeImport();
2428 58 : }
2429 :
2430 24 : void Dxf::fillToItemSet( SfxItemSet& rSet ) const
2431 : {
2432 24 : if (mxFont)
2433 8 : mxFont->fillToItemSet(rSet, FONT_PROPTYPE_CELL);
2434 24 : if (mxNumFmt)
2435 24 : mxNumFmt->fillToItemSet(rSet);
2436 24 : if (mxAlignment)
2437 0 : mxAlignment->fillToItemSet(rSet);
2438 24 : if (mxProtection)
2439 0 : mxProtection->fillToItemSet(rSet);
2440 24 : if (mxBorder)
2441 0 : mxBorder->fillToItemSet(rSet);
2442 24 : if (mxFill)
2443 0 : mxFill->fillToItemSet(rSet);
2444 24 : }
2445 :
2446 : namespace {
2447 :
2448 : const sal_Char* const spcStyleNamePrefix = "Excel Built-in ";
2449 : const sal_Char* const sppcStyleNames[] =
2450 : {
2451 : "Normal",
2452 : "RowLevel_", // outline level will be appended
2453 : "ColLevel_", // outline level will be appended
2454 : "Comma",
2455 : "Currency",
2456 : "Percent",
2457 : "Comma [0]", // new in BIFF4
2458 : "Currency [0]",
2459 : "Hyperlink", // new in BIFF8
2460 : "Followed Hyperlink",
2461 : "Note", // new in OOX
2462 : "Warning Text",
2463 : 0,
2464 : 0,
2465 : 0,
2466 : "Title",
2467 : "Heading 1",
2468 : "Heading 2",
2469 : "Heading 3",
2470 : "Heading 4",
2471 : "Input",
2472 : "Output",
2473 : "Calculation",
2474 : "Check Cell",
2475 : "Linked Cell",
2476 : "Total",
2477 : "Good",
2478 : "Bad",
2479 : "Neutral",
2480 : "Accent1",
2481 : "20% - Accent1",
2482 : "40% - Accent1",
2483 : "60% - Accent1",
2484 : "Accent2",
2485 : "20% - Accent2",
2486 : "40% - Accent2",
2487 : "60% - Accent2",
2488 : "Accent3",
2489 : "20% - Accent3",
2490 : "40% - Accent3",
2491 : "60% - Accent3",
2492 : "Accent4",
2493 : "20% - Accent4",
2494 : "40% - Accent4",
2495 : "60% - Accent4",
2496 : "Accent5",
2497 : "20% - Accent5",
2498 : "40% - Accent5",
2499 : "60% - Accent5",
2500 : "Accent6",
2501 : "20% - Accent6",
2502 : "40% - Accent6",
2503 : "60% - Accent6",
2504 : "Explanatory Text"
2505 : };
2506 : const sal_Int32 snStyleNamesCount = static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( sppcStyleNames ) );
2507 :
2508 116 : OUString lclGetBuiltinStyleName( sal_Int32 nBuiltinId, const OUString& rName, sal_Int32 nLevel = 0 )
2509 : {
2510 : OSL_ENSURE( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount), "lclGetBuiltinStyleName - unknown built-in style" );
2511 116 : OUStringBuffer aStyleName;
2512 116 : aStyleName.appendAscii( spcStyleNamePrefix );
2513 116 : if( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount) && (sppcStyleNames[ nBuiltinId ] != 0) )
2514 116 : aStyleName.appendAscii( sppcStyleNames[ nBuiltinId ] );
2515 0 : else if( !rName.isEmpty() )
2516 0 : aStyleName.append( rName );
2517 : else
2518 0 : aStyleName.append( nBuiltinId );
2519 116 : if( (nBuiltinId == OOX_STYLE_ROWLEVEL) || (nBuiltinId == OOX_STYLE_COLLEVEL) )
2520 0 : aStyleName.append( nLevel );
2521 116 : return aStyleName.makeStringAndClear();
2522 : }
2523 :
2524 129 : OUString lclCreateStyleName( const CellStyleModel& rModel )
2525 : {
2526 129 : return rModel.mbBuiltin ? lclGetBuiltinStyleName( rModel.mnBuiltinId, rModel.maName, rModel.mnLevel ) : rModel.maName;
2527 : }
2528 :
2529 : } // namespace
2530 :
2531 168 : CellStyleModel::CellStyleModel() :
2532 : mnXfId( -1 ),
2533 : mnBuiltinId( -1 ),
2534 : mnLevel( 0 ),
2535 : mbBuiltin( false ),
2536 : mbCustom( false ),
2537 168 : mbHidden( false )
2538 : {
2539 168 : }
2540 :
2541 293 : bool CellStyleModel::isBuiltin() const
2542 : {
2543 293 : return mbBuiltin && (mnBuiltinId >= 0);
2544 : }
2545 :
2546 882 : bool CellStyleModel::isDefaultStyle() const
2547 : {
2548 882 : return mbBuiltin && (mnBuiltinId == OOX_STYLE_NORMAL);
2549 : }
2550 :
2551 168 : CellStyle::CellStyle( const WorkbookHelper& rHelper ) :
2552 : WorkbookHelper( rHelper ),
2553 : mbCreated( false ),
2554 168 : mpStyleSheet( NULL )
2555 : {
2556 168 : }
2557 :
2558 168 : void CellStyle::importCellStyle( const AttributeList& rAttribs )
2559 : {
2560 168 : maModel.maName = rAttribs.getXString( XML_name, OUString() );
2561 168 : maModel.mnXfId = rAttribs.getInteger( XML_xfId, -1 );
2562 168 : maModel.mnBuiltinId = rAttribs.getInteger( XML_builtinId, -1 );
2563 168 : maModel.mnLevel = rAttribs.getInteger( XML_iLevel, 0 );
2564 168 : maModel.mbBuiltin = rAttribs.hasAttribute( XML_builtinId );
2565 168 : maModel.mbCustom = rAttribs.getBool( XML_customBuiltin, false );
2566 168 : maModel.mbHidden = rAttribs.getBool( XML_hidden, false );
2567 168 : }
2568 :
2569 0 : void CellStyle::importCellStyle( SequenceInputStream& rStrm )
2570 : {
2571 : sal_uInt16 nFlags;
2572 0 : rStrm >> maModel.mnXfId >> nFlags;
2573 0 : maModel.mnBuiltinId = rStrm.readInt8();
2574 0 : maModel.mnLevel = rStrm.readInt8();
2575 0 : rStrm >> maModel.maName;
2576 0 : maModel.mbBuiltin = getFlag( nFlags, BIFF12_CELLSTYLE_BUILTIN );
2577 0 : maModel.mbCustom = getFlag( nFlags, BIFF12_CELLSTYLE_CUSTOM );
2578 0 : maModel.mbHidden = getFlag( nFlags, BIFF12_CELLSTYLE_HIDDEN );
2579 0 : }
2580 :
2581 556 : void CellStyle::createCellStyle()
2582 : {
2583 :
2584 : // #i1624# #i1768# ignore unnamed user styles
2585 556 : bool bDefStyle = maModel.isDefaultStyle();
2586 556 : if( !mbCreated )
2587 : {
2588 556 : if ( bDefStyle && maFinalName.isEmpty() )
2589 43 : maFinalName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
2590 556 : mbCreated = maFinalName.isEmpty();
2591 : }
2592 :
2593 556 : if( !mbCreated && !mpStyleSheet )
2594 : {
2595 53 : bool bCreatePattern = false;
2596 53 : Xf* pXF = getStyles().getStyleXf( maModel.mnXfId ).get();
2597 53 : ::ScDocument& rDoc = getScDocument();
2598 :
2599 53 : if( bDefStyle )
2600 : {
2601 : // use existing "Default" style sheet
2602 43 : mpStyleSheet = static_cast< ScStyleSheet* >( static_cast< ScStyleSheetPool* >( rDoc.GetStyleSheetPool() )->Find(
2603 43 : ScGlobal::GetRscString( STR_STYLENAME_STANDARD ), SFX_STYLE_FAMILY_PARA ) );
2604 : OSL_ENSURE( mpStyleSheet, "CellStyle::createStyle - Default style not found" );
2605 43 : bCreatePattern = true;
2606 : }
2607 : else
2608 : {
2609 10 : mpStyleSheet = static_cast< ScStyleSheet* >( static_cast< ScStyleSheetPool* >( rDoc.GetStyleSheetPool() )->Find( maFinalName, SFX_STYLE_FAMILY_PARA ) );
2610 10 : if( !mpStyleSheet )
2611 : {
2612 10 : mpStyleSheet = &static_cast< ScStyleSheet& >( rDoc.GetStyleSheetPool()->Make( maFinalName, SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_USERDEF ) );
2613 10 : bCreatePattern = true;
2614 : }
2615 : }
2616 :
2617 : // bDefStyle==true omits default pool items in CreatePattern()
2618 53 : if( bCreatePattern && mpStyleSheet && pXF )
2619 53 : mpStyleSheet->GetItemSet().Put( pXF->createPattern( bDefStyle ).GetItemSet() );
2620 : }
2621 556 : }
2622 :
2623 125 : void CellStyle::finalizeImport( const OUString& rFinalName )
2624 : {
2625 125 : maFinalName = rFinalName;
2626 125 : if( !maModel.isBuiltin() || maModel.mbCustom )
2627 10 : createCellStyle();
2628 125 : }
2629 :
2630 44 : CellStyleBuffer::CellStyleBuffer( const WorkbookHelper& rHelper ) :
2631 44 : WorkbookHelper( rHelper )
2632 : {
2633 44 : }
2634 :
2635 168 : CellStyleRef CellStyleBuffer::importCellStyle( const AttributeList& rAttribs )
2636 : {
2637 168 : CellStyleRef xCellStyle( new CellStyle( *this ) );
2638 168 : xCellStyle->importCellStyle( rAttribs );
2639 168 : insertCellStyle( xCellStyle );
2640 168 : return xCellStyle;
2641 : }
2642 :
2643 0 : CellStyleRef CellStyleBuffer::importCellStyle( SequenceInputStream& rStrm )
2644 : {
2645 0 : CellStyleRef xCellStyle( new CellStyle( *this ) );
2646 0 : xCellStyle->importCellStyle( rStrm );
2647 0 : insertCellStyle( xCellStyle );
2648 0 : return xCellStyle;
2649 : }
2650 :
2651 44 : void CellStyleBuffer::finalizeImport()
2652 : {
2653 : // calculate final names of all styles
2654 : typedef RefMap< OUString, CellStyle, IgnoreCaseCompare > CellStyleNameMap;
2655 44 : CellStyleNameMap aCellStyles;
2656 88 : CellStyleVector aConflictNameStyles;
2657 :
2658 : /* First, reserve style names that are built-in in Calc. This causes that
2659 : imported cell styles get different unused names and thus do not try to
2660 : overwrite these built-in styles. For BIFF4 workbooks (which contain a
2661 : separate list of cell styles per sheet), reserve all existing styles if
2662 : current sheet is not the first sheet (this styles buffer will be
2663 : constructed again for every new sheet). This will create unique names
2664 : for styles in different sheets with the same name. Assuming that the
2665 : BIFF4W import filter is never used to import from clipboard... */
2666 44 : bool bReserveAll = (getFilterType() == FILTER_BIFF) && (getBiff() == BIFF4) && isWorkbookFile() && (getCurrentSheetIndex() > 0);
2667 : try
2668 : {
2669 : // unfortunately, com.sun.star.style.StyleFamily does not implement XEnumerationAccess...
2670 44 : Reference< XIndexAccess > xStyleFamilyIA( getStyleFamily( false ), UNO_QUERY_THROW );
2671 264 : for( sal_Int32 nIndex = 0, nCount = xStyleFamilyIA->getCount(); nIndex < nCount; ++nIndex )
2672 : {
2673 220 : Reference< XStyle > xStyle( xStyleFamilyIA->getByIndex( nIndex ), UNO_QUERY_THROW );
2674 220 : if( bReserveAll || !xStyle->isUserDefined() )
2675 : {
2676 : // create an empty entry by using ::std::map<>::operator[]
2677 220 : aCellStyles[ xStyle->getName() ];
2678 : }
2679 264 : }
2680 : }
2681 0 : catch( Exception& )
2682 : {
2683 : }
2684 :
2685 : /* Calculate names of built-in styles. Store styles with reserved names
2686 : in the aConflictNameStyles list. */
2687 202 : for( CellStyleVector::iterator aIt = maBuiltinStyles.begin(), aEnd = maBuiltinStyles.end(); aIt != aEnd; ++aIt )
2688 : {
2689 158 : const CellStyleModel& rModel = (*aIt)->getModel();
2690 158 : if (rModel.isDefaultStyle())
2691 43 : continue;
2692 :
2693 115 : OUString aStyleName = lclCreateStyleName( rModel );
2694 : /* If a builtin style entry already exists, and we do not reserve all
2695 : existing styles, we just stick with the last definition and ignore
2696 : the preceding ones. */
2697 115 : if( bReserveAll && (aCellStyles.count( aStyleName ) > 0) )
2698 0 : aConflictNameStyles.push_back( *aIt );
2699 : else
2700 115 : aCellStyles[ aStyleName ] = *aIt;
2701 115 : }
2702 :
2703 : /* Calculate names of user defined styles. Store styles with reserved
2704 : names in the aConflictNameStyles list. */
2705 54 : for( CellStyleVector::iterator aIt = maUserStyles.begin(), aEnd = maUserStyles.end(); aIt != aEnd; ++aIt )
2706 : {
2707 10 : const CellStyleModel& rModel = (*aIt)->getModel();
2708 10 : OUString aStyleName = lclCreateStyleName( rModel );
2709 : // #i1624# #i1768# ignore unnamed user styles
2710 10 : if( aStyleName.getLength() > 0 )
2711 : {
2712 10 : if( aCellStyles.count( aStyleName ) > 0 )
2713 4 : aConflictNameStyles.push_back( *aIt );
2714 : else
2715 6 : aCellStyles[ aStyleName ] = *aIt;
2716 : }
2717 10 : }
2718 :
2719 : // find unused names for all styles with conflicting names
2720 48 : for( CellStyleVector::iterator aIt = aConflictNameStyles.begin(), aEnd = aConflictNameStyles.end(); aIt != aEnd; ++aIt )
2721 : {
2722 4 : const CellStyleModel& rModel = (*aIt)->getModel();
2723 4 : OUString aStyleName = lclCreateStyleName( rModel );
2724 8 : OUString aUnusedName;
2725 4 : sal_Int32 nIndex = 0;
2726 4 : do
2727 : {
2728 4 : aUnusedName = OUStringBuffer( aStyleName ).append( ' ' ).append( ++nIndex ).makeStringAndClear();
2729 : }
2730 4 : while( aCellStyles.count( aUnusedName ) > 0 );
2731 4 : aCellStyles[ aUnusedName ] = *aIt;
2732 4 : }
2733 :
2734 : // set final names and create user-defined and modified built-in cell styles
2735 88 : aCellStyles.forEachMemWithKey( &CellStyle::finalizeImport );
2736 44 : }
2737 :
2738 100 : sal_Int32 CellStyleBuffer::getDefaultXfId() const
2739 : {
2740 100 : return mxDefStyle.get() ? mxDefStyle->getModel().mnXfId : -1;
2741 : }
2742 :
2743 85 : OUString CellStyleBuffer::getDefaultStyleName() const
2744 : {
2745 85 : return createCellStyle( mxDefStyle );
2746 : }
2747 :
2748 462 : OUString CellStyleBuffer::createCellStyle( sal_Int32 nXfId ) const
2749 : {
2750 462 : return createCellStyle( maStylesByXf.get( nXfId ) );
2751 : }
2752 :
2753 400 : ::ScStyleSheet* CellStyleBuffer::getCellStyleSheet( sal_Int32 nXfId ) const
2754 : {
2755 400 : return getCellStyleSheet( maStylesByXf.get( nXfId ) );
2756 : }
2757 :
2758 : // private --------------------------------------------------------------------
2759 :
2760 168 : void CellStyleBuffer::insertCellStyle( CellStyleRef xCellStyle )
2761 : {
2762 168 : const CellStyleModel& rModel = xCellStyle->getModel();
2763 168 : if( rModel.mnXfId >= 0 )
2764 : {
2765 : // insert into the built-in map or user defined map
2766 168 : (rModel.isBuiltin() ? maBuiltinStyles : maUserStyles).push_back( xCellStyle );
2767 :
2768 : // insert into the XF identifier map
2769 : OSL_ENSURE( maStylesByXf.count( rModel.mnXfId ) == 0, "CellStyleBuffer::insertCellStyle - multiple styles with equal XF identifier" );
2770 168 : maStylesByXf[ rModel.mnXfId ] = xCellStyle;
2771 :
2772 : // remember default cell style
2773 168 : if( rModel.isDefaultStyle() )
2774 43 : mxDefStyle = xCellStyle;
2775 : }
2776 168 : }
2777 :
2778 400 : ::ScStyleSheet* CellStyleBuffer::getCellStyleSheet( const CellStyleRef& rxCellStyle ) const
2779 : {
2780 400 : ::ScStyleSheet* pStyleSheet = NULL;
2781 400 : if ( rxCellStyle.get() )
2782 400 : pStyleSheet = rxCellStyle->getStyleSheet();
2783 400 : return pStyleSheet;
2784 : }
2785 :
2786 547 : OUString CellStyleBuffer::createCellStyle( const CellStyleRef& rxCellStyle ) const
2787 : {
2788 547 : if( rxCellStyle.get() )
2789 : {
2790 546 : rxCellStyle->createCellStyle();
2791 546 : const OUString& rStyleName = rxCellStyle->getFinalStyleName();
2792 546 : if( !rStyleName.isEmpty() )
2793 546 : return rStyleName;
2794 : }
2795 : // on error: fallback to default style
2796 1 : return lclGetBuiltinStyleName( OOX_STYLE_NORMAL, OUString() );
2797 : }
2798 :
2799 0 : AutoFormatModel::AutoFormatModel() :
2800 : mnAutoFormatId( 0 ),
2801 : mbApplyNumFmt( false ),
2802 : mbApplyFont( false ),
2803 : mbApplyAlignment( false ),
2804 : mbApplyBorder( false ),
2805 : mbApplyFill( false ),
2806 0 : mbApplyProtection( false )
2807 : {
2808 0 : }
2809 :
2810 44 : StylesBuffer::StylesBuffer( const WorkbookHelper& rHelper ) :
2811 : WorkbookHelper( rHelper ),
2812 : maPalette( rHelper ),
2813 : maNumFmts( rHelper ),
2814 44 : maCellStyles( rHelper )
2815 : {
2816 44 : }
2817 :
2818 131 : FontRef StylesBuffer::createFont( sal_Int32* opnFontId )
2819 : {
2820 131 : if( opnFontId ) *opnFontId = static_cast< sal_Int32 >( maFonts.size() );
2821 131 : FontRef xFont( new Font( *this, false ) );
2822 131 : maFonts.push_back( xFont );
2823 131 : return xFont;
2824 : }
2825 :
2826 58 : NumberFormatRef StylesBuffer::createNumFmt( sal_Int32 nNumFmtId, const OUString& rFmtCode )
2827 : {
2828 58 : return maNumFmts.createNumFmt( nNumFmtId, rFmtCode );
2829 : }
2830 :
2831 58 : sal_Int32 StylesBuffer::nextFreeNumFmtId()
2832 : {
2833 58 : return maNumFmts.nextFreeId();
2834 : }
2835 :
2836 70 : BorderRef StylesBuffer::createBorder( sal_Int32* opnBorderId )
2837 : {
2838 70 : if( opnBorderId ) *opnBorderId = static_cast< sal_Int32 >( maBorders.size() );
2839 70 : BorderRef xBorder( new Border( *this, false ) );
2840 70 : maBorders.push_back( xBorder );
2841 70 : return xBorder;
2842 : }
2843 :
2844 90 : FillRef StylesBuffer::createFill( sal_Int32* opnFillId )
2845 : {
2846 90 : if( opnFillId ) *opnFillId = static_cast< sal_Int32 >( maFills.size() );
2847 90 : FillRef xFill( new Fill( *this, false ) );
2848 90 : maFills.push_back( xFill );
2849 90 : return xFill;
2850 : }
2851 :
2852 99 : XfRef StylesBuffer::createCellXf( sal_Int32* opnXfId )
2853 : {
2854 99 : if( opnXfId ) *opnXfId = static_cast< sal_Int32 >( maCellXfs.size() );
2855 99 : XfRef xXf( new Xf( *this ) );
2856 99 : maCellXfs.push_back( xXf );
2857 99 : return xXf;
2858 : }
2859 :
2860 504 : XfRef StylesBuffer::createStyleXf( sal_Int32* opnXfId )
2861 : {
2862 504 : if( opnXfId ) *opnXfId = static_cast< sal_Int32 >( maStyleXfs.size() );
2863 504 : XfRef xXf( new Xf( *this ) );
2864 504 : maStyleXfs.push_back( xXf );
2865 504 : return xXf;
2866 : }
2867 :
2868 58 : DxfRef StylesBuffer::createDxf( sal_Int32* opnDxfId )
2869 : {
2870 58 : if( opnDxfId ) *opnDxfId = static_cast< sal_Int32 >( maDxfs.size() );
2871 58 : DxfRef xDxf( new Dxf( *this ) );
2872 58 : maDxfs.push_back( xDxf );
2873 58 : return xDxf;
2874 : }
2875 :
2876 456 : void StylesBuffer::importPaletteColor( const AttributeList& rAttribs )
2877 : {
2878 456 : maPalette.importPaletteColor( rAttribs );
2879 456 : }
2880 :
2881 30 : NumberFormatRef StylesBuffer::importNumFmt( const AttributeList& rAttribs )
2882 : {
2883 30 : return maNumFmts.importNumFmt( rAttribs );
2884 : }
2885 :
2886 168 : CellStyleRef StylesBuffer::importCellStyle( const AttributeList& rAttribs )
2887 : {
2888 168 : return maCellStyles.importCellStyle( rAttribs );
2889 : }
2890 :
2891 0 : void StylesBuffer::importPaletteColor( SequenceInputStream& rStrm )
2892 : {
2893 0 : maPalette.importPaletteColor( rStrm );
2894 0 : }
2895 :
2896 0 : void StylesBuffer::importNumFmt( SequenceInputStream& rStrm )
2897 : {
2898 0 : maNumFmts.importNumFmt( rStrm );
2899 0 : }
2900 :
2901 0 : void StylesBuffer::importCellStyle( SequenceInputStream& rStrm )
2902 : {
2903 0 : maCellStyles.importCellStyle( rStrm );
2904 0 : }
2905 :
2906 44 : void StylesBuffer::finalizeImport()
2907 : {
2908 : // fonts first, are needed to finalize unit converter and XFs below
2909 44 : maFonts.forEachMem( &Font::finalizeImport );
2910 : // finalize unit coefficients after default font is known
2911 44 : getUnitConverter().finalizeImport();
2912 : // number formats
2913 44 : maNumFmts.finalizeImport();
2914 : // borders and fills
2915 : // is there a document wide RTL setting that we
2916 : // would/could need to pass to finalizeImport here ?
2917 44 : maBorders.forEachMem( &Border::finalizeImport, false );
2918 44 : maFills.forEachMem( &Fill::finalizeImport );
2919 : // style XFs and cell XFs
2920 44 : maStyleXfs.forEachMem( &Xf::finalizeImport );
2921 44 : maCellXfs.forEachMem( &Xf::finalizeImport );
2922 : // built-in and user defined cell styles
2923 44 : maCellStyles.finalizeImport();
2924 : // differential formatting (for conditional formatting)
2925 44 : maDxfs.forEachMem( &Dxf::finalizeImport );
2926 44 : }
2927 :
2928 371 : sal_Int32 StylesBuffer::getPaletteColor( sal_Int32 nPaletteIdx ) const
2929 : {
2930 371 : return maPalette.getColor( nPaletteIdx );
2931 : }
2932 :
2933 296 : FontRef StylesBuffer::getFont( sal_Int32 nFontId ) const
2934 : {
2935 296 : return maFonts.get( nFontId );
2936 : }
2937 :
2938 123 : BorderRef StylesBuffer::getBorder( sal_Int32 nBorderId ) const
2939 : {
2940 123 : return maBorders.get( nBorderId );
2941 : }
2942 :
2943 2355 : XfRef StylesBuffer::getCellXf( sal_Int32 nXfId ) const
2944 : {
2945 2355 : return maCellXfs.get( nXfId );
2946 : }
2947 :
2948 228 : XfRef StylesBuffer::getStyleXf( sal_Int32 nXfId ) const
2949 : {
2950 228 : return maStyleXfs.get( nXfId );
2951 : }
2952 :
2953 275 : FontRef StylesBuffer::getFontFromCellXf( sal_Int32 nXfId ) const
2954 : {
2955 275 : FontRef xFont;
2956 275 : if( const Xf* pXf = getCellXf( nXfId ).get() )
2957 197 : xFont = pXf->getFont();
2958 275 : return xFont;
2959 : }
2960 :
2961 100 : FontRef StylesBuffer::getDefaultFont() const
2962 : {
2963 100 : FontRef xDefFont;
2964 100 : if( const Xf* pXf = getStyleXf( maCellStyles.getDefaultXfId() ).get() )
2965 99 : xDefFont = pXf->getFont();
2966 : // no font from styles - try first loaded font (e.g. BIFF2)
2967 100 : if( !xDefFont )
2968 1 : xDefFont = maFonts.get( 0 );
2969 : OSL_ENSURE( xDefFont.get(), "StylesBuffer::getDefaultFont - no default font found" );
2970 100 : return xDefFont;
2971 : }
2972 :
2973 56 : const FontModel& StylesBuffer::getDefaultFontModel() const
2974 : {
2975 56 : FontRef xDefFont = getDefaultFont();
2976 56 : return xDefFont.get() ? xDefFont->getModel() : getTheme().getDefaultFontModel();
2977 : }
2978 :
2979 42 : bool StylesBuffer::equalBorders( sal_Int32 nBorderId1, sal_Int32 nBorderId2 ) const
2980 : {
2981 42 : if( nBorderId1 == nBorderId2 )
2982 42 : return true;
2983 :
2984 0 : switch( getFilterType() )
2985 : {
2986 : case FILTER_OOXML:
2987 : // in OOXML, borders are assumed to be unique
2988 0 : return false;
2989 :
2990 : case FILTER_BIFF:
2991 : {
2992 : // in BIFF, a new border entry has been created for every XF
2993 0 : const Border* pBorder1 = maBorders.get( nBorderId1 ).get();
2994 0 : const Border* pBorder2 = maBorders.get( nBorderId2 ).get();
2995 0 : return pBorder1 && pBorder2 && (pBorder1->getApiData() == pBorder2->getApiData());
2996 : }
2997 :
2998 : case FILTER_UNKNOWN:
2999 0 : break;
3000 : }
3001 0 : return false;
3002 : }
3003 :
3004 73 : bool StylesBuffer::equalFills( sal_Int32 nFillId1, sal_Int32 nFillId2 ) const
3005 : {
3006 73 : if( nFillId1 == nFillId2 )
3007 73 : return true;
3008 :
3009 0 : switch( getFilterType() )
3010 : {
3011 : case FILTER_OOXML:
3012 : // in OOXML, fills are assumed to be unique
3013 0 : return false;
3014 :
3015 : case FILTER_BIFF:
3016 : {
3017 : // in BIFF, a new fill entry has been created for every XF
3018 0 : const Fill* pFill1 = maFills.get( nFillId1 ).get();
3019 0 : const Fill* pFill2 = maFills.get( nFillId2 ).get();
3020 0 : return pFill1 && pFill2 && (pFill1->getApiData() == pFill2->getApiData());
3021 : }
3022 :
3023 : case FILTER_UNKNOWN:
3024 0 : break;
3025 : }
3026 0 : return false;
3027 : }
3028 :
3029 85 : OUString StylesBuffer::getDefaultStyleName() const
3030 : {
3031 85 : return maCellStyles.getDefaultStyleName();
3032 : }
3033 :
3034 462 : OUString StylesBuffer::createCellStyle( sal_Int32 nXfId ) const
3035 : {
3036 462 : return maCellStyles.createCellStyle( nXfId );
3037 : }
3038 :
3039 400 : ::ScStyleSheet* StylesBuffer::getCellStyleSheet( sal_Int32 nXfId ) const
3040 : {
3041 400 : return maCellStyles.getCellStyleSheet( nXfId );
3042 : }
3043 :
3044 24 : OUString StylesBuffer::createDxfStyle( sal_Int32 nDxfId ) const
3045 : {
3046 24 : OUString& rStyleName = maDxfStyles[ nDxfId ];
3047 24 : if (!rStyleName.isEmpty())
3048 0 : return rStyleName;
3049 :
3050 24 : if (Dxf* pDxf = maDxfs.get(nDxfId).get())
3051 : {
3052 24 : rStyleName = OUStringBuffer("ConditionalStyle_").append(nDxfId + 1).makeStringAndClear();
3053 :
3054 : // Create a cell style. This may overwrite an existing style if
3055 : // one with the same name exists.
3056 : SfxItemSet& rStyleItemSet =
3057 : ScfTools::MakeCellStyleSheet(
3058 24 : *getScDocument().GetStyleSheetPool(), rStyleName, true).GetItemSet();
3059 :
3060 24 : pDxf->fillToItemSet(rStyleItemSet);
3061 : }
3062 :
3063 : // on error: fallback to default style
3064 24 : if (rStyleName.isEmpty())
3065 0 : rStyleName = maCellStyles.getDefaultStyleName();
3066 :
3067 24 : return rStyleName;
3068 : }
3069 :
3070 67 : void StylesBuffer::writeFontToItemSet( SfxItemSet& rItemSet, sal_Int32 nFontId, bool bSkipPoolDefs ) const
3071 : {
3072 67 : if( Font* pFont = maFonts.get( nFontId ).get() )
3073 67 : pFont->fillToItemSet( rItemSet, FONT_PROPTYPE_CELL, bSkipPoolDefs );
3074 67 : }
3075 :
3076 0 : void StylesBuffer::writeFontToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFontId ) const
3077 : {
3078 0 : if( Font* pFont = maFonts.get( nFontId ).get() )
3079 0 : pFont->writeToPropertyMap( rPropMap, FONT_PROPTYPE_CELL );
3080 0 : }
3081 :
3082 63 : void StylesBuffer::writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs ) const
3083 : {
3084 63 : maNumFmts.fillToItemSet( rItemSet, nNumFmtId, bSkipPoolDefs );
3085 63 : }
3086 :
3087 0 : void StylesBuffer::writeNumFmtToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const
3088 : {
3089 0 : maNumFmts.writeToPropertyMap( rPropMap, nNumFmtId );
3090 0 : }
3091 :
3092 81 : void StylesBuffer::writeBorderToItemSet( SfxItemSet& rItemSet, sal_Int32 nBorderId, bool bSkipPoolDefs ) const
3093 : {
3094 81 : if( Border* pBorder = maBorders.get( nBorderId ).get() )
3095 81 : pBorder->fillToItemSet( rItemSet, bSkipPoolDefs );
3096 81 : }
3097 :
3098 0 : void StylesBuffer::writeBorderToPropertyMap( PropertyMap& rPropMap, sal_Int32 nBorderId ) const
3099 : {
3100 0 : if( Border* pBorder = maBorders.get( nBorderId ).get() )
3101 0 : pBorder->writeToPropertyMap( rPropMap );
3102 0 : }
3103 :
3104 50 : void StylesBuffer::writeFillToItemSet( SfxItemSet& rItemSet, sal_Int32 nFillId, bool bSkipPoolDefs ) const
3105 : {
3106 50 : if( Fill* pFill = maFills.get( nFillId ).get() )
3107 50 : pFill->fillToItemSet( rItemSet, bSkipPoolDefs );
3108 50 : }
3109 :
3110 0 : void StylesBuffer::writeFillToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFillId ) const
3111 : {
3112 0 : if( Fill* pFill = maFills.get( nFillId ).get() )
3113 0 : pFill->writeToPropertyMap( rPropMap );
3114 0 : }
3115 :
3116 246 : bool operator==( const XfModel& rXfModel1, const XfModel& rXfModel2 )
3117 : {
3118 492 : return ( rXfModel1.mbCellXf == rXfModel2.mbCellXf &&
3119 492 : rXfModel1.mnStyleXfId == rXfModel2.mnStyleXfId &&
3120 463 : rXfModel1.mbFontUsed == rXfModel2.mbFontUsed &&
3121 410 : rXfModel1.mnFontId == rXfModel2.mnFontId &&
3122 380 : rXfModel1.mbNumFmtUsed == rXfModel2.mbNumFmtUsed &&
3123 373 : rXfModel1.mnNumFmtId == rXfModel2.mnNumFmtId &&
3124 371 : rXfModel1.mbAlignUsed == rXfModel2.mbAlignUsed &&
3125 355 : rXfModel1.mbBorderUsed == rXfModel2.mbBorderUsed &&
3126 171 : rXfModel1.mnBorderId == rXfModel2.mnBorderId &&
3127 2 : rXfModel1.mbAreaUsed == rXfModel2.mbAreaUsed &&
3128 247 : rXfModel1.mnFillId == rXfModel2.mnFillId &&
3129 246 : rXfModel1.mbProtUsed == rXfModel2.mbProtUsed );
3130 : }
3131 :
3132 246 : bool operator==( const Xf& rXf1, const Xf& rXf2 )
3133 : {
3134 246 : if ( rXf1.maModel == rXf2.maModel )
3135 : {
3136 0 : if ( rXf1.maModel.mbAlignUsed )
3137 : {
3138 0 : if ( !( rXf1.maAlignment.getApiData() == rXf2.maAlignment.getApiData() ) )
3139 0 : return false;
3140 : }
3141 0 : if ( rXf1.maModel.mbProtUsed )
3142 : {
3143 0 : if ( !( rXf1.maProtection.getApiData() == rXf2.maProtection.getApiData() ) )
3144 0 : return false;
3145 : }
3146 0 : return true;
3147 : }
3148 246 : return false;
3149 : }
3150 :
3151 89 : void StylesBuffer::writeCellXfToPropertySet( PropertySet& rPropSet, sal_Int32 nXfId ) const
3152 : {
3153 89 : if( Xf* pXf = maCellXfs.get( nXfId ).get() )
3154 62 : pXf->writeToPropertySet( rPropSet );
3155 89 : }
3156 :
3157 0 : bool StylesBuffer::hasBorder( sal_Int32 nBorderId ) const
3158 : {
3159 0 : Border* pBorder = maBorders.get( nBorderId ).get();
3160 0 : return pBorder && pBorder->hasBorder();
3161 : }
3162 :
3163 : } // namespace xls
3164 18 : } // namespace oox
3165 :
3166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|