Debian Codegraph @

src/lib/MultiplanParser.hxx

raw
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance ([email protected])
18 * Copyright (C) 2002,2004 Marc Maurer ([email protected])
19 * Copyright (C) 2004-2006 Fridrich Strba ([email protected])
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent ([email protected])
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 /*
35 * Parser to convert spreadsheet Multiplan document
36 *
37 */
38 #ifndef MULTIPLAN_PARSER
39 # define MULTIPLAN_PARSER
40
41 #include <vector>
42
43 #include "MWAWCell.hxx"
44 #include "MWAWDebug.hxx"
45
46 #include "MWAWParser.hxx"
47
48 namespace MultiplanParserInternal
49 {
50 struct State;
51
52 class SubDocument;
53 }
54
55 /** \brief the main class to read a Multiplan document
56 *
57 * \note need more files to be sure to treat all documents
58 *
59 */
60 class MultiplanParser final : public MWAWSpreadsheetParser
61 {
62 friend class MultiplanParserInternal::SubDocument;
63 public:
64 //! constructor
65 MultiplanParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
66 //! destructor
67 ~MultiplanParser() final;
68
69 //! checks if the document header is correct (or not)
70 bool checkHeader(MWAWHeader *header, bool strict=false) final;
71
72 //! the main parse function
73 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
74
75 protected:
76 //! creates the listener which will be associated to the document
77 void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface);
78
79 //! finds the different objects zones
80 bool createZones();
81
82 //! read the columns limits pos
83 bool readColumnsPos();
84 //! read the header/footer strings, ...
85 bool readHeaderFooter();
86 //! read the printer information
87 bool readPrinterInfo();
88 //! read the printer message
89 bool readPrinterMessage();
90
91 //! read the spreadsheet zone list
92 bool readZonesList();
93 //! read an unknown zone: two blocks of 60 bytes
94 bool readZone1(MWAWEntry const &entry);
95 //! read the cell data position
96 bool readCellDataPosition(MWAWEntry const &entry);
97 //! read a link given a position
98 bool readLink(int pos, MWAWCellContent::FormulaInstruction &instruction);
99 //! read a link filename
100 bool readLinkFilename(int pos, MWAWCellContent::FormulaInstruction &instruction);
101 //! read a shared data
102 bool readSharedData(int pos, int cellType, MWAWVec2i const &cellPos, MWAWCellContent &content);
103 //! reads a name and returns the cell's instruction
104 bool readName(int pos, MWAWCellContent::FormulaInstruction &instruction);
105 //! read an unknown zone
106 bool readZoneB();
107 //! read an unknown zone
108 bool readZoneC();
109
110 //! try to send the main spreadsheet
111 bool sendSpreadsheet();
112 //! try to send a text zone
113 bool sendText(MWAWEntry const &entry);
114 //! try to send a cell
115 bool sendCell(MWAWVec2i const &cellPos, int pos);
116 protected:
117 //! try to read a double value
118 bool readDouble(double &value);
119 //! try to read a formula
120 bool readFormula(MWAWVec2i const &cellPos, std::vector<MWAWCellContent::FormulaInstruction> &formula, long endPos, std::string &extra);
121
122 //
123 // data
124 //
125
126 //! the state
127 std::shared_ptr<MultiplanParserInternal::State> m_state;
128 };
129 #endif
130 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: