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 -*- */
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>
26#include "richstring.hxx"
27#include "worksheethelper.hxx"
28#include "addressconverter.hxx"
30namespace com::sun::star {
31 namespace util { struct DateTime; }
34namespace oox::xls {
40 sal_Int32 mnCellType;
41 sal_Int32 mnXfId;
44 explicit CellModel();
51 sal_Int32 mnFormulaType;
52 sal_Int32 mnSharedId;
54 explicit CellFormulaModel();
57 bool isValidArrayRef( const ScAddress& rCellAddr );
59 bool isValidSharedRef( const ScAddress& rCellAddr );
65 OUString maRef1;
66 OUString maRef2;
67 bool mb2dTable;
72 explicit DataTableModel();
80 explicit SheetDataBuffer( const WorksheetHelper& rHelper );
83 void setBlankCell( const CellModel& rModel );
85 void setValueCell( const CellModel& rModel, double fValue );
87 void setStringCell( const CellModel& rModel, const OUString& rText );
89 void setStringCell( const CellModel& rModel, const RichStringRef& rxString );
91 void setStringCell( const CellModel& rModel, sal_Int32 nStringId );
93 void setDateTimeCell( const CellModel& rModel, const css::util::DateTime& rDateTime );
95 void setBooleanCell( const CellModel& rModel, bool bValue );
97 void setErrorCell( const CellModel& rModel, const OUString& rErrorCode );
99 void setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode );
101 void setFormulaCell( const CellModel& rModel, const ApiTokenSequence& rTokens );
103 void setDateCell( const CellModel& rModel, const OUString& rDateString );
106 const ScAddress& rRange,
107 const ApiTokenSequence& rTokens);
111 const ScRange& rRange,
112 const ApiTokenSequence& rTokens );
115 const ScRange& rRange,
116 const DataTableModel& rModel );
119 void setRowFormat( sal_Int32 nRow, sal_Int32 nXfId, bool bCustomFormat );
121 void setMergedRange( const ScRange& rRange );
124 void setCellFormat( const CellModel& rModel );
127 void finalizeImport();
130 void setCellFormula(
131 const ScAddress& rCellAddr,
132 const ApiTokenSequence& rTokens );
137 ApiTokenSequence resolveSharedFormula( const ScAddress& rMapKey ) const;
141 const ScRange& rRange,
142 const ApiTokenSequence& rTokens ) const;
145 const ScRange& rRange, const DataTableModel& rModel );
148 void applyCellMerging( const ScRange& rRange );
149 void addColXfStyles();
153 typedef std::pair< ScRange, ApiTokenSequence > ArrayFormula;
154 typedef ::std::vector< ArrayFormula > ArrayFormulaVector;
157 typedef std::pair< ScRange, DataTableModel > TableOperation;
161 {
163 sal_Int32 mnXfId;
165 explicit XfIdRowRange();
166 void set( sal_Int32 nRow, sal_Int32 nXfId );
167 bool tryExpand( sal_Int32 nRow, sal_Int32 nXfId );
168 };
170 typedef ::std::pair< sal_Int32, sal_Int32 > XfIdNumFmtKey;
173 {
174 sal_Int32 mnStartRow;
175 sal_Int32 mnEndRow;
177 };
179 {
180 bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const
181 {
182 // This end-vs-start comparison is needed by the lower_bound() use
183 // in SheetDataBuffer::addColXfStyleProcessRowRanges() that searches
184 // for partially overlapping ranges. In all other places the ranges
185 // should be non-overlapping, in which case this is the same as the "normal"
186 // comparison.
187 return lhs.mnEndRow<rhs.mnStartRow;
188 }
189 };
190 typedef ::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles;
191 typedef ::std::map< sal_Int32, RowStyles > ColStyles;
192 typedef ::std::vector< RowRangeStyle > TmpRowStyles;
193 typedef ::std::map< sal_Int32, TmpRowStyles > TmpColStyles;
196 {
198 sal_Int32 mnHorAlign;
200 explicit MergedRange( const ScRange& rRange );
201 explicit MergedRange( const ScAddress& rAddress, sal_Int32 nHorAlign );
202 bool tryExpand( const ScAddress& rAddress, sal_Int32 nHorAlign );
203 };
204 typedef ::std::vector< MergedRange > MergedRangeVector;
208 std::vector< TableOperation >
210 ::std::map< BinAddress, ApiTokenSequence >
215 std::map< XfIdNumFmtKey, ScRangeList >
220 std::map< sal_Int32, std::vector< ValueRange > > maXfIdRowRangeList;
223} // namespace oox::xls
225/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Manages the cell contents and cell formatting of a sheet.
std::pair< ScRange, ApiTokenSequence > ArrayFormula
Stores cell range address and formula token array of an array formula.
void setErrorCell(const CellModel &rModel, const OUString &rErrorCode)
Inserts an error cell from the passed error code into the sheet.
void setBlankCell(const CellModel &rModel)
Inserts a blank cell (with formatting) into the sheet.
std::map< sal_Int32, std::vector< ValueRange > > maXfIdRowRangeList
True = maSharedFmlaAddr and maSharedBaseAddr are valid.
void createTableOperation(const ScRange &rRange, const DataTableModel &rModel)
Sets a multiple table operation to the passed range.
::std::map< BinAddress, ApiTokenSequence > maSharedFormulas
All table operations in the sheet.
std::vector< TableOperation > maTableOperations
All array formulas in the sheet.
ScAddress maSharedBaseAddr
Address of a cell containing a pending shared formula.
void setRowFormat(sal_Int32 nRow, sal_Int32 nXfId, bool bCustomFormat)
Sets default cell formatting for the specified range of rows.
void setDateCell(const CellModel &rModel, const OUString &rDateString)
Inserts an ISO 8601 date cell into the sheet.
void setMergedRange(const ScRange &rRange)
Merges the cells in the passed cell range.
::std::vector< MergedRange > MergedRangeVector
::std::vector< ArrayFormula > ArrayFormulaVector
ScAddress maSharedFmlaAddr
Maps shared formula base address to defined name token index.
void finalizeArrayFormula(const ScRange &rRange, const ApiTokenSequence &rTokens) const
Inserts the passed array formula into the sheet.
SheetDataBuffer(const WorksheetHelper &rHelper)
std::pair< ScRange, DataTableModel > TableOperation
Stores cell range address and settings of a table operation.
void setCellFormat(const CellModel &rModel)
Processes the cell formatting data of the passed cell.
void finalizeTableOperation(const ScRange &rRange, const DataTableModel &rModel)
Inserts the passed table operation into the sheet.
void setValueCell(const CellModel &rModel, double fValue)
Inserts a value cell into the sheet.
void createSharedFormula(const ScAddress &rRange, const ApiTokenSequence &rTokens)
::std::pair< sal_Int32, sal_Int32 > XfIdNumFmtKey
void setCellFormula(const ScAddress &rCellAddr, const ApiTokenSequence &rTokens)
Sets the passed formula token array into a cell.
::std::map< sal_Int32, RowStyles > ColStyles
void setDateTimeCell(const CellModel &rModel, const css::util::DateTime &rDateTime)
Inserts a date/time cell into the sheet and adjusts number format.
void setFormulaCell(const CellModel &rModel, const ApiTokenSequence &rTokens)
Inserts a formula cell into the sheet.
void setBooleanCell(const CellModel &rModel, bool bValue)
Inserts a boolean cell into the sheet and adjusts number format.
void setStringCell(const CellModel &rModel, const OUString &rText)
Inserts a simple string cell into the sheet.
MergedRangeVector maCenterFillRanges
Merged cell ranges.
void applyCellMerging(const ScRange &rRange)
Writes all cell formatting attributes to the passed cell range list.
::std::vector< RowRangeStyle > TmpRowStyles
void finalizeImport()
Final processing after the sheet has been imported.
void createArrayFormula(const ScRange &rRange, const ApiTokenSequence &rTokens)
Inserts the passed token array as array formula.
bool mbPendingSharedFmla
Merged cell ranges from 'center across' or 'fill' alignment.
ArrayFormulaVector maArrayFormulas
Stores cell styles by column ( in row ranges )
XfIdRowRange maXfIdRowRange
Base address of the pending shared formula.
::std::map< sal_Int32, TmpRowStyles > TmpColStyles
MergedRangeVector maMergedRanges
Collected XF identifiers for cell rangelists.
std::map< XfIdNumFmtKey, ScRangeList > maXfIdRangeLists
Cached XF identifier for a range of rows.
ApiTokenSequence resolveSharedFormula(const ScAddress &rMapKey) const
Creates a formula token array representing the shared formula with the passed identifier.
::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles
css::uno::Sequence< ApiToken > ApiTokenSequence
std::shared_ptr< RichString > RichStringRef
Definition: richstring.hxx:263
Stores data about cell formulas.
bool isValidArrayRef(const ScAddress &rCellAddr)
Returns true, if the passed cell address is valid for an array formula.
bool isValidSharedRef(const ScAddress &rCellAddr)
Returns true, if the passed cell address is valid for a shared formula.
Identifier of a shared formula (OOXML only).
sal_Int32 mnSharedId
Type of the formula (regular, array, shared, table).
sal_Int32 mnFormulaType
Formula range for array/shared formulas and data tables.
Stores basic data about cell values and formatting.
True = show phonetic text.
bool mbShowPhonetic
XF (cell formatting) identifier.
sal_Int32 mnXfId
Data type of the cell value.
sal_Int32 mnCellType
The address of the current cell.
Stores data about table operations.
True = second reference cell deleted.
bool mbRef2Deleted
True = first reference cell deleted.
bool mb2dTable
Second reference cell for table operations.
OUString maRef2
First reference cell for table operations.
bool mbRowTable
True = 2-dimensional data table.
bool mbRef1Deleted
True = row oriented data table.
Stores information about a merged cell range.
sal_Int32 mnHorAlign
The formatted cell range.
bool tryExpand(const ScAddress &rAddress, sal_Int32 nHorAlign)
MergedRange(const ScRange &rRange)
Horizontal alignment in the range.
bool operator()(const RowRangeStyle &lhs, const RowRangeStyle &rhs) const
Stores information about a range of rows with equal cell formatting.
void set(sal_Int32 nRow, sal_Int32 nXfId)
sal_Int32 mnXfId
Indexes of first and last row.
XF identifier for the row range.
bool tryExpand(sal_Int32 nRow, sal_Int32 nXfId)
unsigned char sal_uInt8