| 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 |
#ifndef MS_WKS4_ZONE |
| 35 |
# define MS_WKS4_ZONE |
| 36 |
|
| 37 |
#include <map> |
| 38 |
#include <string> |
| 39 |
|
| 40 |
#include "MWAWDebug.hxx" |
| 41 |
#include "MWAWEntry.hxx" |
| 42 |
#include "MWAWInputStream.hxx" |
| 43 |
|
| 44 |
#include "MWAWParser.hxx" |
| 45 |
|
| 46 |
#include "MsWksDocument.hxx" |
| 47 |
|
| 48 |
class MsWksParser; |
| 49 |
class MsWksDRParser; |
| 50 |
|
| 51 |
namespace MsWks4ZoneInternal |
| 52 |
{ |
| 53 |
struct State; |
| 54 |
} |
| 55 |
|
| 56 |
/** The class which parses the main zones of a mac MS Works document v4 |
| 57 |
* |
| 58 |
* This class must be associated with a MsWksParser or a MsWksDocument, which gives it the oles to parse. |
| 59 |
* This oles can be MN0, MacWorks/QHdr, MacWorks/QFtr, MacWorks/QFootnotes |
| 60 |
* and MacWorks/QFrm\<number\> . |
| 61 |
* |
| 62 |
* It creates a MsWksGraph, a MsWks4Text to parse the |
| 63 |
* the graphic and the text parts. |
| 64 |
* |
| 65 |
* It reads the entries: |
| 66 |
* - DOP : main document properties: dimension, ... (only parsed) |
| 67 |
* - FRAM : a zone which contains dimensions of objects (textbox, picture, ...) : only parsed |
| 68 |
* - PRNT : the printer information which contains page dimensions, margins, ... |
| 69 |
* - RLRB : an unknown zone which seems to contain some dimension ( only parsed) : maybe related to RBDR ( see MsWks4Graph) |
| 70 |
* - SELN : the actual text/... selection |
| 71 |
* |
| 72 |
*/ |
| 73 |
class MsWks4Zone |
| 74 |
{ |
| 75 |
friend class MsWksDocument; |
| 76 |
friend class MsWksDRParser; |
| 77 |
friend class MsWksParser; |
| 78 |
friend class MsWks4Text; |
| 79 |
|
| 80 |
public: |
| 81 |
//! constructor |
| 82 |
MsWks4Zone(MWAWInputStreamPtr const &input, MWAWParserStatePtr const &parserState, |
| 83 |
MWAWParser &parser, std::string const &oleName); |
| 84 |
//! destructor |
| 85 |
~MsWks4Zone(); |
| 86 |
|
| 87 |
protected: |
| 88 |
//! inits all internal variables |
| 89 |
void init(); |
| 90 |
//! returns the actual input |
| 91 |
MWAWInputStreamPtr getInput(); |
| 92 |
|
| 93 |
/** tries to find the beginning of the list of indices, |
| 94 |
* then try to find all entries in this list. |
| 95 |
* |
| 96 |
* Stores result in nameTable, offsetTable */ |
| 97 |
bool parseHeaderIndex(MWAWInputStreamPtr &input); |
| 98 |
|
| 99 |
//! parses an index entry |
| 100 |
bool parseHeaderIndexEntry(MWAWInputStreamPtr &input); |
| 101 |
|
| 102 |
//! finds and parses all the zones to prepare the data |
| 103 |
bool createZones(bool mainOle); |
| 104 |
|
| 105 |
/** final reading of a text zone |
| 106 |
* |
| 107 |
* \note reads all textzone if !entry.valid(), if not does nothing */ |
| 108 |
void readContentZones(MWAWEntry const &entry, bool mainOle); |
| 109 |
|
| 110 |
/** creates the main listener */ |
| 111 |
MWAWTextListenerPtr createListener(librevenge::RVNGTextInterface *interface); |
| 112 |
|
| 113 |
//! returns the page height, ie. paper size less margin (in inches) less header/footer size |
| 114 |
double getTextHeight() const; |
| 115 |
|
| 116 |
//! adds a new page |
| 117 |
void newPage(int number, bool soft=false); |
| 118 |
|
| 119 |
//! sends text corresponding to the footnote id to the listener (via MsWks4Text) |
| 120 |
void readFootNote(int id); |
| 121 |
|
| 122 |
/** return the text positions ( used for frame text) */ |
| 123 |
MWAWEntry getTextPosition() const; |
| 124 |
|
| 125 |
// |
| 126 |
// low level |
| 127 |
// |
| 128 |
|
| 129 |
/** reads the PRNT zone which contains the printer properties ( page dimension, margins, ...) */ |
| 130 |
bool readPRNT(MWAWInputStreamPtr input, MWAWEntry const &entry, MWAWPageSpan &page); |
| 131 |
|
| 132 |
/** parses the DIO zone which contains the document properties (dimension, ...) |
| 133 |
* |
| 134 |
* \note this zone is only parsed ; the read data are not used.*/ |
| 135 |
bool readDOP(MWAWInputStreamPtr input, MWAWEntry const &entry, MWAWPageSpan &page); |
| 136 |
|
| 137 |
/** parses the FRAM zone which contains some information about frames (header, footer, ...) |
| 138 |
* |
| 139 |
* \note this zone is only parsed ; the read data are not used */ |
| 140 |
bool readFRAM(MWAWInputStreamPtr input, MWAWEntry const &entry); |
| 141 |
|
| 142 |
/** parses the RLRB zone which seems to contain some position in the page ? |
| 143 |
* |
| 144 |
* \note this zone is only parsed, maybe MsWksGraph must parse this zone ? */ |
| 145 |
bool readRLRB(MWAWInputStreamPtr input, MWAWEntry const &entry); |
| 146 |
|
| 147 |
/** parses the SELN zone which seems to contain some information about the actual |
| 148 |
* |
| 149 |
* \note this zone is only parsed ; the read data are not used */ |
| 150 |
bool readSELN(MWAWInputStreamPtr input, MWAWEntry const &entry); |
| 151 |
|
| 152 |
//! inits the ascii file |
| 153 |
void setAscii(std::string const &oleName); |
| 154 |
//! a DebugFile used to write what we recognize when we parse the document |
| 155 |
libmwaw::DebugFile &ascii(); |
| 156 |
|
| 157 |
private: |
| 158 |
MsWks4Zone(MsWks4Zone const &orig) = delete; |
| 159 |
MsWks4Zone &operator=(MsWks4Zone const &orig) = delete; |
| 160 |
protected: |
| 161 |
// |
| 162 |
// data |
| 163 |
// |
| 164 |
|
| 165 |
//! the main parser |
| 166 |
MWAWParser *m_mainParser; |
| 167 |
|
| 168 |
//! the parser state |
| 169 |
std::shared_ptr<MWAWParserState> m_parserState; |
| 170 |
|
| 171 |
//! the internal state |
| 172 |
std::shared_ptr<MsWks4ZoneInternal::State> m_state; |
| 173 |
|
| 174 |
//! the zone data |
| 175 |
std::shared_ptr<MsWksDocument> m_document; |
| 176 |
}; |
| 177 |
#endif |
| 178 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |