WPS8TextStyle.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2006, 2007 Andrew Ziem
00011  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00012  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00013  *
00014  * For minor contributions see the git repository.
00015  *
00016  * Alternatively, the contents of this file may be used under the terms
00017  * of the GNU Lesser General Public License Version 2.1 or later
00018  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00019  * applicable instead of those above.
00020  */
00021 
00022 #ifndef WPS8_TEXTSTYLE_H
00023 #define WPS8_TEXTSTYLE_H
00024 
00025 #include <ostream>
00026 #include <string>
00027 #include <vector>
00028 
00029 #include "libwps_internal.h"
00030 
00031 #include "WPSDebug.h"
00032 
00033 namespace WPS8Struct
00034 {
00035 struct FileData;
00036 }
00037 
00038 namespace WPS8TextStyleInternal
00039 {
00040 struct State;
00041 }
00042 
00043 class WPS8Text;
00044 
00045 class WPS8TextStyle
00046 {
00047         friend class WPS8Text;
00048 public:
00049         struct FontData;
00050 
00051         WPS8TextStyle(WPS8Text &parser);
00052         ~WPS8TextStyle();
00053 
00055         void setListener(WPSContentListenerPtr &listen)
00056         {
00057                 m_listener = listen;
00058         }
00059 
00061         bool readStructures();
00062 
00063 protected:
00065         bool readFontNames(WPSEntry const &entry);
00067         bool readFont(long endPos, int &id, std::string &mess);
00068 
00069         void sendFont(int fId, FontData &data);
00070 
00072         bool readParagraph(long endPos, int &id, std::string &mess);
00073 
00074         void sendParagraph(int pId);
00075 
00078         bool readSTSH(WPSEntry const &entry);
00079 
00081         bool readSGP(WPSEntry const &entry);
00082 
00083         //----------------------------------------
00084         // FDP parsing
00085         //----------------------------------------
00086 
00089         bool findFDPStructures(int which, std::vector<WPSEntry> &result);
00092         bool findFDPStructuresByHand(int which, std::vector<WPSEntry> &result);
00093 
00094 protected:
00096         libwps::DebugFile &ascii()
00097         {
00098                 return m_asciiFile;
00099         }
00100 
00101 private:
00103         WPS8TextStyle(WPS8TextStyle const &orig);
00105         WPS8TextStyle &operator=(WPS8TextStyle const &orig);
00106 
00107 protected:
00109         WPS8Text &m_mainParser;
00111         RVNGInputStreamPtr m_input;
00113         WPSContentListenerPtr m_listener;
00115         mutable shared_ptr<WPS8TextStyleInternal::State> m_state;
00117         libwps::DebugFile &m_asciiFile;
00118 public:
00119         struct FontData
00120         {
00121                 FontData() : m_type(T_None), m_fieldType(F_None), m_fieldFormat(0) {}
00123                 friend std::ostream &operator<<(std::ostream &o, FontData const &fData);
00125                 std::string format() const;
00126 
00127                 enum { T_None=0, T_Object=2, T_Footnote=3, T_Endnote=4, T_Field=5, T_Comment=6 };
00129                 int m_type;
00130                 enum { F_None=0, F_PageNumber=-1, F_Date=-4, F_Time=-5 };
00132                 int m_fieldType;
00134                 int m_fieldFormat;
00135         };
00136 protected:
00137 };
00138 
00139 
00140 #endif /* WPS8_TEXT_H */
00141 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */