GWGraph.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 /*
00035  * Parser to GreatWorks text document ( graphic part )
00036  *
00037  */
00038 #ifndef GW_GRAPH
00039 #  define GW_GRAPH
00040 
00041 #include <set>
00042 #include <string>
00043 #include <vector>
00044 
00045 #include <libwpd/libwpd.h>
00046 
00047 #include "libmwaw_internal.hxx"
00048 
00049 #include "MWAWDebug.hxx"
00050 #include "MWAWInputStream.hxx"
00051 
00052 namespace GWGraphInternal
00053 {
00054 struct Frame;
00055 struct FrameGroup;
00056 struct FrameShape;
00057 struct FrameText;
00058 struct Zone;
00059 
00060 struct State;
00061 class SubDocument;
00062 }
00063 
00064 class GWParser;
00065 
00071 class GWGraph
00072 {
00073   friend class GWParser;
00074   friend class GWGraphInternal::SubDocument;
00075 
00076 public:
00078   GWGraph(GWParser &parser);
00080   virtual ~GWGraph();
00081 
00083   int version() const;
00084 
00086   int numPages() const;
00087 
00088 protected:
00090   bool sendPageGraphics();
00092   void flushExtra();
00093 
00094   //
00095   // Intermediate level
00096   //
00097 
00098   // RSRC
00100   bool readPatterns(MWAWEntry const &entry);
00102   bool readPalettes(MWAWEntry const &entry);
00103 
00104   // DataFork: pict
00106   bool sendPageFrames(GWGraphInternal::Zone const &zone);
00108   bool sendFrame(shared_ptr<GWGraphInternal::Frame> frame, GWGraphInternal::Zone const &zone);
00109 
00111   bool sendGroup(GWGraphInternal::FrameGroup const &group, GWGraphInternal::Zone const &zone, MWAWPosition const &pos);
00113   void sendGroupChild(GWGraphInternal::FrameGroup const &group, GWGraphInternal::Zone const &zone, MWAWPosition const &pos);
00115   bool canCreateGraphic(GWGraphInternal::FrameGroup const &group, GWGraphInternal::Zone const &zone);
00117   void sendGroup(GWGraphInternal::FrameGroup const &group, GWGraphInternal::Zone const &zone, MWAWGraphicListenerPtr &listener);
00118 
00120   bool sendTextbox(GWGraphInternal::FrameText const &text, GWGraphInternal::Zone const &zone, MWAWPosition const &pos);
00122   bool sendTextboxAsGraphic(Box2f const &box, GWGraphInternal::FrameText const &text, MWAWGraphicStyle const &style);
00124   bool sendTextbox(MWAWEntry const &entry, bool inGraphic);
00125 
00127   bool sendPicture(MWAWEntry const &entry, MWAWPosition pos);
00129   bool sendShape(GWGraphInternal::FrameShape const &graph, GWGraphInternal::Zone const &zone, MWAWPosition const &pos);
00130 
00131   // DataFork: graphic zone
00132 
00134   bool readGraphicZone();
00136   bool isGraphicZone();
00138   bool findGraphicZone();
00139 
00141   bool isPageFrames();
00143   bool readPageFrames();
00145   shared_ptr<GWGraphInternal::Frame> readFrameHeader();
00147   bool readFrameExtraData(GWGraphInternal::Frame &frame, int id, long endPos=-1);
00148 
00150   bool readStyle(MWAWGraphicStyle &style);
00152   bool readLineFormat(std::string &extra);
00153 
00154   // interface with mainParser
00155 
00156   //
00157   // low level
00158   //
00160   bool readFrameExtraDataRec(GWGraphInternal::Zone &zone, int id, std::set<int> &seens, long endPos=-1);
00162   bool checkGraph(GWGraphInternal::Zone &zone, int id, std::set<int> &seens);
00163 
00164 private:
00165   GWGraph(GWGraph const &orig);
00166   GWGraph &operator=(GWGraph const &orig);
00167 
00168 protected:
00169   //
00170   // data
00171   //
00173   MWAWParserStatePtr m_parserState;
00174 
00176   shared_ptr<GWGraphInternal::State> m_state;
00177 
00179   GWParser *m_mainParser;
00180 };
00181 #endif
00182 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: