MSWText.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* Parser to Microsoft Word text document
*
*/
#ifndef MSW_MWAW_TEXT
# define MSW_MWAW_TEXT
#include <map>
#include <string>
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWEntry.hxx"
#include "MWAWDebug.hxx"
#include "MSWTextStyles.hxx"
namespace MSWTextInternal
{
struct State;
struct Table;
}
struct MSWEntry;
class MSWParser;
class MSWTextStyles;
class MSWText
{
friend class MSWParser;
friend class MSWTextStyles;
public:
struct PLC {
enum Type { TextPosition, HeaderFooter, Page, Section, ParagraphInfo, Paragraph, Font, Footnote, FootnoteDef, Field, Object };
PLC(Type type, int id=0) : m_type(type), m_id(id), m_extra("") {
}
friend std::ostream &operator<<(std::ostream &o, PLC const &plc);
struct ltstr {
bool operator()(PLC const &s1, PLC const &s2) const {
if (s1.m_type != s2.m_type)
return int(s1.m_type) < int(s2.m_type);
if (s1.m_id != s2.m_id)
return s1.m_id < s2.m_id;
return false;
}
};
Type m_type;
int m_id;
std::string m_extra;
};
public:
MSWText(MSWParser &parser);
virtual ~MSWText();
int version() const;
int numPages() const;
MWAWEntry getHeader() const;
MWAWEntry getFooter() const;
protected:
shared_ptr<MWAWParserState> &getParserState() {
return m_parserState;
}
bool sendMainText();
bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false);
bool sendSection(int sectionId);
bool readHeaderTextLength();
bool createZones(long bot);
bool readTextStruct(MSWEntry &entry);
bool readPageBreak(MSWEntry &entry);
bool readParagraphInfo(MSWEntry entry);
bool readFields(MSWEntry &entry, std::vector<long> const &fieldPos);
bool sendFieldComment(int id);
bool readFootnotesPos(MSWEntry &entry, std::vector<long> const &noteDef);
bool readFootnotesData(MSWEntry &entry);
bool sendFootnote(int id);
bool readFontNames(MSWEntry &entry);
void flushExtra();
bool sendTable(MSWTextInternal::Table const &table);
// interface with MSWTextStyles
long getMainTextLength() const;
std::multimap<long, MSWText::PLC> &getTextPLCMap();
std::multimap<long, MSWText::PLC> &getFilePLCMap();
//
// low level
//
void prepareData();
void convertFilePLCPos();
void prepareLines();
void prepareParagraphProperties();
void prepareFontProperties();
void prepareTables();
bool readLongZone(MSWEntry &entry, int sz, std::vector<long> &list);
private:
MSWText(MSWText const &orig);
MSWText &operator=(MSWText const &orig);
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
shared_ptr<MSWTextInternal::State> m_state;
shared_ptr<MSWTextStyles> m_stylesManager;
MSWParser *m_mainParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MSWText::operator=
MSWText & operator=(MSWText const &orig)
MSWText::m_mainParser
MSWParser * m_mainParser
the main parser;
Definition: MSWText.hxx:211
MSWText::convertFilePLCPos
void convertFilePLCPos()
convert the file position in character position and compute the paragraph limit
Definition: MSWText.cxx:1123
MSWText::PLC::ltstr
a comparaison structure
Definition: MSWText.hxx:77
MSWText::readFields
bool readFields(MSWEntry &entry, std::vector< long > const &fieldPos)
read the field data
Definition: MSWText.cxx:998
MSWText::PLC::Page
Definition: MSWText.hxx:71
MSWTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:66
MSWText::sendMainText
bool sendMainText()
send a main zone
Definition: MSWText.cxx:1924
MWAWEntry.hxx
MSWText::readParagraphInfo
bool readParagraphInfo(MSWEntry entry)
read the paragraph height info
Definition: MSWText.cxx:771
libmwaw_internal.hxx
MSWText::getFooter
MWAWEntry getFooter() const
returns the footer entry
Definition: MSWText.cxx:407
MSWText::m_state
shared_ptr< MSWTextInternal::State > m_state
the state
Definition: MSWText.hxx:205
MSWText::PLC::Font
Definition: MSWText.hxx:71
MSWText::prepareParagraphProperties
void prepareParagraphProperties()
retrieve the paragraph properties
Definition: MSWText.cxx:1265
MSWText::PLC::ltstr::operator()
bool operator()(PLC const &s1, PLC const &s2) const
Definition: MSWText.hxx:78
MSWParser
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
MSWText::PLC::Object
Definition: MSWText.hxx:71
MSWText::prepareTables
void prepareTables()
prepare the table to be send
Definition: MSWText.cxx:1406
MSWText::readTextStruct
bool readTextStruct(MSWEntry &entry)
read the text structure(some paragraph style+some text position?)
Definition: MSWText.cxx:612
MSWEntry
the entry of MSWParser
Definition: MSWParser.hxx:63
MSWText::prepareLines
void prepareLines()
cut the text in line/cell pos
Definition: MSWText.cxx:1215
MSWText::PLC::m_id
int m_id
the identificator
Definition: MSWText.hxx:89
MSWText::PLC::Section
Definition: MSWText.hxx:71
MSWText::readFontNames
bool readFontNames(MSWEntry &entry)
read the font names
Definition: MSWText.cxx:710
MSWText::readPageBreak
bool readPageBreak(MSWEntry &entry)
read the page limit ?
Definition: MSWText.cxx:836
MSWText::getMainTextLength
long getMainTextLength() const
returns the main text length
Definition: MSWText.cxx:395
MSWText
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:64
MSWText::sendFieldComment
bool sendFieldComment(int id)
send a field note to a listener
Definition: MSWText.cxx:1951
MSWText::readFootnotesData
bool readFootnotesData(MSWEntry &entry)
read the footnote data
Definition: MSWText.cxx:950
MSWText::prepareFontProperties
void prepareFontProperties()
retrieve the font properties
Definition: MSWText.cxx:1324
MSWText::sendTable
bool sendTable(MSWTextInternal::Table const &table)
try to send a table.
Definition: MSWText.cxx:1858
MSWText::getFilePLCMap
std::multimap< long, MSWText::PLC > & getFilePLCMap()
returns the file correspondance zone ( filepos, plc )
Definition: MSWText.cxx:419
MSWText::PLC::Footnote
Definition: MSWText.hxx:71
MSWTextInternal::Table
Internal and low level: a structure to store a table of a MSWText.
Definition: MSWText.cxx:260
MSWText::version
int version() const
returns the file version
Definition: MSWText.cxx:382
MSWText::readFootnotesPos
bool readFootnotesPos(MSWEntry &entry, std::vector< long > const &noteDef)
read the footnote pos in text + val
Definition: MSWText.cxx:890
MSWText::PLC::PLC
PLC(Type type, int id=0)
Definition: MSWText.hxx:72
MSWText::prepareData
void prepareData()
prepare the data to be send
Definition: MSWText.cxx:1488
MSWText::PLC::m_extra
std::string m_extra
some extra data
Definition: MSWText.hxx:91
MSWText::MSWText
MSWText(MSWParser &parser)
constructor
Definition: MSWText.cxx:372
MSWText::readHeaderTextLength
bool readHeaderTextLength()
reads the three different zone size
Definition: MSWText.cxx:473
MSWText::PLC::HeaderFooter
Definition: MSWText.hxx:71
MSWText::PLC::operator<<
friend std::ostream & operator<<(std::ostream &o, PLC const &plc)
operator<<
Definition: MSWText.cxx:428
MSWText::numPages
int numPages() const
returns the number of pages
Definition: MSWText.cxx:389
MSWText::sendText
bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false)
send a text zone
Definition: MSWText.cxx:1635
MSWText::PLC::m_type
Type m_type
the plc type
Definition: MSWText.hxx:87
MSWText::PLC::TextPosition
Definition: MSWText.hxx:71
MSWText::readLongZone
bool readLongZone(MSWEntry &entry, int sz, std::vector< long > &list)
read a zone which consists in a list of int
Definition: MSWText.cxx:1086
MSWText::sendFootnote
bool sendFootnote(int id)
send a note to a listener
Definition: MSWText.cxx:1933
MSWText::flushExtra
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: MSWText.cxx:1971
MSWText::sendSection
bool sendSection(int sectionId)
try to open a section
Definition: MSWText.cxx:1842
MWAWDebug.hxx
MSWText::PLC
Internal: the plc.
Definition: MSWText.hxx:70
MSWText::m_stylesManager
shared_ptr< MSWTextStyles > m_stylesManager
the style manager
Definition: MSWText.hxx:208
MSWText::PLC::Type
Type
Definition: MSWText.hxx:71
MSWText::getTextPLCMap
std::multimap< long, MSWText::PLC > & getTextPLCMap()
returns the text correspondance zone ( textpos, plc )
Definition: MSWText.cxx:414
MSWTextStyles.hxx
MSWText::PLC::Paragraph
Definition: MSWText.hxx:71
MSWText::getParserState
shared_ptr< MWAWParserState > & getParserState()
returns the parser state
Definition: MSWText.hxx:112
MSWText::PLC::ParagraphInfo
Definition: MSWText.hxx:71
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:342
MSWText::createZones
bool createZones(long bot)
finds the different zones
Definition: MSWText.cxx:500
MSWText::PLC::Field
Definition: MSWText.hxx:71
MSWText::PLC::FootnoteDef
Definition: MSWText.hxx:71
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MSWText::getHeader
MWAWEntry getHeader() const
returns the header entry
Definition: MSWText.cxx:400
MSWText::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MSWText.hxx:202
MSWText::~MSWText
virtual ~MSWText()
destructor
Definition: MSWText.cxx:379