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