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();
79 explicit CellBlockBuffer( const WorksheetHelper& rHelper );
82 void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans );
85 typedef ::std::map< sal_Int32, ValueRangeVector > ColSpanVectorMap;
88 sal_Int32 mnCurrRow;
96 explicit SheetDataBuffer( const WorksheetHelper& rHelper );
99 void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans );
102 void setBlankCell( const CellModel& rModel );
104 void setValueCell( const CellModel& rModel, double fValue );
106 void setStringCell( const CellModel& rModel, const OUString& rText );
108 void setStringCell( const CellModel& rModel, const RichStringRef& rxString );
110 void setStringCell( const CellModel& rModel, sal_Int32 nStringId );
112 void setDateTimeCell( const CellModel& rModel, const css::util::DateTime& rDateTime );
114 void setBooleanCell( const CellModel& rModel, bool bValue );
116 void setErrorCell( const CellModel& rModel, const OUString& rErrorCode );
118 void setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode );
120 void setFormulaCell( const CellModel& rModel, const ApiTokenSequence& rTokens );
122 void setDateCell( const CellModel& rModel, const OUString& rDateString );
125 const ScAddress& rRange,
126 const ApiTokenSequence& rTokens);
130 const ScRange& rRange,
131 const ApiTokenSequence& rTokens );
134 const ScRange& rRange,
135 const DataTableModel& rModel );
138 void setRowFormat( sal_Int32 nRow, sal_Int32 nXfId, bool bCustomFormat );
140 void setMergedRange( const ScRange& rRange );
143 void setCellFormat( const CellModel& rModel );
146 void finalizeImport();
149 void setCellFormula(
150 const ScAddress& rCellAddr,
151 const ApiTokenSequence& rTokens );
156 ApiTokenSequence resolveSharedFormula( const ScAddress& rMapKey ) const;
160 const ScRange& rRange,
161 const ApiTokenSequence& rTokens ) const;
164 const ScRange& rRange, const DataTableModel& rModel );
167 void applyCellMerging( const ScRange& rRange );
168 void addColXfStyles();
172 typedef std::pair< ScRange, ApiTokenSequence > ArrayFormula;
173 typedef ::std::vector< ArrayFormula > ArrayFormulaVector;
176 typedef std::pair< ScRange, DataTableModel > TableOperation;
180 {
182 sal_Int32 mnXfId;
184 explicit XfIdRowRange();
185 void set( sal_Int32 nRow, sal_Int32 nXfId );
186 bool tryExpand( sal_Int32 nRow, sal_Int32 nXfId );
187 };
189 typedef ::std::pair< sal_Int32, sal_Int32 > XfIdNumFmtKey;
192 {
193 sal_Int32 mnStartRow;
194 sal_Int32 mnEndRow;
196 };
198 {
199 bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const
200 {
201 // This end-vs-start comparison is needed by the lower_bound() use
202 // in SheetDataBuffer::addColXfStyleProcessRowRanges() that searches
203 // for partially overlapping ranges. In all other places the ranges
204 // should be non-overlapping, in which case this is the same as the "normal"
205 // comparison.
206 return lhs.mnEndRow<rhs.mnStartRow;
207 }
208 };
209 typedef ::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles;
210 typedef ::std::map< sal_Int32, RowStyles > ColStyles;
211 typedef ::std::vector< RowRangeStyle > TmpRowStyles;
212 typedef ::std::map< sal_Int32, TmpRowStyles > TmpColStyles;
215 {
217 sal_Int32 mnHorAlign;
219 explicit MergedRange( const ScRange& rRange );
220 explicit MergedRange( const ScAddress& rAddress, sal_Int32 nHorAlign );
221 bool tryExpand( const ScAddress& rAddress, sal_Int32 nHorAlign );
222 };
223 typedef ::std::vector< MergedRange > MergedRangeVector;
228 std::vector< TableOperation >
230 ::std::map< BinAddress, ApiTokenSequence >
235 std::map< XfIdNumFmtKey, ScRangeList >
240 std::map< sal_Int32, std::vector< ValueRange > > maXfIdRowRangeList;
243} // namespace oox::xls
245/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Manages all cell blocks currently in use.
CellBlockBuffer(const WorksheetHelper &rHelper)
void setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
::std::map< sal_Int32, ValueRangeVector > ColSpanVectorMap
sal_Int32 mnCurrRow
Buffered column spans, mapped by row index.
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.
CellBlockBuffer maCellBlocks
Stores cell styles by column ( in row ranges )
::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 setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
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
Manages all open cell blocks.
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:260
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