| 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 Canvas text document ( graphic part ) |
| 36 |
* |
| 37 |
*/ |
| 38 |
#ifndef CANVAS_GRAPH |
| 39 |
# define CANVAS_GRAPH |
| 40 |
|
| 41 |
#include <string> |
| 42 |
#include <vector> |
| 43 |
|
| 44 |
#include <librevenge/librevenge.h> |
| 45 |
|
| 46 |
#include "libmwaw_internal.hxx" |
| 47 |
|
| 48 |
#include "MWAWDebug.hxx" |
| 49 |
#include "MWAWGraphicStyle.hxx" |
| 50 |
#include "MWAWInputStream.hxx" |
| 51 |
#include "MWAWPosition.hxx" |
| 52 |
|
| 53 |
namespace CanvasGraphInternal |
| 54 |
{ |
| 55 |
struct LocalTransform; |
| 56 |
struct Shape; |
| 57 |
struct State; |
| 58 |
|
| 59 |
class SubDocument; |
| 60 |
} |
| 61 |
|
| 62 |
class CanvasParser; |
| 63 |
class CanvasStyleManager; |
| 64 |
|
| 65 |
/** \brief the main class to read the graphic part of Canvas file |
| 66 |
* |
| 67 |
* |
| 68 |
* |
| 69 |
*/ |
| 70 |
class CanvasGraph |
| 71 |
{ |
| 72 |
friend class CanvasGraphInternal::SubDocument; |
| 73 |
friend class CanvasParser; |
| 74 |
|
| 75 |
public: |
| 76 |
//! constructor |
| 77 |
explicit CanvasGraph(CanvasParser &parser); |
| 78 |
//! destructor |
| 79 |
virtual ~CanvasGraph(); |
| 80 |
|
| 81 |
/** returns the file version */ |
| 82 |
int version() const; |
| 83 |
|
| 84 |
protected: |
| 85 |
/** store the actual input */ |
| 86 |
void setInput(MWAWInputStreamPtr &input); |
| 87 |
/** returns the current input */ |
| 88 |
MWAWInputStreamPtr &getInput(); |
| 89 |
|
| 90 |
// interface with main parser |
| 91 |
|
| 92 |
//! tries to send a shape with id |
| 93 |
bool sendShape(int id); |
| 94 |
|
| 95 |
// |
| 96 |
// Intermediate level |
| 97 |
// |
| 98 |
|
| 99 |
//! try to read the shapes: in fact, the compression header + the list of shapes |
| 100 |
bool readShapes(int numShapes, unsigned long shapeLength, unsigned long dataLength); |
| 101 |
//! try to read a shape: to do |
| 102 |
bool readShape(int n, std::vector<MWAWEntry> const &dataZonesList); |
| 103 |
//! try to read the shapes data |
| 104 |
bool readShapeData(CanvasGraphInternal::Shape &shape); |
| 105 |
|
| 106 |
//! tries to read a bitmap stored in the rectangle's data |
| 107 |
bool getBitmapBW(CanvasGraphInternal::Shape const &shape, MWAWEmbeddedObject &obj); |
| 108 |
//! tries to read the color bitmap stored in 55's shape: v3.5 |
| 109 |
bool getBitmap(CanvasGraphInternal::Shape const &shape, MWAWEmbeddedObject &obj); |
| 110 |
//! tries to read the file bitmap: windows v3.5 |
| 111 |
bool readFileBitmap(long length); |
| 112 |
//! tries to read a picture stored in the picture's data |
| 113 |
bool getPicture(CanvasGraphInternal::Shape const &shape, MWAWEmbeddedObject &obj); |
| 114 |
|
| 115 |
// |
| 116 |
// send data to the listener |
| 117 |
// |
| 118 |
|
| 119 |
//! updates the style corresponding to a shape |
| 120 |
void update(CanvasGraphInternal::Shape const &shape, MWAWGraphicStyle &style) const; |
| 121 |
//! tries to send a shape |
| 122 |
bool send(CanvasGraphInternal::Shape const &shape, CanvasGraphInternal::LocalTransform const *local=nullptr); |
| 123 |
//! tries the dimension line's special shape: DIMN |
| 124 |
bool sendDimension(CanvasGraphInternal::Shape const &shape, CanvasGraphInternal::LocalTransform const &local); |
| 125 |
//! tries the multiligne's special shape: Palm |
| 126 |
bool sendMultiLines(CanvasGraphInternal::Shape const &shape, CanvasGraphInternal::LocalTransform const &local); |
| 127 |
//! tries to send the special content |
| 128 |
bool sendSpecial(CanvasGraphInternal::Shape const &shape, CanvasGraphInternal::LocalTransform const &local); |
| 129 |
//! tries to send the text of a text's shape |
| 130 |
bool sendText(CanvasGraphInternal::Shape const &shape); |
| 131 |
//! tries to send the text of a text's shape given a zone id |
| 132 |
bool sendText(int zId); |
| 133 |
|
| 134 |
// |
| 135 |
// Low level |
| 136 |
// |
| 137 |
|
| 138 |
//! mark the id's shape as read in debug mode |
| 139 |
void markSent(int id); |
| 140 |
//! look for unsent shapes in debug mode |
| 141 |
void checkUnsent() const; |
| 142 |
|
| 143 |
private: |
| 144 |
CanvasGraph(CanvasGraph const &orig) = delete; |
| 145 |
CanvasGraph &operator=(CanvasGraph const &orig) = delete; |
| 146 |
|
| 147 |
protected: |
| 148 |
// |
| 149 |
// data |
| 150 |
// |
| 151 |
//! the parser state |
| 152 |
MWAWParserStatePtr m_parserState; |
| 153 |
|
| 154 |
//! the state |
| 155 |
std::shared_ptr<CanvasGraphInternal::State> m_state; |
| 156 |
|
| 157 |
//! the main parser; |
| 158 |
CanvasParser *m_mainParser; |
| 159 |
//! the style manager |
| 160 |
std::shared_ptr<CanvasStyleManager> m_styleManager; |
| 161 |
}; |
| 162 |
#endif |
| 163 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |