filters

applixgraphicimport.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Enno Bartels <ebartels@nwn.de>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 #define FAKTOR 39.4  // 1000 dots/inch / 2.54 cm/inch    =   394 dots/cm  = 39.4 dots/mm
00020 
00021 #include <config.h>
00022 
00023 #ifdef HAVE_UNISTD_H
00024 #include <unistd.h>
00025 #endif
00026 
00027 #include <kdebug.h>
00028 #include <qfile.h>
00029 #include <qtextstream.h>
00030 #include <qmessagebox.h>
00031 #include <KoFilterChain.h>
00032 #include <kgenericfactory.h>
00033 #include <math.h>
00034 
00035 #include <applixgraphicimport.h>
00036 
00037 typedef KGenericFactory<APPLIXGRAPHICImport, KoFilter> APPLIXGRAPHICImportFactory;
00038 K_EXPORT_COMPONENT_FACTORY( libapplixgraphicimport, APPLIXGRAPHICImportFactory( "kofficefilters" ) )
00039 
00040 int s_area = 30517;
00041 
00042 /******************************************************************************
00043  *  class: applixGraphicsLine          function:  constructor                 *
00044  ******************************************************************************
00045  *                                                                            *
00046  *  Short description : - Initialize all variables                            *
00047  *                                                                            *
00048  *                                                                            *
00049  ******************************************************************************/
00050 applixGraphicsLine::applixGraphicsLine()
00051 {
00052   offX      = 0;
00053   offY      = 0;
00054   reColor   = 0;
00055   thickNess = 1; // ??
00056 
00057   for (int i=0; i<5; i++)
00058   {
00059     ptX[0] = 0;
00060     ptY[0] = 0;
00061   }
00062 }
00063 
00064 
00065 
00066 
00067 
00068 /******************************************************************************
00069  *  class: applixGraphicsRect          function:  constructor                 *
00070  ******************************************************************************
00071  *                                                                            *
00072  *  Short description : - Initialize all variables                            *
00073  *                                                                            *
00074  *                                                                            *
00075  ******************************************************************************/
00076 applixGraphicsRect::applixGraphicsRect() : applixGraphicsLine()
00077 {
00078   for (int i=0; i<7;i++)
00079   {
00080     bf[i] = 0;
00081     lf[i] = 0;
00082   }
00083 
00084   for (int i=0; i<5;i++)
00085   {
00086     sh[i] = 0;
00087   }
00088 
00089   for (int i=0; i<8;i++)
00090   {
00091     pa[i] = 0;
00092   }
00093 
00094   for (int i=0; i<3;i++)
00095   {
00096     vs[i] = 0;
00097   }
00098 
00099   for (int i=0; i<2;i++)
00100   {
00101     xr[i] = 0;
00102   }
00103 
00104 }
00105 
00106 
00107 
00108 
00109 
00110 /******************************************************************************
00111  *  class: APPLIXGRAPHICImport          function:  constructor                *
00112  ******************************************************************************
00113  *                                                                            *
00114  *  Short description : constructor                                           *
00115  *                                                                            *
00116  *                                                                            *
00117  ******************************************************************************/
00118 APPLIXGRAPHICImport::APPLIXGRAPHICImport (KoFilter *, const char *, const QStringList&) :
00119                      KoFilter ()
00120 {
00121 
00122 }
00123 
00124 
00125 
00126 /******************************************************************************
00127  *  class: APPLIXGRAPHICImport          function:  filter                     *
00128  ******************************************************************************
00129  *                                                                            *
00130  *  Short description : - Read inputfile,                                     *
00131  *                      - convert it to kontour fileformat and                *
00132  *                      - save it                                             *
00133  *                                                                            *
00134  *                                                                            *
00135  ******************************************************************************/
00136 KoFilter::ConversionStatus APPLIXGRAPHICImport::convert( const QCString& from, const QCString& to )
00137 {
00138 
00139     // Check MIME Types
00140     if (to!="application/x-karbon" || from!="application/x-applixgraphic")
00141         return KoFilter::NotImplemented;
00142 
00143     // Open Inputfile
00144     QFile in (m_chain->inputFile());
00145     if (!in.open (IO_ReadOnly) )
00146     {
00147         kdError(30502) << "Unable to open input file!" << endl;
00148         in.close ();
00149         return KoFilter::FileNotFound;
00150     }
00151 
00152     QString str;
00153 
00154     // Create karbon header
00155     str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
00156     str += "<!DOCTYPE karbon>\n";
00157     str += " <karbon mime=\"application/x-karbon\" version=\"2\" editor=\"APPLIXGRAPHICS import filter\">\n";
00158 //      str += "  <head>\n";
00159 //      str += "   <layout width=\"210\" lmargin=\"0\" format=\"a4\" bmargin=\"0\" height=\"297\" rmargin=\"0\" tmargin=\"0\" orientation=\"portrait\"/>\n";
00160 //      str += "   <grid dx=\"20\" dy=\"20\" align=\"0\">\n";
00161 //      str += "    <helplines align=\"0\"/>\n";
00162 //      str += "   </grid>\n";
00163 //      str += "  </head>\n";
00164     str += "  <layer name=\"ag-layer\" visible=\"1\">\n";
00165 
00166     QTextStream stream(&in);
00167     int step  = in.size()/50;
00168     int value = 0;
00169     int i     = 0;
00170     int picture_rememberer = 0;
00171     int pos   = 0;
00172     int vers[3] = { 0, 0, 0 };
00173     int rueck;  // Check scanf inputs
00174     QString mystr;
00175 
00176     // Read Headline
00177     mystr = stream.readLine ();
00178     rueck = sscanf ((const char *) mystr.latin1() ,
00179                     "*BEGIN GRAPHICS VERSION=%d/%d ENCODING=%dBIT",
00180                  &vers[0], &vers[1], &vers[2]);
00181     kdDebug (s_area) << "Versions info: " << vers[0] << vers[1] << vers[2] << endl;
00182 
00183     // Check the headline
00184     if (rueck <= 0)
00185     {
00186       kdDebug (s_area) << "Header not correkt - May be it is not an applixgraphics file" << endl;
00187       kdDebug (s_area) << "Headerline: " << mystr << endl;
00188 
00189       QMessageBox::critical (0L, "Applixgraphics header problem",
00190                                   QString ("The Applixgraphics header is not correct. "
00191                                            "May be it is not an applixgraphics file! <BR>"
00192                                            "This is the header line I did read:<BR><B>%1</B>").arg(mystr.latin1()),
00193                     "Comma");
00194 
00195       // i18n( "What is the separator used in this file ? First line is \n%1" ).arg(firstLine),
00196       return KoFilter::StupidError;
00197     }
00198 
00199     while (!stream.atEnd ())
00200     {
00201         ++i;
00202 
00203         // Read one line
00204         mystr = stream.readLine ();
00205         kdDebug (s_area) << "<<" << mystr << ">>" << endl;
00206 
00207         if      (mystr == "PICTURE")     picture_rememberer = 1;
00208         else if (mystr == "END PICTURE") picture_rememberer = 0;
00209 
00210 
00211         // Detect a point at the first place of the ascii_linie
00212         else if ((mystr[0] == '.') && (picture_rememberer == 1))
00213     {
00214           // Delete point at the first place of the ascii_linie
00215           mystr.remove (0, 1);
00216           kdDebug (s_area) << "StartPoint recognized <" << mystr << ">" << endl;
00217 
00218 
00219           /********************************************************************
00220            * Element "LINE"                                                   *
00221            ********************************************************************/
00222           if (mystr.startsWith ("LINE AT") )
00223       {
00224             // Define
00225             applixGraphicsLine agLine;
00226 
00227             //str += agLine.read (int, mystr);
00228 
00229             kdDebug (s_area) << " Linie recognized: " << endl;
00230             mystr.remove (0, 8);
00231             //mystr.remove (0, 7);
00232 
00233 
00234             //remove_pos = mystr.find ('(');
00235             //mystr.remove (0, remove_pos);
00236             //agLine.offX= mystr.toInt();
00237 
00238             //remove_pos = mystr.find (',');
00239             //mystr.remove (0, remove_pos);
00240             //agLine.offY= mystr.toInt();
00241             rueck = sscanf ((const char *) mystr.latin1(), "(%d,%d)",
00242                             &agLine.offX, &agLine.offY);
00243         kdDebug (s_area) << "  Offset ->   x:" << agLine.offX << "  y:" << agLine.offY << endl;
00244             if (rueck <= 0)
00245         {
00246               kdDebug (s_area) << "LINE tag not correkt" << endl;
00247               kdDebug (s_area) << "LINE: <" << mystr << ">" << endl;
00248               return KoFilter::StupidError;
00249         }
00250 
00251             do
00252         {
00253               // Get acutal position
00254               pos = in.at ();
00255               // Read one line
00256               mystr = stream.readLine ();
00257 
00258           if      (mystr.startsWith (" RECOLOR ") )
00259           {
00260                 kdDebug (s_area) << "  Recolor  ";
00261                 mystr.remove (0, 9);
00262                 if      (mystr == "ON")
00263                 {
00264                   kdDebug (s_area) << "On" << endl;
00265                   agLine.reColor = true;
00266                 }
00267                 else if (mystr == "OFF")
00268                 {
00269                   kdDebug (s_area) << "Off" << endl;
00270                   agLine.reColor = false;
00271                 }
00272                 else
00273                 {
00274                    kdDebug (s_area) << "!!!!!    Unknown RECOLOR item <" << mystr << ">" << endl;
00275                 }
00276           }
00277           else if (mystr.startsWith (" THICKNESS ") )
00278           {
00279                 kdDebug (s_area) << "  Thickness: ";
00280                 mystr.remove (0, 11);
00281                 sscanf ((const char *) mystr.latin1(), "%d", &agLine.thickNess);
00282                 //
00283                 kdDebug (s_area) <<  agLine.thickNess << endl;
00284           }
00285           else if (mystr.startsWith (" PNTS ") )
00286           {
00287                 kdDebug (s_area) << "  Pnts    : ";
00288                 mystr.remove (0, 6);
00289                 sscanf ((const char *) mystr.latin1(), "(%d,%d)(%d,%d)",
00290                         &agLine.ptX[0], &agLine.ptY[0], &agLine.ptX[1], &agLine.ptY[1]);
00291                 kdDebug (s_area) << agLine.ptX[0] << " " << agLine.ptY[0] << " "  << agLine.ptX[1] << " "  << agLine.ptY[1] << endl;
00292           }
00293 
00294         }
00295         while ((mystr[0] != '.') && (mystr[0] != 'E'));
00296 
00297             // An die Position zurueckspringen
00298             in.at (pos);
00299 
00300             // Werte in die Struktur einlagern
00301             str += "   <polyline arrow1=\"0\" arrow2=\"0\" >\n";
00302 //          str += "    <point x=\"" + agLine.ptX[0]  + "\" y=\"" + agLine.ptY[0] + "\" />";
00303             str += "    <point x=\"" ;
00304             str += QString::number ((agLine.ptX[0] + agLine.offX)/FAKTOR);
00305             str += "\" y=\"";
00306             str += QString::number ((agLine.ptY[0] + agLine.offY)/FAKTOR);
00307             str += "\" />\n";
00308 
00309 //          str += "    <point x=\"" + agLine.ptX[1]  + "\" y=\"" + agLine.ptY[1] + "\" />";
00310             str += "    <point x=\"";
00311             str += QString::number ((agLine.ptX[1] + agLine.offX)/FAKTOR);
00312             str += "\" y=\"";
00313             str += QString::number ((agLine.ptY[1] + agLine.offY)/FAKTOR);
00314             str += "\" />\n";
00315             str += "    <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
00316             str += "     <matrix dx=\"0\" dy=\"0\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
00317             str += "    </gobject>\n";
00318 
00319 
00320 
00321             str += "   </polyline>\n";
00322 
00323 
00324       }
00325           /********************************************************************
00326            * Element RPOL Vieleck                                             *
00327            ********************************************************************/
00328           if (mystr.startsWith ("RPOL AT") )
00329       {
00330             // Define
00331             applixGraphicsLine agLine;
00332             int nsides;
00333 
00334             //str += agLine.read (int, mystr);
00335 
00336             kdDebug (s_area) << " RPOL recognized: " << endl;
00337             mystr.remove (0, 8);
00338 
00339             rueck = sscanf ((const char *) mystr.latin1(), "(%d,%d)",
00340                             &agLine.offX, &agLine.offY);
00341         kdDebug (s_area) << "  Offset ->   x:" << agLine.offX << "  y:" << agLine.offY << endl;
00342             if (rueck <= 0)
00343         {
00344               kdDebug (s_area) << "RPOL tag not correkt " << endl;
00345               kdDebug (s_area) << "RPOL: <" << mystr << ">" << endl;
00346               return KoFilter::StupidError;
00347         }
00348 
00349             do
00350         {
00351               // Akutelle Position bestimmen
00352               pos = in.at ();
00353               // Zeile einlesen
00354               mystr = stream.readLine ();
00355 //checkSubElement (mystr, subelements)
00356           if      (mystr.startsWith (" RECOLOR ") )
00357           {
00358                 kdDebug (s_area) << "  Recolor  " ;
00359                 mystr.remove (0, 9);
00360                 if      (mystr == "ON")
00361                 {
00362                   kdDebug (s_area) << "On" << endl;
00363                   agLine.reColor = true;
00364                 }
00365                 else if (mystr == "OFF")
00366                 {
00367                   kdDebug (s_area) << "Off" << endl;
00368                   agLine.reColor = false;
00369                 }
00370                 else
00371                 {
00372                    kdDebug (s_area) << "!!!!!    Whats that <" << mystr << ">" << endl;
00373                 }
00374           }
00375           else if (mystr.startsWith (" NSIDES") )
00376           {
00377                 kdDebug (s_area) << "  NSIDES: " ;
00378                 mystr.remove (0, 8);
00379                 pos = sscanf ((const char *) mystr.latin1(), "%d", &nsides);
00380                 kdDebug (s_area) << nsides << "(" << pos << ")" << endl;
00381           }
00382           else if (mystr.startsWith (" PNTS ") )
00383           {
00384                 kdDebug (s_area) << "  Pnts    : ";
00385                 mystr.remove (0, 6);
00386                 sscanf ((const char *) mystr.latin1(), "(%d,%d)(%d,%d)(%d,%d)(%d,%d)(%d,%d)",
00387                         &agLine.ptX[0], &agLine.ptY[0], &agLine.ptX[1], &agLine.ptY[1],
00388                         &agLine.ptX[2], &agLine.ptY[2], &agLine.ptX[3], &agLine.ptY[3],
00389                         &agLine.ptX[4], &agLine.ptY[4]);
00390                 kdDebug (s_area) << agLine.ptX[0] << " " << agLine.ptY[0] << "   " <<
00391                                     agLine.ptX[1] << " " << agLine.ptY[1] << "   " <<
00392                                     agLine.ptX[2] << " " << agLine.ptY[2] << "   " <<
00393                                     agLine.ptX[3] << " " << agLine.ptY[3] << "   " <<
00394                             agLine.ptX[4] << " " << agLine.ptY[4] << endl;
00395           }
00396 //checkSubElement() ende
00397 
00398         }
00399         while ((mystr[0] != '.') && (mystr[0] != 'E'));
00400 
00401 
00402 
00403             // An die Position zurueckspringen
00404             in.at (pos);
00405 
00406             int a, b;
00407             float wink=0.0;
00408             int *x = new int[nsides];
00409             int *y = new int[nsides];
00410             a = agLine.ptX[2] / 2;
00411             b = agLine.ptY[2] / 2;
00412             for (int i=0; i<nsides; i++)
00413         {
00414               x[i] = qRound (a * cos (wink*M_PI/180));
00415               y[i] = qRound (b * sin (wink*M_PI/180));
00416           wink += (360/nsides);
00417         }
00418 
00419             // Werte in die Struktur einlagern
00420             str += "   <polyline arrow1=\"0\" arrow2=\"0\" >\n";
00421             for (int i=0; i<nsides; i++)
00422         {
00423               str += "    <point x=\"" ;
00424               str += QString::number ((x[i] + agLine.offX)/FAKTOR);
00425               str += "\" y=\"";
00426               str += QString::number ((y[i] + agLine.offY)/FAKTOR);
00427               str += "\" />\n";
00428         }
00429 
00430             str += "    <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
00431             str += "     <matrix dx=\"0\" dy=\"0\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
00432             str += "    </gobject>\n";
00433 
00434 
00435 
00436             str += "   </polyline>\n";
00437 
00438 
00439       }
00440           /********************************************************************
00441            * Element TXT - Text                                               *
00442            ********************************************************************/
00443           else if (mystr.startsWith ("TXT AT") )
00444       {
00445             // Define
00446             //applixGraphicsText agText;
00447             applixGraphicsLine agText;
00448 
00449             kdDebug (s_area) << " Habe Text erkannt (keine Werte uebernommen)" << endl;
00450             mystr.remove (0, 7);
00451             sscanf ((const char *) mystr.latin1(), "(%d,%d)",
00452                     &agText.offX, &agText.offY);
00453         kdDebug (s_area) << "  Offset ->   x:" << agText.offX << "  y:" << agText.offY << endl;
00454 
00455 
00456             do
00457         {
00458               // Aktuelle Position bestimmen
00459               pos = in.at ();
00460               // Zeile einlesen
00461               mystr = stream.readLine ();
00462 //checkSubElement()
00463           if      (mystr.startsWith (" RECOLOR ") )
00464           {
00465                 kdDebug (s_area) << "  Recolor  : ";
00466                 mystr.remove (0, 9);
00467                 if      (mystr == "ON")
00468                 {
00469                   kdDebug (s_area) << "On" << endl;
00470                   agText.reColor = true;
00471                 }
00472                 else if (mystr == "OFF")
00473                 {
00474                   kdDebug (s_area) << "Off" << endl;
00475                   agText.reColor = false;
00476                 }
00477                 else
00478                 {
00479                    kdDebug (s_area) << "!!!!!     Whats that <" << mystr << ">" << endl;
00480                 }
00481           }
00482           else if (mystr.startsWith (" .STR") )
00483           {
00484                 kdDebug (s_area) << " Textstring: ";
00485 
00486                 // Zeile einlesen
00487                 agText.str = stream.readLine ();
00488                 agText.str.remove (0, 3);  // delete ront part
00489                 kdDebug (s_area) << agText.str;
00490           }
00491           else if (mystr.startsWith (" THICKNESS ") )
00492           {
00493                 kdDebug (s_area) << "  Thickness: ";
00494                 mystr.remove (0, 11);
00495                 sscanf ((const char *) mystr.latin1(), "%d", &agText.thickNess);
00496                 kdDebug (s_area) <<  agText.thickNess << endl;
00497           }
00498           else if (mystr.startsWith (" PNTS ") )
00499           {
00500                 kdDebug (s_area) << "  Pnts    : ";
00501                 mystr.remove (0, 6);
00502                 sscanf ((const char *) mystr.latin1(), "(%d,%d)(%d,%d)",
00503                         &agText.ptX[0], &agText.ptY[0], &agText.ptX[1], &agText.ptY[1]);
00504                 kdDebug (s_area) << agText.ptX[0] << " " << agText.ptY[0] << " " << agText.ptX[1] << " " << agText.ptY[1];
00505           }
00506 //checkSubElement() ende
00507 
00508         }
00509         while ((mystr[0] != '.') && (mystr[0] != 'E'));
00510 
00511             // An die Position zurueckspringen
00512             in.at (pos);
00513 
00514             // Werte in die Struktur einlagern
00515             str += "   <text ";
00516             str += "x=\"" ;
00517             str += QString::number (agText.offX);
00518             str += "\" y=\"" ;
00519             str += QString::number (agText.offY);
00520             str += "\" >\n";
00521             str += "    <![CDATA[" + agText.str;
00522             str += "]]>\n";
00523             str += "    <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
00524             str += "     <matrix dx=\"119\" dy=\"310\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
00525             str += "    </gobject>\n";
00526             str += "   </text>\n";
00527 
00528       }
00529 
00530           /********************************************************************
00531            * Element rectangle                                                *
00532            ********************************************************************/
00533           else if (mystr.startsWith ("RECT AT"))
00534       {
00535             applixGraphicsRect agRect;
00536 
00537             kdDebug (s_area) << " Habe Rectangle erkannt " << endl;
00538             mystr.remove (0, 8);
00539             rueck = sscanf ((const char *)mystr.latin1(), "(%d,%d)",    &agRect.offX, &agRect.offY);
00540         if (rueck < 1) kdDebug (s_area) <<"Fehler im String <" << mystr.latin1() << ">" << endl;
00541         kdDebug (s_area) << "  Offset ->   x:" << agRect.offX << "  y:" << agRect.offY << endl;
00542 
00543 
00544             do
00545         {
00546               // Akutelle Position bestimmen
00547               pos = in.at ();
00548               // read one line
00549               mystr = stream.readLine ();
00550 
00551 //checkSubElement()
00552               // option RECOLOR
00553           if      (mystr.startsWith (" RECOLOR ") )
00554           {
00555                 kdDebug (s_area) <<("  Recolor : ");
00556                 mystr.remove (0, 9);
00557                 if      (mystr == "ON")
00558                 {  kdDebug (s_area) << "On" << endl;  agRect.reColor = true;}
00559                 else if (mystr == "OFF")
00560                 { kdDebug (s_area) << "Off" << endl;  agRect.reColor = false;}
00561                 else
00562                 {
00563                    kdDebug (s_area) << "!!!!!    Whats that <" << mystr << ">" << endl;
00564                 }
00565           }
00566               // option BACKFILL
00567           else if (mystr.startsWith (" BACKFILL ") )
00568           {
00569                 kdDebug (s_area) <<("  Backfill: ");
00570                 mystr.remove (0, 12);
00571                 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d %d %d>",
00572                         &agRect.bf[0], &agRect.bf[1], &agRect.bf[2],
00573                         &agRect.bf[3], &agRect.bf[4], &agRect.bf[5],
00574                         &agRect.bf[6]);
00575                 kdDebug (s_area) << agRect.bf[0] << " " << agRect.bf[1] << " "  <<
00576                                     agRect.bf[2] << " " << agRect.bf[3] << " "  <<
00577                                     agRect.bf[4] << " " << agRect.bf[5] << " "  <<
00578                                     agRect.bf[6];
00579 
00580           }
00581               // option LINEFILL
00582           else if (mystr.startsWith (" LINEFILL ") )
00583           {
00584                 kdDebug (s_area) << "  Linefill: ";
00585                 mystr.remove (0, 12);
00586                 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d %d %d>",
00587                         &agRect.lf[0], &agRect.lf[1], &agRect.lf[2],
00588                         &agRect.lf[3], &agRect.lf[4], &agRect.lf[5],
00589                         &agRect.lf[6]);
00590                 kdDebug (s_area) << agRect.lf[0] << " " << agRect.lf[1] << " "  <<
00591                                     agRect.lf[2] << " " << agRect.lf[3] << " "  <<
00592                                     agRect.lf[4] << " " << agRect.lf[5] << " "  <<
00593                                     agRect.lf[6];
00594 
00595           }
00596               // option SHADOW
00597           else if (mystr.startsWith (" SHADOW ")  )
00598           {
00599                 kdDebug (s_area) << "  Shadow  : ";
00600                 mystr.remove (0, 12);
00601                 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d>",
00602                         &agRect.sh[0], &agRect.sh[1], &agRect.sh[2],
00603                         &agRect.sh[3], &agRect.sh[4]);
00604                 kdDebug (s_area) << agRect.sh[0] << " " << agRect.sh[1] << " "  <<
00605                                     agRect.sh[2] << " " << agRect.sh[3] << " "  <<
00606                                     agRect.sh[4];
00607           }
00608               // option PARA
00609           else if (mystr.startsWith (" PARA ")  )
00610           {
00611                 kdDebug (s_area) << "  Para    : ";
00612                 mystr.remove (0, 12);
00613                 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d %d %d %d>",
00614                         &agRect.pa[0], &agRect.pa[1], &agRect.pa[2],
00615                         &agRect.pa[3], &agRect.pa[4], &agRect.pa[5],
00616                         &agRect.pa[6], &agRect.pa[7]);
00617                 kdDebug (s_area) << agRect.pa[0] << " " << agRect.pa[1] << " "  <<
00618                                     agRect.pa[2] << " " << agRect.pa[3] << " "  <<
00619                                     agRect.pa[4] << " " << agRect.pa[5] << " "  <<
00620                                     agRect.pa[6] << " " << agRect.pa[7] ;
00621 
00622           }
00623               // option THICKNESS
00624           else if (mystr.startsWith (" THICKNESS ") )
00625           {
00626                 kdDebug (s_area) << "  Thickness: ";
00627                 mystr.remove (0, 11);
00628                 sscanf ((const char *) mystr.latin1(), "%d", &agRect.thickNess);
00629                 kdDebug (s_area) << agRect.thickNess << endl;
00630           }
00631               // option V_SPACE
00632           else if (mystr.startsWith (" V_SPACE ") )
00633           {
00634                 kdDebug (s_area) << "  V_Space : ";
00635                 mystr.remove (0, 9);
00636                 sscanf ((const char *)mystr.latin1(), "(%d %d %d)",
00637                          &agRect.vs[0], &agRect.vs[1], &agRect.vs[2]);
00638                 kdDebug (s_area) << agRect.vs[0] << " " << agRect.vs[1] << " " <<  agRect.vs[2];
00639           }
00640               // option XYRAD
00641           else if (mystr.startsWith (" XYRAD ") )
00642           {
00643                 kdDebug (s_area) << "  XYRad   : ";
00644                 mystr.remove (0, 7);
00645                 sscanf ((const char *)mystr.latin1(), "<%d %d>",
00646                          &agRect.xr[0], &agRect.xr[1]);
00647                 kdDebug (s_area) << agRect.xr[0] << " " << agRect.xr[1];
00648           }
00649               // option PNTS
00650           else if (mystr.startsWith (" PNTS ") )
00651           {
00652                 kdDebug (s_area) << "  Pnts    : ";
00653                 mystr.remove (0, 6);
00654                 sscanf ((const char *)mystr.latin1(), "(%d,%d)(%d,%d)(%d,%d)(%d,%d)(%d,%d)",
00655                         &agRect.ptX[0], &agRect.ptY[0], &agRect.ptX[1], &agRect.ptY[1],
00656                         &agRect.ptX[2], &agRect.ptY[2], &agRect.ptX[3], &agRect.ptY[3],
00657                         &agRect.ptX[4], &agRect.ptY[4]);
00658                 kdDebug (s_area) << agRect.ptX[0] << " " << agRect.ptY[0] << "  " <<
00659                                     agRect.ptX[1] << " " << agRect.ptY[1] << "   " <<
00660                                     agRect.ptX[2] << " " << agRect.ptY[2] << "  " <<
00661                                     agRect.ptX[3] << " " << agRect.ptY[3] << "  " <<
00662                             agRect.ptX[4] << " " << agRect.ptY[4] << endl;
00663           }
00664 
00665 //checkSubElement() ende
00666         }
00667         while ((mystr[0] != '.') && (mystr[0] != 'E'));
00668 
00669             // An die Position zurueckspringen
00670             in.at (pos);
00671 
00672             // Werte in die Struktur einlagern
00673             str += "   <rectangle ";
00674             str += "x=\"" ;
00675             str += QString::number ((agRect.offX)/FAKTOR);
00676             str += "\" y=\"";
00677             str += QString::number ((agRect.offY)/FAKTOR);
00678             str += "\" width=\"" ;
00679             str += QString::number ((agRect.ptX[2])/FAKTOR);
00680             str += "\" height=\"";
00681             str += QString::number ((agRect.ptY[2])/FAKTOR);
00682             str += "\" >\n";
00683             str += "    <polyline arrow1=\"0\" arrow2=\"0\" >\n";
00684 
00685             str += "     <point x=\"" ;
00686             str += QString::number ((agRect.ptX[0] + agRect.offX)/FAKTOR)  ;
00687             str += "\" y=\"" ;
00688             str += QString::number ((agRect.ptY[0] + agRect.offY)/FAKTOR) ;
00689             str += "\" />\n";
00690 
00691             str += "     <point x=\"" ;
00692             str += QString::number ((agRect.ptX[0] + agRect.ptX[2] + agRect.offX)/FAKTOR)  ;
00693             str += "\" y=\"" ;
00694             str += QString::number ((agRect.ptY[0] + agRect.offY)/FAKTOR) ;
00695             str += "\" />\n";
00696 
00697             str += "     <point x=\"" ;
00698             str += QString::number ((agRect.ptX[0] + agRect.ptX[2] + agRect.offX)/FAKTOR)  ;
00699             str += "\" y=\"" ;
00700             str += QString::number ((agRect.ptY[0] + agRect.ptY[2] + agRect.offY)/FAKTOR) ;
00701             str += "\" />\n";
00702 
00703             str += "     <point x=\"" ;
00704             str += QString::number ((agRect.ptX[0] + agRect.offX)/FAKTOR)  ;
00705             str += "\" y=\"" ;
00706             str += QString::number ((agRect.ptY[0] + agRect.ptY[2] + agRect.offY)/FAKTOR) ;
00707             str += "\" />\n";
00708 
00709 
00710             str += "     <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
00711             str += "      <matrix dx=\"0\" dy=\"0\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
00712             str += "     </gobject>\n";
00713             str += "    </polyline>\n";
00714             str += "   </rectangle>\n";
00715 
00716 
00717 
00718 
00719 
00720 
00721       }
00722           /********************************************************************
00723            * Element ELL - Ellipse                                            *
00724            ********************************************************************/
00725           else if (mystr.startsWith ("ELL AT"))
00726       {
00727             applixGraphicsRect agEll;
00728 
00729             kdDebug (s_area) << " Habe ELL erkannt (keine Werte uebernommen " << endl;
00730             mystr.remove (0, 7);
00731             sscanf ((const char *)mystr.latin1(), "(%d,%d)",
00732                     &agEll.offX, &agEll.offY);
00733         kdDebug (s_area) << "  Offset ->   x:" << agEll.offX << "  y:" << agEll.offY << endl;
00734 
00735             do
00736         {
00737               // Aktuelle Position bestimmen
00738               pos = in.at ();
00739               // read one line
00740               mystr = stream.readLine ();
00741 
00742 //checkSubElement()
00743               // option RECOLOR
00744           if      (mystr.startsWith (" RECOLOR ") )
00745           {
00746                 kdDebug (s_area) << "  Recolor: ";
00747                 mystr.remove (0, 9);
00748                 if      (mystr == "ON")
00749                 {
00750                   kdDebug (s_area) << "On" << endl;
00751                   agEll.reColor = true;
00752                 }
00753                 else if (mystr == "OFF")
00754                 {
00755                   kdDebug (s_area) << "Off" << endl;
00756                   agEll.reColor = false;
00757                 }
00758                 else
00759                 {
00760                    kdDebug (s_area) << "!!!!!    Whats that <" << mystr << ">" << endl;
00761                 }
00762           }
00763           else if (mystr.startsWith (" PNTS ") )
00764           {
00765                 kdDebug (s_area) <<("  Pnts   : ");
00766                 mystr.remove (0, 6);
00767         //
00768                 sscanf ((const char *)mystr.latin1(), "(%d,%d)(%d,%d)(%d,%d)(%d,%d)(%d,%d)",
00769                         &agEll.ptX[0], &agEll.ptY[0], &agEll.ptX[1], &agEll.ptY[1],
00770                         &agEll.ptX[2], &agEll.ptY[2], &agEll.ptX[3], &agEll.ptY[3],
00771                         &agEll.ptX[4], &agEll.ptY[4]);
00772                 kdDebug (s_area) << agEll.ptX[0] << " " << agEll.ptY[0] << "  " <<
00773                                     agEll.ptX[1] << " " << agEll.ptY[1] << "   " <<
00774                                     agEll.ptX[2] << " " << agEll.ptY[2] << "  " <<
00775                                     agEll.ptX[3] << " " << agEll.ptY[3] << "  " <<
00776                             agEll.ptX[4] << " " << agEll.ptY[4] << endl;
00777 
00778           }
00779 //checkSubElement() ende
00780         }
00781         while ((mystr[0] != '.') && (mystr[0] != 'E'));
00782 
00783             // An die Position zurueckspringen
00784             in.at (pos);
00785 
00786             // Werte in die Struktur einlagern
00787             // ???
00788 
00789       }
00790           else
00791       {
00792             kdDebug (s_area) << "Unbekannt : " << mystr << endl;
00793       }
00794 
00795     }
00796 
00797 
00798         if (i>step)
00799         {
00800             i=0;
00801             value+=2;
00802             emit sigProgress (value);
00803         }
00804     }
00805     emit sigProgress(100);
00806 
00807     str += "  </layer>\n";
00808     str += " </karbon>\n";
00809 //  str += "</DOC>\n";
00810 
00811     kdDebug (s_area) << "Text " << str.utf8() << endl;
00812 
00813     KoStoreDevice* out= m_chain->storageFile( "root", KoStore::Write );
00814     if (!out)
00815     {
00816         kdError(s_area) << "Unable to open output file!" << endl;
00817         in.close  ();
00818         return KoFilter::StorageCreationError;
00819     }
00820 
00821     QCString cstring = str.utf8();
00822     out->writeBlock ( (const char*)cstring, cstring.size() - 1 );
00823 
00824     in.close  ();
00825     return KoFilter::OK;
00826 }
00827 
00828 #include <applixgraphicimport.moc>
00829 
00830 
00831 
00832 
KDE Home | KDE Accessibility Home | Description of Access Keys