summaryrefslogtreecommitdiffstats
path: root/kword/KWTableTemplate.h
blob: 729f28208e361091096f01dbf5a874d948b8d131 (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* This file is part of the KDE project
   Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; using
   version 2 of the License.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef kwtabletemplate_h
#define kwtabletemplate_h

#include "KWTableStyle.h"

#include <qdom.h>
#include <qptrlist.h>
#include <qbrush.h>

class KWTableTemplate;
class KWDocument;

/******************************************************************/
/* Class: KWTableTemplateCollection                               */
/******************************************************************/

class KWTableTemplateCollection
{
public:
    KWTableTemplateCollection();
    ~KWTableTemplateCollection();
    const QPtrList<KWTableTemplate> & tableTemplateList() const { return m_templateList; }
    void clear();

    KWTableTemplate* findTableTemplate( const QString & name );
    /**
     * Return style number @p i.
     */
    KWTableTemplate* tableTemplateAt( int i ) { return m_templateList.at(i); }

    KWTableTemplate* addTableTemplate( KWTableTemplate *tt );

    void removeTableTemplate ( KWTableTemplate *tt );

private:
    QPtrList<KWTableTemplate> m_templateList;
    QPtrList<KWTableTemplate> m_deletedTemplates;
    KWTableTemplate *m_lastTemplate;
};

/******************************************************************/
/* Class: KWTableTemplate                                            */
/******************************************************************/

class KWTableTemplate
{
public:
    KWTableTemplate( const QString & name, KWTableStyle * _firstRow=0L, KWTableStyle * _firstCol=0L,
                     KWTableStyle *_lastRow=0L, KWTableStyle *_lastCol=0L, KWTableStyle *_bodyCell=0L,
                     KWTableStyle *_topLeftCorner=0L, KWTableStyle *_topRightCorner=0L,
                     KWTableStyle *_bottomLeftCorner=0L, KWTableStyle *_bottomRightCorner=0L );

    KWTableTemplate( const KWTableTemplate & rhs ) { *this = rhs; }

    KWTableTemplate( QDomElement & parentElem, KWDocument *_doc, int docVersion=2 );

    ~KWTableTemplate() {}

    void operator=( const KWTableTemplate & );

    /** The internal name (untranslated if a standard style) */
    QString name() const { return m_name; }
    void setName( const QString & name ) { m_name = name; }
    /** The translated name */
    QString displayName() const;

    // ATTRIBUTES
    KWTableStyle firstRow() const { return *m_firstRow; }
    KWTableStyle* pFirstRow() const { return m_firstRow; }
    void setFirstRow( KWTableStyle *_tableStyle ) { m_firstRow = _tableStyle; }

    KWTableStyle lastRow() const { return *m_lastRow; }
    KWTableStyle* pLastRow() const { return m_lastRow; }
    void setLastRow( KWTableStyle *_tableStyle ) { m_lastRow = _tableStyle; }

    KWTableStyle firstCol() const { return *m_firstCol; }
    KWTableStyle* pFirstCol() const { return m_firstCol; }
    void setFirstCol( KWTableStyle *_tableStyle ) { m_firstCol = _tableStyle; }

    KWTableStyle lastCol() const { return *m_lastCol; }
    KWTableStyle* pLastCol() const { return m_lastCol; }
    void setLastCol( KWTableStyle *_tableStyle ) { m_lastCol = _tableStyle; }

    KWTableStyle bodyCell() const { return *m_bodyCell; }
    KWTableStyle* pBodyCell() const { return m_bodyCell; }
    void setBodyCell( KWTableStyle *_tableStyle ) { m_bodyCell = _tableStyle; }

    KWTableStyle topLeftCorner() const { return *m_topLeftCorner; }
    KWTableStyle* pTopLeftCorner() const { return m_topLeftCorner; }
    void setTopLeftCorner( KWTableStyle *_tableStyle ) { m_topLeftCorner = _tableStyle; }

    KWTableStyle topRightCorner() const { return *m_topRightCorner; }
    KWTableStyle* pTopRightCorner() const { return m_topRightCorner; }
    void setTopRightCorner( KWTableStyle *_tableStyle ) { m_topRightCorner = _tableStyle; }

    KWTableStyle bottomRightCorner() const { return *m_bottomRightCorner; }
    KWTableStyle* pBottomRightCorner() const { return m_bottomRightCorner; }
    void setBottomRightCorner( KWTableStyle *_tableStyle ) { m_bottomRightCorner = _tableStyle; }

    KWTableStyle bottomLeftCorner() const { return *m_bottomLeftCorner; }
    KWTableStyle* pBottomLeftCorner() const { return m_bottomLeftCorner; }
    void setBottomLeftCorner( KWTableStyle *_tableStyle ) { m_bottomLeftCorner = _tableStyle; }

    // SAVING METHODS
    void save( QDomElement parentElem, KoTextZoomHandler* zh );
    void saveTableTemplate( QDomElement & parentElem );

    // STATIC METHODS
    static KWTableTemplate *loadTemplate( QDomElement & parentElem, KWDocument *_doc, int docVersion=2 );

private:
    QString m_name;
    KWTableStyle *m_firstRow;
    KWTableStyle *m_lastRow;
    KWTableStyle *m_firstCol;
    KWTableStyle *m_lastCol;
    KWTableStyle *m_bodyCell;

    KWTableStyle *m_topLeftCorner;
    KWTableStyle *m_topRightCorner;
    KWTableStyle *m_bottomRightCorner;
    KWTableStyle *m_bottomLeftCorner;

};

#endif