Debian Codegraph @

src/lib/ScoopParser.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 SCOOP_PARSER
35 # define SCOOP_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWDebug.hxx"
43 #include "MWAWInputStream.hxx"
44
45 #include "MWAWParser.hxx"
46
47 namespace ScoopParserInternal
48 {
49 struct FrameZone;
50 struct Paragraph;
51 struct Shape;
52 struct TextZone;
53
54 struct State;
55
56 class SubDocument;
57 }
58
59 /** \brief the main class to read a Scoop v1 file
60 *
61 */
62 class ScoopParser final : public MWAWGraphicParser
63 {
64 friend class ScoopParserInternal::SubDocument;
65 public:
66 //! constructor
67 ScoopParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
68 //! destructor
69 ~ScoopParser() final;
70
71 //! checks if the document header is correct (or not)
72 bool checkHeader(MWAWHeader *header, bool strict=false) final;
73
74 // the main parse function
75 void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
76
77 protected:
78 //! creates the listener which will be associated to the document
79 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
80
81 protected:
82 //! finds the different objects zones
83 bool createZones();
84
85 // Intermediate level
86
87 //! try to read the print info zone
88 bool readPrintInfo();
89 //! try to the header zone
90 bool readHeader();
91
92 /** try to read the data associated to a text zone: its name, its
93 content, the list of shape which displayed this text */
94 bool readTextZone(ScoopParserInternal::TextZone &tZone);
95 //! try to read a frame paragraph
96 bool readTextZoneParagraph(ScoopParserInternal::Paragraph &para, int id);
97
98 //! try to read a font style
99 bool readFont(MWAWFont &font);
100 //! try to read a paragraph style
101 bool readParagraph(MWAWParagraph &para, bool define=false);
102 //! try to read a text zone
103 bool readText(MWAWEntry &entry, std::string const &what);
104
105 //! try to read a list of shape
106 bool readShapesList(std::vector<ScoopParserInternal::Shape> &shapes);
107 //! try to read a shape
108 bool readShape(ScoopParserInternal::Shape &shape, int id);
109 //! try to read a bitmap
110 bool readBitmap(MWAWEntry const &entry, MWAWEmbeddedObject &object, bool compressed=true);
111
112 //
113 // low level
114 //
115
116 //
117 // data
118 //
119
120 //! try to send a shape
121 bool send(ScoopParserInternal::Shape const &shape, MWAWVec2i const &decal);
122 //! try to send the text of a text zone
123 bool sendText(long tZoneId, int subZone);
124 //! try to send the text corresponding to a paragraph
125 bool sendText(ScoopParserInternal::Paragraph const &paragraph);
126
127 //! the state
128 std::shared_ptr<ScoopParserInternal::State> m_state;
129 };
130 #endif
131 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: