[go: up one dir, main page]

Menu

[23fa7c]: / src / lib / WPS8Graph.h  Maximize  Restore  History

Download this file

152 lines (123 with data), 4.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* libwps
* Version: MPL 2.0 / LGPLv2.1+
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Major Contributor(s):
* Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU Lesser General Public License Version 2.1 or later
* (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
* applicable instead of those above.
*
* For further information visit http://libwps.sourceforge.net
*/
#ifndef WPS8_GRAPH
# define WPS8_GRAPH
#include <map>
#include <vector>
#include "libwps_internal.h"
#include "WPSDebug.h"
class WPS8Parser;
namespace WPS8GraphInternal
{
struct State;
}
/** \brief the main class to read/store pictures in a Pc MS Works document v5-8
*
* This class must be associated with a WPS8Parser. It contains code to read
* the BDR/WBDR, PICT/MEF4, IBGF entries and to store the pictures which are found
* in the other ole parts.
*
* \note As the pictures seems always be given with characters positions, many functions
* which exists to maintain the same structures that exist in the other WPS*MNGraph classes
* do almost nothing.
*/
class WPS8Graph
{
friend class WPS8Parser;
public:
//! constructor
explicit WPS8Graph(WPS8Parser &parser);
//! destructor
~WPS8Graph();
//! sets the listener
void setListener(WPSContentListenerPtr &listen)
{
m_listener = listen;
}
/** computes the final position of all found figures.
*
* In reality, as all the pictures seemed to be given with characters positions,
* it does nothing*/
void computePositions() const;
//! returns the number page where we find a picture. In practice, 0/1
int numPages() const;
/** sends an object
* \param pos the object position in the document
* \param id the object identificator
* \param ole indicated if we look for objects coming from a ole zone or objects coming from a Pict zone */
bool sendObject(WPSPosition const &pos, int id, bool ole);
//! sends data corresponding to a ibgf entry on a given \a pos position
bool sendIBGF(WPSPosition const &pos, int ibgfId);
/** send all the objects of a given page:
* \param page if page < 0, sends all the pictures which have not been used,
* \param pageToIgnore pictures on this pages are not send
*
* As all the pictures seemed to be given with characters positions, this
* function only does something if page < 0.
*/
void sendObjects(int page, int pageToIgnore=-2);
protected:
//! returns the file version
int version() const;
/** sends the border frames.
*
* Actually, sends the eight consecutive pictures which form a border on 3 consecutive lines*/
void sendBorder(int borderId);
//! adds a list of object
void storeObjects(std::map<int,WPSEmbeddedObject> const &objectsMap);
//! finds all entries which correspond to some pictures, parses them and stores data
bool readStructures(RVNGInputStreamPtr const &input);
// low level
/** reads a PICT/MEF4 entry : reads uncompressed picture of sx*sy of rgb
*
* This kind of entry seems mainly used to store a background picture */
bool readPICT(RVNGInputStreamPtr const &input, WPSEntry const &entry);
/** reads a IBGF zone: an entry to a background picture
*
* This small entry seems to contain only an identificator which pointed to a PICT Zone
*/
bool readIBGF(RVNGInputStreamPtr const &input, WPSEntry const &entry);
//! parsed BDR/WBDR zone: a complex border formed with 8 pictures
bool readBDR(RVNGInputStreamPtr const &input, WPSEntry const &entry);
//! returns the debug file
libwps::DebugFile &ascii()
{
return m_asciiFile;
}
private:
WPS8Graph(WPS8Graph const &orig) = delete;
WPS8Graph &operator=(WPS8Graph const &orig) = delete;
protected:
//! the listener
WPSContentListenerPtr m_listener;
//! the main parser
WPS8Parser &m_mainParser;
//! the state
mutable std::shared_ptr<WPS8GraphInternal::State> m_state;
//! the ascii file
libwps::DebugFile &m_asciiFile;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */