| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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 |
|
| 41 |
|
| 42 |
class CellReference |
| 43 |
{ |
| 44 |
public: |
| 45 |
|
| 46 |
CellReference() |
| 47 |
: m_cells() |
| 48 |
{ |
| 49 |
} |
| 50 |
|
| 51 |
void addInstruction(WKSContentListener::FormulaInstruction const &instr) |
| 52 |
{ |
| 53 |
if (!m_cells.empty() && instr.m_type!=instr.F_Operator && m_cells.back().m_type!=instr.F_Operator) |
| 54 |
{ |
| 55 |
WKSContentListener::FormulaInstruction sep; |
| 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 |
} |
| 62 |
|
| 63 |
bool empty() const |
| 64 |
{ |
| 65 |
return m_cells.empty(); |
| 66 |
} |
| 67 |
|
| 68 |
friend std::ostream &operator<<(std::ostream &o, CellReference const &ref); |
| 69 |
|
| 70 |
std::vector<WKSContentListener::FormulaInstruction> m_cells; |
| 71 |
}; |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
class QuattroFormulaManager |
| 77 |
{ |
| 78 |
public: |
| 79 |
typedef std::function<bool(std::shared_ptr<WPSStream> const &stream, long endPos, |
| 80 |
QuattroFormulaInternal::CellReference &ref, |
| 81 |
Vec2i const &cPos, int cSheet)> CellReferenceFunction; |
| 82 |
|
| 83 |
|
| 84 |
QuattroFormulaManager(QuattroFormulaManager::CellReferenceFunction const &readCellReference, |
| 85 |
int version); |
| 86 |
|
| 87 |
|
| 88 |
void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1); |
| 89 |
|
| 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: |
| 93 |
|
| 94 |
std::shared_ptr<QuattroFormulaInternal::State> m_state; |
| 95 |
}; |
| 96 |
#endif |
| 97 |
|