author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/plucker_base.cpp | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/plucker_base.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/plucker_base.cpp | 224 |
1 files changed, 172 insertions, 52 deletions
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index d7d538f..51c7fa7 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -1,2 +1 @@ | |||
1 | #include "usenef.h" | ||
2 | #include <stdio.h> | #include <stdio.h> | |
@@ -25,3 +24,3 @@ | |||
25 | #include "hrule.h" | 24 | #include "hrule.h" |
26 | #include "util.h" | 25 | #include "decompress.h" |
27 | 26 | ||
@@ -44,3 +43,4 @@ void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buff | |||
44 | { | 43 | { |
45 | if (type%2 == 0) | 44 | unsuspend(); |
45 | if ((type%2 == 0) && (type != 14)) | ||
46 | { | 46 | { |
@@ -307,3 +307,3 @@ void CPlucker_base::locate(unsigned int n) | |||
307 | } | 307 | } |
308 | } while (locpos + bs <= n); | 308 | } while (locpos + bs < n); |
309 | 309 | ||
@@ -414,3 +414,3 @@ bool CPlucker_base::expand(int thisrec) | |||
414 | } | 414 | } |
415 | 415 | /* | |
416 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 416 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
@@ -451,4 +451,4 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff | |||
451 | } | 451 | } |
452 | 452 | */ | |
453 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 453 | size_t CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
454 | { | 454 | { |
@@ -503,2 +503,3 @@ void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff | |||
503 | } | 503 | } |
504 | return i; | ||
504 | } | 505 | } |
@@ -1058,2 +1059,155 @@ linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& | |||
1058 | } | 1059 | } |
1060 | QString CPlucker_base::getTableAsHtml(unsigned long tgt) | ||
1061 | { | ||
1062 | qDebug("CPlucker_base::getTableAsHtml:%u", tgt); | ||
1063 | size_t reclen; | ||
1064 | UInt16 thisrec = finduid(tgt); | ||
1065 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | ||
1066 | reclen = recordlength(thisrec); | ||
1067 | gotorecordnumber(thisrec); | ||
1068 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
1069 | UInt32 thishdr_size; | ||
1070 | UInt8 thishdr_type, thishdr_reserved; | ||
1071 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
1072 | qDebug("Found a table of type:%u", thishdr_type); | ||
1073 | reclen -= HeaderSize(); | ||
1074 | UInt32 imgsize = thishdr_size; | ||
1075 | UInt8* imgbuffer = new UInt8[imgsize]; | ||
1076 | Expand(reclen, thishdr_type, imgbuffer, imgsize); | ||
1077 | |||
1078 | QString ret; | ||
1079 | |||
1080 | UInt16 size, columns, rows; | ||
1081 | UInt8 depth, border; | ||
1082 | UInt32 borderColour, linkColour; | ||
1083 | UInt8* dp(imgbuffer); | ||
1084 | |||
1085 | memcpy(&size, dp, sizeof(size)); | ||
1086 | size = ntohs(size); | ||
1087 | dp += sizeof(size); | ||
1088 | memcpy(&columns, dp, sizeof(columns)); | ||
1089 | columns = ntohs(columns); | ||
1090 | dp += sizeof(columns); | ||
1091 | memcpy(&rows, dp, sizeof(rows)); | ||
1092 | rows = ntohs(rows); | ||
1093 | dp += sizeof(rows); | ||
1094 | qDebug("Rows:%u Cols:%u", rows, columns); | ||
1095 | |||
1096 | memcpy(&depth, dp, sizeof(depth)); | ||
1097 | dp += sizeof(depth); | ||
1098 | memcpy(&border, dp, sizeof(border)); | ||
1099 | dp += sizeof(border); | ||
1100 | |||
1101 | qDebug("Depth:%u, Border:%u", depth, border); | ||
1102 | |||
1103 | memcpy(&borderColour, dp, sizeof(borderColour)); | ||
1104 | dp += sizeof(borderColour); | ||
1105 | memcpy(&linkColour, dp, sizeof(linkColour)); | ||
1106 | dp += sizeof(linkColour); | ||
1107 | |||
1108 | qDebug("Colours: border:%x, link:%x", borderColour, linkColour); | ||
1109 | |||
1110 | if (border) | ||
1111 | { | ||
1112 | ret = "<table border>"; | ||
1113 | } | ||
1114 | else | ||
1115 | { | ||
1116 | ret = "<table>"; | ||
1117 | } | ||
1118 | bool firstrow = true; | ||
1119 | bool firstcol = true; | ||
1120 | while (dp < imgbuffer+imgsize) | ||
1121 | { | ||
1122 | UInt8 ch = *dp++; | ||
1123 | if (ch == 0x00) | ||
1124 | { | ||
1125 | ch = *dp++; | ||
1126 | if (ch == 0x90) | ||
1127 | { | ||
1128 | if (firstrow) | ||
1129 | { | ||
1130 | ret += "<tr>"; | ||
1131 | firstrow = false; | ||
1132 | firstcol = true; | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | ret += "</tr><tr>"; | ||
1137 | } | ||
1138 | } | ||
1139 | else if (ch == 0x97) | ||
1140 | { | ||
1141 | if (firstcol) | ||
1142 | { | ||
1143 | ret += "<td"; | ||
1144 | firstcol = false; | ||
1145 | } | ||
1146 | else | ||
1147 | { | ||
1148 | ret += "</td><td"; | ||
1149 | } | ||
1150 | UInt8 align; | ||
1151 | UInt16 imgid; | ||
1152 | UInt8 cols, rows; | ||
1153 | UInt16 len; | ||
1154 | memcpy(&align, dp, sizeof(align)); | ||
1155 | dp += sizeof(align); | ||
1156 | memcpy(&imgid, dp, sizeof(imgid)); | ||
1157 | dp += sizeof(imgid); | ||
1158 | imgid = ntohs(imgid); | ||
1159 | memcpy(&cols, dp, sizeof(cols)); | ||
1160 | dp += sizeof(cols); | ||
1161 | memcpy(&rows, dp, sizeof(rows)); | ||
1162 | dp += sizeof(rows); | ||
1163 | memcpy(&len, dp, sizeof(len)); | ||
1164 | dp += sizeof(len); | ||
1165 | len = ntohs(len); | ||
1166 | switch (align) | ||
1167 | { | ||
1168 | case 1: | ||
1169 | ret += " align=right"; | ||
1170 | break; | ||
1171 | case 2: | ||
1172 | ret += " align=center"; | ||
1173 | break; | ||
1174 | case 3: | ||
1175 | ret += " align=justify"; | ||
1176 | break; | ||
1177 | case 0: | ||
1178 | break; | ||
1179 | default: | ||
1180 | qDebug("Unknown table cell alignment:%u", align); | ||
1181 | } | ||
1182 | if (cols != 1) | ||
1183 | { | ||
1184 | QString num; | ||
1185 | num.setNum(cols); | ||
1186 | ret += " colspan="; | ||
1187 | ret += num; | ||
1188 | } | ||
1189 | if (rows != 1) | ||
1190 | { | ||
1191 | QString num; | ||
1192 | num.setNum(rows); | ||
1193 | ret += " rowspan="; | ||
1194 | ret += num; | ||
1195 | } | ||
1196 | ret += ">"; | ||
1197 | } | ||
1198 | else | ||
1199 | { | ||
1200 | dp += (ch & 7); | ||
1201 | } | ||
1202 | } | ||
1203 | else | ||
1204 | { | ||
1205 | ret += QChar(ch); | ||
1206 | } | ||
1207 | } | ||
1208 | |||
1209 | ret += "</td></tr></table>"; | ||
1210 | delete [] imgbuffer; | ||
1211 | return ret; | ||
1212 | } | ||
1059 | 1213 | ||
@@ -1061,2 +1215,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1061 | { | 1215 | { |
1216 | mystyle.setTable(0xffffffff); | ||
1062 | int ch = bgetch(); | 1217 | int ch = bgetch(); |
@@ -1121,6 +1276,2 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1121 | } | 1276 | } |
1122 | else | ||
1123 | { | ||
1124 | mystyle.setUnderline(); | ||
1125 | } | ||
1126 | mystyle.setOffset(m_offset); | 1277 | mystyle.setOffset(m_offset); |
@@ -1331,2 +1482,11 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1331 | break; | 1482 | break; |
1483 | case 0x92: | ||
1484 | { | ||
1485 | ch = bgetch(); | ||
1486 | ch <<= 8; | ||
1487 | ch |= (tchar)bgetch(); | ||
1488 | mystyle.setTable(ch); | ||
1489 | ch = 0x16e5; | ||
1490 | } | ||
1491 | break; | ||
1332 | case 0x85: | 1492 | case 0x85: |
@@ -1359,42 +1519,2 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1359 | 1519 | ||
1360 | #if defined(__STATIC) && defined(USENEF) | ||
1361 | #include "Model.h" | ||
1362 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1363 | { | ||
1364 | if (_s == "PluckerDecompress3") | ||
1365 | { | ||
1366 | return PluckerDecompress3; | ||
1367 | } | ||
1368 | if (_s == "PluckerDecompress4") | ||
1369 | { | ||
1370 | return PluckerDecompress4; | ||
1371 | } | ||
1372 | return NULL; | ||
1373 | } | ||
1374 | #else | ||
1375 | |||
1376 | #include "qfileinfo.h" | ||
1377 | |||
1378 | #include <dlfcn.h> | ||
1379 | |||
1380 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1381 | { | ||
1382 | QString codecpath(QTReaderUtil::getPluginPath("support")); | ||
1383 | codecpath += "/libpluckerdecompress.so"; | ||
1384 | qDebug("Codec:%s", (const char*)codecpath); | ||
1385 | if (QFile::exists(codecpath)) | ||
1386 | { | ||
1387 | qDebug("Codec:%s", (const char*)codecpath); | ||
1388 | void* handle = dlopen(codecpath, RTLD_LAZY); | ||
1389 | if (handle == 0) | ||
1390 | { | ||
1391 | qDebug("Can't find codec:%s", dlerror()); | ||
1392 | return NULL; | ||
1393 | } | ||
1394 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | ||
1395 | } | ||
1396 | return NULL; | ||
1397 | } | ||
1398 | #endif | ||
1399 | |||
1400 | QString CPlucker_base::about() | 1520 | QString CPlucker_base::about() |
@@ -1404,3 +1524,3 @@ QString CPlucker_base::about() | |||
1404 | { | 1524 | { |
1405 | abt += "\nSpecial decompression (c) Tim Wentford"; | 1525 | abt += "\nSpecial decompression (c) Tim Wentford (ppmd by Dmitry Shkarin"; |
1406 | } | 1526 | } |