MsWrdTextStyles.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.
*/
/*
* Class to read/store the text font and paragraph styles
*/
#ifndef MS_WRD_TEXT_STYLES
# define MS_WRD_TEXT_STYLES
#include <iostream>
#include <map>
#include <string>
#include "libmwaw_internal.hxx"
#include "MWAWEntry.hxx"
#include "MWAWParagraph.hxx"
struct MsWrdEntry;
class MsWrdParser;
class MsWrdText;
namespace MsWrdStruct
{
struct Font;
struct Paragraph;
struct Section;
}
namespace MsWrdTextStylesInternal
{
struct State;
}
class MsWrdTextStyles
{
friend class MsWrdText;
public:
enum ZoneType { TextZone, TextStructZone, StyleZone, InParagraphDefinition };
explicit MsWrdTextStyles(MsWrdText &textParser);
virtual ~MsWrdTextStyles();
int version() const;
protected:
// font:
MWAWFont const &getDefaultFont() const;
bool getFont(ZoneType type, int id, MsWrdStruct::Font &actFont);
/* send a font */
void setProperty(MsWrdStruct::Font const &font);
bool readFont(MsWrdStruct::Font &font, ZoneType type);
// pararagraph:
bool getParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para);
bool readParagraph(MsWrdStruct::Paragraph &para, int dataSz=-1);
void sendDefaultParagraph();
bool readPLCList(MsWrdEntry const &entry);
bool readTextStructList(MsWrdEntry &entry);
int readPropertyModifier(bool &complex, std::string &extra);
bool readPLC(MsWrdEntry &entry, int type, MWAWVec2<long> const &fileLimit);
// section:
bool getSection(ZoneType type, int id, MsWrdStruct::Section &section);
bool getSectionParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para);
bool getSectionFont(ZoneType type, int id, MsWrdStruct::Font &font);
bool readSection(MsWrdEntry &entry, std::vector<long> &cLimits);
bool sendSection(int id, int textStructId);
bool readSection(MsWrdStruct::Section &section, long pos);
void setProperty(MsWrdStruct::Section const &sec);
// style
bool readStyles(MsWrdEntry &entry);
bool readStylesHierarchy(MsWrdEntry &entry, int N, std::vector<int> &orig);
bool readStylesNames(MsWrdEntry const &zone, int N, int &Nnamed);
bool readStylesFont(MsWrdEntry &zone, int N, std::vector<int> const &previous,
std::vector<int> const &order);
bool readStylesParagraph(MsWrdEntry &zone, int N, std::vector<int> const &previous,
std::vector<int> const &order);
std::map<int,int> const &getNextStyleMap() const;
static std::vector<int> orderStyles(std::vector<int> const &previous);
private:
MsWrdTextStyles(MsWrdTextStyles const &orig) = delete;
MsWrdTextStyles &operator=(MsWrdTextStyles const &orig) = delete;
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
std::shared_ptr<MsWrdTextStylesInternal::State> m_state;
MsWrdParser *m_mainParser;
MsWrdText *m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry.hxx
MWAWParagraph.hxx
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
MWAWVec2
small class which defines a vector with 2 elements
Definition libmwaw_internal.hxx:656
MsWrdParser
the main class to read a Microsoft Word file
Definition MsWrdParser.hxx:98
MsWrdTextStyles::readTextStructList
bool readTextStructList(MsWrdEntry &entry)
read the paragraphs at the beginning of the text structure zone
Definition MsWrdTextStyles.cxx:806
MsWrdTextStyles::getNextStyleMap
std::map< int, int > const & getNextStyleMap() const
returns the style id to next style id map
Definition MsWrdTextStyles.cxx:1092
MsWrdTextStyles::~MsWrdTextStyles
virtual ~MsWrdTextStyles()
destructor
Definition MsWrdTextStyles.cxx:103
MsWrdTextStyles::m_textParser
MsWrdText * m_textParser
the text parser;
Definition MsWrdTextStyles.hxx:165
MsWrdTextStyles::m_state
std::shared_ptr< MsWrdTextStylesInternal::State > m_state
the state
Definition MsWrdTextStyles.hxx:159
MsWrdTextStyles::readParagraph
bool readParagraph(MsWrdStruct::Paragraph &para, int dataSz=-1)
try to read a paragraph
Definition MsWrdTextStyles.cxx:389
MsWrdTextStyles::MsWrdTextStyles
MsWrdTextStyles(MsWrdText &textParser)
constructor
Definition MsWrdTextStyles.cxx:95
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:1287
MsWrdTextStyles::getParagraph
bool getParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para)
return a paragraph corresponding to an index
Definition MsWrdTextStyles.cxx:353
MsWrdTextStyles::getSection
bool getSection(ZoneType type, int id, MsWrdStruct::Section &section)
return a section corresponding to an index
Definition MsWrdTextStyles.cxx:904
MsWrdTextStyles::getDefaultFont
MWAWFont const & getDefaultFont() const
returns the default font
Definition MsWrdTextStyles.cxx:113
MsWrdTextStyles::m_mainParser
MsWrdParser * m_mainParser
the main parser;
Definition MsWrdTextStyles.hxx:162
MsWrdTextStyles::sendSection
bool sendSection(int id, int textStructId)
try to send a section
Definition MsWrdTextStyles.cxx:1070
MsWrdTextStyles::sendDefaultParagraph
void sendDefaultParagraph()
send a default paragraph
Definition MsWrdTextStyles.cxx:383
MsWrdTextStyles::readPLC
bool readPLC(MsWrdEntry &entry, int type, MWAWVec2< long > const &fileLimit)
read the char/paragraph plc : type=0: char, type=1: parag
Definition MsWrdTextStyles.cxx:652
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:1176
MsWrdTextStyles::readSection
bool readSection(MsWrdEntry &entry, std::vector< long > &cLimits)
read the text section
Definition MsWrdTextStyles.cxx:951
MsWrdTextStyles::readPLCList
bool readPLCList(MsWrdEntry const &entry)
read the main char/paragraph plc list
Definition MsWrdTextStyles.cxx:601
MsWrdTextStyles::readPropertyModifier
int readPropertyModifier(bool &complex, std::string &extra)
read the property modifier (2 bytes last bytes of text struct ).
Definition MsWrdTextStyles.cxx:865
MsWrdTextStyles::version
int version() const
returns the file version
Definition MsWrdTextStyles.cxx:106
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:1226
MsWrdTextStyles::getSectionParagraph
bool getSectionParagraph(ZoneType type, int id, MsWrdStruct::Paragraph &para)
return a paragraph corresponding to the section
Definition MsWrdTextStyles.cxx:925
MsWrdTextStyles::MsWrdTextStyles
MsWrdTextStyles(MsWrdTextStyles const &orig)=delete
MsWrdTextStyles::readFont
bool readFont(MsWrdStruct::Font &font, ZoneType type)
try to read a font.
Definition MsWrdTextStyles.cxx:121
MsWrdTextStyles::MsWrdText
friend class MsWrdText
Definition MsWrdTextStyles.hxx:69
MsWrdTextStyles::getFont
bool getFont(ZoneType type, int id, MsWrdStruct::Font &actFont)
return a font corresponding to an index
Definition MsWrdTextStyles.cxx:304
MsWrdTextStyles::ZoneType
ZoneType
Definition MsWrdTextStyles.hxx:71
MsWrdTextStyles::TextStructZone
@ TextStructZone
Definition MsWrdTextStyles.hxx:71
MsWrdTextStyles::InParagraphDefinition
@ InParagraphDefinition
Definition MsWrdTextStyles.hxx:71
MsWrdTextStyles::TextZone
@ TextZone
Definition MsWrdTextStyles.hxx:71
MsWrdTextStyles::StyleZone
@ StyleZone
Definition MsWrdTextStyles.hxx:71
MsWrdTextStyles::readStylesHierarchy
bool readStylesHierarchy(MsWrdEntry &entry, int N, std::vector< int > &orig)
try to read the styles hierachy
Definition MsWrdTextStyles.cxx:1374
MsWrdTextStyles::readStyles
bool readStyles(MsWrdEntry &entry)
try to read the styles zone
Definition MsWrdTextStyles.cxx:1097
MsWrdTextStyles::operator=
MsWrdTextStyles & operator=(MsWrdTextStyles const &orig)=delete
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:1440
MsWrdTextStyles::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition MsWrdTextStyles.hxx:156
MsWrdTextStyles::getSectionFont
bool getSectionFont(ZoneType type, int id, MsWrdStruct::Font &font)
return a font corresponding to the section
Definition MsWrdTextStyles.cxx:933
MsWrdTextStyles::setProperty
void setProperty(MsWrdStruct::Font const &font)
Definition MsWrdTextStyles.cxx:340
MsWrdText
the main class to read the text part of Microsoft Word file
Definition MsWrdText.hxx:65
libmwaw_internal.hxx
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
MsWrdStruct
namespace to store the main structure which appears in a Microsoft Word 3.0-5.0 file
Definition MsWrdStruct.cxx:42
MsWrdTextStylesInternal
Internal: the structures of a MsWrdTextStyles.
Definition MsWrdTextStyles.cxx:46
MsWrdEntry
the entry of MsWrdParser
Definition MsWrdParser.hxx:63
MsWrdStruct::Font
the font structure of a Microsoft Word file
Definition MsWrdStruct.hxx:57
MsWrdStruct::Paragraph
the paragraph structure of a Microsoft Word file
Definition MsWrdStruct.hxx:312
MsWrdStruct::Section
the section structure of a Microsoft Word file
Definition MsWrdStruct.hxx:118
MsWrdTextStylesInternal::State
Internal: the state of a MsWrdTextStylesInternal.
Definition MsWrdTextStyles.cxx:49