| 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 CLARISDRAW_PARSER |
| 35 |
# define CLARISDRAW_PARSER |
| 36 |
|
| 37 |
#include <string> |
| 38 |
#include <vector> |
| 39 |
|
| 40 |
#include <librevenge/librevenge.h> |
| 41 |
|
| 42 |
#include "MWAWDebug.hxx" |
| 43 |
#include "MWAWInputStream.hxx" |
| 44 |
|
| 45 |
#include "MWAWParser.hxx" |
| 46 |
|
| 47 |
#include "ClarisWksStruct.hxx" |
| 48 |
|
| 49 |
namespace ClarisDrawParserInternal |
| 50 |
{ |
| 51 |
struct State; |
| 52 |
|
| 53 |
class SubDocument; |
| 54 |
} |
| 55 |
|
| 56 |
class ClarisDrawGraph; |
| 57 |
class ClarisDrawText; |
| 58 |
class ClarisDrawStyleManager; |
| 59 |
|
| 60 |
/** \brief the main class to read a ClarisDraw v1 file |
| 61 |
* |
| 62 |
*/ |
| 63 |
class ClarisDrawParser final : public MWAWGraphicParser |
| 64 |
{ |
| 65 |
friend class ClarisDrawGraph; |
| 66 |
friend class ClarisDrawText; |
| 67 |
public: |
| 68 |
//! constructor |
| 69 |
ClarisDrawParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header); |
| 70 |
//! destructor |
| 71 |
~ClarisDrawParser() final; |
| 72 |
|
| 73 |
//! checks if the document header is correct (or not) |
| 74 |
bool checkHeader(MWAWHeader *header, bool strict=false) final; |
| 75 |
|
| 76 |
//! the main parse function |
| 77 |
void parse(librevenge::RVNGDrawingInterface *documentInterface) final; |
| 78 |
|
| 79 |
//! returns the file type corresponding to a zone id |
| 80 |
int getFileType(int zoneId) const; |
| 81 |
//! returns the page left top point ( in inches) |
| 82 |
MWAWVec2f getPageLeftTop(); |
| 83 |
//! sends a text zone |
| 84 |
bool sendTextZone(int number, int subZone=-1); |
| 85 |
|
| 86 |
protected: |
| 87 |
//! inits all internal variables |
| 88 |
void init(); |
| 89 |
|
| 90 |
//! creates the listener which will be associated to the document |
| 91 |
void createDocument(librevenge::RVNGDrawingInterface *documentInterface); |
| 92 |
|
| 93 |
protected: |
| 94 |
//! finds the different objects zones |
| 95 |
bool createZones(); |
| 96 |
//! try to read a zone |
| 97 |
bool readZone(); |
| 98 |
|
| 99 |
// Intermediate level |
| 100 |
|
| 101 |
//! try to read a document header |
| 102 |
bool readDocHeader(); |
| 103 |
//! try to read the library header |
| 104 |
bool readLibraryHeader(); |
| 105 |
//! try to read a DSET structure |
| 106 |
std::shared_ptr<ClarisWksStruct::DSET> readDSET(bool isLibHeader=false); |
| 107 |
|
| 108 |
//! try to read the print info zone |
| 109 |
bool readPrintInfo(); |
| 110 |
//! try to read the document info zone |
| 111 |
bool readDocInfo(); |
| 112 |
//! try to read the layout |
| 113 |
bool readLayouts(); |
| 114 |
//! try to read the library names(two zone) |
| 115 |
bool readLibraryNames(); |
| 116 |
|
| 117 |
// |
| 118 |
// low level |
| 119 |
// |
| 120 |
|
| 121 |
protected: |
| 122 |
// |
| 123 |
// data |
| 124 |
// |
| 125 |
|
| 126 |
//! the state |
| 127 |
std::shared_ptr<ClarisDrawParserInternal::State> m_state; |
| 128 |
//! the style manager |
| 129 |
std::shared_ptr<ClarisDrawStyleManager> m_styleManager; |
| 130 |
//! the graph parser |
| 131 |
std::shared_ptr<ClarisDrawGraph> m_graphParser; |
| 132 |
//! the text parser |
| 133 |
std::shared_ptr<ClarisDrawText> m_textParser; |
| 134 |
}; |
| 135 |
#endif |
| 136 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |