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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_FORMULABUFFER_HXX
11 #define INCLUDED_SC_SOURCE_FILTER_INC_FORMULABUFFER_HXX
12 
13 #include <osl/mutex.hxx>
14 #include "workbookhelper.hxx"
15 #include <vector>
16 
17 namespace oox::xls {
18 
20 {
21 public:
26  {
28  OUString maTokenStr;
29  sal_Int32 mnSharedId;
30 
32  const ScAddress& rAddress,
33  const OUString& rTokenStr, sal_Int32 nSharedId );
34  };
35 
40  {
42  sal_Int32 mnSharedId;
43  OUString maCellValue;
44  sal_Int32 mnValueType;
45 
47  const ScAddress& rAddr, sal_Int32 nSharedId,
48  const OUString& rCellValue, sal_Int32 nValueType );
49  };
50 
52  {
53  OUString maTokenStr;
55  TokenAddressItem( const OUString& rTokenStr, const ScAddress& rAddress ) : maTokenStr( rTokenStr ), maAddress( rAddress ) {}
56  };
57 
59  {
62  TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ScRange& rRange ) : maTokenAndAddress( rTokenAndAddress ), maRange( rRange ) {}
63  };
64 
65  struct FormulaValue
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 
83 private:
84 
85  osl::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 
95 public:
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 
104  void setCellFormulaValue(
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 #endif
121 
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
SharedFormulaDesc(const ScAddress &rAddr, sal_Int32 nSharedId, const OUString &rCellValue, sal_Int32 nValueType)
TokenRangeAddressItem(const TokenAddressItem &rTokenAndAddress, const ScRange &rRange)
std::vector< TokenAddressItem > * mpCellFormulas
std::vector< FormulaValue > * mpCellFormulaValues
std::vector< std::vector< TokenRangeAddressItem > > maCellArrayFormulas
FormulaBuffer(const WorkbookHelper &rHelper)
std::vector< std::vector< TokenAddressItem > > maCellFormulas
std::vector< SharedFormulaDesc > * mpSharedFormulaIDs
std::vector< SharedFormulaEntry > * mpSharedFormulaEntries
void createSharedFormulaMapEntry(const ScAddress &rAddress, sal_Int32 nSharedId, const OUString &rTokens)
std::vector< std::vector< SharedFormulaDesc > > maSharedFormulaIds
std::vector< std::vector< SharedFormulaEntry > > maSharedFormulas
void setCellFormula(const ScAddress &rAddress, const OUString &)
Represents a formula cell that uses shared formula.
SharedFormulaEntry(const ScAddress &rAddress, const OUString &rTokenStr, sal_Int32 nSharedId)
void SetSheetCount(SCTAB nSheets)
ensure sizes of vectors matches the number of sheets
void setCellArrayFormula(const ScRange &rRangeAddress, const ScAddress &rTokenAddress, const OUString &)
std::vector< std::vector< FormulaValue > > maCellFormulaValues
Represents a shared formula definition.
void setCellFormulaValue(const ScAddress &rAddress, const OUString &rValueStr, sal_Int32 nCellType)
std::vector< TokenRangeAddressItem > * mpArrayFormulas
TokenAddressItem(const OUString &rTokenStr, const ScAddress &rAddress)
SheetItem getSheetItem(SCTAB nTab)
sal_Int16 SCTAB
Definition: types.hxx:23