GreatWksGraph.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 GREAT_WKS_GRAPH
00039 #  define GREAT_WKS_GRAPH
00040 
00041 #include <set>
00042 #include <string>
00043 #include <vector>
00044 
00045 #include <librevenge/librevenge.h>
00046 
00047 #include "libmwaw_internal.hxx"
00048 
00049 #include "MWAWDebug.hxx"
00050 #include "MWAWInputStream.hxx"
00051 
00052 namespace GreatWksGraphInternal
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 GreatWksDocument;
00065 class GreatWksParser;
00066 class GreatWksDBParser;
00067 class GreatWksDRParser;
00068 class GreatWksSSParser;
00069 
00075 class GreatWksGraph
00076 {
00077   friend class GreatWksDocument;
00078   friend class GreatWksParser;
00079   friend class GreatWksDBParser;
00080   friend class GreatWksDRParser;
00081   friend class GreatWksSSParser;
00082   friend class GreatWksGraphInternal::SubDocument;
00083 
00084 public:
00086   GreatWksGraph(GreatWksDocument &document);
00088   virtual ~GreatWksGraph();
00089 
00091   int version() const;
00092 
00094   int numPages() const;
00095 
00096 protected:
00098   bool sendPageGraphics();
00100   void flushExtra();
00101 
00102   //
00103   // Intermediate level
00104   //
00105 
00106   // RSRC
00108   bool readPatterns(MWAWEntry const &entry);
00110   bool readPalettes(MWAWEntry const &entry);
00111 
00112   // DataFork: pict
00114   bool sendPageFrames(GreatWksGraphInternal::Zone const &zone);
00116   bool sendFrame(shared_ptr<GreatWksGraphInternal::Frame> frame, GreatWksGraphInternal::Zone const &zone);
00117 
00119   bool sendGroup(GreatWksGraphInternal::FrameGroup const &group, GreatWksGraphInternal::Zone const &zone, MWAWPosition const &pos);
00121   void sendGroupChild(GreatWksGraphInternal::FrameGroup const &group, GreatWksGraphInternal::Zone const &zone, MWAWPosition const &pos);
00123   bool canCreateGraphic(GreatWksGraphInternal::FrameGroup const &group, GreatWksGraphInternal::Zone const &zone);
00125   void sendGroup(GreatWksGraphInternal::FrameGroup const &group, GreatWksGraphInternal::Zone const &zone, MWAWGraphicListenerPtr &listener);
00126 
00128   bool sendTextbox(GreatWksGraphInternal::FrameText const &text, GreatWksGraphInternal::Zone const &zone, MWAWPosition const &pos);
00130   bool sendTextboxAsGraphic(MWAWBox2f const &box, GreatWksGraphInternal::FrameText const &text, MWAWGraphicStyle const &style, MWAWListenerPtr listener);
00132   bool sendTextbox(MWAWEntry const &entry, MWAWListenerPtr listener);
00133 
00135   bool sendPicture(MWAWEntry const &entry, MWAWPosition pos);
00137   bool sendShape(GreatWksGraphInternal::FrameShape const &graph, GreatWksGraphInternal::Zone const &zone, MWAWPosition const &pos);
00138 
00139   // DataFork: graphic zone
00140 
00142   bool readGraphicZone();
00144   bool isGraphicZone();
00146   bool findGraphicZone();
00147 
00149   bool isPageFrames();
00151   bool readPageFrames();
00153   shared_ptr<GreatWksGraphInternal::Frame> readFrameHeader();
00155   bool readFrameExtraData(GreatWksGraphInternal::Frame &frame, int id, long endPos=-1);
00156 
00158   bool readStyle(MWAWGraphicStyle &style);
00160   bool readLineFormat(std::string &extra);
00161 
00162   // interface with mainParser
00163 
00164   //
00165   // low level
00166   //
00168   bool readFrameExtraDataRec(GreatWksGraphInternal::Zone &zone, int id, std::set<int> &seens, long endPos=-1);
00170   bool checkGraph(GreatWksGraphInternal::Zone &zone, int id, std::set<int> &seens);
00171 
00172 private:
00173   GreatWksGraph(GreatWksGraph const &orig);
00174   GreatWksGraph &operator=(GreatWksGraph const &orig);
00175 
00176 protected:
00177   //
00178   // data
00179   //
00181   GreatWksDocument &m_document;
00183   MWAWParserStatePtr m_parserState;
00185   shared_ptr<GreatWksGraphInternal::State> m_state;
00187   MWAWParser *m_mainParser;
00188 };
00189 #endif
00190 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: