KWEFStructures.cpp
1/*
2 This file is part of the KDE project
3 Copyright (C) 2001, 2002, 2004 Nicolas GOUTTE <goutte@kde.org>
4 Copyright (c) 2001 IABG mbH. All rights reserved.
5 Contact: Wolf-Michael Bolle <Bolle@IABG.de>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21*/
22
23/*
24 Part of the code is based on code licensed under the terms of the
25 GNU Library General Public License version 2:
26 Copyright 2001 Michael Johnson <mikej@xnet.com>
27*/
28
29#include <kdebug.h>
30
31#include "KWEFStructures.h"
32
33
34TableCell::~TableCell ( void )
35{
36#if 0
37 if ( paraList) delete paraList;
38#endif
39}
40
41void Table::addCell ( int c, int r, int _cols, int _rows, TQValueList<ParaData> &p, FrameData &frameData )
42{
43 if ( c + _cols > cols )
44 {
45 cols = c + _cols;
46 }
47
48 cellList << TableCell ( c, r, _cols, _rows, new TQValueList<ParaData> (p), frameData );
49}
50
51bool TabulatorData::operator == (const TabulatorData& other) const
52{
53 return ((m_type==other.m_type)
54 && (m_ptpos==other.m_ptpos)
55 && (m_filling==other.m_filling)
56 && (m_width==other.m_width));
57}
58
59void VariableData::setLink(const TQString& linkName, const TQString& hrefName)
60{
61 propertyMap["link:linkName"]=linkName;
62 propertyMap["link:hrefName"]=hrefName;
63}
64
65TQString VariableData::getLinkName(void) const
66{
67 return propertyMap["link:linkName"];
68}
69
70TQString VariableData::getHrefName(void) const
71{
72 return propertyMap["link:hrefName"];
73}
74
75void VariableData::setPgNum(const TQString& subtype, const TQString& value)
76{
77 propertyMap["pgnum:subtype"]=subtype;
78 propertyMap["pgnum:value"]=value;
79}
80
81bool VariableData::isPageNumber(void) const
82{
83 const int num=propertyMap["pgnum:subtype"].toInt();
84 return (num==0);
85}
86
87bool VariableData::isPageCount(void) const
88{
89 const int num=propertyMap["pgnum:subtype"].toInt();
90 return (num==1);
91}
92
93void VariableData::setField(const TQString& name, const TQString& value)
94{
95 propertyMap["field:name"]=name;
96 propertyMap["field:value"]=value;
97}
98
99TQString VariableData::getFieldName(void) const
100{
101 return propertyMap["field:name"];
102}
103
104TQString VariableData::getFieldValue(void) const
105{
106 return propertyMap["field:value"];
107}
108
109void VariableData::setFootnote( const TQString& notetype, const TQString& automatic,const TQString& value, TQValueList<ParaData>* para)
110{
111 propertyMap["footnote:value"] = value;
112 propertyMap["footnote:auto"] = automatic;
113 propertyMap["footnote:notetype"] = notetype;
114 footnotePara = para;
115}
116
118{
119 return propertyMap["footnote:auto"]=="auto";
120}
121
123{
124 return propertyMap["footnote:value"];
125}
126
128{
129 return propertyMap["footnote:notetype"] == "footnote";
130}
131
132TQValueList<ParaData>* VariableData::getFootnotePara(void) const
133{
134 return footnotePara;
135}
136
137void VariableData::setGenericData( const TQString& key, const TQString& data )
138{
139 propertyMap[ key ] = data ;
140}
141
142TQString VariableData::getGenericData( const TQString& key ) const
143{
144 return propertyMap[ key ];
145}
146
147Bookmark::Bookmark()
148 : m_startparag(-1), m_endparag(-1), m_cursorIndexStart(-1), m_cursorIndexEnd(-1)
149{
150}
151
152void CreateMissingFormatData (TQString &paraText, ValueListFormatData &paraFormatDataList)
153{
154 ValueListFormatData::Iterator paraFormatDataIt;
155 int lastPos=0; // last position
156
157 for (paraFormatDataIt = paraFormatDataList.begin ();
158 paraFormatDataIt != paraFormatDataList.end ();
159 paraFormatDataIt++)
160 {
161 if ( (*paraFormatDataIt).pos > lastPos )
162 {
163#if 0
164 kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
165 << ", pos = " << (*paraFormatDataIt).pos
166 << ", len = " << (*paraFormatDataIt).len << " (bad)" << endl;
167#endif
168
169 // We must add a FormatData
170 paraFormatDataList.insert ( paraFormatDataIt,
171 FormatData ( lastPos, (*paraFormatDataIt).pos - lastPos, true ) );
172 }
173#if 0
174 else
175 {
176 kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
177 << ", pos = " << (*paraFormatDataIt).pos
178 << ", len = " << (*paraFormatDataIt).len << " (ok)" << endl;
179 }
180#endif
181
182
183 /* A check for pos < lastPos might be interesting at this point */
184
185
186 lastPos = (*paraFormatDataIt).pos + (*paraFormatDataIt).len;
187
188 }
189
190 // Add the last one if needed
191 if ( (int) paraText.length () > lastPos )
192 {
193#if 0
194 kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
195 << ", total len = " << paraText.length () << " (bad)" << endl;
196#endif
197
198 paraFormatDataList.append (
199 FormatData ( lastPos, paraText.length () - lastPos, true ) );
200 }
201#if 0
202 else
203 {
204 kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
205 << ", total len = " << paraText.length () << " (ok)" << endl;
206 }
207#endif
208}
For <FRAME> Tag.
void addCell(int c, int r, int _cols, int _rows, TQValueList< ParaData > &p, FrameData &frameData)
Tabulator (see also <TABULATOR> element in KWord's DTD)
TQString getFootnoteValue(void) const
Get the value (counter) of the footnote.
TQString getHrefName(void) const
Reference of link (attribute "hrefName" of <LINK>)
bool getFootnoteType(void) const
Get type of footnote.
TQValueList< ParaData > * getFootnotePara(void) const
Paragrapgh of the footnote.
void setLink(const TQString &linkName, const TQString &hrefName)
Set parameters of a LINK element.
void setGenericData(const TQString &key, const TQString &data)
Set generic variable data.
void setField(const TQString &subtype, const TQString &value)
Set parameters of a FIELD element.
void setFootnote(const TQString &notetype, const TQString &automatic, const TQString &value, TQValueList< ParaData > *para)
Set parameters of a <FOOTNOTE> element.
TQString getGenericData(const TQString &key) const
Get generic variable data.
TQString getLinkName(void) const
Name of link (attribute "linkName" of <LINK>)
void setPgNum(const TQString &subtype, const TQString &value)
Set parameters of a PGNUM element.
bool getFootnoteAuto(void) const
Is the footnote an automatic one?