~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/source_exporter/wxPdfDocument/include/wx/pdfxml.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///////////////////////////////////////////////////////////////////////////////
 
2
// Name:        pdfxml.h
 
3
// Purpose:     
 
4
// Author:      Ulrich Telle
 
5
// Modified by:
 
6
// Created:     2005-12-03
 
7
// Copyright:   (c) Ulrich Telle
 
8
// Licence:     wxWindows licence
 
9
///////////////////////////////////////////////////////////////////////////////
 
10
 
 
11
/// \file pdfxml.h Interface of the wxPdfDocument markup
 
12
 
 
13
#ifndef _PDF_XML_H_
 
14
#define _PDF_XML_H_
 
15
 
 
16
// wxWidgets headers
 
17
#include <wx/string.h>
 
18
#include <wx/wfstream.h>
 
19
 
 
20
// wxPdfDocument headers
 
21
#include "wx/pdfdocdef.h"
 
22
#include "wx/pdfdocument.h"
 
23
 
 
24
class WXDLLIMPEXP_FWD_PDFDOC wxPdfTable;
 
25
 
 
26
/// Class representing cell context objects. (For internal use only)
 
27
class WXDLLIMPEXP_PDFDOC wxPdfCellContext
 
28
{
 
29
public:
 
30
  /// Constructor
 
31
  wxPdfCellContext(double maxWidth, wxPdfAlignment hAlign = wxPDF_ALIGN_JUSTIFY, wxPdfAlignment vAlign = wxPDF_ALIGN_TOP);
 
32
 
 
33
  /// Destructor
 
34
  virtual ~wxPdfCellContext();
 
35
 
 
36
  /// Increase total height of cell
 
37
  void AddHeight(double height) { m_height += height; }
 
38
 
 
39
  /// Get total height of cell
 
40
  double GetHeight() { return m_height; }
 
41
 
 
42
  /// Get maximal width of cell
 
43
  double GetMaxWidth() { return m_maxWidth; }
 
44
 
 
45
  /// Get horizontal alignment
 
46
  wxPdfAlignment GetHAlign() { return m_hAlign; }
 
47
 
 
48
  /// Set vertical alignment
 
49
  void SetVAlign(wxPdfAlignment vAlign) { m_vAlign = vAlign; }
 
50
 
 
51
  /// Get vertical alignment
 
52
  wxPdfAlignment GetVAlign() { return m_vAlign; }
 
53
 
 
54
  /// Add a line to cell
 
55
  void AddLine();
 
56
 
 
57
  /// Get number of lines in cell
 
58
  unsigned int GetLineCount() { return (unsigned int) m_linewidth.GetCount(); }
 
59
 
 
60
  /// Add width and number of spaces of the last line of the current context
 
61
  void AddLastLineValues(double width, int spaces);
 
62
 
 
63
  /// Get the width of the last line
 
64
  double GetLastLineWidth();
 
65
 
 
66
  /// Mark the current line as the last line
 
67
  void MarkLastLine();
 
68
 
 
69
  /// Check whether current line is marked as last line
 
70
  bool IsCurrentLineMarked();
 
71
  
 
72
  /// Adjust width of current line
 
73
  void AddCurrentLineWidth(double width);
 
74
 
 
75
  /// Adjust number of spaces of current line
 
76
  void AddCurrentLineSpaces(int spaces);
 
77
 
 
78
  /// Get width of current line
 
79
  double GetCurrentLineWidth();
 
80
 
 
81
  /// Get number of spaces of current line
 
82
  int    GetCurrentLineSpaces();
 
83
 
 
84
  /// Get number of current line
 
85
  unsigned int GetCurrentLine() { return m_currentLine; }
 
86
 
 
87
  /// Increment line counter
 
88
  void IncrementCurrentLine();
 
89
 
 
90
  /// Get line delta measure
 
91
  double GetLineDelta();
 
92
 
 
93
  /// Check whether alignment has been taken care of
 
94
  bool GetAligned() { return m_aligned; }
 
95
 
 
96
  /// Set flag that alignment has been taken care of
 
97
  void SetAligned() { m_aligned = true; }
 
98
 
 
99
  /// Get cell fill style
 
100
  int GetFillStyle() { return m_fillStyle; }
 
101
 
 
102
  /// Set cell fill style
 
103
  void SetFillStyle(int fillStyle) { m_fillStyle = fillStyle; }
 
104
 
 
105
  /// Get the number of contexts
 
106
  unsigned int GetContextCount() { return (unsigned int) m_contexts.GetCount(); }
 
107
 
 
108
  /// Increment current context
 
109
  void IncrementCurrentContext();
 
110
 
 
111
  /// Get current context
 
112
  wxPdfCellContext* GetCurrentContext();
 
113
 
 
114
  /// Append context to context list
 
115
  void AppendContext(wxPdfCellContext* context);
 
116
 
 
117
  /// Remember the last character of the last chunk
 
118
  void SetLastChar(wxChar c) { m_lastChar = c; }
 
119
 
 
120
  /// Get last character of previous chunk
 
121
  wxChar GetLastChar() { return m_lastChar; }
 
122
 
 
123
  /// Remember the width of the last space character
 
124
  void SetLastSpaceWidth(double w) { m_spaceWidth = w; }
 
125
 
 
126
  /// Get width of last space character
 
127
  double GetLastSpaceWidth() { return m_spaceWidth; }
 
128
 
 
129
  /// Set hyper link reference
 
130
  void SetHRef(const wxString& href) { m_href = href; }
 
131
 
 
132
  /// Get hyper link reference
 
133
  wxString& GetHRef() { return m_href; }
 
134
 
 
135
  /// Set table reference
 
136
  void SetTable(wxPdfTable* table) { m_table = table; }
 
137
 
 
138
  /// Get table reference
 
139
  wxPdfTable* GetTable() { return m_table; }
 
140
 
 
141
private:
 
142
  double           m_maxWidth;        ///< maximal line width
 
143
  double           m_lineDelta;       ///< line delta measure
 
144
  wxPdfAlignment   m_hAlign;          ///< horizontal alignment
 
145
  wxPdfAlignment   m_vAlign;          ///< vertical alignment
 
146
  double           m_height;          ///< height of cell
 
147
  unsigned int     m_currentContext;  ///< index of current context
 
148
  wxArrayPtrVoid   m_contexts;        ///< list of contexts
 
149
  unsigned int     m_currentLine;     ///< index of current line
 
150
  bool             m_aligned;         ///< alignment flag
 
151
  int              m_fillStyle;       ///< cell fill style
 
152
  wxPdfArrayDouble m_linewidth;       ///< list of line widths
 
153
  wxArrayInt       m_spaces;          ///< list of space counters
 
154
  wxChar           m_lastChar;        ///< last character of a chunk
 
155
  double           m_spaceWidth;      ///< width of space character
 
156
  wxString         m_href;            ///< hyper link reference
 
157
  wxPdfTable*      m_table;           ///< table reference
 
158
};
 
159
 
 
160
/// Class representing table cells. (For internal use only)
 
161
class WXDLLIMPEXP_PDFDOC wxPdfTableCell
 
162
{
 
163
public:
 
164
  /// Constructor
 
165
  wxPdfTableCell(wxXmlNode* cell, unsigned int row, unsigned int col, unsigned int rows, unsigned int cols);
 
166
 
 
167
  /// Destructor
 
168
  virtual ~wxPdfTableCell();
 
169
 
 
170
  /// Get row of cell
 
171
  unsigned int GetRow() const { return m_row; }
 
172
 
 
173
  /// Get column of cell
 
174
  unsigned int GetCol() const { return m_col; }
 
175
 
 
176
  /// Get row span of cell
 
177
  unsigned int GetRowSpan() const { return m_rowSpan;};
 
178
 
 
179
  /// Get column span of cell
 
180
  unsigned int GetColSpan() const { return m_colSpan;};
 
181
 
 
182
  /// Set width of cell
 
183
  void SetWidth(double w) { m_width = w;};
 
184
 
 
185
  /// Set height of cell
 
186
  void SetHeight(double h) { m_height = h;};
 
187
  
 
188
  /// Get height of cell
 
189
  double GetHeight() const { return m_height;};
 
190
 
 
191
  /// Get width of cell
 
192
  double GetWidth() const { return m_width;};
 
193
 
 
194
  /// Set cell context
 
195
  void SetContext(wxPdfCellContext* context) { m_context = context; }
 
196
 
 
197
  /// Get cell context
 
198
  wxPdfCellContext* GetContext() { return m_context; }
 
199
 
 
200
  /// Set horizontal alignment
 
201
  void SetHAlign(wxPdfAlignment hAlign) { m_hAlign = hAlign; }
 
202
 
 
203
  /// Get horizontal alignment
 
204
  wxPdfAlignment GetHAlign() { return m_hAlign; }
 
205
 
 
206
  /// Set vertical alignment
 
207
  void SetVAlign(wxPdfAlignment vAlign) { m_vAlign = vAlign; }
 
208
 
 
209
  /// Get vertical alignment
 
210
  wxPdfAlignment GetVAlign() { return m_vAlign; }
 
211
 
 
212
  /// Set border
 
213
  void SetBorder(int border) { m_border = border; }
 
214
 
 
215
  /// Get border
 
216
  int GetBorder() { return m_border; }
 
217
 
 
218
  /// Check whether cell has a coloured or transparent background
 
219
  bool HasCellColour() const { return m_hasCellColour; };
 
220
 
 
221
  /// Set background colour of cell
 
222
  void SetCellColour(wxPdfColour colour) { m_hasCellColour = true; m_colourCell = colour;};
 
223
 
 
224
  /// Get background colour of cell
 
225
  wxPdfColour GetCellColour() const { return m_colourCell; };
 
226
 
 
227
  /// Get root node of cell
 
228
  wxXmlNode* GetXmlNode() { return m_cell; }
 
229
 
 
230
private:
 
231
  unsigned int      m_row;           ///< row index
 
232
  unsigned int      m_col;           ///< column index
 
233
  unsigned int      m_rowSpan;       ///< row span
 
234
  unsigned int      m_colSpan;       ///< column span
 
235
 
 
236
  wxPdfCellContext* m_context;       ///< table cell context
 
237
  wxXmlNode*        m_cell;          ///< xml root node of cell
 
238
  wxPdfAlignment    m_hAlign;        ///< horizontal alignment
 
239
  wxPdfAlignment    m_vAlign;        ///< vertical alignment
 
240
  int               m_border;        ///< border
 
241
  double            m_width;         ///< cell width
 
242
  double            m_height;        ///< cell height
 
243
  
 
244
  bool              m_hasCellColour;  ///< flag whether cell has background colour or is transparent
 
245
  wxPdfColour       m_colourCell;     ///< cell background colour
 
246
}; 
 
247
 
 
248
/// Hashmap class for document links
 
249
WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfTableCell*, wxIntegerHash, wxIntegerEqual, wxPdfCellHashMap, class WXDLLIMPEXP_PDFDOC);
 
250
 
 
251
/// Class representing tables within a cell. (For internal use only)
 
252
class WXDLLIMPEXP_PDFDOC wxPdfTable
 
253
{
 
254
public:
 
255
  /// Constructor
 
256
  wxPdfTable(wxPdfDocument* document);
 
257
 
 
258
  /// Destructor
 
259
  virtual ~wxPdfTable();
 
260
 
 
261
  /// Set minimal required row height
 
262
  void SetMinRowHeight(int row, double height) { m_minHeights[row] = height; }
 
263
 
 
264
  /// Set width of column
 
265
  void SetColumnWidth(int col, double width);
 
266
 
 
267
  /// Calculate cell dimensions respecting a maximal allowed width
 
268
  void SetCellDimensions(double maxWidth);
 
269
 
 
270
  /// Insert a cell into the cell array
 
271
  void InsertCell(wxPdfTableCell* c);
 
272
 
 
273
  /// Get height of row
 
274
  double GetRowHeight(int row) { const double height = m_rowHeights[row]; return height; };
 
275
 
 
276
  /// Write table to document
 
277
  void Write();
 
278
 
 
279
  /// Write one table row to the document
 
280
  void WriteRow(unsigned int row, double x, double y);
 
281
 
 
282
  /// Set cell padding
 
283
  void SetPad(double pad) { m_pad = pad; }
 
284
 
 
285
  /// Get cell padding
 
286
  double GetPad() { return m_pad; }
 
287
 
 
288
  /// Set border
 
289
  void SetBorder(bool border) { m_border = border; }
 
290
 
 
291
  /// Check whether border should be drawn
 
292
  bool HasBorder() { return m_border; }
 
293
 
 
294
  /// Get total width of table
 
295
  double GetTotalWidth() { return m_totalWidth; }
 
296
 
 
297
  /// Get total height of table
 
298
  double GetTotalHeight() { return m_totalHeight; }
 
299
 
 
300
  /// Set index of first header row
 
301
  void SetHeadRowFirst(unsigned int row) { m_headRowFirst = row; }
 
302
 
 
303
  /// Set index of last header row
 
304
  void SetHeadRowLast(unsigned int row) { m_headRowLast = row; }
 
305
 
 
306
  /// Set index of first body row
 
307
  void SetBodyRowFirst(unsigned int row) { m_bodyRowFirst = row; }
 
308
 
 
309
  /// Set index of last body row
 
310
  void SetBodyRowLast(unsigned int row) { m_bodyRowLast = row; }
 
311
 
 
312
private:
 
313
  wxPdfDocument* m_document;     ///< document reference
 
314
  wxPdfDoubleHashMap m_minHeights;   ///< array of minimal row heights
 
315
  wxPdfDoubleHashMap m_rowHeights;   ///< array of row heights
 
316
  wxPdfDoubleHashMap m_colWidths;    ///< array of column widths
 
317
 
 
318
  double             m_maxWidth;     ///< maximal allowed width
 
319
  double             m_totalWidth;   ///< total width
 
320
  double             m_totalHeight;  ///< total height
 
321
  double             m_headHeight;   ///< total height of table header
 
322
 
 
323
  unsigned int       m_headRowFirst; ///< index of first header row
 
324
  unsigned int       m_headRowLast;  ///< index of last header row
 
325
  unsigned int       m_bodyRowFirst; ///< index of first body row
 
326
  unsigned int       m_bodyRowLast;  ///< index of last body row
 
327
 
 
328
  unsigned int       m_nRows;        ///< number of rows
 
329
  unsigned int       m_nCols;        ///< number of columns
 
330
  wxPdfCellHashMap   m_table;        ///< array of table cells
 
331
  double             m_pad;          ///< cell padding
 
332
  bool               m_border;       ///< border flag
 
333
};
 
334
 
 
335
#endif