Debian Codegraph @

src/lib/BeagleWksDRParser.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_DR_PARSER
35 # define BEAGLE_WKS_DR_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 BeagleWksDRParserInternal
52 {
53 class SubDocument;
54
55 struct Shape;
56 struct State;
57 }
58
59 class BeagleWksStructManager;
60
61 /** \brief the main class to read a BeagleWorks drawing file
62 */
63 class BeagleWksDRParser final : public MWAWGraphicParser
64 {
65 friend class BeagleWksDRParserInternal::SubDocument;
66 public:
67 //! constructor
68 BeagleWksDRParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
69 //! destructor
70 ~BeagleWksDRParser() 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::RVNGDrawingInterface *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::RVNGDrawingInterface *documentInterface);
84
85 //! returns the page left top point ( in inches)
86 MWAWVec2f getPageLeftTop() const;
87 //! adds a new page
88 void newPage(int number);
89
90 protected:
91 //! finds the different objects zones
92 bool createZones();
93
94 //! read the resource fork zone
95 bool readRSRCZones();
96
97 // send data
98
99 //! try to send the different pictures
100 bool sendPictures();
101 //! try to send a text box content
102 bool sendText(int id);
103
104 //! try to send the page graphic
105 bool sendPageFrames();
106 //! try to send a frame
107 bool sendFrame(BeagleWksStructManager::Frame const &frame);
108 //! try to send a picture
109 bool sendPicture(int pId, MWAWPosition const &pos,
110 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
111
112 //
113 // low level
114 //
115
116 //! try to read the graphic header
117 bool readGraphicHeader();
118 //! try to read the pattern zone
119 bool readPatterns();
120 //! try to read the colors zone
121 bool readColors();
122 //! try to read the arrows zone (unknown format)
123 bool readArrows();
124
125 //! try to read the shape position
126 bool readShapePositions();
127 //! try to read the shape definition
128 bool readShapeDefinitions();
129 //! try to read the shape data
130 bool readShapeDatas();
131
132 //! try to read a style of a shape
133 bool readStyle(BeagleWksDRParserInternal::Shape &shape);
134 //! read the print info zone
135 bool readPrintInfo();
136
137 // data fork
138
139 // resource fork
140
141 //! return the input input
142 MWAWInputStreamPtr rsrcInput();
143
144 //! a DebugFile used to write what we recognize when we parse the document in rsrc
145 libmwaw::DebugFile &rsrcAscii();
146
147
148 //! the state
149 std::shared_ptr<BeagleWksDRParserInternal::State> m_state;
150
151 //! the structure manager
152 std::shared_ptr<BeagleWksStructManager> m_structureManager;
153 };
154 #endif
155 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: