1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SC_SOURCE_FILTER_INC_FORMULABUFFER_HXX
#define INCLUDED_SC_SOURCE_FILTER_INC_FORMULABUFFER_HXX
#include <osl/mutex.hxx>
#include "workbookhelper.hxx"
#include <vector>
namespace oox { namespace xls {
class FormulaBuffer : public WorkbookHelper
{
public:
/**
* Represents a shared formula definition.
*/
struct SharedFormulaEntry
{
ScAddress maAddress;
OUString maTokenStr;
sal_Int32 mnSharedId;
SharedFormulaEntry(
const ScAddress& rAddress,
const OUString& rTokenStr, sal_Int32 nSharedId );
};
/**
* Represents a formula cell that uses shared formula.
*/
struct SharedFormulaDesc
{
ScAddress maAddress;
sal_Int32 mnSharedId;
OUString maCellValue;
sal_Int32 mnValueType;
SharedFormulaDesc(
const ScAddress& rAddr, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType );
};
struct TokenAddressItem
{
OUString maTokenStr;
ScAddress maAddress;
TokenAddressItem( const OUString& rTokenStr, const ScAddress& rAddress ) : maTokenStr( rTokenStr ), maAddress( rAddress ) {}
};
struct TokenRangeAddressItem
{
TokenAddressItem maTokenAndAddress;
ScRange maRange;
TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ScRange& rRange ) : maTokenAndAddress( rTokenAndAddress ), maRange( rRange ) {}
};
struct FormulaValue
{
ScAddress maAddress;
OUString maValueStr;
sal_Int32 mnCellType;
};
struct SheetItem
{
std::vector<TokenAddressItem>* mpCellFormulas;
std::vector<TokenRangeAddressItem>* mpArrayFormulas;
std::vector<FormulaValue>* mpCellFormulaValues;
std::vector<SharedFormulaEntry>* mpSharedFormulaEntries;
std::vector<SharedFormulaDesc>* mpSharedFormulaIDs;
SheetItem();
};
private:
// Vectors indexed by SCTAB - cf. SetSheetCount
typedef ::std::vector< std::vector<TokenAddressItem> > FormulaDataArray;
typedef ::std::vector< std::vector<TokenRangeAddressItem> > ArrayFormulaDataArray;
// sheet -> list of shared formula descriptions
typedef ::std::vector< std::vector<SharedFormulaDesc> > SheetToSharedFormulaid;
// sheet -> stuff needed to create shared formulae
typedef ::std::vector< std::vector<SharedFormulaEntry> > SheetToFormulaEntryArray;
typedef ::std::vector< std::vector<FormulaValue> > FormulaValueArray;
osl::Mutex maMtxData;
FormulaDataArray maCellFormulas;
ArrayFormulaDataArray maCellArrayFormulas;
SheetToFormulaEntryArray maSharedFormulas;
SheetToSharedFormulaid maSharedFormulaIds;
FormulaValueArray maCellFormulaValues;
SheetItem getSheetItem( SCTAB nTab );
public:
explicit FormulaBuffer( const WorkbookHelper& rHelper );
void finalizeImport();
void setCellFormula( const ScAddress& rAddress, const OUString& );
void setCellFormula(
const ScAddress& rAddress, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType );
void setCellFormulaValue(
const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
void setCellArrayFormula( const ScRange& rRangeAddress,
const ScAddress& rTokenAddress,
const OUString& );
void createSharedFormulaMapEntry( const ScAddress& rAddress,
sal_Int32 nSharedId, const OUString& rTokens );
/// ensure sizes of vectors matches the number of sheets
void SetSheetCount( SCTAB nSheets );
};
}}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|