MSWTextStyles.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 /*
35  * Class to read/store the text font and paragraph styles
36  */
37 
38 #ifndef MSW_TEXT_STYLES
39 # define MSW_TEXT_STYLES
40 
41 #include <iostream>
42 #include <map>
43 #include <string>
44 
45 #include "libmwaw_internal.hxx"
46 
47 #include "MWAWEntry.hxx"
48 #include "MWAWParagraph.hxx"
49 
50 class MSWParser;
51 class MSWText;
52 
53 namespace MSWStruct
54 {
55 struct Font;
56 struct Paragraph;
57 struct Section;
58 }
59 
60 namespace MSWTextStylesInternal
61 {
62 struct State;
63 }
64 
67 {
68  friend class MSWText;
69 public:
72  MSWTextStyles(MSWText &textParser);
74  virtual ~MSWTextStyles();
75 
77  int version() const;
78 
79 protected:
80  // font:
82  MWAWFont const &getDefaultFont() const;
84  bool getFont(ZoneType type, int id, MSWStruct::Font &actFont);
85 
86  /* send a font */
87  void setProperty(MSWStruct::Font const &font);
91  bool readFont(MSWStruct::Font &font, ZoneType type);
92 
93  // pararagraph:
95  bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
97  bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1);
99  void sendDefaultParagraph();
100 
102  void setProperty(MSWStruct::Paragraph const &para, bool recursifCall=false);
103 
105  bool readPLCList(MSWEntry &entry);
107  bool readTextStructList(MSWEntry &entry);
110  int readPropertyModifier(bool &complex, std::string &extra);
112  bool readPLC(MSWEntry &entry, int type, Vec2<long> const &fileLimit);
113 
114  // section:
116  bool getSection(ZoneType type, int id, MSWStruct::Section &section);
118  bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
120  bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font);
122  bool readSection(MSWEntry &entry, std::vector<long> &cLimits);
124  bool sendSection(int id, int textStructId);
125 
127  bool readSection(MSWStruct::Section &section, long pos);
129  void setProperty(MSWStruct::Section const &sec);
130 
131  // style
133  bool readStyles(MSWEntry &entry);
135  bool readStylesHierarchy(MSWEntry &entry, int N, std::vector<int> &orig);
137  bool readStylesNames(MSWEntry const &zone, int N, int &Nnamed);
139  bool readStylesFont(MSWEntry &zone, int N, std::vector<int> const &previous,
140  std::vector<int> const &order);
142  bool readStylesParagraph(MSWEntry &zone, int N, std::vector<int> const &previous,
143  std::vector<int> const &order);
145  std::map<int,int> const &getNextStyleMap() const;
147  static std::vector<int> orderStyles(std::vector<int> const &previous);
148 
149 private:
150  MSWTextStyles(MSWTextStyles const &orig);
151  MSWTextStyles &operator=(MSWTextStyles const &orig);
152 
153 protected:
154  //
155  // data
156  //
159 
161  shared_ptr<MSWTextStylesInternal::State> m_state;
162 
165 
168 };
169 #endif
170 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the section structure of a Microsoft Word file
Definition: MSWStruct.hxx:109
ZoneType
Definition: MSWTextStyles.hxx:70
MSWTextStyles & operator=(MSWTextStyles const &orig)
bool readStylesNames(MSWEntry const &zone, int N, int &Nnamed)
try to read the styles names and fill the number of &quot;named&quot; styles...
Definition: MSWTextStyles.cxx:1181
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:66
Definition: MSWTextStyles.hxx:70
bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1)
try to read a paragraph
Definition: MSWTextStyles.cxx:372
the paragraph structure of a Microsoft Word file
Definition: MSWStruct.hxx:286
bool readTextStructList(MSWEntry &entry)
read the paragraphs at the beginning of the text structure zone
Definition: MSWTextStyles.cxx:818
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
int readPropertyModifier(bool &complex, std::string &extra)
read the property modifier (2 bytes last bytes of text struct ).
Definition: MSWTextStyles.cxx:876
the entry of MSWParser
Definition: MSWParser.hxx:63
int version() const
returns the file version
Definition: MSWTextStyles.cxx:97
virtual ~MSWTextStyles()
destructor
Definition: MSWTextStyles.cxx:94
bool readPLC(MSWEntry &entry, int type, Vec2< long > const &fileLimit)
read the char/paragraph plc : type=0: char, type=1: parag
Definition: MSWTextStyles.cxx:672
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:64
MWAWFont const & getDefaultFont() const
returns the default font
Definition: MSWTextStyles.cxx:104
Definition: MSWTextStyles.hxx:70
bool readStylesParagraph(MSWEntry &zone, int N, std::vector< int > const &previous, std::vector< int > const &order)
try to read the styles fonts
Definition: MSWTextStyles.cxx:1289
MSWParser * m_mainParser
the main parser;
Definition: MSWTextStyles.hxx:164
shared_ptr< MSWTextStylesInternal::State > m_state
the state
Definition: MSWTextStyles.hxx:161
bool sendSection(int id, int textStructId)
try to send a section
Definition: MSWTextStyles.cxx:1075
static std::vector< int > orderStyles(std::vector< int > const &previous)
try to reorder the styles to find a good order
Definition: MSWTextStyles.cxx:1439
MSWText * m_textParser
the text parser;
Definition: MSWTextStyles.hxx:167
bool getSection(ZoneType type, int id, MSWStruct::Section &section)
return a section corresponding to an index
Definition: MSWTextStyles.cxx:914
void sendDefaultParagraph()
send a default paragraph
Definition: MSWTextStyles.cxx:365
bool readStylesFont(MSWEntry &zone, int N, std::vector< int > const &previous, std::vector< int > const &order)
try to read the styles fonts
Definition: MSWTextStyles.cxx:1227
bool readStyles(MSWEntry &entry)
try to read the styles zone
Definition: MSWTextStyles.cxx:1102
MSWTextStyles(MSWText &textParser)
constructor
Definition: MSWTextStyles.cxx:88
bool readFont(MSWStruct::Font &font, ZoneType type)
try to read a font.
Definition: MSWTextStyles.cxx:112
bool readStylesHierarchy(MSWEntry &entry, int N, std::vector< int > &orig)
try to read the styles hierachy
Definition: MSWTextStyles.cxx:1376
Definition: MSWTextStyles.hxx:70
void setProperty(MSWStruct::Font const &font)
Definition: MSWTextStyles.cxx:324
Definition: MSWTextStyles.hxx:70
bool readPLCList(MSWEntry &entry)
read the main char/paragraph plc list
Definition: MSWTextStyles.cxx:622
the font structure of a Microsoft Word file
Definition: MSWStruct.hxx:57
bool getFont(ZoneType type, int id, MSWStruct::Font &actFont)
return a font corresponding to an index
Definition: MSWTextStyles.cxx:290
bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font)
return a font corresponding to the section
Definition: MSWTextStyles.cxx:942
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:342
std::map< int, int > const & getNextStyleMap() const
returns the style id to next style id map
Definition: MSWTextStyles.cxx:1097
MWAWParserStatePtr m_parserState
the parser state
Definition: MSWTextStyles.hxx:158
bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para)
return a paragraph corresponding to the section
Definition: MSWTextStyles.cxx:934
bool readSection(MSWEntry &entry, std::vector< long > &cLimits)
read the text section
Definition: MSWTextStyles.cxx:960
bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para)
return a paragraph corresponding to an index
Definition: MSWTextStyles.cxx:337

Generated on Fri May 2 2014 17:42:21 for libmwaw by doxygen 1.8.5