File indexing completed on 2025-02-16 13:49:56
0001 /* 0002 ** A program to convert the XML rendered by Words into LATEX. 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 #include "config.h" 0023 0024 #include "LatexDebug.h" 0025 0026 #include <QTextStream> 0027 0028 /* Static variable */ 0029 const char Config::SPACE_CHAR = ' '; 0030 Config* Config::_instance = 0; 0031 0032 /*******************************************/ 0033 /* Constructor */ 0034 /*******************************************/ 0035 Config::Config() 0036 { 0037 _tabSize = 4; 0038 _tabulation = 0; 0039 _useLatexStyle = true; 0040 _isEmbeded = false; 0041 _convertPictures = false; 0042 } 0043 0044 Config::Config(const Config &config) 0045 { 0046 setTabSize(config.getTabSize()); 0047 setIndentation(config.getIndentation()); 0048 setClass(config.getClass()); 0049 setEmbeded(config.isEmbeded()); 0050 0051 setEncoding(config.getEncoding()); 0052 if (config.isWordsStyleUsed()) useWordsStyle(); 0053 } 0054 0055 /*******************************************/ 0056 /* Destructor */ 0057 /*******************************************/ 0058 Config::~Config() 0059 { 0060 } 0061 0062 void Config::indent() 0063 { 0064 debugLatex << "Indent tab =" << (_tabulation + getTabSize()); 0065 _tabulation = _tabulation + getTabSize(); 0066 } 0067 0068 void Config::unindent() 0069 { 0070 if ((_tabulation - getTabSize()) > 0) { 0071 debugLatex << "Unindent tab =" << (_tabulation - getTabSize()); 0072 _tabulation = _tabulation - getTabSize(); 0073 } else { 0074 debugLatex << "Unindent tab = 0"; 0075 _tabulation = 0; 0076 } 0077 } 0078 0079 void Config::writeIndent(QTextStream& out) 0080 { 0081 for (int index = 0; index < _tabulation; index++) { 0082 out << " "; 0083 } 0084 } 0085 0086 Config* Config::instance() 0087 { 0088 if (_instance == 0) 0089 _instance = new Config(); 0090 return _instance; 0091 }