Debian Codegraph @

src/lib/BeagleWksDBParser.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_DB_PARSER
35 # define BEAGLE_WKS_DB_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 BeagleWksDBParserInternal
52 {
53 class SubDocument;
54
55 struct Database;
56 struct State;
57 }
58
59 class BeagleWksStructManager;
60
61 /** \brief the main class to read a BeagleWorks database file
62 */
63 class BeagleWksDBParser final : public MWAWSpreadsheetParser
64 {
65 friend class BeagleWksDBParserInternal::SubDocument;
66 public:
67 //! constructor
68 BeagleWksDBParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
69 //! destructor
70 ~BeagleWksDBParser() final;
71
72 //! checks if the document header is correct (or not)
73 bool checkHeader(MWAWHeader *header, bool strict=false) final;
74
75 // the main parse function
76 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
77
78 protected:
79 //! inits all internal variables
80 void init();
81
82 //! creates the listener which will be associated to the document
83 void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface);
84
85 //! returns the page left top point ( in inches)
86 MWAWVec2f getPageLeftTop() const;
87
88 //! try to send the main database
89 bool sendDatabase();
90 //! try to send a text zone
91 bool sendText(MWAWEntry const &entry, bool headerFooter=false);
92 //! try to send the page graphic
93 bool sendPageFrames();
94 //! try to send a frame
95 bool sendFrame(BeagleWksStructManager::Frame const &frame);
96 //! try to send a picture
97 bool sendPicture(int pId, MWAWPosition const &pos, bool readEDTP,
98 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
99 protected:
100 //! finds the different objects zones
101 bool createZones();
102
103 //! read the resource fork zone
104 bool readRSRCZones();
105
106 //
107 // low level
108 //
109
110 // data fork similar than in BeagleWksParser ...
111
112 //! read the print info zone
113 bool readPrintInfo();
114
115 // data fork
116
117 //! read the database zone
118 bool readDatabase();
119 //! read a row
120 bool readRow();
121 //! read the fields list
122 bool readFields();
123 //! read the layout zone
124 bool readLayouts();
125 //! read a layout zone
126 bool readLayout(int id);
127 //! try to read a cell's format+font
128 bool readFormat(MWAWCell &cell, std::string &extra);
129
130 // resource fork
131
132 //! return the input input
133 MWAWInputStreamPtr rsrcInput();
134
135 //! a DebugFile used to write what we recognize when we parse the document in rsrc
136 libmwaw::DebugFile &rsrcAscii();
137
138 //! the state
139 std::shared_ptr<BeagleWksDBParserInternal::State> m_state;
140
141 //! the structure manager
142 std::shared_ptr<BeagleWksStructManager> m_structureManager;
143 };
144 #endif
145 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: