filters
KWEFUtil.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
00024 #include <KoPageLayout.h>
00025
00026 #include "KWEFUtil.h"
00027
00028 QString KWEFUtil::EscapeSgmlText(const QTextCodec* codec,
00029 const QString& strIn,
00030 const bool quot ,
00031 const bool apos )
00032 {
00033 QString strReturn;
00034 QChar ch;
00035
00036 for (uint i=0; i<strIn.length(); i++)
00037 {
00038 ch=strIn[i];
00039 switch (ch.unicode())
00040 {
00041 case 38:
00042 {
00043 strReturn+="&";
00044 break;
00045 }
00046 case 60:
00047 {
00048 strReturn+="<";
00049 break;
00050 }
00051 case 62:
00052 {
00053 strReturn+=">";
00054 break;
00055 }
00056 case 34:
00057 {
00058 if (quot)
00059 strReturn+=""";
00060 else
00061 strReturn+=ch;
00062 break;
00063 }
00064 case 39:
00065 {
00066
00067 if (apos)
00068 strReturn+="'";
00069 else
00070 strReturn+=ch;
00071 break;
00072 }
00073 default:
00074 {
00075
00076
00077 if (codec)
00078 {
00079 if (!codec->canEncode(ch))
00080 {
00081 strReturn+=QString("&#%1;").arg(ch.unicode());
00082 break;
00083 }
00084 }
00085 strReturn+=ch;
00086 break;
00087 }
00088 }
00089 }
00090
00091 return strReturn;
00092 }
00093
00094 void KWEFUtil::GetNativePaperFormat(const int format,
00095 QString& width, QString& height, QString& units)
00096
00097 {
00098 switch (format)
00099 {
00100
00101 case PG_DIN_A0:
00102 {
00103 width="84.1"; height="118.0"; units="cm";
00104 break;
00105 }
00106 case PG_DIN_A1:
00107 {
00108 width="59.4"; height="84.1"; units="cm";
00109 break;
00110 }
00111 case PG_DIN_A2:
00112 {
00113 width="42.0"; height="59.4"; units="cm";
00114 break;
00115 }
00116 case PG_DIN_A3:
00117 {
00118 width="29.7"; height="42.0"; units="cm";
00119 break;
00120 }
00121 case PG_DIN_A4:
00122 {
00123 width="21.0"; height="29.7"; units="cm";
00124 break;
00125 }
00126 case PG_DIN_A5:
00127 {
00128 width="14.8"; height="21.0"; units="cm";
00129 break;
00130 }
00131 case PG_DIN_A6:
00132 {
00133 width="10.5"; height="14.8"; units="cm";
00134 break;
00135 }
00136
00137 case PG_DIN_B0:
00138 {
00139 width="100.0"; height="141.0"; units="cm";
00140 break;
00141 }
00142 case PG_DIN_B1:
00143 {
00144 width="70.7"; height="100.0"; units="cm";
00145 break;
00146 }
00147 case PG_DIN_B2:
00148 {
00149 width="50.0"; height="70.7"; units="cm";
00150 break;
00151 }
00152 case PG_DIN_B3:
00153 {
00154 width="35.3"; height="50.0"; units="cm";
00155 break;
00156 }
00157 case PG_DIN_B4:
00158 {
00159 width="25.8"; height="35.3"; units="cm";
00160 break;
00161 }
00162 case PG_DIN_B5:
00163 {
00164 width="17.6"; height="25.0"; units="cm";
00165 break;
00166 }
00167 case PG_DIN_B6:
00168 {
00169 width="12.5"; height="17.6"; units="cm";
00170 break;
00171 }
00172
00173 case PG_US_LETTER:
00174 {
00175 width="8.5"; height="11.0"; units="inch";
00176 break;
00177 }
00178 case PG_US_LEGAL:
00179 {
00180 width="8.5"; height="14.0"; units="inch";
00181 break;
00182 }
00183 case PG_US_EXECUTIVE:
00184 {
00185 width="7.5"; height="10.0"; units="inch";
00186 break;
00187 }
00188
00189 case PG_DIN_A7:
00190 case PG_DIN_A8:
00191 case PG_DIN_A9:
00192 case PG_DIN_B10:
00193
00194 case PG_SCREEN:
00195 case PG_CUSTOM:
00196 default:
00197 {
00198
00199 width=QString::null;
00200 height=QString::null;
00201 units=QString::null;
00202 break;
00203 }
00204 }
00205 }
|