MSWTextStyles.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 MSW_TEXT_STYLES
# define MSW_TEXT_STYLES
#include <iostream>
#include <map>
#include <string>
#include "libmwaw_internal.hxx"
#include "MWAWEntry.hxx"
#include "MWAWParagraph.hxx"
class MSWParser;
class MSWText;
namespace MSWStruct
{
struct Font;
struct Paragraph;
struct Section;
}
namespace MSWTextStylesInternal
{
struct State;
}
class MSWTextStyles
{
friend class MSWText;
public:
enum ZoneType { TextZone, TextStructZone, StyleZone, InParagraphDefinition };
MSWTextStyles(MSWText &textParser);
virtual ~MSWTextStyles();
int version() const;
protected:
// font:
MWAWFont const &getDefaultFont() const;
bool getFont(ZoneType type, int id, MSWStruct::Font &actFont);
/* send a font */
void setProperty(MSWStruct::Font const &font);
bool readFont(MSWStruct::Font &font, ZoneType type);
// pararagraph:
bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1);
void sendDefaultParagraph();
void setProperty(MSWStruct::Paragraph const &para, bool recursifCall=false);
bool readPLCList(MSWEntry &entry);
bool readTextStructList(MSWEntry &entry);
int readPropertyModifier(bool &complex, std::string &extra);
bool readPLC(MSWEntry &entry, int type, Vec2<long> const &fileLimit);
// section:
bool getSection(ZoneType type, int id, MSWStruct::Section &section);
bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para);
bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font);
bool readSection(MSWEntry &entry, std::vector<long> &cLimits);
bool sendSection(int id, int textStructId);
bool readSection(MSWStruct::Section &section, long pos);
void setProperty(MSWStruct::Section const &sec);
// style
bool readStyles(MSWEntry &entry);
bool readStylesHierarchy(MSWEntry &entry, int N, std::vector<int> &orig);
bool readStylesNames(MSWEntry const &zone, int N, int &Nnamed);
bool readStylesFont(MSWEntry &zone, int N, std::vector<int> const &previous,
std::vector<int> const &order);
bool readStylesParagraph(MSWEntry &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:
MSWTextStyles(MSWTextStyles const &orig);
MSWTextStyles &operator=(MSWTextStyles const &orig);
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
shared_ptr<MSWTextStylesInternal::State> m_state;
MSWParser *m_mainParser;
MSWText *m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MSWStruct::Section
the section structure of a Microsoft Word file
Definition: MSWStruct.hxx:109
MSWTextStyles::ZoneType
ZoneType
Definition: MSWTextStyles.hxx:70
MSWTextStyles::operator=
MSWTextStyles & operator=(MSWTextStyles const &orig)
MSWTextStyles::readStylesNames
bool readStylesNames(MSWEntry const &zone, int N, int &Nnamed)
try to read the styles names and fill the number of "named" styles...
Definition: MSWTextStyles.cxx:1181
MSWTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:66
MWAWEntry.hxx
libmwaw_internal.hxx
MSWTextStyles::TextStructZone
Definition: MSWTextStyles.hxx:70
MSWTextStyles::readParagraph
bool readParagraph(MSWStruct::Paragraph &para, int dataSz=-1)
try to read a paragraph
Definition: MSWTextStyles.cxx:372
MSWStruct::Paragraph
the paragraph structure of a Microsoft Word file
Definition: MSWStruct.hxx:286
MSWTextStyles::readTextStructList
bool readTextStructList(MSWEntry &entry)
read the paragraphs at the beginning of the text structure zone
Definition: MSWTextStyles.cxx:818
MSWParser
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
MSWTextStyles::readPropertyModifier
int readPropertyModifier(bool &complex, std::string &extra)
read the property modifier (2 bytes last bytes of text struct ).
Definition: MSWTextStyles.cxx:876
MSWEntry
the entry of MSWParser
Definition: MSWParser.hxx:63
MSWTextStyles::version
int version() const
returns the file version
Definition: MSWTextStyles.cxx:97
MSWTextStyles::~MSWTextStyles
virtual ~MSWTextStyles()
destructor
Definition: MSWTextStyles.cxx:94
MSWTextStyles::readPLC
bool readPLC(MSWEntry &entry, int type, Vec2< long > const &fileLimit)
read the char/paragraph plc : type=0: char, type=1: parag
Definition: MSWTextStyles.cxx:672
MSWText
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:64
MSWTextStyles::getDefaultFont
MWAWFont const & getDefaultFont() const
returns the default font
Definition: MSWTextStyles.cxx:104
MSWTextStyles::InParagraphDefinition
Definition: MSWTextStyles.hxx:70
MSWTextStyles::readStylesParagraph
bool readStylesParagraph(MSWEntry &zone, int N, std::vector< int > const &previous, std::vector< int > const &order)
try to read the styles fonts
Definition: MSWTextStyles.cxx:1289
MSWTextStyles::m_mainParser
MSWParser * m_mainParser
the main parser;
Definition: MSWTextStyles.hxx:164
MSWTextStyles::m_state
shared_ptr< MSWTextStylesInternal::State > m_state
the state
Definition: MSWTextStyles.hxx:161
MSWTextStyles::sendSection
bool sendSection(int id, int textStructId)
try to send a section
Definition: MSWTextStyles.cxx:1075
MSWTextStyles::orderStyles
static std::vector< int > orderStyles(std::vector< int > const &previous)
try to reorder the styles to find a good order
Definition: MSWTextStyles.cxx:1439
MSWTextStyles::m_textParser
MSWText * m_textParser
the text parser;
Definition: MSWTextStyles.hxx:167
MSWTextStyles::getSection
bool getSection(ZoneType type, int id, MSWStruct::Section &section)
return a section corresponding to an index
Definition: MSWTextStyles.cxx:914
MSWTextStyles::sendDefaultParagraph
void sendDefaultParagraph()
send a default paragraph
Definition: MSWTextStyles.cxx:365
MSWTextStyles::readStylesFont
bool readStylesFont(MSWEntry &zone, int N, std::vector< int > const &previous, std::vector< int > const &order)
try to read the styles fonts
Definition: MSWTextStyles.cxx:1227
MSWTextStyles::readStyles
bool readStyles(MSWEntry &entry)
try to read the styles zone
Definition: MSWTextStyles.cxx:1102
MSWTextStyles::MSWTextStyles
MSWTextStyles(MSWText &textParser)
constructor
Definition: MSWTextStyles.cxx:88
MSWTextStyles::readFont
bool readFont(MSWStruct::Font &font, ZoneType type)
try to read a font.
Definition: MSWTextStyles.cxx:112
MSWTextStyles::readStylesHierarchy
bool readStylesHierarchy(MSWEntry &entry, int N, std::vector< int > &orig)
try to read the styles hierachy
Definition: MSWTextStyles.cxx:1376
MSWTextStyles::TextZone
Definition: MSWTextStyles.hxx:70
MSWTextStyles::setProperty
void setProperty(MSWStruct::Font const &font)
Definition: MSWTextStyles.cxx:324
MSWTextStyles::StyleZone
Definition: MSWTextStyles.hxx:70
MSWTextStyles::readPLCList
bool readPLCList(MSWEntry &entry)
read the main char/paragraph plc list
Definition: MSWTextStyles.cxx:622
MSWStruct::Font
the font structure of a Microsoft Word file
Definition: MSWStruct.hxx:57
MSWTextStyles::getFont
bool getFont(ZoneType type, int id, MSWStruct::Font &actFont)
return a font corresponding to an index
Definition: MSWTextStyles.cxx:290
MSWTextStyles::getSectionFont
bool getSectionFont(ZoneType type, int id, MSWStruct::Font &font)
return a font corresponding to the section
Definition: MSWTextStyles.cxx:942
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:342
MSWTextStyles::getNextStyleMap
std::map< int, int > const & getNextStyleMap() const
returns the style id to next style id map
Definition: MSWTextStyles.cxx:1097
MSWTextStyles::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MSWTextStyles.hxx:158
Vec2< long >
MSWTextStyles::getSectionParagraph
bool getSectionParagraph(ZoneType type, int id, MSWStruct::Paragraph &para)
return a paragraph corresponding to the section
Definition: MSWTextStyles.cxx:934
MSWTextStyles::readSection
bool readSection(MSWEntry &entry, std::vector< long > &cLimits)
read the text section
Definition: MSWTextStyles.cxx:960
MWAWParagraph.hxx
MSWTextStyles::getParagraph
bool getParagraph(ZoneType type, int id, MSWStruct::Paragraph &para)
return a paragraph corresponding to an index
Definition: MSWTextStyles.cxx:337