wxMaxima
Loading...
Searching...
No Matches
pdfobjects.h
Go to the documentation of this file.
1
2// Name: pdfobjects.h
3// Purpose:
4// Author: Ulrich Telle
5// Created: 2006-10-12
6// Copyright: (c) Ulrich Telle
7// Licence: wxWindows licence
9
11
12#ifndef _PDF_OBJECTS_H_
13#define _PDF_OBJECTS_H_
14
15// wxWidgets headers
16#include <wx/dynarray.h>
17#include <wx/mstream.h>
18#include <wx/string.h>
19
20// wxPdfDocument headers
21#include "wx/pdfdocdef.h"
22
23#define OBJTYPE_NULL 1
24#define OBJTYPE_BOOLEAN 2
25#define OBJTYPE_NUMBER 3
26#define OBJTYPE_STRING 4
27#define OBJTYPE_NAME 5
28#define OBJTYPE_ARRAY 6
29#define OBJTYPE_DICTIONARY 7
30#define OBJTYPE_STREAM 8
31#define OBJTYPE_INDIRECT 9
32
34class WXDLLIMPEXP_PDFDOC wxPdfObject
35{
36public:
38
41 wxPdfObject(int type);
42
44 virtual ~wxPdfObject();
45
47
50 int GetType() { return m_type; }
51
53
57 void SetObjNum(int objNum, int objGen = 0);
58
60
63 int GetNumber() { return m_objNum; }
64
66
69 int GetGeneration() { return m_objGen; }
70
72
75 void SetActualId(int actualId) { m_actualId = actualId; }
76
77 // Get actual object id
81 int GetActualId() { return m_actualId; }
82
84
87 void SetCreatedIndirect(bool indirect) { m_indirect = indirect; }
88
90
93 bool IsCreatedIndirect() { return m_indirect; }
94
96
99 bool CanBeInObjStm();
100
102
105 bool IsNull() { return (m_type == OBJTYPE_NULL); }
106
108
111 bool IsBoolean() { return (m_type == OBJTYPE_BOOLEAN); }
112
114
117 bool IsNumber() { return (m_type == OBJTYPE_NUMBER); }
118
120
123 bool IsString() { return (m_type == OBJTYPE_STRING); }
124
126
129 bool IsName() { return (m_type == OBJTYPE_NAME); }
130
132
135 bool IsArray() { return (m_type == OBJTYPE_ARRAY); }
136
138
141 bool IsDictionary() { return (m_type == OBJTYPE_DICTIONARY); }
142
144
147 bool IsStream() { return (m_type == OBJTYPE_STREAM); }
148
150
153 bool IsIndirect() { return (m_type == OBJTYPE_INDIRECT); }
154
155protected:
156 int m_type;
161};
162
164class WXDLLIMPEXP_PDFDOC wxPdfNull : public wxPdfObject
165{
166public:
168 wxPdfNull();
169
171 virtual ~wxPdfNull();
172};
173
175class WXDLLIMPEXP_PDFDOC wxPdfIndirectReference : public wxPdfObject
176{
177public:
179
183 wxPdfIndirectReference(int number, int generation = 0);
184
186 virtual ~wxPdfIndirectReference();
187};
188
190class WXDLLIMPEXP_PDFDOC wxPdfLiteral : public wxPdfObject
191{
192public:
194
198 wxPdfLiteral(int type, const wxString& value);
199
201 virtual ~wxPdfLiteral();
202
204
207 wxString GetValue() { return m_value; };
208
209private:
210 wxString m_value;
211};
212
214class WXDLLIMPEXP_PDFDOC wxPdfBoolean : public wxPdfObject
215{
216public:
218
221 wxPdfBoolean(bool value);
222
224 virtual ~wxPdfBoolean();
225
227
230 bool GetValue() { return m_value; };
231
233
236 wxString GetAsString();
237
238private:
239 bool m_value;
240};
241
243class WXDLLIMPEXP_PDFDOC wxPdfString : public wxPdfObject
244{
245public:
247
250 wxPdfString(const wxString& value);
251
253 virtual ~wxPdfString();
254
256
259 wxString GetValue() { return m_value; };
260
262
265 void SetIsHexString(bool isHexString) { m_isHexString = isHexString; }
266
268
271 bool IsHexString() const { return m_isHexString; }
272
273private:
274 wxString m_value;
275 bool m_isHexString;
276};
277
279class WXDLLIMPEXP_PDFDOC wxPdfNumber : public wxPdfObject
280{
281public:
283
286 wxPdfNumber(const wxString& value);
287
289
292 wxPdfNumber(int value);
293
295
298 wxPdfNumber(double value);
299
301 virtual ~wxPdfNumber();
302
304
307 double GetValue() { return m_value; }
308
310
313 int GetInt() { return (int) m_value; }
314
316
319 wxString GetAsString() { return m_string; }
320
322
325 bool IsInt() { return m_isInt; }
326
327private:
328 double m_value;
329 wxString m_string;
330 bool m_isInt;
331};
332
334class WXDLLIMPEXP_PDFDOC wxPdfName : public wxPdfObject
335{
336public:
338 wxPdfName();
339
341
344 wxPdfName(const wxString& name);
345
347 virtual ~wxPdfName();
348
350
353 wxString GetName() { return m_name; };
354
355private:
356 wxString m_name;
357};
358
360class WXDLLIMPEXP_PDFDOC wxPdfArray : public wxPdfObject
361{
362public:
364 wxPdfArray();
365
367 virtual ~wxPdfArray();
368
370
373 void Add(wxPdfObject* obj);
374
376
379 void Add(int value);
380
382
385 void Add(double value);
386
388
392 wxPdfObject* Get(size_t index);
393
395
398 size_t GetSize() { return m_array.GetCount(); }
399
400private:
401 wxArrayPtrVoid m_array;
402};
403
405WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxPdfObject*, wxPdfDictionaryMap, class WXDLLIMPEXP_PDFDOC);
406
408class WXDLLIMPEXP_PDFDOC wxPdfDictionary : public wxPdfObject
409{
410public:
413
415
418 wxPdfDictionary(const wxString& type);
419
421 virtual ~wxPdfDictionary();
422
424
428 void Put(wxPdfName* key, wxPdfObject* value);
429
431
435 void Put(const wxString& key, wxPdfObject* value);
436
438
442 wxPdfObject* Get(const wxString& key);
443
445
448 wxPdfDictionaryMap* GetHashMap() { return m_hashMap; }
449
450private:
451 wxPdfDictionaryMap* m_hashMap;
452};
453
455class WXDLLIMPEXP_PDFDOC wxPdfStream : public wxPdfObject
456{
457public:
459 wxPdfStream();
460
462
465 wxPdfStream(off_t offset);
466
468 virtual ~wxPdfStream();
469
471
474 off_t GetOffset() { return m_offset; }
475
477
480 void SetDictionary(wxPdfDictionary* dictionary) { m_dictionary = dictionary; }
481
483
486 wxPdfDictionary* GetDictionary() { return m_dictionary; }
487
489
492 void SetBuffer(wxMemoryOutputStream* buffer) { m_buffer = buffer; }
493
495
498 wxMemoryOutputStream* GetBuffer() { return m_buffer; }
499
501
505 wxPdfObject* Get(const wxString& key);
506
508
511 void SetHasObjOffsets(bool hasObjOffsets) { m_hasObjOffsets = hasObjOffsets; }
512
514
517 bool HasObjOffsets() { return m_hasObjOffsets; }
518
520
523 wxArrayInt* GetObjOffsets() { return &m_objOffsets; }
524
526
530 int GetObjOffset(int index) const;
531
532private:
533 off_t m_offset;
534 wxPdfDictionary* m_dictionary;
535 wxMemoryOutputStream* m_buffer;
536 bool m_hasObjOffsets;
537 wxArrayInt m_objOffsets;
538};
539
541class WXDLLIMPEXP_PDFDOC wxPdfObjectQueue
542{
543public:
545
550 wxPdfObjectQueue(int originalId = 0, int actualObjectId = 0, wxPdfObject* object = NULL);
551
553 virtual ~wxPdfObjectQueue() {}
554
556
559 int GetOriginalObjectId() const { return m_originalObjectId; }
560
562
565 int GetActualObjectId() const { return m_actualObjectId; }
566
568
571 wxPdfObject* GetObject() const { return m_object; }
572
574
577 void SetObject(wxPdfObject* object) { m_object = object; }
578
580
583 wxPdfObjectQueue* GetNext() const { return m_next; }
584
586
589 void SetNext(wxPdfObjectQueue* next) { m_next = next; }
590
591private:
592 int m_originalObjectId;
593 int m_actualObjectId;
594 wxPdfObject* m_object;
595 wxPdfObjectQueue* m_next;
596};
597
599WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfObjectQueue*, wxIntegerHash, wxIntegerEqual, wxPdfObjectMap, class WXDLLIMPEXP_PDFDOC);
600
602WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfObject*, wxIntegerHash, wxIntegerEqual, wxPdfObjStmMap, class WXDLLIMPEXP_PDFDOC);
603
604#endif
605
const wxChar * key
The name in the config file.
Definition: ToolBarSections.cpp:37
Class representing an array object. (For internal use only)
Definition: pdfobjects.h:361
size_t GetSize()
Get the size of the array.
Definition: pdfobjects.h:398
Class representing a boolean object. (For internal use only)
Definition: pdfobjects.h:215
bool GetValue()
Get boolean value.
Definition: pdfobjects.h:230
Class representing a dictionary object. (For internal use only)
Definition: pdfobjects.h:409
wxPdfDictionaryMap * GetHashMap()
Get the dictionary map.
Definition: pdfobjects.h:448
Class representing an indirect reference object. (For internal use only)
Definition: pdfobjects.h:176
Class representing a literal object. (For internal use only)
Definition: pdfobjects.h:191
wxString GetValue()
Get string value of the literal.
Definition: pdfobjects.h:207
Class representing a name object. (For internal use only)
Definition: pdfobjects.h:335
wxString GetName()
Get name.
Definition: pdfobjects.h:353
Class representing a null object. (For internal use only)
Definition: pdfobjects.h:165
Class representing a numeric object. (For internal use only)
Definition: pdfobjects.h:280
int GetInt()
Get value as integer.
Definition: pdfobjects.h:313
bool IsInt()
Check whether value is integer.
Definition: pdfobjects.h:325
double GetValue()
Get value as floating point.
Definition: pdfobjects.h:307
wxString GetAsString()
Get value as string.
Definition: pdfobjects.h:319
Class representing a queue of objects. (For internal use only)
Definition: pdfobjects.h:542
wxPdfObject * GetObject() const
Get associated object.
Definition: pdfobjects.h:571
int GetActualObjectId() const
Get actual object id.
Definition: pdfobjects.h:565
int GetOriginalObjectId() const
Get original object id.
Definition: pdfobjects.h:559
void SetNext(wxPdfObjectQueue *next)
Set next queue entry.
Definition: pdfobjects.h:589
void SetObject(wxPdfObject *object)
Set associated object.
Definition: pdfobjects.h:577
virtual ~wxPdfObjectQueue()
Destructor.
Definition: pdfobjects.h:553
wxPdfObjectQueue * GetNext() const
Get next queue entry.
Definition: pdfobjects.h:583
Class representing a base PDF object. (For internal use only)
Definition: pdfobjects.h:35
void SetActualId(int actualId)
Set actual object id.
Definition: pdfobjects.h:75
int m_objNum
Object number.
Definition: pdfobjects.h:157
bool IsStream()
Checks whether this PdfObject is of the type PdfStream.
Definition: pdfobjects.h:147
bool IsDictionary()
Checks whether this is a wxPdfDictionary object.
Definition: pdfobjects.h:141
int GetType()
Get the type of the object.
Definition: pdfobjects.h:50
void SetCreatedIndirect(bool indirect)
Flag this object as created through an indirect reference.
Definition: pdfobjects.h:87
bool IsCreatedIndirect()
Check whether this object was created through an indirect reference.
Definition: pdfobjects.h:93
int GetActualId()
Definition: pdfobjects.h:81
bool m_indirect
Flag whether created through indirect reference.
Definition: pdfobjects.h:160
int GetGeneration()
Get generation number.
Definition: pdfobjects.h:69
bool IsString()
Checks whether this is a wxPdfString object.
Definition: pdfobjects.h:123
bool IsIndirect()
Checks if this is an indirect object.
Definition: pdfobjects.h:153
bool IsName()
Checks whether this is a wxPdfName object.
Definition: pdfobjects.h:129
int m_type
Object type.
Definition: pdfobjects.h:156
bool IsBoolean()
Checks whether this is a wxPdfBoolean object.
Definition: pdfobjects.h:111
bool IsNull()
Checks whether this is a wxPdfNull object.
Definition: pdfobjects.h:105
bool IsArray()
Checks whether this is a wxPdfArray object.
Definition: pdfobjects.h:135
int m_objGen
Object generation.
Definition: pdfobjects.h:158
int m_actualId
Actual object id.
Definition: pdfobjects.h:159
int GetNumber()
Get object number.
Definition: pdfobjects.h:63
bool IsNumber()
Checks whether this is a wxPdfNumber object.
Definition: pdfobjects.h:117
Class representing a stream object. (For internal use only)
Definition: pdfobjects.h:456
void SetDictionary(wxPdfDictionary *dictionary)
Set the associated stream dictionary.
Definition: pdfobjects.h:480
void SetBuffer(wxMemoryOutputStream *buffer)
Set the stream data buffer.
Definition: pdfobjects.h:492
wxMemoryOutputStream * GetBuffer()
Get the stream data buffer.
Definition: pdfobjects.h:498
void SetHasObjOffsets(bool hasObjOffsets)
Set flag whether an object stream has already read the object index.
Definition: pdfobjects.h:511
off_t GetOffset()
Get the offset of the stream data.
Definition: pdfobjects.h:474
wxArrayInt * GetObjOffsets()
Get a pointer to the object offsets array.
Definition: pdfobjects.h:523
bool HasObjOffsets()
Get flag whether the offsets of objects in an object stream are available.
Definition: pdfobjects.h:517
wxPdfDictionary * GetDictionary()
Get the associated stream dictionary.
Definition: pdfobjects.h:486
Class representing a normal string object. (For internal use only)
Definition: pdfobjects.h:244
bool IsHexString() const
Check whether string is hexadecimal.
Definition: pdfobjects.h:271
wxString GetValue()
Get value of the string.
Definition: pdfobjects.h:259
void SetIsHexString(bool isHexString)
Set hexadecimal string flag.
Definition: pdfobjects.h:265
Compile time switches for the wxPdfDocument component.
WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfObjectQueue *, wxIntegerHash, wxIntegerEqual, wxPdfObjectMap, class WXDLLIMPEXP_PDFDOC)
Hashmap class for object queue entries (For internal use only)
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxPdfObject *, wxPdfDictionaryMap, class WXDLLIMPEXP_PDFDOC)
Hash map class for dictionaries. (For internal use only)