Debian Codegraph @

src/lib/SpringBoardParser.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 SPRINGBOARD_PARSER
35 # define SPRINGBOARD_PARSER
36
37 #include <string>
38 #include <utility>
39 #include <vector>
40
41 #include <librevenge/librevenge.h>
42
43 #include "MWAWDebug.hxx"
44 #include "MWAWInputStream.hxx"
45
46 #include "MWAWParser.hxx"
47
48 namespace SpringBoardParserInternal
49 {
50 struct State;
51
52 class SubDocument;
53 }
54
55 /** \brief the main class to read a SpringBoard v1 file
56 *
57 */
58 class SpringBoardParser final : public MWAWGraphicParser
59 {
60 friend class SpringBoardParserInternal::SubDocument;
61 public:
62 //! constructor
63 SpringBoardParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
64 //! destructor
65 ~SpringBoardParser() final;
66
67 //! checks if the document header is correct (or not)
68 bool checkHeader(MWAWHeader *header, bool strict=false) final;
69
70 // the main parse function
71 void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
72
73 protected:
74 //! creates the listener which will be associated to the document
75 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
76 //! try to parse the page numbering zone
77 bool parsePageNumbering(MWAWEntry const &entry);
78 //! try to parse a list of data
79 bool parseDataList(int id, MWAWEntry const &entry);
80 //! try to parse a second entry zones
81 bool parseLastZone(int id, MWAWEntry const &entry);
82
83 //! try to parse a list of frames corresponding to a page
84 bool parseFrames(int page, long pos);
85
86 // data
87
88 //! try to parse some data
89 bool parseData(int id, MWAWEntry const &entry, MWAWVec2i const &indices);
90 //! try to parse a list of paragraph style: zone8
91 bool parseParagraphStyle(MWAWEntry const &entry, MWAWVec2i const &indices);
92 //! try to parse a shape
93 bool parseShape(long pos, std::pair<int,int> const &pageId);
94
95 protected:
96
97 //! finds the different objects zones
98 bool createZones();
99
100 // Intermediate level
101
102 //! try to read a font
103 bool readFont(MWAWFont &font, int szFieldSize);
104
105 //! try to send a header/footer text
106 bool sendHeaderFooter(int hfId);
107 //! try to send a frame (with a shape)
108 bool sendFrame(std::pair<int,int> const &pageId);
109 //! try to send a shape text
110 bool sendTextShape(std::pair<int,int> const &pageId, int minParagraph=0, int maxParagraph=-1);
111 //! try to send a link text
112 bool sendLinkShape(std::pair<int,int> const &linkId, bool isTop);
113
114 //
115 // low level
116 //
117
118 /** returns true if the position is a valid file positions,
119 ie. exists in the file and not in a already parsed zone */
120 bool isPositionValid(long pos) const;
121 /** returns true if the zone is a valid zone positions,
122 ie. exists in the file and not in a already parsed zone */
123 bool isEntryValid(MWAWEntry const &entry) const;
124
125 //
126 // data
127 //
128
129 //! the state
130 std::shared_ptr<SpringBoardParserInternal::State> m_state;
131 };
132 #endif
133 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: