File indexing completed on 2024-04-21 15:55:46

0001 /************************************************************************************
0002   Copyright (C) 2003 by Jeroen Wijnhout (wijnhout@science.uva.nl)
0003                 2008-2012 by Michel Ludwig (michel.ludwig@kdemail.net)
0004  ************************************************************************************/
0005 
0006 /***************************************************************************
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 #include "outputinfo.h"
0016 
0017 OutputInfo::OutputInfo()
0018 {
0019     clear();
0020 }
0021 
0022 
0023 OutputInfo::OutputInfo(const QString& mainSourceFile, const QString& strSrcFile, int nSrcLine, int nOutputLine,
0024                        const QString& strError, int nErrorID /*=-1*/) :
0025     m_mainSourceFile(mainSourceFile),
0026     m_strSrcFile(strSrcFile),
0027     m_nSrcLine(nSrcLine),
0028     m_strError(strError),
0029     m_nOutputLine(nOutputLine),
0030     m_nErrorID(nErrorID)
0031 {
0032 }
0033 
0034 void OutputInfo::clear()
0035 {
0036     m_mainSourceFile.clear();
0037     m_strSrcFile.clear();
0038     m_nSrcLine = -1;
0039     m_nOutputLine = -1;
0040     m_strError.clear();
0041     m_nErrorID = -1;
0042 }
0043 
0044 bool OutputInfo::operator==(const OutputInfo& info) const
0045 {
0046     return (m_mainSourceFile == info.m_mainSourceFile
0047             && m_strSrcFile == info.m_strSrcFile
0048             && m_nSrcLine == info.m_nSrcLine
0049             && m_strError == info.m_strError
0050             && m_nOutputLine == info.m_nOutputLine
0051             && m_nErrorID == info.m_nErrorID);
0052 }
0053 
0054 bool OutputInfo::isValid() const
0055 {
0056     return !(m_mainSourceFile.isEmpty() && m_strSrcFile.isEmpty() && m_nSrcLine == -1 && m_nOutputLine == -1
0057              && m_strError.isEmpty() && m_nErrorID == -1);
0058 }
0059 
0060 LatexOutputInfo::LatexOutputInfo() : OutputInfo()
0061 {
0062 }
0063 
0064 
0065 LatexOutputInfo::LatexOutputInfo(const QString& mainSourceFile, const QString& strSrcFile, int nSrcLine, int nOutputLine,
0066                                  const QString& strError, int nErrorID)
0067     : OutputInfo(mainSourceFile, strSrcFile, nSrcLine, nOutputLine, strError, nErrorID)
0068 {
0069 }
0070 
0071 /**
0072  * LatexOutputHandler
0073  */
0074 
0075 LaTeXOutputHandler::LaTeXOutputHandler()
0076     : m_nErrors(-1), m_nWarnings(-1), m_nBadBoxes(-1), m_currentError(-1)
0077 {
0078 }
0079 
0080 LaTeXOutputHandler::~LaTeXOutputHandler()
0081 {
0082 
0083 }
0084 
0085 void LaTeXOutputHandler::storeLaTeXOutputParserResult(int nErrors, int nWarnings, int nBadBoxes,
0086         const LatexOutputInfoArray& outputList,
0087         const QString& logFile)
0088 {
0089     m_nErrors = nErrors;
0090     m_nWarnings = nWarnings;
0091     m_nBadBoxes = nBadBoxes;
0092     m_latexOutputInfoList = outputList;
0093     m_logFile = logFile;
0094     m_currentError = -1;
0095 }
0096 
0097 int LaTeXOutputHandler::numberOfWarnings() const
0098 {
0099     return m_nWarnings;
0100 }
0101 
0102 int LaTeXOutputHandler::numberOfErrors() const
0103 {
0104     return m_nErrors;
0105 }
0106 
0107 int LaTeXOutputHandler::numberOfBadBoxes() const
0108 {
0109     return m_nBadBoxes;
0110 }
0111 
0112 LatexOutputInfoArray LaTeXOutputHandler::outputList() const
0113 {
0114     return m_latexOutputInfoList;
0115 }
0116 
0117 QString LaTeXOutputHandler::logFile() const
0118 {
0119     return m_logFile;
0120 }
0121 
0122 int LaTeXOutputHandler::currentError() const
0123 {
0124     return m_currentError;
0125 }
0126 
0127 void LaTeXOutputHandler::setCurrentError(int i)
0128 {
0129     m_currentError = i;
0130 }
0131 
0132 const KileTool::ToolConfigPair& LaTeXOutputHandler::bibliographyBackendToolUserOverride() const
0133 {
0134     return m_userOverrideBibBackendToolConfigPair;
0135 }
0136 
0137 void LaTeXOutputHandler::setBibliographyBackendToolUserOverride(const KileTool::ToolConfigPair& p)
0138 {
0139     m_userOverrideBibBackendToolConfigPair = p;
0140 }
0141 
0142 const KileTool::ToolConfigPair& LaTeXOutputHandler::bibliographyBackendToolAutoDetected() const
0143 {
0144     return m_autodetectBibBackendToolConfigPair;
0145 }
0146 
0147 void LaTeXOutputHandler::setBibliographyBackendToolAutoDetected(const KileTool::ToolConfigPair& p)
0148 {
0149     m_autodetectBibBackendToolConfigPair = p;
0150 }
0151 
0152 void LaTeXOutputHandler::readBibliographyBackendSettings(const KConfigGroup& group)
0153 {
0154     const QString& bibBackendUserOverride = group.readEntry("bibliographyBackendUserOverride", QString());
0155     m_userOverrideBibBackendToolConfigPair = KileTool::ToolConfigPair::fromConfigStringRepresentation(bibBackendUserOverride);
0156 
0157     const QString& bibBackendAutoDetected = group.readEntry("bibliographyBackendAutoDetected", QString());
0158     m_autodetectBibBackendToolConfigPair = KileTool::ToolConfigPair::fromConfigStringRepresentation(bibBackendAutoDetected);
0159 }
0160 
0161 void LaTeXOutputHandler::writeBibliographyBackendSettings(KConfigGroup& group)
0162 {
0163     group.writeEntry("bibliographyBackendUserOverride", m_userOverrideBibBackendToolConfigPair.configStringRepresentation());
0164     group.writeEntry("bibliographyBackendAutoDetected", m_autodetectBibBackendToolConfigPair.configStringRepresentation());
0165 }