LibreOffice Module sc (master)  1
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at .
18  */
20 #pragma once
22 #include <vector>
23 #include <map>
24 #include <set>
25 #include <o3tl/sorted_vector.hxx>
27 #include "richstring.hxx"
28 #include "worksheethelper.hxx"
29 #include "addressconverter.hxx"
31 namespace com::sun::star {
32  namespace util { struct DateTime; }
33 }
35 namespace oox::xls {
38 struct CellModel
39 {
41  sal_Int32 mnCellType;
42  sal_Int32 mnXfId;
45  explicit CellModel();
46 };
50 {
52  sal_Int32 mnFormulaType;
53  sal_Int32 mnSharedId;
55  explicit CellFormulaModel();
58  bool isValidArrayRef( const ScAddress& rCellAddr );
60  bool isValidSharedRef( const ScAddress& rCellAddr );
61 };
65 {
66  OUString maRef1;
67  OUString maRef2;
68  bool mb2dTable;
69  bool mbRowTable;
73  explicit DataTableModel();
74 };
78 {
79 public:
80  explicit CellBlockBuffer( const WorksheetHelper& rHelper );
83  void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans );
85 private:
86  typedef ::std::map< sal_Int32, ValueRangeVector > ColSpanVectorMap;
88  ColSpanVectorMap maColSpans;
89  sal_Int32 mnCurrRow;
90 };
95 {
96 public:
97  explicit SheetDataBuffer( const WorksheetHelper& rHelper );
100  void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans );
103  void setBlankCell( const CellModel& rModel );
105  void setValueCell( const CellModel& rModel, double fValue );
107  void setStringCell( const CellModel& rModel, const OUString& rText );
109  void setStringCell( const CellModel& rModel, const RichStringRef& rxString );
111  void setStringCell( const CellModel& rModel, sal_Int32 nStringId );
113  void setDateTimeCell( const CellModel& rModel, const css::util::DateTime& rDateTime );
115  void setBooleanCell( const CellModel& rModel, bool bValue );
117  void setErrorCell( const CellModel& rModel, const OUString& rErrorCode );
119  void setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode );
121  void setFormulaCell( const CellModel& rModel, const ApiTokenSequence& rTokens );
123  void setDateCell( const CellModel& rModel, const OUString& rDateString );
125  void createSharedFormula(
126  const ScAddress& rRange,
127  const ApiTokenSequence& rTokens);
130  void createArrayFormula(
131  const ScRange& rRange,
132  const ApiTokenSequence& rTokens );
135  const ScRange& rRange,
136  const DataTableModel& rModel );
139  void setRowFormat( sal_Int32 nRow, sal_Int32 nXfId, bool bCustomFormat );
141  void setMergedRange( const ScRange& rRange );
144  void setCellFormat( const CellModel& rModel );
147  void finalizeImport();
150  void setCellFormula(
151  const ScAddress& rCellAddr,
152  const ApiTokenSequence& rTokens );
153 private:
157  ApiTokenSequence resolveSharedFormula( const ScAddress& rMapKey ) const;
161  const ScRange& rRange,
162  const ApiTokenSequence& rTokens ) const;
165  const ScRange& rRange, const DataTableModel& rModel );
168  void applyCellMerging( const ScRange& rRange );
169  void addColXfStyles();
171 private:
173  typedef std::pair< ScRange, ApiTokenSequence > ArrayFormula;
174  typedef ::std::vector< ArrayFormula > ArrayFormulaVector;
177  typedef std::pair< ScRange, DataTableModel > TableOperation;
181  {
183  sal_Int32 mnXfId;
185  explicit XfIdRowRange();
186  void set( sal_Int32 nRow, sal_Int32 nXfId );
187  bool tryExpand( sal_Int32 nRow, sal_Int32 nXfId );
188  };
190  typedef ::std::pair< sal_Int32, sal_Int32 > XfIdNumFmtKey;
193  {
194  sal_Int32 mnStartRow;
195  sal_Int32 mnEndRow;
196  XfIdNumFmtKey mnNumFmt;
197  };
199  {
200  bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const
201  {
202  return lhs.mnEndRow<rhs.mnStartRow;
203  }
204  };
205  typedef ::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles;
206  typedef ::std::map< sal_Int32, RowStyles > ColStyles;
208  struct MergedRange
209  {
211  sal_Int32 mnHorAlign;
213  explicit MergedRange( const ScRange& rRange );
214  explicit MergedRange( const ScAddress& rAddress, sal_Int32 nHorAlign );
215  bool tryExpand( const ScAddress& rAddress, sal_Int32 nHorAlign );
216  };
217  typedef ::std::vector< MergedRange > MergedRangeVector;
219  ColStyles maStylesPerColumn;
221  ArrayFormulaVector maArrayFormulas;
222  std::vector< TableOperation >
224  ::std::map< BinAddress, ApiTokenSequence >
229  std::map< XfIdNumFmtKey, ScRangeList >
231  MergedRangeVector maMergedRanges;
232  MergedRangeVector maCenterFillRanges;
234  std::map< sal_Int32, std::vector< ValueRange > > maXfIdRowRangeList;
235 };
237 } // namespace oox::xls
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports util
::std::map< BinAddress, ApiTokenSequence > maSharedFormulas
All table operations in the sheet.
sal_Int32 mnCurrRow
Buffered column spans, mapped by row index.
Manages all cell blocks currently in use.
::std::map< sal_Int32, ValueRangeVector > ColSpanVectorMap
void setDateTimeCell(const CellModel &rModel, const css::util::DateTime &rDateTime)
Inserts a date/time cell into the sheet and adjusts number format.
CellBlockBuffer(const WorksheetHelper &rHelper)
ArrayFormulaVector maArrayFormulas
Manages all open cell blocks.
sal_Int32 mnCellType
The address of the current cell.
XF identifier for the row range.
MergedRangeVector maMergedRanges
Collected XF identifiers for cell rangelists.
::std::pair< sal_Int32, sal_Int32 > XfIdNumFmtKey
bool tryExpand(sal_Int32 nRow, sal_Int32 nXfId)
bool mbPendingSharedFmla
Merged cell ranges from 'center across' or 'fill' alignment.
bool mbRowTable
True = 2-dimensional data table.
ApiTokenSequence resolveSharedFormula(const ScAddress &rMapKey) const
Creates a formula token array representing the shared formula with the passed identifier.
std::shared_ptr< RichString > RichStringRef
Definition: richstring.hxx:260
sal_Int32 mnXfId
Indexes of first and last row.
::std::vector< ArrayFormula > ArrayFormulaVector
sal_Int32 mnSharedId
Type of the formula (regular, array, shared, table).
bool mbRef1Deleted
True = row oriented data table.
Stores information about a range of rows with equal cell formatting.
void setBooleanCell(const CellModel &rModel, bool bValue)
Inserts a boolean cell into the sheet and adjusts number format.
void setRowFormat(sal_Int32 nRow, sal_Int32 nXfId, bool bCustomFormat)
Sets default cell formatting for the specified range of rows.
bool isValidArrayRef(const ScAddress &rCellAddr)
Returns true, if the passed cell address is valid for an array formula.
sal_Int32 mnXfId
Data type of the cell value.
void setValueCell(const CellModel &rModel, double fValue)
Inserts a value cell into the sheet.
void setMergedRange(const ScRange &rRange)
Merges the cells in the passed cell range.
ScAddress maSharedFmlaAddr
Maps shared formula base address to defined name token index.
void setDateCell(const CellModel &rModel, const OUString &rDateString)
Inserts an ISO 8601 date cell into the sheet.
Identifier of a shared formula (OOXML only).
Stores basic data about cell values and formatting.
std::vector< TableOperation > maTableOperations
All array formulas in the sheet.
True = show phonetic text.
void createTableOperation(const ScRange &rRange, const DataTableModel &rModel)
Sets a multiple table operation to the passed range.
::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles
MergedRangeVector maCenterFillRanges
Merged cell ranges.
std::map< sal_Int32, std::vector< ValueRange > > maXfIdRowRangeList
True = maSharedFmlaAddr and maSharedBaseAddr are valid.
std::map< XfIdNumFmtKey, ScRangeList > maXfIdRangeLists
Cached XF identifier for a range of rows.
void setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
bool isValidSharedRef(const ScAddress &rCellAddr)
Returns true, if the passed cell address is valid for a shared formula.
std::pair< ScRange, DataTableModel > TableOperation
Stores cell range address and settings of a table operation.
CellBlockBuffer maCellBlocks
Stores cell styles by column ( in row ranges )
void setErrorCell(const CellModel &rModel, const OUString &rErrorCode)
Inserts an error cell from the passed error code into the sheet.
::std::map< sal_Int32, RowStyles > ColStyles
MergedRange(const ScRange &rRange)
Horizontal alignment in the range.
True = second reference cell deleted.
css::uno::Sequence< ApiToken > ApiTokenSequence
void setBlankCell(const CellModel &rModel)
Inserts a blank cell (with formatting) into the sheet.
ScAddress maSharedBaseAddr
Address of a cell containing a pending shared formula.
::std::vector< MergedRange > MergedRangeVector
void setCellFormat(const CellModel &rModel)
Processes the cell formatting data of the passed cell.
void setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
std::pair< ScRange, ApiTokenSequence > ArrayFormula
Stores cell range address and formula token array of an array formula.
unsigned char sal_uInt8
sal_Int32 mnFormulaType
Formula range for array/shared formulas and data tables.
bool mbRef2Deleted
True = first reference cell deleted.
Stores data about cell formulas.
bool mbShowPhonetic
XF (cell formatting) identifier.
void applyCellMerging(const ScRange &rRange)
Writes all cell formatting attributes to the passed cell range list.
void createArrayFormula(const ScRange &rRange, const ApiTokenSequence &rTokens)
Inserts the passed token array as array formula.
bool operator()(const RowRangeStyle &lhs, const RowRangeStyle &rhs) const
void finalizeTableOperation(const ScRange &rRange, const DataTableModel &rModel)
Inserts the passed table operation into the sheet.
Stores information about a merged cell range.
XfIdRowRange maXfIdRowRange
Base address of the pending shared formula.
OUString maRef2
First reference cell for table operations.
void finalizeImport()
Final processing after the sheet has been imported.
sal_Int32 mnHorAlign
The formatted cell range.
void createSharedFormula(const ScAddress &rRange, const ApiTokenSequence &rTokens)
void finalizeArrayFormula(const ScRange &rRange, const ApiTokenSequence &rTokens) const
Inserts the passed array formula into the sheet.
bool mb2dTable
Second reference cell for table operations.
void setFormulaCell(const CellModel &rModel, const ApiTokenSequence &rTokens)
Inserts a formula cell into the sheet.
Stores data about table operations.
void set(sal_Int32 nRow, sal_Int32 nXfId)
void setStringCell(const CellModel &rModel, const OUString &rText)
Inserts a simple string cell into the sheet.
SheetDataBuffer(const WorksheetHelper &rHelper)
void setCellFormula(const ScAddress &rCellAddr, const ApiTokenSequence &rTokens)
Sets the passed formula token array into a cell.
Manages the cell contents and cell formatting of a sheet.
bool tryExpand(const ScAddress &rAddress, sal_Int32 nHorAlign)