From koffice-devel Tue Jul 31 14:45:34 2001 From: Nicolas Goutte Date: Tue, 31 Jul 2001 14:45:34 +0000 To: koffice-devel Subject: [PATCH] KSpread/HTML second patch X-MARC-Message: https://marc.info/?l=koffice-devel&m=99659090218157 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------Boundary-00=_YBECMQXR6HECA81O9OXB" --------------Boundary-00=_YBECMQXR6HECA81O9OXB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Subject: Okay, here is the second part for KSpread's HTML export filter. This time the local encoding is given as tag, at least if the local charset has a IANA charset name. This patch goes over the previous one, which I have not yet commited. Please test, in particular if you are using a non-ISO-8859-1 encoding or even better a non-ISO-8859 one. Thank you in advance. Have a nice day/evening/night! --------------Boundary-00=_YBECMQXR6HECA81O9OXB Content-Type: text/plain; charset="iso-8859-1"; name="diff2.txt" Content-Transfer-Encoding: quoted-printable Content-Description: Diff Content-Disposition: attachment; filename="diff2.txt" --- htmlexport.cc.org=09Mon Jul 30 23:54:44 2001 +++ htmlexport.cc=09Tue Jul 31 16:26:11 2001 @@ -52,6 +52,104 @@ } }; =20 +// getIANAChartsetName +// +// For IANA Charset Names +// see http://www.iana.org/assignments/character-sets +// +// The values of mibEnum used here are only those used by QT 2.3.1 +// +QString getIANACharsetName(const int mibEnum) +{ + switch(mibEnum) + { + case 4: + return "ISO-8859-1"; + case 5: + return "ISO-8859-2"; + case 6: + return "ISO-8859-3"; + case 7: + return "ISO-8859-4"; + case 8: + return "ISO-8859-5"; + case 9: + return "ISO-8859-6"; + case 10: + return "ISO-8859-7"; + case 11: + return "ISO-8859-8"; + case 12: + return "ISO-8859-9"; + case 13: + return "ISO-8859-10"; + case 16: + return "JIS_Encoding"; + case 17: + return "Shift_JIS"; + case 18: + return "EUC-JP"; + case 38: + return "EUC-KR"; + case 57: + return "GB_2312-80"; + case 82: + return "ISO-8859-6-I"; + case 85: + return "ISO-8859-8-I"; + case 106: + return "UTF-8"; + case 109: + return "ISO-8859-13"; + case 110: + return "ISO-8859-14"; + case 111: + return "ISO-8859-15"; + case 1000: + return "ISO-10646-UCS-2"; + case 2026: + return "Big5"; + case 2084: + return "KOI8-R"; + case 2088: + return "KOI8-U"; + case 2250: + return "windows-1250"; + case 2251: + return "windows-1251"; + case 2252: + return "windows-1252"; + case 2253: + return "windows-1253"; + case 2254: + return "windows-1254"; + case 2255: + return "windows-1255"; + case 2256: + return "windows-1256"; + case 2257: + return "windows-1257"; + case 2258: + return "windows-1258"; + case 2259: + return "TIS-620"; // Same as ISO 8859-11 + case 2027: // GBK is not part of IANA (despite that QT 2.3.1has a nu= mber for it!) + case 2028: // TSCII is not part of IANA (despite that QT 2.3.1 has a= number for it!) + case 0: + { + kdWarning(30501) << "Non-IANA character set!" << endl; + return QString::null; + } + default: + { + kdDebug(30501) << "Unknown MIBenum charset found! " << mibEn= um << endl; + break; + } + } + return QString::null; +} + + =20 HTMLExport::HTMLExport(KoFilter *parent, const char *name) : KoFilter(parent, name) { @@ -133,20 +231,36 @@ str +=3D "\n"; str +=3D "\n"; // TODO: possibility of choosing other encodings + + // + // Find IANA charset name for the chosen encoding. + // + QString strCharset; if (utf8) { - str +=3D "\n"; + strCharset=3D"UTF-8"; } else { - // TODO: find a way to retrieve the CORRECT name of the used loc= al charset - // (see http://www.iana.org/assignments/character-sets) - // For now, just give as comment the encoding used (PROVISORY!) + strCharset=3DgetIANACharsetName(QTextCodec::codecForLocale()->mi= bEnum()); + } + kdDebug(30501) << "Charset used: " << strCharset << endl; + if (strCharset.isEmpty()) + { + // We have no valid IANA charset name, so we put QT's codec name= in a comment str +=3D "\n"; } + else + { + // We have a valid IANA charset name, so issue a tag + str +=3D "\n"; + } + str +=3D "\= n"; // I have no idea where to get the document name from :-( table->ta= bleName() @@ -159,7 +273,7 @@ // It's great to have parametrable filters... IIRC even MSOffice do= esn't have that) // Ok, for now we'll use the first table - my document has only one = table anyway ;-))) KSpreadTable * table =3D ksdoc->map()->firstTable(); - =20 + while (table !=3D 0) { =20 --------------Boundary-00=_YBECMQXR6HECA81O9OXB-- _______________________________________________ Koffice-devel mailing list Koffice-devel@master.kde.org http://master.kde.org/mailman/listinfo/koffice-devel