LotusSpreadsheet.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 LOTUS_SPREADSHEET_H
23 #define LOTUS_SPREADSHEET_H
24 
25 #include <ostream>
26 #include <vector>
27 
28 #include <librevenge-stream/librevenge-stream.h>
29 
30 #include "libwps_internal.h"
31 
32 #include "WPSDebug.h"
33 #include "WKSContentListener.h"
34 
36 {
37 class Cell;
38 class Spreadsheet;
39 struct Style;
40 struct State;
41 struct Table123Styles;
42 class SubDocument;
43 }
44 
45 class LotusParser;
46 class LotusStyleManager;
47 
53 {
54 public:
55  friend class LotusParser;
57 
63  void cleanState();
65  void updateState();
68  {
69  m_listener = listen;
70  }
72  void setLastSpreadsheetId(int id);
73 
74  // interface which LotusParser
75 
77  bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos);
78 protected:
80  int version() const;
82  bool hasSomeSpreadsheetData() const;
83 
85  void sendSpreadsheet(int sheetId);
87  librevenge::RVNGString getSheetName(int id) const;
88 
95  LotusSpreadsheetInternal::Style const &style, int numRepeated=1);
97  void sendText(RVNGInputStreamPtr &input, long endPos, LotusSpreadsheetInternal::Style const &style) const;
99  void sendTextNote(RVNGInputStreamPtr &input, WPSEntry const &entry) const;
100 
102 
103  //
104  // low level
105  //
107 
109  bool readSheetName(std::shared_ptr<WPSStream> stream);
111  bool readSheetName1B(std::shared_ptr<WPSStream> stream, long endPos);
112 
114  bool readCellsFormat801(std::shared_ptr<WPSStream> stream, WPSVec3i const &minC, WPSVec3i const &maxC, int typeZone);
116  bool readColumnDefinition(std::shared_ptr<WPSStream> stream);
118  bool readColumnSizes(std::shared_ptr<WPSStream> stream);
120  bool readRowFormats(std::shared_ptr<WPSStream> stream);
122  bool readRowFormat(std::shared_ptr<WPSStream> stream, LotusSpreadsheetInternal::Style &style, int &numCell, long endPos);
124  bool readRowSizes(std::shared_ptr<WPSStream> stream, long endPos);
125 
127  bool readCell(std::shared_ptr<WPSStream> stream);
129  bool readCellName(std::shared_ptr<WPSStream> stream);
130 
131  // in fmt
132 
134  bool readSheetHeader(std::shared_ptr<WPSStream> stream);
136  bool readExtraRowFormats(std::shared_ptr<WPSStream> stream);
137 
138  // in zone 0x1b
139 
141  static bool readNote(std::shared_ptr<WPSStream> stream, long endPos);
142 
143  // data in formula
144 
145  /* reads a cell */
146  bool readCell(WPSStream &stream, int sId, bool isList, WKSContentListener::FormulaInstruction &instr);
147  /* reads a formula */
148  bool readFormula(WPSStream &stream, long endPos, int sId, bool newFormula,
149  std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
150  /* try to parse a variable data */
151  static bool parseVariable(std::string const &variable, WKSContentListener::FormulaInstruction &instr);
153  static std::string getDebugStringForText(std::string const &text);
154 private:
155  LotusSpreadsheet(LotusSpreadsheet const &orig) = delete;
157  std::shared_ptr<WKSContentListener> m_listener;
161  std::shared_ptr<LotusStyleManager> m_styleManager;
163  std::shared_ptr<LotusSpreadsheetInternal::State> m_state;
164 };
165 
166 #endif /* LOTUS_SPREAD_SHEET_H */
167 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
LotusSpreadsheetInternal::Style::operator==
bool operator==(Style const &st) const
operator==
Definition: LotusSpreadsheet.cpp:81
WKSContentListener::FormulaInstruction::F_Text
@ F_Text
Definition: WKSContentListener.h:59
LotusSpreadsheet::readRowSizes
bool readRowSizes(std::shared_ptr< WPSStream > stream, long endPos)
reads the row size ( in pt*32 )
Definition: LotusSpreadsheet.cpp:1759
LotusSpreadsheetInternal::Style::Style
Style(Style const &)=default
LotusSpreadsheetInternal::Cell::Cell
Cell()
constructor
Definition: LotusSpreadsheet.cpp:223
WPSCellFormat::F_BOOLEAN
@ F_BOOLEAN
Definition: WPSCell.h:54
LotusSpreadsheetInternal::Format123Style::operator=
Format123Style & operator=(Format123Style const &)=default
LotusSpreadsheet::version
int version() const
return the file version
Definition: LotusSpreadsheet.cpp:914
WKSSubDocument::parser
WKSParser * parser() const
returns the parser
Definition: WKSSubDocument.h:44
LotusSpreadsheet::LotusSpreadsheet
LotusSpreadsheet(LotusSpreadsheet const &orig)=delete
LotusSpreadsheetInternal::SubDocument::m_sheetParser
LotusSpreadsheet * m_sheetParser
the spreadsheet parse
Definition: LotusSpreadsheet.cpp:779
LotusSpreadsheetInternal::Spreadsheet::m_rowPageBreaksList
std::vector< int > m_rowPageBreaksList
the list of row page break
Definition: LotusSpreadsheet.cpp:483
LotusSpreadsheetInternal::Cell::m_styleId
int m_styleId
the style
Definition: LotusSpreadsheet.cpp:252
LotusSpreadsheet::readSheetName1B
bool readSheetName1B(std::shared_ptr< WPSStream > stream, long endPos)
reads a sheet name: zone 0x1b 36b0
Definition: LotusSpreadsheet.cpp:3262
LotusSpreadsheetInternal::State::m_version
int m_version
the file version
Definition: LotusSpreadsheet.cpp:735
LotusSpreadsheetInternal::CellsList::CellsList
CellsList()
constructor
Definition: LotusSpreadsheet.cpp:196
LotusSpreadsheetInternal::ExtraStyle::m_color
WPSColor m_color
the font color
Definition: LotusSpreadsheet.cpp:147
WKSContentListener::FormulaInstruction::m_fileName
librevenge::RVNGString m_fileName
the file name (external reference)
Definition: WKSContentListener.h:96
LotusSpreadsheetInternal::Format123Style::update
void update(Style &style) const
update the cell style
Definition: LotusSpreadsheet.cpp:508
WKSContentListener::CellContent::m_formula
std::vector< FormulaInstruction > m_formula
the formula list of instruction
Definition: WKSContentListener.h:155
LotusSpreadsheet::hasSomeSpreadsheetData
bool hasSomeSpreadsheetData() const
returns true if some spreadsheet are defined
Definition: LotusSpreadsheet.cpp:921
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
LotusSpreadsheetInternal::Spreadsheet::getRowHeight
WPSRowFormat getRowHeight(int row) const
returns the row size in point
Definition: LotusSpreadsheet.cpp:341
LotusSpreadsheet::readSheetHeader
bool readSheetHeader(std::shared_ptr< WPSStream > stream)
try to read a sheet header: 0xc3
Definition: LotusSpreadsheet.cpp:1879
WKSContentListener::FormulaInstruction::F_Long
@ F_Long
Definition: WKSContentListener.h:59
WPSCellFormat::HALIGN_FULL
@ HALIGN_FULL
Definition: WPSCell.h:47
WKSContentListener::CellContent::C_FORMULA
@ C_FORMULA
Definition: WKSContentListener.h:102
WPS_BOLD_BIT
#define WPS_BOLD_BIT
Definition: libwps_internal.h:506
LotusSpreadsheetInternal::Functions::m_name
char const * m_name
Definition: LotusSpreadsheet.cpp:2862
LotusSpreadsheetInternal::Table123Styles::addCellStyle
void addCellStyle(Vec2i const &cols, Vec2i const &rows, Format123Style const &format)
add a extra style to a list of cell
Definition: LotusSpreadsheet.cpp:621
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
LotusSpreadsheetInternal::Table123Styles
a class used to store the styles of a table in LotusSpreadsheet in a lotus 123 files
Definition: LotusSpreadsheet.cpp:570
WKSContentListener::FormulaInstruction::F_Cell
@ F_Cell
Definition: WKSContentListener.h:59
LotusSpreadsheet::readCell
bool readCell(std::shared_ptr< WPSStream > stream)
reads a cell
Definition: LotusSpreadsheet.cpp:2109
WPSEntry::end
long end() const
returns the end offset
Definition: WPSEntry.h:78
LotusSpreadsheet::setListener
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition: LotusSpreadsheet.h:67
LotusSpreadsheetInternal::Extra123Style::update
void update(Style &style) const
update the cell style
Definition: LotusSpreadsheet.cpp:556
WPSCell.h
LotusSpreadsheetInternal::Spreadsheet::empty
bool empty() const
returns true if the spreedsheet is empty
Definition: LotusSpreadsheet.cpp:464
WPSBox2::setMin
void setMin(Vec2< T > const &x)
resets the minimum point
Definition: libwps_internal.h:771
libwps_tools_win::Font::Type
Type
enum Type
Definition: libwps_tools_win.h:46
LotusSpreadsheetInternal::Spreadsheet::m_rowHeightMap
std::map< Vec2i, WPSRowFormat > m_rowHeightMap
the map Vec2i(min row, max row) to size in points
Definition: LotusSpreadsheet.cpp:479
LotusSpreadsheet::getDebugStringForText
static std::string getDebugStringForText(std::string const &text)
small debug function used to print text with format sequence
Definition: LotusSpreadsheet.cpp:3488
LotusSpreadsheetInternal::ExtraStyle::m_flag
int m_flag
the second flag: graph
Definition: LotusSpreadsheet.cpp:153
LotusSpreadsheetInternal::Format123Style::m_alignAcrossColumn
bool m_alignAcrossColumn
flag to know if we must align across column
Definition: LotusSpreadsheet.cpp:520
LotusSpreadsheet::m_styleManager
std::shared_ptr< LotusStyleManager > m_styleManager
the style manager
Definition: LotusSpreadsheet.h:161
LotusSpreadsheetInternal::Table123Styles::Table123Styles
Table123Styles()
constructor
Definition: LotusSpreadsheet.cpp:572
libwps::readDouble2Inv
bool readDouble2Inv(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 2 bytes: exponent 1.5 bytes, kind of mantisse 0.5 bytes
Definition: libwps_internal.cpp:273