Diffstat (limited to 'pwmanager/pwmanager/htmlgen.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/htmlgen.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/htmlgen.cpp b/pwmanager/pwmanager/htmlgen.cpp index bee8198..be3406a 100644 --- a/pwmanager/pwmanager/htmlgen.cpp +++ b/pwmanager/pwmanager/htmlgen.cpp @@ -1,159 +1,159 @@ /*************************************************************************** * * * copyright (C) 2004 by Michael Buesch * * email: mbuesch@freenet.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * ***************************************************************************/ /*************************************************************************** * copyright (C) 2004 by Ulf Schenk * This file is originaly based on version 1.0.1 of pwmanager * and was modified to run on embedded devices that run microkde * * $Id$ **************************************************************************/ #include "htmlgen.h" #include "pwmexception.h" #include <kstandarddirs.h> /** enable/disable HTML-generator debugging (0/1) */ #define HTMLGEN_DEBUG 0 #define HTML_DOCTYPE_HDR "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" #define HTML_PWM_HDR "<!-- PwManager generated HTML -->" #define HTML_COMMENT_HDR "<!-- type: comment -->" #define HTML_COMMENTVER_HDR "<!-- ver: 0.1 -->" #define HTML_STYLESHEET_DUMMY "@STYLESHEET@" #define HTML_GLOBTBL_CLASS "\"globtable\"" #define HTML_GLOBTITLE_CLASS "\"globtitle\"" #define HTML_SUBTBL_CLASS "\"subtable\"" #define HTML_SUBTITLE_CLASS "\"subtitle\"" #define HTML_ENTRY_CLASS "\"entry\"" #define HTML_VALUE_CLASS "\"value\"" #define PATH_COMMENTSTYLE_CSS "pwmanager/html/htmlcomment_style.css" #if defined(PWM_DEBUG) && HTMLGEN_DEBUG != 0 #define HTML_ENDL "\n" #else // defined(PWM_DEBUG) && ... #define HTML_ENDL "" #endif // defined(PWM_DEBUG) && ... HtmlGen::HtmlGen() { useSSDummy = true; } HtmlGen::~HtmlGen() { } QString HtmlGen::escapeHtmlText(const QString &str) { QString ret; unsigned int len = str.length(), i; char c; for (i = 0; i < len; ++i) { - c = str.at(i); + c = str.at(i).toLatin1(); switch (c) { case '<': ret.append("<"); break; case '>': ret.append(">"); break; case '&': ret.append("&"); break; case '\"': ret.append("""); break; case 'ä': ret.append("ä"); break; case 'Ä': ret.append("Ä"); break; case 'ü': ret.append("ü"); break; case 'Ü': ret.append("Ü"); break; case 'ö': ret.append("ö"); break; case 'Ö': ret.append("Ö"); break; case 'ß': ret.append("ß"); break; case '¿': ret.append("€"); break; default: ret.append(c); } } return ret; } bool HtmlGen::isHtml(const QString &dta) { int ret; ret = dta.find("<html>", 0, false); if (ret == -1) return false; ret = dta.find("<head>", ret, false); if (ret == -1) return false; return true; } QString HtmlGen::getStyleSheetHtml() { QString ret; ret = "<link rel=\"stylesheet\" href=\""; QString cssPath(::locate("data", PATH_COMMENTSTYLE_CSS)); if ((cssPath == QString::null) || (cssPath == "")) { printDebug("HtmlGen::getStyleSheetHtml(): not found"); return ""; } ret += cssPath; ret += "\" type=\"text/css\">" HTML_ENDL; return ret; } bool HtmlGen::replaceSSDummy(QString *doc) { int beginPos = doc->find(HTML_STYLESHEET_DUMMY); if (beginPos == -1) { printDebug("HtmlGen::replaceSSDummy(): not found"); return false; } *doc = doc->replace(beginPos, strlen(HTML_STYLESHEET_DUMMY), getStyleSheetHtml()); return true; } QString HtmlGen::genHtmlComment(const HtmlComment *dta) { QString ret(HTML_DOCTYPE_HDR HTML_PWM_HDR HTML_ENDL HTML_COMMENT_HDR HTML_ENDL HTML_COMMENTVER_HDR HTML_ENDL); ret += "<html>" HTML_ENDL; if (!appendCommentHeader(&ret)) return ""; if (!appendCommentBody(&ret, dta)) return ""; ret += "</html>" HTML_ENDL; #if defined(PWM_DEBUG) && HTMLGEN_DEBUG != 0 |