LibreOffice Module sc (master) 1
formulabuffer.hxx
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 http://mozilla.org/MPL/2.0/.
8 */
9
10#pragma once
11
12#include "workbookhelper.hxx"
13#include <mutex>
14#include <utility>
15#include <vector>
16
17namespace oox::xls {
18
19class FormulaBuffer final : public WorkbookHelper
20{
21public:
26 {
28 OUString maTokenStr;
29 sal_Int32 mnSharedId;
30
32 const ScAddress& rAddress,
33 OUString aTokenStr, sal_Int32 nSharedId );
34 };
35
40 {
42 OUString maCellValue;
43 sal_Int32 mnSharedId;
44 sal_Int32 mnValueType;
45
47 const ScAddress& rAddr, sal_Int32 nSharedId,
48 OUString aCellValue, sal_Int32 nValueType );
49 };
50
52 {
53 OUString maTokenStr;
55 TokenAddressItem( OUString aTokenStr, const ScAddress& rAddress ) : maTokenStr(std::move( aTokenStr )), maAddress( rAddress ) {}
56 };
57
59 {
62 TokenRangeAddressItem( TokenAddressItem aTokenAndAddress, const ScRange& rRange ) : maTokenAndAddress(std::move( aTokenAndAddress )), maRange( rRange ) {}
63 };
64
66 {
68 OUString maValueStr;
69 sal_Int32 mnCellType;
70 };
71
72 struct SheetItem
73 {
74 std::vector<TokenAddressItem>* mpCellFormulas;
75 std::vector<TokenRangeAddressItem>* mpArrayFormulas;
76 std::vector<FormulaValue>* mpCellFormulaValues;
77 std::vector<SharedFormulaEntry>* mpSharedFormulaEntries;
78 std::vector<SharedFormulaDesc>* mpSharedFormulaIDs;
79
80 SheetItem();
81 };
82
83private:
84
85 std::mutex maMtxData;
86 // Vectors indexed by SCTAB - cf. SetSheetCount
87 std::vector< std::vector<TokenAddressItem> > maCellFormulas;
88 std::vector< std::vector<TokenRangeAddressItem> > maCellArrayFormulas;
89 std::vector< std::vector<SharedFormulaEntry> > maSharedFormulas; // sheet -> stuff needed to create shared formulae
90 std::vector< std::vector<SharedFormulaDesc> > maSharedFormulaIds; // sheet -> list of shared formula descriptions
91 std::vector< std::vector<FormulaValue> > maCellFormulaValues; // sheet -> stuff needed to create shared formulae
92
94
95public:
96 explicit FormulaBuffer( const WorkbookHelper& rHelper );
97 void finalizeImport();
98 void setCellFormula( const ScAddress& rAddress, const OUString& );
99
100 void setCellFormula(
101 const ScAddress& rAddress, sal_Int32 nSharedId,
102 const OUString& rCellValue, sal_Int32 nValueType );
103
105 const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
106
107 void setCellArrayFormula( const ScRange& rRangeAddress,
108 const ScAddress& rTokenAddress,
109 const OUString& );
110
111 void createSharedFormulaMapEntry( const ScAddress& rAddress,
112 sal_Int32 nSharedId, const OUString& rTokens );
113
115 void SetSheetCount( SCTAB nSheets );
116};
117
118}
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< std::vector< TokenRangeAddressItem > > maCellArrayFormulas
std::vector< std::vector< SharedFormulaDesc > > maSharedFormulaIds
SheetItem getSheetItem(SCTAB nTab)
std::vector< std::vector< TokenAddressItem > > maCellFormulas
void createSharedFormulaMapEntry(const ScAddress &rAddress, sal_Int32 nSharedId, const OUString &rTokens)
void SetSheetCount(SCTAB nSheets)
ensure sizes of vectors matches the number of sheets
void setCellFormulaValue(const ScAddress &rAddress, const OUString &rValueStr, sal_Int32 nCellType)
std::vector< std::vector< FormulaValue > > maCellFormulaValues
void setCellArrayFormula(const ScRange &rRangeAddress, const ScAddress &rTokenAddress, const OUString &)
void setCellFormula(const ScAddress &rAddress, const OUString &)
FormulaBuffer(const WorkbookHelper &rHelper)
std::vector< std::vector< SharedFormulaEntry > > maSharedFormulas
Helper class to provide access to global workbook data.
Represents a formula cell that uses shared formula.
SharedFormulaDesc(const ScAddress &rAddr, sal_Int32 nSharedId, OUString aCellValue, sal_Int32 nValueType)
Represents a shared formula definition.
SharedFormulaEntry(const ScAddress &rAddress, OUString aTokenStr, sal_Int32 nSharedId)
std::vector< FormulaValue > * mpCellFormulaValues
std::vector< TokenRangeAddressItem > * mpArrayFormulas
std::vector< SharedFormulaDesc > * mpSharedFormulaIDs
std::vector< SharedFormulaEntry > * mpSharedFormulaEntries
std::vector< TokenAddressItem > * mpCellFormulas
TokenAddressItem(OUString aTokenStr, const ScAddress &rAddress)
TokenRangeAddressItem(TokenAddressItem aTokenAndAddress, const ScRange &rRange)
sal_Int16 SCTAB
Definition: types.hxx:22