File indexing completed on 2025-03-09 04:54:33
0001 /* -*- c++ -*- 0002 filehtmlwriter.cpp 0003 0004 This file is part of KMail, the KDE mail client. 0005 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #include "filehtmlwriter.h" 0011 #include "messageviewer_debug.h" 0012 0013 using namespace MessageViewer; 0014 0015 FileHtmlWriter::FileHtmlWriter(const QString &filename) 0016 : mFile(filename.isEmpty() ? QStringLiteral("filehtmlwriter.out") : filename) 0017 { 0018 } 0019 0020 FileHtmlWriter::~FileHtmlWriter() 0021 { 0022 if (mFile.isOpen()) { 0023 qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: file still open!"; 0024 HtmlWriter::end(); 0025 mFile.close(); 0026 } 0027 } 0028 0029 void FileHtmlWriter::begin() 0030 { 0031 if (mFile.isOpen()) { 0032 qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: file still open!"; 0033 mFile.close(); 0034 } 0035 if (!mFile.open(QIODevice::WriteOnly)) { 0036 qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: Cannot open file" << mFile.fileName(); 0037 } 0038 HtmlWriter::begin(); 0039 } 0040 0041 void FileHtmlWriter::end() 0042 { 0043 HtmlWriter::end(); 0044 mFile.close(); 0045 } 0046 0047 void FileHtmlWriter::reset() 0048 { 0049 HtmlWriter::reset(); 0050 if (mFile.isOpen()) { 0051 mFile.close(); 0052 } 0053 } 0054 0055 QIODevice *FileHtmlWriter::device() const 0056 { 0057 return const_cast<QFile *>(&mFile); 0058 } 0059 0060 void FileHtmlWriter::embedPart(const QByteArray &contentId, const QString &url) 0061 { 0062 *stream() << "<!-- embedPart(contentID=" << contentId << ", url=" << url << ") -->" << Qt::endl; 0063 } 0064 0065 void FileHtmlWriter::setExtraHead(const QString &) 0066 { 0067 } 0068 0069 void FileHtmlWriter::setStyleBody(const QString &) 0070 { 0071 }