1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_XISTYLE_HXX
29 #define SC_XISTYLE_HXX
32 #include <tools/mempool.hxx>
33 #include "rangelst.hxx"
34 #include "patattr.hxx"
35 #include "xladdress.hxx"
36 #include "xlstyle.hxx"
41 /* ============================================================================
42 - Buffers for style records (PALETTE, FONT, FORMAT, XF)
43 and a container for XF indexes for every used cell in a sheet.
44 ============================================================================ */
46 // PALETTE record - color information =========================================
48 /** Stores the default colors for the current BIFF version and the contents of
50 class XclImpPalette
: public XclDefaultPalette
53 explicit XclImpPalette( const XclImpRoot
& rRoot
);
55 /** Clears all buffered data, used to set up for a new sheet. */
58 /** Returns the RGB color data for a (non-zero-based) Excel palette entry.
59 @descr First looks for a color read from file, then looks for a default color.
60 @return The color from current or default palette or COL_AUTO, if nothing else found. */
61 ColorData
GetColorData( sal_uInt16 nXclIndex
) const;
62 /** Returns the color for a (non-zero-based) Excel palette entry.
63 @descr First looks for a color read from file, then looks for a default color.
64 @return The color from current or default palette or COL_AUTO, if nothing else found. */
65 inline Color
GetColor( sal_uInt16 nXclIndex
) const
66 { return Color( GetColorData( nXclIndex
) ); }
68 /** Reads a PALETTE record. */
69 void ReadPalette( XclImpStream
& rStrm
);
72 typedef ::std::vector
< ColorData
> ColorDataVec
;
73 ColorDataVec maColorTable
; /// Colors read from file.
76 // FONT record - font information =============================================
78 /** Stores all data of an Excel font and provides import of FONT records. */
79 class XclImpFont
: protected XclImpRoot
82 explicit XclImpFont( const XclImpRoot
& rRoot
);
84 /** Constructs a font from font data.
85 @descr Special handling for font style (bold, italic) in font name,
86 overwrites settings in rFontData. */
87 explicit XclImpFont( const XclImpRoot
& rRoot
, const XclFontData
& rFontData
);
89 /** Sets all font attributes to used or unused. */
90 void SetAllUsedFlags( bool bUsed
);
91 /** Sets the passed font data and all used flags to 'used'. */
92 void SetFontData( const XclFontData
& rFontData
, bool bHasCharSet
);
94 /** Returns read-only access to font data. */
95 inline const XclFontData
& GetFontData() const { return maData
; }
96 /** Returns true, if the font character set is valid. */
97 inline bool HasCharSet() const { return mbHasCharSet
; }
98 /** Returns true, if the font contains superscript or subscript. */
99 inline bool HasEscapement() const { return maData
.mnEscapem
!= EXC_FONTESC_NONE
; }
100 /** Returns the text encoding for strings used with this font. */
101 rtl_TextEncoding
GetFontEncoding() const;
103 /** Returns true, if this font contains characters for Western scripts. */
104 inline bool HasWesternChars() const { return mbHasWstrn
; }
105 /** Returns true, if this font contains characters for Asian scripts (CJK). */
106 inline bool HasAsianChars() const { return mbHasAsian
; }
107 /** Returns true, if this font contains characters for Complex scripts (CTL). */
108 inline bool HasComplexChars() const { return mbHasCmplx
; }
110 /** Reads a FONT record for all BIFF versions. */
111 void ReadFont( XclImpStream
& rStrm
);
112 /** Reads an EFONT record (BIFF2 font color). */
113 void ReadEfont( XclImpStream
& rStrm
);
114 /** Reads the font block from a CF (conditional format) record. */
115 void ReadCFFontBlock( XclImpStream
& rStrm
);
117 /** Fills all font properties to the item set.
118 @param rItemSet The destination item set.
119 @param eType The type of Which-IDs.
120 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
121 void FillToItemSet( SfxItemSet
& rItemSet
, XclFontItemType eType
,
122 bool bSkipPoolDefs
= false ) const;
123 /** Writes all font properties to the passed property set.
124 @param pFontColor If set, overrides internal stored font color. */
125 void WriteFontProperties( ScfPropertySet
& rPropSet
,
126 XclFontPropSetType eType
, const Color
* pFontColor
= 0 ) const;
129 /** Reads and sets height and flags. */
130 void ReadFontData2( XclImpStream
& rStrm
);
131 /** Reads and sets height, flags, color, boldness, script, family and charset. */
132 void ReadFontData5( XclImpStream
& rStrm
);
134 /** Reads and sets the font color. */
135 void ReadFontColor( XclImpStream
& rStrm
);
137 /** Reads and sets a byte string as font name. */
138 void ReadFontName2( XclImpStream
& rStrm
);
139 /** Reads and sets a Unicode string as font name. */
140 void ReadFontName8( XclImpStream
& rStrm
);
142 /** Tests whether the font contains CJK or CTL characters.
143 @descr This is only a weak guess using preselected characters. */
144 void GuessScriptType();
147 XclFontData maData
; /// All font attributes.
148 bool mbHasCharSet
; /// true = Font contains own character set info.
149 bool mbHasWstrn
; /// true = Font contains Western script characters.
150 bool mbHasAsian
; /// true = Font contains Asian script characters.
151 bool mbHasCmplx
; /// true = Font contains Complex script characters.
152 bool mbFontNameUsed
; /// true = Font name, family, charset used.
153 bool mbHeightUsed
; /// true = Font height used.
154 bool mbColorUsed
; /// true = Color used.
155 bool mbWeightUsed
; /// true = Weight used.
156 bool mbEscapemUsed
; /// true = Escapement type used.
157 bool mbUnderlUsed
; /// true = Underline style used.
158 bool mbItalicUsed
; /// true = Italic used.
159 bool mbStrikeUsed
; /// true = Strikeout used.
160 bool mbOutlineUsed
; /// true = Outlined used.
161 bool mbShadowUsed
; /// true = Shadowed used.
164 // ----------------------------------------------------------------------------
166 /** Stores the data of all fonts occurred in an Excel file. */
167 class XclImpFontBuffer
: protected XclImpRoot
, ScfNoCopy
170 explicit XclImpFontBuffer( const XclImpRoot
& rRoot
);
172 /** Clears all buffered data, used to set up for a new sheet. */
175 /** Returns the object that stores all contents of a FONT record. */
176 const XclImpFont
* GetFont( sal_uInt16 nFontIndex
) const;
177 /** Returns the application font data of this file, needed i.e. for column width. */
178 inline const XclFontData
& GetAppFontData() const { return maAppFont
; }
180 /** Reads a FONT record. */
181 void ReadFont( XclImpStream
& rStrm
);
182 /** Reads an EFONT record (BIFF2 font color). */
183 void ReadEfont( XclImpStream
& rStrm
);
185 /** Fills all font properties from a FONT record to the item set.
186 @param rItemSet The destination item set.
187 @param eType The type of Which-IDs.
188 @param nFontIdx The Excel index of the font.
189 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
190 void FillToItemSet( SfxItemSet
& rItemSet
, XclFontItemType eType
,
191 sal_uInt16 nFontIdx
, bool bSkipPoolDefs
= false ) const;
192 /** Writes all font properties to the passed property set.
193 @param pFontColor If set, overrides internal stored font color. */
194 void WriteFontProperties(
195 ScfPropertySet
& rPropSet
, XclFontPropSetType eType
,
196 sal_uInt16 nFontIdx
, const Color
* pFontColor
= 0 ) const;
197 /** Writes default font properties for form controls to the passed property set. */
198 void WriteDefaultCtrlFontProperties( ScfPropertySet
& rPropSet
) const;
201 /** Updates the application default font. */
202 void UpdateAppFont( const XclFontData
& rFontData
, bool bHasCharSet
);
205 ScfDelList
< XclImpFont
> maFontList
; /// List of all FONT records in the Excel file.
206 XclFontData maAppFont
; /// Application font (for column width).
207 XclImpFont maFont4
; /// Built-in font with index 4.
208 XclImpFont maCtrlFont
; /// BIFF5 default form controls font (Helv,8pt,bold).
211 // FORMAT record - number formats =============================================
213 /** Stores all user defined number formats occured in the file. */
214 class XclImpNumFmtBuffer
: public XclNumFmtBuffer
, protected XclImpRoot
217 explicit XclImpNumFmtBuffer( const XclImpRoot
& rRoot
);
219 /** Clears all buffered data, used to set up for a new sheet. */
222 /** Reads a FORMAT record. */
223 void ReadFormat( XclImpStream
& rStrm
);
224 /** Creates the number formats in the Calc document. */
225 void CreateScFormats();
227 /** Returns the format key with the passed Excel index or NUMBERFORMAT_ENTRY_NOT_FOUND on error. */
228 ULONG
GetScFormat( sal_uInt16 nXclNumFmt
) const;
230 /** Fills an Excel number format to the passed item set.
231 @param rItemSet The destination item set.
232 @param nXclNumFmt The Excel number format index.
233 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
235 SfxItemSet
& rItemSet
, sal_uInt16 nXclNumFmt
,
236 bool bSkipPoolDefs
= false ) const;
237 /** Fills a Calc number format to the passed item set.
238 @param rItemSet The destination item set.
239 @param nScNumFmt The Calc number formatter index of the format.
240 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
241 void FillScFmtToItemSet(
242 SfxItemSet
& rItemSet
, ULONG nScNumFmt
,
243 bool bSkipPoolDefs
= false ) const;
246 typedef ::std::map
< sal_uInt16
, ULONG
> XclImpIndexMap
;
248 XclImpIndexMap maIndexMap
; /// Maps Excel format indexes to Calc formats.
249 sal_uInt16 mnNextXclIdx
; /// Index counter for BIFF2-BIFF4.
252 // XF, STYLE record - Cell formatting =========================================
254 /** Extends the XclCellProt struct for import.
255 @descr Provides functions to fill from Excel record data and to fill to item sets. */
256 struct XclImpCellProt
: public XclCellProt
258 /** Fills this struct with BIFF2 XF record data. */
259 void FillFromXF2( sal_uInt8 nNumFmt
);
260 /** Fills this struct with BIFF3-BIFF8 XF record data. */
261 void FillFromXF3( sal_uInt16 nProt
);
263 /** Inserts items representing this protection style into the item set.
264 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
265 void FillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
= false ) const;
268 // ----------------------------------------------------------------------------
270 /** Extends the XclCellAlign struct for import.
271 @descr Provides functions to fill from Excel record data and to fill to item sets. */
272 struct XclImpCellAlign
: public XclCellAlign
274 /** Fills this struct with BIFF2 XF record data. */
275 void FillFromXF2( sal_uInt8 nFlags
);
276 /** Fills this struct with BIFF3 XF record data. */
277 void FillFromXF3( sal_uInt16 nAlign
);
278 /** Fills this struct with BIFF4 XF record data. */
279 void FillFromXF4( sal_uInt16 nAlign
);
280 /** Fills this struct with BIFF5/BIFF7 XF record data. */
281 void FillFromXF5( sal_uInt16 nAlign
);
282 /** Fills this struct with BIFF8 XF record data. */
283 void FillFromXF8( sal_uInt16 nAlign
, sal_uInt16 nMiscAttrib
);
285 /** Inserts items representing this alignment style into the item set.
286 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
287 void FillToItemSet( SfxItemSet
& rItemSet
, const XclImpFont
* pFont
, bool bSkipPoolDefs
= false ) const;
290 // ----------------------------------------------------------------------------
292 /** Extends the XclCellBorder struct for import.
293 @descr Provides functions to fill from Excel record data and to fill to item sets. */
294 struct XclImpCellBorder
: public XclCellBorder
296 bool mbLeftUsed
; /// true = Left line style used.
297 bool mbRightUsed
; /// true = Right line style used.
298 bool mbTopUsed
; /// true = Top line style used.
299 bool mbBottomUsed
; /// true = Bottom line style used.
300 bool mbDiagUsed
; /// true = Diagonal line style used.
302 explicit XclImpCellBorder();
304 /** Sets outer line states and diagonal line states to used or unused. */
305 void SetUsedFlags( bool bOuterUsed
, bool bDiagUsed
);
307 /** Fills this struct with BIFF2 XF record data. */
308 void FillFromXF2( sal_uInt8 nFlags
);
309 /** Fills this struct with BIFF3/BIFF4 XF record data. */
310 void FillFromXF3( sal_uInt32 nBorder
);
311 /** Fills this struct with BIFF5/BIFF7 XF record data. */
312 void FillFromXF5( sal_uInt32 nBorder
, sal_uInt32 nArea
);
313 /** Fills this struct with BIFF8 XF record data. */
314 void FillFromXF8( sal_uInt32 nBorder1
, sal_uInt32 nBorder2
);
316 /** Fills this struct with BIFF8 CF (conditional format) record data. */
317 void FillFromCF8( sal_uInt16 nLineStyle
, sal_uInt32 nLineColor
, sal_uInt32 nFlags
);
319 /** Returns true, if any of the outer border lines is visible. */
320 bool HasAnyOuterBorder() const;
322 /** Inserts a box item representing this border style into the item set.
323 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
325 SfxItemSet
& rItemSet
,
326 const XclImpPalette
& rPalette
,
327 bool bSkipPoolDefs
= false ) const;
330 // ----------------------------------------------------------------------------
332 /** Extends the XclCellArea struct for import.
333 @descr Provides functions to fill from Excel record data and to fill to item sets. */
334 struct XclImpCellArea
: public XclCellArea
336 bool mbForeUsed
; /// true = Foreground color used.
337 bool mbBackUsed
; /// true = Background color used.
338 bool mbPattUsed
; /// true = Pattern used.
340 explicit XclImpCellArea();
342 /** Sets colors and pattern state to used or unused. */
343 void SetUsedFlags( bool bUsed
);
345 /** Fills this struct with BIFF2 XF record data. */
346 void FillFromXF2( sal_uInt8 nFlags
);
347 /** Fills this struct with BIFF3/BIFF4 XF record data. */
348 void FillFromXF3( sal_uInt16 nArea
);
349 /** Fills this struct with BIFF5/BIFF7 XF record data. */
350 void FillFromXF5( sal_uInt32 nArea
);
351 /** Fills this struct with BIFF8 XF record data. */
352 void FillFromXF8( sal_uInt32 nBorder2
, sal_uInt16 nArea
);
354 /** Fills this struct with BIFF8 CF (conditional format) record data. */
355 void FillFromCF8( sal_uInt16 nPattern
, sal_uInt16 nColor
, sal_uInt32 nFlags
);
357 /** Inserts a brush item representing this area style into the item set.
358 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
360 SfxItemSet
& rItemSet
,
361 const XclImpPalette
& rPalette
,
362 bool bSkipPoolDefs
= false ) const;
365 // ----------------------------------------------------------------------------
367 /** Represents an XF record index with additional information. */
371 inline explicit XclImpXFIndex( sal_uInt16 nXFIndex
, bool bBoolCell
= false ) :
372 mnXFIndex( nXFIndex
), mbBoolCell( bBoolCell
) {}
374 inline sal_uInt16
GetXFIndex() const { return mnXFIndex
; }
375 inline bool IsBoolCell() const { return mbBoolCell
; }
378 sal_uInt16 mnXFIndex
; /// The XF record index.
379 bool mbBoolCell
; /// true = A Boolean value cell.
382 inline bool operator==( const XclImpXFIndex
& rLeft
, const XclImpXFIndex
& rRight
)
383 { return (rLeft
.GetXFIndex() == rRight
.GetXFIndex()) && (rLeft
.IsBoolCell() == rRight
.IsBoolCell()); }
385 inline bool operator!=( const XclImpXFIndex
& rLeft
, const XclImpXFIndex
& rRight
)
386 { return !(rLeft
== rRight
); }
388 // ----------------------------------------------------------------------------
390 /** Contains all data of a XF record and a Calc item set. */
391 class XclImpXF
: public XclXFBase
, protected XclImpRoot
, ScfNoCopy
394 explicit XclImpXF( const XclImpRoot
& rRoot
);
397 /** Reads an XF record. */
398 void ReadXF( XclImpStream
& rStrm
);
400 inline sal_uInt8
GetHorAlign() const { return maAlignment
.mnHorAlign
; }
401 inline sal_uInt8
GetVerAlign() const { return maAlignment
.mnVerAlign
; }
402 inline sal_uInt16
GetFontIndex() const { return mnXclFont
; }
404 /** Creates a Calc item set containing an item set with all cell properties.
405 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items.
406 @return A read-only reference to the item set stored internally. */
407 const ScPatternAttr
& CreatePattern( bool bSkipPoolDefs
= false );
409 /** Inserts all formatting attributes to the specified area in the Calc document.
410 @param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
411 the number format of the XF. */
413 SCCOL nScCol1
, SCROW nScRow1
,
414 SCCOL nScCol2
, SCROW nScRow2
,
416 ULONG nForceScNumFmt
= NUMBERFORMAT_ENTRY_NOT_FOUND
);
419 void ReadXF2( XclImpStream
& rStrm
);
420 void ReadXF3( XclImpStream
& rStrm
);
421 void ReadXF4( XclImpStream
& rStrm
);
422 void ReadXF5( XclImpStream
& rStrm
);
423 void ReadXF8( XclImpStream
& rStrm
);
425 /** Sets all "attribute used" flags according to the passed mask.
426 @descr In cell XFs, a set bit represents "used", in style XFs it is a cleared bit.
427 Therefore mbCellXF must be set correctly before calling this method. */
428 void SetUsedFlags( sal_uInt8 nUsedFlags
);
431 typedef ::std::auto_ptr
< ScPatternAttr
> ScPatternAttrPtr
;
433 ScPatternAttrPtr mpPattern
; /// Calc item set.
434 ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
436 XclImpCellProt maProtection
; /// Cell protection flags.
437 XclImpCellAlign maAlignment
; /// All alignment attributes.
438 XclImpCellBorder maBorder
; /// Border line style.
439 XclImpCellArea maArea
; /// Background area style.
440 sal_uInt16 mnXclNumFmt
; /// Index to number format.
441 sal_uInt16 mnXclFont
; /// Index to font record.
444 // ----------------------------------------------------------------------------
446 /** Contains all data of a cell style associated with an XF record. */
447 class XclImpStyle
: protected XclImpRoot
450 explicit XclImpStyle( const XclImpRoot
& rRoot
);
452 /** Reads a STYLE record. */
453 void ReadStyle( XclImpStream
& rStrm
);
455 inline const String
& GetName() const { return maName
; }
456 inline sal_uInt16
GetXfId() const { return mnXfId
; }
457 inline bool IsBuiltin() const { return mbBuiltin
&& (mnBuiltinId
!= EXC_STYLE_USERDEF
); }
458 inline sal_uInt8
GetBuiltinId() const { return mnBuiltinId
; }
459 inline sal_uInt8
GetLevel() const { return mnLevel
; }
461 /** Creates a cell style sheet and inserts it into the Calc document.
462 @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
463 ScStyleSheet
* CreateStyleSheet();
464 /** Creates the Calc style sheet, if this is a user-defined style. */
465 void CreateUserStyle( const String
& rFinalName
);
468 String maName
; /// Cell style name.
469 sal_uInt16 mnXfId
; /// Formatting for this cell style.
470 sal_uInt8 mnBuiltinId
; /// Identifier for builtin styles.
471 sal_uInt8 mnLevel
; /// Level for builtin column/row styles.
472 bool mbBuiltin
; /// True = builtin style.
473 bool mbCustom
; /// True = customized builtin style.
474 bool mbHidden
; /// True = style not visible in GUI.
476 String maFinalName
; /// Final name used in the Calc document.
477 ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
480 // ----------------------------------------------------------------------------
482 /** Contains all XF records occured in the file.
483 @descr This class is able to read XF records (BIFF2 - BIFF8) and STYLE records (BIFF8). */
484 class XclImpXFBuffer
: protected XclImpRoot
, ScfNoCopy
487 explicit XclImpXFBuffer( const XclImpRoot
& rRoot
);
489 /** Clears all buffered data, used to set up for a new sheet. */
492 /** Reads an XF record. */
493 void ReadXF( XclImpStream
& rStrm
);
494 /** Reads a STYLE record. */
495 void ReadStyle( XclImpStream
& rStrm
);
497 /** Returns the object that stores all contents of an XF record. */
498 inline XclImpXF
* GetXF( sal_uInt16 nXFIndex
) const
499 { return maXFList
.GetObject( nXFIndex
); }
501 /** Returns the index to the Excel font used in the specified XF record. */
502 sal_uInt16
GetFontIndex( sal_uInt16 nXFIndex
) const;
503 /** Returns the Excel font used in the specified XF record. */
504 const XclImpFont
* GetFont( sal_uInt16 nXFIndex
) const;
506 /** Creates all user defined style sheets. */
507 void CreateUserStyles();
508 /** Creates a cell style sheet of the passed XF and inserts it into the Calc document.
509 @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
510 ScStyleSheet
* CreateStyleSheet( sal_uInt16 nXFIndex
);
512 /** Inserts formatting attributes from an XF to the specified area in the Calc document.
513 @param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
514 the number format of the XF. */
516 SCCOL nScCol1
, SCROW nScRow1
,
517 SCCOL nScCol2
, SCROW nScRow2
,
518 SCTAB nScTab
, const XclImpXFIndex
& rXFIndex
);
521 typedef ScfDelList
< XclImpStyle
> XclImpStyleList
;
522 typedef ::std::map
< sal_uInt16
, XclImpStyle
* > XclImpStyleMap
;
524 ScfDelList
< XclImpXF
> maXFList
; /// List of contents of all XF record.
525 XclImpStyleList maBuiltinStyles
; /// List of built-in cell styles.
526 XclImpStyleList maUserStyles
; /// List of user defined cell styles.
527 XclImpStyleMap maStylesByXf
; /// Maps XF records to cell styles.
530 // Buffer for XF indexes in cells =============================================
532 /** Contains an (encoded) XF index for a range of rows in a single column. */
535 DECL_FIXEDMEMPOOL_NEWDEL( XclImpXFRange
)
538 SCROW mnScRow1
; /// The first row of an equal-formatted range.
539 SCROW mnScRow2
; /// The last row of an equal-formatted range.
540 XclImpXFIndex maXFIndex
; /// Extended XF index.
542 inline explicit XclImpXFRange( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
543 inline explicit XclImpXFRange( SCROW nFirstScRow
, SCROW nLastScRow
, const XclImpXFIndex
& rXFIndex
);
545 /** Returns true, if nScRow is contained in own row range. */
546 inline bool Contains( SCROW nScRow
) const;
548 /** Returns true, if the range has been expanded. */
549 bool Expand( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
550 /** Returns true, if the range has been expanded. */
551 bool Expand( const XclImpXFRange
& rNextRange
);
554 inline XclImpXFRange::XclImpXFRange( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
) :
557 maXFIndex( rXFIndex
)
561 inline XclImpXFRange::XclImpXFRange( SCROW nFirstScRow
, SCROW nLastScRow
, const XclImpXFIndex
& rXFIndex
) :
562 mnScRow1( nFirstScRow
),
563 mnScRow2( nLastScRow
),
564 maXFIndex( rXFIndex
)
568 inline bool XclImpXFRange::Contains( SCROW nScRow
) const
570 return (mnScRow1
<= nScRow
) && (nScRow
<= mnScRow2
);
573 // ----------------------------------------------------------------------------
575 /** Contains the XF indexes for every used cell in a column. */
576 class XclImpXFRangeColumn
: ScfNoCopy
579 inline explicit XclImpXFRangeColumn() {}
581 /** Returns the first formatted cell range in this column. */
582 inline XclImpXFRange
* First() { return maIndexList
.First(); }
583 /** Returns the next formatted cell range in this column. */
584 inline XclImpXFRange
* Next() { return maIndexList
.Next(); }
586 /** Inserts a single row range into the list. */
587 void SetDefaultXF( const XclImpXFIndex
& rXFIndex
);
589 /** Inserts a new (encoded) XF index (first try to expand the last range). */
590 void SetXF( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
593 /** Finds the previous and next row range from row position nScRow.
594 @descr If an XF still exists, it is contained in rpPrevRange. */
596 XclImpXFRange
*& rpPrevRange
,
597 XclImpXFRange
*& rpNextRange
,
599 SCROW nScRow
) const;
601 /** Tries to concatenate a range with its predecessor.
602 @descr The ranges must have the same XF index and must not have a gap.
603 The resulting range has the index nIndex-1. */
604 void TryConcatPrev( ULONG nIndex
);
607 ScfDelList
< XclImpXFRange
> maIndexList
; /// The list of XF index range.
610 // ----------------------------------------------------------------------------
612 /** Contains the XF indexes for every used cell in a single sheet. */
613 class XclImpXFRangeBuffer
: protected XclImpRoot
, ScfNoCopy
616 explicit XclImpXFRangeBuffer( const XclImpRoot
& rRoot
);
617 virtual ~XclImpXFRangeBuffer();
619 /** Clears all buffered data, used to set up for a new sheet. */
622 /** Inserts a new XF index. */
623 void SetXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
624 /** Inserts a new XF index for blank cells. */
625 void SetBlankXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
626 /** Inserts a new XF index for boolean cells. */
627 void SetBoolXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
628 /** Inserts a new XF index for all cells in a row. */
629 void SetRowDefXF( SCROW nScRow
, sal_uInt16 nXFIndex
);
630 /** Inserts a new XF index for all cells in a column. */
631 void SetColumnDefXF( SCCOL nScCol
, sal_uInt16 nXFIndex
);
633 /** Inserts a range of hyperlink cells. */
634 void SetHyperlink( const XclRange
& rXclRange
, const String
& rUrl
);
636 /** Inserts the first cell of a merged cell range. */
637 void SetMerge( SCCOL nScCol
, SCROW nScRow
);
638 /** Inserts a complete merged cell range. */
639 void SetMerge( SCCOL nScCol1
, SCROW nScRow1
, SCCOL nScCol2
, SCROW nScRow2
);
641 /** Applies styles and cell merging to the current sheet in the document. */
645 /** Insertion mode of an XF index. */
646 enum XclImpXFInsertMode
648 xlXFModeCell
, /// Filled cell.
649 xlXFModeBoolCell
, /// Cell with a single Boolean value.
650 xlXFModeBlank
, /// Blank cell.
651 xlXFModeRow
/// Row default XF.
655 /** Inserts a new XF index for the specified cell type. */
656 void SetXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
, XclImpXFInsertMode eMode
);
658 /** Copies border of the last cell of the range to the first cell to keep it visible
659 when the range is merged.
661 BOX_LINE_RIGHT = copy most-right border of top row;
662 BOX_LINE_BOTTOM = copy most-bottom border of first column. */
663 void SetBorderLine( const ScRange
& rRange
, SCTAB nScTab
, USHORT nLine
);
666 typedef ScfRef
< XclImpXFRangeColumn
> XclImpXFRangeColumnRef
;
667 typedef ::std::vector
< XclImpXFRangeColumnRef
> XclImpXFRangeColumnVec
;
668 typedef ::std::pair
< XclRange
, String
> XclImpHyperlinkRange
;
669 typedef ::std::list
< XclImpHyperlinkRange
> XclImpHyperlinkList
;
671 XclImpXFRangeColumnVec maColumns
; /// Array of column XF index buffers.
672 XclImpHyperlinkList maHyperlinks
; /// Maps URLs to hyperlink cells.
673 ScRangeList maMergeList
; /// List of merged cell ranges.
676 // ============================================================================