HMWKGraph.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 HanMac Word text document ( graphic part )
00036  *
00037  */
00038 #ifndef HMWK_GRAPH
00039 #  define HMWK_GRAPH
00040 
00041 #include <map>
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 HMWKGraphInternal
00053 {
00054 struct Frame;
00055 struct ShapeGraph;
00056 struct FootnoteFrame;
00057 struct Group;
00058 struct PictureFrame;
00059 struct Table;
00060 struct TableCell;
00061 struct TextBox;
00062 
00063 struct Picture;
00064 
00065 struct State;
00066 class SubDocument;
00067 }
00068 
00069 struct HMWKZone;
00070 class HMWKParser;
00071 
00077 class HMWKGraph
00078 {
00079   friend class HMWKParser;
00080   friend class HMWKGraphInternal::SubDocument;
00081   friend struct HMWKGraphInternal::Table;
00082 
00083 public:
00085   HMWKGraph(HMWKParser &parser);
00087   virtual ~HMWKGraph();
00088 
00090   int version() const;
00091 
00093   int numPages() const;
00094 
00095 protected:
00096 
00098   bool getColor(int colId, int patternId, MWAWColor &color) const;
00099 
00101   bool sendPageGraphics(std::vector<long> const &doNotSendIds);
00103   void flushExtra();
00104 
00105 
00106   //
00107   // Intermediate level
00108   //
00109 
00111   bool readFrames(shared_ptr<HMWKZone> zone);
00113   bool readPicture(shared_ptr<HMWKZone> zone);
00115   void prepareStructures();
00116 
00117   // interface with mainParser
00118 
00120   bool sendFrame(long frameId, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00122   bool sendPicture(long pictId, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00123 
00125   bool sendText(long textId, long id, bool asGraphic=false);
00128   std::map<long,int> getTextFrameInformations() const;
00129 
00130   //
00131   // low level
00132   //
00133 
00135   bool checkGroupStructures(long fileId, long fileSubId, std::multimap<long, long> &seens, bool inGroup);
00136 
00138   bool sendPicture(HMWKGraphInternal::Picture const &picture, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00140   bool sendFrame(HMWKGraphInternal::Frame const &frame, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00142   bool sendShapeGraph(HMWKGraphInternal::ShapeGraph const &shape, MWAWPosition pos);
00144   bool sendPictureFrame(HMWKGraphInternal::PictureFrame const &pict, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00146   bool sendEmptyPicture(MWAWPosition pos);
00148   bool sendTextBox(HMWKGraphInternal::TextBox const &textbox, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00150   bool sendTableUnformatted(long fId);
00151 
00153   bool sendGroup(long fId, MWAWPosition pos);
00155   bool sendGroup(HMWKGraphInternal::Group const &group, MWAWPosition pos);
00157   bool canCreateGraphic(HMWKGraphInternal::Group const &group);
00159   void sendGroupChild(HMWKGraphInternal::Group const &group, MWAWPosition const &pos);
00161   void sendGroup(HMWKGraphInternal::Group const &group, MWAWGraphicListenerPtr &listener);
00162 
00164   shared_ptr<HMWKGraphInternal::ShapeGraph> readShapeGraph(shared_ptr<HMWKZone> zone, HMWKGraphInternal::Frame const &header);
00166   shared_ptr<HMWKGraphInternal::FootnoteFrame> readFootnoteFrame(shared_ptr<HMWKZone> zone, HMWKGraphInternal::Frame const &header);
00168   shared_ptr<HMWKGraphInternal::Group> readGroup(shared_ptr<HMWKZone> zone, HMWKGraphInternal::Frame const &header);
00170   shared_ptr<HMWKGraphInternal::PictureFrame> readPictureFrame(shared_ptr<HMWKZone> zone, HMWKGraphInternal::Frame const &header);
00172   shared_ptr<HMWKGraphInternal::Table> readTable(shared_ptr<HMWKZone> zone, HMWKGraphInternal::Frame const &header);
00174   shared_ptr<HMWKGraphInternal::TextBox> readTextBox(shared_ptr<HMWKZone> zone, HMWKGraphInternal::Frame const &header, bool isMemo);
00175 
00176 private:
00177   HMWKGraph(HMWKGraph const &orig);
00178   HMWKGraph &operator=(HMWKGraph const &orig);
00179 
00180 protected:
00181   //
00182   // data
00183   //
00185   MWAWParserStatePtr m_parserState;
00186 
00188   shared_ptr<HMWKGraphInternal::State> m_state;
00189 
00191   HMWKParser *m_mainParser;
00192 };
00193 #endif
00194 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: