filters

KWEFStructures.cc

00001 /*
00002    This file is part of the KDE project
00003    Copyright (C) 2001, 2002, 2004 Nicolas GOUTTE <goutte@kde.org>
00004    Copyright (c) 2001 IABG mbH. All rights reserved.
00005                       Contact: Wolf-Michael Bolle <Bolle@IABG.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021 */
00022 
00023 /*
00024    Part of the code is based on code licensed under the terms of the
00025    GNU Library General Public License version 2:
00026    Copyright 2001 Michael Johnson <mikej@xnet.com>
00027 */
00028 
00029 #include <kdebug.h>
00030 
00031 #include "KWEFStructures.h"
00032 
00033 
00034 TableCell::~TableCell ( void )
00035 {
00036 #if 0
00037     if ( paraList) delete paraList;
00038 #endif
00039 }
00040 
00041 void Table::addCell ( int c, int r, int _cols, int _rows, QValueList<ParaData> &p, FrameData &frameData )
00042 {
00043    if ( c + _cols > cols )
00044    {
00045       cols = c + _cols;
00046    }
00047 
00048    cellList << TableCell ( c, r, _cols, _rows, new QValueList<ParaData> (p), frameData );
00049 }
00050 
00051 bool TabulatorData::operator == (const TabulatorData& other) const
00052 {
00053     return ((m_type==other.m_type)
00054         && (m_ptpos==other.m_ptpos)
00055         && (m_filling==other.m_filling)
00056         && (m_width==other.m_width));
00057 }
00058 
00059 void VariableData::setLink(const QString& linkName, const QString& hrefName)
00060 {
00061     propertyMap["link:linkName"]=linkName;
00062     propertyMap["link:hrefName"]=hrefName;
00063 }
00064 
00065 QString VariableData::getLinkName(void) const
00066 {
00067     return propertyMap["link:linkName"];
00068 }
00069 
00070 QString VariableData::getHrefName(void) const
00071 {
00072     return propertyMap["link:hrefName"];
00073 }
00074 
00075 void VariableData::setPgNum(const QString& subtype, const QString& value)
00076 {
00077     propertyMap["pgnum:subtype"]=subtype;
00078     propertyMap["pgnum:value"]=value;
00079 }
00080 
00081 bool VariableData::isPageNumber(void) const
00082 {
00083     const int num=propertyMap["pgnum:subtype"].toInt();
00084     return (num==0);
00085 }
00086 
00087 bool VariableData::isPageCount(void) const
00088 {
00089     const int num=propertyMap["pgnum:subtype"].toInt();
00090     return (num==1);
00091 }
00092 
00093 void VariableData::setField(const QString& name, const QString& value)
00094 {
00095     propertyMap["field:name"]=name;
00096     propertyMap["field:value"]=value;
00097 }
00098 
00099 QString VariableData::getFieldName(void) const
00100 {
00101     return propertyMap["field:name"];
00102 }
00103 
00104 QString VariableData::getFieldValue(void) const
00105 {
00106     return propertyMap["field:value"];
00107 }
00108 
00109 void VariableData::setFootnote( const QString& notetype, const QString& automatic,const QString& value, QValueList<ParaData>* para)
00110 {
00111     propertyMap["footnote:value"] = value;
00112     propertyMap["footnote:auto"]  = automatic;
00113     propertyMap["footnote:notetype"]  = notetype;
00114     footnotePara = para;
00115 }
00116 
00117 bool VariableData::getFootnoteAuto(void) const
00118 {
00119     return propertyMap["footnote:auto"]=="auto";
00120 }
00121 
00122 QString VariableData::getFootnoteValue(void) const
00123 {
00124     return propertyMap["footnote:value"];
00125 }
00126 
00127 bool VariableData::getFootnoteType( void ) const
00128 {
00129     return propertyMap["footnote:notetype"] == "footnote";
00130 }
00131  
00132 QValueList<ParaData>* VariableData::getFootnotePara(void) const
00133 {
00134     return footnotePara;
00135 }
00136 
00137 void VariableData::setGenericData( const QString& key, const QString& data )
00138 {
00139     propertyMap[ key ] = data ;
00140 }
00141 
00142 QString VariableData::getGenericData( const QString& key ) const
00143 {
00144     return propertyMap[ key ];
00145 }
00146 
00147 Bookmark::Bookmark()
00148  : m_startparag(-1), m_endparag(-1), m_cursorIndexStart(-1), m_cursorIndexEnd(-1)
00149 {
00150 }
00151 
00152 void CreateMissingFormatData (QString &paraText, ValueListFormatData &paraFormatDataList)
00153 {
00154     ValueListFormatData::Iterator  paraFormatDataIt;
00155     int lastPos=0;   // last position
00156 
00157     for (paraFormatDataIt = paraFormatDataList.begin ();
00158         paraFormatDataIt != paraFormatDataList.end ();
00159         paraFormatDataIt++)
00160     {
00161         if ( (*paraFormatDataIt).pos > lastPos )
00162         {
00163 #if 0
00164             kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
00165                             << ", pos = " << (*paraFormatDataIt).pos
00166                             << ", len = " << (*paraFormatDataIt).len << " (bad)" << endl;
00167 #endif
00168 
00169             // We must add a FormatData
00170             paraFormatDataList.insert ( paraFormatDataIt,
00171                 FormatData ( lastPos, (*paraFormatDataIt).pos - lastPos, true ) );
00172         }
00173 #if 0
00174         else
00175         {
00176             kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
00177                             << ", pos = " << (*paraFormatDataIt).pos
00178                             << ", len = " << (*paraFormatDataIt).len << " (ok)" << endl;
00179         }
00180 #endif
00181 
00182 
00183         /* A check for pos < lastPos might be interesting at this point */
00184 
00185 
00186         lastPos = (*paraFormatDataIt).pos + (*paraFormatDataIt).len;
00187 
00188     }
00189 
00190     // Add the last one if needed
00191     if ( (int) paraText.length () > lastPos )
00192     {
00193 #if 0
00194         kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
00195                         << ", total len = " << paraText.length () << " (bad)" << endl;
00196 #endif
00197 
00198         paraFormatDataList.append (
00199             FormatData ( lastPos, paraText.length () - lastPos, true ) );
00200     }
00201 #if 0
00202     else
00203     {
00204         kdDebug (30508) << "CreateMissingFormatData: lastPos = " << lastPos
00205                         << ", total len = " << paraText.length () << " (ok)" << endl;
00206     }
00207 #endif
00208 }
KDE Home | KDE Accessibility Home | Description of Access Keys