MacWrtProStructures.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.
*/
#ifndef MAC_WRT_PRO_STRUCTURES
# define MAC_WRT_PRO_STRUCTURES
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWPosition.hxx"
#include "MWAWStream.hxx"
class MacWrtProParser;
namespace MacWrtProParserInternal
{
class SubDocument;
}
namespace MacWrtProStructuresInternal
{
struct Graphic;
struct Page;
struct Cell;
struct Font;
struct Paragraph;
struct Section;
struct State;
class SubDocument;
}
class MacWrtProStructures;
class MacWrtProStructuresListenerState
{
public:
MacWrtProStructuresListenerState(std::shared_ptr<MacWrtProStructures> const &structures, bool mainZone, int version);
~MacWrtProStructuresListenerState();
bool isSent(int graphicId);
bool send(int graphicId);
void sendSection(int numSection);
bool sendFont(int id);
bool sendParagraph(int id);
void sendChar(char c);
int numSection() const
{
if (!m_isMainZone) {
MWAW_DEBUG_MSG(("MacWrtProStructuresListenerState::numSection: not called in main zone\n"));
return 0;
}
return m_section;
}
std::vector<int> getPageBreaksPos() const;
void insertSoftPageBreak();
protected:
bool newPage(bool softBreak=false);
// true if this is the mainZone
bool m_isMainZone;
// the file version
int m_version;
// the actual page
int m_actPage;
// the actual tab
int m_actTab;
// the number of tab
int m_numTab;
// the actual section ( if mainZone )
int m_section;
// the actual number of columns
int m_numCols;
// a flag to know if a new page has just been open
bool m_newPageDone;
// the main structure parser
std::shared_ptr<MacWrtProStructures> m_structures;
};
class MacWrtProStructures
{
friend class MacWrtProParser;
friend class MacWrtProParserInternal::SubDocument;
friend struct MacWrtProStructuresInternal::Cell;
friend class MacWrtProStructuresListenerState;
public:
explicit MacWrtProStructures(MacWrtProParser &mainParser);
virtual ~MacWrtProStructures();
int version() const;
protected:
void init();
bool createZones(std::shared_ptr<MWAWStream> &stream, int numPages);
bool createZonesII(std::shared_ptr<MWAWStream> &stream, int numPages);
int numPages() const;
bool sendMainZone();
void updatePageSpan(int page, bool hasTitlePage, MWAWPageSpan &pageSpan);
void flushExtra();
void buildPageStructures();
void buildTableStructures();
//
// low level
//
bool readStyles(std::shared_ptr<MWAWStream> &stream);
bool readStyle(std::shared_ptr<MWAWStream> &stream, int styleId);
bool readCharStyles(std::shared_ptr<MWAWStream> &stream);
bool readParagraphs(std::shared_ptr<MWAWStream> &stream);
bool readParagraph(std::shared_ptr<MWAWStream> &stream, MacWrtProStructuresInternal::Paragraph &para);
bool readGraphicsList(std::shared_ptr<MWAWStream> &stream, int nuumPages);
std::shared_ptr<MacWrtProStructuresInternal::Graphic> readGraphic(std::shared_ptr<MWAWStream> &stream);
bool readPagesListII(std::shared_ptr<MWAWStream> const &stream, int numPages);
bool readPageII(std::shared_ptr<MWAWStream> const &stream, int wh, MacWrtProStructuresInternal::Page &page);
bool readGraphicII(std::shared_ptr<MWAWStream> const &stream, int id, bool mainGraphic, MacWrtProStructuresInternal::Graphic &graphic);
bool readFontsName(std::shared_ptr<MWAWStream> &stream);
bool readFontsDef(std::shared_ptr<MWAWStream> &stream);
bool readFont(std::shared_ptr<MWAWStream> &stream, MacWrtProStructuresInternal::Font &font);
bool readSections(std::shared_ptr<MWAWStream> &stream, std::vector<MacWrtProStructuresInternal::Section> &sections);
bool readSelection(std::shared_ptr<MWAWStream> &stream);
bool readStructB(std::shared_ptr<MWAWStream> &stream);
static bool readString(MWAWInputStreamPtr input, std::string &res);
bool getColor(int colId, MWAWColor &color) const;
bool getPattern(int patId, float &patternPercent) const;
bool getColor(int colId, int patId, MWAWColor &color) const;
bool isSent(int graphicId);
bool send(int graphicId, bool mainZone=false);
MWAWTextListenerPtr &getTextListener();
protected:
//
// data
//
MWAWParserStatePtr m_parserState;
MacWrtProParser &m_mainParser;
std::shared_ptr<MacWrtProStructuresInternal::State> m_state;
std::string m_asciiName;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWEntry.hxx
MWAWInputStream.hxx
MWAWPosition.hxx
MWAWStream.hxx
MWAWPageSpan
A class which defines the page properties.
Definition MWAWPageSpan.hxx:99
MacWrtProParserInternal::SubDocument
Internal: the subdocument of a MacWrtProParser.
Definition MacWrtProParser.cxx:255
MacWrtProParser
the main class to read a MacWrite II and MacWrite Pro file
Definition MacWrtProParser.hxx:68
MacWrtProStructuresListenerState::m_numTab
int m_numTab
Definition MacWrtProStructures.hxx:119
MacWrtProStructuresListenerState::MacWrtProStructuresListenerState
MacWrtProStructuresListenerState(std::shared_ptr< MacWrtProStructures > const &structures, bool mainZone, int version)
the constructor
Definition MacWrtProStructures.cxx:2832
MacWrtProStructuresListenerState::sendChar
void sendChar(char c)
send a character
Definition MacWrtProStructures.cxx:2933
MacWrtProStructuresListenerState::newPage
bool newPage(bool softBreak=false)
create a new page
Definition MacWrtProStructures.cxx:2879
MacWrtProStructuresListenerState::m_structures
std::shared_ptr< MacWrtProStructures > m_structures
Definition MacWrtProStructures.hxx:127
MacWrtProStructuresListenerState::sendFont
bool sendFont(int id)
try to send a character style
Definition MacWrtProStructures.cxx:3008
MacWrtProStructuresListenerState::insertSoftPageBreak
void insertSoftPageBreak()
insert a page break ( if we are not on a new page )
Definition MacWrtProStructures.cxx:2873
MacWrtProStructuresListenerState::send
bool send(int graphicId)
try to send a graphic which corresponds to graphicid
Definition MacWrtProStructures.cxx:2863
MacWrtProStructuresListenerState::isSent
bool isSent(int graphicId)
returns true if the graphic is already sent ( or does not exists)
Definition MacWrtProStructures.cxx:2857
MacWrtProStructuresListenerState::sendParagraph
bool sendParagraph(int id)
try to send a paragraph
Definition MacWrtProStructures.cxx:3022
MacWrtProStructuresListenerState::m_actPage
int m_actPage
Definition MacWrtProStructures.hxx:115
MacWrtProStructuresListenerState::m_section
int m_section
Definition MacWrtProStructures.hxx:121
MacWrtProStructuresListenerState::m_version
int m_version
Definition MacWrtProStructures.hxx:113
MacWrtProStructuresListenerState::m_numCols
int m_numCols
Definition MacWrtProStructures.hxx:123
MacWrtProStructuresListenerState::sendSection
void sendSection(int numSection)
try to send the i^th section
Definition MacWrtProStructures.cxx:3037
MacWrtProStructuresListenerState::numSection
int numSection() const
returns the actual section
Definition MacWrtProStructures.hxx:92
MacWrtProStructuresListenerState::getPageBreaksPos
std::vector< int > getPageBreaksPos() const
return a list of page break position ( as some page break are soft )
Definition MacWrtProStructures.cxx:2910
MacWrtProStructuresListenerState::m_newPageDone
bool m_newPageDone
Definition MacWrtProStructures.hxx:125
MacWrtProStructuresListenerState::~MacWrtProStructuresListenerState
~MacWrtProStructuresListenerState()
the destructor
Definition MacWrtProStructures.cxx:2853
MacWrtProStructuresListenerState::m_isMainZone
bool m_isMainZone
Definition MacWrtProStructures.hxx:111
MacWrtProStructuresListenerState::m_actTab
int m_actTab
Definition MacWrtProStructures.hxx:117
MacWrtProStructures
the main class to read the structures part of MacWrite Pro file
Definition MacWrtProStructures.hxx:136
MacWrtProStructures::MacWrtProParser
friend class MacWrtProParser
Definition MacWrtProStructures.hxx:137
MacWrtProStructures::createZones
bool createZones(std::shared_ptr< MWAWStream > &stream, int numPages)
finds the different objects zones
Definition MacWrtProStructures.cxx:918
MacWrtProStructures::readSelection
bool readSelection(std::shared_ptr< MWAWStream > &stream)
try to read a 16 bytes the zone which follow the char styles zone ( the selection?...
Definition MacWrtProStructures.cxx:2555
MacWrtProStructures::readGraphicII
bool readGraphicII(std::shared_ptr< MWAWStream > const &stream, int id, bool mainGraphic, MacWrtProStructuresInternal::Graphic &graphic)
try to read a graphic structure: II
Definition MacWrtProStructures.cxx:1944
MacWrtProStructures::getColor
bool getColor(int colId, MWAWColor &color) const
try to return the color corresponding to colId
Definition MacWrtProStructures.cxx:819
MacWrtProStructures::readPagesListII
bool readPagesListII(std::shared_ptr< MWAWStream > const &stream, int numPages)
try to parse the list of page: II
Definition MacWrtProStructures.cxx:1869
MacWrtProStructures::readFont
bool readFont(std::shared_ptr< MWAWStream > &stream, MacWrtProStructuresInternal::Font &font)
try to read a font
Definition MacWrtProStructures.cxx:1351
MacWrtProStructures::readString
static bool readString(MWAWInputStreamPtr input, std::string &res)
try to read a string
Definition MacWrtProStructures.cxx:2594
MacWrtProStructures::readStructB
bool readStructB(std::shared_ptr< MWAWStream > &stream)
try to read a zone which follow the fonts zone(checkme)
Definition MacWrtProStructures.cxx:2627
MacWrtProStructures::init
void init()
inits all internal variables
Definition MacWrtProStructures.cxx:743
MacWrtProStructures::readStyles
bool readStyles(std::shared_ptr< MWAWStream > &stream)
try to read the paragraph styles zone which begins at address 0x200
Definition MacWrtProStructures.cxx:1733
MacWrtProStructures::readGraphic
std::shared_ptr< MacWrtProStructuresInternal::Graphic > readGraphic(std::shared_ptr< MWAWStream > &stream)
try to read a graphic entry: 1.0, 1.5
Definition MacWrtProStructures.cxx:2156
MacWrtProStructures::numPages
int numPages() const
returns the number of pages
Definition MacWrtProStructures.cxx:760
MacWrtProStructures::readStyle
bool readStyle(std::shared_ptr< MWAWStream > &stream, int styleId)
try to read a style
Definition MacWrtProStructures.cxx:1775
MacWrtProStructures::version
int version() const
returns the file version.
Definition MacWrtProStructures.cxx:748
MacWrtProStructures::readFontsDef
bool readFontsDef(std::shared_ptr< MWAWStream > &stream)
try to read the list of fonts
Definition MacWrtProStructures.cxx:1304
MacWrtProStructures::m_state
std::shared_ptr< MacWrtProStructuresInternal::State > m_state
the state
Definition MacWrtProStructures.hxx:268
MacWrtProStructures::buildPageStructures
void buildPageStructures()
look for pages structures
Definition MacWrtProStructures.cxx:1116
MacWrtProStructures::MacWrtProStructures
MacWrtProStructures(MacWrtProParser &mainParser)
constructor
Definition MacWrtProStructures.cxx:730
MacWrtProStructures::m_mainParser
MacWrtProParser & m_mainParser
the main parser
Definition MacWrtProStructures.hxx:265
MacWrtProStructures::readFontsName
bool readFontsName(std::shared_ptr< MWAWStream > &stream)
try to read the fonts zone
Definition MacWrtProStructures.cxx:1238
MacWrtProStructures::readParagraph
bool readParagraph(std::shared_ptr< MWAWStream > &stream, MacWrtProStructuresInternal::Paragraph &para)
try to read a paragraph
Definition MacWrtProStructures.cxx:1489
MacWrtProStructures::flushExtra
void flushExtra()
flush not send zones
Definition MacWrtProStructures.cxx:2768
MacWrtProStructures::readPageII
bool readPageII(std::shared_ptr< MWAWStream > const &stream, int wh, MacWrtProStructuresInternal::Page &page)
try to read a page entry: II
Definition MacWrtProStructures.cxx:1889
MacWrtProStructures::isSent
bool isSent(int graphicId)
returns true if the graphic is already sent ( or does not exists)
Definition MacWrtProStructures.cxx:2671
MacWrtProStructures::readSections
bool readSections(std::shared_ptr< MWAWStream > &stream, std::vector< MacWrtProStructuresInternal::Section > &sections)
try to read the section info ?
Definition MacWrtProStructures.cxx:2431
MacWrtProStructures::readParagraphs
bool readParagraphs(std::shared_ptr< MWAWStream > &stream)
try to read a list of paragraph
Definition MacWrtProStructures.cxx:1439
MacWrtProStructures::send
bool send(int graphicId, bool mainZone=false)
try to send a graphic which corresponds to graphicid
Definition MacWrtProStructures.cxx:2682
MacWrtProStructures::createZonesII
bool createZonesII(std::shared_ptr< MWAWStream > &stream, int numPages)
finds the different objects zones in a MacWriteII file
Definition MacWrtProStructures.cxx:1019
MacWrtProStructures::buildTableStructures
void buildTableStructures()
look for tables structures and if so, prepare data
Definition MacWrtProStructures.cxx:1181
MacWrtProStructures::getPattern
bool getPattern(int patId, float &patternPercent) const
try to return the pattern corresponding to patId
Definition MacWrtProStructures.cxx:877
MacWrtProStructures::~MacWrtProStructures
virtual ~MacWrtProStructures()
destructor
Definition MacWrtProStructures.cxx:739
MacWrtProStructures::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the actual listener
Definition MacWrtProStructures.cxx:755
MacWrtProStructures::updatePageSpan
void updatePageSpan(int page, bool hasTitlePage, MWAWPageSpan &pageSpan)
update the page span
Definition MacWrtProStructures.cxx:767
MacWrtProStructures::readGraphicsList
bool readGraphicsList(std::shared_ptr< MWAWStream > &stream, int nuumPages)
try to read the list of graphic entries: 1.0 1.5
Definition MacWrtProStructures.cxx:2070
MacWrtProStructures::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition MacWrtProStructures.hxx:262
MacWrtProStructures::readCharStyles
bool readCharStyles(std::shared_ptr< MWAWStream > &stream)
try to read the character styles zone
Definition MacWrtProStructures.cxx:1645
MacWrtProStructures::m_asciiName
std::string m_asciiName
the debug file name
Definition MacWrtProStructures.hxx:271
MacWrtProStructures::MacWrtProStructuresListenerState
friend class MacWrtProStructuresListenerState
Definition MacWrtProStructures.hxx:140
MacWrtProStructures::sendMainZone
bool sendMainZone()
send the main zone
Definition MacWrtProStructures.cxx:1086
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
MWAWTextListenerPtr
std::shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition libmwaw_internal.hxx:567
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition libmwaw_internal.hxx:129
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MacWrtProParserInternal
Internal: the structures of a MacWrtProParser.
Definition MacWrtProParser.cxx:62
MacWrtProStructuresInternal
Internal: the structures of a MacWrtProStructures.
Definition MacWrtProStructures.cxx:59
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MacWrtProStructuresInternal::Cell
Internal: the cell of a MacWrtProStructure.
Definition MacWrtProStructures.cxx:492
MacWrtProStructuresInternal::Font
Internal: the fonts.
Definition MacWrtProStructures.cxx:425
MacWrtProStructuresInternal::Graphic
Internal: the graphic structure.
Definition MacWrtProStructures.cxx:61
MacWrtProStructuresInternal::Page
Internal: a page.
Definition MacWrtProStructures.cxx:395
MacWrtProStructuresInternal::Paragraph
Internal: class to store the paragraph properties.
Definition MacWrtProStructures.cxx:464
MacWrtProStructuresInternal::Section
Internal: the section of a MacWrtProStructures.
Definition MacWrtProStructures.cxx:558
MacWrtProStructuresInternal::State
Internal: the state of a MacWrtProStructures.
Definition MacWrtProStructures.cxx:647