tablehandler.h
1/* This file is part of the KOffice project
2 Copyright (C) 2002 Werner Trobin <trobin@kde.org>
3 Copyright (C) 2002 David Faure <faure@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef TABLEHANDLER_H
21#define TABLEHANDLER_H
22
23#include <wv2/functor.h>
24#include <wv2/word97_generated.h> // for TAP
25#include <wv2/handlers.h>
26#include <tqstring.h>
27#include <tqvaluelist.h>
28#include <tqobject.h>
29#include <deque>
30
31namespace wvWare {
32 namespace Word97 {
33 class TC;
34 class SHD;
35 }
36}
37class KoRect;
38
39namespace KWord
40{
41 typedef const wvWare::TableRowFunctor* TableRowFunctorPtr;
42 typedef wvWare::SharedPtr<const wvWare::Word97::TAP> TAPptr;
43
44 // Data for a given row table. This struct is used by the Table struct.
45 struct Row
46 {
47 Row() : functorPtr( 0L ), tap( 0L ) {} // TQValueList wants that one
48 Row( TableRowFunctorPtr ptr, TAPptr _tap ) : functorPtr(ptr), tap(_tap) {}
49 ~Row() {}
50
51 // Each row has: a functor to call to parse it and a TAP (table row properties)
52 TableRowFunctorPtr functorPtr;
53 TAPptr tap;
54 };
55
56 // Data for a given table, stored between the 'tableRowFound' callback
57 // during text parsing and the final generation of table cells.
58 struct Table
59 {
60 TQString name; // kword's grpMgr attribute
61 TQValueList<Row> rows; // need to use TQValueList to benefit from implicit sharing
62
63 // Word has a very flexible concept of columns: each row can vary the
64 // edges of each column. We must map this onto a set of fixed-width columns
65 // by defining columns on each edge, and then using joined cells to model
66 // the original Word cells. We accumulate all the known edges for a given
67 // table in an array.
68 // Important: don't use unsigned int. Value can be negative (relative to margin...).
69 TQMemArray<int> m_cellEdges;
70
71 void cacheCellEdge( int cellEdge );
72 int columnNumber( int cellEdge ) const;
73 };
74}
75
76class KWordTableHandler : public TQObject, public wvWare::TableHandler
77{
78 TQ_OBJECT
79
80public:
81 KWordTableHandler();
82
84 virtual void tableRowStart( wvWare::SharedPtr<const wvWare::Word97::TAP> tap );
85 virtual void tableRowEnd();
86 virtual void tableCellStart();
87 virtual void tableCellEnd();
88
90 void tableStart( KWord::Table* table );
91 void tableEnd();
92
93signals:
94 // Tells Document to create frameset for cell
95 void sigTableCellStart( int row, int column, int rowSpan, int columnSpan, const KoRect& cellRect, const TQString& tableName, const wvWare::Word97::BRC& brcTop, const wvWare::Word97::BRC& brcBottom, const wvWare::Word97::BRC& brcLeft, const wvWare::Word97::BRC& brcRight, const wvWare::Word97::SHD& shd );
96 void sigTableCellEnd();
97
98protected:
99 double rowHeight() const;
100
101private:
102 KWord::Table* m_currentTable;
103 int m_row;
104 int m_column;
105 double m_currentY;
106 wvWare::SharedPtr<const wvWare::Word97::TAP> m_tap;
107};
108
109#endif // TABLEHANDLER_H
This class hold a row.
Definition row.h:38
This class hold a table.