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

0001 /*
0002 ** Header file for inclusion with words_xml2latex.c
0003 **
0004 ** Copyright (C) 2002 - 2003 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 __LATEX_CONFIG_H__
0023 #define __LATEX_CONFIG_H__
0024 
0025 #include <QTextStream>
0026 #include <QStringList>
0027 
0028 /***********************************************************************/
0029 /* Class: Config                                                       */
0030 /***********************************************************************/
0031 
0032 /**
0033  * This class holds all parameters and configuration from a file or from
0034  * the filter configuration dialog box. It's a singleton, so you may use
0035  * the instance() method to get this instance.
0036  */
0037 class Config
0038 {
0039     /* Document tab */
0040     bool _useLatexStyle;
0041     bool _isEmbeded;
0042     QString _class;
0043     QString _quality;
0044     unsigned int _defaultFontSize;
0045 
0046     /* Pictures tab */
0047     bool _convertPictures;
0048     QString _picturesDir;
0049 
0050     /* Language tab */
0051     //bool _useUnicode;
0052     //bool _useLatin1;
0053     QString _encoding;
0054     QStringList _languagesList;
0055     QString _defaultLanguage;
0056 
0057     int _tabSize; /* Size of the para indentation. */
0058     int _tabulation; /* Total size  of the indentation. */
0059 
0060 public:
0061 
0062     static const char SPACE_CHAR;
0063 
0064     static Config* instance(void);
0065 
0066     Config(const Config&);
0067 
0068     /*
0069      * Destructor
0070      */
0071     virtual ~Config();
0072 
0073     /* ==== Getters ==== */
0074 
0075     /**
0076      * Return the value of a tabulation.
0077      */
0078     bool isWordsStyleUsed() const {
0079         return (_useLatexStyle == false);
0080     }
0081     bool isEmbeded() const {
0082         return _isEmbeded;
0083     }
0084     QString getClass() const {
0085         return _class;
0086     }
0087     QString getQuality() const {
0088         return _quality;
0089     }
0090     unsigned int getDefaultFontSize() const {
0091         return _defaultFontSize;
0092     }
0093 
0094     bool convertPictures() const {
0095         return _convertPictures;
0096     }
0097     QString getPicturesDir() const {
0098         return _picturesDir;
0099     }
0100 
0101     bool mustUseUnicode() const {
0102         return (_encoding == "unicode");
0103     }
0104     bool mustUseLatin1() const {
0105         return (_encoding != "unicode");
0106     }
0107     QString getEncoding() const {
0108         return _encoding;
0109     }
0110     QStringList getLanguagesList() const {
0111         return _languagesList;
0112     }
0113     QString getDefaultLanguage() const {
0114         return _defaultLanguage;
0115     }
0116 
0117     int getTabSize() const {
0118         return _tabSize;
0119     }
0120     int getIndentation() const {
0121         return _tabulation;
0122     }
0123 
0124     /* ==== Setters ==== */
0125 
0126     /**
0127      * Initialize the tab size.
0128      * @param size New size. Must be greater or equal to 0.
0129      */
0130     void setTabSize(int size) {
0131         if (size >= 0)
0132             _tabSize = size;
0133     }
0134 
0135     void useLatexStyle() {
0136         _useLatexStyle = true;
0137     }
0138     void useWordsStyle() {
0139         _useLatexStyle = false;
0140     }
0141     void setEmbeded(bool emb) {
0142         _isEmbeded = emb;
0143     }
0144     /** The class can be article, book, letter, report or slides. It's the type of the
0145      * latex document. */
0146     void setClass(const QString &lclass) {
0147         _class = lclass;
0148     }
0149     void setQuality(const QString &quality) {
0150         _quality = quality;
0151     }
0152     void setDefaultFontSize(int size) {
0153         _defaultFontSize = size;
0154     }
0155 
0156     void convertPictures(bool state) {
0157         _convertPictures = state;
0158     }
0159     void setPicturesDir(const QString &dir) {
0160         _picturesDir = dir;
0161     }
0162 
0163     void setEncoding(const QString &enc) {
0164         _encoding = enc;
0165     }
0166     void addLanguage(const QString &l) {
0167         _languagesList.append(l);
0168     }
0169     void setDefaultLanguage(const QString &l) {
0170         _defaultLanguage = l;
0171     }
0172 
0173     void setIndentation(int indent) {
0174         _tabulation = indent;
0175     }
0176 
0177     /* ==== Helpful functions ==== */
0178     void indent();
0179     void unindent();
0180 
0181     void writeIndent(QTextStream& out);
0182 
0183 protected:
0184     /**
0185      * Constructors
0186      *
0187      * Creates a new instance of Config.
0188      * Initialize params to default values.
0189      */
0190     Config(); /* Ensure singleton */
0191 
0192     static Config* _instance; /* Singleton */
0193 
0194 private:
0195 
0196 };
0197 
0198 #endif /* __LATEX_CONFIG_H__ */