filters

layout.cc

00001 /*
00002 ** A program to convert the XML rendered by KWord into LATEX.
00003 **
00004 ** Copyright (C) 2000 Robert JACOLIN
00005 **
00006 ** This library is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU Library General Public
00008 ** License as published by the Free Software Foundation; either
00009 ** version 2 of the License, or (at your option) any later version.
00010 **
00011 ** This library is distributed in the hope that it will be useful,
00012 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 ** Library General Public License for more details.
00015 **
00016 ** To receive a copy of the GNU Library General Public License, write to the
00017 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 **
00020 */
00021 
00022 #include <stdlib.h> /* for atoi function */
00023 
00024 #include <kdebug.h> /* for kdDebug() stream */
00025 
00026 #include "fileheader.h" /* for _header use */
00027 #include "layout.h"
00028 
00029 /* Static Datas */
00030 QString Layout::_last_name;
00031 EType   Layout::_last_counter;
00032 
00033 /*******************************************/
00034 /* Constructor                             */
00035 /*******************************************/
00036 Layout::Layout()
00037 {
00038     _last_name     =  "STANDARD";
00039     _last_counter  =  TL_NONE;
00040     _env           =  ENV_LEFT;
00041     _counterType   =  TL_NONE;
00042     _counterDepth  =  0;
00043     _counterBullet =  0;
00044     _counterStart  =  0;
00045     _numberingType = -1;
00046     _useHardBreakAfter = false;
00047     _useHardBreak      = false;
00048     _keepLinesTogether = false;
00049 }
00050 
00051 /*******************************************/
00052 /* analyseLAyout                           */
00053 /*******************************************/
00054 void Layout::analyseLayout(const QDomNode balise)
00055 {
00056     /* Markup type : FORMAT id="1" pos="0" len="17">...</FORMAT> */
00057     
00058     /* No parameters for this markup */
00059     kdDebug(30522) << "ANALYSE OF THE BEGINING OF A LAYOUT" << endl;
00060     
00061     /* Analyse children markups */
00062     for(int index= 0; index < getNbChild(balise); index++)
00063     {
00064         if(getChildName(balise, index).compare("NAME")== 0)
00065         {
00066             kdDebug(30522) << "NAME : " << endl;
00067             analyseName(getChild(balise, index));
00068         }
00069         else if(getChildName(balise, index).compare("FOLLOWING")== 0)
00070         {
00071             kdDebug(30522) << "FOLLOWING : " << endl;
00072             analyseFollowing(getChild(balise, index));
00073         }
00074         else if(getChildName(balise, index).compare("FLOW")== 0)
00075         {
00076             kdDebug(30522) << "FLOW : " << endl;
00077             analyseEnv(getChild(balise, index));
00078         }
00079         else if(getChildName(balise, index).compare("PAGEBREAKING")== 0)
00080         {
00081             kdDebug(30522) << "PAGEBREAKING : " << endl;
00082             analyseBreakLine(getChild(balise, index));
00083         }
00084         else if(getChildName(balise, index).compare("COUNTER")== 0)
00085         {
00086             kdDebug(30522) << "COUNTER : " << endl;
00087             analyseCounter(getChild(balise, index));
00088         }
00089         else if(getChildName(balise, index).compare("FORMAT")== 0)
00090         {
00091             kdDebug(30522) << "FORMAT : " << endl;
00092             analyseFormat(getChild(balise, index));
00093         }
00094     }
00095     kdDebug(30522) << "END OF THE BEGINING OF A LAYOUT" << endl;
00096 }
00097 
00098 void Layout::analyseName(const QDomNode balise)
00099 {
00100     /* <NAME value="times"> */
00101     kdDebug(30522) << "PARAM" << endl;
00102     setName(getAttr(balise, "value"));
00103 }
00104 
00105 /*******************************************/
00106 /* analyseFollowing                        */
00107 /*******************************************/
00108 /* Get info about folowing. Ununsefull.    */
00109 /*******************************************/
00110 void Layout::analyseFollowing(const QDomNode balise)
00111 {
00112     /* <FOLLOWING name="times"> */
00113     kdDebug(30522) << "PARAM" << endl;
00114     setFollowing(getAttr(balise, "name"));
00115 }
00116 
00117 /*******************************************/
00118 /* analyseEnv                              */
00119 /*******************************************/
00120 /* Get informations about environment.     */
00121 /*******************************************/
00122 void Layout::analyseEnv(const QDomNode balise)
00123 {
00124     /* <FLOW align="0"> */
00125     // ERROR: Enter first in flow ????
00126     kdDebug(30522) << "PARAM" << endl;
00127     if(getAttr(balise,"align").compare("justify")== 0)
00128         setEnv(ENV_JUSTIFY);
00129     else if(getAttr(balise, "align").compare("left")== 0)
00130         setEnv(ENV_LEFT);
00131     else if(getAttr(balise, "align").compare("right")== 0)
00132         setEnv(ENV_RIGHT);
00133     else if(getAttr(balise, "align").compare("center")== 0)
00134         setEnv(ENV_CENTER);
00135 }
00136 
00137 void Layout::analyseBreakLine(const QDomNode balise)
00138 {
00139     /* <NAME hardFrameBreakAfter="true"> */
00140     kdDebug(30522) << "PARAM" << endl;
00141     if(getAttr(balise, "linesTogether") != 0)
00142         keepLinesTogether();
00143     else if(getAttr(balise, "hardFrameBreak") != 0)
00144         useHardBreak();
00145     else if(getAttr(balise, "hardFrameBreakAfter") != 0)
00146         useHardBreakAfter();
00147 }
00148 
00149 /*******************************************/
00150 /* analyseCounter                          */
00151 /*******************************************/
00152 /* Get all informations about counter.     */
00153 /* If I use a counter, I must include a tex*/
00154 /* package.                                */
00155 /*******************************************/
00156 void Layout::analyseCounter(const QDomNode balise)
00157 {
00158     /* <COUNTER type="1"> */
00159     kdDebug(30522) << "PARAM" << endl;
00160     setCounterType(getAttr(balise, "type").toInt());
00161     if(getCounterType() > TL_ARABIC && getCounterType() < TL_DISC_BULLET)
00162     {
00163         kdDebug(30522) <<  getCounterType() << endl;
00164         FileHeader::instance()->useEnumerate();
00165     }
00166     setCounterDepth(getAttr(balise, "depth").toInt());
00167     setCounterBullet(getAttr(balise, "bullet").toInt());
00168     setCounterStart(getAttr(balise, "start").toInt());
00169     setNumberingType(getAttr(balise, "numberingtype").toInt());
00170 }
KDE Home | KDE Accessibility Home | Description of Access Keys