CWGraph.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 CW_GRAPH
00039 #  define CW_GRAPH
00040 
00041 #include <string>
00042 #include <vector>
00043 
00044 #include <libwpd/libwpd.h>
00045 
00046 #include "libmwaw_internal.hxx"
00047 
00048 #include "MWAWDebug.hxx"
00049 #include "MWAWInputStream.hxx"
00050 #include "MWAWPosition.hxx"
00051 
00052 #include "CWStruct.hxx"
00053 
00054 namespace CWGraphInternal
00055 {
00056 struct Group;
00057 struct State;
00058 struct Style;
00059 struct Zone;
00060 struct ZoneShape;
00061 struct Bitmap;
00062 struct ZonePict;
00063 
00064 class SubDocument;
00065 }
00066 
00067 class CWParser;
00068 class CWStyleManager;
00069 
00075 class CWGraph
00076 {
00077   friend class CWGraphInternal::SubDocument;
00078   friend class CWParser;
00079 
00080 public:
00082   CWGraph(CWParser &parser);
00084   virtual ~CWGraph();
00085 
00087   int version() const;
00088 
00090   int numPages() const;
00091 
00093   shared_ptr<CWStruct::DSET> readGroupZone
00094   (CWStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
00095 
00097   shared_ptr<CWStruct::DSET> readBitmapZone
00098   (CWStruct::DSET const &zone, MWAWEntry const &entry, bool &complete);
00099 
00101   bool getSurfaceColor(CWGraphInternal::Style const style, MWAWColor &col) const;
00102 protected:
00104   void setSlideList(std::vector<int> const &slideList);
00106   bool canSendGroupAsGraphic(int number) const;
00108   bool sendGroup(int number, bool asGraphic, MWAWPosition const &pos=MWAWPosition());
00110   bool canSendBitmapAsGraphic(int number) const;
00112   bool sendBitmap(int number, bool asGraphic, MWAWPosition const &pos=MWAWPosition());
00113 
00115   void flushExtra();
00116 
00117   // interface with main parser
00118 
00120   void askToSend(int number, bool asGraphic, MWAWPosition const &pos=MWAWPosition());
00121 
00122   //
00123   // Intermediate level
00124   //
00125 
00127   void checkNumberAccrossPages(CWGraphInternal::Group &group) const;
00129   void updateInformation(CWGraphInternal::Group &group) const;
00131   bool canSendAsGraphic(CWGraphInternal::Group &group) const;
00133   bool sendGroup(CWGraphInternal::Group &group, MWAWPosition const &position);
00135   bool sendGroup(CWGraphInternal::Group &group, std::vector<size_t> const &lChild, MWAWGraphicListener &listener);
00137   bool sendGroupChild(CWGraphInternal::Group &group, size_t child, MWAWPosition position);
00138   /* read a simple group */
00139   shared_ptr<CWGraphInternal::Zone> readGroupDef(MWAWEntry const &entry);
00140 
00141   /* read a simple graphic zone */
00142   bool readShape(MWAWEntry const &entry,
00143                  CWGraphInternal::ZoneShape &zone);
00144 
00145   /* read the group data.
00146 
00147      \note \a beginGroupPos is only used to help debugging */
00148   bool readGroupData(CWGraphInternal::Group &group, long beginGroupPos);
00149 
00150   /* try to read the polygon data */
00151   bool readPolygonData(shared_ptr<CWGraphInternal::Zone> zone);
00152 
00154   /* try to read a pict data zone */
00155   bool readPictData(shared_ptr<CWGraphInternal::Zone> zone);
00156 
00157   /* read a picture */
00158   bool readPICT(CWGraphInternal::ZonePict &zone);
00159 
00160   /* read a postcript zone */
00161   bool readPS(CWGraphInternal::ZonePict &zone);
00162 
00163   /* read a ole document zone */
00164   bool readOLE(CWGraphInternal::ZonePict &zone);
00165 
00167   /* try to read the qtime data zone */
00168   bool readQTimeData(shared_ptr<CWGraphInternal::Zone> zone);
00169 
00170   /* read a named picture */
00171   bool readNamedPict(CWGraphInternal::ZonePict &zone);
00172 
00174   /* try to read a bitmap zone */
00175   bool readBitmapColorMap(std::vector<MWAWColor> &cMap);
00176 
00177   /* try to read the bitmap  */
00178   bool readBitmapData(CWGraphInternal::Bitmap &zone);
00179   //
00180   // low level
00181   //
00182 
00183   /* read the first zone of a group type */
00184   bool readGroupHeader(CWGraphInternal::Group &group);
00185 
00186   /* read some unknown data in first zone */
00187   bool readGroupUnknown(CWGraphInternal::Group &group, int zoneSz, int id);
00188 
00190   bool sendPicture(CWGraphInternal::ZonePict &pict, MWAWPosition pos,
00191                    WPXPropertyList extras = WPXPropertyList());
00192 
00194   bool sendShape(CWGraphInternal::ZoneShape &pict, MWAWPosition pos);
00195 
00197   bool sendBitmap(CWGraphInternal::Bitmap &pict, bool asGraphic, MWAWPosition pos);
00198 
00199 private:
00200   CWGraph(CWGraph const &orig);
00201   CWGraph &operator=(CWGraph const &orig);
00202 
00203 protected:
00204   //
00205   // data
00206   //
00208   MWAWParserStatePtr m_parserState;
00209 
00211   shared_ptr<CWGraphInternal::State> m_state;
00212 
00214   CWParser *m_mainParser;
00215 
00217   shared_ptr<CWStyleManager> m_styleManager;
00218 };
00219 #endif
00220 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: