StarCellFormula.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libstaroffice
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 /*
35 * Parser to read StarOffice formula in cells
36 *
37 */
38 #ifndef STAR_CELL_FORMULA
39 # define STAR_CELL_FORMULA
40
41 #include <vector>
42
43 #include "libstaroffice_internal.hxx"
44 #include "STOFFCell.hxx"
45
46 class StarZone;
47
48 namespace StarCellFormulaInternal
49 {
50 struct Token;
51 }
57 class StarCellFormula
58 {
59 public:
61 StarCellFormula() {}
63 ~StarCellFormula() {}
65 static bool readSCFormula(StarZone &zone, STOFFCellContent &content, int version, long lastPos);
67 static bool readSCFormula3(StarZone &zone, STOFFCellContent &content, int version, long lastPos);
69 static void updateFormula(STOFFCellContent &content, std::vector<librevenge::RVNGString> const &sheetNames, int cellSheetId);
70 protected:
71 //
72 // data
73 //
75 static bool readSCToken(StarZone &zone, StarCellFormulaInternal::Token &token, int version, long lastPos);
77 static bool readSCToken3(StarZone &zone, StarCellFormulaInternal::Token &token, bool &endData, long lastPos);
78 };
79 #endif
80 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFCellContent::m_formula
std::vector< FormulaInstruction > m_formula
the formula list of instruction
Definition: STOFFCell.hxx:324
StarCellFormulaInternal::Token::String2
@ String2
Definition: StarCellFormula.cxx:55
StarCellFormulaInternal::Token::Double
@ Double
Definition: StarCellFormula.cxx:55
STOFFCellContent
small class use to define a sheet cell content
Definition: STOFFCell.hxx:234
STOFFCellContent::FormulaInstruction::m_doubleValue
double m_doubleValue
value ( if type==F_Double )
Definition: STOFFCell.hxx:260
libstoff::getString
librevenge::RVNGString getString(std::vector< uint32_t > const &unicode)
transform a unicode string in a RNVGString
Definition: libstaroffice_internal.cxx:63
StarCellFormulaInternal::Token::m_index
int m_index
the index
Definition: StarCellFormula.cxx:149
StarCellFormula::StarCellFormula
StarCellFormula()
constructor
Definition: StarCellFormula.hxx:61
STOFFCellContent::m_contentType
Type m_contentType
the content type ( by default unknown )
Definition: STOFFCell.hxx:316
StarZone::ascii
libstoff::DebugFile & ascii()
returns the ascii file
Definition: StarZone.hxx:254
StarCellFormulaInternal::Token::CellList
@ CellList
Definition: StarCellFormula.cxx:55
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
StarCellFormula::readSCToken3
static bool readSCToken3(StarZone &zone, StarCellFormulaInternal::Token &token, bool &endData, long lastPos)
try to read a token in a formula (v3)
Definition: StarCellFormula.cxx:769
STOFFCellContent::FormulaInstruction::m_longValue
long m_longValue
value ( if type==F_Long )
Definition: STOFFCell.hxx:258
StarCellFormulaInternal::Token::m_positions
STOFFVec3i m_positions[2]
the cells positions: col, row, tab
Definition: StarCellFormula.cxx:145
StarCellFormulaInternal::Token::Missing
@ Missing
Definition: StarCellFormula.cxx:55
StarCellFormulaInternal::Token::Token
Token()
constructor
Definition: StarCellFormula.cxx:59
StarCellFormulaInternal::Token::m_relPositions
STOFFVec3b m_relPositions[2]
the cells relative positions
Definition: StarCellFormula.cxx:147
StarCellFormulaInternal::Token::External
@ External
Definition: StarCellFormula.cxx:55
StarCellFormulaInternal::Token::Type
Type
the different type
Definition: StarCellFormula.cxx:55
StarZone::readString
bool readString(std::vector< uint32_t > &string, int encoding=-1) const
try to read an unicode string
Definition: StarZone.hxx:220
StarCellFormulaInternal::Token::C_Data
@ C_Data
Definition: StarCellFormula.cxx:57
StarCellFormulaInternal::Token::m_instruction
STOFFCellContent::FormulaInstruction m_instruction
the final instruction
Definition: StarCellFormula.cxx:153
STOFFVec3i
STOFFVec3< int > STOFFVec3i
STOFFVec3 of int.
Definition: libstaroffice_internal.hxx:948
StarCellFormulaInternal
namespace used to define StarCellFormula structures
Definition: StarCellFormula.cxx:50
libstoff::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string
Definition: libstaroffice_internal.cxx:81
STOFFCellContent::FormulaInstruction::m_sheetId
int m_sheetId
the sheet id (if set)
Definition: STOFFCell.hxx:268
StarCellFormula::~StarCellFormula
~StarCellFormula()
destructor
Definition: StarCellFormula.hxx:63
STOFFOLEParser.hxx
StarCellFormula
the main class to read a cell formula
Definition: StarCellFormula.hxx:57
libstaroffice_internal.hxx
StarCellFormulaInternal::Token::m_content
Content m_content
the content type
Definition: StarCellFormula.cxx:135
libstoff::DebugStream::str
static std::string str()
Definition: STOFFDebug.hxx:203
STOFFCellContent::FormulaInstruction::F_Text
@ F_Text
Definition: STOFFCell.hxx:239
StarCellFormula::readSCToken
static bool readSCToken(StarZone &zone, StarCellFormulaInternal::Token &token, int version, long lastPos)
try to read a token in a formula
Definition: StarCellFormula.cxx:570
StarCellFormulaInternal::Token::m_type
Type m_type
the type
Definition: StarCellFormula.cxx:133
StarCellFormulaInternal::Token::m_doubleValue
double m_doubleValue
the double value
Definition: StarCellFormula.cxx:141
StarEncoding::convert
static bool convert(std::vector< uint8_t > const &src, Encoding encoding, std::vector< uint32_t > &dest, std::vector< size_t > &srcPositions)
try to convert a list of character and transforms it a unicode's list
Definition: StarEncoding.cxx:61
STOFFCellContent::FormulaInstruction::m_positionRelative
STOFFVec2b m_positionRelative[2]
relative cell position ( if type==F_Cell or F_CellList )
Definition: STOFFCell.hxx:264
STOFFVec3< int >
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:489
StarZone
a zone in a StarOffice file
Definition: StarZone.hxx:56
StarZone::getRecordLevel
int getRecordLevel() const
returns the record level
Definition: StarZone.hxx:195
StarCellFormula::readSCFormula3
static bool readSCFormula3(StarZone &zone, STOFFCellContent &content, int version, long lastPos)
try to read a formula(v3)
Definition: StarCellFormula.cxx:531
STOFFVec3b
STOFFVec3< bool > STOFFVec3b
STOFFVec3 of bool.
Definition: libstaroffice_internal.hxx:944
StarZone::getEncoding
StarEncoding::Encoding getEncoding() const
returns the zone encoding
Definition: StarZone.hxx:121
StarCellFormulaInternal::Token::Content
Content
the content type
Definition: StarCellFormula.cxx:57
StarCellFormula.hxx
StarEncoding.hxx
StarCellFormulaInternal::Token::m_operation
unsigned m_operation
the operation
Definition: StarCellFormula.cxx:137
StarCellFormulaInternal::Token::Jump
@ Jump
Definition: StarCellFormula.cxx:55
libstoff::DebugStream
Definition: STOFFDebug.hxx:194
STOFFCellContent::FormulaInstruction::m_type
Type m_type
the type
Definition: STOFFCell.hxx:254
STOFFCellContent::FormulaInstruction::m_position
STOFFVec2i m_position[2]
cell position ( if type==F_Cell or F_CellList )
Definition: STOFFCell.hxx:262
StarCellFormulaInternal::Token::updateFunction
bool updateFunction()
try to update the function/operator
Definition: StarCellFormula.cxx:206
StarCellFormulaInternal::Token::addToken
static bool addToken(std::vector< std::vector< Token > > &stack, Token const &token)
a static function to recompile a formula from Polish notation
Definition: StarCellFormula.cxx:305
StarCellFormula::readSCFormula
static bool readSCFormula(StarZone &zone, STOFFCellContent &content, int version, long lastPos)
try to read a formula
Definition: StarCellFormula.cxx:385
StarCellFormulaInternal::Token::Long
@ Long
Definition: StarCellFormula.cxx:55
StarCellFormulaInternal::Token::get
bool get(STOFFCellContent::FormulaInstruction &instr, bool &ignore)
return a instruction corresponding to a token
Definition: StarCellFormula.cxx:158
STOFFCellContent::FormulaInstruction::m_content
librevenge::RVNGString m_content
the content ( if type == F_Operator or type = F_Function or type==F_Text)
Definition: STOFFCell.hxx:256
StarCellFormulaInternal::Token::Empty
@ Empty
Definition: StarCellFormula.cxx:55
libstoff::DebugFile::addPos
static void addPos(long)
Definition: STOFFDebug.hxx:223
StarCellFormulaInternal::Token::Index
@ Index
Definition: StarCellFormula.cxx:55
StarZone.hxx
StarCellFormulaInternal::Token::String
@ String
Definition: StarCellFormula.cxx:55
StarCellFormulaInternal::Token
a structure used to store a token
Definition: StarCellFormula.cxx:53
StarCellFormulaInternal::Token::operator<<
friend std::ostream & operator<<(std::ostream &o, Token const &tok)
operator<<
Definition: StarCellFormula.cxx:73
StarCellFormulaInternal::Token::m_textValue
librevenge::RVNGString m_textValue
the string value
Definition: StarCellFormula.cxx:143
STOFFCellContent::FormulaInstruction::F_Double
@ F_Double
Definition: STOFFCell.hxx:239
libstoff::DebugFile
Definition: STOFFDebug.hxx:210
StarCellFormulaInternal::Token::Unknown
@ Unknown
Definition: StarCellFormula.cxx:55
StarCellFormulaInternal::Token::m_jumpPositions
std::vector< int > m_jumpPositions
the jump position(for if, choose, ...)
Definition: StarCellFormula.cxx:151
STOFFVec2b
STOFFVec2< bool > STOFFVec2b
STOFFVec2 of bool.
Definition: libstaroffice_internal.hxx:765
STOFFCellContent::FormulaInstruction::F_Operator
@ F_Operator
Definition: STOFFCell.hxx:239
StarCellFormulaInternal::Token::m_extra
std::string m_extra
extra data
Definition: StarCellFormula.cxx:155
StarCellFormulaInternal::Token::m_longValue
long m_longValue
the long value
Definition: StarCellFormula.cxx:139
libstoff::DebugFile::addNote
static void addNote(char const *)
Definition: STOFFDebug.hxx:224
StarZone::input
STOFFInputStreamPtr input()
return the zone input
Definition: StarZone.hxx:247
StarCellFormulaInternal::Token::Error
@ Error
Definition: StarCellFormula.cxx:55
STOFFCellContent::C_FORMULA
@ C_FORMULA
Definition: STOFFCell.hxx:276
StarCellFormulaInternal::Token::C_FunctionOperator
@ C_FunctionOperator
Definition: StarCellFormula.cxx:57
STOFFCellContent::FormulaInstruction::F_Function
@ F_Function
Definition: STOFFCell.hxx:239
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:767
STOFFCellContent::FormulaInstruction::F_CellList
@ F_CellList
Definition: STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction::F_Cell
@ F_Cell
Definition: STOFFCell.hxx:239
StarCellFormulaInternal::Token::Function
@ Function
Definition: StarCellFormula.cxx:55
STOFFCellContent::FormulaInstruction::F_Long
@ F_Long
Definition: STOFFCell.hxx:239
STOFFCellContent::FormulaInstruction
small class use to define a formula instruction
Definition: STOFFCell.hxx:238
StarCellFormula::updateFormula
static void updateFormula(STOFFCellContent &content, std::vector< librevenge::RVNGString > const &sheetNames, int cellSheetId)
update the different formula(knowing the list of sheet names and the cell's sheetId)
Definition: StarCellFormula.cxx:365
STOFFCell.hxx
StarCellFormulaInternal::Token::Cell
@ Cell
Definition: StarCellFormula.cxx:55