Debian Codegraph @

src/lib/BeagleWksSSParser.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 #ifndef BEAGLE_WKS_SS_PARSER
35 # define BEAGLE_WKS_SS_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWCell.hxx"
43 #include "MWAWDebug.hxx"
44 #include "MWAWGraphicStyle.hxx"
45 #include "MWAWInputStream.hxx"
46
47 #include "MWAWParser.hxx"
48
49 #include "BeagleWksStructManager.hxx"
50
51 namespace BeagleWksSSParserInternal
52 {
53 class SubDocument;
54
55 struct Cell;
56 struct Chart;
57 struct Spreadsheet;
58 struct State;
59 }
60
61 class BeagleWksStructManager;
62
63 /** \brief the main class to read a BeagleWorks spreadsheet file
64 */
65 class BeagleWksSSParser final : public MWAWSpreadsheetParser
66 {
67 friend struct BeagleWksSSParserInternal::Chart;
68 friend class BeagleWksSSParserInternal::SubDocument;
69 public:
70 //! constructor
71 BeagleWksSSParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
72 //! destructor
73 ~BeagleWksSSParser() final;
74
75 //! checks if the document header is correct (or not)
76 bool checkHeader(MWAWHeader *header, bool strict=false) final;
77
78 // the main parse function
79 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
80
81 protected:
82 //! inits all internal variables
83 void init();
84
85 //! creates the listener which will be associated to the document
86 void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface);
87
88 //! returns the page left top point ( in inches)
89 MWAWVec2f getPageLeftTop() const;
90 //! adds a new page
91 void newPage(int number);
92
93 //! try to send the main spreadsheet
94 bool sendSpreadsheet();
95 //! try to send a text zone
96 bool sendText(MWAWEntry const &entry, bool headerFooter=false);
97 //! try to send the page graphic
98 bool sendPageFrames();
99 //! try to send a frame
100 bool sendFrame(BeagleWksStructManager::Frame const &frame);
101 //! try to send a picture
102 bool sendPicture(int pId, MWAWPosition const &pos,
103 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
104 protected:
105 //! finds the different objects zones
106 bool createZones();
107
108 //! read the resource fork zone
109 bool readRSRCZones();
110
111 //
112 // low level
113 //
114
115 // data fork similar than in BeagleWksParser ...
116
117 //! read the print info zone
118 bool readPrintInfo();
119
120 // data fork
121
122 //! read the chart zone
123 bool readChartZone();
124
125 //! read a chart
126 bool readChart();
127
128 //! read the spreadsheet zone
129 bool readSpreadsheet();
130
131 //! read the spreadsheet row
132 bool readRowSheet(BeagleWksSSParserInternal::Spreadsheet &sheet);
133
134 //! read a cell row
135 bool readCellSheet(BeagleWksSSParserInternal::Cell &cell);
136
137 //! read an unknown zone ( which appears before and after the columns's width zone )
138 bool readZone0();
139
140 //! read the columns widths
141 bool readColumnWidths(BeagleWksSSParserInternal::Spreadsheet &sheet);
142
143 //! read the differents formula
144 bool readFormula(BeagleWksSSParserInternal::Spreadsheet &sheet);
145
146 // resource fork
147
148 //! return the input input
149 MWAWInputStreamPtr rsrcInput();
150
151 //! a DebugFile used to write what we recognize when we parse the document in rsrc
152 libmwaw::DebugFile &rsrcAscii();
153
154 //! the state
155 std::shared_ptr<BeagleWksSSParserInternal::State> m_state;
156
157 //! the structure manager
158 std::shared_ptr<BeagleWksStructManager> m_structureManager;
159 };
160 #endif
161 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: