1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "stylesbuffer.hxx"
22 #include <com/sun/star/awt/FontDescriptor.hpp>
23 #include <com/sun/star/awt/FontFamily.hpp>
24 #include <com/sun/star/awt/FontPitch.hpp>
25 #include <com/sun/star/awt/FontSlant.hpp>
26 #include <com/sun/star/awt/FontStrikeout.hpp>
27 #include <com/sun/star/awt/FontType.hpp>
28 #include <com/sun/star/awt/FontWeight.hpp>
29 #include <com/sun/star/awt/FontUnderline.hpp>
30 #include <com/sun/star/awt/XDevice.hpp>
31 #include <com/sun/star/awt/XFont2.hpp>
32 #include <com/sun/star/container/XIndexAccess.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/style/XStyle.hpp>
35 #include <com/sun/star/text/WritingMode2.hpp>
36 #include <com/sun/star/text/XText.hpp>
37 #include <com/sun/star/table/BorderLineStyle.hpp>
38 #include <com/sun/star/table/CellVertJustify2.hpp>
39 #include <com/sun/star/table/CellJustifyMethod.hpp>
40 #include <com/sun/star/table/TableBorder.hpp>
41 #include <editeng/justifyitem.hxx>
42 #include <editeng/frmdiritem.hxx>
43 #include <editeng/fontitem.hxx>
44 #include <editeng/postitem.hxx>
45 #include <editeng/fhgtitem.hxx>
46 #include <editeng/wghtitem.hxx>
47 #include <editeng/udlnitem.hxx>
48 #include <editeng/colritem.hxx>
49 #include <editeng/crossedoutitem.hxx>
50 #include <editeng/contouritem.hxx>
51 #include <editeng/escapementitem.hxx>
52 #include <editeng/shdditem.hxx>
53 #include <editeng/eeitem.hxx>
54 #include <editeng/boxitem.hxx>
55 #include <editeng/lineitem.hxx>
56 #include <editeng/brushitem.hxx>
57 #include <svx/rotmodit.hxx>
58 #include <tools/fontenum.hxx>
59 #include <toolkit/helper/vclunohelper.hxx>
60 #include <rtl/tencinfo.h>
61 #include <rtl/ustrbuf.hxx>
62 #include <oox/core/filterbase.hxx>
63 #include <oox/helper/attributelist.hxx>
64 #include <oox/helper/containerhelper.hxx>
65 #include <oox/helper/propertymap.hxx>
66 #include <oox/helper/propertyset.hxx>
67 #include "biffinputstream.hxx"
68 #include "condformatbuffer.hxx"
69 #include "excelhandlers.hxx"
70 #include "themebuffer.hxx"
71 #include "unitconverter.hxx"
72 #include "document.hxx"
73 #include "stlpool.hxx"
74 #include "docpool.hxx"
76 #include "scitems.hxx"
78 #include "globstr.hrc"
79 #include "xlconst.hxx"
80 #include <documentimport.hxx>
81 #include <numformat.hxx>
83 using ::com::sun::star::table::BorderLine2
;
87 using namespace com::sun::star
;
88 using namespace ::com::sun::star::awt
;
89 using namespace ::com::sun::star::container
;
90 using namespace ::com::sun::star::style
;
91 using namespace ::com::sun::star::table
;
92 using namespace ::com::sun::star::text
;
93 using namespace ::com::sun::star::uno
;
95 using ::oox::core::FilterBase
;
99 // OOXML constants ------------------------------------------------------------
101 // OOXML predefined color indexes (also used in BIFF3-BIFF8)
102 const sal_Int32 OOX_COLOR_USEROFFSET
= 0; /// First user defined color in palette (OOXML/BIFF12).
103 const sal_Int32 BIFF_COLOR_USEROFFSET
= 8; /// First user defined color in palette (BIFF3-BIFF8).
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;
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;
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;
122 // OOXML cell indentation
123 const sal_Int32 OOX_XF_INDENT_NONE
= 0;
125 // OOXML built-in cell styles (also used in BIFF)
126 const sal_Int32 OOX_STYLE_NORMAL
= 0; /// Default cell style.
127 const sal_Int32 OOX_STYLE_ROWLEVEL
= 1; /// RowLevel_x cell style.
128 const sal_Int32 OOX_STYLE_COLLEVEL
= 2; /// ColLevel_x cell style.
130 // BIFF12 constants -----------------------------------------------------------
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;
138 // BIFF12 diagonal borders
139 const sal_uInt8 BIFF12_BORDER_DIAG_TLBR
= 0x01; /// Top-left to bottom-right.
140 const sal_uInt8 BIFF12_BORDER_DIAG_BLTR
= 0x02; /// Bottom-left to top-right.
142 // BIFF12 gradient fill
143 const sal_Int32 BIFF12_FILL_GRADIENT
= 40;
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;
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;
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;
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;
189 // BIFF constants -------------------------------------------------------------
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;
198 const sal_uInt16 BIFF_FONTWEIGHT_BOLD
= 450;
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;
207 sal_Int32
lclReadRgbColor( BinaryInputStream
& rStrm
)
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
;
226 ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper
& rHelper
) :
227 GraphicHelper( rHelper
.getBaseFilter().getComponentContext(), rHelper
.getBaseFilter().getTargetFrame(), rHelper
.getBaseFilter().getStorage() ),
228 WorkbookHelper( rHelper
)
232 sal_Int32
ExcelGraphicHelper::getSchemeColor( sal_Int32 nToken
) const
234 if( getFilterType() == FILTER_OOXML
)
235 return getTheme().getColorByToken( nToken
);
236 return GraphicHelper::getSchemeColor( nToken
);
239 sal_Int32
ExcelGraphicHelper::getPaletteColor( sal_Int32 nPaletteIdx
) const
241 return getStyles().getPaletteColor( nPaletteIdx
);
244 void Color::setAuto()
246 clearTransformations();
247 setSchemeClr( XML_phClr
);
250 void Color::setRgb( sal_Int32 nRgbValue
, double fTint
)
252 clearTransformations();
253 setSrgbClr( nRgbValue
& 0xFFFFFF );
254 if( fTint
!= 0.0 ) addExcelTintTransformation( fTint
);
257 void Color::setTheme( sal_Int32 nThemeIdx
, double fTint
)
259 clearTransformations();
260 static const sal_Int32 spnColorTokens
[] = {
261 XML_lt1
, XML_dk1
, XML_lt2
, XML_dk2
, XML_accent1
, XML_accent2
,
262 XML_accent3
, XML_accent4
, XML_accent5
, XML_accent6
, XML_hlink
, XML_folHlink
};
263 setSchemeClr( STATIC_ARRAY_SELECT( spnColorTokens
, nThemeIdx
, XML_TOKEN_INVALID
) );
264 if( fTint
!= 0.0 ) addExcelTintTransformation( fTint
);
267 void Color::setIndexed( sal_Int32 nPaletteIdx
, double fTint
)
269 clearTransformations();
270 setPaletteClr( nPaletteIdx
);
271 if( fTint
!= 0.0 ) addExcelTintTransformation( fTint
);
274 void Color::importColor( const AttributeList
& rAttribs
)
276 if( rAttribs
.getBool( XML_auto
, false ) )
278 else if( rAttribs
.hasAttribute( XML_rgb
) )
279 setRgb( rAttribs
.getIntegerHex( XML_rgb
, API_RGB_TRANSPARENT
), rAttribs
.getDouble( XML_tint
, 0.0 ) );
280 else if( rAttribs
.hasAttribute( XML_theme
) )
281 setTheme( rAttribs
.getInteger( XML_theme
, -1 ), rAttribs
.getDouble( XML_tint
, 0.0 ) );
282 else if( rAttribs
.hasAttribute( XML_indexed
) )
283 setIndexed( rAttribs
.getInteger( XML_indexed
, -1 ), rAttribs
.getDouble( XML_tint
, 0.0 ) );
286 OSL_FAIL( "Color::importColor - unknown color type" );
291 void Color::importColor( SequenceInputStream
& rStrm
)
293 sal_uInt8 nFlags
, nIndex
;
295 nFlags
= rStrm
.readuChar();
296 nIndex
= rStrm
.readuChar();
297 nTint
= rStrm
.readInt16();
299 // scale tint from signed 16-bit to double range -1.0 ... 1.0
300 double fTint
= nTint
;
302 fTint
/= -SAL_MIN_INT16
;
304 fTint
/= SAL_MAX_INT16
;
306 switch( extractValue
< sal_uInt8
>( nFlags
, 1, 7 ) )
308 case BIFF12_COLOR_AUTO
:
312 case BIFF12_COLOR_INDEXED
:
313 setIndexed( nIndex
, fTint
);
316 case BIFF12_COLOR_RGB
:
317 setRgb( lclReadRgbColor( rStrm
), fTint
);
319 case BIFF12_COLOR_THEME
:
320 setTheme( nIndex
, fTint
);
324 OSL_FAIL( "Color::importColor - unknown color type" );
330 void Color::importColorId( SequenceInputStream
& rStrm
)
332 setIndexed( rStrm
.readInt32() );
335 SequenceInputStream
& operator>>( SequenceInputStream
& rStrm
, Color
& orColor
)
337 orColor
.importColor( rStrm
);
343 /** Standard EGA colors, bright. */
344 #define PALETTE_EGA_COLORS_LIGHT \
345 0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF
346 /** Standard EGA colors, dark. */
347 #define PALETTE_EGA_COLORS_DARK \
348 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080
350 /** Default color table for BIFF2. */
351 static const sal_Int32 spnDefColors2
[] =
353 /* 0 */ PALETTE_EGA_COLORS_LIGHT
356 /** Default color table for BIFF3/BIFF4. */
357 static const sal_Int32 spnDefColors3
[] =
359 /* 0 */ PALETTE_EGA_COLORS_LIGHT
,
360 /* 8 */ PALETTE_EGA_COLORS_LIGHT
,
361 /* 16 */ PALETTE_EGA_COLORS_DARK
364 /** Default color table for BIFF5. */
365 static const sal_Int32 spnDefColors5
[] =
367 /* 0 */ PALETTE_EGA_COLORS_LIGHT
,
368 /* 8 */ PALETTE_EGA_COLORS_LIGHT
,
369 /* 16 */ PALETTE_EGA_COLORS_DARK
,
370 /* 24 */ 0x8080FF, 0x802060, 0xFFFFC0, 0xA0E0E0, 0x600080, 0xFF8080, 0x0080C0, 0xC0C0FF,
371 /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
372 /* 40 */ 0x00CFFF, 0x69FFFF, 0xE0FFE0, 0xFFFF80, 0xA6CAF0, 0xDD9CB3, 0xB38FEE, 0xE3E3E3,
373 /* 48 */ 0x2A6FF9, 0x3FB8CD, 0x488436, 0x958C41, 0x8E5E42, 0xA0627A, 0x624FAC, 0x969696,
374 /* 56 */ 0x1D2FBE, 0x286676, 0x004500, 0x453E01, 0x6A2813, 0x85396A, 0x4A3285, 0x424242
377 /** Default color table for BIFF8/BIFF12/OOXML. */
378 static const sal_Int32 spnDefColors8
[] =
380 /* 0 */ PALETTE_EGA_COLORS_LIGHT
,
381 /* 8 */ PALETTE_EGA_COLORS_LIGHT
,
382 /* 16 */ PALETTE_EGA_COLORS_DARK
,
383 /* 24 */ 0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF,
384 /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
385 /* 40 */ 0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99,
386 /* 48 */ 0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696,
387 /* 56 */ 0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333
390 #undef PALETTE_EGA_COLORS_LIGHT
391 #undef PALETTE_EGA_COLORS_DARK
395 ColorPalette::ColorPalette( const WorkbookHelper
& rHelper
)
396 : WorkbookHelper(rHelper
)
400 switch( getFilterType() )
403 maColors
.insert( maColors
.begin(), spnDefColors8
, STATIC_ARRAY_END( spnDefColors8
) );
404 mnAppendIndex
= OOX_COLOR_USEROFFSET
;
409 case BIFF2
: maColors
.insert( maColors
.begin(), spnDefColors2
, STATIC_ARRAY_END( spnDefColors2
) ); break;
411 case BIFF4
: maColors
.insert( maColors
.begin(), spnDefColors3
, STATIC_ARRAY_END( spnDefColors3
) ); break;
412 case BIFF5
: maColors
.insert( maColors
.begin(), spnDefColors5
, STATIC_ARRAY_END( spnDefColors5
) ); break;
413 case BIFF8
: maColors
.insert( maColors
.begin(), spnDefColors8
, STATIC_ARRAY_END( spnDefColors8
) ); break;
414 case BIFF_UNKNOWN
: break;
416 mnAppendIndex
= BIFF_COLOR_USEROFFSET
;
418 case FILTER_UNKNOWN
: break;
422 void ColorPalette::importPaletteColor( const AttributeList
& rAttribs
)
424 appendColor( rAttribs
.getIntegerHex( XML_rgb
, API_RGB_WHITE
) );
427 void ColorPalette::importPaletteColor( SequenceInputStream
& rStrm
)
429 sal_Int32 nRgb
= lclReadRgbColor( rStrm
);
430 appendColor( nRgb
& 0xFFFFFF );
433 sal_Int32
ColorPalette::getColor( sal_Int32 nPaletteIdx
) const
435 sal_Int32 nColor
= API_RGB_TRANSPARENT
;
436 if( const sal_Int32
* pnPaletteColor
= ContainerHelper::getVectorElement( maColors
, nPaletteIdx
) )
438 nColor
= *pnPaletteColor
;
440 else switch( nPaletteIdx
)
442 case OOX_COLOR_WINDOWTEXT3
:
443 case OOX_COLOR_WINDOWTEXT
:
444 case OOX_COLOR_CHWINDOWTEXT
: nColor
= getBaseFilter().getGraphicHelper().getSystemColor( XML_windowText
); break;
445 case OOX_COLOR_WINDOWBACK3
:
446 case OOX_COLOR_WINDOWBACK
:
447 case OOX_COLOR_CHWINDOWBACK
: nColor
= getBaseFilter().getGraphicHelper().getSystemColor( XML_window
); break;
448 case OOX_COLOR_BUTTONBACK
: nColor
= getBaseFilter().getGraphicHelper().getSystemColor( XML_btnFace
); break;
449 case OOX_COLOR_CHBORDERAUTO
: nColor
= API_RGB_BLACK
; /* really always black? */ break;
450 case OOX_COLOR_NOTEBACK
: nColor
= getBaseFilter().getGraphicHelper().getSystemColor( XML_infoBk
); break;
451 case OOX_COLOR_NOTETEXT
: nColor
= getBaseFilter().getGraphicHelper().getSystemColor( XML_infoText
); break;
452 case OOX_COLOR_FONTAUTO
: nColor
= API_RGB_TRANSPARENT
; break;
453 default: OSL_FAIL( "ColorPalette::getColor - unknown color index" );
458 void ColorPalette::appendColor( sal_Int32 nRGBValue
)
460 if( mnAppendIndex
< maColors
.size() )
461 maColors
[ mnAppendIndex
] = nRGBValue
;
463 maColors
.push_back( nRGBValue
);
469 void lclSetFontName( ApiScriptFontName
& rFontName
, const FontDescriptor
& rFontDesc
, bool bHasGlyphs
)
473 rFontName
.maName
= rFontDesc
.Name
;
474 rFontName
.mnFamily
= rFontDesc
.Family
;
475 // API font descriptor contains rtl_TextEncoding constants
476 rFontName
.mnTextEnc
= rFontDesc
.CharSet
;
480 rFontName
= ApiScriptFontName();
486 FontModel::FontModel() :
487 mnScheme( XML_none
),
488 mnFamily( OOX_FONTFAMILY_NONE
),
489 mnCharSet( WINDOWS_CHARSET_DEFAULT
),
491 mnUnderline( XML_none
),
492 mnEscapement( XML_baseline
),
495 mbStrikeout( false ),
501 void FontModel::setBiff12Scheme( sal_uInt8 nScheme
)
503 static const sal_Int32 spnSchemes
[] = { XML_none
, XML_major
, XML_minor
};
504 mnScheme
= STATIC_ARRAY_SELECT( spnSchemes
, nScheme
, XML_none
);
507 void FontModel::setBiffHeight( sal_uInt16 nHeight
)
509 mfHeight
= nHeight
/ 20.0; // convert twips to points
512 void FontModel::setBiffWeight( sal_uInt16 nWeight
)
514 mbBold
= nWeight
>= BIFF_FONTWEIGHT_BOLD
;
517 void FontModel::setBiffUnderline( sal_uInt16 nUnderline
)
521 case BIFF_FONTUNDERL_NONE
: mnUnderline
= XML_none
; break;
522 case BIFF_FONTUNDERL_SINGLE
: mnUnderline
= XML_single
; break;
523 case BIFF_FONTUNDERL_DOUBLE
: mnUnderline
= XML_double
; break;
524 case BIFF_FONTUNDERL_SINGLE_ACC
: mnUnderline
= XML_singleAccounting
; break;
525 case BIFF_FONTUNDERL_DOUBLE_ACC
: mnUnderline
= XML_doubleAccounting
; break;
526 default: mnUnderline
= XML_none
;
530 void FontModel::setBiffEscapement( sal_uInt16 nEscapement
)
532 static const sal_Int32 spnEscapes
[] = { XML_baseline
, XML_superscript
, XML_subscript
};
533 mnEscapement
= STATIC_ARRAY_SELECT( spnEscapes
, nEscapement
, XML_baseline
);
536 ApiFontUsedFlags::ApiFontUsedFlags( bool bAllUsed
) :
537 mbNameUsed( bAllUsed
),
538 mbColorUsed( bAllUsed
),
539 mbSchemeUsed( bAllUsed
),
540 mbHeightUsed( bAllUsed
),
541 mbUnderlineUsed( bAllUsed
),
542 mbEscapementUsed( bAllUsed
),
543 mbWeightUsed( bAllUsed
),
544 mbPostureUsed( bAllUsed
),
545 mbStrikeoutUsed( bAllUsed
),
546 mbOutlineUsed( bAllUsed
),
547 mbShadowUsed( bAllUsed
)
551 ApiScriptFontName::ApiScriptFontName() :
552 mnFamily( ::com::sun::star::awt::FontFamily::DONTKNOW
),
553 mnTextEnc( RTL_TEXTENCODING_DONTKNOW
)
557 ApiFontData::ApiFontData() :
560 220, // height 11 points
563 ::com::sun::star::awt::FontFamily::DONTKNOW
,
564 RTL_TEXTENCODING_DONTKNOW
,
565 ::com::sun::star::awt::FontPitch::DONTKNOW
,
567 ::com::sun::star::awt::FontWeight::NORMAL
,
568 ::com::sun::star::awt::FontSlant_NONE
,
569 ::com::sun::star::awt::FontUnderline::NONE
,
570 ::com::sun::star::awt::FontStrikeout::NONE
,
574 ::com::sun::star::awt::FontType::DONTKNOW
),
575 mnColor( API_RGB_TRANSPARENT
),
576 mnEscapement( API_ESCAPE_NONE
),
577 mnEscapeHeight( API_ESCAPEHEIGHT_NONE
),
581 maLatinFont
.maName
= maDesc
.Name
;
584 Font::Font( const WorkbookHelper
& rHelper
, bool bDxf
) :
585 WorkbookHelper( rHelper
),
586 maModel( rHelper
.getTheme().getDefaultFontModel() ),
587 maUsedFlags( !bDxf
),
592 Font::Font( const WorkbookHelper
& rHelper
, const FontModel
& rModel
) :
593 WorkbookHelper( rHelper
),
600 void Font::importAttribs( sal_Int32 nElement
, const AttributeList
& rAttribs
)
602 const FontModel
& rDefModel
= getTheme().getDefaultFontModel();
605 case XLS_TOKEN( name
): // when in <font> element
606 case XLS_TOKEN( rFont
): // when in <rPr> element
607 if( rAttribs
.hasAttribute( XML_val
) )
609 maModel
.maName
= rAttribs
.getXString( XML_val
, OUString() );
610 maUsedFlags
.mbNameUsed
= true;
613 case XLS_TOKEN( scheme
):
614 maModel
.mnScheme
= rAttribs
.getToken( XML_val
, rDefModel
.mnScheme
);
616 case XLS_TOKEN( family
):
617 maModel
.mnFamily
= rAttribs
.getInteger( XML_val
, rDefModel
.mnFamily
);
619 case XLS_TOKEN( charset
):
620 maModel
.mnCharSet
= rAttribs
.getInteger( XML_val
, rDefModel
.mnCharSet
);
622 case XLS_TOKEN( sz
):
623 maModel
.mfHeight
= rAttribs
.getDouble( XML_val
, rDefModel
.mfHeight
);
624 maUsedFlags
.mbHeightUsed
= true;
626 case XLS_TOKEN( color
):
627 maModel
.maColor
.importColor( rAttribs
);
628 maUsedFlags
.mbColorUsed
= true;
631 maModel
.mnUnderline
= rAttribs
.getToken( XML_val
, XML_single
);
632 maUsedFlags
.mbUnderlineUsed
= true;
634 case XLS_TOKEN( vertAlign
):
635 maModel
.mnEscapement
= rAttribs
.getToken( XML_val
, XML_baseline
);
636 maUsedFlags
.mbEscapementUsed
= true;
639 maModel
.mbBold
= rAttribs
.getBool( XML_val
, true );
640 maUsedFlags
.mbWeightUsed
= true;
643 maModel
.mbItalic
= rAttribs
.getBool( XML_val
, true );
644 maUsedFlags
.mbPostureUsed
= true;
646 case XLS_TOKEN( strike
):
647 maModel
.mbStrikeout
= rAttribs
.getBool( XML_val
, true );
648 maUsedFlags
.mbStrikeoutUsed
= true;
650 case XLS_TOKEN( outline
):
651 maModel
.mbOutline
= rAttribs
.getBool( XML_val
, true );
652 maUsedFlags
.mbOutlineUsed
= true;
654 case XLS_TOKEN( shadow
):
655 maModel
.mbShadow
= rAttribs
.getBool( XML_val
, true );
656 maUsedFlags
.mbShadowUsed
= true;
661 void Font::importFont( SequenceInputStream
& rStrm
)
663 SAL_WARN_IF( mbDxf
, "sc", "Font::importFont - unexpected conditional formatting flag" );
665 sal_uInt16 nHeight
, nFlags
, nWeight
, nEscapement
;
666 sal_uInt8 nUnderline
, nFamily
, nCharSet
, nScheme
;
667 nHeight
= rStrm
.readuInt16();
668 nFlags
= rStrm
.readuInt16();
669 nWeight
= rStrm
.readuInt16();
670 nEscapement
= rStrm
.readuInt16();
671 nUnderline
= rStrm
.readuChar();
672 nFamily
= rStrm
.readuChar();
673 nCharSet
= rStrm
.readuChar();
675 rStrm
>> maModel
.maColor
;
676 nScheme
= rStrm
.readuChar();
677 rStrm
>> maModel
.maName
;
679 // equal constants in all BIFFs for weight, underline, and escapement
680 maModel
.setBiff12Scheme( nScheme
);
681 maModel
.setBiffHeight( nHeight
);
682 maModel
.setBiffWeight( nWeight
);
683 maModel
.setBiffUnderline( nUnderline
);
684 maModel
.setBiffEscapement( nEscapement
);
685 maModel
.mnFamily
= nFamily
;
686 maModel
.mnCharSet
= nCharSet
;
687 // equal flags in all BIFFs
688 maModel
.mbItalic
= getFlag( nFlags
, BIFF_FONTFLAG_ITALIC
);
689 maModel
.mbStrikeout
= getFlag( nFlags
, BIFF_FONTFLAG_STRIKEOUT
);
690 maModel
.mbOutline
= getFlag( nFlags
, BIFF_FONTFLAG_OUTLINE
);
691 maModel
.mbShadow
= getFlag( nFlags
, BIFF_FONTFLAG_SHADOW
);
694 void Font::importDxfName( SequenceInputStream
& rStrm
)
696 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfName - missing conditional formatting flag" );
697 maModel
.maName
= BiffHelper::readString( rStrm
, false );
698 maUsedFlags
.mbColorUsed
= true;
701 void Font::importDxfColor( SequenceInputStream
& rStrm
)
703 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfColor - missing conditional formatting flag" );
704 rStrm
>> maModel
.maColor
;
705 maUsedFlags
.mbColorUsed
= true;
708 void Font::importDxfScheme( SequenceInputStream
& rStrm
)
710 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfScheme - missing conditional formatting flag" );
711 maModel
.setBiff12Scheme( rStrm
.readuInt8() );
712 maUsedFlags
.mbSchemeUsed
= true;
715 void Font::importDxfHeight( SequenceInputStream
& rStrm
)
717 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfHeight - missing conditional formatting flag" );
718 maModel
.setBiffHeight( rStrm
.readuInt16() );
719 maUsedFlags
.mbHeightUsed
= true;
722 void Font::importDxfWeight( SequenceInputStream
& rStrm
)
724 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfWeight - missing conditional formatting flag" );
725 maModel
.setBiffWeight( rStrm
.readuInt16() );
726 maUsedFlags
.mbWeightUsed
= true;
729 void Font::importDxfUnderline( SequenceInputStream
& rStrm
)
731 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfUnderline - missing conditional formatting flag" );
732 maModel
.setBiffUnderline( rStrm
.readuInt16() );
733 maUsedFlags
.mbUnderlineUsed
= true;
736 void Font::importDxfEscapement( SequenceInputStream
& rStrm
)
738 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfEscapement - missing conditional formatting flag" );
739 maModel
.setBiffEscapement( rStrm
.readuInt16() );
740 maUsedFlags
.mbEscapementUsed
= true;
743 void Font::importDxfFlag( sal_Int32 nElement
, SequenceInputStream
& rStrm
)
745 SAL_WARN_IF( !mbDxf
, "sc", "Font::importDxfFlag - missing conditional formatting flag" );
746 bool bFlag
= rStrm
.readuInt8() != 0;
750 maModel
.mbItalic
= bFlag
;
751 maUsedFlags
.mbPostureUsed
= true;
754 maModel
.mbStrikeout
= bFlag
;
755 maUsedFlags
.mbStrikeoutUsed
= true;
758 maModel
.mbOutline
= bFlag
;
759 maUsedFlags
.mbOutlineUsed
= true;
762 maModel
.mbShadow
= bFlag
;
763 maUsedFlags
.mbShadowUsed
= true;
766 OSL_FAIL( "Font::importDxfFlag - unexpected element identifier" );
770 void Font::finalizeImport()
772 namespace cssawt
= ::com::sun::star::awt
;
775 maApiData
.maDesc
.Name
= maModel
.maName
;
778 switch( maModel
.mnFamily
)
780 case OOX_FONTFAMILY_NONE
: maApiData
.maDesc
.Family
= cssawt::FontFamily::DONTKNOW
; break;
781 case OOX_FONTFAMILY_ROMAN
: maApiData
.maDesc
.Family
= cssawt::FontFamily::ROMAN
; break;
782 case OOX_FONTFAMILY_SWISS
: maApiData
.maDesc
.Family
= cssawt::FontFamily::SWISS
; break;
783 case OOX_FONTFAMILY_MODERN
: maApiData
.maDesc
.Family
= cssawt::FontFamily::MODERN
; break;
784 case OOX_FONTFAMILY_SCRIPT
: maApiData
.maDesc
.Family
= cssawt::FontFamily::SCRIPT
; break;
785 case OOX_FONTFAMILY_DECORATIVE
: maApiData
.maDesc
.Family
= cssawt::FontFamily::DECORATIVE
; break;
788 // character set (API font descriptor uses rtl_TextEncoding in member CharSet!)
789 if( (0 <= maModel
.mnCharSet
) && (maModel
.mnCharSet
<= SAL_MAX_UINT8
) )
790 maApiData
.maDesc
.CharSet
= static_cast< sal_Int16
>(
791 rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8
>( maModel
.mnCharSet
) ) );
793 // color, height, weight, slant, strikeout, outline, shadow
794 maApiData
.mnColor
= maModel
.maColor
.getColor( getBaseFilter().getGraphicHelper() );
795 maApiData
.maDesc
.Height
= static_cast< sal_Int16
>( maModel
.mfHeight
* 20.0 );
796 maApiData
.maDesc
.Weight
= maModel
.mbBold
? cssawt::FontWeight::BOLD
: cssawt::FontWeight::NORMAL
;
797 maApiData
.maDesc
.Slant
= maModel
.mbItalic
? cssawt::FontSlant_ITALIC
: cssawt::FontSlant_NONE
;
798 maApiData
.maDesc
.Strikeout
= maModel
.mbStrikeout
? cssawt::FontStrikeout::SINGLE
: cssawt::FontStrikeout::NONE
;
799 maApiData
.mbOutline
= maModel
.mbOutline
;
800 maApiData
.mbShadow
= maModel
.mbShadow
;
803 switch( maModel
.mnUnderline
)
805 case XML_double
: maApiData
.maDesc
.Underline
= cssawt::FontUnderline::DOUBLE
; break;
806 case XML_doubleAccounting
: maApiData
.maDesc
.Underline
= cssawt::FontUnderline::DOUBLE
; break;
807 case XML_none
: maApiData
.maDesc
.Underline
= cssawt::FontUnderline::NONE
; break;
808 case XML_single
: maApiData
.maDesc
.Underline
= cssawt::FontUnderline::SINGLE
; break;
809 case XML_singleAccounting
: maApiData
.maDesc
.Underline
= cssawt::FontUnderline::SINGLE
; break;
813 switch( maModel
.mnEscapement
)
816 maApiData
.mnEscapement
= API_ESCAPE_NONE
;
817 maApiData
.mnEscapeHeight
= API_ESCAPEHEIGHT_NONE
;
819 case XML_superscript
:
820 maApiData
.mnEscapement
= API_ESCAPE_SUPERSCRIPT
;
821 maApiData
.mnEscapeHeight
= API_ESCAPEHEIGHT_DEFAULT
;
824 maApiData
.mnEscapement
= API_ESCAPE_SUBSCRIPT
;
825 maApiData
.mnEscapeHeight
= API_ESCAPEHEIGHT_DEFAULT
;
829 // supported script types
830 if( maUsedFlags
.mbNameUsed
)
832 PropertySet
aDocProps( getDocument() );
833 Reference
< XDevice
> xDevice( aDocProps
.getAnyProperty( PROP_ReferenceDevice
), UNO_QUERY
);
836 Reference
< XFont2
> xFont( xDevice
->getFont( maApiData
.maDesc
), UNO_QUERY
);
841 xFont
->hasGlyphs( OUString( sal_Unicode( 0x3041 ) ) ) || // 3040-309F: Hiragana
842 xFont
->hasGlyphs( OUString( sal_Unicode( 0x30A1 ) ) ) || // 30A0-30FF: Katakana
843 xFont
->hasGlyphs( OUString( sal_Unicode( 0x3111 ) ) ) || // 3100-312F: Bopomofo
844 xFont
->hasGlyphs( OUString( sal_Unicode( 0x3131 ) ) ) || // 3130-318F: Hangul Compatibility Jamo
845 xFont
->hasGlyphs( OUString( sal_Unicode( 0x3301 ) ) ) || // 3300-33FF: CJK Compatibility
846 xFont
->hasGlyphs( OUString( sal_Unicode( 0x3401 ) ) ) || // 3400-4DBF: CJK Unified Ideographs Extension A
847 xFont
->hasGlyphs( OUString( sal_Unicode( 0x4E01 ) ) ) || // 4E00-9FAF: CJK Unified Ideographs
848 xFont
->hasGlyphs( OUString( sal_Unicode( 0x7E01 ) ) ) || // 4E00-9FAF: CJK unified ideographs
849 xFont
->hasGlyphs( OUString( sal_Unicode( 0xA001 ) ) ) || // A001-A48F: Yi Syllables
850 xFont
->hasGlyphs( OUString( sal_Unicode( 0xAC01 ) ) ) || // AC00-D7AF: Hangul Syllables
851 xFont
->hasGlyphs( OUString( sal_Unicode( 0xCC01 ) ) ) || // AC00-D7AF: Hangul Syllables
852 xFont
->hasGlyphs( OUString( sal_Unicode( 0xF901 ) ) ) || // F900-FAFF: CJK Compatibility Ideographs
853 xFont
->hasGlyphs( OUString( sal_Unicode( 0xFF71 ) ) ); // FF00-FFEF: Halfwidth/Fullwidth Forms
854 // #113783# CTL fonts
856 xFont
->hasGlyphs( OUString( sal_Unicode( 0x05D1 ) ) ) || // 0590-05FF: Hebrew
857 xFont
->hasGlyphs( OUString( sal_Unicode( 0x0631 ) ) ) || // 0600-06FF: Arabic
858 xFont
->hasGlyphs( OUString( sal_Unicode( 0x0721 ) ) ) || // 0700-074F: Syriac
859 xFont
->hasGlyphs( OUString( sal_Unicode( 0x0911 ) ) ) || // 0900-0DFF: Indic scripts
860 xFont
->hasGlyphs( OUString( sal_Unicode( 0x0E01 ) ) ) || // 0E00-0E7F: Thai
861 xFont
->hasGlyphs( OUString( sal_Unicode( 0xFB21 ) ) ) || // FB1D-FB4F: Hebrew Presentation Forms
862 xFont
->hasGlyphs( OUString( sal_Unicode( 0xFB51 ) ) ) || // FB50-FDFF: Arabic Presentation Forms-A
863 xFont
->hasGlyphs( OUString( sal_Unicode( 0xFE71 ) ) ); // FE70-FEFF: Arabic Presentation Forms-B
866 (!bHasAsian
&& !bHasCmplx
) ||
867 xFont
->hasGlyphs( OUString( 'A' ) );
869 lclSetFontName( maApiData
.maLatinFont
, maApiData
.maDesc
, bHasLatin
);
870 lclSetFontName( maApiData
.maAsianFont
, maApiData
.maDesc
, bHasAsian
);
871 lclSetFontName( maApiData
.maCmplxFont
, maApiData
.maDesc
, bHasCmplx
);
877 bool Font::needsRichTextFormat() const
879 return maApiData
.mnEscapement
!= API_ESCAPE_NONE
;
881 ::FontFamily
lcl_getFontFamily( sal_Int32 nFamily
)
883 namespace cssawt
= ::com::sun::star::awt
;
885 ::FontFamily eScFamily
= FAMILY_DONTKNOW
;
888 case cssawt::FontFamily::DONTKNOW
:
889 eScFamily
= FAMILY_DONTKNOW
;
891 case cssawt::FontFamily::ROMAN
:
892 eScFamily
= FAMILY_ROMAN
;
894 case cssawt::FontFamily::SWISS
:
895 eScFamily
= FAMILY_SWISS
;
897 case cssawt::FontFamily::MODERN
:
898 eScFamily
= FAMILY_MODERN
;
900 case cssawt::FontFamily::SCRIPT
:
901 eScFamily
= FAMILY_SCRIPT
;
903 case cssawt::FontFamily::DECORATIVE
:
904 eScFamily
= FAMILY_DECORATIVE
;
910 void Font::fillToItemSet( SfxItemSet
& rItemSet
, bool bEditEngineText
, bool bSkipPoolDefs
) const
912 namespace cssawt
= ::com::sun::star::awt
;
913 if ( maUsedFlags
.mbNameUsed
)
915 if( !maApiData
.maLatinFont
.maName
.isEmpty() )
917 rtl_TextEncoding eFontEnc
= maApiData
.maLatinFont
.mnTextEnc
;
918 // taken from binary importer
919 rtl_TextEncoding eTempTextEnc
= (bEditEngineText
&& (eFontEnc
== getTextEncoding())) ?
920 ScfTools::GetSystemTextEncoding() : eFontEnc
;
922 SvxFontItem
aFontItem( lcl_getFontFamily( maApiData
.maLatinFont
.mnFamily
), maApiData
.maLatinFont
.maName
, OUString(),
923 PITCH_DONTKNOW
, eTempTextEnc
, ATTR_FONT
);
924 ScfTools::PutItem( rItemSet
, aFontItem
, bEditEngineText
? EE_CHAR_FONTINFO
: ATTR_FONT
, bSkipPoolDefs
);
926 if( !maApiData
.maAsianFont
.maName
.isEmpty() )
928 rtl_TextEncoding eFontEnc
= maApiData
.maAsianFont
.mnTextEnc
;
929 // taken from binary importer
930 rtl_TextEncoding eTempTextEnc
= (bEditEngineText
&& (eFontEnc
== getTextEncoding())) ?
931 ScfTools::GetSystemTextEncoding() : eFontEnc
;
932 SvxFontItem
aFontItem( lcl_getFontFamily( maApiData
.maAsianFont
.mnFamily
), maApiData
.maAsianFont
.maName
, OUString(),
933 PITCH_DONTKNOW
, eTempTextEnc
, ATTR_FONT
);
934 ScfTools::PutItem( rItemSet
, aFontItem
, bEditEngineText
? EE_CHAR_FONTINFO_CJK
: ATTR_CJK_FONT
, bSkipPoolDefs
);
936 if( !maApiData
.maCmplxFont
.maName
.isEmpty() )
938 rtl_TextEncoding eFontEnc
= maApiData
.maCmplxFont
.mnTextEnc
;
939 // taken from binary importer
940 rtl_TextEncoding eTempTextEnc
= (bEditEngineText
&& (eFontEnc
== getTextEncoding())) ?
941 ScfTools::GetSystemTextEncoding() : eFontEnc
;
942 SvxFontItem
aFontItem( lcl_getFontFamily( maApiData
.maCmplxFont
.mnFamily
), maApiData
.maCmplxFont
.maName
, OUString(),
943 PITCH_DONTKNOW
, eTempTextEnc
, ATTR_FONT
);
944 ScfTools::PutItem( rItemSet
, aFontItem
, bEditEngineText
? EE_CHAR_FONTINFO_CTL
: ATTR_CTL_FONT
, bSkipPoolDefs
);
948 if( maUsedFlags
.mbHeightUsed
)
950 sal_Int32 nHeight
= maApiData
.maDesc
.Height
;
951 // do we use EXC_FONTITEM_HF ( or is it just relevant for the binary filter )
952 if( bEditEngineText
/* && (eType != EXC_FONTITEM_HF) */) // do not convert header/footer height
953 nHeight
= (nHeight
* 127 + 36) / EXC_POINTS_PER_INCH
; // 1 in == 72 pt
954 SvxFontHeightItem
aHeightItem( nHeight
, 100, ATTR_FONT_HEIGHT
);
955 ScfTools::PutItem( rItemSet
, aHeightItem
, bEditEngineText
? EE_CHAR_FONTHEIGHT
: ATTR_FONT_HEIGHT
, bSkipPoolDefs
);
956 ScfTools::PutItem( rItemSet
, aHeightItem
, bEditEngineText
? EE_CHAR_FONTHEIGHT_CJK
: ATTR_CJK_FONT_HEIGHT
, bSkipPoolDefs
);
957 ScfTools::PutItem( rItemSet
, aHeightItem
, bEditEngineText
? EE_CHAR_FONTHEIGHT_CTL
: ATTR_CTL_FONT_HEIGHT
, bSkipPoolDefs
);
960 if( maUsedFlags
.mbWeightUsed
)
962 ::FontWeight fWeight
= VCLUnoHelper::ConvertFontWeight( maApiData
.maDesc
.Weight
);
963 SvxWeightItem
aWeightItem( fWeight
, ATTR_FONT_WEIGHT
);
964 ScfTools::PutItem( rItemSet
, aWeightItem
, bEditEngineText
? EE_CHAR_WEIGHT
: ATTR_FONT_WEIGHT
, bSkipPoolDefs
);
965 ScfTools::PutItem( rItemSet
, aWeightItem
, bEditEngineText
? EE_CHAR_WEIGHT_CTL
: ATTR_CTL_FONT_WEIGHT
, bSkipPoolDefs
);
966 ScfTools::PutItem( rItemSet
, aWeightItem
, bEditEngineText
? EE_CHAR_WEIGHT_CJK
: ATTR_CJK_FONT_WEIGHT
, bSkipPoolDefs
);
969 if( maUsedFlags
.mbPostureUsed
)
971 SvxPostureItem
aPostItem( ( maApiData
.maDesc
.Slant
== cssawt::FontSlant_ITALIC
) ? ITALIC_NORMAL
: ITALIC_NONE
, ATTR_FONT_POSTURE
);
972 ScfTools::PutItem( rItemSet
, aPostItem
, bEditEngineText
? EE_CHAR_ITALIC
: ATTR_FONT_POSTURE
, bSkipPoolDefs
);
973 ScfTools::PutItem( rItemSet
, aPostItem
, bEditEngineText
? EE_CHAR_ITALIC_CJK
: ATTR_CJK_FONT_POSTURE
, bSkipPoolDefs
);
974 ScfTools::PutItem( rItemSet
, aPostItem
, bEditEngineText
? EE_CHAR_ITALIC_CTL
: ATTR_CTL_FONT_POSTURE
, bSkipPoolDefs
);
977 if( maUsedFlags
.mbColorUsed
)
979 ScfTools::PutItem( rItemSet
,SvxColorItem( maApiData
.mnColor
, bEditEngineText
? EE_CHAR_COLOR
: ATTR_FONT_COLOR
) , bSkipPoolDefs
);
982 if( maUsedFlags
.mbUnderlineUsed
)
984 ::FontUnderline eScUnderl
;
985 if ( maApiData
.maDesc
.Underline
== cssawt::FontUnderline::DOUBLE
)
986 eScUnderl
= UNDERLINE_DOUBLE
;
987 else if ( maApiData
.maDesc
.Underline
== cssawt::FontUnderline::SINGLE
)
988 eScUnderl
= UNDERLINE_SINGLE
;
990 eScUnderl
= UNDERLINE_NONE
;
991 SvxUnderlineItem
aUnderlItem( eScUnderl
, ATTR_FONT_UNDERLINE
);
992 ScfTools::PutItem( rItemSet
, aUnderlItem
, bEditEngineText
? EE_CHAR_UNDERLINE
: ATTR_FONT_UNDERLINE
, bSkipPoolDefs
);
995 if( maUsedFlags
.mbStrikeoutUsed
)
997 ScfTools::PutItem( rItemSet
, SvxCrossedOutItem( maModel
.mbStrikeout
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
, bEditEngineText
? EE_CHAR_STRIKEOUT
: ATTR_FONT_CROSSEDOUT
), bEditEngineText
? EE_CHAR_STRIKEOUT
: ATTR_FONT_CROSSEDOUT
, bSkipPoolDefs
);
1001 if( maUsedFlags
.mbOutlineUsed
)
1003 ScfTools::PutItem( rItemSet
, SvxContourItem( maApiData
.mbOutline
, ATTR_FONT_CONTOUR
), bEditEngineText
? EE_CHAR_OUTLINE
: ATTR_FONT_CONTOUR
, bSkipPoolDefs
);
1007 if( maUsedFlags
.mbShadowUsed
)
1009 ScfTools::PutItem( rItemSet
, SvxShadowedItem( maApiData
.mbShadow
, ATTR_FONT_SHADOWED
), bEditEngineText
? EE_CHAR_SHADOW
: ATTR_FONT_SHADOWED
, bSkipPoolDefs
);
1011 if( maUsedFlags
.mbEscapementUsed
)
1013 SvxEscapement eScEscapem
= SVX_ESCAPEMENT_OFF
;
1014 if ( maApiData
.mnEscapement
== API_ESCAPE_SUPERSCRIPT
)
1015 eScEscapem
= SVX_ESCAPEMENT_SUPERSCRIPT
;
1016 else if ( maApiData
.mnEscapement
== API_ESCAPE_SUBSCRIPT
)
1017 eScEscapem
= SVX_ESCAPEMENT_SUBSCRIPT
;
1018 if( bEditEngineText
)
1020 // #TODO handle EscapementHeight
1021 rItemSet
.Put( SvxEscapementItem( eScEscapem
, EE_CHAR_ESCAPEMENT
) );
1026 void Font::writeToPropertyMap( PropertyMap
& rPropMap
, FontPropertyType ePropType
) const
1028 // font name properties
1029 if( maUsedFlags
.mbNameUsed
)
1031 if( !maApiData
.maLatinFont
.maName
.isEmpty() )
1033 rPropMap
.setProperty( PROP_CharFontName
, maApiData
.maLatinFont
.maName
);
1034 rPropMap
.setProperty( PROP_CharFontFamily
, maApiData
.maLatinFont
.mnFamily
);
1035 rPropMap
.setProperty( PROP_CharFontCharSet
, maApiData
.maLatinFont
.mnTextEnc
);
1037 if( !maApiData
.maAsianFont
.maName
.isEmpty() )
1039 rPropMap
.setProperty( PROP_CharFontNameAsian
, maApiData
.maAsianFont
.maName
);
1040 rPropMap
.setProperty( PROP_CharFontFamilyAsian
, maApiData
.maAsianFont
.mnFamily
);
1041 rPropMap
.setProperty( PROP_CharFontCharSetAsian
, maApiData
.maAsianFont
.mnTextEnc
);
1043 if( !maApiData
.maCmplxFont
.maName
.isEmpty() )
1045 rPropMap
.setProperty( PROP_CharFontNameComplex
, maApiData
.maCmplxFont
.maName
);
1046 rPropMap
.setProperty( PROP_CharFontFamilyComplex
, maApiData
.maCmplxFont
.mnFamily
);
1047 rPropMap
.setProperty( PROP_CharFontCharSetComplex
, maApiData
.maCmplxFont
.mnTextEnc
);
1051 if( maUsedFlags
.mbHeightUsed
)
1053 float fHeight
= static_cast< float >( maApiData
.maDesc
.Height
/ 20.0 ); // twips to points
1054 rPropMap
.setProperty( PROP_CharHeight
, fHeight
);
1055 rPropMap
.setProperty( PROP_CharHeightAsian
, fHeight
);
1056 rPropMap
.setProperty( PROP_CharHeightComplex
, fHeight
);
1059 if( maUsedFlags
.mbWeightUsed
)
1061 float fWeight
= maApiData
.maDesc
.Weight
;
1062 rPropMap
.setProperty( PROP_CharWeight
, fWeight
);
1063 rPropMap
.setProperty( PROP_CharWeightAsian
, fWeight
);
1064 rPropMap
.setProperty( PROP_CharWeightComplex
, fWeight
);
1067 if( maUsedFlags
.mbPostureUsed
)
1069 rPropMap
.setProperty( PROP_CharPosture
, maApiData
.maDesc
.Slant
);
1070 rPropMap
.setProperty( PROP_CharPostureAsian
, maApiData
.maDesc
.Slant
);
1071 rPropMap
.setProperty( PROP_CharPostureComplex
, maApiData
.maDesc
.Slant
);
1074 if( maUsedFlags
.mbColorUsed
)
1075 rPropMap
.setProperty( PROP_CharColor
, maApiData
.mnColor
);
1077 if( maUsedFlags
.mbUnderlineUsed
)
1078 rPropMap
.setProperty( PROP_CharUnderline
, maApiData
.maDesc
.Underline
);
1080 if( maUsedFlags
.mbStrikeoutUsed
)
1081 rPropMap
.setProperty( PROP_CharStrikeout
, maApiData
.maDesc
.Strikeout
);
1083 if( maUsedFlags
.mbOutlineUsed
)
1084 rPropMap
.setProperty( PROP_CharContoured
, maApiData
.mbOutline
);
1086 if( maUsedFlags
.mbShadowUsed
)
1087 rPropMap
.setProperty( PROP_CharShadowed
, maApiData
.mbShadow
);
1089 if( maUsedFlags
.mbEscapementUsed
)
1091 rPropMap
.setProperty( PROP_CharEscapement
, maApiData
.mnEscapement
);
1092 if( ePropType
== FONT_PROPTYPE_TEXT
)
1093 rPropMap
.setProperty( PROP_CharEscapementHeight
, maApiData
.mnEscapeHeight
);
1097 void Font::writeToPropertySet( PropertySet
& rPropSet
, FontPropertyType ePropType
) const
1099 PropertyMap aPropMap
;
1100 writeToPropertyMap( aPropMap
, ePropType
);
1101 rPropSet
.setProperties( aPropMap
);
1104 AlignmentModel::AlignmentModel() :
1105 mnHorAlign( XML_general
),
1106 mnVerAlign( XML_bottom
),
1107 mnTextDir( OOX_XF_TEXTDIR_CONTEXT
),
1108 mnRotation( OOX_XF_ROTATION_NONE
),
1109 mnIndent( OOX_XF_INDENT_NONE
),
1110 mbWrapText( false ),
1112 mbJustLastLine( false )
1116 void AlignmentModel::setBiffHorAlign( sal_uInt8 nHorAlign
)
1118 static const sal_Int32 spnHorAligns
[] = {
1119 XML_general
, XML_left
, XML_center
, XML_right
,
1120 XML_fill
, XML_justify
, XML_centerContinuous
, XML_distributed
};
1121 mnHorAlign
= STATIC_ARRAY_SELECT( spnHorAligns
, nHorAlign
, XML_general
);
1124 void AlignmentModel::setBiffVerAlign( sal_uInt8 nVerAlign
)
1126 static const sal_Int32 spnVerAligns
[] = {
1127 XML_top
, XML_center
, XML_bottom
, XML_justify
, XML_distributed
};
1128 mnVerAlign
= STATIC_ARRAY_SELECT( spnVerAligns
, nVerAlign
, XML_bottom
);
1131 ApiAlignmentData::ApiAlignmentData() :
1132 meHorJustify( ::com::sun::star::table::CellHoriJustify_STANDARD
),
1133 mnHorJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO
),
1134 mnVerJustify( ::com::sun::star::table::CellVertJustify2::STANDARD
),
1135 mnVerJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO
),
1136 meOrientation( ::com::sun::star::table::CellOrientation_STANDARD
),
1138 mnWritingMode( ::com::sun::star::text::WritingMode2::PAGE
),
1140 mbWrapText( false ),
1145 bool operator==( const ApiAlignmentData
& rLeft
, const ApiAlignmentData
& rRight
)
1148 (rLeft
.meHorJustify
== rRight
.meHorJustify
) &&
1149 (rLeft
.mnHorJustifyMethod
== rRight
.mnHorJustifyMethod
) &&
1150 (rLeft
.mnVerJustify
== rRight
.mnVerJustify
) &&
1151 (rLeft
.mnVerJustifyMethod
== rRight
.mnVerJustifyMethod
) &&
1152 (rLeft
.meOrientation
== rRight
.meOrientation
) &&
1153 (rLeft
.mnRotation
== rRight
.mnRotation
) &&
1154 (rLeft
.mnWritingMode
== rRight
.mnWritingMode
) &&
1155 (rLeft
.mnIndent
== rRight
.mnIndent
) &&
1156 (rLeft
.mbWrapText
== rRight
.mbWrapText
) &&
1157 (rLeft
.mbShrink
== rRight
.mbShrink
);
1160 Alignment::Alignment( const WorkbookHelper
& rHelper
) :
1161 WorkbookHelper( rHelper
)
1165 void Alignment::importAlignment( const AttributeList
& rAttribs
)
1167 maModel
.mnHorAlign
= rAttribs
.getToken( XML_horizontal
, XML_general
);
1168 maModel
.mnVerAlign
= rAttribs
.getToken( XML_vertical
, XML_bottom
);
1169 maModel
.mnTextDir
= rAttribs
.getInteger( XML_readingOrder
, OOX_XF_TEXTDIR_CONTEXT
);
1170 maModel
.mnRotation
= rAttribs
.getInteger( XML_textRotation
, OOX_XF_ROTATION_NONE
);
1171 maModel
.mnIndent
= rAttribs
.getInteger( XML_indent
, OOX_XF_INDENT_NONE
);
1172 maModel
.mbWrapText
= rAttribs
.getBool( XML_wrapText
, false );
1173 maModel
.mbShrink
= rAttribs
.getBool( XML_shrinkToFit
, false );
1174 maModel
.mbJustLastLine
= rAttribs
.getBool( XML_justifyLastLine
, false );
1177 void Alignment::setBiff12Data( sal_uInt32 nFlags
)
1179 maModel
.setBiffHorAlign( extractValue
< sal_uInt8
>( nFlags
, 16, 3 ) );
1180 maModel
.setBiffVerAlign( extractValue
< sal_uInt8
>( nFlags
, 19, 3 ) );
1181 maModel
.mnTextDir
= extractValue
< sal_Int32
>( nFlags
, 26, 2 );
1182 maModel
.mnRotation
= extractValue
< sal_Int32
>( nFlags
, 0, 8 );
1183 maModel
.mnIndent
= extractValue
< sal_uInt8
>( nFlags
, 8, 8 );
1184 maModel
.mbWrapText
= getFlag( nFlags
, BIFF12_XF_WRAPTEXT
);
1185 maModel
.mbShrink
= getFlag( nFlags
, BIFF12_XF_SHRINK
);
1186 maModel
.mbJustLastLine
= getFlag( nFlags
, BIFF12_XF_JUSTLASTLINE
);
1189 void Alignment::finalizeImport()
1191 namespace csstab
= ::com::sun::star::table
;
1192 namespace csstxt
= ::com::sun::star::text
;
1194 // horizontal alignment
1195 switch( maModel
.mnHorAlign
)
1197 case XML_center
: maApiData
.meHorJustify
= csstab::CellHoriJustify_CENTER
; break;
1198 case XML_centerContinuous
: maApiData
.meHorJustify
= csstab::CellHoriJustify_CENTER
; break;
1199 case XML_distributed
: maApiData
.meHorJustify
= csstab::CellHoriJustify_BLOCK
; break;
1200 case XML_fill
: maApiData
.meHorJustify
= csstab::CellHoriJustify_REPEAT
; break;
1201 case XML_general
: maApiData
.meHorJustify
= csstab::CellHoriJustify_STANDARD
; break;
1202 case XML_justify
: maApiData
.meHorJustify
= csstab::CellHoriJustify_BLOCK
; break;
1203 case XML_left
: maApiData
.meHorJustify
= csstab::CellHoriJustify_LEFT
; break;
1204 case XML_right
: maApiData
.meHorJustify
= csstab::CellHoriJustify_RIGHT
; break;
1207 if (maModel
.mnHorAlign
== XML_distributed
)
1208 maApiData
.mnHorJustifyMethod
= csstab::CellJustifyMethod::DISTRIBUTE
;
1210 // vertical alignment
1211 switch( maModel
.mnVerAlign
)
1213 case XML_bottom
: maApiData
.mnVerJustify
= csstab::CellVertJustify2::BOTTOM
; break;
1214 case XML_center
: maApiData
.mnVerJustify
= csstab::CellVertJustify2::CENTER
; break;
1215 case XML_distributed
: maApiData
.mnVerJustify
= csstab::CellVertJustify2::BLOCK
; break;
1216 case XML_justify
: maApiData
.mnVerJustify
= csstab::CellVertJustify2::BLOCK
; break;
1217 case XML_top
: maApiData
.mnVerJustify
= csstab::CellVertJustify2::TOP
; break;
1220 if (maModel
.mnVerAlign
== XML_distributed
)
1221 maApiData
.mnVerJustifyMethod
= csstab::CellJustifyMethod::DISTRIBUTE
;
1223 /* indentation: expressed as number of blocks of 3 space characters in
1224 OOXML/BIFF12, and as multiple of 10 points in BIFF8. */
1225 sal_Int32 nIndent
= 0;
1226 switch( getFilterType() )
1228 case FILTER_OOXML
: nIndent
= getUnitConverter().scaleToMm100( 3.0 * maModel
.mnIndent
, UNIT_SPACE
); break;
1229 case FILTER_BIFF
: nIndent
= getUnitConverter().scaleToMm100( 10.0 * maModel
.mnIndent
, UNIT_POINT
); break;
1230 case FILTER_UNKNOWN
: break;
1232 if( (0 <= nIndent
) && (nIndent
<= SAL_MAX_INT16
) )
1233 maApiData
.mnIndent
= static_cast< sal_Int16
>( nIndent
);
1235 // complex text direction
1236 switch( maModel
.mnTextDir
)
1238 case OOX_XF_TEXTDIR_CONTEXT
: maApiData
.mnWritingMode
= csstxt::WritingMode2::PAGE
; break;
1239 case OOX_XF_TEXTDIR_LTR
: maApiData
.mnWritingMode
= csstxt::WritingMode2::LR_TB
; break;
1240 case OOX_XF_TEXTDIR_RTL
: maApiData
.mnWritingMode
= csstxt::WritingMode2::RL_TB
; break;
1243 // rotation: 0-90 means 0 to 90 degrees ccw, 91-180 means 1 to 90 degrees cw, 255 means stacked
1244 sal_Int32 nOoxRot
= maModel
.mnRotation
;
1245 maApiData
.mnRotation
= ((0 <= nOoxRot
) && (nOoxRot
<= 90)) ?
1247 (((91 <= nOoxRot
) && (nOoxRot
<= 180)) ? (100 * (450 - nOoxRot
)) : 0);
1249 // "Orientation" property used for character stacking
1250 maApiData
.meOrientation
= (nOoxRot
== OOX_XF_ROTATION_STACKED
) ?
1251 csstab::CellOrientation_STACKED
: csstab::CellOrientation_STANDARD
;
1253 // alignment flags (#i84960 automatic line break, if vertically justified/distributed)
1254 maApiData
.mbWrapText
= maModel
.mbWrapText
|| (maModel
.mnVerAlign
== XML_distributed
) || (maModel
.mnVerAlign
== XML_justify
);
1255 maApiData
.mbShrink
= maModel
.mbShrink
;
1259 ::SvxCellVerJustify
Alignment::GetScVerAlign() const
1261 namespace csstab
= ::com::sun::star::table
;
1262 ::SvxCellVerJustify nVert
= ::SVX_VER_JUSTIFY_STANDARD
;
1263 switch ( maApiData
.mnVerJustify
)
1265 case csstab::CellVertJustify2::BOTTOM
:
1266 nVert
= ::SVX_VER_JUSTIFY_BOTTOM
;
1268 case csstab::CellVertJustify2::CENTER
:
1269 nVert
= ::SVX_VER_JUSTIFY_CENTER
;
1271 case csstab::CellVertJustify2::TOP
:
1272 nVert
= ::SVX_VER_JUSTIFY_TOP
;
1274 case csstab::CellVertJustify2::BLOCK
:
1275 nVert
= ::SVX_VER_JUSTIFY_BLOCK
;
1277 case csstab::CellVertJustify2::STANDARD
:
1279 nVert
= ::SVX_VER_JUSTIFY_STANDARD
;
1285 ::SvxCellHorJustify
Alignment::GetScHorAlign() const
1287 namespace csstab
= ::com::sun::star::table
;
1288 ::SvxCellHorJustify nHori
= ::SVX_HOR_JUSTIFY_STANDARD
;
1289 switch( maApiData
.meHorJustify
)
1291 case csstab::CellHoriJustify_LEFT
:
1292 nHori
= ::SVX_HOR_JUSTIFY_LEFT
;
1294 case csstab::CellHoriJustify_CENTER
:
1295 nHori
= ::SVX_HOR_JUSTIFY_CENTER
;
1297 case csstab::CellHoriJustify_RIGHT
:
1298 nHori
= ::SVX_HOR_JUSTIFY_RIGHT
;
1300 case csstab::CellHoriJustify_BLOCK
:
1301 nHori
= ::SVX_HOR_JUSTIFY_BLOCK
;
1303 case csstab::CellHoriJustify_REPEAT
:
1304 nHori
= ::SVX_HOR_JUSTIFY_REPEAT
;
1306 case csstab::CellHoriJustify_STANDARD
:
1308 nHori
= ::SVX_HOR_JUSTIFY_STANDARD
;
1314 ::SvxFrameDirection
Alignment::GetScFrameDir() const
1316 namespace csstxt
= ::com::sun::star::text
;
1317 ::SvxFrameDirection eFrameDir
= ::FRMDIR_ENVIRONMENT
;
1318 switch( maApiData
.mnWritingMode
)
1320 case csstxt::WritingMode2::PAGE
:
1321 eFrameDir
= ::FRMDIR_ENVIRONMENT
;
1323 case csstxt::WritingMode2::LR_TB
:
1324 eFrameDir
= ::FRMDIR_HORI_LEFT_TOP
;
1326 case csstxt::WritingMode2::RL_TB
:
1327 eFrameDir
= ::FRMDIR_HORI_RIGHT_TOP
;
1330 OSL_FAIL( "GetScFrameDir - unknown CTL text direction" );
1335 void Alignment::fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
) const
1337 namespace csstab
= ::com::sun::star::table
;
1338 // horizontal alignment
1339 ScfTools::PutItem( rItemSet
, SvxHorJustifyItem( GetScHorAlign(), ATTR_HOR_JUSTIFY
), bSkipPoolDefs
);
1340 ScfTools::PutItem( rItemSet
, SvxJustifyMethodItem( ( maApiData
.mnHorJustifyMethod
== csstab::CellJustifyMethod::DISTRIBUTE
) ? ::SVX_JUSTIFY_METHOD_DISTRIBUTE
: ::SVX_JUSTIFY_METHOD_AUTO
, ATTR_HOR_JUSTIFY_METHOD
), bSkipPoolDefs
);
1341 ScfTools::PutItem( rItemSet
, SvxVerJustifyItem( GetScVerAlign(), ATTR_VER_JUSTIFY
), bSkipPoolDefs
);
1342 // vertical alignment
1343 ScfTools::PutItem( rItemSet
, SvxJustifyMethodItem( ( maApiData
.mnVerJustifyMethod
== csstab::CellJustifyMethod::DISTRIBUTE
) ? ::SVX_JUSTIFY_METHOD_DISTRIBUTE
: ::SVX_JUSTIFY_METHOD_AUTO
, ATTR_VER_JUSTIFY_METHOD
), bSkipPoolDefs
);
1345 // CTL text direction
1346 ScfTools::PutItem( rItemSet
, SvxFrameDirectionItem( GetScFrameDir(), ATTR_WRITINGDIR
), bSkipPoolDefs
);
1347 // set an angle in the range from -90 to 90 degrees
1348 ScfTools::PutItem( rItemSet
, SfxInt32Item( ATTR_ROTATE_VALUE
, maApiData
.mnRotation
), bSkipPoolDefs
);
1350 ScfTools::PutItem( rItemSet
, SfxBoolItem( ATTR_STACKED
, maApiData
.meOrientation
== csstab::CellOrientation_STACKED
), bSkipPoolDefs
);
1352 ScfTools::PutItem( rItemSet
, SfxUInt16Item( ATTR_INDENT
, maApiData
.mnIndent
), bSkipPoolDefs
);
1354 ScfTools::PutItem( rItemSet
, SfxBoolItem( ATTR_LINEBREAK
, maApiData
.mbWrapText
), bSkipPoolDefs
);
1355 ScfTools::PutItem( rItemSet
, SfxBoolItem( ATTR_SHRINKTOFIT
, maApiData
.mbShrink
), bSkipPoolDefs
);
1358 void Alignment::writeToPropertyMap( PropertyMap
& rPropMap
) const
1360 rPropMap
.setProperty( PROP_HoriJustify
, maApiData
.meHorJustify
);
1361 rPropMap
.setProperty( PROP_HoriJustifyMethod
, maApiData
.mnHorJustifyMethod
);
1362 rPropMap
.setProperty( PROP_VertJustify
, maApiData
.mnVerJustify
);
1363 rPropMap
.setProperty( PROP_VertJustifyMethod
, maApiData
.mnVerJustifyMethod
);
1364 rPropMap
.setProperty( PROP_WritingMode
, maApiData
.mnWritingMode
);
1365 rPropMap
.setProperty( PROP_RotateAngle
, maApiData
.mnRotation
);
1366 rPropMap
.setProperty( PROP_Orientation
, maApiData
.meOrientation
);
1367 rPropMap
.setProperty( PROP_ParaIndent
, maApiData
.mnIndent
);
1368 rPropMap
.setProperty( PROP_IsTextWrapped
, maApiData
.mbWrapText
);
1369 rPropMap
.setProperty( PROP_ShrinkToFit
, maApiData
.mbShrink
);
1372 ProtectionModel::ProtectionModel() :
1373 mbLocked( true ), // default in Excel and Calc
1378 ApiProtectionData::ApiProtectionData() :
1379 maCellProt( sal_True
, sal_False
, sal_False
, sal_False
)
1383 bool operator==( const ApiProtectionData
& rLeft
, const ApiProtectionData
& rRight
)
1386 (rLeft
.maCellProt
.IsLocked
== rRight
.maCellProt
.IsLocked
) &&
1387 (rLeft
.maCellProt
.IsFormulaHidden
== rRight
.maCellProt
.IsFormulaHidden
) &&
1388 (rLeft
.maCellProt
.IsHidden
== rRight
.maCellProt
.IsHidden
) &&
1389 (rLeft
.maCellProt
.IsPrintHidden
== rRight
.maCellProt
.IsPrintHidden
);
1392 Protection::Protection( const WorkbookHelper
& rHelper
) :
1393 WorkbookHelper( rHelper
)
1397 void Protection::importProtection( const AttributeList
& rAttribs
)
1399 maModel
.mbLocked
= rAttribs
.getBool( XML_locked
, true );
1400 maModel
.mbHidden
= rAttribs
.getBool( XML_hidden
, false );
1403 void Protection::setBiff12Data( sal_uInt32 nFlags
)
1405 maModel
.mbLocked
= getFlag( nFlags
, BIFF12_XF_LOCKED
);
1406 maModel
.mbHidden
= getFlag( nFlags
, BIFF12_XF_HIDDEN
);
1409 void Protection::finalizeImport()
1411 maApiData
.maCellProt
.IsLocked
= maModel
.mbLocked
;
1412 maApiData
.maCellProt
.IsFormulaHidden
= maModel
.mbHidden
;
1415 void Protection::writeToPropertyMap( PropertyMap
& rPropMap
) const
1417 rPropMap
.setProperty( PROP_CellProtection
, maApiData
.maCellProt
);
1420 void Protection::fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
) const
1422 ScfTools::PutItem( rItemSet
, ScProtectionAttr( maApiData
.maCellProt
.IsLocked
, maApiData
.maCellProt
.IsFormulaHidden
), bSkipPoolDefs
);
1427 bool lcl_isBorder(const ::com::sun::star::table::BorderLine
& rBorder
)
1429 return (rBorder
.InnerLineWidth
> 0) || (rBorder
.OuterLineWidth
> 0);
1434 BorderLineModel::BorderLineModel( bool bDxf
) :
1435 mnStyle( XML_none
),
1438 maColor
.setIndexed( OOX_COLOR_WINDOWTEXT
);
1441 void BorderLineModel::setBiffStyle( sal_Int32 nLineStyle
)
1443 static const sal_Int32 spnStyleIds
[] = {
1444 XML_none
, XML_thin
, XML_medium
, XML_dashed
,
1445 XML_dotted
, XML_thick
, XML_double
, XML_hair
,
1446 XML_mediumDashed
, XML_dashDot
, XML_mediumDashDot
, XML_dashDotDot
,
1447 XML_mediumDashDotDot
, XML_slantDashDot
};
1448 mnStyle
= STATIC_ARRAY_SELECT( spnStyleIds
, nLineStyle
, XML_none
);
1451 BorderModel::BorderModel( bool bDxf
) :
1457 mbDiagTLtoBR( false ),
1458 mbDiagBLtoTR( false )
1462 ApiBorderData::ApiBorderData() :
1463 mbBorderUsed( false ),
1468 bool ApiBorderData::hasAnyOuterBorder() const
1471 ( ( lcl_isBorder( maTop
) && maTop
.OuterLineWidth
> 0 ) ) ||
1472 ( ( lcl_isBorder( maBottom
) && maBottom
.OuterLineWidth
> 0 ) ) ||
1473 ( ( lcl_isBorder( maLeft
) && maLeft
.OuterLineWidth
> 0 ) ) ||
1474 ( ( lcl_isBorder( maRight
) && maRight
.OuterLineWidth
> 0 ) );
1479 bool operator==( const BorderLine
& rLeft
, const BorderLine
& rRight
)
1482 (rLeft
.Color
== rRight
.Color
) &&
1483 (rLeft
.InnerLineWidth
== rRight
.InnerLineWidth
) &&
1484 (rLeft
.OuterLineWidth
== rRight
.OuterLineWidth
) &&
1485 (rLeft
.LineDistance
== rRight
.LineDistance
);
1490 bool operator==( const ApiBorderData
& rLeft
, const ApiBorderData
& rRight
)
1493 (rLeft
.maLeft
== rRight
.maLeft
) &&
1494 (rLeft
.maRight
== rRight
.maRight
) &&
1495 (rLeft
.maTop
== rRight
.maTop
) &&
1496 (rLeft
.maBottom
== rRight
.maBottom
) &&
1497 (rLeft
.maTLtoBR
== rRight
.maTLtoBR
) &&
1498 (rLeft
.maBLtoTR
== rRight
.maBLtoTR
) &&
1499 (rLeft
.mbBorderUsed
== rRight
.mbBorderUsed
) &&
1500 (rLeft
.mbDiagUsed
== rRight
.mbDiagUsed
);
1505 inline void lclSetBorderLineWidth( BorderLine
& rBorderLine
,
1506 sal_Int16 nOuter
, sal_Int16 nDist
= API_LINE_NONE
, sal_Int16 nInner
= API_LINE_NONE
)
1508 rBorderLine
.OuterLineWidth
= nOuter
;
1509 rBorderLine
.LineDistance
= nDist
;
1510 rBorderLine
.InnerLineWidth
= nInner
;
1515 Border::Border( const WorkbookHelper
& rHelper
, bool bDxf
) :
1516 WorkbookHelper( rHelper
),
1522 void Border::importBorder( const AttributeList
& rAttribs
)
1524 maModel
.mbDiagTLtoBR
= rAttribs
.getBool( XML_diagonalDown
, false );
1525 maModel
.mbDiagBLtoTR
= rAttribs
.getBool( XML_diagonalUp
, false );
1528 void Border::importStyle( sal_Int32 nElement
, const AttributeList
& rAttribs
)
1530 if( BorderLineModel
* pBorderLine
= getBorderLine( nElement
) )
1532 pBorderLine
->mnStyle
= rAttribs
.getToken( XML_style
, XML_none
);
1533 pBorderLine
->mbUsed
= true;
1537 void Border::importColor( sal_Int32 nElement
, const AttributeList
& rAttribs
)
1539 if( BorderLineModel
* pBorderLine
= getBorderLine( nElement
) )
1540 pBorderLine
->maColor
.importColor( rAttribs
);
1543 void Border::importBorder( SequenceInputStream
& rStrm
)
1545 sal_uInt8 nFlags
= rStrm
.readuInt8();
1546 maModel
.mbDiagTLtoBR
= getFlag( nFlags
, BIFF12_BORDER_DIAG_TLBR
);
1547 maModel
.mbDiagBLtoTR
= getFlag( nFlags
, BIFF12_BORDER_DIAG_BLTR
);
1548 maModel
.maTop
.setBiffStyle( rStrm
.readuInt16() );
1549 rStrm
>> maModel
.maTop
.maColor
;
1550 maModel
.maBottom
.setBiffStyle( rStrm
.readuInt16() );
1551 rStrm
>> maModel
.maBottom
.maColor
;
1552 maModel
.maLeft
.setBiffStyle( rStrm
.readuInt16() );
1553 rStrm
>> maModel
.maLeft
.maColor
;
1554 maModel
.maRight
.setBiffStyle( rStrm
.readuInt16() );
1555 rStrm
>> maModel
.maRight
.maColor
;
1556 maModel
.maDiagonal
.setBiffStyle( rStrm
.readuInt16() );
1557 rStrm
>> maModel
.maDiagonal
.maColor
;
1560 void Border::importDxfBorder( sal_Int32 nElement
, SequenceInputStream
& rStrm
)
1562 SAL_WARN_IF( !mbDxf
, "sc", "Border::importDxfBorder - missing conditional formatting flag" );
1563 if( BorderLineModel
* pBorderLine
= getBorderLine( nElement
) )
1566 rStrm
>> pBorderLine
->maColor
;
1567 nStyle
= rStrm
.readuInt16();
1568 pBorderLine
->setBiffStyle( nStyle
);
1569 pBorderLine
->mbUsed
= true;
1573 void Border::finalizeImport( bool bRTL
)
1577 BorderLineModel aTmp
= maModel
.maLeft
;
1578 maModel
.maLeft
= maModel
.maRight
;
1579 maModel
.maRight
= aTmp
;
1581 maApiData
.mbBorderUsed
= maModel
.maLeft
.mbUsed
|| maModel
.maRight
.mbUsed
|| maModel
.maTop
.mbUsed
|| maModel
.maBottom
.mbUsed
;
1582 maApiData
.mbDiagUsed
= maModel
.maDiagonal
.mbUsed
;
1584 convertBorderLine( maApiData
.maLeft
, maModel
.maLeft
);
1585 convertBorderLine( maApiData
.maRight
, maModel
.maRight
);
1586 convertBorderLine( maApiData
.maTop
, maModel
.maTop
);
1587 convertBorderLine( maApiData
.maBottom
, maModel
.maBottom
);
1589 if( maModel
.mbDiagTLtoBR
)
1590 convertBorderLine( maApiData
.maTLtoBR
, maModel
.maDiagonal
);
1591 if( maModel
.mbDiagBLtoTR
)
1592 convertBorderLine( maApiData
.maBLtoTR
, maModel
.maDiagonal
);
1595 void Border::fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
) const
1597 if( maApiData
.mbBorderUsed
)
1599 SvxBoxItem
aBoxItem( ATTR_BORDER
);
1600 ::editeng::SvxBorderLine aLine
;
1602 if (SvxBoxItem::LineToSvxLine(maApiData
.maLeft
, aLine
, false))
1604 aBoxItem
.SetLine( &aLine
, SvxBoxItemLine::LEFT
);
1606 if (SvxBoxItem::LineToSvxLine(maApiData
.maRight
, aLine
, false))
1608 aBoxItem
.SetLine( &aLine
, SvxBoxItemLine::RIGHT
);
1610 if (SvxBoxItem::LineToSvxLine(maApiData
.maTop
, aLine
, false))
1612 aBoxItem
.SetLine( &aLine
, SvxBoxItemLine::TOP
);
1614 if (SvxBoxItem::LineToSvxLine(maApiData
.maBottom
, aLine
, false))
1616 aBoxItem
.SetLine( &aLine
, SvxBoxItemLine::BOTTOM
);
1618 ScfTools::PutItem( rItemSet
, aBoxItem
, bSkipPoolDefs
);
1620 if ( maApiData
.mbDiagUsed
)
1622 SvxLineItem
aTLBRItem( ATTR_BORDER_TLBR
);
1623 SvxLineItem
aBLTRItem( ATTR_BORDER_BLTR
);
1624 ::editeng::SvxBorderLine aLine
;
1625 if (SvxBoxItem::LineToSvxLine(maApiData
.maTLtoBR
, aLine
, false))
1627 aTLBRItem
.SetLine( &aLine
);
1629 if (SvxBoxItem::LineToSvxLine(maApiData
.maBLtoTR
, aLine
, false))
1631 aBLTRItem
.SetLine( &aLine
);
1633 ScfTools::PutItem( rItemSet
, aTLBRItem
, bSkipPoolDefs
);
1634 ScfTools::PutItem( rItemSet
, aBLTRItem
, bSkipPoolDefs
);
1638 void Border::writeToPropertyMap( PropertyMap
& rPropMap
) const
1640 if( maApiData
.mbBorderUsed
)
1642 rPropMap
.setProperty( PROP_LeftBorder
, maApiData
.maLeft
);
1643 rPropMap
.setProperty( PROP_RightBorder
, maApiData
.maRight
);
1644 rPropMap
.setProperty( PROP_TopBorder
, maApiData
.maTop
);
1645 rPropMap
.setProperty( PROP_BottomBorder
, maApiData
.maBottom
);
1647 if( maApiData
.mbDiagUsed
)
1649 rPropMap
.setProperty( PROP_DiagonalTLBR
, maApiData
.maTLtoBR
);
1650 rPropMap
.setProperty( PROP_DiagonalBLTR
, maApiData
.maBLtoTR
);
1654 bool Border::hasBorder() const
1656 if (lcl_isBorder(maApiData
.maBottom
))
1659 if (lcl_isBorder(maApiData
.maTop
))
1662 if (lcl_isBorder(maApiData
.maLeft
))
1665 if (lcl_isBorder(maApiData
.maRight
))
1671 BorderLineModel
* Border::getBorderLine( sal_Int32 nElement
)
1675 case XLS_TOKEN( left
): return &maModel
.maLeft
;
1676 case XLS_TOKEN( start
): return &maModel
.maLeft
;
1677 case XLS_TOKEN( right
): return &maModel
.maRight
;
1678 case XLS_TOKEN( end
): return &maModel
.maRight
;
1679 case XLS_TOKEN( top
): return &maModel
.maTop
;
1680 case XLS_TOKEN( bottom
): return &maModel
.maBottom
;
1681 case XLS_TOKEN( diagonal
): return &maModel
.maDiagonal
;
1686 bool Border::convertBorderLine( BorderLine2
& rBorderLine
, const BorderLineModel
& rModel
)
1688 rBorderLine
.Color
= rModel
.maColor
.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK
);
1689 switch( rModel
.mnStyle
)
1692 lclSetBorderLineWidth( rBorderLine
, API_LINE_THIN
);
1693 rBorderLine
.LineStyle
= table::BorderLineStyle::DASH_DOT
;
1695 case XML_dashDotDot
:
1696 lclSetBorderLineWidth( rBorderLine
, API_LINE_THIN
);
1697 rBorderLine
.LineStyle
= table::BorderLineStyle::DASH_DOT_DOT
;
1700 lclSetBorderLineWidth( rBorderLine
, API_LINE_THIN
);
1701 rBorderLine
.LineStyle
= table::BorderLineStyle::FINE_DASHED
;
1704 lclSetBorderLineWidth( rBorderLine
, API_LINE_THIN
);
1705 rBorderLine
.LineStyle
= table::BorderLineStyle::DOTTED
;
1708 lclSetBorderLineWidth( rBorderLine
, 10, 30, 10 );
1709 rBorderLine
.LineStyle
= table::BorderLineStyle::DOUBLE_THIN
;
1711 case XML_hair
: lclSetBorderLineWidth( rBorderLine
, API_LINE_HAIR
); break;
1712 case XML_medium
: lclSetBorderLineWidth( rBorderLine
, API_LINE_MEDIUM
); break;
1713 case XML_mediumDashDot
:
1714 lclSetBorderLineWidth( rBorderLine
, API_LINE_MEDIUM
);
1715 rBorderLine
.LineStyle
= table::BorderLineStyle::DASH_DOT
;
1717 case XML_mediumDashDotDot
:
1718 lclSetBorderLineWidth( rBorderLine
, API_LINE_MEDIUM
);
1719 rBorderLine
.LineStyle
= table::BorderLineStyle::DASH_DOT_DOT
;
1721 case XML_mediumDashed
:
1722 lclSetBorderLineWidth( rBorderLine
, API_LINE_MEDIUM
);
1723 rBorderLine
.LineStyle
= table::BorderLineStyle::DASHED
;
1725 case XML_none
: lclSetBorderLineWidth( rBorderLine
, API_LINE_NONE
); break;
1726 case XML_slantDashDot
:
1727 lclSetBorderLineWidth( rBorderLine
, API_LINE_MEDIUM
);
1728 rBorderLine
.LineStyle
= table::BorderLineStyle::DASH_DOT
;
1730 case XML_thick
: lclSetBorderLineWidth( rBorderLine
, API_LINE_THICK
); break;
1731 case XML_thin
: lclSetBorderLineWidth( rBorderLine
, API_LINE_THIN
); break;
1732 default: lclSetBorderLineWidth( rBorderLine
, API_LINE_NONE
); break;
1734 return rModel
.mbUsed
;
1737 PatternFillModel::PatternFillModel( bool bDxf
) :
1738 mnPattern( XML_none
),
1739 mbPattColorUsed( !bDxf
),
1740 mbFillColorUsed( !bDxf
),
1741 mbPatternUsed( !bDxf
)
1743 maPatternColor
.setIndexed( OOX_COLOR_WINDOWTEXT
);
1744 maFillColor
.setIndexed( OOX_COLOR_WINDOWBACK
);
1747 void PatternFillModel::setBiffPattern( sal_Int32 nPattern
)
1749 static const sal_Int32 spnPatternIds
[] = {
1750 XML_none
, XML_solid
, XML_mediumGray
, XML_darkGray
,
1751 XML_lightGray
, XML_darkHorizontal
, XML_darkVertical
, XML_darkDown
,
1752 XML_darkUp
, XML_darkGrid
, XML_darkTrellis
, XML_lightHorizontal
,
1753 XML_lightVertical
, XML_lightDown
, XML_lightUp
, XML_lightGrid
,
1754 XML_lightTrellis
, XML_gray125
, XML_gray0625
};
1755 mnPattern
= STATIC_ARRAY_SELECT( spnPatternIds
, nPattern
, XML_none
);
1758 GradientFillModel::GradientFillModel() :
1759 mnType( XML_linear
),
1768 void GradientFillModel::readGradient( SequenceInputStream
& rStrm
)
1771 nType
= rStrm
.readInt32();
1772 mfAngle
= rStrm
.readDouble();
1773 mfLeft
= rStrm
.readDouble();
1774 mfRight
= rStrm
.readDouble();
1775 mfTop
= rStrm
.readDouble();
1776 mfBottom
= rStrm
.readDouble();
1777 static const sal_Int32 spnTypes
[] = { XML_linear
, XML_path
};
1778 mnType
= STATIC_ARRAY_SELECT( spnTypes
, nType
, XML_TOKEN_INVALID
);
1781 void GradientFillModel::readGradientStop( SequenceInputStream
& rStrm
, bool bDxf
)
1788 fPosition
= rStrm
.readDouble();
1794 fPosition
= rStrm
.readDouble();
1796 if( !rStrm
.isEof() && (fPosition
>= 0.0) )
1797 maColors
[ fPosition
] = aColor
;
1800 ApiSolidFillData::ApiSolidFillData() :
1801 mnColor( API_RGB_TRANSPARENT
),
1802 mbTransparent( true ),
1807 bool operator==( const ApiSolidFillData
& rLeft
, const ApiSolidFillData
& rRight
)
1810 (rLeft
.mnColor
== rRight
.mnColor
) &&
1811 (rLeft
.mbTransparent
== rRight
.mbTransparent
) &&
1812 (rLeft
.mbUsed
== rRight
.mbUsed
);
1817 inline sal_Int32
lclGetMixedColorComp( sal_Int32 nPatt
, sal_Int32 nFill
, sal_Int32 nAlpha
)
1819 return ((nPatt
- nFill
) * nAlpha
) / 0x80 + nFill
;
1822 sal_Int32
lclGetMixedColor( sal_Int32 nPattColor
, sal_Int32 nFillColor
, sal_Int32 nAlpha
)
1825 (lclGetMixedColorComp( nPattColor
& 0xFF0000, nFillColor
& 0xFF0000, nAlpha
) & 0xFF0000) |
1826 (lclGetMixedColorComp( nPattColor
& 0x00FF00, nFillColor
& 0x00FF00, nAlpha
) & 0x00FF00) |
1827 (lclGetMixedColorComp( nPattColor
& 0x0000FF, nFillColor
& 0x0000FF, nAlpha
) & 0x0000FF);
1832 Fill::Fill( const WorkbookHelper
& rHelper
, bool bDxf
) :
1833 WorkbookHelper( rHelper
),
1838 void Fill::importPatternFill( const AttributeList
& rAttribs
)
1840 mxPatternModel
.reset( new PatternFillModel( mbDxf
) );
1841 mxPatternModel
->mnPattern
= rAttribs
.getToken( XML_patternType
, XML_none
);
1843 mxPatternModel
->mbPatternUsed
= rAttribs
.hasAttribute( XML_patternType
);
1846 void Fill::importFgColor( const AttributeList
& rAttribs
)
1848 OSL_ENSURE( mxPatternModel
.get(), "Fill::importFgColor - missing pattern data" );
1849 if( mxPatternModel
.get() )
1851 mxPatternModel
->maPatternColor
.importColor( rAttribs
);
1852 mxPatternModel
->mbPattColorUsed
= true;
1856 void Fill::importBgColor( const AttributeList
& rAttribs
)
1858 OSL_ENSURE( mxPatternModel
.get(), "Fill::importBgColor - missing pattern data" );
1859 if( mxPatternModel
.get() )
1861 mxPatternModel
->maFillColor
.importColor( rAttribs
);
1862 mxPatternModel
->mbFillColorUsed
= true;
1866 void Fill::importGradientFill( const AttributeList
& rAttribs
)
1868 mxGradientModel
.reset( new GradientFillModel
);
1869 mxGradientModel
->mnType
= rAttribs
.getToken( XML_type
, XML_linear
);
1870 mxGradientModel
->mfAngle
= rAttribs
.getDouble( XML_degree
, 0.0 );
1871 mxGradientModel
->mfLeft
= rAttribs
.getDouble( XML_left
, 0.0 );
1872 mxGradientModel
->mfRight
= rAttribs
.getDouble( XML_right
, 0.0 );
1873 mxGradientModel
->mfTop
= rAttribs
.getDouble( XML_top
, 0.0 );
1874 mxGradientModel
->mfBottom
= rAttribs
.getDouble( XML_bottom
, 0.0 );
1877 void Fill::importColor( const AttributeList
& rAttribs
, double fPosition
)
1879 OSL_ENSURE( mxGradientModel
.get(), "Fill::importColor - missing gradient data" );
1880 if( mxGradientModel
.get() && (fPosition
>= 0.0) )
1881 mxGradientModel
->maColors
[ fPosition
].importColor( rAttribs
);
1884 void Fill::importFill( SequenceInputStream
& rStrm
)
1886 SAL_WARN_IF( mbDxf
, "sc", "Fill::importFill - unexpected conditional formatting flag" );
1887 sal_Int32 nPattern
= rStrm
.readInt32();
1888 if( nPattern
== BIFF12_FILL_GRADIENT
)
1890 mxGradientModel
.reset( new GradientFillModel
);
1891 sal_Int32 nStopCount
;
1893 mxGradientModel
->readGradient( rStrm
);
1894 nStopCount
= rStrm
.readInt32();
1895 for( sal_Int32 nStop
= 0; (nStop
< nStopCount
) && !rStrm
.isEof(); ++nStop
)
1896 mxGradientModel
->readGradientStop( rStrm
, false );
1900 mxPatternModel
.reset( new PatternFillModel( mbDxf
) );
1901 mxPatternModel
->setBiffPattern( nPattern
);
1902 rStrm
>> mxPatternModel
->maPatternColor
>> mxPatternModel
->maFillColor
;
1906 void Fill::importDxfPattern( SequenceInputStream
& rStrm
)
1908 SAL_WARN_IF( !mbDxf
, "sc", "Fill::importDxfPattern - missing conditional formatting flag" );
1909 if( !mxPatternModel
)
1910 mxPatternModel
.reset( new PatternFillModel( mbDxf
) );
1911 mxPatternModel
->setBiffPattern( rStrm
.readuInt8() );
1912 mxPatternModel
->mbPatternUsed
= true;
1915 void Fill::importDxfFgColor( SequenceInputStream
& rStrm
)
1917 SAL_WARN_IF( !mbDxf
, "sc", "Fill::importDxfFgColor - missing conditional formatting flag" );
1918 if( !mxPatternModel
)
1919 mxPatternModel
.reset( new PatternFillModel( mbDxf
) );
1920 mxPatternModel
->maPatternColor
.importColor( rStrm
);
1921 mxPatternModel
->mbPattColorUsed
= true;
1924 void Fill::importDxfBgColor( SequenceInputStream
& rStrm
)
1926 SAL_WARN_IF( !mbDxf
, "sc", "Fill::importDxfBgColor - missing conditional formatting flag" );
1927 if( !mxPatternModel
)
1928 mxPatternModel
.reset( new PatternFillModel( mbDxf
) );
1929 mxPatternModel
->maFillColor
.importColor( rStrm
);
1930 mxPatternModel
->mbFillColorUsed
= true;
1933 void Fill::importDxfGradient( SequenceInputStream
& rStrm
)
1935 SAL_WARN_IF( !mbDxf
, "sc", "Fill::importDxfGradient - missing conditional formatting flag" );
1936 if( !mxGradientModel
)
1937 mxGradientModel
.reset( new GradientFillModel
);
1938 mxGradientModel
->readGradient( rStrm
);
1941 void Fill::importDxfStop( SequenceInputStream
& rStrm
)
1943 SAL_WARN_IF( !mbDxf
, "sc", "Fill::importDxfStop - missing conditional formatting flag" );
1944 if( !mxGradientModel
)
1945 mxGradientModel
.reset( new GradientFillModel
);
1946 mxGradientModel
->readGradientStop( rStrm
, true );
1949 void Fill::finalizeImport()
1951 const GraphicHelper
& rGraphicHelper
= getBaseFilter().getGraphicHelper();
1953 if( mxPatternModel
.get() )
1955 // finalize the OOXML data struct
1956 PatternFillModel
& rModel
= *mxPatternModel
;
1959 if( rModel
.mbFillColorUsed
&& (!rModel
.mbPatternUsed
|| (rModel
.mnPattern
== XML_solid
)) )
1961 rModel
.maPatternColor
= rModel
.maFillColor
;
1962 rModel
.mnPattern
= XML_solid
;
1963 rModel
.mbPattColorUsed
= rModel
.mbPatternUsed
= true;
1965 else if( !rModel
.mbFillColorUsed
&& rModel
.mbPatternUsed
&& (rModel
.mnPattern
== XML_solid
) )
1967 rModel
.mbPatternUsed
= false;
1971 // convert to API fill settings
1972 maApiData
.mbUsed
= rModel
.mbPatternUsed
;
1973 if( rModel
.mnPattern
== XML_none
)
1975 maApiData
.mnColor
= API_RGB_TRANSPARENT
;
1976 maApiData
.mbTransparent
= true;
1980 sal_Int32 nAlpha
= 0x80;
1981 switch( rModel
.mnPattern
)
1983 case XML_darkDown
: nAlpha
= 0x40; break;
1984 case XML_darkGray
: nAlpha
= 0x60; break;
1985 case XML_darkGrid
: nAlpha
= 0x40; break;
1986 case XML_darkHorizontal
: nAlpha
= 0x40; break;
1987 case XML_darkTrellis
: nAlpha
= 0x60; break;
1988 case XML_darkUp
: nAlpha
= 0x40; break;
1989 case XML_darkVertical
: nAlpha
= 0x40; break;
1990 case XML_gray0625
: nAlpha
= 0x08; break;
1991 case XML_gray125
: nAlpha
= 0x10; break;
1992 case XML_lightDown
: nAlpha
= 0x20; break;
1993 case XML_lightGray
: nAlpha
= 0x20; break;
1994 case XML_lightGrid
: nAlpha
= 0x38; break;
1995 case XML_lightHorizontal
: nAlpha
= 0x20; break;
1996 case XML_lightTrellis
: nAlpha
= 0x30; break;
1997 case XML_lightUp
: nAlpha
= 0x20; break;
1998 case XML_lightVertical
: nAlpha
= 0x20; break;
1999 case XML_mediumGray
: nAlpha
= 0x40; break;
2000 case XML_solid
: nAlpha
= 0x80; break;
2003 sal_Int32 nWinTextColor
= rGraphicHelper
.getSystemColor( XML_windowText
);
2004 sal_Int32 nWinColor
= rGraphicHelper
.getSystemColor( XML_window
);
2006 if( !rModel
.mbPattColorUsed
)
2007 rModel
.maPatternColor
.setAuto();
2008 sal_Int32 nPattColor
= rModel
.maPatternColor
.getColor( rGraphicHelper
, nWinTextColor
);
2010 if( !rModel
.mbFillColorUsed
)
2011 rModel
.maFillColor
.setAuto();
2012 sal_Int32 nFillColor
= rModel
.maFillColor
.getColor( rGraphicHelper
, nWinColor
);
2014 maApiData
.mnColor
= lclGetMixedColor( nPattColor
, nFillColor
, nAlpha
);
2015 maApiData
.mbTransparent
= false;
2018 else if( mxGradientModel
.get() && !mxGradientModel
->maColors
.empty() )
2020 GradientFillModel
& rModel
= *mxGradientModel
;
2021 maApiData
.mbUsed
= true; // no support for differential attributes
2022 GradientFillModel::ColorMap::const_iterator aIt
= rModel
.maColors
.begin();
2023 OSL_ENSURE( !aIt
->second
.isAuto(), "Fill::finalizeImport - automatic gradient color" );
2024 maApiData
.mnColor
= aIt
->second
.getColor( rGraphicHelper
, API_RGB_WHITE
);
2025 if( ++aIt
!= rModel
.maColors
.end() )
2027 OSL_ENSURE( !aIt
->second
.isAuto(), "Fill::finalizeImport - automatic gradient color" );
2028 sal_Int32 nEndColor
= aIt
->second
.getColor( rGraphicHelper
, API_RGB_WHITE
);
2029 maApiData
.mnColor
= lclGetMixedColor( maApiData
.mnColor
, nEndColor
, 0x40 );
2030 maApiData
.mbTransparent
= false;
2035 void Fill::fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
) const
2037 if( maApiData
.mbUsed
)
2039 SvxBrushItem
aBrushItem( ATTR_BACKGROUND
);
2040 if ( maApiData
.mbTransparent
)
2042 aBrushItem
.SetColor( ::Color( COL_TRANSPARENT
) );
2046 aBrushItem
.SetColor( maApiData
.mnColor
);
2048 ScfTools::PutItem( rItemSet
, aBrushItem
, bSkipPoolDefs
);
2052 void Fill::writeToPropertyMap( PropertyMap
& rPropMap
) const
2054 if( maApiData
.mbUsed
)
2056 rPropMap
.setProperty( PROP_CellBackColor
, maApiData
.mnColor
);
2057 rPropMap
.setProperty( PROP_IsCellBackgroundTransparent
, maApiData
.mbTransparent
);
2061 XfModel::XfModel() :
2068 mbFontUsed( false ),
2069 mbNumFmtUsed( false ),
2070 mbAlignUsed( false ),
2071 mbProtUsed( false ),
2072 mbBorderUsed( false ),
2077 Xf::AttrList::AttrList() : mbLatinNumFmtOnly(true) {}
2079 Xf::Xf( const WorkbookHelper
& rHelper
) :
2080 WorkbookHelper( rHelper
),
2082 maAlignment( rHelper
),
2083 maProtection( rHelper
),
2084 meRotationRef( ::com::sun::star::table::CellVertJustify2::STANDARD
),
2085 mpStyleSheet( NULL
)
2089 void Xf::importXf( const AttributeList
& rAttribs
, bool bCellXf
)
2091 maModel
.mbCellXf
= bCellXf
;
2092 maModel
.mnStyleXfId
= rAttribs
.getInteger( XML_xfId
, -1 );
2093 maModel
.mnFontId
= rAttribs
.getInteger( XML_fontId
, -1 );
2094 maModel
.mnNumFmtId
= rAttribs
.getInteger( XML_numFmtId
, -1 );
2095 maModel
.mnBorderId
= rAttribs
.getInteger( XML_borderId
, -1 );
2096 maModel
.mnFillId
= rAttribs
.getInteger( XML_fillId
, -1 );
2098 /* Default value of the apply*** attributes is dependent on context:
2099 true in cellStyleXfs element, false in cellXfs element... */
2100 maModel
.mbAlignUsed
= rAttribs
.getBool( XML_applyAlignment
, !maModel
.mbCellXf
);
2101 maModel
.mbProtUsed
= rAttribs
.getBool( XML_applyProtection
, !maModel
.mbCellXf
);
2102 maModel
.mbFontUsed
= rAttribs
.getBool( XML_applyFont
, !maModel
.mbCellXf
);
2103 maModel
.mbNumFmtUsed
= rAttribs
.getBool( XML_applyNumberFormat
, !maModel
.mbCellXf
);
2104 maModel
.mbBorderUsed
= rAttribs
.getBool( XML_applyBorder
, !maModel
.mbCellXf
);
2105 maModel
.mbAreaUsed
= rAttribs
.getBool( XML_applyFill
, !maModel
.mbCellXf
);
2108 void Xf::importAlignment( const AttributeList
& rAttribs
)
2110 maAlignment
.importAlignment( rAttribs
);
2113 void Xf::importProtection( const AttributeList
& rAttribs
)
2115 maProtection
.importProtection( rAttribs
);
2118 void Xf::importXf( SequenceInputStream
& rStrm
, bool bCellXf
)
2120 maModel
.mbCellXf
= bCellXf
;
2121 maModel
.mnStyleXfId
= rStrm
.readuInt16();
2122 maModel
.mnNumFmtId
= rStrm
.readuInt16();
2123 maModel
.mnFontId
= rStrm
.readuInt16();
2124 maModel
.mnFillId
= rStrm
.readuInt16();
2125 maModel
.mnBorderId
= rStrm
.readuInt16();
2126 sal_uInt32 nFlags
= rStrm
.readuInt32();
2127 maAlignment
.setBiff12Data( nFlags
);
2128 maProtection
.setBiff12Data( nFlags
);
2129 // used flags, see comments in Xf::setBiffUsedFlags()
2130 sal_uInt16 nUsedFlags
= rStrm
.readuInt16();
2131 maModel
.mbFontUsed
= maModel
.mbCellXf
== getFlag( nUsedFlags
, BIFF12_XF_FONT_USED
);
2132 maModel
.mbNumFmtUsed
= maModel
.mbCellXf
== getFlag( nUsedFlags
, BIFF12_XF_NUMFMT_USED
);
2133 maModel
.mbAlignUsed
= maModel
.mbCellXf
== getFlag( nUsedFlags
, BIFF12_XF_ALIGN_USED
);
2134 maModel
.mbProtUsed
= maModel
.mbCellXf
== getFlag( nUsedFlags
, BIFF12_XF_PROT_USED
);
2135 maModel
.mbBorderUsed
= maModel
.mbCellXf
== getFlag( nUsedFlags
, BIFF12_XF_BORDER_USED
);
2136 maModel
.mbAreaUsed
= maModel
.mbCellXf
== getFlag( nUsedFlags
, BIFF12_XF_AREA_USED
);
2139 void Xf::finalizeImport()
2141 // alignment and protection
2142 maAlignment
.finalizeImport();
2143 maProtection
.finalizeImport();
2146 FontRef
Xf::getFont() const
2148 return getStyles().getFont( maModel
.mnFontId
);
2151 void Xf::applyPatternToAttrList( AttrList
& rAttrs
, SCROW nRow1
, SCROW nRow2
, sal_Int32 nNumFmtId
)
2154 ScPatternAttr
& rPat
= *mpPattern
;
2155 ScDocument
& rDoc
= getScDocument();
2158 StylesBuffer
& rStyles
= getStyles();
2159 rStyles
.createCellStyle( maModel
.mnStyleXfId
);
2161 mpStyleSheet
= rStyles
.getCellStyleSheet( maModel
.mnStyleXfId
);
2164 //rDoc.ApplySelectionStyle( static_cast<ScStyleSheet&>(*mpStyleSheet), rMarkData );
2165 rPat
.SetStyleSheet(mpStyleSheet
, false);
2169 ScStyleSheetPool
* pStylePool
= rDoc
.GetStyleSheetPool();
2172 ScStyleSheet
* pStyleSheet
= static_cast<ScStyleSheet
*>(
2174 ScGlobal::GetRscString(STR_STYLENAME_STANDARD
), SFX_STYLE_FAMILY_PARA
));
2177 rPat
.SetStyleSheet( pStyleSheet
, false );
2181 if ( nNumFmtId
>= 0 )
2183 ScPatternAttr
aNumPat(rDoc
.GetPool());
2184 mnScNumFmt
= getStyles().writeNumFmtToItemSet( aNumPat
.GetItemSet(), nNumFmtId
);
2185 rPat
.GetItemSet().Put(aNumPat
.GetItemSet());
2188 if (!sc::NumFmtUtil::isLatinScript(mnScNumFmt
, rDoc
))
2189 rAttrs
.mbLatinNumFmtOnly
= false;
2191 if (rPat
.GetStyleName())
2193 // Check for a gap between the last entry and this one.
2194 bool bHasGap
= false;
2195 if (rAttrs
.maAttrs
.empty() && nRow1
> 0)
2196 // First attribute range doesn't start at row 0.
2199 if (!rAttrs
.maAttrs
.empty() && rAttrs
.maAttrs
.back().nRow
+ 1 < nRow1
)
2204 // Fill this gap with the default pattern.
2206 aEntry
.nRow
= nRow1
- 1;
2207 aEntry
.pPattern
= rDoc
.GetDefPattern();
2208 rAttrs
.maAttrs
.push_back(aEntry
);
2210 // Check if the default pattern is 'General'.
2211 if (!sc::NumFmtUtil::isLatinScript(*aEntry
.pPattern
, rDoc
))
2212 rAttrs
.mbLatinNumFmtOnly
= false;
2216 aEntry
.nRow
= nRow2
;
2217 aEntry
.pPattern
= static_cast<const ScPatternAttr
*>(&rDoc
.GetPool()->Put(rPat
));
2218 rAttrs
.maAttrs
.push_back(aEntry
);
2220 if (!sc::NumFmtUtil::isLatinScript(*aEntry
.pPattern
, rDoc
))
2221 rAttrs
.mbLatinNumFmtOnly
= false;
2225 void Xf::writeToPropertyMap( PropertyMap
& rPropMap
) const
2227 StylesBuffer
& rStyles
= getStyles();
2229 // create and set cell style.
2231 // TODO : We should gradually move things to writeToDoc(), to set cell
2232 // styles to the document directly.
2234 if( maModel
.mbFontUsed
)
2235 rStyles
.writeFontToPropertyMap( rPropMap
, maModel
.mnFontId
);
2236 if( maModel
.mbNumFmtUsed
)
2237 rStyles
.writeNumFmtToPropertyMap( rPropMap
, maModel
.mnNumFmtId
);
2238 if( maModel
.mbAlignUsed
)
2239 maAlignment
.writeToPropertyMap( rPropMap
);
2240 if( maModel
.mbProtUsed
)
2241 maProtection
.writeToPropertyMap( rPropMap
);
2242 if( maModel
.mbBorderUsed
)
2243 rStyles
.writeBorderToPropertyMap( rPropMap
, maModel
.mnBorderId
);
2244 if( maModel
.mbAreaUsed
)
2245 rStyles
.writeFillToPropertyMap( rPropMap
, maModel
.mnFillId
);
2248 void Xf::writeToPropertySet( PropertySet
& rPropSet
) const
2250 PropertyMap aPropMap
;
2251 writeToPropertyMap( aPropMap
);
2252 rPropSet
.setProperties( aPropMap
);
2255 void Xf::writeToDoc( ScDocumentImport
& rDoc
, const table::CellRangeAddress
& rRange
) const
2257 const StylesBuffer
& rStyles
= getStyles();
2262 OUString aStyleName
= rStyles
.createCellStyle(maModel
.mnStyleXfId
);
2264 ScStyleSheet
* pStyleSheet
=
2265 static_cast<ScStyleSheet
*>(
2266 rDoc
.getDoc().GetStyleSheetPool()->Find(aStyleName
, SFX_STYLE_FAMILY_PARA
));
2270 rDoc
.getDoc().ApplyStyleAreaTab(
2271 rRange
.StartColumn
, rRange
.StartRow
, rRange
.EndColumn
, rRange
.EndRow
, rRange
.Sheet
,
2276 boost::scoped_ptr
<ScPatternAttr
> pAttr(new ScPatternAttr(rDoc
.getDoc().GetPool()));
2279 SvxRotateMode eRotateMode
= SVX_ROTATE_MODE_STANDARD
;
2281 if (maModel
.mbBorderUsed
&& rStyles
.hasBorder(maModel
.mnBorderId
) && maAlignment
.getApiData().mnRotation
)
2282 eRotateMode
= SVX_ROTATE_MODE_BOTTOM
;
2284 SvxRotateModeItem
aItem(eRotateMode
, ATTR_ROTATE_MODE
);
2285 ScfTools::PutItem(pAttr
->GetItemSet(), aItem
, false);
2288 // TODO : Move more properties from writeToPropertyMap().
2290 rDoc
.getDoc().ApplyPatternAreaTab(
2291 rRange
.StartColumn
, rRange
.StartRow
, rRange
.EndColumn
, rRange
.EndRow
, rRange
.Sheet
, *pAttr
);
2294 const ::ScPatternAttr
&
2295 Xf::createPattern( bool bSkipPoolDefs
)
2297 if( mpPattern
.get() )
2299 mpPattern
.reset( new ::ScPatternAttr( getScDocument().GetPool() ) );
2300 SfxItemSet
& rItemSet
= mpPattern
->GetItemSet();
2301 /* Enables the used flags, if the formatting attributes differ from the
2302 style XF. In cell XFs Excel uses the cell attributes, if they differ
2303 from the parent style XF (even if the used flag is switched off).
2304 #109899# ...or if the respective flag is not set in parent style XF.
2306 StylesBuffer
& rStyles
= getStyles();
2308 const Xf
* pStyleXf
= isCellXf() ? rStyles
.getStyleXf( maModel
.mnStyleXfId
).get() : 0;
2309 if( pStyleXf
&& !mpStyleSheet
)
2311 rStyles
.createCellStyle( maModel
.mnStyleXfId
);
2312 mpStyleSheet
= rStyles
.getCellStyleSheet( maModel
.mnStyleXfId
);
2313 OSL_ENSURE( mpStyleSheet
, "Xf::createPattern - no parentStyle created" );
2315 const XfModel
& rStyleData
= pStyleXf
->maModel
;
2316 if( !maModel
.mbFontUsed
)
2317 maModel
.mbFontUsed
= !rStyleData
.mbFontUsed
|| (maModel
.mnFontId
!= rStyleData
.mnFontId
);
2318 if( !maModel
.mbNumFmtUsed
)
2319 maModel
.mbNumFmtUsed
= !rStyleData
.mbNumFmtUsed
|| (maModel
.mnNumFmtId
!= rStyleData
.mnNumFmtId
);
2320 if( !maModel
.mbAlignUsed
)
2321 maModel
.mbAlignUsed
= !rStyleData
.mbAlignUsed
|| !(maAlignment
.getApiData() == pStyleXf
->maAlignment
.getApiData());
2322 if( !maModel
.mbProtUsed
)
2323 maModel
.mbProtUsed
= !rStyleData
.mbProtUsed
|| !(maProtection
.getApiData() == pStyleXf
->maProtection
.getApiData());
2324 if( !maModel
.mbBorderUsed
)
2325 maModel
.mbBorderUsed
= !rStyleData
.mbBorderUsed
|| !rStyles
.equalBorders( maModel
.mnBorderId
, rStyleData
.mnBorderId
);
2326 if( !maModel
.mbAreaUsed
)
2327 maModel
.mbAreaUsed
= !rStyleData
.mbAreaUsed
|| !rStyles
.equalFills( maModel
.mnFillId
, rStyleData
.mnFillId
);
2330 if( maModel
.mbProtUsed
)
2332 maProtection
.fillToItemSet( rItemSet
, bSkipPoolDefs
);
2336 if( maModel
.mbFontUsed
)
2338 rStyles
.writeFontToItemSet( rItemSet
, maModel
.mnFontId
, bSkipPoolDefs
);
2342 if( maModel
.mbNumFmtUsed
)
2344 mnScNumFmt
= rStyles
.writeNumFmtToItemSet( rItemSet
, maModel
.mnNumFmtId
, bSkipPoolDefs
);
2347 if( maModel
.mbAlignUsed
)
2349 maAlignment
.fillToItemSet( rItemSet
, bSkipPoolDefs
);
2353 if( maModel
.mbBorderUsed
)
2355 rStyles
.writeBorderToItemSet( rItemSet
, maModel
.mnBorderId
, bSkipPoolDefs
);
2359 if( maModel
.mbAreaUsed
)
2361 rStyles
.writeFillToItemSet( rItemSet
, maModel
.mnFillId
, bSkipPoolDefs
);
2364 /* #i38709# Decide which rotation reference mode to use. If any outer
2365 border line of the cell is set (either explicitly or via cell style),
2366 and the cell contents are rotated, set rotation reference to bottom of
2367 cell. This causes the borders to be painted rotated with the text. */
2368 if( const Alignment
* pAlignment
= maModel
.mbAlignUsed
? &maAlignment
: (pStyleXf
? &pStyleXf
->maAlignment
: 0) )
2370 SvxRotateMode eRotateMode
= SVX_ROTATE_MODE_STANDARD
;
2371 sal_Int32 nBorderId
= maModel
.mbBorderUsed
? maModel
.mnBorderId
: (pStyleXf
? pStyleXf
->maModel
.mnBorderId
: -1);
2372 if( const Border
* pBorder
= rStyles
.getBorder( nBorderId
).get() )
2374 if( (pAlignment
->getApiData().mnRotation
!= 0) && pBorder
->getApiData().hasAnyOuterBorder() )
2376 meRotationRef
= ::com::sun::star::table::CellVertJustify2::BOTTOM
;
2377 eRotateMode
= SVX_ROTATE_MODE_BOTTOM
;
2380 ScfTools::PutItem( rItemSet
, SvxRotateModeItem( eRotateMode
, ATTR_ROTATE_MODE
), bSkipPoolDefs
);
2386 Dxf::Dxf( const WorkbookHelper
& rHelper
) :
2387 WorkbookHelper( rHelper
)
2391 FontRef
Dxf::createFont( bool bAlwaysNew
)
2393 if( bAlwaysNew
|| !mxFont
)
2394 mxFont
.reset( new Font( *this, true ) );
2398 BorderRef
Dxf::createBorder( bool bAlwaysNew
)
2400 if( bAlwaysNew
|| !mxBorder
)
2401 mxBorder
.reset( new Border( *this, true ) );
2405 FillRef
Dxf::createFill( bool bAlwaysNew
)
2407 if( bAlwaysNew
|| !mxFill
)
2408 mxFill
.reset( new Fill( *this, true ) );
2412 void Dxf::importNumFmt( const AttributeList
& rAttribs
)
2414 // don't propagate number formats defined in Dxf entries
2415 // they can have the same id ( but different format codes ) as those
2416 // defined globally earlier. We discard the id defined in XML_numFmtId
2417 // and generate one ourselves ( this assumes that the normal numberformat
2418 // import has already taken place )
2419 sal_Int32 nNumFmtId
= getStyles().nextFreeNumFmtId();
2420 OUString aFmtCode
= rAttribs
.getXString( XML_formatCode
, OUString() );
2421 mxNumFmt
= getStyles().createNumFmt( nNumFmtId
, aFmtCode
);
2424 void Dxf::importDxf( SequenceInputStream
& rStrm
)
2426 sal_Int32 nNumFmtId
= -1;
2428 sal_uInt16 nRecCount
;
2429 rStrm
.skip( 4 ); // flags
2430 nRecCount
= rStrm
.readuInt16();
2431 for( sal_uInt16 nRec
= 0; !rStrm
.isEof() && (nRec
< nRecCount
); ++nRec
)
2433 sal_uInt16 nSubRecId
, nSubRecSize
;
2434 sal_Int64 nRecEnd
= rStrm
.tell();
2435 nSubRecId
= rStrm
.readuInt16();
2436 nSubRecSize
= rStrm
.readuInt16();
2437 nRecEnd
+= nSubRecSize
;
2440 case BIFF12_DXF_FILL_PATTERN
: createFill( false )->importDxfPattern( rStrm
); break;
2441 case BIFF12_DXF_FILL_FGCOLOR
: createFill( false )->importDxfFgColor( rStrm
); break;
2442 case BIFF12_DXF_FILL_BGCOLOR
: createFill( false )->importDxfBgColor( rStrm
); break;
2443 case BIFF12_DXF_FILL_GRADIENT
: createFill( false )->importDxfGradient( rStrm
); break;
2444 case BIFF12_DXF_FILL_STOP
: createFill( false )->importDxfStop( rStrm
); break;
2445 case BIFF12_DXF_FONT_COLOR
: createFont( false )->importDxfColor( rStrm
); break;
2446 case BIFF12_DXF_BORDER_TOP
: createBorder( false )->importDxfBorder( XLS_TOKEN( top
), rStrm
); break;
2447 case BIFF12_DXF_BORDER_BOTTOM
: createBorder( false )->importDxfBorder( XLS_TOKEN( bottom
), rStrm
); break;
2448 case BIFF12_DXF_BORDER_LEFT
: createBorder( false )->importDxfBorder( XLS_TOKEN( left
), rStrm
); break;
2449 case BIFF12_DXF_BORDER_RIGHT
: createBorder( false )->importDxfBorder( XLS_TOKEN( right
), rStrm
); break;
2450 case BIFF12_DXF_FONT_NAME
: createFont( false )->importDxfName( rStrm
); break;
2451 case BIFF12_DXF_FONT_WEIGHT
: createFont( false )->importDxfWeight( rStrm
); break;
2452 case BIFF12_DXF_FONT_UNDERLINE
: createFont( false )->importDxfUnderline( rStrm
); break;
2453 case BIFF12_DXF_FONT_ESCAPEMENT
: createFont( false )->importDxfEscapement( rStrm
); break;
2454 case BIFF12_DXF_FONT_ITALIC
: createFont( false )->importDxfFlag( XML_i
, rStrm
); break;
2455 case BIFF12_DXF_FONT_STRIKE
: createFont( false )->importDxfFlag( XML_strike
, rStrm
); break;
2456 case BIFF12_DXF_FONT_OUTLINE
: createFont( false )->importDxfFlag( XML_outline
, rStrm
); break;
2457 case BIFF12_DXF_FONT_SHADOW
: createFont( false )->importDxfFlag( XML_shadow
, rStrm
); break;
2458 case BIFF12_DXF_FONT_HEIGHT
: createFont( false )->importDxfHeight( rStrm
); break;
2459 case BIFF12_DXF_FONT_SCHEME
: createFont( false )->importDxfScheme( rStrm
); break;
2460 case BIFF12_DXF_NUMFMT_CODE
: aFmtCode
= BiffHelper::readString( rStrm
, false ); break;
2461 case BIFF12_DXF_NUMFMT_ID
: nNumFmtId
= rStrm
.readuInt16(); break;
2463 rStrm
.seek( nRecEnd
);
2465 OSL_ENSURE( !rStrm
.isEof() && (rStrm
.getRemaining() == 0), "Dxf::importDxf - unexpected remaining data" );
2466 mxNumFmt
= getStyles().createNumFmt( nNumFmtId
, aFmtCode
);
2469 void Dxf::finalizeImport()
2472 mxFont
->finalizeImport();
2474 // number format already finalized by the number formats buffer
2475 if( mxAlignment
.get() )
2477 mxAlignment
->finalizeImport();
2478 // how do we detect RTL when text dir is OOX_XF_CONTEXT? ( seems you
2479 // would need access to the cell content, which we don't here )
2480 if ( mxAlignment
->getModel().mnTextDir
== OOX_XF_TEXTDIR_RTL
)
2483 if( mxProtection
.get() )
2484 mxProtection
->finalizeImport();
2485 if( mxBorder
.get() )
2487 mxBorder
->finalizeImport( bRTL
);
2490 mxFill
->finalizeImport();
2493 void Dxf::fillToItemSet( SfxItemSet
& rSet
) const
2496 mxFont
->fillToItemSet(rSet
, false);
2498 mxNumFmt
->fillToItemSet(rSet
);
2500 mxAlignment
->fillToItemSet(rSet
);
2502 mxProtection
->fillToItemSet(rSet
);
2504 mxBorder
->fillToItemSet(rSet
);
2506 mxFill
->fillToItemSet(rSet
);
2511 const sal_Char
* const spcStyleNamePrefix
= "Excel Built-in ";
2512 const sal_Char
* const sppcStyleNames
[] =
2515 "RowLevel_", // outline level will be appended
2516 "ColLevel_", // outline level will be appended
2520 "Comma [0]", // new in BIFF4
2522 "Hyperlink", // new in BIFF8
2523 "Followed Hyperlink",
2524 "Note", // new in OOX
2569 const sal_Int32 snStyleNamesCount
= static_cast< sal_Int32
>( SAL_N_ELEMENTS( sppcStyleNames
) );
2571 OUString
lclGetBuiltinStyleName( sal_Int32 nBuiltinId
, const OUString
& rName
, sal_Int32 nLevel
= 0 )
2573 OSL_ENSURE( (0 <= nBuiltinId
) && (nBuiltinId
< snStyleNamesCount
), "lclGetBuiltinStyleName - unknown built-in style" );
2574 OUStringBuffer aStyleName
;
2575 aStyleName
.appendAscii( spcStyleNamePrefix
);
2576 if( (0 <= nBuiltinId
) && (nBuiltinId
< snStyleNamesCount
) && (sppcStyleNames
[ nBuiltinId
] != 0) )
2577 aStyleName
.appendAscii( sppcStyleNames
[ nBuiltinId
] );
2578 else if( !rName
.isEmpty() )
2579 aStyleName
.append( rName
);
2581 aStyleName
.append( nBuiltinId
);
2582 if( (nBuiltinId
== OOX_STYLE_ROWLEVEL
) || (nBuiltinId
== OOX_STYLE_COLLEVEL
) )
2583 aStyleName
.append( nLevel
);
2584 return aStyleName
.makeStringAndClear();
2587 OUString
lclCreateStyleName( const CellStyleModel
& rModel
)
2589 return rModel
.mbBuiltin
? lclGetBuiltinStyleName( rModel
.mnBuiltinId
, rModel
.maName
, rModel
.mnLevel
) : rModel
.maName
;
2594 CellStyleModel::CellStyleModel() :
2604 bool CellStyleModel::isBuiltin() const
2606 return mbBuiltin
&& (mnBuiltinId
>= 0);
2609 bool CellStyleModel::isDefaultStyle() const
2611 return mbBuiltin
&& (mnBuiltinId
== OOX_STYLE_NORMAL
);
2614 CellStyle::CellStyle( const WorkbookHelper
& rHelper
) :
2615 WorkbookHelper( rHelper
),
2617 mpStyleSheet( NULL
)
2621 void CellStyle::importCellStyle( const AttributeList
& rAttribs
)
2623 maModel
.maName
= rAttribs
.getXString( XML_name
, OUString() );
2624 maModel
.mnXfId
= rAttribs
.getInteger( XML_xfId
, -1 );
2625 maModel
.mnBuiltinId
= rAttribs
.getInteger( XML_builtinId
, -1 );
2626 maModel
.mnLevel
= rAttribs
.getInteger( XML_iLevel
, 0 );
2627 maModel
.mbBuiltin
= rAttribs
.hasAttribute( XML_builtinId
);
2628 maModel
.mbCustom
= rAttribs
.getBool( XML_customBuiltin
, false );
2629 maModel
.mbHidden
= rAttribs
.getBool( XML_hidden
, false );
2632 void CellStyle::importCellStyle( SequenceInputStream
& rStrm
)
2635 maModel
.mnXfId
= rStrm
.readInt32();
2636 nFlags
= rStrm
.readuInt16();
2637 maModel
.mnBuiltinId
= rStrm
.readInt8();
2638 maModel
.mnLevel
= rStrm
.readInt8();
2639 rStrm
>> maModel
.maName
;
2640 maModel
.mbBuiltin
= getFlag( nFlags
, BIFF12_CELLSTYLE_BUILTIN
);
2641 maModel
.mbCustom
= getFlag( nFlags
, BIFF12_CELLSTYLE_CUSTOM
);
2642 maModel
.mbHidden
= getFlag( nFlags
, BIFF12_CELLSTYLE_HIDDEN
);
2645 void CellStyle::createCellStyle()
2648 // #i1624# #i1768# ignore unnamed user styles
2649 bool bDefStyle
= maModel
.isDefaultStyle();
2652 if ( bDefStyle
&& maFinalName
.isEmpty() )
2653 maFinalName
= ScGlobal::GetRscString( STR_STYLENAME_STANDARD
);
2654 mbCreated
= maFinalName
.isEmpty();
2657 if( !mbCreated
&& !mpStyleSheet
)
2659 bool bCreatePattern
= false;
2660 Xf
* pXF
= getStyles().getStyleXf( maModel
.mnXfId
).get();
2661 ::ScDocument
& rDoc
= getScDocument();
2665 // use existing "Default" style sheet
2666 mpStyleSheet
= static_cast< ScStyleSheet
* >( static_cast< ScStyleSheetPool
* >( rDoc
.GetStyleSheetPool() )->Find(
2667 ScGlobal::GetRscString( STR_STYLENAME_STANDARD
), SFX_STYLE_FAMILY_PARA
) );
2668 OSL_ENSURE( mpStyleSheet
, "CellStyle::createStyle - Default style not found" );
2669 bCreatePattern
= true;
2673 mpStyleSheet
= static_cast< ScStyleSheet
* >( static_cast< ScStyleSheetPool
* >( rDoc
.GetStyleSheetPool() )->Find( maFinalName
, SFX_STYLE_FAMILY_PARA
) );
2676 mpStyleSheet
= &static_cast< ScStyleSheet
& >( rDoc
.GetStyleSheetPool()->Make( maFinalName
, SFX_STYLE_FAMILY_PARA
, SFXSTYLEBIT_USERDEF
) );
2677 bCreatePattern
= true;
2681 // bDefStyle==true omits default pool items in CreatePattern()
2682 if( bCreatePattern
&& mpStyleSheet
&& pXF
)
2683 mpStyleSheet
->GetItemSet().Put( pXF
->createPattern( bDefStyle
).GetItemSet() );
2687 void CellStyle::finalizeImport( const OUString
& rFinalName
)
2689 maFinalName
= rFinalName
;
2690 if( !maModel
.isBuiltin() || maModel
.mbCustom
)
2694 CellStyleBuffer::CellStyleBuffer( const WorkbookHelper
& rHelper
) :
2695 WorkbookHelper( rHelper
)
2699 CellStyleRef
CellStyleBuffer::importCellStyle( const AttributeList
& rAttribs
)
2701 CellStyleRef
xCellStyle( new CellStyle( *this ) );
2702 xCellStyle
->importCellStyle( rAttribs
);
2703 insertCellStyle( xCellStyle
);
2707 CellStyleRef
CellStyleBuffer::importCellStyle( SequenceInputStream
& rStrm
)
2709 CellStyleRef
xCellStyle( new CellStyle( *this ) );
2710 xCellStyle
->importCellStyle( rStrm
);
2711 insertCellStyle( xCellStyle
);
2715 void CellStyleBuffer::finalizeImport()
2717 // calculate final names of all styles
2718 typedef RefMap
< OUString
, CellStyle
, IgnoreCaseCompare
> CellStyleNameMap
;
2719 CellStyleNameMap aCellStyles
;
2720 CellStyleVector aConflictNameStyles
;
2722 /* First, reserve style names that are built-in in Calc. This causes that
2723 imported cell styles get different unused names and thus do not try to
2724 overwrite these built-in styles. For BIFF4 workbooks (which contain a
2725 separate list of cell styles per sheet), reserve all existing styles if
2726 current sheet is not the first sheet (this styles buffer will be
2727 constructed again for every new sheet). This will create unique names
2728 for styles in different sheets with the same name. Assuming that the
2729 BIFF4W import filter is never used to import from clipboard... */
2730 bool bReserveAll
= (getFilterType() == FILTER_BIFF
) && (getBiff() == BIFF4
) && isWorkbookFile() && (getCurrentSheetIndex() > 0);
2733 // unfortunately, com.sun.star.style.StyleFamily does not implement XEnumerationAccess...
2734 Reference
< XIndexAccess
> xStyleFamilyIA( getStyleFamily( false ), UNO_QUERY_THROW
);
2735 for( sal_Int32 nIndex
= 0, nCount
= xStyleFamilyIA
->getCount(); nIndex
< nCount
; ++nIndex
)
2737 Reference
< XStyle
> xStyle( xStyleFamilyIA
->getByIndex( nIndex
), UNO_QUERY_THROW
);
2738 if( bReserveAll
|| !xStyle
->isUserDefined() )
2740 // create an empty entry by using ::std::map<>::operator[]
2741 aCellStyles
[ xStyle
->getName() ];
2749 /* Calculate names of built-in styles. Store styles with reserved names
2750 in the aConflictNameStyles list. */
2751 for( CellStyleVector::iterator aIt
= maBuiltinStyles
.begin(), aEnd
= maBuiltinStyles
.end(); aIt
!= aEnd
; ++aIt
)
2753 const CellStyleModel
& rModel
= (*aIt
)->getModel();
2754 if (rModel
.isDefaultStyle())
2757 OUString aStyleName
= lclCreateStyleName( rModel
);
2758 /* If a builtin style entry already exists, and we do not reserve all
2759 existing styles, we just stick with the last definition and ignore
2760 the preceding ones. */
2761 if( bReserveAll
&& (aCellStyles
.find( aStyleName
) != aCellStyles
.end()) )
2762 aConflictNameStyles
.push_back( *aIt
);
2764 aCellStyles
[ aStyleName
] = *aIt
;
2767 /* Calculate names of user defined styles. Store styles with reserved
2768 names in the aConflictNameStyles list. */
2769 for( CellStyleVector::iterator aIt
= maUserStyles
.begin(), aEnd
= maUserStyles
.end(); aIt
!= aEnd
; ++aIt
)
2771 const CellStyleModel
& rModel
= (*aIt
)->getModel();
2772 OUString aStyleName
= lclCreateStyleName( rModel
);
2773 // #i1624# #i1768# ignore unnamed user styles
2774 if( aStyleName
.getLength() > 0 )
2776 if( aCellStyles
.find( aStyleName
) != aCellStyles
.end() )
2777 aConflictNameStyles
.push_back( *aIt
);
2779 aCellStyles
[ aStyleName
] = *aIt
;
2783 // find unused names for all styles with conflicting names
2784 // having the index counter outside the loop prevents performance problems with opening some pathological documents (tdf#62095)
2785 sal_Int32 nIndex
= 0;
2786 for( CellStyleVector::iterator aIt
= aConflictNameStyles
.begin(), aEnd
= aConflictNameStyles
.end(); aIt
!= aEnd
; ++aIt
)
2788 const CellStyleModel
& rModel
= (*aIt
)->getModel();
2789 OUString aStyleName
= lclCreateStyleName( rModel
);
2790 OUString aUnusedName
;
2793 aUnusedName
= OUStringBuffer( aStyleName
).append( ' ' ).append( ++nIndex
).makeStringAndClear();
2795 while( aCellStyles
.find( aUnusedName
) != aCellStyles
.end() );
2796 aCellStyles
[ aUnusedName
] = *aIt
;
2799 // set final names and create user-defined and modified built-in cell styles
2800 aCellStyles
.forEachMemWithKey( &CellStyle::finalizeImport
);
2803 sal_Int32
CellStyleBuffer::getDefaultXfId() const
2805 return mxDefStyle
.get() ? mxDefStyle
->getModel().mnXfId
: -1;
2808 OUString
CellStyleBuffer::getDefaultStyleName() const
2810 return createCellStyle( mxDefStyle
);
2813 OUString
CellStyleBuffer::createCellStyle( sal_Int32 nXfId
) const
2815 return createCellStyle( maStylesByXf
.get( nXfId
) );
2818 ::ScStyleSheet
* CellStyleBuffer::getCellStyleSheet( sal_Int32 nXfId
) const
2820 return getCellStyleSheet( maStylesByXf
.get( nXfId
) );
2823 // private --------------------------------------------------------------------
2825 void CellStyleBuffer::insertCellStyle( CellStyleRef xCellStyle
)
2827 const CellStyleModel
& rModel
= xCellStyle
->getModel();
2828 if( rModel
.mnXfId
>= 0 )
2830 // insert into the built-in map or user defined map
2831 (rModel
.isBuiltin() ? maBuiltinStyles
: maUserStyles
).push_back( xCellStyle
);
2833 // insert into the XF identifier map
2834 OSL_ENSURE( maStylesByXf
.count( rModel
.mnXfId
) == 0, "CellStyleBuffer::insertCellStyle - multiple styles with equal XF identifier" );
2835 maStylesByXf
[ rModel
.mnXfId
] = xCellStyle
;
2837 // remember default cell style
2838 if( rModel
.isDefaultStyle() )
2839 mxDefStyle
= xCellStyle
;
2843 ::ScStyleSheet
* CellStyleBuffer::getCellStyleSheet( const CellStyleRef
& rxCellStyle
)
2845 ::ScStyleSheet
* pStyleSheet
= NULL
;
2846 if ( rxCellStyle
.get() )
2847 pStyleSheet
= rxCellStyle
->getStyleSheet();
2851 OUString
CellStyleBuffer::createCellStyle( const CellStyleRef
& rxCellStyle
)
2853 if( rxCellStyle
.get() )
2855 rxCellStyle
->createCellStyle();
2856 const OUString
& rStyleName
= rxCellStyle
->getFinalStyleName();
2857 if( !rStyleName
.isEmpty() )
2860 // on error: fallback to default style
2861 return lclGetBuiltinStyleName( OOX_STYLE_NORMAL
, OUString() );
2864 AutoFormatModel::AutoFormatModel() :
2865 mnAutoFormatId( 0 ),
2866 mbApplyNumFmt( false ),
2867 mbApplyFont( false ),
2868 mbApplyAlignment( false ),
2869 mbApplyBorder( false ),
2870 mbApplyFill( false ),
2871 mbApplyProtection( false )
2875 StylesBuffer::StylesBuffer( const WorkbookHelper
& rHelper
) :
2876 WorkbookHelper( rHelper
),
2877 maPalette( rHelper
),
2878 maNumFmts( rHelper
),
2879 maCellStyles( rHelper
)
2883 FontRef
StylesBuffer::createFont( sal_Int32
* opnFontId
)
2885 if( opnFontId
) *opnFontId
= static_cast< sal_Int32
>( maFonts
.size() );
2886 FontRef
xFont( new Font( *this, false ) );
2887 maFonts
.push_back( xFont
);
2891 NumberFormatRef
StylesBuffer::createNumFmt( sal_Int32 nNumFmtId
, const OUString
& rFmtCode
)
2893 return maNumFmts
.createNumFmt( nNumFmtId
, rFmtCode
);
2896 sal_Int32
StylesBuffer::nextFreeNumFmtId()
2898 return maNumFmts
.nextFreeId();
2901 BorderRef
StylesBuffer::createBorder( sal_Int32
* opnBorderId
)
2903 if( opnBorderId
) *opnBorderId
= static_cast< sal_Int32
>( maBorders
.size() );
2904 BorderRef
xBorder( new Border( *this, false ) );
2905 maBorders
.push_back( xBorder
);
2909 FillRef
StylesBuffer::createFill( sal_Int32
* opnFillId
)
2911 if( opnFillId
) *opnFillId
= static_cast< sal_Int32
>( maFills
.size() );
2912 FillRef
xFill( new Fill( *this, false ) );
2913 maFills
.push_back( xFill
);
2917 XfRef
StylesBuffer::createCellXf( sal_Int32
* opnXfId
)
2919 if( opnXfId
) *opnXfId
= static_cast< sal_Int32
>( maCellXfs
.size() );
2920 XfRef
xXf( new Xf( *this ) );
2921 maCellXfs
.push_back( xXf
);
2925 XfRef
StylesBuffer::createStyleXf( sal_Int32
* opnXfId
)
2927 if( opnXfId
) *opnXfId
= static_cast< sal_Int32
>( maStyleXfs
.size() );
2928 XfRef
xXf( new Xf( *this ) );
2929 maStyleXfs
.push_back( xXf
);
2933 DxfRef
StylesBuffer::createDxf( sal_Int32
* opnDxfId
)
2935 if( opnDxfId
) *opnDxfId
= static_cast< sal_Int32
>( maDxfs
.size() );
2936 DxfRef
xDxf( new Dxf( *this ) );
2937 maDxfs
.push_back( xDxf
);
2941 void StylesBuffer::importPaletteColor( const AttributeList
& rAttribs
)
2943 maPalette
.importPaletteColor( rAttribs
);
2946 NumberFormatRef
StylesBuffer::importNumFmt( const AttributeList
& rAttribs
)
2948 return maNumFmts
.importNumFmt( rAttribs
);
2951 CellStyleRef
StylesBuffer::importCellStyle( const AttributeList
& rAttribs
)
2953 return maCellStyles
.importCellStyle( rAttribs
);
2956 void StylesBuffer::importPaletteColor( SequenceInputStream
& rStrm
)
2958 maPalette
.importPaletteColor( rStrm
);
2961 void StylesBuffer::importNumFmt( SequenceInputStream
& rStrm
)
2963 maNumFmts
.importNumFmt( rStrm
);
2966 void StylesBuffer::importCellStyle( SequenceInputStream
& rStrm
)
2968 maCellStyles
.importCellStyle( rStrm
);
2971 void StylesBuffer::finalizeImport()
2973 // fonts first, are needed to finalize unit converter and XFs below
2974 maFonts
.forEachMem( &Font::finalizeImport
);
2975 // finalize unit coefficients after default font is known
2976 getUnitConverter().finalizeImport();
2978 maNumFmts
.finalizeImport();
2979 // borders and fills
2980 // is there a document wide RTL setting that we
2981 // would/could need to pass to finalizeImport here ?
2982 maBorders
.forEachMem( &Border::finalizeImport
, false );
2983 maFills
.forEachMem( &Fill::finalizeImport
);
2984 // style XFs and cell XFs
2985 maStyleXfs
.forEachMem( &Xf::finalizeImport
);
2986 maCellXfs
.forEachMem( &Xf::finalizeImport
);
2987 // built-in and user defined cell styles
2988 maCellStyles
.finalizeImport();
2989 // differential formatting (for conditional formatting)
2990 maDxfs
.forEachMem( &Dxf::finalizeImport
);
2993 sal_Int32
StylesBuffer::getPaletteColor( sal_Int32 nPaletteIdx
) const
2995 return maPalette
.getColor( nPaletteIdx
);
2998 FontRef
StylesBuffer::getFont( sal_Int32 nFontId
) const
3000 return maFonts
.get( nFontId
);
3003 BorderRef
StylesBuffer::getBorder( sal_Int32 nBorderId
) const
3005 return maBorders
.get( nBorderId
);
3008 XfRef
StylesBuffer::getCellXf( sal_Int32 nXfId
) const
3010 return maCellXfs
.get( nXfId
);
3013 XfRef
StylesBuffer::getStyleXf( sal_Int32 nXfId
) const
3015 return maStyleXfs
.get( nXfId
);
3018 FontRef
StylesBuffer::getFontFromCellXf( sal_Int32 nXfId
) const
3021 if( const Xf
* pXf
= getCellXf( nXfId
).get() )
3022 xFont
= pXf
->getFont();
3026 FontRef
StylesBuffer::getDefaultFont() const
3029 if( const Xf
* pXf
= getStyleXf( maCellStyles
.getDefaultXfId() ).get() )
3030 xDefFont
= pXf
->getFont();
3031 // no font from styles - try first loaded font (e.g. BIFF2)
3033 xDefFont
= maFonts
.get( 0 );
3034 OSL_ENSURE( xDefFont
.get(), "StylesBuffer::getDefaultFont - no default font found" );
3038 const FontModel
& StylesBuffer::getDefaultFontModel() const
3040 FontRef xDefFont
= getDefaultFont();
3041 return xDefFont
.get() ? xDefFont
->getModel() : getTheme().getDefaultFontModel();
3044 bool StylesBuffer::equalBorders( sal_Int32 nBorderId1
, sal_Int32 nBorderId2
) const
3046 if( nBorderId1
== nBorderId2
)
3049 switch( getFilterType() )
3052 // in OOXML, borders are assumed to be unique
3057 // in BIFF, a new border entry has been created for every XF
3058 const Border
* pBorder1
= maBorders
.get( nBorderId1
).get();
3059 const Border
* pBorder2
= maBorders
.get( nBorderId2
).get();
3060 return pBorder1
&& pBorder2
&& (pBorder1
->getApiData() == pBorder2
->getApiData());
3063 case FILTER_UNKNOWN
:
3069 bool StylesBuffer::equalFills( sal_Int32 nFillId1
, sal_Int32 nFillId2
) const
3071 if( nFillId1
== nFillId2
)
3074 switch( getFilterType() )
3077 // in OOXML, fills are assumed to be unique
3082 // in BIFF, a new fill entry has been created for every XF
3083 const Fill
* pFill1
= maFills
.get( nFillId1
).get();
3084 const Fill
* pFill2
= maFills
.get( nFillId2
).get();
3085 return pFill1
&& pFill2
&& (pFill1
->getApiData() == pFill2
->getApiData());
3088 case FILTER_UNKNOWN
:
3094 OUString
StylesBuffer::getDefaultStyleName() const
3096 return maCellStyles
.getDefaultStyleName();
3099 OUString
StylesBuffer::createCellStyle( sal_Int32 nXfId
) const
3101 return maCellStyles
.createCellStyle( nXfId
);
3104 ::ScStyleSheet
* StylesBuffer::getCellStyleSheet( sal_Int32 nXfId
) const
3106 return maCellStyles
.getCellStyleSheet( nXfId
);
3109 OUString
StylesBuffer::createDxfStyle( sal_Int32 nDxfId
) const
3111 OUString
& rStyleName
= maDxfStyles
[ nDxfId
];
3112 if (!rStyleName
.isEmpty())
3115 if (Dxf
* pDxf
= maDxfs
.get(nDxfId
).get())
3117 rStyleName
= OUStringBuffer("ConditionalStyle_").append(nDxfId
+ 1).makeStringAndClear();
3119 // Create a cell style. This may overwrite an existing style if
3120 // one with the same name exists.
3121 ScStyleSheet
& rStyleSheet
= ScfTools::MakeCellStyleSheet(
3122 *getScDocument().GetStyleSheetPool(), rStyleName
, true);
3124 rStyleSheet
.ResetParent();
3125 SfxItemSet
& rStyleItemSet
=
3126 rStyleSheet
.GetItemSet();
3128 pDxf
->fillToItemSet(rStyleItemSet
);
3131 // on error: fallback to default style
3132 if (rStyleName
.isEmpty())
3133 rStyleName
= maCellStyles
.getDefaultStyleName();
3138 void StylesBuffer::writeFontToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nFontId
, bool bSkipPoolDefs
) const
3140 if( Font
* pFont
= maFonts
.get( nFontId
).get() )
3141 pFont
->fillToItemSet( rItemSet
, false, bSkipPoolDefs
);
3144 void StylesBuffer::writeFontToPropertyMap( PropertyMap
& rPropMap
, sal_Int32 nFontId
) const
3146 if( Font
* pFont
= maFonts
.get( nFontId
).get() )
3147 pFont
->writeToPropertyMap( rPropMap
, FONT_PROPTYPE_CELL
);
3150 sal_uLong
StylesBuffer::writeNumFmtToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nNumFmtId
, bool bSkipPoolDefs
) const
3152 return maNumFmts
.fillToItemSet( rItemSet
, nNumFmtId
, bSkipPoolDefs
);
3155 void StylesBuffer::writeNumFmtToPropertyMap( PropertyMap
& rPropMap
, sal_Int32 nNumFmtId
) const
3157 maNumFmts
.writeToPropertyMap( rPropMap
, nNumFmtId
);
3160 void StylesBuffer::writeBorderToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nBorderId
, bool bSkipPoolDefs
) const
3162 if( Border
* pBorder
= maBorders
.get( nBorderId
).get() )
3163 pBorder
->fillToItemSet( rItemSet
, bSkipPoolDefs
);
3166 void StylesBuffer::writeBorderToPropertyMap( PropertyMap
& rPropMap
, sal_Int32 nBorderId
) const
3168 if( Border
* pBorder
= maBorders
.get( nBorderId
).get() )
3169 pBorder
->writeToPropertyMap( rPropMap
);
3172 void StylesBuffer::writeFillToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nFillId
, bool bSkipPoolDefs
) const
3174 if( Fill
* pFill
= maFills
.get( nFillId
).get() )
3175 pFill
->fillToItemSet( rItemSet
, bSkipPoolDefs
);
3178 void StylesBuffer::writeFillToPropertyMap( PropertyMap
& rPropMap
, sal_Int32 nFillId
) const
3180 if( Fill
* pFill
= maFills
.get( nFillId
).get() )
3181 pFill
->writeToPropertyMap( rPropMap
);
3184 bool operator==( const XfModel
& rXfModel1
, const XfModel
& rXfModel2
)
3186 return ( rXfModel1
.mbCellXf
== rXfModel2
.mbCellXf
&&
3187 rXfModel1
.mnStyleXfId
== rXfModel2
.mnStyleXfId
&&
3188 rXfModel1
.mbFontUsed
== rXfModel2
.mbFontUsed
&&
3189 rXfModel1
.mnFontId
== rXfModel2
.mnFontId
&&
3190 rXfModel1
.mbNumFmtUsed
== rXfModel2
.mbNumFmtUsed
&&
3191 rXfModel1
.mnNumFmtId
== rXfModel2
.mnNumFmtId
&&
3192 rXfModel1
.mbAlignUsed
== rXfModel2
.mbAlignUsed
&&
3193 rXfModel1
.mbBorderUsed
== rXfModel2
.mbBorderUsed
&&
3194 rXfModel1
.mnBorderId
== rXfModel2
.mnBorderId
&&
3195 rXfModel1
.mbAreaUsed
== rXfModel2
.mbAreaUsed
&&
3196 rXfModel1
.mnFillId
== rXfModel2
.mnFillId
&&
3197 rXfModel1
.mbProtUsed
== rXfModel2
.mbProtUsed
);
3200 bool operator==( const Xf
& rXf1
, const Xf
& rXf2
)
3202 if ( rXf1
.maModel
== rXf2
.maModel
)
3204 if ( rXf1
.maModel
.mbAlignUsed
)
3206 if ( !( rXf1
.maAlignment
.getApiData() == rXf2
.maAlignment
.getApiData() ) )
3209 if ( rXf1
.maModel
.mbProtUsed
)
3211 if ( !( rXf1
.maProtection
.getApiData() == rXf2
.maProtection
.getApiData() ) )
3219 void StylesBuffer::writeCellXfToPropertySet( PropertySet
& rPropSet
, sal_Int32 nXfId
) const
3221 if( Xf
* pXf
= maCellXfs
.get( nXfId
).get() )
3222 pXf
->writeToPropertySet( rPropSet
);
3225 void StylesBuffer::writeCellXfToDoc(
3226 ScDocumentImport
& rDoc
, const table::CellRangeAddress
& rRange
, sal_Int32 nXfId
) const
3228 Xf
* pXf
= maCellXfs
.get(nXfId
).get();
3232 pXf
->writeToDoc(rDoc
, rRange
);
3235 bool StylesBuffer::hasBorder( sal_Int32 nBorderId
) const
3237 Border
* pBorder
= maBorders
.get( nBorderId
).get();
3238 return pBorder
&& pBorder
->hasBorder();
3244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */