1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xistyle.hxx,v $
10 * $Revision: 1.23.90.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XISTYLE_HXX
32 #define SC_XISTYLE_HXX
35 #include <tools/mempool.hxx>
36 #include "rangelst.hxx"
37 #include "patattr.hxx"
38 #include "xladdress.hxx"
39 #include "xlstyle.hxx"
44 /* ============================================================================
45 - Buffers for style records (PALETTE, FONT, FORMAT, XF)
46 and a container for XF indexes for every used cell in a sheet.
47 ============================================================================ */
49 // PALETTE record - color information =========================================
51 /** Stores the default colors for the current BIFF version and the contents of
53 class XclImpPalette
: public XclDefaultPalette
56 explicit XclImpPalette( const XclImpRoot
& rRoot
);
58 /** Clears all buffered data, used to set up for a new sheet. */
61 /** Returns the RGB color data for a (non-zero-based) Excel palette entry.
62 @descr First looks for a color read from file, then looks for a default color.
63 @return The color from current or default palette or COL_AUTO, if nothing else found. */
64 ColorData
GetColorData( sal_uInt16 nXclIndex
) const;
65 /** Returns the color for a (non-zero-based) Excel palette entry.
66 @descr First looks for a color read from file, then looks for a default color.
67 @return The color from current or default palette or COL_AUTO, if nothing else found. */
68 inline Color
GetColor( sal_uInt16 nXclIndex
) const
69 { return Color( GetColorData( nXclIndex
) ); }
71 /** Reads a PALETTE record. */
72 void ReadPalette( XclImpStream
& rStrm
);
76 typedef ::std::vector
< ColorData
> ColorDataVec
;
77 ColorDataVec maColorTable
; /// Colors read from file.
78 const XclImpRoot
& mrRoot
;
81 // FONT record - font information =============================================
83 /** Stores all data of an Excel font and provides import of FONT records. */
84 class XclImpFont
: protected XclImpRoot
87 explicit XclImpFont( const XclImpRoot
& rRoot
);
89 /** Constructs a font from font data.
90 @descr Special handling for font style (bold, italic) in font name,
91 overwrites settings in rFontData. */
92 explicit XclImpFont( const XclImpRoot
& rRoot
, const XclFontData
& rFontData
);
94 /** Sets all font attributes to used or unused. */
95 void SetAllUsedFlags( bool bUsed
);
96 /** Sets the passed font data and all used flags to 'used'. */
97 void SetFontData( const XclFontData
& rFontData
, bool bHasCharSet
);
99 /** Returns read-only access to font data. */
100 inline const XclFontData
& GetFontData() const { return maData
; }
101 /** Returns true, if the font character set is valid. */
102 inline bool HasCharSet() const { return mbHasCharSet
; }
103 /** Returns true, if the font contains superscript or subscript. */
104 inline bool HasEscapement() const { return maData
.mnEscapem
!= EXC_FONTESC_NONE
; }
105 /** Returns the text encoding for strings used with this font. */
106 rtl_TextEncoding
GetFontEncoding() const;
108 /** Returns true, if this font contains characters for Western scripts. */
109 inline bool HasWesternChars() const { return mbHasWstrn
; }
110 /** Returns true, if this font contains characters for Asian scripts (CJK). */
111 inline bool HasAsianChars() const { return mbHasAsian
; }
112 /** Returns true, if this font contains characters for Complex scripts (CTL). */
113 inline bool HasComplexChars() const { return mbHasCmplx
; }
115 /** Reads a FONT record for all BIFF versions. */
116 void ReadFont( XclImpStream
& rStrm
);
117 /** Reads an EFONT record (BIFF2 font color). */
118 void ReadEfont( XclImpStream
& rStrm
);
119 /** Reads the font block from a CF (conditional format) record. */
120 void ReadCFFontBlock( XclImpStream
& rStrm
);
122 /** Fills all font properties to the item set.
123 @param rItemSet The destination item set.
124 @param eType The type of Which-IDs.
125 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
126 void FillToItemSet( SfxItemSet
& rItemSet
, XclFontItemType eType
,
127 bool bSkipPoolDefs
= false ) const;
128 /** Writes all font properties to the passed property set.
129 @param pFontColor If set, overrides internal stored font color. */
130 void WriteFontProperties( ScfPropertySet
& rPropSet
,
131 XclFontPropSetType eType
, const Color
* pFontColor
= 0 ) const;
134 /** Reads and sets height and flags. */
135 void ReadFontData2( XclImpStream
& rStrm
);
136 /** Reads and sets height, flags, color, boldness, script, family and charset. */
137 void ReadFontData5( XclImpStream
& rStrm
);
139 /** Reads and sets the font color. */
140 void ReadFontColor( XclImpStream
& rStrm
);
142 /** Reads and sets a byte string as font name. */
143 void ReadFontName2( XclImpStream
& rStrm
);
144 /** Reads and sets a Unicode string as font name. */
145 void ReadFontName8( XclImpStream
& rStrm
);
147 /** Tests whether the font contains CJK or CTL characters.
148 @descr This is only a weak guess using preselected characters. */
149 void GuessScriptType();
152 XclFontData maData
; /// All font attributes.
153 bool mbHasCharSet
; /// true = Font contains own character set info.
154 bool mbHasWstrn
; /// true = Font contains Western script characters.
155 bool mbHasAsian
; /// true = Font contains Asian script characters.
156 bool mbHasCmplx
; /// true = Font contains Complex script characters.
157 bool mbFontNameUsed
; /// true = Font name, family, charset used.
158 bool mbHeightUsed
; /// true = Font height used.
159 bool mbColorUsed
; /// true = Color used.
160 bool mbWeightUsed
; /// true = Weight used.
161 bool mbEscapemUsed
; /// true = Escapement type used.
162 bool mbUnderlUsed
; /// true = Underline style used.
163 bool mbItalicUsed
; /// true = Italic used.
164 bool mbStrikeUsed
; /// true = Strikeout used.
165 bool mbOutlineUsed
; /// true = Outlined used.
166 bool mbShadowUsed
; /// true = Shadowed used.
169 // ----------------------------------------------------------------------------
171 /** Stores the data of all fonts occurred in an Excel file. */
172 class XclImpFontBuffer
: protected XclImpRoot
, ScfNoCopy
175 explicit XclImpFontBuffer( const XclImpRoot
& rRoot
);
177 /** Clears all buffered data, used to set up for a new sheet. */
180 /** Returns the object that stores all contents of a FONT record. */
181 const XclImpFont
* GetFont( sal_uInt16 nFontIndex
) const;
182 /** Returns the application font data of this file, needed i.e. for column width. */
183 inline const XclFontData
& GetAppFontData() const { return maAppFont
; }
185 /** Reads a FONT record. */
186 void ReadFont( XclImpStream
& rStrm
);
187 /** Reads an EFONT record (BIFF2 font color). */
188 void ReadEfont( XclImpStream
& rStrm
);
190 /** Fills all font properties from a FONT record to the item set.
191 @param rItemSet The destination item set.
192 @param eType The type of Which-IDs.
193 @param nFontIdx The Excel index of the font.
194 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
195 void FillToItemSet( SfxItemSet
& rItemSet
, XclFontItemType eType
,
196 sal_uInt16 nFontIdx
, bool bSkipPoolDefs
= false ) const;
197 /** Writes all font properties to the passed property set.
198 @param pFontColor If set, overrides internal stored font color. */
199 void WriteFontProperties(
200 ScfPropertySet
& rPropSet
, XclFontPropSetType eType
,
201 sal_uInt16 nFontIdx
, const Color
* pFontColor
= 0 ) const;
202 /** Writes default font properties for form controls to the passed property set. */
203 void WriteDefaultCtrlFontProperties( ScfPropertySet
& rPropSet
) const;
206 /** Updates the application default font. */
207 void UpdateAppFont( const XclFontData
& rFontData
, bool bHasCharSet
);
210 ScfDelList
< XclImpFont
> maFontList
; /// List of all FONT records in the Excel file.
211 XclFontData maAppFont
; /// Application font (for column width).
212 XclImpFont maFont4
; /// Built-in font with index 4.
213 XclImpFont maCtrlFont
; /// BIFF5 default form controls font (Helv,8pt,bold).
216 // FORMAT record - number formats =============================================
218 /** Stores all user defined number formats occured in the file. */
219 class XclImpNumFmtBuffer
: public XclNumFmtBuffer
, protected XclImpRoot
222 explicit XclImpNumFmtBuffer( const XclImpRoot
& rRoot
);
224 /** Clears all buffered data, used to set up for a new sheet. */
227 /** Reads a FORMAT record. */
228 void ReadFormat( XclImpStream
& rStrm
);
229 /** Creates the number formats in the Calc document. */
230 void CreateScFormats();
232 /** Returns the format key with the passed Excel index or NUMBERFORMAT_ENTRY_NOT_FOUND on error. */
233 ULONG
GetScFormat( sal_uInt16 nXclNumFmt
) const;
235 /** Fills an Excel number format to the passed item set.
236 @param rItemSet The destination item set.
237 @param nXclNumFmt The Excel number format index.
238 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
240 SfxItemSet
& rItemSet
, sal_uInt16 nXclNumFmt
,
241 bool bSkipPoolDefs
= false ) const;
242 /** Fills a Calc number format to the passed item set.
243 @param rItemSet The destination item set.
244 @param nScNumFmt The Calc number formatter index of the format.
245 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
246 void FillScFmtToItemSet(
247 SfxItemSet
& rItemSet
, ULONG nScNumFmt
,
248 bool bSkipPoolDefs
= false ) const;
251 typedef ::std::map
< sal_uInt16
, ULONG
> XclImpIndexMap
;
253 XclImpIndexMap maIndexMap
; /// Maps Excel format indexes to Calc formats.
254 sal_uInt16 mnNextXclIdx
; /// Index counter for BIFF2-BIFF4.
257 // XF, STYLE record - Cell formatting =========================================
259 /** Extends the XclCellProt struct for import.
260 @descr Provides functions to fill from Excel record data and to fill to item sets. */
261 struct XclImpCellProt
: public XclCellProt
263 /** Fills this struct with BIFF2 XF record data. */
264 void FillFromXF2( sal_uInt8 nNumFmt
);
265 /** Fills this struct with BIFF3-BIFF8 XF record data. */
266 void FillFromXF3( sal_uInt16 nProt
);
268 /** Inserts items representing this protection style into the item set.
269 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
270 void FillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
= false ) const;
273 // ----------------------------------------------------------------------------
275 /** Extends the XclCellAlign struct for import.
276 @descr Provides functions to fill from Excel record data and to fill to item sets. */
277 struct XclImpCellAlign
: public XclCellAlign
279 /** Fills this struct with BIFF2 XF record data. */
280 void FillFromXF2( sal_uInt8 nFlags
);
281 /** Fills this struct with BIFF3 XF record data. */
282 void FillFromXF3( sal_uInt16 nAlign
);
283 /** Fills this struct with BIFF4 XF record data. */
284 void FillFromXF4( sal_uInt16 nAlign
);
285 /** Fills this struct with BIFF5/BIFF7 XF record data. */
286 void FillFromXF5( sal_uInt16 nAlign
);
287 /** Fills this struct with BIFF8 XF record data. */
288 void FillFromXF8( sal_uInt16 nAlign
, sal_uInt16 nMiscAttrib
);
290 /** Inserts items representing this alignment style into the item set.
291 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
292 void FillToItemSet( SfxItemSet
& rItemSet
, const XclImpFont
* pFont
, bool bSkipPoolDefs
= false ) const;
295 // ----------------------------------------------------------------------------
297 /** Extends the XclCellBorder struct for import.
298 @descr Provides functions to fill from Excel record data and to fill to item sets. */
299 struct XclImpCellBorder
: public XclCellBorder
301 bool mbLeftUsed
; /// true = Left line style used.
302 bool mbRightUsed
; /// true = Right line style used.
303 bool mbTopUsed
; /// true = Top line style used.
304 bool mbBottomUsed
; /// true = Bottom line style used.
305 bool mbDiagUsed
; /// true = Diagonal line style used.
307 explicit XclImpCellBorder();
309 /** Sets outer line states and diagonal line states to used or unused. */
310 void SetUsedFlags( bool bOuterUsed
, bool bDiagUsed
);
312 /** Fills this struct with BIFF2 XF record data. */
313 void FillFromXF2( sal_uInt8 nFlags
);
314 /** Fills this struct with BIFF3/BIFF4 XF record data. */
315 void FillFromXF3( sal_uInt32 nBorder
);
316 /** Fills this struct with BIFF5/BIFF7 XF record data. */
317 void FillFromXF5( sal_uInt32 nBorder
, sal_uInt32 nArea
);
318 /** Fills this struct with BIFF8 XF record data. */
319 void FillFromXF8( sal_uInt32 nBorder1
, sal_uInt32 nBorder2
);
321 /** Fills this struct with BIFF8 CF (conditional format) record data. */
322 void FillFromCF8( sal_uInt16 nLineStyle
, sal_uInt32 nLineColor
, sal_uInt32 nFlags
);
324 /** Inserts a box item representing this border style into the item set.
325 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
327 SfxItemSet
& rItemSet
,
328 const XclImpPalette
& rPalette
,
329 bool bSkipPoolDefs
= false ) const;
332 // ----------------------------------------------------------------------------
334 /** Extends the XclCellArea struct for import.
335 @descr Provides functions to fill from Excel record data and to fill to item sets. */
336 struct XclImpCellArea
: public XclCellArea
338 bool mbForeUsed
; /// true = Foreground color used.
339 bool mbBackUsed
; /// true = Background color used.
340 bool mbPattUsed
; /// true = Pattern used.
342 explicit XclImpCellArea();
344 /** Sets colors and pattern state to used or unused. */
345 void SetUsedFlags( bool bUsed
);
347 /** Fills this struct with BIFF2 XF record data. */
348 void FillFromXF2( sal_uInt8 nFlags
);
349 /** Fills this struct with BIFF3/BIFF4 XF record data. */
350 void FillFromXF3( sal_uInt16 nArea
);
351 /** Fills this struct with BIFF5/BIFF7 XF record data. */
352 void FillFromXF5( sal_uInt32 nArea
);
353 /** Fills this struct with BIFF8 XF record data. */
354 void FillFromXF8( sal_uInt32 nBorder2
, sal_uInt16 nArea
);
356 /** Fills this struct with BIFF8 CF (conditional format) record data. */
357 void FillFromCF8( sal_uInt16 nPattern
, sal_uInt16 nColor
, sal_uInt32 nFlags
);
359 /** Inserts a brush item representing this area style into the item set.
360 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
362 SfxItemSet
& rItemSet
,
363 const XclImpPalette
& rPalette
,
364 bool bSkipPoolDefs
= false ) const;
367 // ----------------------------------------------------------------------------
369 /** Represents an XF record index with additional information. */
373 inline explicit XclImpXFIndex( sal_uInt16 nXFIndex
, bool bBoolCell
= false ) :
374 mnXFIndex( nXFIndex
), mbBoolCell( bBoolCell
) {}
376 inline sal_uInt16
GetXFIndex() const { return mnXFIndex
; }
377 inline bool IsBoolCell() const { return mbBoolCell
; }
380 sal_uInt16 mnXFIndex
; /// The XF record index.
381 bool mbBoolCell
; /// true = A Boolean value cell.
384 inline bool operator==( const XclImpXFIndex
& rLeft
, const XclImpXFIndex
& rRight
)
385 { return (rLeft
.GetXFIndex() == rRight
.GetXFIndex()) && (rLeft
.IsBoolCell() == rRight
.IsBoolCell()); }
387 inline bool operator!=( const XclImpXFIndex
& rLeft
, const XclImpXFIndex
& rRight
)
388 { return !(rLeft
== rRight
); }
390 // ----------------------------------------------------------------------------
392 /** Contains all data of a XF record and a Calc item set. */
393 class XclImpXF
: public XclXFBase
, protected XclImpRoot
, ScfNoCopy
396 explicit XclImpXF( const XclImpRoot
& rRoot
);
399 /** Reads an XF record. */
400 void ReadXF( XclImpStream
& rStrm
);
402 /** Sets the style name of this XF, if it is a style XF.
403 @descr Additionally creates this user-defined style in the Calc document. */
404 void SetStyleName( const String
& rStyleName
);
405 /** Sets the style name of this XF from a built-in Excel style, if it is a style XF.
406 @descr Does not create the style in the Calc document. This is done on demand
407 in CreatePattern(), if the style is really used. */
408 void SetBuiltInStyleName( sal_uInt8 nStyleId
, sal_uInt8 nLevel
);
410 inline const String
& GetStyleName() const { return maStyleName
; }
411 inline sal_uInt8
GetHorAlign() const { return maAlignment
.mnHorAlign
; }
412 inline sal_uInt8
GetVerAlign() const { return maAlignment
.mnVerAlign
; }
413 inline sal_uInt16
GetFontIndex() const { return mnXclFont
; }
415 /** Creates the Calc style sheet, if this is a user-defined style. */
416 void CreateUserStyle();
418 /** Inserts all formatting attributes to the specified area in the Calc document.
419 @param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
420 the number format of the XF. */
422 SCCOL nScCol1
, SCROW nScRow1
,
423 SCCOL nScCol2
, SCROW nScRow2
,
425 ULONG nForceScNumFmt
= NUMBERFORMAT_ENTRY_NOT_FOUND
);
428 void ReadXF2( XclImpStream
& rStrm
);
429 void ReadXF3( XclImpStream
& rStrm
);
430 void ReadXF4( XclImpStream
& rStrm
);
431 void ReadXF5( XclImpStream
& rStrm
);
432 void ReadXF8( XclImpStream
& rStrm
);
434 /** Sets all "attribute used" flags according to the passed mask.
435 @descr In cell XFs, a set bit represents "used", in style XFs it is a cleared bit.
436 Therefore mbCellXF must be set correctly before calling this method. */
437 void SetUsedFlags( sal_uInt8 nUsedFlags
);
438 /** Sets own "attribute used" flags, if attributes are different from passed parent XF. */
439 void UpdateUsedFlags( const XclImpXF
& rParentXF
);
441 /** Creates a Calc item set containing an item set with all cell properties.
442 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items.
443 @return A read-only reference to the item set stored internally. */
444 const ScPatternAttr
& CreatePattern( bool bSkipPoolDefs
= false );
445 /** Creates a cell style sheet and inserts it into the Calc document.
446 @descr Creates a style sheet only for style XFs with a valid style name.
447 @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
448 ScStyleSheet
* CreateStyleSheet();
451 typedef ::std::auto_ptr
< ScPatternAttr
> ScPatternAttrPtr
;
453 ScPatternAttrPtr mpPattern
; /// Calc item set.
454 String maStyleName
; /// Name of the style sheet.
455 ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
457 XclImpCellProt maProtection
; /// Cell protection flags.
458 XclImpCellAlign maAlignment
; /// All alignment attributes.
459 XclImpCellBorder maBorder
; /// Border line style.
460 XclImpCellArea maArea
; /// Background area style.
461 sal_uInt16 mnXclNumFmt
; /// Index to number format.
462 sal_uInt16 mnXclFont
; /// Index to font record.
464 bool mbWasBuiltIn
; /// true = XF was an Excel built-in style.
465 bool mbForceCreate
; /// true = Force creation of style sheet.
468 // ----------------------------------------------------------------------------
470 /** Contains all XF records occured in the file.
471 @descr This class is able to read XF records (BIFF2 - BIFF8) and STYLE records (BIFF8). */
472 class XclImpXFBuffer
: protected XclImpRoot
, ScfNoCopy
475 explicit XclImpXFBuffer( const XclImpRoot
& rRoot
);
477 /** Clears all buffered data, used to set up for a new sheet. */
480 /** Reads an XF record. */
481 void ReadXF( XclImpStream
& rStrm
);
482 /** Reads a STYLE record. */
483 void ReadStyle( XclImpStream
& rStrm
);
485 /** Returns the object that stores all contents of an XF record. */
486 inline XclImpXF
* GetXF( sal_uInt16 nXFIndex
) const
487 { return maXFList
.GetObject( nXFIndex
); }
489 /** Returns the index to the Excel font used in the specified XF record. */
490 sal_uInt16
GetFontIndex( sal_uInt16 nXFIndex
) const;
491 /** Returns the Excel font used in the specified XF record. */
492 const XclImpFont
* GetFont( sal_uInt16 nXFIndex
) const;
494 /** Creates all user defined style sheets. */
495 void CreateUserStyles();
497 /** Inserts formatting attributes from an XF to the specified area in the Calc document.
498 @param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
499 the number format of the XF. */
501 SCCOL nScCol1
, SCROW nScRow1
,
502 SCCOL nScCol2
, SCROW nScRow2
,
503 SCTAB nScTab
, const XclImpXFIndex
& rXFIndex
);
506 ScfDelList
< XclImpXF
> maXFList
; /// List of contents of all XF record.
509 // Buffer for XF indexes in cells =============================================
511 /** Contains an (encoded) XF index for a range of rows in a single column. */
514 DECL_FIXEDMEMPOOL_NEWDEL( XclImpXFRange
)
517 SCROW mnScRow1
; /// The first row of an equal-formatted range.
518 SCROW mnScRow2
; /// The last row of an equal-formatted range.
519 XclImpXFIndex maXFIndex
; /// Extended XF index.
521 inline explicit XclImpXFRange( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
522 inline explicit XclImpXFRange( SCROW nFirstScRow
, SCROW nLastScRow
, const XclImpXFIndex
& rXFIndex
);
524 /** Returns true, if nScRow is contained in own row range. */
525 inline bool Contains( SCROW nScRow
) const;
527 /** Returns true, if the range has been expanded. */
528 bool Expand( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
529 /** Returns true, if the range has been expanded. */
530 bool Expand( const XclImpXFRange
& rNextRange
);
533 inline XclImpXFRange::XclImpXFRange( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
) :
536 maXFIndex( rXFIndex
)
540 inline XclImpXFRange::XclImpXFRange( SCROW nFirstScRow
, SCROW nLastScRow
, const XclImpXFIndex
& rXFIndex
) :
541 mnScRow1( nFirstScRow
),
542 mnScRow2( nLastScRow
),
543 maXFIndex( rXFIndex
)
547 inline bool XclImpXFRange::Contains( SCROW nScRow
) const
549 return (mnScRow1
<= nScRow
) && (nScRow
<= mnScRow2
);
552 // ----------------------------------------------------------------------------
554 /** Contains the XF indexes for every used cell in a column. */
555 class XclImpXFRangeColumn
: ScfNoCopy
558 inline explicit XclImpXFRangeColumn() {}
560 /** Returns the first formatted cell range in this column. */
561 inline XclImpXFRange
* First() { return maIndexList
.First(); }
562 /** Returns the next formatted cell range in this column. */
563 inline XclImpXFRange
* Next() { return maIndexList
.Next(); }
565 /** Inserts a single row range into the list. */
566 void SetDefaultXF( const XclImpXFIndex
& rXFIndex
);
568 /** Inserts a new (encoded) XF index (first try to expand the last range). */
569 void SetXF( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
572 /** Finds the previous and next row range from row position nScRow.
573 @descr If an XF still exists, it is contained in rpPrevRange. */
575 XclImpXFRange
*& rpPrevRange
,
576 XclImpXFRange
*& rpNextRange
,
578 SCROW nScRow
) const;
580 /** Tries to concatenate a range with its predecessor.
581 @descr The ranges must have the same XF index and must not have a gap.
582 The resulting range has the index nIndex-1. */
583 void TryConcatPrev( ULONG nIndex
);
586 ScfDelList
< XclImpXFRange
> maIndexList
; /// The list of XF index range.
589 // ----------------------------------------------------------------------------
591 /** Contains the XF indexes for every used cell in a single sheet. */
592 class XclImpXFRangeBuffer
: protected XclImpRoot
, ScfNoCopy
595 explicit XclImpXFRangeBuffer( const XclImpRoot
& rRoot
);
596 virtual ~XclImpXFRangeBuffer();
598 /** Clears all buffered data, used to set up for a new sheet. */
601 /** Inserts a new XF index. */
602 void SetXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
603 /** Inserts a new XF index for blank cells. */
604 void SetBlankXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
605 /** Inserts a new XF index for boolean cells. */
606 void SetBoolXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
607 /** Inserts a new XF index for all cells in a row. */
608 void SetRowDefXF( SCROW nScRow
, sal_uInt16 nXFIndex
);
609 /** Inserts a new XF index for all cells in a column. */
610 void SetColumnDefXF( SCCOL nScCol
, sal_uInt16 nXFIndex
);
612 /** Inserts a range of hyperlink cells. */
613 void SetHyperlink( const XclRange
& rXclRange
, const String
& rUrl
);
615 /** Inserts the first cell of a merged cell range. */
616 void SetMerge( SCCOL nScCol
, SCROW nScRow
);
617 /** Inserts a complete merged cell range. */
618 void SetMerge( SCCOL nScCol1
, SCROW nScRow1
, SCCOL nScCol2
, SCROW nScRow2
);
620 /** Applies styles and cell merging to the current sheet in the document. */
624 /** Insertion mode of an XF index. */
625 enum XclImpXFInsertMode
627 xlXFModeCell
, /// Filled cell.
628 xlXFModeBoolCell
, /// Cell with a single Boolean value.
629 xlXFModeBlank
, /// Blank cell.
630 xlXFModeRow
/// Row default XF.
634 /** Inserts a new XF index for the specified cell type. */
635 void SetXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
, XclImpXFInsertMode eMode
);
637 /** Copies border of the last cell of the range to the first cell to keep it visible
638 when the range is merged.
640 BOX_LINE_RIGHT = copy most-right border of top row;
641 BOX_LINE_BOTTOM = copy most-bottom border of first column. */
642 void SetBorderLine( const ScRange
& rRange
, SCTAB nScTab
, USHORT nLine
);
645 typedef ScfRef
< XclImpXFRangeColumn
> XclImpXFRangeColumnRef
;
646 typedef ::std::vector
< XclImpXFRangeColumnRef
> XclImpXFRangeColumnVec
;
647 typedef ::std::pair
< XclRange
, String
> XclImpHyperlinkRange
;
648 typedef ::std::list
< XclImpHyperlinkRange
> XclImpHyperlinkList
;
650 XclImpXFRangeColumnVec maColumns
; /// Array of column XF index buffers.
651 XclImpHyperlinkList maHyperlinks
; /// Maps URLs to hyperlink cells.
652 ScRangeList maMergeList
; /// List of merged cell ranges.
655 // ============================================================================