MsWrdText.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 MS_WRD_MWAW_TEXT
# define MS_WRD_MWAW_TEXT
#include <map>
#include <string>
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWEntry.hxx"
#include "MWAWDebug.hxx"
#include "MsWrdTextStyles.hxx"
namespace MsWrdTextInternal
{
struct State;
struct Table;
}
struct MsWrdEntry;
class MsWrdParser;
class MsWrdTextStyles;
class MsWrdText
{
friend class MsWrdParser;
friend class MsWrdTextStyles;
public:
struct PLC {
enum Type { TextPosition, HeaderFooter, Page, Section, ParagraphInfo, Paragraph, Font, Footnote, FootnoteDef, Field, Object };
explicit 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:
explicit MsWrdText(MsWrdParser &parser);
virtual ~MsWrdText();
int version() const;
int numPages() const;
MWAWEntry getHeader() const;
MWAWEntry getFooter() const;
protected:
std::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(MsWrdEntry &entry);
bool readPageBreak(MsWrdEntry &entry);
bool readParagraphInfo(MsWrdEntry const &entry);
bool readFields(MsWrdEntry &entry, std::vector<long> const &fieldPos);
bool sendFieldComment(int id);
bool readFootnotesPos(MsWrdEntry &entry, std::vector<long> const &noteDef);
bool readFootnotesData(MsWrdEntry &entry);
bool sendFootnote(int id);
bool readFontNames(MsWrdEntry &entry);
void flushExtra();
bool sendTable(MsWrdTextInternal::Table const &table);
// interface with MsWrdTextStyles
long getMainTextLength() const;
std::multimap<long, MsWrdText::PLC> &getTextPLCMap();
std::multimap<long, MsWrdText::PLC> &getFilePLCMap();
//
// low level
//
void prepareData();
void prepareLines();
void convertFilePLCPos();
void prepareParagraphProperties();
void prepareFontProperties();
void prepareTableLimits();
bool updateTableBeginnningAt(long cPos, long &nextCPos);
bool readLongZone(MsWrdEntry &entry, int sz, std::vector<long> &list);
private:
MsWrdText(MsWrdText const &orig) = delete;
MsWrdText &operator=(MsWrdText const &orig) = delete;
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
std::shared_ptr<MsWrdTextInternal::State> m_state;
std::shared_ptr<MsWrdTextStyles> m_stylesManager;
MsWrdParser *m_mainParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWEntry.hxx
MsWrdTextStyles.hxx
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MsWrdParser
the main class to read a Microsoft Word file
Definition MsWrdParser.hxx:98
MsWrdTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition MsWrdTextStyles.hxx:68
MsWrdText::sendTable
bool sendTable(MsWrdTextInternal::Table const &table)
try to send a table.
Definition MsWrdText.cxx:2109
MsWrdText::MsWrdText
MsWrdText(MsWrdText const &orig)=delete
MsWrdText::sendSection
bool sendSection(int sectionId)
try to open a section
Definition MsWrdText.cxx:2093
MsWrdText::MsWrdParser
friend class MsWrdParser
Definition MsWrdText.hxx:66
MsWrdText::prepareLines
void prepareLines()
cut the text in line/cell pos
Definition MsWrdText.cxx:1274
MsWrdText::MsWrdText
MsWrdText(MsWrdParser &parser)
constructor
Definition MsWrdText.cxx:467
MsWrdText::~MsWrdText
virtual ~MsWrdText()
destructor
Definition MsWrdText.cxx:476
MsWrdText::readFontNames
bool readFontNames(MsWrdEntry &entry)
read the font names
Definition MsWrdText.cxx:846
MsWrdText::m_stylesManager
std::shared_ptr< MsWrdTextStyles > m_stylesManager
the style manager
Definition MsWrdText.hxx:216
MsWrdText::version
int version() const
returns the file version
Definition MsWrdText.cxx:479
MsWrdText::readFields
bool readFields(MsWrdEntry &entry, std::vector< long > const &fieldPos)
read the field data
Definition MsWrdText.cxx:1144
MsWrdText::prepareTableLimits
void prepareTableLimits()
find the table end position knowing the end cell/pos delimiter
Definition MsWrdText.cxx:1606
MsWrdText::sendFootnote
bool sendFootnote(int id)
send a note to a listener
Definition MsWrdText.cxx:2184
MsWrdText::readHeaderTextLength
bool readHeaderTextLength()
reads the three different zone size
Definition MsWrdText.cxx:604
MsWrdText::operator=
MsWrdText & operator=(MsWrdText const &orig)=delete
MsWrdText::readParagraphInfo
bool readParagraphInfo(MsWrdEntry const &entry)
read the paragraph height info
Definition MsWrdText.cxx:907
MsWrdText::getMainTextLength
long getMainTextLength() const
returns the main text length
Definition MsWrdText.cxx:492
MsWrdText::prepareParagraphProperties
void prepareParagraphProperties()
retrieve the paragraph properties
Definition MsWrdText.cxx:1429
MsWrdText::readTextStruct
bool readTextStruct(MsWrdEntry &entry)
read the text structure(some paragraph style+some text position?)
Definition MsWrdText.cxx:744
MsWrdText::getFilePLCMap
std::multimap< long, MsWrdText::PLC > & getFilePLCMap()
returns the file correspondance zone ( filepos, plc )
Definition MsWrdText.cxx:548
MsWrdText::sendText
bool sendText(MWAWEntry const &textEntry, bool mainZone, bool tableCell=false)
send a text zone
Definition MsWrdText.cxx:1883
MsWrdText::readLongZone
bool readLongZone(MsWrdEntry &entry, int sz, std::vector< long > &list)
read a zone which consists in a list of int
Definition MsWrdText.cxx:1236
MsWrdText::flushExtra
void flushExtra()
sends the data which have not yet been sent to the listener
Definition MsWrdText.cxx:2222
MsWrdText::getParserState
std::shared_ptr< MWAWParserState > & getParserState()
returns the parser state
Definition MsWrdText.hxx:117
MsWrdText::numPages
int numPages() const
returns the number of pages
Definition MsWrdText.cxx:486
MsWrdText::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition MsWrdText.hxx:210
MsWrdText::convertFilePLCPos
void convertFilePLCPos()
convert the file position in character position and compute the paragraph limit
Definition MsWrdText.cxx:1312
MsWrdText::readFootnotesPos
bool readFootnotesPos(MsWrdEntry &entry, std::vector< long > const &noteDef)
read the footnote pos in text + val
Definition MsWrdText.cxx:1036
MsWrdText::getHeader
MWAWEntry getHeader() const
returns the header entry
Definition MsWrdText.cxx:497
MsWrdText::readFootnotesData
bool readFootnotesData(MsWrdEntry &entry)
read the footnote data
Definition MsWrdText.cxx:1097
MsWrdText::m_mainParser
MsWrdParser * m_mainParser
the main parser;
Definition MsWrdText.hxx:219
MsWrdText::getFooter
MWAWEntry getFooter() const
returns the footer entry
Definition MsWrdText.cxx:520
MsWrdText::MsWrdTextStyles
friend class MsWrdTextStyles
Definition MsWrdText.hxx:67
MsWrdText::getTextPLCMap
std::multimap< long, MsWrdText::PLC > & getTextPLCMap()
returns the text correspondance zone ( textpos, plc )
Definition MsWrdText.cxx:543
MsWrdText::m_state
std::shared_ptr< MsWrdTextInternal::State > m_state
the state
Definition MsWrdText.hxx:213
MsWrdText::sendFieldComment
bool sendFieldComment(int id)
send a field note to a listener
Definition MsWrdText.cxx:2202
MsWrdText::prepareData
void prepareData()
prepare the data to be send
Definition MsWrdText.cxx:1729
MsWrdText::sendMainText
bool sendMainText()
send a main zone
Definition MsWrdText.cxx:2175
MsWrdText::updateTableBeginnningAt
bool updateTableBeginnningAt(long cPos, long &nextCPos)
try to find a table which begin at position cPos, if so, update its data...
Definition MsWrdText.cxx:1706
MsWrdText::prepareFontProperties
void prepareFontProperties()
retrieve the font properties
Definition MsWrdText.cxx:1521
MsWrdText::readPageBreak
bool readPageBreak(MsWrdEntry &entry)
read the page limit ?
Definition MsWrdText.cxx:973
MsWrdText::createZones
bool createZones(long bot)
finds the different zones
Definition MsWrdText.cxx:634
libmwaw_internal.hxx
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
MsWrdTextInternal
Internal: the structures of a MsWrdText.
Definition MsWrdText.cxx:70
MsWrdEntry
the entry of MsWrdParser
Definition MsWrdParser.hxx:63
MsWrdTextInternal::State
Internal: the state of a MsWrdParser.
Definition MsWrdText.cxx:320
MsWrdTextInternal::Table
Internal and low level: a structure to store a table of a MsWrdText.
Definition MsWrdText.cxx:290
MsWrdText::PLC::ltstr
a comparaison structure
Definition MsWrdText.hxx:81
MsWrdText::PLC::ltstr::operator()
bool operator()(PLC const &s1, PLC const &s2) const
Definition MsWrdText.hxx:82
MsWrdText::PLC
Internal: the plc.
Definition MsWrdText.hxx:70
MsWrdText::PLC::Type
Type
Definition MsWrdText.hxx:71
MsWrdText::PLC::FootnoteDef
@ FootnoteDef
Definition MsWrdText.hxx:71
MsWrdText::PLC::ParagraphInfo
@ ParagraphInfo
Definition MsWrdText.hxx:71
MsWrdText::PLC::Paragraph
@ Paragraph
Definition MsWrdText.hxx:71
MsWrdText::PLC::TextPosition
@ TextPosition
Definition MsWrdText.hxx:71
MsWrdText::PLC::Object
@ Object
Definition MsWrdText.hxx:71
MsWrdText::PLC::HeaderFooter
@ HeaderFooter
Definition MsWrdText.hxx:71
MsWrdText::PLC::Font
@ Font
Definition MsWrdText.hxx:71
MsWrdText::PLC::Page
@ Page
Definition MsWrdText.hxx:71
MsWrdText::PLC::Section
@ Section
Definition MsWrdText.hxx:71
MsWrdText::PLC::Field
@ Field
Definition MsWrdText.hxx:71
MsWrdText::PLC::Footnote
@ Footnote
Definition MsWrdText.hxx:71
MsWrdText::PLC::m_type
Type m_type
the plc type
Definition MsWrdText.hxx:92
MsWrdText::PLC::m_id
int m_id
the identificator
Definition MsWrdText.hxx:94
MsWrdText::PLC::m_extra
std::string m_extra
some extra data
Definition MsWrdText.hxx:96
MsWrdText::PLC::PLC
PLC(Type type, int id=0)
Definition MsWrdText.hxx:72
MsWrdText::PLC::operator<<
friend std::ostream & operator<<(std::ostream &o, PLC const &plc)
operator<<
Definition MsWrdText.cxx:557