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