MacDrawProParser.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 
00003 /* libmwaw
00004 * Version: MPL 2.0 / LGPLv2+
00005 *
00006 * The contents of this file are subject to the Mozilla Public License Version
00007 * 2.0 (the "License"); you may not use this file except in compliance with
00008 * the License or as specified alternatively below. You may obtain a copy of
00009 * the License at http://www.mozilla.org/MPL/
00010 *
00011 * Software distributed under the License is distributed on an "AS IS" basis,
00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013 * for the specific language governing rights and limitations under the
00014 * License.
00015 *
00016 * Major Contributor(s):
00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00020 * Copyright (C) 2006, 2007 Andrew Ziem
00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00022 *
00023 *
00024 * All Rights Reserved.
00025 *
00026 * For minor contributions see the git repository.
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00030 * in which case the provisions of the LGPLv2+ are applicable
00031 * instead of those above.
00032 */
00033 
00034 #ifndef MACDRAWPRO_PARSER
00035 #  define MACDRAWPRO_PARSER
00036 
00037 #include <map>
00038 #include <string>
00039 #include <vector>
00040 
00041 #include <librevenge/librevenge.h>
00042 
00043 #include "MWAWDebug.hxx"
00044 #include "MWAWInputStream.hxx"
00045 
00046 #include "MWAWParser.hxx"
00047 
00048 namespace MacDrawProParserInternal
00049 {
00050 struct Layer;
00051 struct Library;
00052 struct Shape;
00053 struct State;
00054 
00055 class SubDocument;
00056 }
00057 
00058 class MacDrawProStyleManager;
00059 
00063 class MacDrawProParser : public MWAWGraphicParser
00064 {
00065   friend class MacDrawProStyleManager;
00066   friend class MacDrawProParserInternal::SubDocument;
00067 public:
00069   MacDrawProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00071   virtual ~MacDrawProParser();
00072 
00074   bool checkHeader(MWAWHeader *header, bool strict=false);
00075 
00076   // the main parse function
00077   void parse(librevenge::RVNGDrawingInterface *documentInterface);
00078 
00079 protected:
00081   void init();
00082 
00084   void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
00085 
00086 protected:
00088   bool createZones();
00089 
00090   // Intermediate level
00091 
00093   bool readPrintInfo();
00095   bool readHeaderInfo();
00097   bool readLayersInfo();
00099   bool readLayerLibraryCorrespondance();
00101   bool readLibrariesInfo();
00103   bool findObjectPositions(bool dataZone);
00105   bool computeLayersAndLibrariesBoundingBox();
00106 
00108   bool readStructuredHeaderZone(MWAWEntry const &entry, std::map<int, long> &idToDeltaPosMap);
00109 
00110   //
00111   // low level
00112   //
00113 
00115   int readObject();
00117   bool readObjectData(MacDrawProParserInternal::Shape &shape, int zId);
00119   bool readRotationInObjectData(MacDrawProParserInternal::Shape &shape, long endPos, std::string &extra);
00121   bool updateGeometryShape(MacDrawProParserInternal::Shape &shape, float cornerWidth);
00123   bool readBitmap(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
00125   bool readTextII(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
00127   bool readTextPro(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
00129   bool readGeometryShapeData(MacDrawProParserInternal::Shape &shape, MWAWEntry const &entry);
00130 
00131   // send functions
00132 
00134   bool sendMasterPage();
00136   bool sendPage(int page);
00138   bool send(MacDrawProParserInternal::Library const &library);
00140   bool send(MacDrawProParserInternal::Layer const &layer);
00142   bool send(MacDrawProParserInternal::Shape const &shape, MWAWVec2f const &orig);
00144   bool sendBitmap(MacDrawProParserInternal::Shape const &shape, MWAWPosition const &pos);
00146   bool sendText(int zoneId);
00148   bool sendLabel(MWAWEntry const &entry);
00150   void flushExtra();
00151 
00152   //
00153   // data
00154   //
00156   shared_ptr<MacDrawProParserInternal::State> m_state;
00157 
00159   shared_ptr<MacDrawProStyleManager> m_styleManager;
00160 };
00161 #endif
00162 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: