File indexing completed on 2025-02-16 13:49:56

0001 /*
0002 ** Header file for inclusion with words_xml2latex.c
0003 **
0004 ** Copyright (C) 2000, 2002 Robert JACOLIN
0005 **
0006 ** This library is free software; you can redistribute it and/or
0007 ** modify it under the terms of the GNU Library General Public
0008 ** License as published by the Free Software Foundation; either
0009 ** version 2 of the License, or (at your option) any later version.
0010 **
0011 ** This library is distributed in the hope that it will be useful,
0012 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014 ** Library General Public License for more details.
0015 **
0016 ** To receive a copy of the GNU Library General Public License, write to the
0017 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 **
0020 */
0021 
0022 #ifndef __CALLIGRA_SHEETS_LATEX_FILEHEADER_H__
0023 #define __CALLIGRA_SHEETS_LATEX_FILEHEADER_H__
0024 
0025 #include <QTextStream>
0026 
0027 #include "xmlparser.h"
0028 
0029 /***********************************************************************/
0030 /* Class: FileHeader                                                   */
0031 /***********************************************************************/
0032 
0033 /**
0034  * This class holds all general information about the doc: does it use a color markup, ... ?
0035  * paper size, ... and generates the information about the doc (packages and extensions
0036  * to include, ...). It's the configuration latex file used to include the needed packages,
0037  * define the paper format, ...
0038  */
0039 class FileHeader: public XmlParser
0040 {
0041 public:
0042     enum TFormat { TF_A3, TF_A4, TF_A5, TF_USLETTER, TF_USLEGAL, TF_SCREEN,
0043                    TF_CUSTOM, TF_B3, TF_USEXECUTIVE
0044                  };
0045     enum TUnit { TMillimeter, TCentimeter, TPoint, TInch };
0046     enum TOrient { TO_PORTRAIT, TO_LANDSCAPE };
0047     enum TColonne { TC_NONE, TC_1, TC_2, TC_MORE };
0048     enum THeadfoot { TH_ALL = 0, TH_XXX = 1, TH_FIRST = 2, TH_EVODD = 3 };
0049     enum TProcType { TP_NORMAL, TP_DTP };
0050 
0051     static FileHeader* instance(void);
0052 
0053 private:
0054     /* PAPER */
0055     TFormat   _format;
0056     double    _width,
0057     _height;
0058     TOrient   _orientation;
0059     TColonne  _colonne;
0060     double    _columnSpacing;
0061     THeadfoot _headType;
0062     THeadfoot _footType;
0063     TProcType _processing;
0064     int       _standardPage;
0065     double    _footBody;
0066     double    _headBody;
0067 
0068     /* PAPERBORDERS */
0069     double    _leftBorder,
0070     _rightBorder,
0071     _bottomBorder,
0072     _topBorder;
0073 
0074     /* ATTRIBUTES */
0075     TUnit    _unite;
0076     bool     _hasHeader;
0077     bool     _hasFooter;
0078     bool     _hasTOC;
0079 
0080     /* FOOTNOTEMGR */
0081 
0082     /* DIVERSE */
0083     /* for special packages to include */
0084     bool     _hasColor;
0085     bool     _hasUnderline;
0086     bool     _hasEnumerate;
0087     bool     _hasGraphics;
0088     bool     _hasTable;
0089 
0090 public:
0091 
0092     /**
0093      * Destructor
0094      */
0095     ~FileHeader() override;
0096 
0097     /**
0098      * Accessors
0099      */
0100     TFormat   getFormat() const {
0101         return _format;
0102     }
0103     TOrient   getOrientation() const {
0104         return _orientation;
0105     }
0106     TColonne  getColumns() const {
0107         return _colonne;
0108     }
0109     THeadfoot getHeadType() const {
0110         return _headType;
0111     }
0112     THeadfoot getFootType() const {
0113         return _footType;
0114     }
0115     TUnit     getUnit() const {
0116         return _unite;
0117     }
0118     TProcType getProcessing() const {
0119         return _processing;
0120     }
0121     int       getStandardPge() const {
0122         return _standardPage;
0123     }
0124     bool      hasHeader() const {
0125         return _hasHeader;
0126     }
0127     bool      hasFooter() const {
0128         return _hasFooter;
0129     }
0130     bool      hasTOC() const {
0131         return _hasTOC;
0132     }
0133     bool      hasColor() const {
0134         return _hasColor;
0135     }
0136     bool      hasUnderline() const {
0137         return _hasUnderline;
0138     }
0139     bool      hasEnumerate() const {
0140         return _hasEnumerate;
0141     }
0142     bool      hasGraphics() const {
0143         return _hasGraphics;
0144     }
0145     bool      hasTable() const {
0146         return _hasTable;
0147     }
0148 
0149     /**
0150      * Modifiers
0151      */
0152     void setFormat(TFormat f)  {
0153         _format       = f;
0154     }
0155     void setFormat(int f)      {
0156         _format       = (TFormat) f;
0157     }
0158     void setOrientation(TOrient o)  {
0159         _orientation  = o;
0160     }
0161     void setOrientation(int o)      {
0162         _orientation  = (TOrient) o;
0163     }
0164     void setColumns(TColonne c) {
0165         _colonne      = c;
0166     }
0167     void setColumns(int c)      {
0168         _colonne      = (TColonne) c;
0169     }
0170     void setUnit(int u)      {
0171         _unite        = (TUnit) u;
0172     }
0173     void setProcessing(int p)      {
0174         _processing   = (TProcType) p;
0175     }
0176     void setStandardPge(int s)      {
0177         _standardPage = s;
0178     }
0179     void setTOC(int t)      {
0180         _hasTOC       = t;
0181     }
0182     void setHeadType(int ht)     {
0183         _headType     = (THeadfoot) ht;
0184     }
0185     void setFootType(int ft)     {
0186         _footType     = (THeadfoot) ft;
0187     }
0188     void useColor()           {
0189         _hasColor     = true;
0190     }
0191     void useUnderline()           {
0192         _hasUnderline = true;
0193     }
0194     void useEnumerate()           {
0195         _hasEnumerate = true;
0196     }
0197     void useGraphics()           {
0198         _hasGraphics  = true;
0199     }
0200     void useTable()           {
0201         _hasTable     = true;
0202     }
0203 
0204     void analyzePaper(const QDomNode);
0205     void analyzeAttributes(const QDomNode);
0206 
0207     void generate(QTextStream &);
0208 
0209 protected:
0210     /**
0211      * Constructor
0212      */
0213     FileHeader();  /* Ensure singleton */
0214 
0215     static FileHeader* _instance; /* singleton */
0216 
0217 private:
0218 
0219     void analyzePaperParam(const QDomNode);
0220 
0221     void generatePaper(QTextStream&);
0222     void generateLatinPreamble(QTextStream&);
0223     void generateUnicodePreamble(QTextStream&);
0224     void generatePackage(QTextStream&);
0225 
0226 };
0227 
0228 #endif /* __CALLIGRA_SHEETS_LATEX_FILEHEADER_H__ */