/* This file is part of the KDE project Copyright (C) 2001 Enno Bartels This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #ifdef HAVE_UNISTD_H #include #endif #include #include #include #include #include #include #include #include #include typedef KGenericFactory APPLIXSPREADImportFactory; K_EXPORT_COMPONENT_FACTORY( libapplixspreadimport, APPLIXSPREADImportFactory( "kofficefilters" ) ) APPLIXSPREADImport::APPLIXSPREADImport ( TQObject */*parent*/, const char* /*name*/, const TQStringList& ) : KoFilter() { } TQString APPLIXSPREADImport::nextLine( TQTextStream & stream ) { TQString s = stream.readLine(); m_instep += s.length(); if (m_instep > m_stepsize) { m_instep = 0; m_progress += 2; emit sigProgress( m_progress ); } return s; } KoFilter::ConversionStatus APPLIXSPREADImport::convert( const TQCString& from, const TQCString& to ) { if (to != "application/x-kspread" || from != "application/x-applixspread") return KoFilter::NotImplemented; TQFile in (m_chain->inputFile()); if (!in.open(IO_ReadOnly)) { kdError(30502) << "Unable to open input file!" << endl; in.close(); return KoFilter::FileNotFound; } TQString str; TQPtrList mcol; str += "\n"; str += "\n"; str += "\n"; str += " \n"; str += " \n"; str += " \n"; str += " \n"; str += " \n"; str += " \n"; str += " \n"; // str += " \n"; // TQTextStream TQTextStream stream (&in); m_stepsize = in.size()/50; m_instep = 0; m_progress = 0; int pos; char ccol; int irow, icol; TQString tabctr ; // Tab control TQString mystr, typestr, cellnostr, tabnostr; TQStringList typefacetab; // TQStringList rclist; t_rc my_rc; /************************************************************************** * Read header * **************************************************************************/ if (! readHeader (stream)) return KoFilter::StupidError; while (!stream.atEnd ()) { // Read one line mystr = nextLine( stream ); kdDebug()<<"INPUT : "<= 80-1) { kdDebug()<< " Line >= 80 chars \n"; int ok = true; do { pos = in.at (); mystrn = nextLine( stream ); if (mystrn[0] == ' ') { mystrn.remove (0, 1); mystr += mystrn; } else { in.at (pos); ok = false; } } while (ok == true); } // Search for ')' pos = mystr.find (')'); typestr = mystr.left (pos); // Delete typeformat infos incl. Space mystr.remove (0, pos+1); // alllength = alllength - pos - 1; // Search for ':' pos = mystr.find (':'); // Copy cellnumber informations cellnostr = mystr.left (pos); // Delete cellnumber informations mystr.remove (0, pos+1); // alllength = alllength - pos - 1; // Split Table and Cell Number pos = cellnostr.find ('!'); // Copy tabnumber informations tabnostr = cellnostr.left (pos); // Delete cellnumber informations cellnostr.remove (0, pos+1); int len = cellnostr.length (); char tmp[300], tmp1[300]; int leni; pos = cellnostr.find (TQRegExp ("[0-9]")); kdDebug()<<" findpos :"<, & mystr.replace (TQRegExp ("&"), "&"); mystr.replace (TQRegExp ("<"), "<"); mystr.replace (TQRegExp (">"), ">"); // Replace part for Applix Characters int foundSpecialCharakter; TQChar newchar; do { // initialize foundSpecialCharakter = false; pos = mystr.find ("^"); // is there a special character ? if (pos > -1 ) { // i have found a special character ! foundSpecialCharakter = true; // translate the applix special character newchar = specCharfind (mystr[pos+1], mystr[pos+2]); // replace the character mystr.replace (pos, 3, newchar); } } while (foundSpecialCharakter == true); // examine the typestring // splitt typestring in 3 parts by an | TQString typeFormStr; TQString typeCharStr; TQString typeCellStr; int pos1 = typestr.find ("|"); int pos2 = typestr.findRev ("|"); typeFormStr = typestr.left (pos1); typeCharStr = typestr.mid (pos1+1, pos2 - pos1 - 1); typeCellStr = typestr.right (typestr.length() - pos2 - 1); // Is it a new table if (tabctr != tabnostr) { // is it not the first table if (!(tabctr.isNull())) str += "
\n"; str += " \n"; tabctr = tabnostr; // Searching for the rowcol part and adding to the hole string pos = my_rc.tabname.findIndex (tabnostr); if (pos > -1) str += my_rc.rc[pos]; } kdDebug()<<" Data : Text :"<"<<*it<<"< "<%s< ", // nn, (*it).latin1() ); nn++; // Grep horizontal alignment if ( (*it) == "1") { kdDebug()<< " = left align\n"; align = 1; // left } else if ( (*it) == "2") { kdDebug()<< " = right align\n"; align = 3; // right } else if ( (*it) == "3") { kdDebug()<< " = center align\n"; align = 2; // center } // Grep verticale alignment else if ( (*it) == "VT") { kdDebug()<<" = top valign\n"; valign = 1; // top } else if ( (*it) == "VC") { kdDebug()<<" = center valign\n"; valign = 0; // center - default (2) } else if ( (*it) == "VB") { kdDebug()<<" = bottom valign\n"; valign = 3; // bottom } else { kdDebug()<<" = ???\n"; } } /******************************************************************** * examine cell format String, splitt it up in basic parts * ********************************************************************/ TQStringList typeCellList; int topPenWidth=0, bottomPenWidth=0, leftPenWidth = 0, rightPenWidth = 0, fg_bg=-1; int topPenStyle=0, bottomPenStyle=0, leftPenStyle = 0, rightPenStyle = 0; int brushstyle=0, brushcolor=1; int topbrushstyle=0, topbrushcolor=1, topfg_bg=1; int leftbrushstyle=0, leftbrushcolor=1, leftfg_bg=1; int rightbrushstyle=0, rightbrushcolor=1, rightfg_bg=1; int bottombrushstyle=0, bottombrushcolor=1, bottomfg_bg=1; typeCellList = TQStringList::split (',', typeCellStr); nn=0; for ( TQStringList::Iterator it = typeCellList.begin(); it != typeCellList.end(); ++it ) { // Output printf (" Cell (%2d) >%s< ", nn, (*it).latin1() ); nn++; if ((*it)[0] == 'T') { kdDebug()<<" = top \n"; transPenFormat ((*it), &topPenWidth, &topPenStyle); if ((*it).length() > 2) { (*it).remove (0, 2); filterSHFGBG ((*it), &topbrushstyle, &topbrushcolor, &topfg_bg); } } else if ( (*it)[0] == 'B') { kdDebug()<<" = bottom \n"; transPenFormat ((*it), &bottomPenWidth, &bottomPenStyle); if ((*it).length() > 2) { (*it).remove (0, 2); filterSHFGBG ((*it), &bottombrushstyle, &bottombrushcolor, &bottomfg_bg); } } else if ( (*it)[0] == 'L') { kdDebug()<<" = left \n"; transPenFormat ((*it), &leftPenWidth, &leftPenStyle); if ((*it).length() > 2) { (*it).remove (0, 2); filterSHFGBG ((*it), &leftbrushstyle, &leftbrushcolor, &leftfg_bg); } } else if ( (*it)[0] == 'R') { kdDebug()<<" = right \n"; transPenFormat ((*it), &rightPenWidth, &rightPenStyle); if ((*it).length() > 2) { (*it).remove (0, 2); filterSHFGBG ((*it), &rightbrushstyle, &rightbrushcolor, &rightfg_bg); } } else if ( ((*it).startsWith ("SH")) || ((*it).startsWith ("FG")) || ((*it).startsWith ("BG")) ) { kdDebug()<<" = \n"; filterSHFGBG ((*it), &brushstyle, &fg_bg, &brushcolor); } else { kdDebug()<<" = ???\n"; } } TQString col; // create kspread fileformat output str += " \n"; if (bold == 1 || italic == 1 || underline == 1 || align != 0 || valign != 0 || topPenStyle != 0 || bottomPenStyle != 0 || leftPenStyle != 0 || rightPenStyle != 0 || fg !=-1 || fg_bg != -1 || fontsize != 12 || brushstyle != 0 || fontnr != -1) { str += " \n"; } // Left border if (leftPenWidth > 0) { str += " \n"; col = writeColor (mcol.at(leftfg_bg)); writePen (str, leftPenWidth, leftPenStyle, col); str += " \n"; } // Right border if (rightPenWidth > 0) { str += " \n"; col = writeColor (mcol.at(rightfg_bg)); writePen (str, rightPenWidth, rightPenStyle, col); str += " \n"; } // Bottom border if (bottomPenWidth > 0) { str += " \n"; col = writeColor (mcol.at(bottomfg_bg)); writePen (str, bottomPenWidth, bottomPenStyle, col); str += " \n"; } // Top border if (topPenWidth > 0) { str += " \n"; col = writeColor (mcol.at(topfg_bg)); writePen (str, topPenWidth, topPenStyle, col); str += " \n"; } // Font (size and family) if ((fontsize != 12) || (fontnr != -1)) { str += " \n"; str += " \n"; } } emit sigProgress(100); str += "
\n"; str += "
\n"; str += "
\n"; // str += "\n"; kdDebug ()<<"Text "<< str<storageFile( "root", KoStore::Write ); if (!out) { kdError(38000/*30502*/) << "Unable to open output file!" << endl; in.close (); return KoFilter::StorageCreationError; } TQCString cstring = str.utf8(); out->writeBlock ( cstring, cstring.length() ); in.close (); return KoFilter::OK; } /****************************************************************************** * function: specCharfind * ******************************************************************************/ TQChar APPLIXSPREADImport::specCharfind (TQChar a, TQChar b) { TQChar chr; if ( (a == 'n') && (b == 'p') ) chr = 'ß'; else if ( (a == 'n') && (b == 'c') ) chr = 'Ò'; else if ( (a == 'p') && (b == 'c') ) chr = 'ò'; else if ( (a == 'n') && (b == 'd') ) chr = 'Ó'; else if ( (a == 'p') && (b == 'd') ) chr = 'ó'; else if ( (a == 'n') && (b == 'e') ) chr = 'Ô'; else if ( (a == 'p') && (b == 'e') ) chr = 'ô'; else if ( (a == 'n') && (b == 'f') ) chr = 'Õ'; else if ( (a == 'p') && (b == 'f') ) chr = 'õ'; else if ( (a == 'p') && (b == 'g') ) chr = 'ö'; else if ( (a == 'n') && (b == 'g') ) chr = 'Ö'; else if ( (a == 'n') && (b == 'j') ) chr = 'Ù'; else if ( (a == 'p') && (b == 'j') ) chr = 'ù'; else if ( (a == 'n') && (b == 'k') ) chr = 'Ú'; else if ( (a == 'p') && (b == 'k') ) chr = 'ú'; else if ( (a == 'n') && (b == 'l') ) chr = 'Û'; else if ( (a == 'p') && (b == 'l') ) chr = 'û'; else if ( (a == 'p') && (b == 'm') ) chr = 'ü'; else if ( (a == 'n') && (b == 'm') ) chr = 'Ü'; else if ( (a == 'm') && (b == 'a') ) chr = 'À'; else if ( (a == 'o') && (b == 'a') ) chr = 'à'; else if ( (a == 'm') && (b == 'b') ) chr = 'Á'; else if ( (a == 'o') && (b == 'b') ) chr = 'á'; else if ( (a == 'm') && (b == 'c') ) chr = 'Â'; else if ( (a == 'o') && (b == 'c') ) chr = 'â'; else if ( (a == 'm') && (b == 'd') ) chr = 'Ã'; else if ( (a == 'o') && (b == 'd') ) chr = 'ã'; else if ( (a == 'm') && (b == 'e') ) chr = 'Ä'; else if ( (a == 'o') && (b == 'e') ) chr = 'ä'; else if ( (a == 'm') && (b == 'f') ) chr = 'Å'; else if ( (a == 'o') && (b == 'f') ) chr = 'å'; else if ( (a == 'm') && (b == 'g') ) chr = 'Æ'; else if ( (a == 'o') && (b == 'g') ) chr = 'æ'; else if ( (a == 'm') && (b == 'i') ) chr = 'È'; else if ( (a == 'o') && (b == 'i') ) chr = 'è'; else if ( (a == 'm') && (b == 'j') ) chr = 'É'; else if ( (a == 'o') && (b == 'j') ) chr = 'é'; else if ( (a == 'm') && (b == 'k') ) chr = 'Ê'; else if ( (a == 'o') && (b == 'k') ) chr = 'ê'; else if ( (a == 'm') && (b == 'l') ) chr = 'Ë'; else if ( (a == 'o') && (b == 'l') ) chr = 'ë'; else if ( (a == 'm') && (b == 'm') ) chr = 'Ì'; else if ( (a == 'o') && (b == 'm') ) chr = 'ì'; else if ( (a == 'm') && (b == 'n') ) chr = 'Í'; else if ( (a == 'o') && (b == 'n') ) chr = 'í'; else if ( (a == 'm') && (b == 'o') ) chr = 'Î'; else if ( (a == 'o') && (b == 'o') ) chr = 'î'; else if ( (a == 'm') && (b == 'p') ) chr = 'Ï'; else if ( (a == 'o') && (b == 'p') ) chr = 'ï'; else if ( (a == 'n') && (b == 'b') ) chr = 'Ñ'; else if ( (a == 'p') && (b == 'b') ) chr = 'ñ'; else if ( (a == 'k') && (b == 'c') ) chr = '¢'; else if ( (a == 'k') && (b == 'j') ) chr = '©'; else if ( (a == 'l') && (b == 'f') ) chr = 'µ'; else if ( (a == 'n') && (b == 'i') ) chr = 'Ø'; else if ( (a == 'p') && (b == 'i') ) chr = 'ø'; else if ( (a == 'l') && (b == 'j') ) chr = '¹'; else if ( (a == 'l') && (b == 'c') ) chr = '²'; else if ( (a == 'l') && (b == 'd') ) chr = '³'; else if ( (a == 'l') && (b == 'm') ) chr = '¼'; else if ( (a == 'l') && (b == 'n') ) chr = '½'; else if ( (a == 'l') && (b == 'o') ) chr = '¾'; else if ( (a == 'l') && (b == 'a') ) chr = '°'; else if ( (a == 'k') && (b == 'o') ) chr = '®'; else if ( (a == 'k') && (b == 'h') ) chr = '§'; else if ( (a == 'k') && (b == 'd') ) chr = '£'; else if ( (a == 'p') && (b == 'a') ) chr = 'ð'; else if ( (a == 'n') && (b == 'a') ) chr = 'Ð'; else if ( (a == 'l') && (b == 'l') ) chr = '»'; else if ( (a == 'k') && (b == 'l') ) chr = '«'; else if ( (a == 'l') && (b == 'k') ) chr = 'º'; else if ( (a == 'l') && (b == 'h') ) chr = '·'; else if ( (a == 'k') && (b == 'b') ) chr = '¡'; else if ( (a == 'k') && (b == 'e') ) chr = '¤'; else if ( (a == 'l') && (b == 'b') ) chr = '±'; else if ( (a == 'l') && (b == 'p') ) chr = '¿'; else if ( (a == 'k') && (b == 'f') ) chr = '¥'; else if ( (a == 'p') && (b == 'o') ) chr = 'þ'; else if ( (a == 'n') && (b == 'o') ) chr = 'Þ'; else if ( (a == 'n') && (b == 'n') ) chr = 'Ý'; else if ( (a == 'p') && (b == 'n') ) chr = 'ý'; else if ( (a == 'p') && (b == 'p') ) chr = 'ÿ'; else if ( (a == 'k') && (b == 'k') ) chr = 'ª'; else if ( (a == 'k') && (b == 'm') ) chr = '¬'; else if ( (a == 'p') && (b == 'h') ) chr = '÷'; else if ( (a == 'k') && (b == 'g') ) chr = '|'; else if ( (a == 'l') && (b == 'e') ) chr = '\''; else if ( (a == 'k') && (b == 'i') ) chr = '¨'; else if ( (a == 'k') && (b == 'n') ) chr = '­'; else if ( (a == 'k') && (b == 'p') ) chr = '¯'; else if ( (a == 'l') && (b == 'g') ) chr = '¶'; else if ( (a == 'l') && (b == 'i') ) chr = '¸'; else if ( (a == 'm') && (b == 'h') ) chr = 'Ç'; else if ( (a == 'o') && (b == 'h') ) chr = 'ç'; else if ( (a == 'n') && (b == 'h') ) chr = '×'; else if ( (a == 'k') && (b == 'a') ) chr = ' '; else if ( (a == 'a') && (b == 'j') ) chr = '!'; else chr = '#'; return chr; } /****************************************************************************** * function: writePen * ******************************************************************************/ void APPLIXSPREADImport::writePen (TQString &str, int penwidth, int penstyle, TQString framecolor) { str += " \n"; } /****************************************************************************** * function: writeColor * ******************************************************************************/ TQString APPLIXSPREADImport::writeColor (t_mycolor *mc) { char rgb[20]; // printf (" WriteColor: <%d>-<%d>-<%d> <%d>-<%d>-<%d>-<%d>\n", // mc->r, mc->g, mc->b, // mc->c, mc->m, mc->y, mc->k); sprintf (rgb, "#%02X%02X%02X", mc->r, mc->g, mc->b); TQString bla = rgb; return bla; } /****************************************************************************** * function: readTypefaceTable * ******************************************************************************/ void APPLIXSPREADImport::readTypefaceTable (TQTextStream &stream, TQStringList &typefacetab) { int tftabCounter=0, ok; TQString mystr; // Read the colormap kdDebug()<<"Reading typeface table: \n"; ok = true; do { mystr = nextLine( stream ); if (mystr == "END TYPEFACE TABLE" ) ok = false; else { //printf (" %2d: <%s>\n", tftabCounter, mystr.latin1()); typefacetab.append(mystr); tftabCounter++; } } while (ok == true ); kdDebug()<<"... done \n"; } /****************************************************************************** * function: readColormap * ******************************************************************************/ void APPLIXSPREADImport::readColormap (TQTextStream &stream, TQPtrList &mcol) { int contcount, ok, pos; TQString colstr, mystr; kdDebug ()<<"Reading colormap: \n"; ok = true; do { mystr = nextLine( stream ); mystr.stripWhiteSpace (); if (mystr == "END COLORMAP") ok = false; else { kdDebug()<<" -> "<< mystr<c, &tmc->m, &tmc->y, &tmc->k); printf (" - <%-20s> <%-15s> <%3d> <%3d> <%3d> <%3d> pos: %d\n", mystr.latin1(), colstr.latin1(), tmc->c, tmc->m, tmc->y, tmc->k, pos); // Color transformation cmyk -> rgb tmc->r = 255 - (tmc->c + tmc->k); if (tmc->r < 0) tmc->r = 0; tmc->g = 255 - (tmc->m + tmc->k); if (tmc->g < 0) tmc->g = 0; tmc->b = 255 - (tmc->y + tmc->k); if (tmc->b < 0) tmc->b = 0; mcol.append (tmc); } } while (ok == true ); kdDebug()<< "... done "<< mcol.count()<c, emp->m, emp->y, emp->k, emp->r, emp->g, emp->b); } } /****************************************************************************** * function: readColormap * ******************************************************************************/ void APPLIXSPREADImport::readView (TQTextStream &stream, TQString instr, t_rc &rc) { TQString rowcolstr; TQString mystr, tabname; int ok; kdDebug()<<"Reading View\n"; tabname = instr; tabname.remove (0, 19); tabname.remove (tabname.length()-2, 2); kdDebug()<< " - Table name: "<< tabname<%s<- -<%c><%d> \n", (*it).latin1(), ccolumn, colwidth); // Transformat ascii column to int column icolumn = translateColumnNumber (*it); //icolumn = ccolumn - 64; // Translate the column width right from applix to kspread icolumn = icolumn * 5; rowcolstr += " \n"; rowcolstr += " \n"; rowcolstr += " \n"; } } // ROW Heights else if (mystr.startsWith ("View Row Heights")) { kdDebug()<< " - Row Heights\n"; mystr.remove (0, 17); kdDebug()<<" "<< mystr< 32768) rowheight -= 32768; printf (" height: %2d\n", rowheight); rowcolstr += " \n"; rowcolstr += " \n"; rowcolstr += " \n"; } } } // else != END COLORMAP } while (ok == true ); // tabname append to my list // tabname append to my list rc.tabname.append (tabname); rc.rc.append (rowcolstr); printf ("%s %s\n", tabname.latin1(), rowcolstr.latin1()); printf ("...done \n\n"); } /****************************************************************************** * function: filterSHFGBG * ******************************************************************************/ void APPLIXSPREADImport::filterSHFGBG (TQString it, int *style, int *bgcolor, int *fgcolor) { TQString tmpstr; int pos; int m2=0, m3=0; // filter SH = Brushstyle Background pos = it.find ("SH"); if (pos > -1) { tmpstr = it; if (pos > 0) tmpstr.remove(0, pos); pos = sscanf (tmpstr.latin1(), "SH%d", style); printf ("style: %d(%d) ", *style, pos); } // filter FG = FGCOLOR pos = it.find ("FG"); if (pos > -1) { tmpstr = it; if (pos > 0) tmpstr.remove(0, pos); pos = sscanf (tmpstr.latin1(), "FG%d", fgcolor); printf ("fg: %d(%d) ", *fgcolor, pos); m2=1; } // filter BG = BGCOLOR pos = it.find ("BG"); if (pos > -1) { tmpstr = it; if (pos > 0) tmpstr.remove(0, pos); pos = sscanf (tmpstr.latin1(), "BG%d", bgcolor); printf ("bgcolor: %d(%d) ", *bgcolor, pos); m3=1; } printf ("\n"); // corrent the bgcolor to the fgcolor if the background is plain if ((*style == 8) && (m2 == 1) && (m3 == 0)) { *bgcolor = *fgcolor; } // Translate brushstyle to kspread brushstyle if (*style != 0) { if (*style == 1) *style = 0; else if (*style == 2) *style = 7; else if (*style == 3) *style = 0; else if (*style == 4) *style = 4; else if (*style == 5) *style = 3; else if (*style == 6) *style = 2; else if (*style == 7) *style = 0; else if (*style == 8) *style = 0; else if (*style == 9) *style = 10; else if (*style == 10) *style = 9; else if (*style == 11) *style = 11; else if (*style == 12) *style = 12; else if (*style == 13) *style = 13; else if (*style == 14) *style = 14; else if (*style == 15) *style = 0; else if (*style == 16) *style = 0; else if (*style == 17) *style = 0; else if (*style == 18) *style = 0; else if (*style == 19) *style = 0; } } /****************************************************************************** * function: filterSHFGBG * ******************************************************************************/ void APPLIXSPREADImport::transPenFormat (TQString it, int *PenWidth, int *PenStyle) { if ( it[1] == '1' ) { *PenWidth = 1; *PenStyle = 1; } else if ( it[1] == '2' ) { *PenWidth = 2; *PenStyle = 1; } else if ( it[1] == '3' ) { *PenWidth = 3; *PenStyle = 1; } else if ( it[1] == '4' ) { *PenWidth = 1; *PenStyle = 3; } else if ( it[1] == '5' ) { *PenWidth = 5; *PenStyle = 1; } printf ("frame (w:%d - s:%d) \n", *PenWidth, *PenStyle); } /****************************************************************************** * function: readHeader * ******************************************************************************/ int APPLIXSPREADImport::readHeader (TQTextStream &stream) { TQString mystr; int vers[3] = { 0, 0, 0 }; int rueck; // Read Headline mystr = nextLine (stream); rueck = sscanf (mystr.latin1(), "*BEGIN SPREADSHEETS VERSION=%d/%d ENCODING=%dBIT", &vers[0], &vers[1], &vers[2]); printf ("Versions info: %d %d %d\n", vers[0], vers[1], vers[2]); // Check the headline if (rueck <= 0) { printf ("Header not correkt - May be it is not an applixspreadsheet file\n"); printf ("Headerline: <%s>\n", mystr.latin1()); TQMessageBox::critical (0L, "Applix spreadsheet header problem", TQString ("The Applix Spreadsheet header is not correct. " "May be it is not an applix spreadsheet file!
" "This is the header line I did read:
%1").arg(mystr.latin1()), "Okay"); return false; } else { return true; } } /****************************************************************************** * function: translateRowNumber * ******************************************************************************/ int APPLIXSPREADImport::translateColumnNumber (TQString colstr) { int icol=0; int p, x, len; len = colstr.length (); p = len-1; x = 1; printf ("HI 0 len:%d\n", len ); while ((p >= 0)) { printf ("HI 1 x:%d p:%d char:<%c>\n", x, p, colstr[p].latin1()); // Upper chars if ((colstr[p] >= 'A') && (colstr[p] <= 'Z')) { kdDebug ()<<" UPPER\n"; icol = icol + ((int)pow ((double)x, 26) * (colstr[p].latin1() - 'A' + 1) ); x++; } // lower chars else if ((colstr[p] >= 'a') && (colstr[p] <= 'z')) { kdDebug()<<" lower\n"; icol = icol + ((int)pow ((double)x, 26) * (colstr[p].latin1() - 'a' + 1) ); x++; } p--; kdDebug ()<< "HI 2\n"; } printf ("translateColumnNumber : <%s> -> %d\n", colstr.latin1(), icol); return icol; } #include