HMWJGraph.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-J text document ( graphic part )
00036  *
00037  */
00038 #ifndef HMWJ_GRAPH
00039 #  define HMWJ_GRAPH
00040 
00041 #include <map>
00042 #include <set>
00043 #include <string>
00044 #include <vector>
00045 
00046 #include <libwpd/libwpd.h>
00047 
00048 #include "libmwaw_internal.hxx"
00049 
00050 #include "MWAWDebug.hxx"
00051 #include "MWAWInputStream.hxx"
00052 
00053 namespace HMWJGraphInternal
00054 {
00055 struct CellFormat;
00056 struct Frame;
00057 struct CommentFrame;
00058 struct Group;
00059 struct PictureFrame;
00060 struct ShapeGraph;
00061 struct TableFrame;
00062 struct TextboxFrame;
00063 struct TextFrame;
00064 struct Table;
00065 struct TableCell;
00066 
00067 struct State;
00068 class SubDocument;
00069 }
00070 
00071 class HMWJParser;
00072 
00078 class HMWJGraph
00079 {
00080   friend class HMWJParser;
00081   friend struct HMWJGraphInternal::Table;
00082   friend class HMWJGraphInternal::SubDocument;
00083 
00084 public:
00086   HMWJGraph(HMWJParser &parser);
00088   virtual ~HMWJGraph();
00089 
00091   int version() const;
00092 
00094   int numPages() const;
00095 
00096 protected:
00097 
00099   bool getColor(int colId, int patternId, MWAWColor &color) const;
00100 
00102   void prepareStructures();
00104   bool sendPageGraphics(std::vector<long> const &doNotSendIds);
00106   void flushExtra();
00107 
00108   //
00109   // Intermediate level
00110   //
00112   bool readFrames(MWAWEntry const &entry);
00114   shared_ptr<HMWJGraphInternal::Frame> readFrame(int id);
00116   shared_ptr<HMWJGraphInternal::ShapeGraph> readShapeGraph(HMWJGraphInternal::Frame const &header, long endPos);
00118   shared_ptr<HMWJGraphInternal::CommentFrame> readCommentData(HMWJGraphInternal::Frame const &header, long endPos);
00120   shared_ptr<HMWJGraphInternal::PictureFrame> readPictureData(HMWJGraphInternal::Frame const &header, long endPos);
00122   shared_ptr<HMWJGraphInternal::TableFrame> readTableData(HMWJGraphInternal::Frame const &header, long endPos);
00124   shared_ptr<HMWJGraphInternal::TextboxFrame> readTextboxData(HMWJGraphInternal::Frame const &header, long endPos);
00126   shared_ptr<HMWJGraphInternal::TextFrame> readTextData(HMWJGraphInternal::Frame const &header, long endPos);
00128   bool readGroupData(MWAWEntry const &entry, int actZone);
00130   bool readGraphData(MWAWEntry const &entry, int actZone);
00132   bool readPicture(MWAWEntry const &entry, int actZone);
00134   bool readTable(MWAWEntry const &entry, int actZone);
00136   bool readTableFormatsList(HMWJGraphInternal::Table &table, long endPos);
00137 
00138 
00140   bool sendFrame(HMWJGraphInternal::Frame const &frame, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00142   bool sendShapeGraph(HMWJGraphInternal::ShapeGraph const &pict, MWAWPosition pos);
00144   bool sendComment(HMWJGraphInternal::CommentFrame const &textbox, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00146   bool sendPictureFrame(HMWJGraphInternal::PictureFrame const &pict, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00148   bool sendEmptyPicture(MWAWPosition pos);
00150   bool sendTextbox(HMWJGraphInternal::TextboxFrame const &textbox, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00152   bool sendTableUnformatted(long zId);
00153 
00155   bool sendGroup(long zId, MWAWPosition pos);
00157   bool sendGroup(HMWJGraphInternal::Group const &group, MWAWPosition pos);
00159   bool canCreateGraphic(HMWJGraphInternal::Group const &group);
00161   void sendGroupChild(HMWJGraphInternal::Group const &group, MWAWPosition const &pos);
00163   void sendGroup(HMWJGraphInternal::Group const &group, MWAWGraphicListenerPtr &listener);
00164 
00165   // interface with mainParser
00166 
00169   std::map<long,int> getTextFrameInformations() const;
00171   bool getFootnoteInformations(long &textZId, std::vector<long> &fPosList) const;
00173   bool sendFrame(long frameId, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList());
00175   bool sendText(long textId, long fPos, bool asGraphic=false);
00176 
00177   //
00178   // low level
00179   //
00181   bool checkGroupStructures(long zId, std::set<long> &seens, bool inGroup);
00182 
00183 
00184 private:
00185   HMWJGraph(HMWJGraph const &orig);
00186   HMWJGraph &operator=(HMWJGraph const &orig);
00187 
00188 protected:
00189   //
00190   // data
00191   //
00193   MWAWParserStatePtr m_parserState;
00194 
00196   shared_ptr<HMWJGraphInternal::State> m_state;
00197 
00199   HMWJParser *m_mainParser;
00200 };
00201 #endif
00202 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: