HMWKText.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
00036  *
00037  */
00038 #ifndef HMWK_TEXT
00039 #  define HMWK_TEXT
00040 
00041 #include <map>
00042 
00043 #include "libmwaw_internal.hxx"
00044 #include "MWAWDebug.hxx"
00045 
00046 namespace HMWKTextInternal
00047 {
00048 struct Paragraph;
00049 struct Token;
00050 struct State;
00051 }
00052 
00053 struct HMWKZone;
00054 class HMWKParser;
00055 
00061 class HMWKText
00062 {
00063   friend class HMWKParser;
00064 public:
00066   HMWKText(HMWKParser &parser);
00068   virtual ~HMWKText();
00069 
00071   int version() const;
00072 
00074   int numPages() const;
00075 
00076 protected:
00078   bool sendMainText();
00080   bool sendText(long id, long subId, bool asGraphic=false);
00082   bool canSendTextAsGraphic(long id, long subId);
00084   void flushExtra();
00086   void updateTextZoneTypes(std::map<long,int> const &idTypeMap);
00088   std::vector<long> const &getTokenIdList() const;
00090   void getHeaderFooterId(long &headerId, long &footerId) const;
00091 
00092   //
00093   // intermediate level
00094   //
00095 
00097   bool readTextZone(shared_ptr<HMWKZone> zone);
00099   bool readFontNames(shared_ptr<HMWKZone> zone);
00101   bool readStyles(shared_ptr<HMWKZone> zone);
00103   bool readSections(shared_ptr<HMWKZone> zone);
00104 
00106   bool sendText(HMWKZone &zone, bool asGraphic=false);
00108   bool canSendTextAsGraphic(HMWKZone &zone);
00109 
00110   //
00111   // low level
00112   //
00114   bool readFont(HMWKZone &zone, MWAWFont &font);
00115 
00117   bool readParagraph(HMWKZone &zone, HMWKTextInternal::Paragraph &para);
00119   void setProperty(HMWKTextInternal::Paragraph const &para, float width);
00120 
00122   bool readToken(HMWKZone &zone, HMWKTextInternal::Token &token);
00123 
00124 private:
00125   HMWKText(HMWKText const &orig);
00126   HMWKText &operator=(HMWKText const &orig);
00127 
00128 protected:
00129   //
00130   // data
00131   //
00133   MWAWParserStatePtr m_parserState;
00134 
00136   shared_ptr<HMWKTextInternal::State> m_state;
00137 
00139   HMWKParser *m_mainParser;
00140 };
00141 #endif
00142 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: