| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Major Contributor(s): |
| 17 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 18 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 19 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 20 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 21 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 22 |
* |
| 23 |
* |
| 24 |
* All Rights Reserved. |
| 25 |
* |
| 26 |
* For minor contributions see the git repository. |
| 27 |
* |
| 28 |
* Alternatively, the contents of this file may be used under the terms of |
| 29 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 30 |
* in which case the provisions of the LGPLv2+ are applicable |
| 31 |
* instead of those above. |
| 32 |
*/ |
| 33 |
|
| 34 |
/* |
| 35 |
* Parser to Nisus text document |
| 36 |
* |
| 37 |
*/ |
| 38 |
#ifndef NISUS_WRT_TEXT |
| 39 |
# define NISUS_WRT_TEXT |
| 40 |
|
| 41 |
#include "libmwaw_internal.hxx" |
| 42 |
#include "MWAWDebug.hxx" |
| 43 |
|
| 44 |
#include "NisusWrtStruct.hxx" |
| 45 |
|
| 46 |
namespace NisusWrtTextInternal |
| 47 |
{ |
| 48 |
class SubDocument; |
| 49 |
struct Paragraph; |
| 50 |
struct State; |
| 51 |
} |
| 52 |
|
| 53 |
class NisusWrtParser; |
| 54 |
|
| 55 |
/** \brief the main class to read the text part of Nisus file |
| 56 |
* |
| 57 |
* |
| 58 |
* |
| 59 |
*/ |
| 60 |
class NisusWrtText |
| 61 |
{ |
| 62 |
friend class NisusWrtTextInternal::SubDocument; |
| 63 |
friend class NisusWrtParser; |
| 64 |
public: |
| 65 |
//! constructor |
| 66 |
explicit NisusWrtText(NisusWrtParser &parser); |
| 67 |
//! destructor |
| 68 |
virtual ~NisusWrtText(); |
| 69 |
|
| 70 |
/** returns the file version */ |
| 71 |
int version() const; |
| 72 |
|
| 73 |
/** returns the number of pages */ |
| 74 |
int numPages() const; |
| 75 |
|
| 76 |
protected: |
| 77 |
|
| 78 |
//! finds the different text zones |
| 79 |
bool createZones(); |
| 80 |
|
| 81 |
//! return an header subdocument |
| 82 |
std::shared_ptr<MWAWSubDocument> getHeader(int page, int &numSimillar); |
| 83 |
//! return a footer subdocument |
| 84 |
std::shared_ptr<MWAWSubDocument> getFooter(int page, int &numSimillar); |
| 85 |
|
| 86 |
//! send a main zone |
| 87 |
bool sendMainText(); |
| 88 |
|
| 89 |
//! sends the data which have not yet been sent to the listener |
| 90 |
void flushExtra(); |
| 91 |
|
| 92 |
/** read a text entry. |
| 93 |
\note entry.id() must correspond to the zone id. |
| 94 |
\note while the main text is in the data fork, the footnote/header footer is in a ??TX rsrc.*/ |
| 95 |
bool sendText(MWAWEntry const &entry, NisusWrtStruct::Position fPos=NisusWrtStruct::Position()); |
| 96 |
|
| 97 |
/** try to send the ith footnote */ |
| 98 |
bool sendFootnote(int footnoteId); |
| 99 |
|
| 100 |
/** try to send the ith header footer */ |
| 101 |
bool sendHeaderFooter(int hfId); |
| 102 |
|
| 103 |
// |
| 104 |
// intermediate level |
| 105 |
// |
| 106 |
|
| 107 |
/** compute the positions */ |
| 108 |
void computePositions(); |
| 109 |
|
| 110 |
/** sends a paragraph property to the listener */ |
| 111 |
void setProperty(NisusWrtTextInternal::Paragraph const &ruler, int width); |
| 112 |
|
| 113 |
//! read the list of fonts |
| 114 |
bool readFontsList(MWAWEntry const &entry); |
| 115 |
/** read the header/footer main entry */ |
| 116 |
bool readHeaderFooter(MWAWEntry const &entry); |
| 117 |
/** read the footnote main entry */ |
| 118 |
bool readFootnotes(MWAWEntry const &entry); |
| 119 |
|
| 120 |
//! read the FTAB/STYL resource: a list of fonts |
| 121 |
bool readFonts(MWAWEntry const &entry); |
| 122 |
//! read the FRMT resource: a list of filepos -> fontId |
| 123 |
bool readPosToFont(MWAWEntry const &entry, NisusWrtStruct::ZoneType zoneId); |
| 124 |
|
| 125 |
//! read the RULE resource: a list of paragraphs |
| 126 |
bool readParagraphs(MWAWEntry const &entry, NisusWrtStruct::ZoneType zoneId); |
| 127 |
|
| 128 |
//! read the PICD resource: a list of pict link to the paragraph |
| 129 |
bool readPICD(MWAWEntry const &entry, NisusWrtStruct::ZoneType zoneId); |
| 130 |
|
| 131 |
// |
| 132 |
// low level |
| 133 |
// |
| 134 |
|
| 135 |
//! find the file pos which correspond to a pos |
| 136 |
long findFilePos(NisusWrtStruct::ZoneType zoneId, NisusWrtStruct::Position const &pos); |
| 137 |
private: |
| 138 |
NisusWrtText(NisusWrtText const &orig) = delete; |
| 139 |
NisusWrtText &operator=(NisusWrtText const &orig) = delete; |
| 140 |
|
| 141 |
protected: |
| 142 |
// |
| 143 |
// data |
| 144 |
// |
| 145 |
//! the parser state |
| 146 |
MWAWParserStatePtr m_parserState; |
| 147 |
|
| 148 |
//! the state |
| 149 |
std::shared_ptr<NisusWrtTextInternal::State> m_state; |
| 150 |
|
| 151 |
//! the main parser; |
| 152 |
NisusWrtParser *m_mainParser; |
| 153 |
|
| 154 |
}; |
| 155 |
#endif |
| 156 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |