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 WPS8TextStyleInternal
00034 {
00035 struct State;
00036 }
00037 
00038 class WPS8Text;
00039 
00040 class WPS8TextStyle
00041 {
00042         friend class WPS8Text;
00043 public:
00044         struct FontData;
00045 
00046         WPS8TextStyle(WPS8Text &parser);
00047         ~WPS8TextStyle();
00048 
00050         void setListener(WPSContentListenerPtr &listen)
00051         {
00052                 m_listener = listen;
00053         }
00054 
00056         bool readStructures();
00057 
00058 protected:
00060         bool readFontNames(WPSEntry const &entry);
00062         bool readFont(long endPos, int &id, std::string &mess);
00063 
00064         void sendFont(int fId, FontData &data);
00065 
00067         bool readParagraph(long endPos, int &id, std::string &mess);
00068 
00069         void sendParagraph(int pId);
00070 
00073         bool readSTSH(WPSEntry const &entry);
00074 
00076         bool readSGP(WPSEntry const &entry);
00077 
00078         //----------------------------------------
00079         // FDP parsing
00080         //----------------------------------------
00081 
00084         bool findFDPStructures(int which, std::vector<WPSEntry> &result);
00087         bool findFDPStructuresByHand(int which, std::vector<WPSEntry> &result);
00088 
00089 protected:
00091         libwps::DebugFile &ascii()
00092         {
00093                 return m_asciiFile;
00094         }
00095 
00096 private:
00098         WPS8TextStyle(WPS8TextStyle const &orig);
00100         WPS8TextStyle &operator=(WPS8TextStyle const &orig);
00101 
00102 protected:
00104         WPS8Text &m_mainParser;
00106         RVNGInputStreamPtr m_input;
00108         WPSContentListenerPtr m_listener;
00110         mutable shared_ptr<WPS8TextStyleInternal::State> m_state;
00112         libwps::DebugFile &m_asciiFile;
00113 public:
00114         struct FontData
00115         {
00116                 FontData() : m_type(T_None), m_fieldType(F_None), m_fieldFormat(0) {}
00118                 friend std::ostream &operator<<(std::ostream &o, FontData const &fData);
00120                 std::string format() const;
00121 
00122                 enum { T_None=0, T_Object=2, T_Footnote=3, T_Endnote=4, T_Field=5, T_Comment=6 };
00124                 int m_type;
00125                 enum { F_None=0, F_PageNumber=-1, F_Date=-4, F_Time=-5 };
00127                 int m_fieldType;
00129                 int m_fieldFormat;
00130         };
00131 protected:
00132 };
00133 
00134 
00135 #endif /* WPS8_TEXT_H */
00136 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */