wxMaxima
Loading...
Searching...
No Matches
pdfxml.h
Go to the documentation of this file.
1
2// Name: pdfxml.h
3// Purpose:
4// Author: Ulrich Telle
5// Created: 2005-12-03
6// Copyright: (c) Ulrich Telle
7// Licence: wxWindows licence
9
11
12#ifndef _PDF_XML_H_
13#define _PDF_XML_H_
14
15// wxWidgets headers
16#include <wx/string.h>
17#include <wx/wfstream.h>
18
19// wxPdfDocument headers
20#include "wx/pdfdocdef.h"
21#include "wx/pdfdocument.h"
22
23class WXDLLIMPEXP_FWD_PDFDOC wxPdfTable;
24
27class WXDLLIMPEXP_PDFDOC wxPdfCellContext
28{
29public:
31
37
39 virtual ~wxPdfCellContext();
40
42
45 void AddHeight(double height) { m_height += height; }
46
48
51 double GetHeight() { return m_height; }
52
54
57 double GetMaxWidth() { return m_maxWidth; }
58
60
63 wxPdfAlignment GetHAlign() { return m_hAlign; }
64
66
69 void SetVAlign(wxPdfAlignment vAlign) { m_vAlign = vAlign; }
70
72
75 wxPdfAlignment GetVAlign() { return m_vAlign; }
76
78 void AddLine();
79
81
84 unsigned int GetLineCount() { return (unsigned int) m_linewidth.GetCount(); }
85
87
91 void AddLastLineValues(double width, int spaces);
92
94
97 double GetLastLineWidth();
98
100 void MarkLastLine();
101
103
106 bool IsCurrentLineMarked();
107
109
112 void AddCurrentLineWidth(double width);
113
115
118 void AddCurrentLineSpaces(int spaces);
119
121
124 double GetCurrentLineWidth();
125
127
130 int GetCurrentLineSpaces();
131
133
136 unsigned int GetCurrentLine() { return m_currentLine; }
137
139 void IncrementCurrentLine();
140
142
145 double GetLineDelta();
146
148
151 bool GetAligned() { return m_aligned; }
152
154 void SetAligned() { m_aligned = true; }
155
157
160 int GetFillStyle() { return m_fillStyle; }
161
163
166 void SetFillStyle(int fillStyle) { m_fillStyle = fillStyle; }
167
169
172 unsigned int GetContextCount() { return (unsigned int) m_contexts.GetCount(); }
173
175 void IncrementCurrentContext();
176
178
181 wxPdfCellContext* GetCurrentContext();
182
184
187 void AppendContext(wxPdfCellContext* context);
188
190
193 void SetLastChar(wxUniChar c) { m_lastChar = c; }
194
196
199 wxUniChar GetLastChar() { return m_lastChar; }
200
202
205 void SetLastSpaceWidth(double w) { m_spaceWidth = w; }
206
208
211 double GetLastSpaceWidth() { return m_spaceWidth; }
212
214
217 void SetCharacterSpacing(double charSpacing) { m_charSpacing = charSpacing; }
218
220
223 double GetCharacterSpacing() { return m_charSpacing; }
224
226
229 void SetHRef(const wxString& href) { m_href = href; }
230
232
235 wxString& GetHRef() { return m_href; }
236
238
241 void SetTable(wxPdfTable* table) { m_table = table; }
242
244
247 wxPdfTable* GetTable() { return m_table; }
248
249private:
250
251 double m_maxWidth;
252 double m_lineDelta;
253 wxPdfAlignment m_hAlign;
254 wxPdfAlignment m_vAlign;
255 double m_height;
256 unsigned int m_currentContext;
257 wxArrayPtrVoid m_contexts;
258 unsigned int m_currentLine;
259 bool m_aligned;
260 int m_fillStyle;
261 wxPdfArrayDouble m_linewidth;
262 wxArrayInt m_spaces;
263 wxUniChar m_lastChar;
264 double m_spaceWidth;
265 double m_charSpacing;
266 wxString m_href;
267 wxPdfTable* m_table;
268};
269
272class WXDLLIMPEXP_PDFDOC wxPdfTableCell
273{
274public:
276
283 wxPdfTableCell(wxXmlNode* cell, unsigned int row, unsigned int col, unsigned int rows, unsigned int cols);
284
286 virtual ~wxPdfTableCell();
287
289
292 unsigned int GetRow() const { return m_row; }
293
295
298 unsigned int GetCol() const { return m_col; }
299
301
304 unsigned int GetRowSpan() const { return m_rowSpan;};
305
307
310 unsigned int GetColSpan() const { return m_colSpan;};
311
313
316 void SetWidth(double w) { m_width = w;};
317
319
322 void SetHeight(double h) { m_height = h;};
323
325
328 double GetHeight() const { return m_height;};
329
331
334 double GetWidth() const { return m_width;};
335
337
340 void SetContext(wxPdfCellContext* context) { m_context = context; }
341
343
346 wxPdfCellContext* GetContext() { return m_context; }
347
349
352 void SetHAlign(wxPdfAlignment hAlign) { m_hAlign = hAlign; }
353
355
358 wxPdfAlignment GetHAlign() { return m_hAlign; }
359
361
364 void SetVAlign(wxPdfAlignment vAlign) { m_vAlign = vAlign; }
365
367
370 wxPdfAlignment GetVAlign() { return m_vAlign; }
371
373
376 void SetBorder(int border) { m_border = border; }
377
379
382 int GetBorder() { return m_border; }
383
385
388 bool HasCellColour() const { return m_hasCellColour; };
389
391
394 void SetCellColour(wxPdfColour colour) { m_hasCellColour = true; m_colourCell = colour;};
395
397
400 wxPdfColour GetCellColour() const { return m_colourCell; };
401
403
406 wxXmlNode* GetXmlNode() { return m_cell; }
407
408private:
409 unsigned int m_row;
410 unsigned int m_col;
411 unsigned int m_rowSpan;
412 unsigned int m_colSpan;
413
414 wxPdfCellContext* m_context;
415 wxXmlNode* m_cell;
416 wxPdfAlignment m_hAlign;
417 wxPdfAlignment m_vAlign;
418 int m_border;
419 double m_width;
420 double m_height;
421
422 bool m_hasCellColour;
423 wxPdfColour m_colourCell;
424};
425
427WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfTableCell*, wxIntegerHash, wxIntegerEqual, wxPdfCellHashMap, class WXDLLIMPEXP_PDFDOC);
428
431class WXDLLIMPEXP_PDFDOC wxPdfTable
432{
433public:
435
438 wxPdfTable(wxPdfDocument* document);
439
441 virtual ~wxPdfTable();
442
444
448 void SetMinRowHeight(int row, double height) { m_minHeights[row] = height; }
449
451
455 void SetMaxRowHeight(int row, double height) { m_maxHeights[row] = height; }
456
458
462 void SetColumnWidth(int col, double width);
463
465
468 void SetCellDimensions(double maxWidth);
469
471
474 void InsertCell(wxPdfTableCell* c);
475
477
483 double WriteOnPage(bool writeHeader, double x, double y);
484
486
494 double WriteRowsOnPage(unsigned firstRow, unsigned lastRow, double x, double y, bool writeHeader);
495
497
502 unsigned int AddPage(wxArrayInt::const_iterator iter, wxArrayInt::const_iterator endIter);
503
505
512 double WriteTable(bool writeHeader, const wxArrayInt& lastRowsOnPage, double x, double y);
513
515
519 double GetRowHeight(int row) { const double height = m_rowHeights[row]; return height; };
520
522 void Write();
523
525
533 double WriteRows(unsigned int firstRow, unsigned int lastRow, double x, double y, bool isHeaderRow);
534
536
539 void SetPad(double pad) { m_pad = pad; }
540
542
545 double GetPad() { return m_pad; }
546
548
551 void SetBorder(bool border) { m_border = border; }
552
554
557 void SetBorderWidth(double borderWidth) { m_borderWidth = borderWidth; }
558
560
563 void SetBorderColour(wxPdfColour borderColour) { m_borderColour = borderColour; }
564
566
569 bool HasBorder() { return m_border; }
570
572
575 double GetTotalWidth() { return m_totalWidth; }
576
578
581 double GetHeadHeight() { return m_headHeight; }
582
584
587 double GetBodyHeight() { return m_bodyHeight; }
588
590
593 double GetTotalHeight() { return m_headHeight + m_bodyHeight; }
594
596
599 void SetHeadRowFirst(unsigned int row) { m_headRowFirst = row; }
600
602
605 void SetHeadRowLast(unsigned int row) { m_headRowLast = row; }
606
608
611 void SetBodyRowFirst(unsigned int row) { m_bodyRowFirst = row; }
612
614
617 void SetBodyRowLast(unsigned int row) { m_bodyRowLast = row; }
618
619private:
621 void WriteFillingOfCell(unsigned int row, unsigned int col, double x, double y) const;
623 void WriteFillingOfRow(unsigned int row, double x, double y) const;
625 void WriteFillingOfRows(unsigned int firstRow, unsigned int lastRow, double x, double y) const;
626
628 void WriteBordersOfCell(unsigned row, unsigned int col, double x, double y);
630 void WriteBordersOfRow(unsigned int row, double x, double y);
632 void WriteBordersOfRows(unsigned int firstRow, unsigned int lastRow, double x, double y);
633
635 void WriteContentOfCell(unsigned int row, unsigned int col, double x, double y, bool isHeaderRow);
637 void WriteContentOfRow(unsigned int row, double x, double y, bool isHeaderRow);
639 double WriteContentOfRows(unsigned int firstRow, unsigned int lastRow, double x, double y, bool isHeaderRow);
640
644 wxArrayInt GetLastRowsOnPage() const;
646 void DrawCellBorders(double x, double y, double w, double h, wxPdfTableCell* cell) const;
648 void DrawCellFilling(double x, double y, double w, double h, wxPdfTableCell* cell) const;
650 void DrawCellContent(double x, double y, bool isHeaderRow, double w, double h, wxPdfTableCell* cell);
652 void CalculateCellDimension(unsigned row, unsigned col, double& w, double& h,
653 wxPdfTableCell* cell) const;
654
655 wxPdfDocument* m_document;
656 wxPdfDoubleHashMap m_minHeights;
657 wxPdfDoubleHashMap m_rowHeights;
658 wxPdfDoubleHashMap m_colWidths;
659 wxPdfDoubleHashMap m_maxHeights;
660
661 double m_totalWidth;
662 double m_bodyHeight;
663 double m_headHeight;
664
665 unsigned int m_headRowFirst;
666 unsigned int m_headRowLast;
667 unsigned int m_bodyRowFirst;
668 unsigned int m_bodyRowLast;
669
670 unsigned int m_nRows;
671 unsigned int m_nCols;
672 wxPdfCellHashMap m_table;
673 double m_pad;
674 bool m_border;
675 double m_borderWidth;
676 wxPdfColour m_borderColour;
677};
678
679#endif
Class representing cell context objects. (For internal use only)
Definition: pdfxml.h:28
void SetAligned()
Set flag that alignment has been taken care of.
Definition: pdfxml.h:154
void SetTable(wxPdfTable *table)
Set reference to an embedded markup table.
Definition: pdfxml.h:241
wxUniChar GetLastChar()
Get last character of previous chunk.
Definition: pdfxml.h:199
void SetCharacterSpacing(double charSpacing)
Remember the character spacing.
Definition: pdfxml.h:217
void SetVAlign(wxPdfAlignment vAlign)
Set vertical alignment.
Definition: pdfxml.h:69
double GetLastSpaceWidth()
Get width of last space character.
Definition: pdfxml.h:211
double GetCharacterSpacing()
Get character spacing.
Definition: pdfxml.h:223
unsigned int GetContextCount()
Get the number of contexts.
Definition: pdfxml.h:172
wxPdfAlignment GetVAlign()
Get vertical alignment.
Definition: pdfxml.h:75
int GetFillStyle()
Get cell fill style.
Definition: pdfxml.h:160
bool GetAligned()
Check whether alignment has been taken care of.
Definition: pdfxml.h:151
double GetMaxWidth()
Get maximum width of cell.
Definition: pdfxml.h:57
unsigned int GetLineCount()
Get number of lines in cell.
Definition: pdfxml.h:84
double GetHeight()
Get total height of cell.
Definition: pdfxml.h:51
void SetLastSpaceWidth(double w)
Remember the width of the last space character.
Definition: pdfxml.h:205
void SetHRef(const wxString &href)
Set hyper link reference.
Definition: pdfxml.h:229
void SetFillStyle(int fillStyle)
Set cell fill style.
Definition: pdfxml.h:166
void SetLastChar(wxUniChar c)
Remember the last character of the last chunk.
Definition: pdfxml.h:193
void AddHeight(double height)
Increase total height of cell.
Definition: pdfxml.h:45
wxPdfAlignment GetHAlign()
Get horizontal alignment.
Definition: pdfxml.h:63
unsigned int GetCurrentLine()
Get number of current line.
Definition: pdfxml.h:136
wxPdfTable * GetTable()
Get reference to an embedded markup table.
Definition: pdfxml.h:247
wxString & GetHRef()
Get hyper link reference.
Definition: pdfxml.h:235
Class representing wxPdfDocument colours.
Definition: pdfcolour.h:40
Class representing a PDF document.
Definition: pdfdocument.h:176
Class representing table cells. (For internal use only)
Definition: pdfxml.h:273
void SetHAlign(wxPdfAlignment hAlign)
Set horizontal alignment.
Definition: pdfxml.h:352
void SetCellColour(wxPdfColour colour)
Set background colour of cell.
Definition: pdfxml.h:394
int GetBorder()
Get border.
Definition: pdfxml.h:382
void SetContext(wxPdfCellContext *context)
Set cell context.
Definition: pdfxml.h:340
unsigned int GetRowSpan() const
Get row span of cell.
Definition: pdfxml.h:304
wxXmlNode * GetXmlNode()
Get root node of cell.
Definition: pdfxml.h:406
bool HasCellColour() const
Check whether cell has a coloured or transparent background.
Definition: pdfxml.h:388
wxPdfCellContext * GetContext()
Get cell context.
Definition: pdfxml.h:346
wxPdfColour GetCellColour() const
Get background colour of cell.
Definition: pdfxml.h:400
double GetHeight() const
Get height of cell.
Definition: pdfxml.h:328
unsigned int GetColSpan() const
Get column span of cell.
Definition: pdfxml.h:310
void SetBorder(int border)
Set border.
Definition: pdfxml.h:376
double GetWidth() const
Get width of cell.
Definition: pdfxml.h:334
unsigned int GetRow() const
Get row of cell.
Definition: pdfxml.h:292
unsigned int GetCol() const
Get column of cell.
Definition: pdfxml.h:298
void SetVAlign(wxPdfAlignment vAlign)
Set vertical alignment.
Definition: pdfxml.h:364
void SetWidth(double w)
Set width of cell.
Definition: pdfxml.h:316
wxPdfAlignment GetHAlign()
Get horizontal alignment.
Definition: pdfxml.h:358
wxPdfAlignment GetVAlign()
Get vertical alignment.
Definition: pdfxml.h:370
void SetHeight(double h)
Set height of cell.
Definition: pdfxml.h:322
Class representing tables within a cell. (For internal use only)
Definition: pdfxml.h:432
double GetTotalWidth()
Get total width of table.
Definition: pdfxml.h:575
bool HasBorder()
Check whether border should be drawn.
Definition: pdfxml.h:569
double GetHeadHeight()
Get height of table head.
Definition: pdfxml.h:581
void SetBorderWidth(double borderWidth)
Set border size.
Definition: pdfxml.h:557
void SetHeadRowFirst(unsigned int row)
Set index of first header row.
Definition: pdfxml.h:599
double GetBodyHeight()
Get height of table body.
Definition: pdfxml.h:587
double GetRowHeight(int row)
Get height of row.
Definition: pdfxml.h:519
double GetPad()
Get cell padding.
Definition: pdfxml.h:545
double GetTotalHeight()
Get total height of table.
Definition: pdfxml.h:593
void SetHeadRowLast(unsigned int row)
Set index of last header row.
Definition: pdfxml.h:605
void SetBodyRowLast(unsigned int row)
Set index of last body row.
Definition: pdfxml.h:617
void SetBodyRowFirst(unsigned int row)
Set index of first body row.
Definition: pdfxml.h:611
void SetBorder(bool border)
Set border flag.
Definition: pdfxml.h:551
void SetMaxRowHeight(int row, double height)
Set maximum allowed row height.
Definition: pdfxml.h:455
void SetBorderColour(wxPdfColour borderColour)
Set border colour.
Definition: pdfxml.h:563
void SetMinRowHeight(int row, double height)
Set minimum required row height.
Definition: pdfxml.h:448
void SetPad(double pad)
Set cell padding.
Definition: pdfxml.h:539
Compile time switches for the wxPdfDocument component.
Interface of the wxPdfDocument class.
wxPdfAlignment
Alignment options.
Definition: pdfproperties.h:164
@ wxPDF_ALIGN_JUSTIFY
Justified alignment.
Definition: pdfproperties.h:168
@ wxPDF_ALIGN_TOP
Top alignment (alias for left)
Definition: pdfproperties.h:169
WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfTableCell *, wxIntegerHash, wxIntegerEqual, wxPdfCellHashMap, class WXDLLIMPEXP_PDFDOC)
Hashmap class for document links.