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