filters
ExportDocStruct.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qstring.h>
00022 #include <qtextcodec.h>
00023 #include <qfile.h>
00024
00025 #include <klocale.h>
00026 #include <kdebug.h>
00027
00028 #include <KWEFBaseWorker.h>
00029
00030 #include "ExportFilter.h"
00031 #include "ExportDocStruct.h"
00032
00033 QString HtmlDocStructWorker::getStartOfListOpeningTag(const CounterData::Style typeList, bool& ordered)
00034 {
00035 QString strResult;
00036 switch (typeList)
00037 {
00038 case CounterData::STYLE_CUSTOMBULLET:
00039 default:
00040 case CounterData::STYLE_NONE:
00041 case CounterData::STYLE_CIRCLEBULLET:
00042 case CounterData::STYLE_SQUAREBULLET:
00043 case CounterData::STYLE_DISCBULLET:
00044 {
00045 ordered=false;
00046 strResult="<ul>\n";
00047 break;
00048 }
00049 case CounterData::STYLE_NUM:
00050 case CounterData::STYLE_ALPHAB_L:
00051 case CounterData::STYLE_ALPHAB_U:
00052 case CounterData::STYLE_ROM_NUM_L:
00053 case CounterData::STYLE_ROM_NUM_U:
00054 case CounterData::STYLE_CUSTOM:
00055 {
00056 ordered=true;
00057 strResult="<ol>\n";
00058 break;
00059 }
00060 }
00061 return strResult;
00062 }
00063
00064 void HtmlDocStructWorker::openFormatData(const FormatData& formatOrigin,
00065 const FormatData& format, const bool force, const bool allowBold)
00066 {
00067
00068
00069 if (format.text.fontName.contains("ourier"))
00070 {
00071 *m_streamOut << "<tt>";
00072 }
00073
00074 if (force || (formatOrigin.text.italic!=format.text.italic))
00075 {
00076 if (format.text.italic)
00077 {
00078 *m_streamOut << "<i>";
00079 }
00080 }
00081
00082 if (force || ((formatOrigin.text.weight>=75)!=(format.text.weight>=75)))
00083 {
00084 if (allowBold && (format.text.weight >= 75))
00085 {
00086 *m_streamOut << "<b>";
00087 }
00088 }
00089
00090 if (force || (formatOrigin.text.verticalAlignment!=format.text.verticalAlignment))
00091 {
00092 if (1==format.text.verticalAlignment)
00093 {
00094 *m_streamOut << "<sub>";
00095 }
00096 else if (2==format.text.verticalAlignment)
00097 {
00098 *m_streamOut << "<sup>";
00099 }
00100 }
00101
00102
00103 }
00104
00105 void HtmlDocStructWorker::closeFormatData(const FormatData& formatOrigin,
00106 const FormatData& format, const bool force, const bool allowBold)
00107 {
00108 if (force || (formatOrigin.text.verticalAlignment!=format.text.verticalAlignment))
00109 {
00110 if (2==format.text.verticalAlignment)
00111 {
00112 *m_streamOut << "</sup>";
00113 }
00114 else if (1==format.text.verticalAlignment)
00115 {
00116 *m_streamOut << "</sub>";
00117 }
00118 }
00119
00120 if (force || ((formatOrigin.text.weight>=75)!=(format.text.weight>=75)))
00121 {
00122 if (allowBold && (format.text.weight >= 75))
00123 {
00124 *m_streamOut << "</b>";
00125 }
00126 }
00127
00128 if (force || (formatOrigin.text.italic!=format.text.italic))
00129 {
00130 if (format.text.italic)
00131 {
00132 *m_streamOut << "</i>";
00133 }
00134 }
00135
00136 if (format.text.fontName.contains("ourier"))
00137 {
00138 *m_streamOut << "</tt>";
00139 }
00140 }
00141
00142 void HtmlDocStructWorker::openParagraph(const QString& strTag,
00143 const LayoutData& layout,QChar::Direction )
00144 {
00145 *m_streamOut << '<' << strTag << ">";
00146 openFormatData(layout.formatData,layout.formatData,true,(strTag[0]!='h'));
00147 }
00148
00149 void HtmlDocStructWorker::closeParagraph(const QString& strTag,
00150 const LayoutData& layout)
00151 {
00152 closeFormatData(layout.formatData,layout.formatData,true,(strTag[0]!='h'));
00153 *m_streamOut << "</" << strTag << ">\n";
00154 }
00155
00156 void HtmlDocStructWorker::openSpan(const FormatData& formatOrigin, const FormatData& format)
00157 {
00158 openFormatData(formatOrigin,format,false,true);
00159 }
00160
00161 void HtmlDocStructWorker::closeSpan(const FormatData& formatOrigin, const FormatData& format)
00162 {
00163 closeFormatData(formatOrigin,format,false,true);
00164 }
00165
|