BeagleWksStructManager.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 BeagleWorks document
00036  *
00037  */
00038 #ifndef BEAGLE_WKS_STRUCT_MANAGER
00039 #  define BEAGLE_WKS_STRUCT_MANAGER
00040 
00041 #include <map>
00042 
00043 #include "libmwaw_internal.hxx"
00044 
00045 #include "MWAWCell.hxx"
00046 
00047 namespace BeagleWksStructManagerInternal
00048 {
00049 struct State;
00050 }
00056 class BeagleWksStructManager
00057 {
00058 public:
00059   struct Frame;
00060 
00062   BeagleWksStructManager(MWAWParserStatePtr parserState);
00064   ~BeagleWksStructManager();
00065 
00067   bool getFrame(int fId, Frame &frame) const;
00069   std::map<int,Frame> const &getIdFrameMap() const;
00070 
00072   int getFontId(int fFontId) const;
00074   void getHeaderFooterEntries(MWAWEntry &header, MWAWEntry &footer) const;
00076   bool readFontNames(MWAWEntry const &entry);
00078   bool readFrame(MWAWEntry const &entry);
00080   bool readDocumentInfo();
00082   bool readDocumentPreferences();
00083 
00084   // resource fork
00085 
00087   bool readPicture(int pId, librevenge::RVNGBinaryData &pict);
00089   bool readwPos(MWAWEntry const &entry);
00091   bool readFontStyle(MWAWEntry const &entry);
00092 
00093   //
00094   // formula data
00095   //
00096   /* reads a cell */
00097   bool readCellInFormula(MWAWVec2i actPos, MWAWCellContent::FormulaInstruction &instr);
00098   /* reads a formula */
00099   bool readFormula(long endPos, MWAWVec2i const &pos,   std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error);
00100 
00102   struct Frame {
00104     Frame() : m_charAnchor(true), m_id(0), m_pictId(0), m_origin(), m_dim(), m_page(1),
00105       m_wrap(0), m_border(), m_bordersSet(0), m_extra("")
00106     {
00107     }
00109     friend std::ostream &operator<<(std::ostream &o, Frame const &frm)
00110     {
00111       if (frm.m_id) o << "id=" << frm.m_id << ",";
00112       if (!frm.m_charAnchor) o << "pageFrame,";
00113       if (frm.m_page!=1) o << "page=" << frm.m_page << ",";
00114       if (frm.m_origin[0]>0||frm.m_origin[1]>0)
00115         o << "origin=" << frm.m_origin << ",";
00116       o << "dim=" << frm.m_dim << ",";
00117       if (frm.m_pictId) o << "picId=" << std::hex << frm.m_pictId << std::dec << ",";
00118       o << frm.m_extra;
00119       return o;
00120     }
00122     bool m_charAnchor;
00124     int m_id;
00126     int m_pictId;
00128     MWAWVec2f m_origin;
00130     MWAWVec2f m_dim;
00132     int m_page;
00134     int m_wrap;
00136     MWAWBorder m_border;
00138     int m_bordersSet;
00140     std::string m_extra;
00141   };
00142 protected:
00144   MWAWInputStreamPtr getInput();
00146   libmwaw::DebugFile &ascii();
00148   MWAWInputStreamPtr rsrcInput();
00150   libmwaw::DebugFile &rsrcAscii();
00151 
00152 private:
00153   BeagleWksStructManager(BeagleWksStructManager const &orig);
00154   BeagleWksStructManager &operator=(BeagleWksStructManager const &orig);
00155 
00156 protected:
00157   //
00158   // data
00159   //
00161   MWAWParserStatePtr m_parserState;
00162 
00164   shared_ptr<BeagleWksStructManagerInternal::State> m_state;
00165 };
00166 
00167 #endif
00168 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: