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