MsWrdTextStyles.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MsWrdTextStyles.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 MS_WRD_TEXT_STYLES
39 # define MS_WRD_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 MsWrdParser;
51 class MsWrdText;
52
53 namespace MsWrdStruct
54 {
55 struct Font;
56 struct Paragraph;
57 struct Section;
58 }
59
60 namespace MsWrdTextStylesInternal
61 {
62 struct State;
63 }
64
66 class MsWrdTextStyles
67 {
68 friend class MsWrdText;
69 public:
70 enum ZoneType { TextZone, TextStructZone, StyleZone, InParagraphDefinition };
72 MsWrdTextStyles(MsWrdText &textParser);
74 virtual ~MsWrdTextStyles();
75
77 int version() const;
78
79 protected:
80 // font:
82 MWAWFont const &getDefaultFont() const;
84 bool getFont(ZoneType type, int id, MsWrdStruct::Font &actFont);
85
86 /* send a font */
87 void setProperty(MsWrdStruct::Font const &font);
91 bool readFont(MsWrdStruct::Font &font, ZoneType type);
92
93 // pararagraph:
95 bool getParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para);
97 bool readParagraph(MsWrdStruct::Paragraph &para, int dataSz=-1);
99 void sendDefaultParagraph();
100
102 bool readPLCList(MsWrdEntry &entry);
104 bool readTextStructList(MsWrdEntry &entry);
107 int readPropertyModifier(bool &complex, std::string &extra);
109 bool readPLC(MsWrdEntry &entry, int type, Vec2<long> const &fileLimit);
110
111 // section:
113 bool getSection(ZoneType type, int id, MsWrdStruct::Section &section);
115 bool getSectionParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para);
117 bool getSectionFont(ZoneType type, int id, MsWrdStruct::Font &font);
119 bool readSection(MsWrdEntry &entry, std::vector<long> &cLimits);
121 bool sendSection(int id, int textStructId);
122
124 bool readSection(MsWrdStruct::Section &section, long pos);
126 void setProperty(MsWrdStruct::Section const &sec);
127
128 // style
130 bool readStyles(MsWrdEntry &entry);
132 bool readStylesHierarchy(MsWrdEntry &entry, int N, std::vector<int> &orig);
134 bool readStylesNames(MsWrdEntry const &zone, int N, int &Nnamed);
136 bool readStylesFont(MsWrdEntry &zone, int N, std::vector<int> const &previous,
137 std::vector<int> const &order);
139 bool readStylesParagraph(MsWrdEntry &zone, int N, std::vector<int> const &previous,
140 std::vector<int> const &order);
142 std::map<int,int> const &getNextStyleMap() const;
144 static std::vector<int> orderStyles(std::vector<int> const &previous);
145
146 private:
147 MsWrdTextStyles(MsWrdTextStyles const &orig);
148 MsWrdTextStyles &operator=(MsWrdTextStyles const &orig);
149
150 protected:
151 //
152 // data
153 //
155 MWAWParserStatePtr m_parserState;
156
158 shared_ptr<MsWrdTextStylesInternal::State> m_state;
159
161 MsWrdParser *m_mainParser;
162
164 MsWrdText *m_textParser;
165 };
166 #endif
167 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MsWrdTextStyles::m_textParser
MsWrdText * m_textParser
the text parser;
Definition: MsWrdTextStyles.hxx:164
MsWrdTextStyles::InParagraphDefinition
Definition: MsWrdTextStyles.hxx:70
MsWrdTextStyles::readParagraph
bool readParagraph(MsWrdStruct::Paragraph &para, int dataSz=-1)
try to read a paragraph
Definition: MsWrdTextStyles.cxx:377
MsWrdTextStyles::getSection
bool getSection(ZoneType type, int id, MsWrdStruct::Section &section)
return a section corresponding to an index
Definition: MsWrdTextStyles.cxx:891
MsWrdTextStyles::readSection
bool readSection(MsWrdEntry &entry, std::vector< long > &cLimits)
read the text section
Definition: MsWrdTextStyles.cxx:937
MsWrdStruct::Font
the font structure of a Microsoft Word file
Definition: MsWrdStruct.hxx:57
MsWrdTextStyles::getFont
bool getFont(ZoneType type, int id, MsWrdStruct::Font &actFont)
return a font corresponding to an index
Definition: MsWrdTextStyles.cxx:296
MsWrdTextStyles::setProperty
void setProperty(MsWrdStruct::Font const &font)
Definition: MsWrdTextStyles.cxx:330
MWAWEntry.hxx
libmwaw_internal.hxx
MsWrdEntry
the entry of MsWrdParser
Definition: MsWrdParser.hxx:63
MsWrdTextStyles::readStyles
bool readStyles(MsWrdEntry &entry)
try to read the styles zone
Definition: MsWrdTextStyles.cxx:1083
MsWrdStruct
namespace to store the main structure which appears in a Microsoft Word 3.0-5.0 file ...
Definition: MsWrdStruct.cxx:41
MsWrdTextStylesInternal
Internal: the structures of a MsWrdTextStyles.
Definition: MsWrdTextStyles.cxx:45
MsWrdStruct::Paragraph
the paragraph structure of a Microsoft Word file
Definition: MsWrdStruct.hxx:282
MsWrdTextStyles::readStylesHierarchy
bool readStylesHierarchy(MsWrdEntry &entry, int N, std::vector< int > &orig)
try to read the styles hierachy
Definition: MsWrdTextStyles.cxx:1358
MsWrdTextStyles::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MsWrdTextStyles.hxx:155
MsWrdTextStyles::MsWrdTextStyles
MsWrdTextStyles(MsWrdText &textParser)
constructor
Definition: MsWrdTextStyles.cxx:89
MsWrdTextStyles::getDefaultFont
MWAWFont const & getDefaultFont() const
returns the default font
Definition: MsWrdTextStyles.cxx:105
MsWrdTextStyles::getParagraph
bool getParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para)
return a paragraph corresponding to an index
Definition: MsWrdTextStyles.cxx:343
MsWrdTextStyles::StyleZone
Definition: MsWrdTextStyles.hxx:70
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MsWrdTextStyles::readStylesParagraph
bool readStylesParagraph(MsWrdEntry &zone, int N, std::vector< int > const &previous, std::vector< int > const &order)
try to read the styles fonts
Definition: MsWrdTextStyles.cxx:1270
MsWrdTextStyles::getSectionParagraph
bool getSectionParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para)
return a paragraph corresponding to the section
Definition: MsWrdTextStyles.cxx:911
MsWrdTextStyles::sendDefaultParagraph
void sendDefaultParagraph()
send a default paragraph
Definition: MsWrdTextStyles.cxx:371
MsWrdTextStyles::readPLCList
bool readPLCList(MsWrdEntry &entry)
read the main char/paragraph plc list
Definition: MsWrdTextStyles.cxx:589
MsWrdTextStyles::readFont
bool readFont(MsWrdStruct::Font &font, ZoneType type)
try to read a font.
Definition: MsWrdTextStyles.cxx:113
MsWrdTextStyles::getSectionFont
bool getSectionFont(ZoneType type, int id, MsWrdStruct::Font &font)
return a font corresponding to the section
Definition: MsWrdTextStyles.cxx:919
MsWrdTextStyles::sendSection
bool sendSection(int id, int textStructId)
try to send a section
Definition: MsWrdTextStyles.cxx:1056
MsWrdParser
the main class to read a Microsoft Word file
Definition: MsWrdParser.hxx:91
MsWrdTextStyles::readStylesFont
bool readStylesFont(MsWrdEntry &zone, int N, std::vector< int > const &previous, std::vector< int > const &order)
try to read the styles fonts
Definition: MsWrdTextStyles.cxx:1208
MsWrdTextStyles::getNextStyleMap
std::map< int, int > const & getNextStyleMap() const
returns the style id to next style id map
Definition: MsWrdTextStyles.cxx:1078
MsWrdTextStyles::TextStructZone
Definition: MsWrdTextStyles.hxx:70
MsWrdTextStyles::readTextStructList
bool readTextStructList(MsWrdEntry &entry)
read the paragraphs at the beginning of the text structure zone
Definition: MsWrdTextStyles.cxx:793
MsWrdStruct::Section
the section structure of a Microsoft Word file
Definition: MsWrdStruct.hxx:111
MsWrdTextStyles::readStylesNames
bool readStylesNames(MsWrdEntry const &zone, int N, int &Nnamed)
try to read the styles names and fill the number of "named" styles...
Definition: MsWrdTextStyles.cxx:1162
MsWrdText
the main class to read the text part of Microsoft Word file
Definition: MsWrdText.hxx:64
MsWrdTextStyles::readPropertyModifier
int readPropertyModifier(bool &complex, std::string &extra)
read the property modifier (2 bytes last bytes of text struct ).
Definition: MsWrdTextStyles.cxx:852
MsWrdTextStyles::TextZone
Definition: MsWrdTextStyles.hxx:70
MsWrdTextStyles::ZoneType
ZoneType
Definition: MsWrdTextStyles.hxx:70
MsWrdTextStyles::~MsWrdTextStyles
virtual ~MsWrdTextStyles()
destructor
Definition: MsWrdTextStyles.cxx:95
MsWrdTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition: MsWrdTextStyles.hxx:66
MsWrdTextStyles::operator=
MsWrdTextStyles & operator=(MsWrdTextStyles const &orig)
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:435
MsWrdTextStyles::readPLC
bool readPLC(MsWrdEntry &entry, int type, Vec2< long > const &fileLimit)
read the char/paragraph plc : type=0: char, type=1: parag
Definition: MsWrdTextStyles.cxx:640
MsWrdTextStyles::m_mainParser
MsWrdParser * m_mainParser
the main parser;
Definition: MsWrdTextStyles.hxx:161
MsWrdTextStyles::orderStyles
static std::vector< int > orderStyles(std::vector< int > const &previous)
try to reorder the styles to find a good order
Definition: MsWrdTextStyles.cxx:1424
MsWrdTextStyles::version
int version() const
returns the file version
Definition: MsWrdTextStyles.cxx:98
Vec2< long >
MWAWParagraph.hxx
MsWrdTextStyles::m_state
shared_ptr< MsWrdTextStylesInternal::State > m_state
the state
Definition: MsWrdTextStyles.hxx:158