MSWrite.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) 2015 Sean Young <sean@mess.org>
11 *
12 * For minor contributions see the git repository.
13 *
14 * Alternatively, the contents of this file may be used under the terms
15 * of the GNU Lesser General Public License Version 2.1 or later
16 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
17 * applicable instead of those above.
18 *
19 * For further information visit http://libwps.sourceforge.net
20 */
21
22#ifndef MS_WRITE_H
23#define MS_WRITE_H
24
25#include <vector>
26
27#include <librevenge-stream/librevenge-stream.h>
28#include "libwps_internal.h"
29#include "libwps_tools_win.h"
30
31#include "WPSParser.h"
32#include "WPSEntry.h"
33#include "WPSFont.h"
34#include "WPSPageSpan.h"
35#include "WPSParagraph.h"
36
38{
39class SubDocument;
40
41struct Paragraph final : public WPSParagraph
42{
45 : WPSParagraph()
46 , m_fcFirst(0)
47 , m_fcLim(0)
49 , m_graphics(false)
50 , m_firstpage(false)
51 , m_skiptab(false)
52 , m_headerUseMargin(false)
53 , m_interLine(0.0)
55 Paragraph(Paragraph const &)=default;
56 ~Paragraph() final;
57 uint32_t m_fcFirst, m_fcLim;
61 WPSPageSpan::HeaderFooterOccurrence m_HeaderFooterOccurrence;
62};
63
64struct Font final : public WPSFont
65{
67 : WPSFont()
68 , m_fcFirst(0)
69 , m_fcLim(0)
70 , m_special(false)
71 , m_footnote(false)
72 , m_annotation(false)
73 , m_encoding(libwps_tools_win::Font::UNKNOWN) { }
74 Font(Font const &)=default;
75 ~Font() final;
76 uint32_t m_fcFirst, m_fcLim;
79};
80
82{
84 : m_fcFtn(0)
85 , m_fcRef(0) { }
86 uint32_t m_fcFtn, m_fcRef;
87};
88
89struct Section
90{
93 : m_fcLim(0)
94 , m_bkc(1)
95 , m_yaMac(11)
96 , m_xaMac(8.5)
97 , m_yaTop(1)
98 , m_dyaText(9)
99 , m_xaLeft(1.25)
100 , m_dxaText(6)
101 , m_startPageNumber(0xffff)
102 , m_yaHeader(0.75)
103 , m_yaFooter(10.25) /* 11-0.75inch*/
104 , m_endFtns(false)
105 , m_columns(1)
106 , m_dxaColumns(0.5)
107 , m_dxaGutter(0.0)
108 , m_Main() { }
109 uint32_t m_fcLim;
110 unsigned m_bkc;
112 double m_yaTop;
113 double m_dyaText;
114 double m_xaLeft;
115 double m_dxaText;
120 unsigned m_columns;
123};
124
125}
126
132{
136
137public:
140
141
142 ~MSWriteParser() override;
143 void parse(librevenge::RVNGTextInterface *documentInterface) override;
144
145private:
146 MSWriteParser(const MSWriteParser &) = delete;
148
149 std::shared_ptr<WPSContentListener> createListener(librevenge::RVNGTextInterface *interface);
150protected:
151 void readStructures();
153 void readFIB();
154 virtual void readFFNTB();
155 void readFOD(unsigned page, void (MSWriteParser::*parseFOD)(uint32_t fcFirst, uint32_t fcLim, unsigned size));
156 virtual void readPAP(uint32_t fcFirst, uint32_t fcLim, unsigned cch);
157 virtual void readCHP(uint32_t fcFirst, uint32_t fcLim, unsigned cch);
158 virtual void readSUMD();
159 virtual void readFNTB();
160 virtual void readSED();
162 int numPages();
163 void processObject(WPSPosition &pos, unsigned long lastPos);
164 bool processDDB(librevenge::RVNGBinaryData &bmpdata, WPSPosition &pos, unsigned width, unsigned height, unsigned byte_width, unsigned planes, unsigned bits_pixel, unsigned size);
165 bool processDIB(librevenge::RVNGBinaryData &bmpdata, unsigned size);
166 bool processWMF(librevenge::RVNGBinaryData &wmfdata, unsigned size);
167 void processEmbeddedOLE(WPSPosition &pos, unsigned long lastPos);
168 bool processStaticOLE(librevenge::RVNGBinaryData &, std::string &mimetype, WPSPosition &pos, unsigned long lastPos);
169 bool readString(std::string &res, unsigned long lastPos);
170 virtual void insertSpecial(uint8_t val, uint32_t fc, MSWriteParserInternal::Paragraph::Location location);
171 virtual void insertControl(uint8_t val, uint32_t fc);
172 void insertNote(bool annotation, uint32_t fcPos, librevenge::RVNGString const &label);
173 unsigned insertString(const unsigned char *str, unsigned size, libwps_tools_win::Font::Type type);
174 static void getPageStyle(MSWriteParserInternal::Section &sep, WPSPageSpan &pageSpan);
175 void getHeaderFooters(uint32_t first, MSWriteParserInternal::Section &sep, WPSPageSpan &pageSpan);
176 void startSection(MSWriteParserInternal::Section const &section);
177
179 bool checkFilePosition(uint32_t pos) const
180 {
181 return pos<=m_fileLength;
182 }
183 // State
185 uint32_t m_fileLength;
186 uint32_t m_fcMac;
187
188 std::vector<MSWriteParserInternal::Paragraph> m_paragraphList;
189 std::vector<MSWriteParserInternal::Font> m_fontList;
190 std::vector<MSWriteParserInternal::Footnote> m_footnotes;
191 std::vector<MSWriteParserInternal::Section> m_sections;
192 std::vector<librevenge::RVNGString> m_fonts;
194
195 std::shared_ptr<WPSContentListener> m_listener; /* the listener (if set)*/
196
197 librevenge::RVNGPropertyList m_metaData;
198};
199
200#endif /* MS_WRITE_H */
201/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
Internal: the subdocument of a MSWriteParser.
Definition MSWrite.cpp:49
uint32_t m_fcMac
Definition MSWrite.h:186
virtual void insertControl(uint8_t val, uint32_t fc)
Definition MSWrite.cpp:1107
libwps_tools_win::Font::Type m_fontType
Definition MSWrite.h:193
std::vector< MSWriteParserInternal::Footnote > m_footnotes
Definition MSWrite.h:190
bool processDDB(librevenge::RVNGBinaryData &bmpdata, WPSPosition &pos, unsigned width, unsigned height, unsigned byte_width, unsigned planes, unsigned bits_pixel, unsigned size)
Definition MSWrite.cpp:1295
std::vector< MSWriteParserInternal::Font > m_fontList
Definition MSWrite.h:189
void readStructures()
Definition MSWrite.cpp:1689
virtual libwps_tools_win::Font::Type getFileEncoding(libwps_tools_win::Font::Type hint)
Definition MSWrite.cpp:320
void startSection(MSWriteParserInternal::Section const &section)
Definition MSWrite.cpp:1754
std::vector< librevenge::RVNGString > m_fonts
Definition MSWrite.h:192
void processObject(WPSPosition &pos, unsigned long lastPos)
Definition MSWrite.cpp:1186
bool processDIB(librevenge::RVNGBinaryData &bmpdata, unsigned size)
Definition MSWrite.cpp:1480
void readFOD(unsigned page, void(MSWriteParser::*parseFOD)(uint32_t fcFirst, uint32_t fcLim, unsigned size))
Definition MSWrite.cpp:557
MSWriteParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header, libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::WIN3_WEUROPE)
Definition MSWrite.cpp:290
void insertNote(bool annotation, uint32_t fcPos, librevenge::RVNGString const &label)
Definition MSWrite.cpp:1717
unsigned insertString(const unsigned char *str, unsigned size, libwps_tools_win::Font::Type type)
Definition MSWrite.cpp:1134
MSWriteParser & operator=(const MSWriteParser &)=delete
std::vector< MSWriteParserInternal::Paragraph > m_paragraphList
Definition MSWrite.h:188
virtual void insertSpecial(uint8_t val, uint32_t fc, MSWriteParserInternal::Paragraph::Location location)
Definition MSWrite.cpp:1101
std::vector< MSWriteParserInternal::Section > m_sections
Definition MSWrite.h:191
virtual void readFFNTB()
Definition MSWrite.cpp:354
void readFIB()
Definition MSWrite.cpp:328
static void getPageStyle(MSWriteParserInternal::Section &sep, WPSPageSpan &pageSpan)
Definition MSWrite.cpp:510
void processEmbeddedOLE(WPSPosition &pos, unsigned long lastPos)
Definition MSWrite.cpp:1580
bool readString(std::string &res, unsigned long lastPos)
Definition MSWrite.cpp:1145
void readText(WPSEntry const &e, MSWriteParserInternal::Paragraph::Location location)
Definition MSWrite.cpp:931
librevenge::RVNGPropertyList m_metaData
Definition MSWrite.h:197
std::shared_ptr< WPSContentListener > m_listener
Definition MSWrite.h:195
MSWriteParser(const MSWriteParser &)=delete
virtual void readCHP(uint32_t fcFirst, uint32_t fcLim, unsigned cch)
Definition MSWrite.cpp:711
void parse(librevenge::RVNGTextInterface *documentInterface) override
Definition MSWrite.cpp:1764
uint32_t m_fileLength
the last file position
Definition MSWrite.h:185
std::shared_ptr< WPSContentListener > createListener(librevenge::RVNGTextInterface *interface)
Definition MSWrite.cpp:906
virtual void readPAP(uint32_t fcFirst, uint32_t fcLim, unsigned cch)
Definition MSWrite.cpp:612
void getHeaderFooters(uint32_t first, MSWriteParserInternal::Section &sep, WPSPageSpan &pageSpan)
Definition MSWrite.cpp:767
bool processWMF(librevenge::RVNGBinaryData &wmfdata, unsigned size)
Definition MSWrite.cpp:1660
virtual void readSED()
Definition MSWrite.cpp:452
virtual void readSUMD()
Definition MSWrite.cpp:1679
virtual void readFNTB()
Definition MSWrite.cpp:1684
bool processStaticOLE(librevenge::RVNGBinaryData &, std::string &mimetype, WPSPosition &pos, unsigned long lastPos)
Definition MSWrite.cpp:1523
bool checkFilePosition(uint32_t pos) const
check if the file position is correct or not
Definition MSWrite.h:179
basic class to store an entry in a file This contained :
Definition WPSEntry.h:39
WPSFont()
constructor
Definition WPSFont.h:40
Definition WPSPageSpan.h:39
WPSParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header)
Definition WPSParser.cpp:30
Class to define the position of an object (textbox, picture, ..) in the document.
Definition WPSPosition.h:40
Type
enum Type
Definition libwps_tools_win.h:46
@ WIN3_WEUROPE
Definition libwps_tools_win.h:52
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition libwps_internal.h:109
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition libwps_internal.h:87
Definition MSWrite.cpp:39
some Windows© classes and tools
Definition libwps_tools_win.cpp:32
Definition MSWrite.h:65
bool m_annotation
Definition MSWrite.h:77
Font(Font const &)=default
uint32_t m_fcLim
Definition MSWrite.h:76
uint32_t m_fcFirst
Definition MSWrite.h:76
bool m_special
Definition MSWrite.h:77
libwps_tools_win::Font::Type m_encoding
Definition MSWrite.h:78
Font()
Definition MSWrite.h:66
bool m_footnote
Definition MSWrite.h:77
Footnote()
Definition MSWrite.h:83
uint32_t m_fcFtn
Definition MSWrite.h:86
uint32_t m_fcRef
Definition MSWrite.h:86
Definition MSWrite.h:42
bool m_headerUseMargin
Definition MSWrite.h:59
bool m_graphics
Definition MSWrite.h:59
Paragraph(Paragraph const &)=default
uint32_t m_fcLim
Definition MSWrite.h:57
bool m_skiptab
Definition MSWrite.h:59
WPSPageSpan::HeaderFooterOccurrence m_HeaderFooterOccurrence
Definition MSWrite.h:61
Location m_Location
Definition MSWrite.h:58
Paragraph()
Definition MSWrite.h:44
bool m_firstpage
Definition MSWrite.h:59
Location
Definition MSWrite.h:43
@ FOOTNOTE
Definition MSWrite.h:43
@ FOOTER
Definition MSWrite.h:43
@ HEADER
Definition MSWrite.h:43
@ MAIN
Definition MSWrite.h:43
uint32_t m_fcFirst
Definition MSWrite.h:57
~Paragraph() final
Definition MSWrite.cpp:44
double m_interLine
Definition MSWrite.h:60
Definition MSWrite.h:90
double m_xaLeft
Definition MSWrite.h:114
double m_dyaText
Definition MSWrite.h:113
unsigned m_columns
Definition MSWrite.h:120
double m_xaMac
Definition MSWrite.h:111
unsigned m_bkc
Definition MSWrite.h:110
uint16_t m_startPageNumber
Definition MSWrite.h:116
double m_yaHeader
Definition MSWrite.h:117
double m_yaMac
Definition MSWrite.h:111
double m_dxaGutter
Definition MSWrite.h:121
Section()
constructor
Definition MSWrite.h:92
double m_dxaText
Definition MSWrite.h:115
double m_yaFooter
Definition MSWrite.h:118
double m_yaTop
Definition MSWrite.h:112
bool m_endFtns
Definition MSWrite.h:119
uint32_t m_fcLim
Definition MSWrite.h:109
double m_dxaColumns
Definition MSWrite.h:121
WPSEntry m_Main
Definition MSWrite.h:122
WPSParagraph()
constructor
Definition WPSParagraph.h:64

Generated on Sat Jul 19 2025 05:24:39 for libwps by doxygen 1.14.0