ClarisDrawGraph.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 ClarisDrawGraphInternal
00055 {
00056 struct Group;
00057 struct State;
00058 struct Style;
00059 struct Zone;
00060 struct ZoneShape;
00061 struct Bitmap;
00062 
00063 class SubDocument;
00064 }
00065 
00066 class ClarisDrawParser;
00067 
00073 class ClarisDrawGraph
00074 {
00075   friend class ClarisDrawGraphInternal::SubDocument;
00076   friend class ClarisDrawParser;
00077   friend class ClarisWksParser;
00078 
00079 public:
00081   ClarisDrawGraph(ClarisDrawParser &parser);
00083   virtual ~ClarisDrawGraph();
00084 
00086   int version() const;
00088   void resetState();
00090   int numPages() const;
00091 
00093   shared_ptr<ClarisWksStruct::DSET> readGroupZone
00094   (ClarisWksStruct::DSET const &zone, MWAWEntry const &entry, bool isLibHeader=false);
00096   shared_ptr<ClarisWksStruct::DSET> readBitmapZone(ClarisWksStruct::DSET const &zone, MWAWEntry const &entry);
00098   bool readTransformations();
00100   void updateGroup(bool isLibrary);
00102   bool isEmptyGroup(int gId) const;
00103 
00105   bool getSurfaceColor(ClarisDrawGraphInternal::Style const &style, MWAWColor &col) const;
00106 protected:
00108   bool sendBitmap(int number, MWAWPosition const &pos=MWAWPosition());
00110   bool sendGroup(int number, MWAWPosition const &pos=MWAWPosition());
00112   bool sendMainGroupChild(int childId, MWAWPosition const &pos=MWAWPosition());
00114   void flushExtra();
00115 
00116   // interface with main parser
00117 
00119   bool sendTextZone(int number, int subZone=-1);
00120 
00121   //
00122   // Intermediate level
00123   //
00124 
00125   /* read a simple group */
00126   shared_ptr<ClarisDrawGraphInternal::Zone> readGroupDef(MWAWEntry const &entry);
00127   /* read the group data.
00128 
00129      \note \a beginGroupPos is only used to help debugging */
00130   bool readGroupData(ClarisDrawGraphInternal::Group &group, long beginGroupPos, bool isLibHeader);
00131 
00132   /* read a simple graphic zone */
00133   bool readShape(MWAWEntry const &entry,
00134                  ClarisDrawGraphInternal::ZoneShape &zone);
00135 
00136   /* try to read the polygon data */
00137   bool readPolygonData(shared_ptr<ClarisDrawGraphInternal::Zone> zone);
00138 
00140   /* try to read a bitmap zone */
00141   bool readBitmapColorMap(std::vector<MWAWColor> &cMap);
00142 
00143   /* try to read the bitmap  */
00144   bool readBitmapData(ClarisDrawGraphInternal::Bitmap &zone);
00145 
00146   //
00147   // low level
00148   //
00149 
00150   /* read the first zone of a group type */
00151   bool readGroupHeader(ClarisDrawGraphInternal::Group &group);
00152 
00153   /* read some unknown data in first zone */
00154   bool readGroupUnknown(ClarisDrawGraphInternal::Group &group, int zoneSz, int id);
00155 
00157   bool sendShape(ClarisDrawGraphInternal::ZoneShape &pict, MWAWPosition pos);
00158 
00160   bool sendBitmap(ClarisDrawGraphInternal::Bitmap &pict, MWAWPosition pos);
00161 
00162 private:
00163   ClarisDrawGraph(ClarisDrawGraph const &orig);
00164   ClarisDrawGraph &operator=(ClarisDrawGraph const &orig);
00165 
00166 protected:
00167   //
00168   // data
00169   //
00171   MWAWParserStatePtr m_parserState;
00172 
00174   shared_ptr<ClarisDrawGraphInternal::State> m_state;
00175 
00177   ClarisDrawParser *m_mainParser;
00179   shared_ptr<ClarisDrawStyleManager> m_styleManager;
00180 };
00181 #endif
00182 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: