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 }
42 
43 class LotusParser;
44 class LotusStyleManager;
45 
51 {
52 public:
53  friend class LotusParser;
54 
56  explicit LotusSpreadsheet(LotusParser &parser);
60  void cleanState();
62  void updateState();
65  {
66  m_listener = listen;
67  }
69  void setLastSpreadsheetId(int id);
70 
71  // interface which LotusParser
72 
74  bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos);
75 protected:
77  int version() const;
79  bool hasSomeSpreadsheetData() const;
80 
82  void sendSpreadsheet(int sheetId);
83 
87  void sendRowContent(LotusSpreadsheetInternal::Spreadsheet const &sheet, int row);
89  void sendCellContent(LotusSpreadsheetInternal::Cell const &cell,
90  LotusSpreadsheetInternal::Style const &style, int numRepeated=1);
92  void sendText(RVNGInputStreamPtr &input, long endPos, LotusSpreadsheetInternal::Style const &style) const;
93 
95 
96  //
97  // low level
98  //
100 
102  bool readSheetName(shared_ptr<WPSStream> stream);
104  bool readSheetName1B(shared_ptr<WPSStream> stream, long endPos);
105 
107  bool readColumnDefinition(shared_ptr<WPSStream> stream);
109  bool readColumnSizes(shared_ptr<WPSStream> stream);
111  bool readRowFormats(shared_ptr<WPSStream> stream);
113  bool readRowFormat(shared_ptr<WPSStream> stream, LotusSpreadsheetInternal::Style &style, int &numCell, long endPos);
115  bool readRowSizes(shared_ptr<WPSStream> stream, long endPos);
116 
118  bool readCell(shared_ptr<WPSStream> stream);
120  bool readCellName(shared_ptr<WPSStream> stream);
121 
122  // in fmt
123 
125  bool readSheetHeader(shared_ptr<WPSStream> stream);
127  bool readExtraRowFormats(shared_ptr<WPSStream> stream);
128 
129  // in zone 0x1b
130 
132  bool readNote(shared_ptr<WPSStream> stream, long endPos);
133 
134  // data in formula
135 
136  /* reads a cell */
137  bool readCell(WPSStream &stream, int sId, bool isList, WKSContentListener::FormulaInstruction &instr);
138  /* reads a formula */
139  bool readFormula(WPSStream &stream, long endPos, int sId, bool newFormula,
140  std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
141 
143  static std::string getDebugStringForText(std::string const &text);
144 private:
145  LotusSpreadsheet(LotusSpreadsheet const &orig);
147  shared_ptr<WKSContentListener> m_listener;
148  LotusParser &m_mainParser;
151  shared_ptr<LotusStyleManager> m_styleManager;
153  shared_ptr<LotusSpreadsheetInternal::State> m_state;
154 };
155 
156 #endif /* LOTUS_SPREAD_SHEET_H */
157 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
shared_ptr< WKSContentListener > m_listener
Definition: LotusSpreadsheet.h:147
a cellule of a Lotus spreadsheet
Definition: LotusSpreadsheet.cpp:192
int version() const
return the file version
Definition: Lotus.cpp:217
a class used to store a style of a cell in LotusSpreadsheet
Definition: LotusSpreadsheet.cpp:53
bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos) const
returns the left top position of a cell
Definition: Lotus.cpp:253
This class parses a WK2..WK4 Lotus spreadsheet.
Definition: Lotus.h:66
shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition: libwps_internal.h:115
This class parses the Lotus style.
Definition: LotusStyleManager.h:45
the spreadsheet of a LotusSpreadsheet
Definition: LotusSpreadsheet.cpp:256
WKSParser & operator=(const WKSParser &)
shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:88
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition: LotusSpreadsheet.h:64
This class parses Microsoft Works spreadsheet file.
Definition: LotusSpreadsheet.h:50
shared_ptr< LotusSpreadsheetInternal::State > m_state
the internal state
Definition: LotusSpreadsheet.h:153
shared_ptr< LotusStyleManager > m_styleManager
the style manager
Definition: LotusSpreadsheet.h:151
Definition: LotusSpreadsheet.cpp:48
small structure use to store a stream and it debug file
Definition: WPSStream.h:29
small class use to define a formula instruction
Definition: WKSContentListener.h:54
shared_ptr< WKSContentListener > m_listener
Definition: Lotus.h:164
friend class LotusSpreadsheet
Definition: Lotus.h:70

Generated on Wed Oct 26 2016 16:54:37 for libwps by doxygen 1.8.12