QuattroFormula.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3  * Version: MPL 2.0 / LGPLv2.1+
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  * Major Contributor(s):
10  * Copyright (C) 2006, 2007 Andrew Ziem
11  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
12  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
13  *
14  * For minor contributions see the git repository.
15  *
16  * Alternatively, the contents of this file may be used under the terms
17  * of the GNU Lesser General Public License Version 2.1 or later
18  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19  * applicable instead of those above.
20  */
21 
22 #ifndef QUATTRO_FORMULA_H
23 #define QUATTRO_FORMULA_H
24 
25 #include <functional>
26 #include <ostream>
27 #include <string>
28 #include <vector>
29 
30 #include <librevenge-stream/librevenge-stream.h>
31 
32 #include "libwps_internal.h"
33 
34 #include "WPSDebug.h"
35 #include "WKSContentListener.h"
36 
37 namespace QuattroFormulaInternal
38 {
39 struct State;
40 
43 {
44 public:
47  : m_cells()
48  {
49  }
52  {
53  if (!m_cells.empty() && instr.m_type!=instr.F_Operator && m_cells.back().m_type!=instr.F_Operator)
54  {
56  sep.m_type=sep.F_Operator;
57  sep.m_content=";";
58  m_cells.push_back(sep);
59  }
60  m_cells.push_back(instr);
61  }
63  bool empty() const
64  {
65  return m_cells.empty();
66  }
68  friend std::ostream &operator<<(std::ostream &o, CellReference const &ref);
70  std::vector<WKSContentListener::FormulaInstruction> m_cells;
71 };
72 
73 }
74 
77 {
78 public:
79  typedef std::function<bool(std::shared_ptr<WPSStream> const &stream, long endPos,
81  Vec2i const &cPos, int cSheet)> CellReferenceFunction;
82 
85  int version);
86 
88  void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1);
90  bool readFormula(std::shared_ptr<WPSStream> const &stream, long endPos, Vec2i const &pos, int sheetId,
91  std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error) const;
92 private:
94  std::shared_ptr<QuattroFormulaInternal::State> m_state;
95 };
96 #endif /* QUATTRO_FORMULA_H */
97 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WKSContentListener::FormulaInstruction::F_Text
@ F_Text
Definition: WKSContentListener.h:59
WPS_N_ELEMENTS
#define WPS_N_ELEMENTS(m)
Definition: libwps_internal.h:124
QuattroFormulaManager::readFormula
bool readFormula(std::shared_ptr< WPSStream > const &stream, long endPos, Vec2i const &pos, int sheetId, std::vector< WKSContentListener::FormulaInstruction > &formula, std::string &error) const
reads a formula
Definition: QuattroFormula.cpp:189
QuattroFormula.h
QuattroFormulaInternal::CellReference
small class use to store Quattro Pro cell reference (.wb1-3 and qpw)
Definition: QuattroFormula.h:43
WKSContentListener::FormulaInstruction::F_Long
@ F_Long
Definition: WKSContentListener.h:59
QuattroFormulaInternal::Functions
Definition: QuattroFormula.cpp:33
QuattroFormulaManager::CellReferenceFunction
std::function< bool(std::shared_ptr< WPSStream > const &stream, long endPos, QuattroFormulaInternal::CellReference &ref, Vec2i const &cPos, int cSheet)> CellReferenceFunction
Definition: QuattroFormula.h:81
QuattroFormulaInternal::State::m_version
int m_version
the file version: 1: .wb1-3, 2: .qpw
Definition: QuattroFormula.cpp:63
WKSContentListener::FormulaInstruction::F_Operator
@ F_Operator
Definition: WKSContentListener.h:59
QuattroFormulaInternal::State::m_actDLLName1Id
int m_actDLLName1Id
the current id DLL name 1
Definition: QuattroFormula.cpp:69
WKSContentListener::FormulaInstruction::F_Double
@ F_Double
Definition: WKSContentListener.h:59
WKSContentListener::FormulaInstruction::m_longValue
double m_longValue
value ( if type==F_Long )
Definition: WKSContentListener.h:81
WKSContentListener::FormulaInstruction::F_Function
@ F_Function
Definition: WKSContentListener.h:59
QuattroFormulaInternal::State
Definition: QuattroFormula.cpp:39
WKSContentListener::FormulaInstruction::m_doubleValue
double m_doubleValue
value ( if type==F_Double )
Definition: WKSContentListener.h:83
QuattroFormulaInternal::CellReference::addInstruction
void addInstruction(WKSContentListener::FormulaInstruction const &instr)
add an instruction
Definition: QuattroFormula.h:51
QuattroFormulaInternal::CellReference::CellReference
CellReference()
constructor
Definition: QuattroFormula.h:46
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libwps_internal.h:702
WKSContentListener::FormulaInstruction::m_type
What m_type
the type
Definition: WKSContentListener.h:77
QuattroFormulaManager::QuattroFormulaManager
QuattroFormulaManager(QuattroFormulaManager::CellReferenceFunction const &readCellReference, int version)
constructor, version=1: means .wb1-3, version=2 means .qpw
Definition: QuattroFormula.cpp:76
QuattroFormulaInternal::CellReference::m_cells
std::vector< WKSContentListener::FormulaInstruction > m_cells
the list of instruction coding each cell's block
Definition: QuattroFormula.h:70
Vec2< int >
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
QuattroFormulaInternal
namespace to regroup data used to read QuattroPro .wb1-3, .qpw formula
Definition: Quattro.h:46
WKSContentListener::FormulaInstruction
small class use to define a formula instruction
Definition: WKSContentListener.h:58
QuattroFormulaManager::addDLLIdName
void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1)
add a dll's correspondance between an id and a name
Definition: QuattroFormula.cpp:81
QuattroFormulaInternal::State::m_idFunctionsMap
std::map< int, Functions > m_idFunctionsMap
the function which differs from default
Definition: QuattroFormula.cpp:65
libwps::read8
int8_t read8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:59
QuattroFormulaManager::m_state
std::shared_ptr< QuattroFormulaInternal::State > m_state
the formula state
Definition: QuattroFormula.h:94
libwps::readDouble8
bool readDouble8(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 8 bytes: mantisse 6.5 bytes, exponent 1.5 bytes
Definition: libwps_internal.cpp:173
QuattroFormulaInternal::s_listFunctions
static Functions const s_listFunctions[]
Definition: QuattroFormula.cpp:121
libwps::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:40
QuattroFormulaInternal::State::m_readCellReferenceFunction
QuattroFormulaManager::CellReferenceFunction m_readCellReferenceFunction
function to call to read a cell reference
Definition: QuattroFormula.cpp:61
QuattroFormulaInternal::State::m_idToDLLName2Map
std::map< Vec2i, librevenge::RVNGString > m_idToDLLName2Map
map id to DLL name2
Definition: QuattroFormula.cpp:71
QuattroFormulaInternal::Functions::m_name
char const * m_name
Definition: QuattroFormula.cpp:34
QuattroFormulaInternal::CellReference::operator<<
friend std::ostream & operator<<(std::ostream &o, CellReference const &ref)
friend operator<<
Definition: QuattroFormula.cpp:570
WKSContentListener::FormulaInstruction::m_content
std::string m_content
the content ( if type == F_Operator or type = F_Function or type==F_Text)
Definition: WKSContentListener.h:79
QuattroFormulaInternal::CellReference::empty
bool empty() const
return true if we have not read any reference
Definition: QuattroFormula.h:63
libwps::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:64
libwps_tools_win::Language::name
std::string name(long id)
returns the name given Windows© id
Definition: libwps_tools_win.cpp:7332
QuattroFormulaManager
a class to read formula in a wb1-wb3, qpw file
Definition: QuattroFormula.h:77
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WPSDebug.h
libwps::DebugFile::addDelimiter
static void addDelimiter(long, char)
Definition: WPSDebug.h:222
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:71
QuattroFormulaInternal::Functions::m_arity
int m_arity
Definition: QuattroFormula.cpp:35
libwps_internal.h
QuattroFormulaInternal::State::State
State(QuattroFormulaManager::CellReferenceFunction const &readCellReference, int version)
constructor
Definition: QuattroFormula.cpp:41
QuattroFormulaInternal::State::m_idToDLLName1Map
std::map< int, librevenge::RVNGString > m_idToDLLName1Map
map id to DLL name 1
Definition: QuattroFormula.cpp:67
WKSContentListener.h
WPSStream.h
libwps::DebugFile
Definition: WPSDebug.h:208
QuattroFormulaInternal::operator<<
std::ostream & operator<<(std::ostream &o, CellReference const &ref)
Definition: QuattroFormula.cpp:570

Generated on Tue Dec 10 2024 02:10:18 for libwps by doxygen 1.8.20