WPS8TextStyle.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3  * Version: MPL 2.0 / LGPLv2.1+
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Major Contributor(s):
10  * Copyright (C) 2006, 2007 Andrew Ziem
11  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
12  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
13  *
14  * For minor contributions see the git repository.
15  *
16  * Alternatively, the contents of this file may be used under the terms
17  * of the GNU Lesser General Public License Version 2.1 or later
18  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19  * applicable instead of those above.
20  */
21 
22 #ifndef WPS8_TEXTSTYLE_H
23 #define WPS8_TEXTSTYLE_H
24 
25 #include <ostream>
26 #include <string>
27 #include <vector>
28 
29 #include "libwps_internal.h"
30 
31 #include "WPSDebug.h"
32 
33 namespace WPS8TextStyleInternal
34 {
35 struct State;
36 }
37 
38 class WPS8Text;
39 
41 {
42  friend class WPS8Text;
43 public:
44  struct FontData;
45 
46  explicit WPS8TextStyle(WPS8Text &parser);
48 
51  {
52  m_listener = listen;
53  }
54 
56  bool readStructures();
57 
58 protected:
60  bool readFontNames(WPSEntry const &entry);
62  bool readFont(long endPos, int &id, std::string &mess);
63 
64  void sendFont(int fId, FontData &data);
65 
67  bool readParagraph(long endPos, int &id, std::string &mess);
68 
69  void sendParagraph(int pId);
70 
73  bool readSTSH(WPSEntry const &entry);
74 
76  bool readSGP(WPSEntry const &entry);
77 
78  //----------------------------------------
79  // FDP parsing
80  //----------------------------------------
81 
84  bool findFDPStructures(int which, std::vector<WPSEntry> &result);
87  bool findFDPStructuresByHand(int which, std::vector<WPSEntry> &result);
88 
89 protected:
92  {
93  return m_asciiFile;
94  }
95 
96 private:
98  WPS8TextStyle(WPS8TextStyle const &orig) = delete;
100  WPS8TextStyle &operator=(WPS8TextStyle const &orig) = delete;
101 
102 protected:
110  mutable std::shared_ptr<WPS8TextStyleInternal::State> m_state;
113 public:
114  struct FontData
115  {
117  : m_type(T_None)
119  , m_fieldFormat(0) {}
121  friend std::ostream &operator<<(std::ostream &o, FontData const &fData);
123  std::string format() const;
124 
127  int m_type;
128  enum { F_None=0, F_PageNumber=-1, F_Date=-4, F_Time=-5 };
133  };
134 protected:
135 };
136 
137 
138 #endif /* WPS8_TEXT_H */
139 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSColor::white
static WPSColor white()
return the white color
Definition: libwps_internal.h:311
WPS_N_ELEMENTS
#define WPS_N_ELEMENTS(m)
Definition: libwps_internal.h:124
WPSParagraph.h
WPS8TextStyleInternal::State::m_paragraphTypes
std::map< int, int > m_paragraphTypes
the paragraph type
Definition: WPS8TextStyle.cpp:127
WPSEntry::hasName
bool hasName(std::string const &nam) const
checks if the entry name is equal to name
Definition: WPSEntry.h:150
WPS8TextStyle::WPS8TextStyle
WPS8TextStyle(WPS8Text &parser)
Definition: WPS8TextStyle.cpp:161
WPSParagraph::m_justify
libwps::Justification m_justify
the justification
Definition: WPSParagraph.h:116
WPS_STRIKEOUT_BIT
#define WPS_STRIKEOUT_BIT
Definition: libwps_internal.h:507
WPS8TextStyle::m_mainParser
WPS8Text & m_mainParser
the main parser
Definition: WPS8TextStyle.h:104
libwps::UPPERCASE_ROMAN
Definition: libwps_internal.h:246
WPSParagraph::m_listLevelIndex
int m_listLevelIndex
the actual level index
Definition: WPSParagraph.h:121
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
WPS8TextStyle::m_listener
WPSContentListenerPtr m_listener
the listener
Definition: WPS8TextStyle.h:108
WPS8TextStyleInternal::State::m_fontList
std::vector< Font > m_fontList
a list of all font properties
Definition: WPS8TextStyle.cpp:118
WPS_BOLD_BIT
#define WPS_BOLD_BIT
Definition: libwps_internal.h:506
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
WPS8TextStyleInternal::Font::~Font
~Font() final
destructor
Definition: WPS8TextStyle.cpp:81
WPSEntry::end
long end() const
returns the end offset
Definition: WPSEntry.h:76
WPS8TextStyle::readSGP
bool readSGP(WPSEntry const &entry)
parses a SGP zone: style general property ?
Definition: WPS8TextStyle.cpp:305
WPSParagraph::m_margins
double m_margins[3]
the margins
Definition: WPSParagraph.h:101
WPS8TextStyle::readFontNames
bool readFontNames(WPSEntry const &entry)
reads the font names
Definition: WPS8TextStyle.cpp:222
WPS8TextStyleInternal::Font::special
const WPS8TextStyle::FontData & special() const
return the auxilliary data
Definition: WPS8TextStyle.cpp:71
WPS_SUBSCRIPT_BIT
#define WPS_SUBSCRIPT_BIT
Definition: libwps_internal.h:500
WPS8TextStyle::FontData::operator<<
friend std::ostream & operator<<(std::ostream &o, FontData const &fData)
operator <<
Definition: WPS8TextStyle.cpp:1307
WPS8TextStyleInternal::State::m_fontNames
std::vector< librevenge::RVNGString > m_fontNames
the font names
Definition: WPS8TextStyle.cpp:113
WPSList::Level::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition: WPSList.h:60
WPS8TextStyle::FontData::format
std::string format() const
returns a format to used with strftime
Definition: WPS8TextStyle.cpp:1353
WPS_UNDERLINE_BIT
#define WPS_UNDERLINE_BIT
Definition: libwps_internal.h:508
WPS8Struct::FileData::m_recursData
std::vector< FileData > m_recursData
the list of children
Definition: WPS8Struct.h:145
WPS8TextStyleInternal::State::initTypeMaps
void initTypeMaps()
initializes the type map
Definition: WPS8TextStyle.cpp:130
WPS8TextStyle::FontData::FontData
FontData()
Definition: WPS8TextStyle.h:116
WPSTabStop::CENTER
Definition: WPSParagraph.h:39
WPSContentListenerPtr
std::shared_ptr< WPSContentListener > WPSContentListenerPtr
shared pointer to WPSContentListener
Definition: libwps_internal.h:107
WPS8Struct::readBlockData
bool readBlockData(RVNGInputStreamPtr input, long endPos, FileData &dt, std::string &error)
tries to read a block zone as a list of Data
Definition: WPS8Struct.cpp:168
libwps::BULLET
Definition: libwps_internal.h:246
WPSBorder::BottomBit
Definition: libwps_internal.h:401
WPS_SUPERSCRIPT_BIT
#define WPS_SUPERSCRIPT_BIT
Definition: libwps_internal.h:499
WPS_ALL_CAPS_BIT
#define WPS_ALL_CAPS_BIT
Definition: libwps_internal.h:512
WPS8Text::readString
bool readString(RVNGInputStreamPtr input, long page_size, librevenge::RVNGString &res)
reads a string
Definition: WPS8Text.cpp:1127
WPS8TextStyle::FontData::F_None
Definition: WPS8TextStyle.h:128
WPS8TextStyleInternal::State::m_fontTypes
std::map< int, int > m_fontTypes
the character type
Definition: WPS8TextStyle.cpp:125
WPS8TextStyle::ascii
libwps::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: WPS8TextStyle.h:91
WPSBorder::m_width
int m_width
the border width
Definition: libwps_internal.h:450
WPSList.h
libwps::ARABIC
Definition: libwps_internal.h:246
WPS_OUTLINE_BIT
#define WPS_OUTLINE_BIT
Definition: libwps_internal.h:501
WPSTextParser::getNameEntryMap
std::multimap< std::string, WPSEntry > & getNameEntryMap()
returns the map type->entry
Definition: WPSTextParser.cpp:58
WPS8Struct::FileData::m_value
long m_value
an int value, filled if the data store an val
Definition: WPS8Struct.h:141
WPS_DOUBLE_UNDERLINE_BIT
#define WPS_DOUBLE_UNDERLINE_BIT
Definition: libwps_internal.h:505
WPS8TextStyle::~WPS8TextStyle
~WPS8TextStyle()
Definition: WPS8TextStyle.cpp:171
WPSFont
define the font properties
Definition: WPSFont.h:36
WPSColor::barycenter
static WPSColor barycenter(float alpha, WPSColor const &colA, float beta, WPSColor const &colB)
return alpha*colA+beta*colB
Definition: libwps_internal.cpp:386
WPS8TextStyleInternal::State::m_paragraphList
std::vector< WPSParagraph > m_paragraphList
a list of all paragraph properties
Definition: WPS8TextStyle.cpp:122
WPS8TextStyleInternal::operator<<
std::ostream & operator<<(std::ostream &o, Font const &ft)
operator<< for a font
Definition: WPS8TextStyle.cpp:86
WPS_ITALICS_BIT
#define WPS_ITALICS_BIT
Definition: libwps_internal.h:502
WPS8TextStyleInternal::Font::m_special
WPS8TextStyle::FontData m_special
the auxialliary data
Definition: WPS8TextStyle.cpp:78
WPS8TextStyle::readSTSH
bool readSTSH(WPSEntry const &entry)
reads a style sheet zone
Definition: WPS8TextStyle.cpp:1068
WPS8TextStyle::FontData::T_Comment
Definition: WPS8TextStyle.h:125
WPSTabStop::RIGHT
Definition: WPSParagraph.h:39
WPSParagraph::m_listLevel
ListLevel m_listLevel
the actual level
Definition: WPSParagraph.h:123
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:38
WPS_SMALL_CAPS_BIT
#define WPS_SMALL_CAPS_BIT
Definition: libwps_internal.h:509
WPSEntry::name
const std::string & name() const
name of the entry
Definition: WPSEntry.h:145
WPS8TextStyle::FontData::F_Date
Definition: WPS8TextStyle.h:128
WPS8TextStyle::FontData::m_fieldFormat
int m_fieldFormat
the field format
Definition: WPS8TextStyle.h:132
WPSParagraph::setInterline
void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
set the interline
Definition: WPSParagraph.h:87
WPSEntry::type
const std::string & type() const
returns the type of the entry
Definition: WPSEntry.h:129
WPSBorder::m_color
WPSColor m_color
the border color
Definition: libwps_internal.h:456
WPS8Struct::FileData::id
int id() const
returns the identificator
Definition: WPS8Struct.h:132
WPSList::Level::m_type
libwps::NumberingType m_type
the type of the level
Definition: WPSList.h:98
WPSParagraph::m_borderStyle
WPSBorder m_borderStyle
the border style
Definition: WPSParagraph.h:131
WPS8Struct.h
WPSTabStop::LEFT
Definition: WPSParagraph.h:39
WPS8TextStyleInternal::Font
Internal: class to store font properties.
Definition: WPS8TextStyle.cpp:45
WPS8TextStyle::FontData::m_type
int m_type
the main type: footnote, ...
Definition: WPS8TextStyle.h:127
WPS8TextStyle::FontData::F_PageNumber
Definition: WPS8TextStyle.h:128
WPSBorder::TopBit
Definition: libwps_internal.h:401
WPS8TextStyle::FontData::T_Field
Definition: WPS8TextStyle.h:125
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
libwps::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:76
WPSTextParser::mergeSortedFODLists
std::vector< DataFOD > mergeSortedFODLists(std::vector< DataFOD > const &lst1, std::vector< DataFOD > const &lst2) const
function which takes two sorted list of attribute (by text position).
Definition: WPSTextParser.cpp:253
libwps::LOWERCASE_ROMAN
Definition: libwps_internal.h:246
libwps_tools_win::Font::unicode
static unsigned long unicode(unsigned char c, Type type)
converts a character in unicode, knowing the character and the font type
Definition: libwps_tools_win.cpp:7160
WPS_FALLTHROUGH
#define WPS_FALLTHROUGH
fall through attributes
Definition: libwps_internal.h:82
WPSParagraph
class to store the paragraph properties
Definition: WPSParagraph.h:57
WPS8Struct::FileData::readArrayBlock
bool readArrayBlock() const
forces reading the data as a list of block
Definition: WPS8Struct.cpp:33
WPSContentListener.h
WPS8TextStyle::FontData::T_None
Definition: WPS8TextStyle.h:125
WPS8TextStyleInternal::State::State
State()
constructor
Definition: WPS8TextStyle.cpp:97
WPS8TextStyle::readParagraph
bool readParagraph(long endPos, int &id, std::string &mess)
the paragraph
Definition: WPS8TextStyle.cpp:636
WPS8TextStyle::operator=
WPS8TextStyle & operator=(WPS8TextStyle const &orig)=delete
private copy operator: forbidden
WPS8TextStyle::FontData::F_Time
Definition: WPS8TextStyle.h:128
WPSTabStop::DECIMAL
Definition: WPSParagraph.h:39
WPS8TextStyleInternal::State::m_defaultFont
Font m_defaultFont
the default font
Definition: WPS8TextStyle.cpp:116
libwps::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string ( with correct encoding ).
Definition: libwps_internal.cpp:836
libwps::read32
int32_t read32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:85
libwps::UPPERCASE
Definition: libwps_internal.h:246
WPS8TextStyleInternal::State::m_defaultParagraph
WPSParagraph m_defaultParagraph
the default paragraph
Definition: WPS8TextStyle.cpp:120
WPS8TextStyle::FontData::T_Footnote
Definition: WPS8TextStyle.h:125
WPSFont.h
WPSTextParser::m_FODList
std::vector< DataFOD > m_FODList
the list of a FOD
Definition: WPSTextParser.h:134
WPSBorder::RightBit
Definition: libwps_internal.h:401
WPSEntry.h
libwps::DebugFile::addNote
static void addNote(char const *)
Definition: WPSDebug.h:221
WPSEntry::begin
long begin() const
returns the begin offset
Definition: WPSEntry.h:71
WPS8Struct::FileData
A recursif structure which seems generally used to store complex memory structures in a file.
Definition: WPS8Struct.h:63
WPS8Text.h
WPSParagraph::m_extra
std::string m_extra
a string to store some errors
Definition: WPSParagraph.h:134
libwps::read8
int8_t read8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:59
WPSFont::m_size
double m_size
font size
Definition: WPSFont.h:83
WPS8TextStyle::sendParagraph
void sendParagraph(int pId)
Definition: WPS8TextStyle.cpp:1053
WPS8TextStyle::m_state
std::shared_ptr< WPS8TextStyleInternal::State > m_state
the internal state
Definition: WPS8TextStyle.h:110
WPSBorder::m_style
Style m_style
the border style
Definition: libwps_internal.h:446
WPS8Text
Definition: WPS8Text.h:47
WPS8TextStyle::readFont
bool readFont(long endPos, int &id, std::string &mess)
reads a font properties
Definition: WPS8TextStyle.cpp:357
WPSParagraph::m_border
int m_border
list of bits to indicated a border 1: LeftBorderBit, 2: RightBorderBit, ...
Definition: WPSParagraph.h:129
WPSEntry::length
long length() const
returns the length of the zone
Definition: WPSEntry.h:81
libwps::DebugStream
Definition: WPSDebug.h:191
WPSTextParser::readFDP
bool readFDP(WPSEntry const &entry, std::vector< DataFOD > &fods, FDPParser parser)
parses a FDPP or a FDPC entry (which contains a list of ATTR_TEXT/ATTR_PARAG with their definition ) ...
Definition: WPSTextParser.cpp:71
WPS8TextStyle::readStructures
bool readStructures()
finds all entries which correspond to the styles, parses them and stores data
Definition: WPS8TextStyle.cpp:178
WPS8TextStyle::findFDPStructures
bool findFDPStructures(int which, std::vector< WPSEntry > &result)
finds the FDPC/FDPP structure using the BTEC/BTEP entries which == 0 means FDPP, 1 means FDPC
Definition: WPS8TextStyle.cpp:1209
libwps_tools_win.h
WPS8TextStyleInternal
Definition: WPS8TextStyle.cpp:42
WPS8Text::readPLC
bool readPLC(WPSEntry const &entry, std::vector< long > &textPtrs, std::vector< long > &listValues, DataParser parser=&WPS8Text::defDataParser, EndDataParser endParser=nullptr)
reads a PLC (Pointer List Composant ?) in zone entry
Definition: WPS8Text.cpp:1990
WPS8TextStyle::FontData::T_Object
Definition: WPS8TextStyle.h:125
WPS8TextStyle::m_asciiFile
libwps::DebugFile & m_asciiFile
the ascii file
Definition: WPS8TextStyle.h:112
libwps::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:64
WPSList::Level::m_bullet
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition: WPSList.h:99
WPSEntry::hasType
bool hasType(std::string const &tp) const
returns true if the type entry == type
Definition: WPSEntry.h:134
WPS8TextStyle::findFDPStructuresByHand
bool findFDPStructuresByHand(int which, std::vector< WPSEntry > &result)
finds the FDPC/FDPP structure by searching after the text zone which == 0 means FDPP,...
Definition: WPS8TextStyle.cpp:1286
WPS_EMBOSS_BIT
#define WPS_EMBOSS_BIT
Definition: libwps_internal.h:513
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WPSParagraph::m_spacings
double m_spacings[3]
the line spacing
Definition: WPSParagraph.h:107
WPSBorder::LeftBit
Definition: libwps_internal.h:401
WPSBorder::m_type
Type m_type
the border repetition
Definition: libwps_internal.h:448
WPS8.h
WPSDebug.h
WPS8Text::readFont
bool readFont(long endPos, int &id, std::string &mess)
reads a font properties
Definition: WPS8Text.cpp:580
WPS8TextStyle::FontData::T_Endnote
Definition: WPS8TextStyle.h:125
WPSList::Level::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition: WPSList.h:96
libwps::LOWERCASE
Definition: libwps_internal.h:246
WPS8TextStyle::FontData::m_fieldType
int m_fieldType
the field type: pagenumber, data, time, ...
Definition: WPS8TextStyle.h:130
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:71
operator<<
std::ostream & operator<<(std::ostream &o, WPS8TextStyle::FontData const &fData)
Definition: WPS8TextStyle.cpp:1307
libwps::JustificationFull
Definition: libwps_internal.h:249
libwps_internal.h
libwps::JustificationLeft
Definition: libwps_internal.h:249
WPSColor
the class to store a color
Definition: libwps_internal.h:280
WPS8TextStyleInternal::State
Internal: the state of a WPS4Text.
Definition: WPS8TextStyle.cpp:94
WPS8TextStyleInternal::Font::operator<<
friend std::ostream & operator<<(std::ostream &o, Font const &ft)
operator<<
Definition: WPS8TextStyle.cpp:86
WPS_SHADOW_BIT
#define WPS_SHADOW_BIT
Definition: libwps_internal.h:503
WPSList::Level::m_labelIndent
double m_labelIndent
the list indent
Definition: WPSList.h:93
WPS8TextStyle::m_input
RVNGInputStreamPtr m_input
the main input
Definition: WPS8TextStyle.h:106
WPS8TextStyleInternal::Font::Font
Font()
constructor
Definition: WPS8TextStyle.cpp:48
libwps::NONE
Definition: libwps_internal.h:246
WPSEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: WPSEntry.h:118
WPS_ENGRAVE_BIT
#define WPS_ENGRAVE_BIT
Definition: libwps_internal.h:514
WPS8Text::readParagraph
bool readParagraph(long endPos, int &id, std::string &mess)
the paragraph
Definition: WPS8Text.cpp:585
libwps::JustificationCenter
Definition: libwps_internal.h:249
libwps::DebugFile
Definition: WPSDebug.h:207
WPSParagraph::m_backgroundColor
WPSColor m_backgroundColor
the background color
Definition: WPSParagraph.h:126
libwps::JustificationRight
Definition: libwps_internal.h:250
WPS8Struct::FileData::isArray
bool isArray() const
returns true if this is a list of block or an unstructured list
Definition: WPS8Struct.h:115
WPS8TextStyleInternal::Font::def
static Font def()
Definition: WPS8TextStyle.cpp:54
WPS8Struct::FileData::isRead
bool isRead() const
returns true if the data are read
Definition: WPS8Struct.h:120
WPS8TextStyle::setListener
void setListener(WPSContentListenerPtr &listen)
sets the listener
Definition: WPS8TextStyle.h:50
WPSTextParser::FDPParser
bool(WPSTextParser::* FDPParser)(long endPos, int &id, std::string &mess)
callback when a new attribute is found in an FDPP/FDPC entry
Definition: WPSTextParser.h:103
WPSTabStop::BAR
Definition: WPSParagraph.h:39
WPSColor::black
static WPSColor black()
return the back color
Definition: libwps_internal.h:306
WPSParagraph::m_tabs
std::vector< WPSTabStop > m_tabs
the tabulations
Definition: WPSParagraph.h:113
WPS8TextStyle.h
WPSFont::m_name
librevenge::RVNGString m_name
font name
Definition: WPSFont.h:81
libwps_tools_win::Font::WIN3_WINGDINGS
Definition: libwps_tools_win.h:62
WPS8TextStyle
Definition: WPS8TextStyle.h:40
WPSList::Level::m_suffix
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: WPSList.h:99
WPS8TextStyle::FontData
Definition: WPS8TextStyle.h:114
WPS8TextStyle::sendFont
void sendFont(int fId, FontData &data)
Definition: WPS8TextStyle.cpp:619
WPS8TextStyleInternal::Font::special
WPS8TextStyle::FontData & special()
return the auxilliary data
Definition: WPS8TextStyle.cpp:66

Generated on Wed Jul 24 2024 02:01:29 for libwps by doxygen 1.8.16