MacDrawProParser.hxx
Go to the documentation of this file.
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 (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
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 MACDRAWPRO_PARSER
35 # define MACDRAWPRO_PARSER
36
37 #include <map>
38 #include <string>
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 MacDrawProParserInternal
49 {
50 struct Layer;
51 struct Library;
52 struct Shape;
53 struct State;
54
55 class SubDocument;
56 }
57
58 class MacDrawProStyleManager;
59
63 class MacDrawProParser : public MWAWGraphicParser
64 {
65 friend class MacDrawProStyleManager;
66 friend class MacDrawProParserInternal::SubDocument;
67 public:
69 MacDrawProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
71 virtual ~MacDrawProParser();
72
74 bool checkHeader(MWAWHeader *header, bool strict=false);
75
76 // the main parse function
77 void parse(librevenge::RVNGDrawingInterface *documentInterface);
78
79 protected:
81 void init();
82
84 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
85
86 protected:
88 bool createZones();
89
90 // Intermediate level
91
93 bool readPrintInfo();
95 bool readHeaderInfo();
97 bool readLayersInfo();
99 bool readLayerLibraryCorrespondance();
101 bool readLibrariesInfo();
103 bool findObjectPositions(bool dataZone);
105 bool computeLayersAndLibrariesBoundingBox();
106
108 bool readStructuredHeaderZone(MWAWEntry const &entry, std::map<int, long> &idToDeltaPosMap);
109
110 //
111 // low level
112 //
113
115 int readObject();
117 bool readObjectData(MacDrawProParserInternal::Shape &shape, int zId);
119 bool readRotationInObjectData(MacDrawProParserInternal::Shape &shape, long endPos, std::string &extra);
121 bool updateGeometryShape(MacDrawProParserInternal::Shape &shape, float cornerWidth);
123 bool readBitmap(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
125 bool readTextII(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
127 bool readTextPro(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
129 bool readGeometryShapeData(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
130
131 // send functions
132
134 bool sendMasterPage();
136 bool sendPage(int page);
138 bool send(MacDrawProParserInternal::Library const &library);
140 bool send(MacDrawProParserInternal::Layer const &layer);
142 bool send(MacDrawProParserInternal::Shape const &shape, MWAWVec2f const &orig);
144 bool sendBitmap(MacDrawProParserInternal::Shape const &shape, MWAWPosition const &pos);
146 bool sendText(int zoneId);
148 bool sendMeasure(MWAWEntry const &entry);
150 void flushExtra();
151
152 //
153 // data
154 //
156 shared_ptr<MacDrawProParserInternal::State> m_state;
157
159 shared_ptr<MacDrawProStyleManager> m_styleManager;
160 };
161 #endif
162 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MacDrawProParserInternal::Library
Definition: MacDrawProParser.cxx:88
MacDrawProParserInternal::Layer
Definition: MacDrawProParser.cxx:65
MWAWParser.hxx
MacDrawProParserInternal::SubDocument
Internal: the subdocument of a MacDrawProParser.
Definition: MacDrawProParser.cxx:321
MacDrawProParserInternal
Internal: the structures of a MacDrawProParser.
Definition: MacDrawProParser.cxx:62
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:527
MacDrawProParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type)
the parser function
Definition: MacDrawProParser.cxx:361
MacDrawProParser
the main class to read a MacDraw II file
Definition: MacDrawProParser.hxx:63
MacDrawProStyleManager
the main class to read a MacDraw II file
Definition: MacDrawProStyleManager.hxx:59
MacDrawProParser::m_state
shared_ptr< MacDrawProParserInternal::State > m_state
the state
Definition: MacDrawProParser.hxx:156
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:517
MWAWGraphicParser
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:250
MWAWInputStream.hxx
MWAWDebug.hxx
MacDrawProParserInternal::Shape
Definition: MacDrawProParser.cxx:104
MacDrawProParser::m_styleManager
shared_ptr< MacDrawProStyleManager > m_styleManager
the style manager state
Definition: MacDrawProParser.hxx:159
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWVec2< float >