| 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 convert some Script Writer 1.3 text document |
| 36 |
* |
| 37 |
*/ |
| 38 |
#ifndef SCRIPT_WRITER_PARSER |
| 39 |
# define SCRIPT_WRITER_PARSER |
| 40 |
|
| 41 |
#include <vector> |
| 42 |
|
| 43 |
#include "MWAWDebug.hxx" |
| 44 |
#include "MWAWEntry.hxx" |
| 45 |
#include "MWAWInputStream.hxx" |
| 46 |
|
| 47 |
#include "MWAWParser.hxx" |
| 48 |
|
| 49 |
namespace ScriptWriterParserInternal |
| 50 |
{ |
| 51 |
struct Frame; |
| 52 |
struct HFData; |
| 53 |
struct Page; |
| 54 |
struct State; |
| 55 |
|
| 56 |
class SubDocument; |
| 57 |
} |
| 58 |
|
| 59 |
/** \brief the main class to read a Script Writer 1.3 file |
| 60 |
* |
| 61 |
* |
| 62 |
* |
| 63 |
*/ |
| 64 |
class ScriptWriterParser final : public MWAWTextParser |
| 65 |
{ |
| 66 |
friend class ScriptWriterParserInternal::SubDocument; |
| 67 |
|
| 68 |
public: |
| 69 |
//! constructor |
| 70 |
ScriptWriterParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header); |
| 71 |
//! destructor |
| 72 |
~ScriptWriterParser() final; |
| 73 |
|
| 74 |
//! checks if the document header is correct (or not) |
| 75 |
bool checkHeader(MWAWHeader *header, bool strict=false) final; |
| 76 |
|
| 77 |
// the main parse function |
| 78 |
void parse(librevenge::RVNGTextInterface *documentInterface) final; |
| 79 |
|
| 80 |
protected: |
| 81 |
//! creates the listener which will be associated to the document |
| 82 |
void createDocument(librevenge::RVNGTextInterface *documentInterface); |
| 83 |
|
| 84 |
//! finds the different objects zones |
| 85 |
bool createZones(); |
| 86 |
|
| 87 |
//! try to read the document header |
| 88 |
bool readDocument(); |
| 89 |
//! try to read the print information |
| 90 |
bool readPrintInfo(); |
| 91 |
|
| 92 |
//! try to read a frame entry |
| 93 |
bool readFrame(ScriptWriterParserInternal::Frame &frame); |
| 94 |
|
| 95 |
//! try to read the character style |
| 96 |
bool readCharStyle(ScriptWriterParserInternal::Page &page, int column); |
| 97 |
//! try to read page |
| 98 |
bool readPage(ScriptWriterParserInternal::Page &page); |
| 99 |
//! try to read the main text zone |
| 100 |
bool readTextZone(); |
| 101 |
//! try to read the hf style |
| 102 |
bool readHFStyle(std::map<int,MWAWFont> &posToFontMap); |
| 103 |
|
| 104 |
//! try to read a picture entry |
| 105 |
bool readPicture(MWAWEntry &entry); |
| 106 |
//! try to read a font |
| 107 |
bool readFont(MWAWFont &font); |
| 108 |
|
| 109 |
// |
| 110 |
// send data |
| 111 |
// |
| 112 |
|
| 113 |
//! try to send a header/footer |
| 114 |
bool send(ScriptWriterParserInternal::HFData const &hf); |
| 115 |
//! try to send a frame text |
| 116 |
bool sendText(ScriptWriterParserInternal::Frame const &frame); |
| 117 |
//! try to send the main text zone |
| 118 |
bool sendMainZone(); |
| 119 |
//! try to send a page text |
| 120 |
bool sendText(ScriptWriterParserInternal::Page const &page); |
| 121 |
protected: |
| 122 |
// |
| 123 |
// data |
| 124 |
// |
| 125 |
|
| 126 |
//! the state |
| 127 |
std::shared_ptr<ScriptWriterParserInternal::State> m_state; |
| 128 |
}; |
| 129 |
#endif |
| 130 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |