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 <vector>
15 
16 namespace oox::xls {
17 
19 {
20 public:
25  {
27  OUString maTokenStr;
28  sal_Int32 mnSharedId;
29 
31  const ScAddress& rAddress,
32  const OUString& rTokenStr, sal_Int32 nSharedId );
33  };
34 
39  {
41  OUString maCellValue;
42  sal_Int32 mnSharedId;
43  sal_Int32 mnValueType;
44 
46  const ScAddress& rAddr, sal_Int32 nSharedId,
47  const OUString& rCellValue, sal_Int32 nValueType );
48  };
49 
51  {
52  OUString maTokenStr;
54  TokenAddressItem( const OUString& rTokenStr, const ScAddress& rAddress ) : maTokenStr( rTokenStr ), maAddress( rAddress ) {}
55  };
56 
58  {
61  TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ScRange& rRange ) : maTokenAndAddress( rTokenAndAddress ), maRange( rRange ) {}
62  };
63 
64  struct FormulaValue
65  {
67  OUString maValueStr;
68  sal_Int32 mnCellType;
69  };
70 
71  struct SheetItem
72  {
73  std::vector<TokenAddressItem>* mpCellFormulas;
74  std::vector<TokenRangeAddressItem>* mpArrayFormulas;
75  std::vector<FormulaValue>* mpCellFormulaValues;
76  std::vector<SharedFormulaEntry>* mpSharedFormulaEntries;
77  std::vector<SharedFormulaDesc>* mpSharedFormulaIDs;
78 
79  SheetItem();
80  };
81 
82 private:
83 
84  std::mutex maMtxData;
85  // Vectors indexed by SCTAB - cf. SetSheetCount
86  std::vector< std::vector<TokenAddressItem> > maCellFormulas;
87  std::vector< std::vector<TokenRangeAddressItem> > maCellArrayFormulas;
88  std::vector< std::vector<SharedFormulaEntry> > maSharedFormulas; // sheet -> stuff needed to create shared formulae
89  std::vector< std::vector<SharedFormulaDesc> > maSharedFormulaIds; // sheet -> list of shared formula descriptions
90  std::vector< std::vector<FormulaValue> > maCellFormulaValues; // sheet -> stuff needed to create shared formulae
91 
93 
94 public:
95  explicit FormulaBuffer( const WorkbookHelper& rHelper );
96  void finalizeImport();
97  void setCellFormula( const ScAddress& rAddress, const OUString& );
98 
99  void setCellFormula(
100  const ScAddress& rAddress, sal_Int32 nSharedId,
101  const OUString& rCellValue, sal_Int32 nValueType );
102 
103  void setCellFormulaValue(
104  const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
105 
106  void setCellArrayFormula( const ScRange& rRangeAddress,
107  const ScAddress& rTokenAddress,
108  const OUString& );
109 
110  void createSharedFormulaMapEntry( const ScAddress& rAddress,
111  sal_Int32 nSharedId, const OUString& rTokens );
112 
114  void SetSheetCount( SCTAB nSheets );
115 };
116 
117 }
118 
119 /* 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:22