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 <string>
43 
44 #include "libmwaw_internal.hxx"
45 
46 #include "MWAWEntry.hxx"
47 #include "MWAWParagraph.hxx"
48 
49 class MWAWFont;
51 typedef shared_ptr<MWAWParserState> MWAWParserStatePtr;
52 
53 class MSWParser;
54 class MSWText;
55 
56 namespace MSWStruct
57 {
58 struct Font;
59 struct Paragraph;
60 struct Section;
61 }
62 
63 namespace MSWTextStylesInternal
64 {
65 struct State;
66 }
67 
70 {
71  friend class MSWText;
72 public:
75  MSWTextStyles(MSWText &textParser);
77  virtual ~MSWTextStyles();
78 
80  int version() const;
81 
82 protected:
83  // font:
85  MWAWFont const &getDefaultFont() const;
87  bool getFont(ZoneType type, int id, MSWStruct::Font &actFont);
88  /* try to send a font. If so, update the font */
89  bool sendFont(ZoneType type, int id, MSWStruct::Font &actFont);
90 
91  /* send a font */
92  void setProperty(MSWStruct::Font const &font);
96  bool readFont(MSWStruct::Font &font, ZoneType type);
97 
98  // pararagraph:
100  bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
102  bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1);
104  void sendDefaultParagraph();
105 
107  void setProperty(MSWStruct::Paragraph const &para, bool recursifCall=false);
108 
110  bool readPLCList(MSWEntry &entry);
112  bool readTextStructList(MSWEntry &entry);
115  int readPropertyModifier(bool &complex, std::string &extra);
117  bool readPLC(MSWEntry &entry, int type, Vec2<long> const &fileLimit);
118 
119  // section:
121  bool getSection(ZoneType type, int id, MSWStruct::Section &section);
123  bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
125  bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font);
127  bool readSection(MSWEntry &entry);
129  bool sendSection(int id);
130 
132  bool readSection(MSWStruct::Section &section, long pos);
134  void setProperty(MSWStruct::Section const &sec);
135 
137  bool readStyles(MSWEntry &entry);
139  bool readStylesHierarchy(MSWEntry &entry, int N, std::vector<int> &previous);
141  bool readStylesNames(MSWEntry const &zone, int N, int &Nnamed);
143  bool readStylesFont(MSWEntry &zone, int N, std::vector<int> const &previous,
144  std::vector<int> const &order);
146  bool readStylesParagraph(MSWEntry &zone, int N, std::vector<int> const &previous,
147  std::vector<int> const &order);
149  static std::vector<int> orderStyles(std::vector<int> const &previous);
150 
151 private:
152  MSWTextStyles(MSWTextStyles const &orig);
153  MSWTextStyles &operator=(MSWTextStyles const &orig);
154 
155 protected:
156  //
157  // data
158  //
161 
163  shared_ptr<MSWTextStylesInternal::State> m_state;
164 
167 
170 };
171 #endif
172 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
the section structure of a Microsoft Word file
Definition: MSWStruct.hxx:115
bool sendSection(int id)
try to send a section
Definition: MSWTextStyles.cxx:1078
ZoneType
Definition: MSWTextStyles.hxx:73
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:1171
shared_ptr< MWAWParserState > MWAWParserStatePtr
Definition: ACText.hxx:49
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:69
Definition: MSWTextStyles.hxx:73
bool readStylesHierarchy(MSWEntry &entry, int N, std::vector< int > &previous)
try to read the styles hierachy
Definition: MSWTextStyles.cxx:1371
bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1)
try to read a paragraph
Definition: MSWTextStyles.cxx:355
the paragraph structure of a Microsoft Word file
Definition: MSWStruct.hxx:289
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:94
virtual ~MSWTextStyles()
destructor
Definition: MSWTextStyles.cxx:91
bool readPLC(MSWEntry &entry, int type, Vec2< long > const &fileLimit)
read the char/paragraph plc : type=0: char, type=1: parag
Definition: MSWTextStyles.cxx:674
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:67
MWAWFont const & getDefaultFont() const
returns the default font
Definition: MSWTextStyles.cxx:101
Definition: MSWTextStyles.hxx:73
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:1278
MSWParser * m_mainParser
the main parser;
Definition: MSWTextStyles.hxx:166
shared_ptr< MSWTextStylesInternal::State > m_state
the state
Definition: MSWTextStyles.hxx:163
static std::vector< int > orderStyles(std::vector< int > const &previous)
try to reorder the styles to find a good order
Definition: MSWTextStyles.cxx:1429
MSWText * m_textParser
the text parser;
Definition: MSWTextStyles.hxx:169
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:348
Class to store font.
Definition: MWAWFont.hxx:47
a class to define the parser state
Definition: MWAWParser.hxx:60
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:1217
bool readStyles(MSWEntry &entry)
try to read the styles zone
Definition: MSWTextStyles.cxx:1093
MSWTextStyles(MSWText &textParser)
constructor
Definition: MSWTextStyles.cxx:85
bool readSection(MSWEntry &entry)
read the text section
Definition: MSWTextStyles.cxx:962
bool readFont(MSWStruct::Font &font, ZoneType type)
try to read a font.
Definition: MSWTextStyles.cxx:109
Definition: MSWTextStyles.hxx:73
void setProperty(MSWStruct::Font const &font)
Definition: MSWTextStyles.cxx:307
Definition: MSWTextStyles.hxx:73
bool readPLCList(MSWEntry &entry)
read the main char/paragraph plc list
Definition: MSWTextStyles.cxx:624
the font structure of a Microsoft Word file
Definition: MSWStruct.hxx:63
bool getFont(ZoneType type, int id, MSWStruct::Font &actFont)
return a font corresponding to an index
Definition: MSWTextStyles.cxx:266
bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font)
return a font corresponding to the section
Definition: MSWTextStyles.cxx:942
MWAWParserStatePtr m_parserState
the parser state
Definition: MSWTextStyles.hxx:160
bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para)
return a paragraph corresponding to the section
Definition: MSWTextStyles.cxx:934
bool sendFont(ZoneType type, int id, MSWStruct::Font &actFont)
Definition: MSWTextStyles.cxx:300
bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para)
return a paragraph corresponding to an index
Definition: MSWTextStyles.cxx:320

Generated for libmwaw by doxygen 1.8.5