MSWTextStyles.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  * Class to read/store the text font and paragraph styles
00036  */
00037 
00038 #ifndef MSW_TEXT_STYLES
00039 #  define MSW_TEXT_STYLES
00040 
00041 #include <iostream>
00042 #include <map>
00043 #include <string>
00044 
00045 #include "libmwaw_internal.hxx"
00046 
00047 #include "MWAWEntry.hxx"
00048 #include "MWAWParagraph.hxx"
00049 
00050 class MSWParser;
00051 class MSWText;
00052 
00053 namespace MSWStruct
00054 {
00055 struct Font;
00056 struct Paragraph;
00057 struct Section;
00058 }
00059 
00060 namespace MSWTextStylesInternal
00061 {
00062 struct State;
00063 }
00064 
00066 class MSWTextStyles
00067 {
00068   friend class MSWText;
00069 public:
00070   enum ZoneType { TextZone, TextStructZone, StyleZone, InParagraphDefinition };
00072   MSWTextStyles(MSWText &textParser);
00074   virtual ~MSWTextStyles();
00075 
00077   int version() const;
00078 
00079 protected:
00080   // font:
00082   MWAWFont const &getDefaultFont() const;
00084   bool getFont(ZoneType type, int id, MSWStruct::Font &actFont);
00085 
00086   /* send a font */
00087   void setProperty(MSWStruct::Font const &font);
00091   bool readFont(MSWStruct::Font &font, ZoneType type);
00092 
00093   // pararagraph:
00095   bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
00097   bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1);
00099   void sendDefaultParagraph();
00100 
00102   bool readPLCList(MSWEntry &entry);
00104   bool readTextStructList(MSWEntry &entry);
00107   int readPropertyModifier(bool &complex, std::string &extra);
00109   bool readPLC(MSWEntry &entry, int type, Vec2<long> const &fileLimit);
00110 
00111   // section:
00113   bool getSection(ZoneType type, int id, MSWStruct::Section &section);
00115   bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
00117   bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font);
00119   bool readSection(MSWEntry &entry, std::vector<long> &cLimits);
00121   bool sendSection(int id, int textStructId);
00122 
00124   bool readSection(MSWStruct::Section &section, long pos);
00126   void setProperty(MSWStruct::Section const &sec);
00127 
00128   // style
00130   bool readStyles(MSWEntry &entry);
00132   bool readStylesHierarchy(MSWEntry &entry, int N, std::vector<int> &orig);
00134   bool readStylesNames(MSWEntry const &zone, int N, int &Nnamed);
00136   bool readStylesFont(MSWEntry &zone, int N, std::vector<int> const &previous,
00137                       std::vector<int> const &order);
00139   bool readStylesParagraph(MSWEntry &zone, int N, std::vector<int> const &previous,
00140                            std::vector<int> const &order);
00142   std::map<int,int> const &getNextStyleMap() const;
00144   static std::vector<int> orderStyles(std::vector<int> const &previous);
00145 
00146 private:
00147   MSWTextStyles(MSWTextStyles const &orig);
00148   MSWTextStyles &operator=(MSWTextStyles const &orig);
00149 
00150 protected:
00151   //
00152   // data
00153   //
00155   MWAWParserStatePtr m_parserState;
00156 
00158   shared_ptr<MSWTextStylesInternal::State> m_state;
00159 
00161   MSWParser *m_mainParser;
00162 
00164   MSWText *m_textParser;
00165 };
00166 #endif
00167 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: