File indexing completed on 2024-04-28 11:20:49

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com>
0004     SPDX-FileCopyrightText: 2022 Alexander Semke <alexander.semke@web.de>
0005 */
0006 
0007 #ifndef _TEXTRESULT_H
0008 #define _TEXTRESULT_H
0009 
0010 #include "result.h"
0011 
0012 #include "cantor_export.h"
0013 
0014 namespace Cantor
0015 {
0016 
0017 class TextResultPrivate;
0018 class CANTOR_EXPORT TextResult : public Result
0019 {
0020   public:
0021     enum { Type=1 };
0022     enum Format { PlainTextFormat, LatexFormat};
0023 
0024     TextResult(const QString& text);
0025     TextResult(const QString& text, const QString& plain);
0026     ~TextResult() override;
0027 
0028     void setIsWarning(bool);
0029     bool isWarning() const;
0030 
0031     QString toHtml() override;
0032     QVariant data() override;
0033 
0034     QString plain();
0035 
0036     int type() override;
0037     QString mimeType() override;
0038 
0039     Format format();
0040     void setFormat(Format f);
0041 
0042     bool isStderr() const;
0043     void setStdErr(bool value);
0044 
0045     QDomElement toXml(QDomDocument& doc) override;
0046     QJsonValue toJupyterJson() override;
0047 
0048     void save(const QString& filename) override;
0049 
0050   private:
0051     QJsonArray jupyterText(const QString& text, bool addEndNewLine = false);
0052 
0053   private:
0054     TextResultPrivate* d;
0055 };
0056 
0057 }
0058 #endif /* _TEXTRESULT_H */