| 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 GREAT_WKS_DOCUMENT |
| 35 |
# define GREAT_WKS_DOCUMENT |
| 36 |
|
| 37 |
#include <string> |
| 38 |
#include <vector> |
| 39 |
|
| 40 |
#include <librevenge/librevenge.h> |
| 41 |
|
| 42 |
#include "MWAWCell.hxx" |
| 43 |
#include "MWAWDebug.hxx" |
| 44 |
#include "MWAWParser.hxx" |
| 45 |
|
| 46 |
namespace GreatWksDocumentInternal |
| 47 |
{ |
| 48 |
struct State; |
| 49 |
} |
| 50 |
|
| 51 |
class GreatWksGraph; |
| 52 |
class GreatWksParser; |
| 53 |
class GreatWksDBParser; |
| 54 |
class GreatWksDRParser; |
| 55 |
class GreatWksSSParser; |
| 56 |
class GreatWksText; |
| 57 |
|
| 58 |
/** \brief the main class to read/store generic data of a GreatWorks document |
| 59 |
*/ |
| 60 |
class GreatWksDocument |
| 61 |
{ |
| 62 |
friend class GreatWksParser; |
| 63 |
friend class GreatWksDBParser; |
| 64 |
friend class GreatWksDRParser; |
| 65 |
friend class GreatWksSSParser; |
| 66 |
public: |
| 67 |
//! constructor |
| 68 |
explicit GreatWksDocument(MWAWParser &parser); |
| 69 |
//! destructor |
| 70 |
virtual ~GreatWksDocument(); |
| 71 |
|
| 72 |
//! checks if the document header is correct (or not) |
| 73 |
bool checkHeader(MWAWHeader *header, bool strict=false); |
| 74 |
|
| 75 |
//! returns the main parser |
| 76 |
MWAWParser &getMainParser() |
| 77 |
{ |
| 78 |
return *m_parser; |
| 79 |
} |
| 80 |
//! returns the graph parser |
| 81 |
std::shared_ptr<GreatWksGraph> getGraphParser() |
| 82 |
{ |
| 83 |
return m_graphParser; |
| 84 |
} |
| 85 |
//! returns the text parser |
| 86 |
std::shared_ptr<GreatWksText> getTextParser() |
| 87 |
{ |
| 88 |
return m_textParser; |
| 89 |
} |
| 90 |
|
| 91 |
//! return the main section |
| 92 |
MWAWSection getMainSection() const; |
| 93 |
/** send a page break */ |
| 94 |
void newPage(int page); |
| 95 |
//! send a picture |
| 96 |
bool sendPicture(MWAWEntry const &entry, MWAWPosition const &pos); |
| 97 |
|
| 98 |
// interface with the graph parser |
| 99 |
|
| 100 |
//! check if a textbox can be send in a graphic zone, ie. does not contains any graphic |
| 101 |
bool canSendTextboxAsGraphic(MWAWEntry const &entry); |
| 102 |
//! try to send textbox |
| 103 |
bool sendTextbox(MWAWEntry const &entry, MWAWListenerPtr listener); |
| 104 |
|
| 105 |
protected: |
| 106 |
|
| 107 |
//! read the resource fork zone |
| 108 |
bool readRSRCZones(); |
| 109 |
|
| 110 |
// formula function |
| 111 |
|
| 112 |
/** reads a cell */ |
| 113 |
bool readCellInFormula(MWAWVec2i const &pos, MWAWCellContent::FormulaInstruction &instr); |
| 114 |
/** try to read a string */ |
| 115 |
bool readString(long endPos, std::string &res); |
| 116 |
/** try to read a number */ |
| 117 |
bool readNumber(long endPos, double &res, bool &isNan); |
| 118 |
//! read to read a formula |
| 119 |
bool readFormula(MWAWVec2i const &cPos, long endPos, |
| 120 |
std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error); |
| 121 |
|
| 122 |
// |
| 123 |
// low level |
| 124 |
// |
| 125 |
|
| 126 |
//! read a PrintInfo block ( PRNT resource block ) |
| 127 |
bool readPrintInfo(MWAWEntry const &entry); |
| 128 |
|
| 129 |
//! read the windows positions ( WPSN resource block ) |
| 130 |
bool readWPSN(MWAWEntry const &entry); |
| 131 |
|
| 132 |
//! read a unknown zone ( ARRs resource block: v2 ) |
| 133 |
bool readARRs(MWAWEntry const &entry); |
| 134 |
//! read a unknown zone ( DaHS resource block: v2 ) |
| 135 |
bool readDaHS(MWAWEntry const &entry); |
| 136 |
//! read a unknown zone ( GrDS resource block: v2 ) |
| 137 |
bool readGrDS(MWAWEntry const &entry); |
| 138 |
//! read a unknown zone ( NxED resource block: v2 ) |
| 139 |
bool readNxEd(MWAWEntry const &entry); |
| 140 |
|
| 141 |
//! return the input input |
| 142 |
MWAWInputStreamPtr rsrcInput(); |
| 143 |
|
| 144 |
//! a DebugFile used to write what we recognize when we parse the document in rsrc |
| 145 |
libmwaw::DebugFile &rsrcAscii(); |
| 146 |
|
| 147 |
private: |
| 148 |
GreatWksDocument(GreatWksDocument const &orig) = delete; |
| 149 |
GreatWksDocument &operator=(GreatWksDocument const &orig) = delete; |
| 150 |
|
| 151 |
// |
| 152 |
// data |
| 153 |
// |
| 154 |
|
| 155 |
protected: |
| 156 |
//! the state |
| 157 |
std::shared_ptr<GreatWksDocumentInternal::State> m_state; |
| 158 |
public: |
| 159 |
//! the parser state |
| 160 |
std::shared_ptr<MWAWParserState> m_parserState; |
| 161 |
|
| 162 |
protected: |
| 163 |
//! the main parser |
| 164 |
MWAWParser *m_parser; |
| 165 |
//! the graph document |
| 166 |
std::shared_ptr<GreatWksGraph> m_graphParser; |
| 167 |
//! the text document |
| 168 |
std::shared_ptr<GreatWksText> m_textParser; |
| 169 |
|
| 170 |
//! callback used to return the main section |
| 171 |
typedef MWAWSection(MWAWParser::* GetMainSection)() const; |
| 172 |
/** callback used to send a page break */ |
| 173 |
typedef void (MWAWParser::* NewPage)(int page); |
| 174 |
|
| 175 |
/** the getMainSection callback */ |
| 176 |
GetMainSection m_getMainSection; |
| 177 |
/** the new page callback */ |
| 178 |
NewPage m_newPage; |
| 179 |
}; |
| 180 |
#endif |
| 181 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |