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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XISTYLE_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XISTYLE_HXX
26 #include <tools/mempool.hxx>
27 #include "rangelst.hxx"
28 #include "patattr.hxx"
29 #include "xladdress.hxx"
30 #include "xlstyle.hxx"
34 enum class SvxBoxItemLine
;
36 /* ============================================================================
37 - Buffers for style records (PALETTE, FONT, FORMAT, XF)
38 and a container for XF indexes for every used cell in a sheet.
39 ============================================================================ */
41 // PALETTE record - color information =========================================
43 /** Stores the default colors for the current BIFF version and the contents of
45 class XclImpPalette
: public XclDefaultPalette
48 explicit XclImpPalette( const XclImpRoot
& rRoot
);
50 /** Clears all buffered data, used to set up for a new sheet. */
53 /** Returns the RGB color data for a (non-zero-based) Excel palette entry.
54 @descr First looks for a color read from file, then looks for a default color.
55 @return The color from current or default palette or COL_AUTO, if nothing else found. */
56 ColorData
GetColorData( sal_uInt16 nXclIndex
) const;
57 /** Returns the color for a (non-zero-based) Excel palette entry.
58 @descr First looks for a color read from file, then looks for a default color.
59 @return The color from current or default palette or COL_AUTO, if nothing else found. */
60 inline Color
GetColor( sal_uInt16 nXclIndex
) const
61 { return Color( GetColorData( nXclIndex
) ); }
63 /** Reads a PALETTE record. */
64 void ReadPalette( XclImpStream
& rStrm
);
68 typedef ::std::vector
< ColorData
> ColorDataVec
;
69 ColorDataVec maColorTable
; /// Colors read from file.
70 const XclImpRoot
& mrRoot
;
73 // FONT record - font information =============================================
75 /** Stores all data of an Excel font and provides import of FONT records. */
76 class XclImpFont
: protected XclImpRoot
79 explicit XclImpFont( const XclImpRoot
& rRoot
);
81 /** Constructs a font from font data.
82 @descr Special handling for font style (bold, italic) in font name,
83 overwrites settings in rFontData. */
84 explicit XclImpFont( const XclImpRoot
& rRoot
, const XclFontData
& rFontData
);
86 /** Sets all font attributes to used or unused. */
87 void SetAllUsedFlags( bool bUsed
);
88 /** Sets the passed font data and all used flags to 'used'. */
89 void SetFontData( const XclFontData
& rFontData
, bool bHasCharSet
);
91 /** Returns read-only access to font data. */
92 inline const XclFontData
& GetFontData() const { return maData
; }
93 /** Returns true, if the font character set is valid. */
94 inline bool HasCharSet() const { return mbHasCharSet
; }
95 /** Returns true, if the font contains superscript or subscript. */
96 inline bool HasEscapement() const { return maData
.mnEscapem
!= EXC_FONTESC_NONE
; }
97 /** Returns the text encoding for strings used with this font. */
98 rtl_TextEncoding
GetFontEncoding() const;
100 /** Returns true, if this font contains characters for Asian scripts (CJK). */
101 inline bool HasAsianChars() const { return mbHasAsian
; }
103 /** Reads a FONT record for all BIFF versions. */
104 void ReadFont( XclImpStream
& rStrm
);
105 /** Reads an EFONT record (BIFF2 font color). */
106 void ReadEfont( XclImpStream
& rStrm
);
107 /** Reads the font block from a CF (conditional format) record. */
108 void ReadCFFontBlock( XclImpStream
& rStrm
);
110 /** Fills all font properties to the item set.
111 @param rItemSet The destination item set.
112 @param eType The type of Which-IDs.
113 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
114 void FillToItemSet( SfxItemSet
& rItemSet
, XclFontItemType eType
,
115 bool bSkipPoolDefs
= false ) const;
116 /** Writes all font properties to the passed property set.
117 @param pFontColor If set, overrides internal stored font color. */
118 void WriteFontProperties( ScfPropertySet
& rPropSet
,
119 XclFontPropSetType eType
, const Color
* pFontColor
= nullptr ) const;
122 /** Reads and sets height and flags. */
123 void ReadFontData2( XclImpStream
& rStrm
);
124 /** Reads and sets height, flags, color, boldness, script, family and charset. */
125 void ReadFontData5( XclImpStream
& rStrm
);
127 /** Reads and sets the font color. */
128 void ReadFontColor( XclImpStream
& rStrm
);
130 /** Reads and sets a byte string as font name. */
131 void ReadFontName2( XclImpStream
& rStrm
);
132 /** Reads and sets a Unicode string as font name. */
133 void ReadFontName8( XclImpStream
& rStrm
);
135 /** Tests whether the font contains CJK or CTL characters.
136 @descr This is only a weak guess using preselected characters. */
137 void GuessScriptType();
140 XclFontData maData
; /// All font attributes.
141 bool mbHasCharSet
; /// true = Font contains own character set info.
142 bool mbHasWstrn
; /// true = Font contains Western script characters.
143 bool mbHasAsian
; /// true = Font contains Asian script characters.
144 bool mbHasCmplx
; /// true = Font contains Complex script characters.
145 bool mbFontNameUsed
; /// true = Font name, family, charset used.
146 bool mbHeightUsed
; /// true = Font height used.
147 bool mbColorUsed
; /// true = Color used.
148 bool mbWeightUsed
; /// true = Weight used.
149 bool mbEscapemUsed
; /// true = Escapement type used.
150 bool mbUnderlUsed
; /// true = Underline style used.
151 bool mbItalicUsed
; /// true = Italic used.
152 bool mbStrikeUsed
; /// true = Strikeout used.
153 bool mbOutlineUsed
; /// true = Outlined used.
154 bool mbShadowUsed
; /// true = Shadowed used.
157 /** Stores the data of all fonts occurred in an Excel file. */
158 class XclImpFontBuffer
: protected XclImpRoot
161 /** delete copy constructor */
162 XclImpFontBuffer(const XclImpFontBuffer
&) = delete;
163 /** delete copy-assignment operator */
164 const XclImpFontBuffer
& operator=(const XclImpFontBuffer
&) = delete;
166 explicit XclImpFontBuffer( const XclImpRoot
& rRoot
);
168 /** Clears all buffered data, used to set up for a new sheet. */
171 /** Returns the object that stores all contents of a FONT record. */
172 const XclImpFont
* GetFont( sal_uInt16 nFontIndex
) const;
173 /** Returns the application font data of this file, needed i.e. for column width. */
174 inline const XclFontData
& GetAppFontData() const { return maAppFont
; }
176 /** Reads a FONT record. */
177 void ReadFont( XclImpStream
& rStrm
);
178 /** Reads an EFONT record (BIFF2 font color). */
179 void ReadEfont( XclImpStream
& rStrm
);
181 /** Fills all font properties from a FONT record to the item set.
182 @param rItemSet The destination item set.
183 @param eType The type of Which-IDs.
184 @param nFontIdx The Excel index of the font.
185 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
186 void FillToItemSet( SfxItemSet
& rItemSet
, XclFontItemType eType
,
187 sal_uInt16 nFontIdx
, bool bSkipPoolDefs
= false ) const;
188 /** Writes all font properties to the passed property set.
189 @param pFontColor If set, overrides internal stored font color. */
190 void WriteFontProperties(
191 ScfPropertySet
& rPropSet
, XclFontPropSetType eType
,
192 sal_uInt16 nFontIdx
, const Color
* pFontColor
= nullptr ) const;
193 /** Writes default font properties for form controls to the passed property set. */
194 void WriteDefaultCtrlFontProperties( ScfPropertySet
& rPropSet
) const;
197 /** Updates the application default font. */
198 void UpdateAppFont( const XclFontData
& rFontData
, bool bHasCharSet
);
201 std::vector
< XclImpFont
> maFontList
; /// List of all FONT records in the Excel file.
202 XclFontData maAppFont
; /// Application font (for column width).
203 XclImpFont maFont4
; /// Built-in font with index 4.
204 XclImpFont maCtrlFont
; /// BIFF5 default form controls font (Helv,8pt,bold).
207 // FORMAT record - number formats =============================================
209 /** Stores all user defined number formats occurred in the file. */
210 class XclImpNumFmtBuffer
: public XclNumFmtBuffer
, protected XclImpRoot
213 explicit XclImpNumFmtBuffer( const XclImpRoot
& rRoot
);
215 /** Clears all buffered data, used to set up for a new sheet. */
218 /** Reads a FORMAT record. */
219 void ReadFormat( XclImpStream
& rStrm
);
221 /** Read NumFmt from conditional format record */
222 sal_uInt16
ReadCFFormat( XclImpStream
& rStrm
, bool bIFmt
);
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 sal_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
, sal_uLong nScNumFmt
,
243 bool bSkipPoolDefs
= false ) const;
246 typedef ::std::map
< sal_uInt16
, sal_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 /** Extends the XclCellAlign struct for import.
269 @descr Provides functions to fill from Excel record data and to fill to item sets. */
270 struct XclImpCellAlign
: public XclCellAlign
272 /** Fills this struct with BIFF2 XF record data. */
273 void FillFromXF2( sal_uInt8 nFlags
);
274 /** Fills this struct with BIFF3 XF record data. */
275 void FillFromXF3( sal_uInt16 nAlign
);
276 /** Fills this struct with BIFF4 XF record data. */
277 void FillFromXF4( sal_uInt16 nAlign
);
278 /** Fills this struct with BIFF5/BIFF7 XF record data. */
279 void FillFromXF5( sal_uInt16 nAlign
);
280 /** Fills this struct with BIFF8 XF record data. */
281 void FillFromXF8( sal_uInt16 nAlign
, sal_uInt16 nMiscAttrib
);
282 /** Fills this struct with CF record data. */
283 void FillFromCF( 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 /** Extends the XclCellBorder struct for import.
291 @descr Provides functions to fill from Excel record data and to fill to item sets. */
292 struct XclImpCellBorder
: public XclCellBorder
294 bool mbLeftUsed
; /// true = Left line style used.
295 bool mbRightUsed
; /// true = Right line style used.
296 bool mbTopUsed
; /// true = Top line style used.
297 bool mbBottomUsed
; /// true = Bottom line style used.
298 bool mbDiagUsed
; /// true = Diagonal line style used.
300 explicit XclImpCellBorder();
302 /** Sets outer line states and diagonal line states to used or unused. */
303 void SetUsedFlags( bool bOuterUsed
, bool bDiagUsed
);
305 /** Fills this struct with BIFF2 XF record data. */
306 void FillFromXF2( sal_uInt8 nFlags
);
307 /** Fills this struct with BIFF3/BIFF4 XF record data. */
308 void FillFromXF3( sal_uInt32 nBorder
);
309 /** Fills this struct with BIFF5/BIFF7 XF record data. */
310 void FillFromXF5( sal_uInt32 nBorder
, sal_uInt32 nArea
);
311 /** Fills this struct with BIFF8 XF record data. */
312 void FillFromXF8( sal_uInt32 nBorder1
, sal_uInt32 nBorder2
);
314 /** Fills this struct with BIFF8 CF (conditional format) record data. */
315 void FillFromCF8( sal_uInt16 nLineStyle
, sal_uInt32 nLineColor
, sal_uInt32 nFlags
);
317 /** Returns true, if any of the outer border lines is visible. */
318 bool HasAnyOuterBorder() const;
320 /** Inserts a box item representing this border style into the item set.
321 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
323 SfxItemSet
& rItemSet
,
324 const XclImpPalette
& rPalette
,
325 bool bSkipPoolDefs
= false ) const;
328 /** Extends the XclCellArea struct for import.
329 @descr Provides functions to fill from Excel record data and to fill to item sets. */
330 struct XclImpCellArea
: public XclCellArea
332 bool mbForeUsed
; /// true = Foreground color used.
333 bool mbBackUsed
; /// true = Background color used.
334 bool mbPattUsed
; /// true = Pattern used.
336 explicit XclImpCellArea();
338 /** Sets colors and pattern state to used or unused. */
339 void SetUsedFlags( bool bUsed
);
341 /** Fills this struct with BIFF2 XF record data. */
342 void FillFromXF2( sal_uInt8 nFlags
);
343 /** Fills this struct with BIFF3/BIFF4 XF record data. */
344 void FillFromXF3( sal_uInt16 nArea
);
345 /** Fills this struct with BIFF5/BIFF7 XF record data. */
346 void FillFromXF5( sal_uInt32 nArea
);
347 /** Fills this struct with BIFF8 XF record data. */
348 void FillFromXF8( sal_uInt32 nBorder2
, sal_uInt16 nArea
);
350 /** Fills this struct with BIFF8 CF (conditional format) record data. */
351 void FillFromCF8( sal_uInt16 nPattern
, sal_uInt16 nColor
, sal_uInt32 nFlags
);
353 /** Inserts a brush item representing this area style into the item set.
354 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
356 SfxItemSet
& rItemSet
,
357 const XclImpPalette
& rPalette
,
358 bool bSkipPoolDefs
= false ) const;
361 /** Represents an XF record index with additional information. */
365 inline explicit XclImpXFIndex( sal_uInt16 nXFIndex
, bool bBoolCell
= false ) :
366 mnXFIndex( nXFIndex
), mbBoolCell( bBoolCell
) {}
368 inline sal_uInt16
GetXFIndex() const { return mnXFIndex
; }
369 inline bool IsBoolCell() const { return mbBoolCell
; }
372 sal_uInt16 mnXFIndex
; /// The XF record index.
373 bool mbBoolCell
; /// true = A Boolean value cell.
376 inline bool operator==( const XclImpXFIndex
& rLeft
, const XclImpXFIndex
& rRight
)
377 { return (rLeft
.GetXFIndex() == rRight
.GetXFIndex()) && (rLeft
.IsBoolCell() == rRight
.IsBoolCell()); }
379 inline bool operator!=( const XclImpXFIndex
& rLeft
, const XclImpXFIndex
& rRight
)
380 { return !(rLeft
== rRight
); }
382 /** Contains all data of a XF record and a Calc item set. */
383 class XclImpXF
: public XclXFBase
, protected XclImpRoot
386 /** make noncopyable */
387 XclImpXF(const XclImpXF
&) = delete;
388 const XclImpXF
& operator=(const XclImpXF
&) = delete;
390 explicit XclImpXF( const XclImpRoot
& rRoot
);
393 /** Reads an XF record. */
394 void ReadXF( XclImpStream
& rStrm
);
396 inline sal_uInt8
GetHorAlign() const { return maAlignment
.mnHorAlign
; }
397 inline sal_uInt16
GetFontIndex() const { return mnXclFont
; }
399 /** Creates a Calc item set containing an item set with all cell properties.
400 @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items.
401 @return A read-only reference to the item set stored internally. */
402 const ScPatternAttr
& CreatePattern( bool bSkipPoolDefs
= false );
404 void ApplyPatternToAttrList(
405 ::std::list
<ScAttrEntry
>& rAttrs
, SCROW nRow1
, SCROW nRow2
,
406 sal_uInt32 nForceScNumFmt
= NUMBERFORMAT_ENTRY_NOT_FOUND
);
408 /** Inserts all formatting attributes to the specified area in the Calc document.
409 @param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
410 the number format of the XF. */
412 SCCOL nScCol1
, SCROW nScRow1
,
413 SCCOL nScCol2
, SCROW nScRow2
,
416 /** Converts formatting information from BIFF2 cell record data directly. */
417 static void ApplyPatternForBiff2CellFormat(
418 const XclImpRoot
& rRoot
, const ScAddress
& rScPos
,
419 sal_uInt8 nFlags1
, sal_uInt8 nFlags2
, sal_uInt8 nFlags3
);
422 void ReadXF2( XclImpStream
& rStrm
);
423 void ReadXF3( XclImpStream
& rStrm
);
424 void ReadXF4( XclImpStream
& rStrm
);
425 void ReadXF5( XclImpStream
& rStrm
);
426 void ReadXF8( XclImpStream
& rStrm
);
428 /** Sets all "attribute used" flags according to the passed mask.
429 @descr In cell XFs, a set bit represents "used", in style XFs it is a cleared bit.
430 Therefore mbCellXF must be set correctly before calling this method. */
431 void SetUsedFlags( sal_uInt8 nUsedFlags
);
434 typedef ::std::unique_ptr
< ScPatternAttr
> ScPatternAttrPtr
;
436 ScPatternAttrPtr mpPattern
; /// Calc item set.
437 ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
439 XclImpCellProt maProtection
; /// Cell protection flags.
440 XclImpCellAlign maAlignment
; /// All alignment attributes.
441 XclImpCellBorder maBorder
; /// Border line style.
442 XclImpCellArea maArea
; /// Background area style.
443 sal_uInt16 mnXclNumFmt
; /// Index to number format.
444 sal_uInt16 mnXclFont
; /// Index to font record.
447 /** Contains all data of a cell style associated with an XF record. */
448 class XclImpStyle
: protected XclImpRoot
451 explicit XclImpStyle( const XclImpRoot
& rRoot
);
453 /** Reads a STYLE record. */
454 void ReadStyle( XclImpStream
& rStrm
);
456 inline const OUString
& GetName() const { return maName
; }
457 inline sal_uInt16
GetXfId() const { return mnXfId
; }
458 inline bool IsBuiltin() const { return mbBuiltin
&& (mnBuiltinId
!= EXC_STYLE_USERDEF
); }
459 inline sal_uInt8
GetBuiltinId() const { return mnBuiltinId
; }
460 inline sal_uInt8
GetLevel() const { return mnLevel
; }
462 /** Creates a cell style sheet and inserts it into the Calc document.
463 @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
464 ScStyleSheet
* CreateStyleSheet();
465 /** Creates the Calc style sheet, if this is a user-defined style. */
466 void CreateUserStyle( const OUString
& rFinalName
);
469 OUString maName
; /// Cell style name.
470 sal_uInt16 mnXfId
; /// Formatting for this cell style.
471 sal_uInt8 mnBuiltinId
; /// Identifier for builtin styles.
472 sal_uInt8 mnLevel
; /// Level for builtin column/row styles.
473 bool mbBuiltin
; /// True = builtin style.
474 bool mbCustom
; /// True = customized builtin style.
475 bool mbHidden
; /// True = style not visible in GUI.
477 OUString maFinalName
; /// Final name used in the Calc document.
478 ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
481 /** Contains all XF records occurred in the file.
482 @descr This class is able to read XF records (BIFF2 - BIFF8) and STYLE records (BIFF8). */
483 class XclImpXFBuffer
: protected XclImpRoot
486 /** make noncopyable */
487 XclImpXFBuffer(const XclImpXFBuffer
&) = delete;
488 const XclImpXFBuffer
& operator=(const XclImpXFBuffer
&) = delete;
490 explicit XclImpXFBuffer( const XclImpRoot
& rRoot
);
492 /** Clears all buffered data, used to set up for a new sheet. */
495 /** Reads an XF record. */
496 void ReadXF( XclImpStream
& rStrm
);
497 /** Reads a STYLE record. */
498 void ReadStyle( XclImpStream
& rStrm
);
500 /** Returns the object that stores all contents of an XF record. */
501 inline XclImpXF
* GetXF( sal_uInt16 nXFIndex
)
502 { return (nXFIndex
>= maXFList
.size()) ? nullptr : maXFList
.at(nXFIndex
).get(); }
504 inline const XclImpXF
* GetXF( sal_uInt16 nXFIndex
) const
505 { return (nXFIndex
>= maXFList
.size()) ? nullptr : maXFList
.at(nXFIndex
).get(); }
507 /** Returns the index to the Excel font used in the specified XF record. */
508 sal_uInt16
GetFontIndex( sal_uInt16 nXFIndex
) const;
509 /** Returns the Excel font used in the specified XF record. */
510 const XclImpFont
* GetFont( sal_uInt16 nXFIndex
) const;
512 /** Creates all user defined style sheets. */
513 void CreateUserStyles();
514 /** Creates a cell style sheet of the passed XF and inserts it into the Calc document.
515 @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
516 ScStyleSheet
* CreateStyleSheet( sal_uInt16 nXFIndex
);
519 typedef std::vector
< std::unique_ptr
<XclImpStyle
> > XclImpStyleList
;
520 typedef ::std::map
< sal_uInt16
, XclImpStyle
* > XclImpStyleMap
;
522 std::vector
< std::unique_ptr
<XclImpXF
> > maXFList
; /// List of contents of all XF record.
523 XclImpStyleList maBuiltinStyles
; /// List of built-in cell styles.
524 XclImpStyleList maUserStyles
; /// List of user defined cell styles.
525 XclImpStyleMap maStylesByXf
; /// Maps XF records to cell styles.
528 // Buffer for XF indexes in cells =============================================
530 /** Contains an (encoded) XF index for a range of rows in a single column. */
533 DECL_FIXEDMEMPOOL_NEWDEL( XclImpXFRange
)
536 SCROW mnScRow1
; /// The first row of an equal-formatted range.
537 SCROW mnScRow2
; /// The last row of an equal-formatted range.
538 XclImpXFIndex maXFIndex
; /// Extended XF index.
540 inline explicit XclImpXFRange( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
541 inline explicit XclImpXFRange( SCROW nFirstScRow
, SCROW nLastScRow
, const XclImpXFIndex
& rXFIndex
);
543 /** Returns true, if nScRow is contained in own row range. */
544 inline bool Contains( SCROW nScRow
) const;
546 /** Returns true, if the range has been expanded. */
547 bool Expand( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
);
548 /** Returns true, if the range has been expanded. */
549 bool Expand( const XclImpXFRange
& rNextRange
);
552 inline XclImpXFRange::XclImpXFRange( SCROW nScRow
, const XclImpXFIndex
& rXFIndex
) :
555 maXFIndex( rXFIndex
)
559 inline XclImpXFRange::XclImpXFRange( SCROW nFirstScRow
, SCROW nLastScRow
, const XclImpXFIndex
& rXFIndex
) :
560 mnScRow1( nFirstScRow
),
561 mnScRow2( nLastScRow
),
562 maXFIndex( rXFIndex
)
566 inline bool XclImpXFRange::Contains( SCROW nScRow
) const
568 return (mnScRow1
<= nScRow
) && (nScRow
<= mnScRow2
);
571 /** Contains the XF indexes for every used cell in a column. */
572 class XclImpXFRangeColumn
575 /** make noncopyable */
576 XclImpXFRangeColumn(const XclImpXFRangeColumn
&) = delete;
577 const XclImpXFRangeColumn
& operator=(const XclImpXFRangeColumn
&) = delete;
579 typedef std::vector
< std::unique_ptr
<XclImpXFRange
> > IndexList
;
581 inline explicit XclImpXFRangeColumn() {}
583 IndexList::iterator
begin() { return maIndexList
.begin(); }
584 IndexList::iterator
end() { return maIndexList
.end(); }
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
,
598 sal_uLong
& rnNextIndex
,
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( sal_uLong nIndex
);
606 /** Insert a range into the list at the specified index. */
607 void Insert(XclImpXFRange
* pXFRange
, sal_uLong nIndex
);
610 IndexList maIndexList
; /// The list of XF index range.
613 /** Contains the XF indexes for every used cell in a single sheet. */
614 class XclImpXFRangeBuffer
: protected XclImpRoot
617 /** make noncopyable */
618 XclImpXFRangeBuffer(const XclImpXFRangeBuffer
&) = delete;
619 const XclImpXFRangeBuffer
& operator=(const XclImpXFRangeBuffer
&) = delete;
621 explicit XclImpXFRangeBuffer( const XclImpRoot
& rRoot
);
622 virtual ~XclImpXFRangeBuffer();
624 /** Clears all buffered data, used to set up for a new sheet. */
627 /** Inserts a new XF index. */
628 void SetXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
629 /** Inserts a new XF index for blank cells. */
630 void SetBlankXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
631 /** Inserts a new XF index for boolean cells. */
632 void SetBoolXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
);
633 /** Inserts a new XF index for all cells in a row. */
634 void SetRowDefXF( SCROW nScRow
, sal_uInt16 nXFIndex
);
635 /** Inserts a new XF index for all cells in a column. */
636 void SetColumnDefXF( SCCOL nScCol
, sal_uInt16 nXFIndex
);
638 /** Inserts a range of hyperlink cells. */
639 void SetHyperlink( const XclRange
& rXclRange
, const OUString
& rUrl
);
641 /** Inserts the first cell of a merged cell range. */
642 void SetMerge( SCCOL nScCol
, SCROW nScRow
);
643 /** Inserts a complete merged cell range. */
644 void SetMerge( SCCOL nScCol1
, SCROW nScRow1
, SCCOL nScCol2
, SCROW nScRow2
);
646 /** Applies styles and cell merging to the current sheet in the document. */
650 /** Insertion mode of an XF index. */
651 enum XclImpXFInsertMode
653 xlXFModeCell
, /// Filled cell.
654 xlXFModeBoolCell
, /// Cell with a single Boolean value.
655 xlXFModeBlank
, /// Blank cell.
656 xlXFModeRow
/// Row default XF.
660 /** Inserts a new XF index for the specified cell type. */
661 void SetXF( const ScAddress
& rScPos
, sal_uInt16 nXFIndex
, XclImpXFInsertMode eMode
);
663 /** Copies border of the last cell of the range to the first cell to keep it visible
664 when the range is merged.
666 SvxBoxItemLine::RIGHT = copy most-right border of top row;
667 SvxBoxItemLine::BOTTOM = copy most-bottom border of first column. */
668 void SetBorderLine( const ScRange
& rRange
, SCTAB nScTab
, SvxBoxItemLine nLine
);
671 typedef std::shared_ptr
< XclImpXFRangeColumn
> XclImpXFRangeColumnRef
;
672 typedef ::std::vector
< XclImpXFRangeColumnRef
> XclImpXFRangeColumnVec
;
673 typedef ::std::pair
< XclRange
, OUString
> XclImpHyperlinkRange
;
674 typedef ::std::list
< XclImpHyperlinkRange
> XclImpHyperlinkList
;
676 XclImpXFRangeColumnVec maColumns
; /// Array of column XF index buffers.
677 XclImpHyperlinkList maHyperlinks
; /// Maps URLs to hyperlink cells.
678 ScRangeList maMergeList
; /// List of merged cell ranges.
683 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */