26#include <tqmessagebox.h>
27#include <tqstringlist.h>
30#include <applixspreadimport.h>
33#include <KoFilterChain.h>
34#include <kgenericfactory.h>
36typedef KGenericFactory<APPLIXSPREADImport, KoFilter> APPLIXSPREADImportFactory;
37K_EXPORT_COMPONENT_FACTORY( libapplixspreadimport, APPLIXSPREADImportFactory(
"kofficefilters" ) )
40APPLIXSPREADImport::APPLIXSPREADImport ( TQObject *, const
char* , const TQStringList& )
45TQString APPLIXSPREADImport::nextLine( TQTextStream & stream )
47 TQString s = stream.readLine();
48 m_instep += s.length();
49 if (m_instep > m_stepsize)
53 emit sigProgress( m_progress );
58KoFilter::ConversionStatus APPLIXSPREADImport::convert(
const TQCString& from,
const TQCString& to )
61 if (to !=
"application/x-kspread" || from !=
"application/x-applixspread")
62 return KoFilter::NotImplemented;
64 TQFile in (m_chain->inputFile());
65 if (!in.open(IO_ReadOnly))
67 kdError(30502) <<
"Unable to open input file!" << endl;
69 return KoFilter::FileNotFound;
73 TQPtrList<t_mycolor> mcol;
75 str +=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
76 str +=
"<!DOCTYPE spreadsheet>\n";
77 str +=
"<spreadsheet mime=\"application/x-kspread\" editor=\"KSpread\" >\n";
78 str +=
" <paper format=\"A4\" orientation=\"Portrait\" >\n";
79 str +=
" <borders right=\"20\" left=\"20\" bottom=\"20\" top=\"20\" />\n";
83 str +=
" <locale positivePrefixCurrencySymbol=\"True\" negativeMonetarySignPosition=\"1\" negativePrefixCurrencySymbol=\"True\" fracDigits=\"2\" thousandsSeparator=\" \" dateFormat=\"%A, %e. %B %Y\" timeFormat=\"%H:%M:%S\" monetaryDecimalSymbol=\",\" weekStartsMonday=\"True\" currencySymbol=\"DM\" negativeSign=\"-\" positiveSign=\"\" positiveMonetarySignPosition=\"1\" decimalSymbol=\",\" monetaryThousandsSeparator=\" \" dateFormatShort=\"%d.%m.%Y\" />\n";
84 str +=
" <map markerColumn=\"1\" activeTable=\"Table1\" markerRow=\"1\" >\n";
89 TQTextStream stream (&in);
90 m_stepsize = in.size()/50;
97 TQString mystr, typestr, cellnostr, tabnostr;
98 TQStringList typefacetab;
108 if (! readHeader (stream))
return KoFilter::StupidError;
111 while (!stream.atEnd ())
114 mystr = nextLine( stream );
116 kdDebug()<<
"INPUT : "<<mystr<<endl;
122 if (mystr.startsWith (
"COLORMAP") )
124 readColormap (stream, mcol);
130 else if (mystr.startsWith (
"TYPEFACE TABLE") )
132 readTypefaceTable (stream, typefacetab);
138 else if (mystr.startsWith (
"View Start, Name:") )
140 readView (stream, mystr, my_rc);
147 else if (mystr[0] ==
'(')
158 alllength = mystr.length ();
159 if (alllength >= 80-1)
161 kdDebug()<<
" Line >= 80 chars \n";
166 mystrn = nextLine( stream );
167 if (mystrn[0] ==
' ')
169 mystrn.remove (0, 1);
184 pos = mystr.find (
')');
185 typestr = mystr.left (pos);
189 mystr.remove (0, pos+1);
193 pos = mystr.find (
':');
196 cellnostr = mystr.left (pos);
199 mystr.remove (0, pos+1);
204 pos = cellnostr.find (
'!');
207 tabnostr = cellnostr.left (pos);
210 cellnostr.remove (0, pos+1);
212 int len = cellnostr.length ();
213 char tmp[300], tmp1[300];
218 pos = cellnostr.find (TQRegExp (
"[0-9]"));
219 kdDebug()<<
" findpos :"<<pos<<endl;
226 rowstr = cellnostr.mid (pos, cellnostr.length()-pos);
227 irow = rowstr.toInt(&ok);
229 kdDebug()<<
" findpos :"<< rowstr<<
" "<<irow<<endl;
230 sscanf (cellnostr.latin1(),
"%299s%d",tmp, &bla);
231 sprintf (tmp1,
"%d", irow);
232 leni = strlen (tmp1);
234 cellcolstr = cellnostr;
235 cellcolstr.remove (cellcolstr.length()-leni, leni);
237 kdDebug()<<
" Info: length :"<<len<<
" cellnostr :"<<cellnostr<<
" tmp :"<<tmp<<
" irow :"<<irow<<
" cellcolstr :"<<cellcolstr<<endl;
240 icol = translateColumnNumber (cellcolstr);
250 tabnostr.remove (0, 1);
254 mystr.replace (TQRegExp (
"&"),
"&");
255 mystr.replace (TQRegExp (
"<"),
"<");
256 mystr.replace (TQRegExp (
">"),
">");
260 int foundSpecialCharakter;
266 foundSpecialCharakter =
false;
268 pos = mystr.find (
"^");
274 foundSpecialCharakter =
true;
277 newchar = specCharfind (mystr[pos+1], mystr[pos+2]);
280 mystr.replace (pos, 3, newchar);
284 while (foundSpecialCharakter ==
true);
289 TQString typeFormStr;
290 TQString typeCharStr;
291 TQString typeCellStr;
293 int pos1 = typestr.find (
"|");
294 int pos2 = typestr.findRev (
"|");
297 typeFormStr = typestr.left (pos1);
299 typeCharStr = typestr.mid (pos1+1, pos2 - pos1 - 1);
301 typeCellStr = typestr.right (typestr.length() - pos2 - 1);
304 if (tabctr != tabnostr)
307 if (!(tabctr.isNull())) str +=
" </table>\n";
309 str +=
" <table columnnumber=\"0\" borders=\"0\" hide=\"0\" hidezero=\"0\" firstletterupper=\"0\" grid=\"1\" formular=\"0\" lcmode=\"0\" name=\"";
316 pos = my_rc.tabname.findIndex (tabnostr);
317 if (pos > -1) str += my_rc.rc[pos];
320 kdDebug()<<
" Data : Text :"<<mystr<<
" tab :"<<tabnostr<<
" "<< cellnostr <<
" " <<ccol<<
" " << irow<<
" "<< typeFormStr<<
" " <<typeCharStr<<
" " <<typeCellStr<<endl;
326 TQStringList typeCharList;
327 int bold=0, italic=0, underline=0, nn=0, fontsize=12, fontnr=-1;
329 typeCharList = TQStringList::split (
',', typeCharStr);
331 for (TQStringList::Iterator it = typeCharList.begin();
332 it != typeCharList.end(); ++it )
335 kdDebug()<<
" Char ("<<nn<<
" ) >"<<*it<<
"< "<<endl;
340 kdDebug()<<
" bold\n";
343 else if ((*it) ==
"I")
346 kdDebug()<<
" = italic\n";
349 else if ((*it) ==
"U")
351 kdDebug()<<
" = underline\n";
354 else if ((*it).startsWith(
"FG") )
356 sscanf ((*it).latin1(),
"FG%d", &fg);
357 kdDebug()<<
" = Colornr "<< fg<<endl;
359 else if ((*it).startsWith(
"TF") )
361 sscanf ((*it).latin1(),
"TF%d", &fontnr);
362 kdDebug()<<
" = Font :"<<fontnr<<
" "<<typefacetab[fontnr]<<endl;
364 else if ((*it).startsWith(
"P") )
366 sscanf ((*it).latin1(),
"P%d", &fontsize);
367 kdDebug()<<
" = Fontsize "<<fontsize<<endl;
372 kdDebug()<<
" = ???\n";
382 TQStringList typeFormList;
383 int align = 0, valign=0;
385 typeFormList = TQStringList::split (
',', typeFormStr);
387 for (TQStringList::Iterator it = typeFormList.begin(); it != typeFormList.end(); ++it )
396 kdDebug()<<
" = left align\n";
399 else if ( (*it) ==
"2")
401 kdDebug()<<
" = right align\n";
404 else if ( (*it) ==
"3")
406 kdDebug()<<
" = center align\n";
411 else if ( (*it) ==
"VT")
413 kdDebug()<<
" = top valign\n";
416 else if ( (*it) ==
"VC")
418 kdDebug()<<
" = center valign\n";
421 else if ( (*it) ==
"VB")
423 kdDebug()<<
" = bottom valign\n";
428 kdDebug()<<
" = ???\n";
436 TQStringList typeCellList;
437 int topPenWidth=0, bottomPenWidth=0, leftPenWidth = 0, rightPenWidth = 0, fg_bg=-1;
438 int topPenStyle=0, bottomPenStyle=0, leftPenStyle = 0, rightPenStyle = 0;
439 int brushstyle=0, brushcolor=1;
440 int topbrushstyle=0, topbrushcolor=1, topfg_bg=1;
441 int leftbrushstyle=0, leftbrushcolor=1, leftfg_bg=1;
442 int rightbrushstyle=0, rightbrushcolor=1, rightfg_bg=1;
443 int bottombrushstyle=0, bottombrushcolor=1, bottomfg_bg=1;
445 typeCellList = TQStringList::split (
',', typeCellStr);
447 for ( TQStringList::Iterator it = typeCellList.begin(); it != typeCellList.end(); ++it )
450 printf (
" Cell (%2d) >%s< ",
451 nn, (*it).latin1() );
456 kdDebug()<<
" = top \n";
457 transPenFormat ((*it), &topPenWidth, &topPenStyle);
459 if ((*it).length() > 2)
462 filterSHFGBG ((*it), &topbrushstyle, &topbrushcolor, &topfg_bg);
467 else if ( (*it)[0] ==
'B')
469 kdDebug()<<
" = bottom \n";
470 transPenFormat ((*it), &bottomPenWidth, &bottomPenStyle);
472 if ((*it).length() > 2)
475 filterSHFGBG ((*it), &bottombrushstyle, &bottombrushcolor, &bottomfg_bg);
479 else if ( (*it)[0] ==
'L')
481 kdDebug()<<
" = left \n";
482 transPenFormat ((*it), &leftPenWidth, &leftPenStyle);
484 if ((*it).length() > 2)
487 filterSHFGBG ((*it), &leftbrushstyle, &leftbrushcolor, &leftfg_bg);
491 else if ( (*it)[0] ==
'R')
493 kdDebug()<<
" = right \n";
494 transPenFormat ((*it), &rightPenWidth, &rightPenStyle);
496 if ((*it).length() > 2)
499 filterSHFGBG ((*it), &rightbrushstyle, &rightbrushcolor, &rightfg_bg);
503 else if ( ((*it).startsWith (
"SH")) || ((*it).startsWith (
"FG")) ||
504 ((*it).startsWith (
"BG")) )
507 filterSHFGBG ((*it), &brushstyle, &fg_bg, &brushcolor);
512 kdDebug()<<
" = ???\n";
524 str +=
" <cell row=\"" + TQString::number (irow) +
"\"";
525 str +=
" column=\"" + TQString::number (icol) +
"\">\n";
526 if (bold == 1 || italic == 1 || underline == 1 ||
527 align != 0 || valign != 0 ||
528 topPenStyle != 0 || bottomPenStyle != 0 ||
529 leftPenStyle != 0 || rightPenStyle != 0 || fg !=-1 || fg_bg != -1 ||
530 fontsize != 12 || brushstyle != 0 || fontnr != -1)
535 str +=
" brushstyle=\"" + TQString::number(brushstyle) +
"\" ";
536 str +=
" brushcolor=\"";
537 str += writeColor (mcol.at(brushcolor));
541 if (align != 0) str +=
" align=\"" + TQString::number(align) +
"\" ";
542 if (valign != 0) str +=
" alignY=\"" + TQString::number(valign) +
"\" ";
545 str +=
" bgcolor=\"";
546 str += writeColor (mcol.at(fg_bg));
554 str +=
" <pen width=\"0\" style=\"1\" color=\"";
555 str += writeColor (mcol.at(fg));
560 if (leftPenWidth > 0)
562 str +=
" <left-border>\n";
563 col = writeColor (mcol.at(leftfg_bg));
564 writePen (str, leftPenWidth, leftPenStyle, col);
565 str +=
" </left-border>\n";
569 if (rightPenWidth > 0)
571 str +=
" <right-border>\n";
572 col = writeColor (mcol.at(rightfg_bg));
573 writePen (str, rightPenWidth, rightPenStyle, col);
574 str +=
" </right-border>\n";
578 if (bottomPenWidth > 0)
580 str +=
" <bottom-border>\n";
581 col = writeColor (mcol.at(bottomfg_bg));
582 writePen (str, bottomPenWidth, bottomPenStyle, col);
583 str +=
" </bottom-border>\n";
589 str +=
" <top-border>\n";
590 col = writeColor (mcol.at(topfg_bg));
591 writePen (str, topPenWidth, topPenStyle, col);
592 str +=
" </top-border>\n";
596 if ((fontsize != 12) || (fontnr != -1))
603 str += TQString::number (fontsize);
610 str += typefacetab[fontnr].latin1();
613 str +=
"weight=\"0\"";
615 if (italic == 1) str +=
" italic=\"yes\"";
616 if (bold == 1) str +=
" bold=\"yes\"";
617 if (underline == 1) str +=
" underline=\"yes\"";
621 str +=
" </format>\n";
623 str +=
" <text>" + mystr +
"</text>\n";
628 emit sigProgress(100);
630 str +=
" </table>\n";
632 str +=
"</spreadsheet>\n";
635 kdDebug ()<<
"Text "<< str<<endl;
637 KoStoreDevice* out=m_chain->storageFile(
"root", KoStore::Write );
641 kdError(38000) <<
"Unable to open output file!" << endl;
643 return KoFilter::StorageCreationError;
646 TQCString cstring = str.utf8();
647 out->writeBlock ( cstring, cstring.length() );
660APPLIXSPREADImport::specCharfind (TQChar a, TQChar b)
664 if ( (a ==
'n') && (b ==
'p') ) chr =
'ß';
667 else if ( (a ==
'n') && (b ==
'c') ) chr =
'Ò';
668 else if ( (a ==
'p') && (b ==
'c') ) chr =
'ò';
670 else if ( (a ==
'n') && (b ==
'd') ) chr =
'Ó';
671 else if ( (a ==
'p') && (b ==
'd') ) chr =
'ó';
673 else if ( (a ==
'n') && (b ==
'e') ) chr =
'Ô';
674 else if ( (a ==
'p') && (b ==
'e') ) chr =
'ô';
676 else if ( (a ==
'n') && (b ==
'f') ) chr =
'Õ';
677 else if ( (a ==
'p') && (b ==
'f') ) chr =
'õ';
679 else if ( (a ==
'p') && (b ==
'g') ) chr =
'ö';
680 else if ( (a ==
'n') && (b ==
'g') ) chr =
'Ö';
684 else if ( (a ==
'n') && (b ==
'j') ) chr =
'Ù';
685 else if ( (a ==
'p') && (b ==
'j') ) chr =
'ù';
687 else if ( (a ==
'n') && (b ==
'k') ) chr =
'Ú';
688 else if ( (a ==
'p') && (b ==
'k') ) chr =
'ú';
690 else if ( (a ==
'n') && (b ==
'l') ) chr =
'Û';
691 else if ( (a ==
'p') && (b ==
'l') ) chr =
'û';
693 else if ( (a ==
'p') && (b ==
'm') ) chr =
'ü';
694 else if ( (a ==
'n') && (b ==
'm') ) chr =
'Ü';
698 else if ( (a ==
'm') && (b ==
'a') ) chr =
'À';
699 else if ( (a ==
'o') && (b ==
'a') ) chr =
'à';
701 else if ( (a ==
'm') && (b ==
'b') ) chr =
'Á';
702 else if ( (a ==
'o') && (b ==
'b') ) chr =
'á';
704 else if ( (a ==
'm') && (b ==
'c') ) chr =
'Â';
705 else if ( (a ==
'o') && (b ==
'c') ) chr =
'â';
707 else if ( (a ==
'm') && (b ==
'd') ) chr =
'Ã';
708 else if ( (a ==
'o') && (b ==
'd') ) chr =
'ã';
710 else if ( (a ==
'm') && (b ==
'e') ) chr =
'Ä';
711 else if ( (a ==
'o') && (b ==
'e') ) chr =
'ä';
713 else if ( (a ==
'm') && (b ==
'f') ) chr =
'Å';
714 else if ( (a ==
'o') && (b ==
'f') ) chr =
'å';
716 else if ( (a ==
'm') && (b ==
'g') ) chr =
'Æ';
717 else if ( (a ==
'o') && (b ==
'g') ) chr =
'æ';
721 else if ( (a ==
'm') && (b ==
'i') ) chr =
'È';
722 else if ( (a ==
'o') && (b ==
'i') ) chr =
'è';
724 else if ( (a ==
'm') && (b ==
'j') ) chr =
'É';
725 else if ( (a ==
'o') && (b ==
'j') ) chr =
'é';
727 else if ( (a ==
'm') && (b ==
'k') ) chr =
'Ê';
728 else if ( (a ==
'o') && (b ==
'k') ) chr =
'ê';
730 else if ( (a ==
'm') && (b ==
'l') ) chr =
'Ë';
731 else if ( (a ==
'o') && (b ==
'l') ) chr =
'ë';
738 else if ( (a ==
'm') && (b ==
'm') ) chr =
'Ì';
739 else if ( (a ==
'o') && (b ==
'm') ) chr =
'ì';
741 else if ( (a ==
'm') && (b ==
'n') ) chr =
'Í';
742 else if ( (a ==
'o') && (b ==
'n') ) chr =
'í';
744 else if ( (a ==
'm') && (b ==
'o') ) chr =
'Î';
745 else if ( (a ==
'o') && (b ==
'o') ) chr =
'î';
747 else if ( (a ==
'm') && (b ==
'p') ) chr =
'Ï';
748 else if ( (a ==
'o') && (b ==
'p') ) chr =
'ï';
751 else if ( (a ==
'n') && (b ==
'b') ) chr =
'Ñ';
752 else if ( (a ==
'p') && (b ==
'b') ) chr =
'ñ';
755 else if ( (a ==
'k') && (b ==
'c') ) chr =
'¢';
756 else if ( (a ==
'k') && (b ==
'j') ) chr =
'©';
757 else if ( (a ==
'l') && (b ==
'f') ) chr =
'µ';
758 else if ( (a ==
'n') && (b ==
'i') ) chr =
'Ø';
759 else if ( (a ==
'p') && (b ==
'i') ) chr =
'ø';
761 else if ( (a ==
'l') && (b ==
'j') ) chr =
'¹';
762 else if ( (a ==
'l') && (b ==
'c') ) chr =
'²';
763 else if ( (a ==
'l') && (b ==
'd') ) chr =
'³';
765 else if ( (a ==
'l') && (b ==
'm') ) chr =
'¼';
766 else if ( (a ==
'l') && (b ==
'n') ) chr =
'½';
767 else if ( (a ==
'l') && (b ==
'o') ) chr =
'¾';
769 else if ( (a ==
'l') && (b ==
'a') ) chr =
'°';
771 else if ( (a ==
'k') && (b ==
'o') ) chr =
'®';
772 else if ( (a ==
'k') && (b ==
'h') ) chr =
'§';
773 else if ( (a ==
'k') && (b ==
'd') ) chr =
'£';
775 else if ( (a ==
'p') && (b ==
'a') ) chr =
'ð';
776 else if ( (a ==
'n') && (b ==
'a') ) chr =
'Ð';
778 else if ( (a ==
'l') && (b ==
'l') ) chr =
'»';
779 else if ( (a ==
'k') && (b ==
'l') ) chr =
'«';
781 else if ( (a ==
'l') && (b ==
'k') ) chr =
'º';
783 else if ( (a ==
'l') && (b ==
'h') ) chr =
'·';
785 else if ( (a ==
'k') && (b ==
'b') ) chr =
'¡';
787 else if ( (a ==
'k') && (b ==
'e') ) chr =
'¤';
789 else if ( (a ==
'l') && (b ==
'b') ) chr =
'±';
791 else if ( (a ==
'l') && (b ==
'p') ) chr =
'¿';
793 else if ( (a ==
'k') && (b ==
'f') ) chr =
'¥';
795 else if ( (a ==
'p') && (b ==
'o') ) chr =
'þ';
796 else if ( (a ==
'n') && (b ==
'o') ) chr =
'Þ';
798 else if ( (a ==
'n') && (b ==
'n') ) chr =
'Ý';
799 else if ( (a ==
'p') && (b ==
'n') ) chr =
'ý';
800 else if ( (a ==
'p') && (b ==
'p') ) chr =
'ÿ';
802 else if ( (a ==
'k') && (b ==
'k') ) chr =
'ª';
804 else if ( (a ==
'k') && (b ==
'm') ) chr =
'¬';
805 else if ( (a ==
'p') && (b ==
'h') ) chr =
'÷';
807 else if ( (a ==
'k') && (b ==
'g') ) chr =
'|';
809 else if ( (a ==
'l') && (b ==
'e') ) chr =
'\'';
811 else if ( (a ==
'k') && (b ==
'i') ) chr =
'¨';
813 else if ( (a ==
'k') && (b ==
'n') ) chr =
'';
815 else if ( (a ==
'k') && (b ==
'p') ) chr =
'¯';
817 else if ( (a ==
'l') && (b ==
'g') ) chr =
'¶';
819 else if ( (a ==
'l') && (b ==
'i') ) chr =
'¸';
821 else if ( (a ==
'm') && (b ==
'h') ) chr =
'Ç';
822 else if ( (a ==
'o') && (b ==
'h') ) chr =
'ç';
824 else if ( (a ==
'n') && (b ==
'h') ) chr =
'×';
826 else if ( (a ==
'k') && (b ==
'a') ) chr =
' ';
828 else if ( (a ==
'a') && (b ==
'j') ) chr =
'!';
841APPLIXSPREADImport::writePen (TQString &str,
int penwidth,
int penstyle, TQString framecolor)
843 str +=
" <pen width=\"";
846 str += TQString::number (penwidth);
847 str +=
"\" style=\"";
850 str += TQString::number (penstyle);
851 str +=
"\" color=\"";
865APPLIXSPREADImport::writeColor (t_mycolor *mc)
873 sprintf (rgb,
"#%02X%02X%02X", mc->r, mc->g, mc->b);
887APPLIXSPREADImport::readTypefaceTable (TQTextStream &stream, TQStringList &typefacetab)
889 int tftabCounter=0, ok;
893 kdDebug()<<
"Reading typeface table: \n";
898 mystr = nextLine( stream );
899 if (mystr ==
"END TYPEFACE TABLE" ) ok =
false;
903 typefacetab.append(mystr);
909 kdDebug()<<
"... done \n";
918APPLIXSPREADImport::readColormap (TQTextStream &stream, TQPtrList<t_mycolor> &mcol)
920 int contcount, ok, pos;
922 TQString colstr, mystr;
923 kdDebug ()<<
"Reading colormap: \n";
930 mystr = nextLine( stream );
931 mystr.stripWhiteSpace ();
933 if (mystr ==
"END COLORMAP") ok =
false;
936 kdDebug()<<
" -> "<< mystr<<endl;
939 contcount = mystr.contains (
' ');
940 kdDebug()<<
"contcount: "<< contcount<<endl;
944 pos = mystr.find (
" 0 ");
947 colstr = mystr.left (pos);
948 mystr.remove (0, pos+1);
949 mystr.stripWhiteSpace ();
951 t_mycolor *tmc =
new t_mycolor;
954 pos = sscanf (mystr.latin1(),
"0 %d %d %d %d 0",
955 &tmc->c, &tmc->m, &tmc->y, &tmc->k);
957 printf (
" - <%-20s> <%-15s> <%3d> <%3d> <%3d> <%3d> pos: %d\n",
960 tmc->c, tmc->m, tmc->y, tmc->k, pos);
963 tmc->r = 255 - (tmc->c + tmc->k);
964 if (tmc->r < 0) tmc->r = 0;
966 tmc->g = 255 - (tmc->m + tmc->k);
967 if (tmc->g < 0) tmc->g = 0;
969 tmc->b = 255 - (tmc->y + tmc->k);
970 if (tmc->b < 0) tmc->b = 0;
978 kdDebug()<<
"... done "<< mcol.count()<<endl;
982 for (emp=mcol.first(); emp != 0; emp=mcol.next() )
984 printf (
" c:%3d m:%3d y:%3d k:%3d r:%3d g:%3d b:%3d\n",
985 emp->c, emp->m, emp->y, emp->k, emp->r, emp->g, emp->b);
996APPLIXSPREADImport::readView (TQTextStream &stream, TQString instr, t_rc &rc)
999 TQString mystr, tabname;
1002 kdDebug()<<
"Reading View\n";
1006 tabname.remove (0, 19);
1007 tabname.remove (tabname.length()-2, 2);
1008 kdDebug()<<
" - Table name: "<< tabname<<endl;
1013 mystr = nextLine( stream );
1015 kdDebug()<<
" "<< mystr<<endl;
1016 if (mystr.startsWith (
"View End, Name:")) ok =
false;
1020 if (mystr.startsWith (
"View Column Widths"))
1022 kdDebug()<<
" - Column Widths\n";
1023 mystr.remove (0, 20);
1024 kdDebug()<<
" "<<mystr<<endl;
1026 int colwidth, icolumn;
1030 TQStringList ColumnList;
1031 ColumnList = TQStringList::split (
' ', mystr);
1033 for ( TQStringList::Iterator it = ColumnList.begin(); it != ColumnList.end(); ++it )
1036 sscanf ((*it).latin1(),
"%c:%d", &ccolumn, &colwidth);
1037 int len = (*it).length ();
1038 int pos = (*it).find (
":");
1039 (*it).remove (pos, len-pos);
1041 printf(
" >%s<- -<%c><%d> \n", (*it).latin1(), ccolumn, colwidth);
1044 icolumn = translateColumnNumber (*it);
1048 icolumn = icolumn * 5;
1051 rowcolstr +=
" <column width=\"";
1052 rowcolstr += TQString::number (colwidth);
1053 rowcolstr +=
"\" column=\"";
1054 rowcolstr += TQString::number (icolumn);
1055 rowcolstr +=
"\" >\n";
1056 rowcolstr +=
" <format/>\n";
1057 rowcolstr +=
" </column>\n";
1062 else if (mystr.startsWith (
"View Row Heights"))
1064 kdDebug()<<
" - Row Heights\n";
1065 mystr.remove (0, 17);
1066 kdDebug()<<
" "<< mystr<<endl;
1068 int irow, rowheight;
1071 TQStringList RowList;
1072 RowList = TQStringList::split (
' ', mystr);
1074 for ( TQStringList::Iterator it = RowList.begin(); it != RowList.end(); ++it )
1076 sscanf ((*it).latin1(),
" %d:%d",
1078 printf (
" row: %2d height: %2d\n", irow, rowheight);
1079 if (rowheight > 32768) rowheight -= 32768;
1080 printf (
" height: %2d\n", rowheight);
1081 rowcolstr +=
" <row row=\"";
1082 rowcolstr += TQString::number (irow);
1083 rowcolstr +=
"\" height=\"";
1084 rowcolstr += TQString::number (rowheight);
1085 rowcolstr +=
"\" >\n";
1086 rowcolstr +=
" <format/>\n";
1087 rowcolstr +=
" </row>\n";
1094 while (ok ==
true );
1098 rc.tabname.append (tabname);
1099 rc.rc.append (rowcolstr);
1101 printf (
"%s %s\n", tabname.latin1(),
1102 rowcolstr.latin1());
1104 printf (
"...done \n\n");
1115APPLIXSPREADImport::filterSHFGBG (TQString it,
int *style,
int *bgcolor,
1123 pos = it.find (
"SH");
1127 if (pos > 0) tmpstr.remove(0, pos);
1128 pos = sscanf (tmpstr.latin1(),
"SH%d",
1131 printf (
"style: %d(%d) ",
1137 pos = it.find (
"FG");
1141 if (pos > 0) tmpstr.remove(0, pos);
1142 pos = sscanf (tmpstr.latin1(),
"FG%d",
1144 printf (
"fg: %d(%d) ",
1151 pos = it.find (
"BG");
1155 if (pos > 0) tmpstr.remove(0, pos);
1156 pos = sscanf (tmpstr.latin1(),
"BG%d",
1158 printf (
"bgcolor: %d(%d) ",
1168 if ((*style == 8) && (m2 == 1) && (m3 == 0))
1170 *bgcolor = *fgcolor;
1177 if (*style == 1) *style = 0;
1178 else if (*style == 2) *style = 7;
1179 else if (*style == 3) *style = 0;
1180 else if (*style == 4) *style = 4;
1181 else if (*style == 5) *style = 3;
1182 else if (*style == 6) *style = 2;
1183 else if (*style == 7) *style = 0;
1184 else if (*style == 8) *style = 0;
1185 else if (*style == 9) *style = 10;
1186 else if (*style == 10) *style = 9;
1187 else if (*style == 11) *style = 11;
1188 else if (*style == 12) *style = 12;
1189 else if (*style == 13) *style = 13;
1190 else if (*style == 14) *style = 14;
1191 else if (*style == 15) *style = 0;
1192 else if (*style == 16) *style = 0;
1193 else if (*style == 17) *style = 0;
1194 else if (*style == 18) *style = 0;
1195 else if (*style == 19) *style = 0;
1205APPLIXSPREADImport::transPenFormat (TQString it,
int *PenWidth,
int *PenStyle)
1214 else if ( it[1] ==
'2' )
1220 else if ( it[1] ==
'3' )
1226 else if ( it[1] ==
'4' )
1232 else if ( it[1] ==
'5' )
1238 printf (
"frame (w:%d - s:%d) \n", *PenWidth, *PenStyle);
1248APPLIXSPREADImport::readHeader (TQTextStream &stream)
1251 int vers[3] = { 0, 0, 0 };
1256 mystr = nextLine (stream);
1257 rueck = sscanf (mystr.latin1(),
1258 "*BEGIN SPREADSHEETS VERSION=%d/%d ENCODING=%dBIT",
1259 &vers[0], &vers[1], &vers[2]);
1260 printf (
"Versions info: %d %d %d\n", vers[0], vers[1], vers[2]);
1265 printf (
"Header not correkt - May be it is not an applixspreadsheet file\n");
1266 printf (
"Headerline: <%s>\n", mystr.latin1());
1268 TQMessageBox::critical (0L,
"Applix spreadsheet header problem",
1269 TQString (
"The Applix Spreadsheet header is not correct. "
1270 "May be it is not an applix spreadsheet file! <BR>"
1271 "This is the header line I did read:<BR><B>%1</B>").arg(mystr.latin1()),
1289APPLIXSPREADImport::translateColumnNumber (TQString colstr)
1295 len = colstr.length ();
1299 printf (
"HI 0 len:%d\n", len );
1302 printf (
"HI 1 x:%d p:%d char:<%c>\n", x, p, colstr[p].latin1());
1304 if ((colstr[p] >=
'A') && (colstr[p] <=
'Z'))
1306 kdDebug ()<<
" UPPER\n";
1307 icol = icol + ((int)pow ((
double)x, 26) * (colstr[p].latin1() -
'A' + 1) );
1311 else if ((colstr[p] >=
'a') && (colstr[p] <=
'z'))
1313 kdDebug()<<
" lower\n";
1314 icol = icol + ((int)pow ((
double)x, 26) * (colstr[p].latin1() -
'a' + 1) );
1318 kdDebug ()<<
"HI 2\n";
1322 printf (
"translateColumnNumber : <%s> -> %d\n", colstr.latin1(), icol);
1326#include <applixspreadimport.moc>