PocketExcel.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 POCKETEXCEL_H
23#define POCKETEXCEL_H
24
25#include <vector>
26
27#include <librevenge-stream/librevenge-stream.h>
28#include "libwps/libwps.h"
29
30#include "libwps_internal.h"
31#include "libwps_tools_win.h"
32
33#include "WKSContentListener.h"
34
35#include "WKSParser.h"
36
37class WPSCellFormat;
38
39namespace libwps
40{
41
43{
44struct Cell;
45struct Sheet;
46
47struct State;
48}
49
54class PocketExcelParser final : public WKSParser
55{
56public:
60 ~PocketExcelParser() override;
62 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
64 bool checkHeader(WPSHeader *header, bool strict=false);
65
66protected:
68 bool checkFilePosition(long pos);
69
71 std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
72
73 //
74 // low level
75 //
76
78 bool readZones(librevenge::RVNGSpreadsheetInterface *documentInterface);
80 bool readZone(librevenge::RVNGSpreadsheetInterface *documentInterface);
82 bool readBeginZone();
84 bool readSheetName();
86 bool readCell();
88 bool readDefColInfo();
90 bool readColInfo();
94 bool readCellFormat();
96 bool readName();
98 bool readNumberFormat();
100 bool readPaneInfo();
102 bool readDefRowHeight();
104 bool readRowHeight();
106 bool readSelection();
108 bool readSheetInfo();
109
111
112 // TODO
113
114protected:
116 void updateFmtWithUserFormat(WPSCellFormat &fmt, librevenge::RVNGString const &format);
117
119 librevenge::RVNGString readString(int N);
120
122 bool updateCell(int row, int col, int relPos, Vec2i const &actPos, WKSContentListener::FormulaInstruction &instr, int which=0);
123
125 bool readFormula(long endPos, Vec2i const &cellPos, std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &extra);
126
128 bool sendSheet(PocketExcelParserInternal::Sheet const &sheet, int id);
130 void sendCellContent(PocketExcelParserInternal::Cell const &cell, Vec2i const &pos);
131
132 std::shared_ptr<WKSContentListener> m_listener;
134 std::shared_ptr<PocketExcelParserInternal::State> m_state;
135};
136
137}
138
139#endif /* POCKETEXCEL_H */
140/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WKSParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header)
Definition WKSParser.cpp:30
a structure used to defined the cell format
Definition WPSCell.h:41
Definition WPSHeader.h:32
bool readSheetName()
tries to read the sheet name zone: 85
Definition PocketExcel.cpp:820
bool readDefColInfo()
tries to read the default column info: 55
Definition PocketExcel.cpp:914
bool readColInfo()
tries to read the column information: 7d
Definition PocketExcel.cpp:856
bool readSheetInfo()
tries to read the sheet window info: 3e
Definition PocketExcel.cpp:1205
bool readCellFormat()
tries to read a cellule format : e0
Definition PocketExcel.cpp:1475
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition PocketExcel.cpp:418
bool readPaneInfo()
tries to read the pane information: 41
Definition PocketExcel.cpp:950
bool readBeginZone()
tries to read the begining of a block: 09
Definition PocketExcel.cpp:706
bool readCell()
tries to read a cell: 1: blank, 3: number, 4: label
Definition PocketExcel.cpp:1749
bool readDefRowHeight()
tries to read the default row heights: 25
Definition PocketExcel.cpp:984
bool readNumberFormat()
tries to read a format zone: 1e
Definition PocketExcel.cpp:1082
bool readZones(librevenge::RVNGSpreadsheetInterface *documentInterface)
finds the different zones (spreadsheet, chart, print, ...)
Definition PocketExcel.cpp:473
std::shared_ptr< WKSContentListener > m_listener
Definition PocketExcel.h:132
bool sendSheet(PocketExcelParserInternal::Sheet const &sheet, int id)
try to send a sheet
Definition PocketExcel.cpp:2468
void sendCellContent(PocketExcelParserInternal::Cell const &cell, Vec2i const &pos)
send the cell data
Definition PocketExcel.cpp:2449
bool readZone(librevenge::RVNGSpreadsheetInterface *documentInterface)
tries to read a zone.
Definition PocketExcel.cpp:491
librevenge::RVNGString readString(int N)
try to read a string, ie. N unicode characters
Definition PocketExcel.cpp:1934
bool readFontDescription()
tries to read a font description: 32
Definition PocketExcel.cpp:751
bool readName()
tries to read a defined name: 8
Definition PocketExcel.cpp:1119
~PocketExcelParser() override
destructor
Definition PocketExcel.cpp:343
bool updateCell(int row, int col, int relPos, Vec2i const &actPos, WKSContentListener::FormulaInstruction &instr, int which=0)
try to update a cell position
Definition PocketExcel.cpp:2050
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
called by WPSDocument to parse the file
Definition PocketExcel.cpp:363
bool checkFilePosition(long pos)
return true if the pos is in the file, update the file size if need
Definition PocketExcel.cpp:347
bool readFormula(long endPos, Vec2i const &cellPos, std::vector< WKSContentListener::FormulaInstruction > &formula, std::string &extra)
try to read a formula
Definition PocketExcel.cpp:2060
std::shared_ptr< WKSContentListener > createListener(librevenge::RVNGSpreadsheetInterface *interface)
creates the main listener
Definition PocketExcel.cpp:405
void updateFmtWithUserFormat(WPSCellFormat &fmt, librevenge::RVNGString const &format)
try to update a cell format using the custom string
Definition PocketExcel.cpp:1262
PocketExcelParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header)
constructor
Definition PocketExcel.cpp:336
bool readRowHeight()
tries to read a row height: 8
Definition PocketExcel.cpp:1020
std::shared_ptr< PocketExcelParserInternal::State > m_state
the listener (if set)
Definition PocketExcel.h:134
bool readSelection()
tries to read the current selection: 1d
Definition PocketExcel.cpp:1174
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition libwps_internal.h:109
Vec2< int > Vec2i
Vec2 of int.
Definition libwps_internal.h:702
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition libwps_internal.h:87
Internal: namespace to define internal class of PocketExcelParser.
Definition PocketExcel.cpp:53
Definition libwps_internal.cpp:39
small class use to define a formula instruction
Definition WKSContentListener.h:58
a cell
Definition PocketExcel.cpp:78
the sheet data of a PocketExcelParser
Definition PocketExcel.cpp:131
the state of PocketExcelParser
Definition PocketExcel.cpp:249

Generated on for libwps by doxygen 1.17.0