forked from lpxxn/docx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtable.h
121 lines (103 loc) · 2.51 KB
/
table.h
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
#ifndef TABLE_H
#define TABLE_H
#include "docx_global.h"
#include "shared.h"
#include "./oxml/oxmltable.h"
#include "length.h"
#include <QString>
#include <QDomDocument>
#include <QSharedPointer>
namespace Docx {
class DocumentPart;
class Paragraph;
class Column;
class Row;
class Cell;
class Columns;
class DOCX_EXPORT Table
{
public:
Table(DocumentPart *part, const QDomElement &element);
Cell* cell(int rowIndex, int colIndex);
Row* addRow();
Column* addColumn();
Cell *merge(int startRowIdx, int startColIdx, int endRowIdx, int endColIdx);
QList<Cell*> rowCells(int rowIndex);
QList<Row *> rows();
void setStyle(const QString &style);
void setAlignment(WD_TABLE_ALIGNMENT alignment);
virtual ~Table();
void loadExistRowElement();
private:
QList<Row*> m_rows;
DocumentPart *m_part = nullptr;
QDomDocument *m_dom = nullptr;
CT_Tbl *m_ctTbl = nullptr;
friend class Row;
friend class CT_Tbl;
};
class DOCX_EXPORT Cell
{
public:
Cell(const QDomElement &element, Row *row);
Paragraph *addParagraph(const QString &text = QString(), const QString &style = QString());
void addText(const QString &text, QString halign=QString("center"), QString valign=QString("center"));
Table *addTable(int rows, int cols, const QString &style = QString::fromLatin1("TableGrid"));
Cell *merge(Cell *other, bool isAddParagraph = true);
int cellIndex();
int rowIndex();
Table *table();
virtual ~Cell();
public:
QDomDocument *m_dom;
DocumentPart *m_part;
QList<Paragraph *> m_paras;
Paragraph *m_currentpara;
Row *m_row;
QDomElement m_valign;
QSharedPointer<CT_Tc> m_tc;
friend class CT_Tc;
friend class Row;
};
class DOCX_EXPORT Columns
{
public:
Columns();
virtual ~Columns();
private:
};
class DOCX_EXPORT Column
{
public:
Column(const QDomElement &tlGrid, int gridIndex, Table *table);
Length width() const;
void setWidth();
virtual ~Column();
private:
QDomElement m_grid;
Table *m_table;
int m_index;
};
class DOCX_EXPORT Row
{
public:
Row(const QDomElement &element, Table *table);
void loadExistElement();
Table *table() const;
QList<Cell *> cells() const;
Table *table();
int rowIndex();
virtual ~Row();
private:
void addTc();
private:
QList<Cell *> m_cells;
QDomElement m_ele;
Table *m_table;
DocumentPart *m_part;
QDomDocument *m_dom;
friend class Cell;
friend class Table;
};
}
#endif // TABLE_H