ClarisWksGraph.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 Claris Works text document ( graphic part )
00036  *
00037  */
00038 #ifndef CLARIS_WKS_GRAPH
00039 #  define CLARIS_WKS_GRAPH
00040 
00041 #include <string>
00042 #include <vector>
00043 
00044 #include <librevenge/librevenge.h>
00045 
00046 #include "libmwaw_internal.hxx"
00047 
00048 #include "MWAWDebug.hxx"
00049 #include "MWAWInputStream.hxx"
00050 #include "MWAWPosition.hxx"
00051 
00052 #include "ClarisWksStruct.hxx"
00053 
00054 namespace ClarisWksGraphInternal
00055 {
00056 struct Group;
00057 struct State;
00058 struct Style;
00059 struct Zone;
00060 struct Chart;
00061 struct ZoneShape;
00062 struct Bitmap;
00063 struct ZonePict;
00064 
00065 class SubDocument;
00066 }
00067 
00068 class ClarisWksDocument;
00069 class ClarisWksParser;
00070 class MWAWParser;
00071 
00077 class ClarisWksGraph
00078 {
00079   friend class ClarisWksGraphInternal::SubDocument;
00080   friend class ClarisWksDocument;
00081   friend class ClarisWksParser;
00082 
00083 public:
00085   ClarisWksGraph(ClarisWksDocument &document);
00087   virtual ~ClarisWksGraph();
00088 
00090   int version() const;
00091 
00093   int numPages() const;
00094 
00096   bool getPageDimension(MWAWVec2f &dim) const;
00097 
00099   void computePositions() const;
00100 
00102   void findMasterPage() const;
00103 
00105   shared_ptr<ClarisWksStruct::DSET> readGroupZone
00106   (ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
00107 
00109   shared_ptr<ClarisWksStruct::DSET> readBitmapZone
00110   (ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
00111 
00113   bool getSurfaceColor(ClarisWksGraphInternal::Style const &style, MWAWColor &col) const;
00114 protected:
00116   bool canSendGroupAsGraphic(int number) const;
00118   bool sendPageGraphics(int groupId);
00120   bool sendMaster(int pg);
00122   bool sendGroup(int number, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
00124   bool canSendBitmapAsGraphic(int number) const;
00126   bool sendBitmap(int number, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
00127 
00129   void flushExtra();
00130 
00131   // interface with main parser
00132 
00134   void askToSend(int number, MWAWListenerPtr listener, MWAWPosition const &pos=MWAWPosition());
00135 
00136   //
00137   // Intermediate level
00138   //
00139 
00141   void updateGroup(ClarisWksGraphInternal::Group &group) const;
00143   bool canSendAsGraphic(ClarisWksGraphInternal::Group &group) const;
00145   bool sendGroup(ClarisWksGraphInternal::Group &group, MWAWPosition const &position);
00147   bool sendGroupChild(std::vector<shared_ptr<ClarisWksGraphInternal::Zone> > const &lChild, MWAWListenerPtr listener, MWAWVec2f const &leftTop);
00149   bool sendGroupChild(shared_ptr<ClarisWksGraphInternal::Zone> zone, MWAWPosition position);
00151   bool sendPageChild(ClarisWksGraphInternal::Group &group);
00152   /* read a simple group */
00153   shared_ptr<ClarisWksGraphInternal::Zone> readGroupDef(MWAWEntry const &entry);
00154   /* read the group data.
00155 
00156      \note \a beginGroupPos is only used to help debugging */
00157   bool readGroupData(ClarisWksGraphInternal::Group &group, long beginGroupPos);
00158 
00159   /* read a simple graphic zone */
00160   bool readShape(MWAWEntry const &entry,
00161                  ClarisWksGraphInternal::ZoneShape &zone);
00162 
00163   /* try to read the chart data */
00164   bool readChartData(shared_ptr<ClarisWksGraphInternal::Zone> zone);
00165 
00166   /* try to read a pict data zone */
00167   bool readPictData(shared_ptr<ClarisWksGraphInternal::Zone> zone);
00168 
00169   /* try to read the polygon data */
00170   bool readPolygonData(shared_ptr<ClarisWksGraphInternal::Zone> zone);
00171 
00172   /* read a picture */
00173   bool readPICT(ClarisWksGraphInternal::ZonePict &zone);
00174 
00175   /* read a postcript zone */
00176   bool readPS(ClarisWksGraphInternal::ZonePict &zone);
00177 
00178   /* read a ole document zone */
00179   bool readOLE(ClarisWksGraphInternal::ZonePict &zone);
00180 
00182   /* try to read the qtime data zone */
00183   bool readQTimeData(shared_ptr<ClarisWksGraphInternal::Zone> zone);
00184 
00185   /* read a named picture */
00186   bool readNamedPict(ClarisWksGraphInternal::ZonePict &zone);
00187 
00189   /* try to read a bitmap zone */
00190   bool readBitmapColorMap(std::vector<MWAWColor> &cMap);
00191 
00192   /* try to read the bitmap  */
00193   bool readBitmapData(ClarisWksGraphInternal::Bitmap &zone);
00194   //
00195   // low level
00196   //
00197 
00198   /* read the first zone of a group type */
00199   bool readGroupHeader(ClarisWksGraphInternal::Group &group);
00200 
00201   /* read some unknown data in first zone */
00202   bool readGroupUnknown(ClarisWksGraphInternal::Group &group, int zoneSz, int id);
00203 
00205   bool sendPicture(ClarisWksGraphInternal::ZonePict &pict, MWAWPosition pos);
00206 
00208   bool sendShape(ClarisWksGraphInternal::ZoneShape &pict, MWAWPosition pos);
00209 
00211   bool sendBitmap(ClarisWksGraphInternal::Bitmap &pict, MWAWListener &listener, MWAWPosition pos);
00212 
00213 private:
00214   ClarisWksGraph(ClarisWksGraph const &orig);
00215   ClarisWksGraph &operator=(ClarisWksGraph const &orig);
00216 
00217 protected:
00218   //
00219   // data
00220   //
00222   ClarisWksDocument &m_document;
00223 
00225   MWAWParserStatePtr m_parserState;
00226 
00228   shared_ptr<ClarisWksGraphInternal::State> m_state;
00229 
00231   MWAWParser *m_mainParser;
00232 };
00233 #endif
00234 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: