Debian Codegraph @

src/lib/BeagleWksStructManager.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 BeagleWorks document
36 *
37 */
38 #ifndef BEAGLE_WKS_STRUCT_MANAGER
39 # define BEAGLE_WKS_STRUCT_MANAGER
40
41 #include <map>
42
43 #include "libmwaw_internal.hxx"
44
45 #include "MWAWCell.hxx"
46 #include "MWAWDebug.hxx"
47
48 namespace BeagleWksStructManagerInternal
49 {
50 struct State;
51 }
52 /** \brief the main class to read the structure shared between different BeagleWorks files
53 *
54 *
55 *
56 */
57 class BeagleWksStructManager
58 {
59 public:
60 struct Frame;
61
62 //! constructor
63 explicit BeagleWksStructManager(MWAWParserStatePtr const &parserState);
64 //! destructor
65 ~BeagleWksStructManager();
66
67 //! returns a frame corresponding to an id
68 bool getFrame(int fId, Frame &frame) const;
69 //! returns the id to frame map
70 std::map<int,Frame> const &getIdFrameMap() const;
71
72 //! returns a font id corresponding to a file id (or -3)
73 int getFontId(int fFontId) const;
74 //! returns the header, footer entries (find by readDocumentInfo)
75 void getHeaderFooterEntries(MWAWEntry &header, MWAWEntry &footer) const;
76 //! read the font names
77 bool readFontNames(MWAWEntry const &entry);
78 //! read the frame
79 bool readFrame(MWAWEntry const &entry);
80 //! read the document information ( pagespan + header/footer)
81 bool readDocumentInfo();
82 //! read the document preferences
83 bool readDocumentPreferences();
84
85 // resource fork
86
87 //! read a picture (edtp or PICT resource )
88 bool readPicture(int pId, librevenge::RVNGBinaryData &pict, bool readEDTP=true);
89 //! read the windows positions ( wPos 1001 resource block )
90 bool readwPos(MWAWEntry const &entry);
91 //! read the font style ressource
92 bool readFontStyle(MWAWEntry const &entry);
93
94 //
95 // formula data
96 //
97 /* reads a cell */
98 bool readCellInFormula(MWAWVec2i actPos, MWAWCellContent::FormulaInstruction &instr);
99 /* reads a formula */
100 bool readFormula(long endPos, MWAWVec2i const &pos, std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error);
101
102 //! Internal: a structure use to store a frame in a BeagleWorks files
103 struct Frame {
104 //! constructor
105 Frame()
106 : m_charAnchor(true)
107 , m_id(0)
108 , m_pictId(0)
109 , m_origin()
110 , m_dim()
111 , m_page(1)
112 , m_wrap(0)
113 , m_border()
114 , m_bordersSet(0)
115 , m_extra("")
116 {
117 }
118 //! operator<<
119 friend std::ostream &operator<<(std::ostream &o, Frame const &frm)
120 {
121 if (frm.m_id) o << "id=" << frm.m_id << ",";
122 if (!frm.m_charAnchor) o << "pageFrame,";
123 if (frm.m_page!=1) o << "page=" << frm.m_page << ",";
124 if (frm.m_origin[0]>0||frm.m_origin[1]>0)
125 o << "origin=" << frm.m_origin << ",";
126 o << "dim=" << frm.m_dim << ",";
127 if (frm.m_pictId) o << "picId=" << std::hex << frm.m_pictId << std::dec << ",";
128 o << frm.m_extra;
129 return o;
130 }
131 //! a flag to know if this is a char or a page frame
132 bool m_charAnchor;
133 //! frame id
134 int m_id;
135 //! the picture id
136 int m_pictId;
137 //! the origin ( for a page frame )
138 MWAWVec2f m_origin;
139 //! the dimension
140 MWAWVec2f m_dim;
141 //! the page ( for a page frame )
142 int m_page;
143 //! the wrapping: 0=none, 1=rectangle, 2=irregular
144 int m_wrap;
145 //! the border
146 MWAWBorder m_border;
147 //! the list of border which are set in form libmwaw::LeftBit|...
148 int m_bordersSet;
149 //! extra data
150 std::string m_extra;
151 };
152 protected:
153 //! return the input input
154 MWAWInputStreamPtr getInput();
155 //! a DebugFile used to write what we recognize when we parse the document
156 libmwaw::DebugFile &ascii();
157 //! return the input input
158 MWAWInputStreamPtr rsrcInput();
159 //! a DebugFile used to write what we recognize when we parse the document in rsrc
160 libmwaw::DebugFile &rsrcAscii();
161
162 private:
163 BeagleWksStructManager(BeagleWksStructManager const &orig) = delete;
164 BeagleWksStructManager &operator=(BeagleWksStructManager const &orig) = delete;
165
166 protected:
167 //
168 // data
169 //
170 //! the parser state
171 MWAWParserStatePtr m_parserState;
172
173 //! the state
174 std::shared_ptr<BeagleWksStructManagerInternal::State> m_state;
175 };
176
177 #endif
178 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: