filters

applixgraphicimport.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Enno Bartels <ebartels@nwn.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19#define FAKTOR 39.4 // 1000 dots/inch / 2.54 cm/inch = 394 dots/cm = 39.4 dots/mm
20
21#include <config.h>
22
23#ifdef HAVE_UNISTD_H
24#include <unistd.h>
25#endif
26
27#include <kdebug.h>
28#include <tqfile.h>
29#include <tqtextstream.h>
30#include <tqmessagebox.h>
31#include <KoFilterChain.h>
32#include <kgenericfactory.h>
33#include <math.h>
34
35#include <applixgraphicimport.h>
36
37typedef KGenericFactory<APPLIXGRAPHICImport, KoFilter> APPLIXGRAPHICImportFactory;
38K_EXPORT_COMPONENT_FACTORY( libapplixgraphicimport, APPLIXGRAPHICImportFactory( "kofficefilters" ) )
39
40int s_area = 30517;
41
42/******************************************************************************
43 * class: applixGraphicsLine function: constructor *
44 ******************************************************************************
45 * *
46 * Short description : - Initialize all variables *
47 * *
48 * *
49 ******************************************************************************/
50applixGraphicsLine::applixGraphicsLine()
51{
52 offX = 0;
53 offY = 0;
54 reColor = 0;
55 thickNess = 1; // ??
56
57 for (int i=0; i<5; i++)
58 {
59 ptX[0] = 0;
60 ptY[0] = 0;
61 }
62}
63
64
65
66
67
68/******************************************************************************
69 * class: applixGraphicsRect function: constructor *
70 ******************************************************************************
71 * *
72 * Short description : - Initialize all variables *
73 * *
74 * *
75 ******************************************************************************/
76applixGraphicsRect::applixGraphicsRect() : applixGraphicsLine()
77{
78 for (int i=0; i<7;i++)
79 {
80 bf[i] = 0;
81 lf[i] = 0;
82 }
83
84 for (int i=0; i<5;i++)
85 {
86 sh[i] = 0;
87 }
88
89 for (int i=0; i<8;i++)
90 {
91 pa[i] = 0;
92 }
93
94 for (int i=0; i<3;i++)
95 {
96 vs[i] = 0;
97 }
98
99 for (int i=0; i<2;i++)
100 {
101 xr[i] = 0;
102 }
103
104}
105
106
107
108
109
110/******************************************************************************
111 * class: APPLIXGRAPHICImport function: constructor *
112 ******************************************************************************
113 * *
114 * Short description : constructor *
115 * *
116 * *
117 ******************************************************************************/
118APPLIXGRAPHICImport::APPLIXGRAPHICImport (KoFilter *, const char *, const TQStringList&) :
119 KoFilter ()
120{
121
122}
123
124
125
126/******************************************************************************
127 * class: APPLIXGRAPHICImport function: filter *
128 ******************************************************************************
129 * *
130 * Short description : - Read inputfile, *
131 * - convert it to kontour fileformat and *
132 * - save it *
133 * *
134 * *
135 ******************************************************************************/
136KoFilter::ConversionStatus APPLIXGRAPHICImport::convert( const TQCString& from, const TQCString& to )
137{
138
139 // Check MIME Types
140 if (to!="application/x-karbon" || from!="application/x-applixgraphic")
141 return KoFilter::NotImplemented;
142
143 // Open Inputfile
144 TQFile in (m_chain->inputFile());
145 if (!in.open (IO_ReadOnly) )
146 {
147 kdError(30502) << "Unable to open input file!" << endl;
148 in.close ();
149 return KoFilter::FileNotFound;
150 }
151
152 TQString str;
153
154 // Create karbon header
155 str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
156 str += "<!DOCTYPE karbon>\n";
157 str += " <karbon mime=\"application/x-karbon\" version=\"2\" editor=\"APPLIXGRAPHICS import filter\">\n";
158// str += " <head>\n";
159// str += " <layout width=\"210\" lmargin=\"0\" format=\"a4\" bmargin=\"0\" height=\"297\" rmargin=\"0\" tmargin=\"0\" orientation=\"portrait\"/>\n";
160// str += " <grid dx=\"20\" dy=\"20\" align=\"0\">\n";
161// str += " <helplines align=\"0\"/>\n";
162// str += " </grid>\n";
163// str += " </head>\n";
164 str += " <layer name=\"ag-layer\" visible=\"1\">\n";
165
166 TQTextStream stream(&in);
167 int step = in.size()/50;
168 int value = 0;
169 int i = 0;
170 int picture_rememberer = 0;
171 int pos = 0;
172 int vers[3] = { 0, 0, 0 };
173 int rueck; // Check scanf inputs
174 TQString mystr;
175
176 // Read Headline
177 mystr = stream.readLine ();
178 rueck = sscanf ((const char *) mystr.latin1() ,
179 "*BEGIN GRAPHICS VERSION=%d/%d ENCODING=%dBIT",
180 &vers[0], &vers[1], &vers[2]);
181 kdDebug (s_area) << "Versions info: " << vers[0] << vers[1] << vers[2] << endl;
182
183 // Check the headline
184 if (rueck <= 0)
185 {
186 kdDebug (s_area) << "Header not correkt - May be it is not an applixgraphics file" << endl;
187 kdDebug (s_area) << "Headerline: " << mystr << endl;
188
189 TQMessageBox::critical (0L, "Applixgraphics header problem",
190 TQString ("The Applixgraphics header is not correct. "
191 "May be it is not an applixgraphics file! <BR>"
192 "This is the header line I did read:<BR><B>%1</B>").arg(mystr.latin1()),
193 "Comma");
194
195 // i18n( "What is the separator used in this file ? First line is \n%1" ).arg(firstLine),
196 return KoFilter::StupidError;
197 }
198
199 while (!stream.atEnd ())
200 {
201 ++i;
202
203 // Read one line
204 mystr = stream.readLine ();
205 kdDebug (s_area) << "<<" << mystr << ">>" << endl;
206
207 if (mystr == "PICTURE") picture_rememberer = 1;
208 else if (mystr == "END PICTURE") picture_rememberer = 0;
209
210
211 // Detect a point at the first place of the ascii_linie
212 else if ((mystr[0] == '.') && (picture_rememberer == 1))
213 {
214 // Delete point at the first place of the ascii_linie
215 mystr.remove (0, 1);
216 kdDebug (s_area) << "StartPoint recognized <" << mystr << ">" << endl;
217
218
219 /********************************************************************
220 * Element "LINE" *
221 ********************************************************************/
222 if (mystr.startsWith ("LINE AT") )
223 {
224 // Define
225 applixGraphicsLine agLine;
226
227 //str += agLine.read (int, mystr);
228
229 kdDebug (s_area) << " Linie recognized: " << endl;
230 mystr.remove (0, 8);
231 //mystr.remove (0, 7);
232
233
234 //remove_pos = mystr.find ('(');
235 //mystr.remove (0, remove_pos);
236 //agLine.offX= mystr.toInt();
237
238 //remove_pos = mystr.find (',');
239 //mystr.remove (0, remove_pos);
240 //agLine.offY= mystr.toInt();
241 rueck = sscanf ((const char *) mystr.latin1(), "(%d,%d)",
242 &agLine.offX, &agLine.offY);
243 kdDebug (s_area) << " Offset -> x:" << agLine.offX << " y:" << agLine.offY << endl;
244 if (rueck <= 0)
245 {
246 kdDebug (s_area) << "LINE tag not correkt" << endl;
247 kdDebug (s_area) << "LINE: <" << mystr << ">" << endl;
248 return KoFilter::StupidError;
249 }
250
251 do
252 {
253 // Get acutal position
254 pos = in.at ();
255 // Read one line
256 mystr = stream.readLine ();
257
258 if (mystr.startsWith (" RECOLOR ") )
259 {
260 kdDebug (s_area) << " Recolor ";
261 mystr.remove (0, 9);
262 if (mystr == "ON")
263 {
264 kdDebug (s_area) << "On" << endl;
265 agLine.reColor = true;
266 }
267 else if (mystr == "OFF")
268 {
269 kdDebug (s_area) << "Off" << endl;
270 agLine.reColor = false;
271 }
272 else
273 {
274 kdDebug (s_area) << "!!!!! Unknown RECOLOR item <" << mystr << ">" << endl;
275 }
276 }
277 else if (mystr.startsWith (" THICKNESS ") )
278 {
279 kdDebug (s_area) << " Thickness: ";
280 mystr.remove (0, 11);
281 sscanf ((const char *) mystr.latin1(), "%d", &agLine.thickNess);
282 //
283 kdDebug (s_area) << agLine.thickNess << endl;
284 }
285 else if (mystr.startsWith (" PNTS ") )
286 {
287 kdDebug (s_area) << " Pnts : ";
288 mystr.remove (0, 6);
289 sscanf ((const char *) mystr.latin1(), "(%d,%d)(%d,%d)",
290 &agLine.ptX[0], &agLine.ptY[0], &agLine.ptX[1], &agLine.ptY[1]);
291 kdDebug (s_area) << agLine.ptX[0] << " " << agLine.ptY[0] << " " << agLine.ptX[1] << " " << agLine.ptY[1] << endl;
292 }
293
294 }
295 while ((mystr[0] != '.') && (mystr[0] != 'E'));
296
297 // An die Position zurueckspringen
298 in.at (pos);
299
300 // Werte in die Struktur einlagern
301 str += " <polyline arrow1=\"0\" arrow2=\"0\" >\n";
302// str += " <point x=\"" + agLine.ptX[0] + "\" y=\"" + agLine.ptY[0] + "\" />";
303 str += " <point x=\"" ;
304 str += TQString::number ((agLine.ptX[0] + agLine.offX)/FAKTOR);
305 str += "\" y=\"";
306 str += TQString::number ((agLine.ptY[0] + agLine.offY)/FAKTOR);
307 str += "\" />\n";
308
309// str += " <point x=\"" + agLine.ptX[1] + "\" y=\"" + agLine.ptY[1] + "\" />";
310 str += " <point x=\"";
311 str += TQString::number ((agLine.ptX[1] + agLine.offX)/FAKTOR);
312 str += "\" y=\"";
313 str += TQString::number ((agLine.ptY[1] + agLine.offY)/FAKTOR);
314 str += "\" />\n";
315 str += " <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
316 str += " <matrix dx=\"0\" dy=\"0\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
317 str += " </gobject>\n";
318
319
320
321 str += " </polyline>\n";
322
323
324 }
325 /********************************************************************
326 * Element RPOL Vieleck *
327 ********************************************************************/
328 if (mystr.startsWith ("RPOL AT") )
329 {
330 // Define
331 applixGraphicsLine agLine;
332 int nsides;
333
334 //str += agLine.read (int, mystr);
335
336 kdDebug (s_area) << " RPOL recognized: " << endl;
337 mystr.remove (0, 8);
338
339 rueck = sscanf ((const char *) mystr.latin1(), "(%d,%d)",
340 &agLine.offX, &agLine.offY);
341 kdDebug (s_area) << " Offset -> x:" << agLine.offX << " y:" << agLine.offY << endl;
342 if (rueck <= 0)
343 {
344 kdDebug (s_area) << "RPOL tag not correkt " << endl;
345 kdDebug (s_area) << "RPOL: <" << mystr << ">" << endl;
346 return KoFilter::StupidError;
347 }
348
349 do
350 {
351 // Akutelle Position bestimmen
352 pos = in.at ();
353 // Zeile einlesen
354 mystr = stream.readLine ();
355//checkSubElement (mystr, subelements)
356 if (mystr.startsWith (" RECOLOR ") )
357 {
358 kdDebug (s_area) << " Recolor " ;
359 mystr.remove (0, 9);
360 if (mystr == "ON")
361 {
362 kdDebug (s_area) << "On" << endl;
363 agLine.reColor = true;
364 }
365 else if (mystr == "OFF")
366 {
367 kdDebug (s_area) << "Off" << endl;
368 agLine.reColor = false;
369 }
370 else
371 {
372 kdDebug (s_area) << "!!!!! Whats that <" << mystr << ">" << endl;
373 }
374 }
375 else if (mystr.startsWith (" NSIDES") )
376 {
377 kdDebug (s_area) << " NSIDES: " ;
378 mystr.remove (0, 8);
379 pos = sscanf ((const char *) mystr.latin1(), "%d", &nsides);
380 kdDebug (s_area) << nsides << "(" << pos << ")" << endl;
381 }
382 else if (mystr.startsWith (" PNTS ") )
383 {
384 kdDebug (s_area) << " Pnts : ";
385 mystr.remove (0, 6);
386 sscanf ((const char *) mystr.latin1(), "(%d,%d)(%d,%d)(%d,%d)(%d,%d)(%d,%d)",
387 &agLine.ptX[0], &agLine.ptY[0], &agLine.ptX[1], &agLine.ptY[1],
388 &agLine.ptX[2], &agLine.ptY[2], &agLine.ptX[3], &agLine.ptY[3],
389 &agLine.ptX[4], &agLine.ptY[4]);
390 kdDebug (s_area) << agLine.ptX[0] << " " << agLine.ptY[0] << " " <<
391 agLine.ptX[1] << " " << agLine.ptY[1] << " " <<
392 agLine.ptX[2] << " " << agLine.ptY[2] << " " <<
393 agLine.ptX[3] << " " << agLine.ptY[3] << " " <<
394 agLine.ptX[4] << " " << agLine.ptY[4] << endl;
395 }
396//checkSubElement() ende
397
398 }
399 while ((mystr[0] != '.') && (mystr[0] != 'E'));
400
401
402
403 // An die Position zurueckspringen
404 in.at (pos);
405
406 int a, b;
407 float wink=0.0;
408 int *x = new int[nsides];
409 int *y = new int[nsides];
410 a = agLine.ptX[2] / 2;
411 b = agLine.ptY[2] / 2;
412 for (int i=0; i<nsides; i++)
413 {
414 x[i] = tqRound (a * cos (wink*M_PI/180));
415 y[i] = tqRound (b * sin (wink*M_PI/180));
416 wink += (360/nsides);
417 }
418
419 // Werte in die Struktur einlagern
420 str += " <polyline arrow1=\"0\" arrow2=\"0\" >\n";
421 for (int i=0; i<nsides; i++)
422 {
423 str += " <point x=\"" ;
424 str += TQString::number ((x[i] + agLine.offX)/FAKTOR);
425 str += "\" y=\"";
426 str += TQString::number ((y[i] + agLine.offY)/FAKTOR);
427 str += "\" />\n";
428 }
429
430 str += " <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
431 str += " <matrix dx=\"0\" dy=\"0\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
432 str += " </gobject>\n";
433
434
435
436 str += " </polyline>\n";
437
438
439 }
440 /********************************************************************
441 * Element TXT - Text *
442 ********************************************************************/
443 else if (mystr.startsWith ("TXT AT") )
444 {
445 // Define
446 //applixGraphicsText agText;
447 applixGraphicsLine agText;
448
449 kdDebug (s_area) << " Habe Text erkannt (keine Werte uebernommen)" << endl;
450 mystr.remove (0, 7);
451 sscanf ((const char *) mystr.latin1(), "(%d,%d)",
452 &agText.offX, &agText.offY);
453 kdDebug (s_area) << " Offset -> x:" << agText.offX << " y:" << agText.offY << endl;
454
455
456 do
457 {
458 // Aktuelle Position bestimmen
459 pos = in.at ();
460 // Zeile einlesen
461 mystr = stream.readLine ();
462//checkSubElement()
463 if (mystr.startsWith (" RECOLOR ") )
464 {
465 kdDebug (s_area) << " Recolor : ";
466 mystr.remove (0, 9);
467 if (mystr == "ON")
468 {
469 kdDebug (s_area) << "On" << endl;
470 agText.reColor = true;
471 }
472 else if (mystr == "OFF")
473 {
474 kdDebug (s_area) << "Off" << endl;
475 agText.reColor = false;
476 }
477 else
478 {
479 kdDebug (s_area) << "!!!!! Whats that <" << mystr << ">" << endl;
480 }
481 }
482 else if (mystr.startsWith (" .STR") )
483 {
484 kdDebug (s_area) << " Textstring: ";
485
486 // Zeile einlesen
487 agText.str = stream.readLine ();
488 agText.str.remove (0, 3); // delete ront part
489 kdDebug (s_area) << agText.str;
490 }
491 else if (mystr.startsWith (" THICKNESS ") )
492 {
493 kdDebug (s_area) << " Thickness: ";
494 mystr.remove (0, 11);
495 sscanf ((const char *) mystr.latin1(), "%d", &agText.thickNess);
496 kdDebug (s_area) << agText.thickNess << endl;
497 }
498 else if (mystr.startsWith (" PNTS ") )
499 {
500 kdDebug (s_area) << " Pnts : ";
501 mystr.remove (0, 6);
502 sscanf ((const char *) mystr.latin1(), "(%d,%d)(%d,%d)",
503 &agText.ptX[0], &agText.ptY[0], &agText.ptX[1], &agText.ptY[1]);
504 kdDebug (s_area) << agText.ptX[0] << " " << agText.ptY[0] << " " << agText.ptX[1] << " " << agText.ptY[1];
505 }
506//checkSubElement() ende
507
508 }
509 while ((mystr[0] != '.') && (mystr[0] != 'E'));
510
511 // An die Position zurueckspringen
512 in.at (pos);
513
514 // Werte in die Struktur einlagern
515 str += " <text ";
516 str += "x=\"" ;
517 str += TQString::number (agText.offX);
518 str += "\" y=\"" ;
519 str += TQString::number (agText.offY);
520 str += "\" >\n";
521 str += " <![CDATA[" + agText.str;
522 str += "]]>\n";
523 str += " <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
524 str += " <matrix dx=\"119\" dy=\"310\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
525 str += " </gobject>\n";
526 str += " </text>\n";
527
528 }
529
530 /********************************************************************
531 * Element rectangle *
532 ********************************************************************/
533 else if (mystr.startsWith ("RECT AT"))
534 {
535 applixGraphicsRect agRect;
536
537 kdDebug (s_area) << " Habe Rectangle erkannt " << endl;
538 mystr.remove (0, 8);
539 rueck = sscanf ((const char *)mystr.latin1(), "(%d,%d)", &agRect.offX, &agRect.offY);
540 if (rueck < 1) kdDebug (s_area) <<"Fehler im String <" << mystr.latin1() << ">" << endl;
541 kdDebug (s_area) << " Offset -> x:" << agRect.offX << " y:" << agRect.offY << endl;
542
543
544 do
545 {
546 // Akutelle Position bestimmen
547 pos = in.at ();
548 // read one line
549 mystr = stream.readLine ();
550
551//checkSubElement()
552 // option RECOLOR
553 if (mystr.startsWith (" RECOLOR ") )
554 {
555 kdDebug (s_area) <<(" Recolor : ");
556 mystr.remove (0, 9);
557 if (mystr == "ON")
558 { kdDebug (s_area) << "On" << endl; agRect.reColor = true;}
559 else if (mystr == "OFF")
560 { kdDebug (s_area) << "Off" << endl; agRect.reColor = false;}
561 else
562 {
563 kdDebug (s_area) << "!!!!! Whats that <" << mystr << ">" << endl;
564 }
565 }
566 // option BACKFILL
567 else if (mystr.startsWith (" BACKFILL ") )
568 {
569 kdDebug (s_area) <<(" Backfill: ");
570 mystr.remove (0, 12);
571 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d %d %d>",
572 &agRect.bf[0], &agRect.bf[1], &agRect.bf[2],
573 &agRect.bf[3], &agRect.bf[4], &agRect.bf[5],
574 &agRect.bf[6]);
575 kdDebug (s_area) << agRect.bf[0] << " " << agRect.bf[1] << " " <<
576 agRect.bf[2] << " " << agRect.bf[3] << " " <<
577 agRect.bf[4] << " " << agRect.bf[5] << " " <<
578 agRect.bf[6];
579
580 }
581 // option LINEFILL
582 else if (mystr.startsWith (" LINEFILL ") )
583 {
584 kdDebug (s_area) << " Linefill: ";
585 mystr.remove (0, 12);
586 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d %d %d>",
587 &agRect.lf[0], &agRect.lf[1], &agRect.lf[2],
588 &agRect.lf[3], &agRect.lf[4], &agRect.lf[5],
589 &agRect.lf[6]);
590 kdDebug (s_area) << agRect.lf[0] << " " << agRect.lf[1] << " " <<
591 agRect.lf[2] << " " << agRect.lf[3] << " " <<
592 agRect.lf[4] << " " << agRect.lf[5] << " " <<
593 agRect.lf[6];
594
595 }
596 // option SHADOW
597 else if (mystr.startsWith (" SHADOW ") )
598 {
599 kdDebug (s_area) << " Shadow : ";
600 mystr.remove (0, 12);
601 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d>",
602 &agRect.sh[0], &agRect.sh[1], &agRect.sh[2],
603 &agRect.sh[3], &agRect.sh[4]);
604 kdDebug (s_area) << agRect.sh[0] << " " << agRect.sh[1] << " " <<
605 agRect.sh[2] << " " << agRect.sh[3] << " " <<
606 agRect.sh[4];
607 }
608 // option PARA
609 else if (mystr.startsWith (" PARA ") )
610 {
611 kdDebug (s_area) << " Para : ";
612 mystr.remove (0, 12);
613 sscanf ((const char *)mystr.latin1(), "<%d %d %d %d %d %d %d %d>",
614 &agRect.pa[0], &agRect.pa[1], &agRect.pa[2],
615 &agRect.pa[3], &agRect.pa[4], &agRect.pa[5],
616 &agRect.pa[6], &agRect.pa[7]);
617 kdDebug (s_area) << agRect.pa[0] << " " << agRect.pa[1] << " " <<
618 agRect.pa[2] << " " << agRect.pa[3] << " " <<
619 agRect.pa[4] << " " << agRect.pa[5] << " " <<
620 agRect.pa[6] << " " << agRect.pa[7] ;
621
622 }
623 // option THICKNESS
624 else if (mystr.startsWith (" THICKNESS ") )
625 {
626 kdDebug (s_area) << " Thickness: ";
627 mystr.remove (0, 11);
628 sscanf ((const char *) mystr.latin1(), "%d", &agRect.thickNess);
629 kdDebug (s_area) << agRect.thickNess << endl;
630 }
631 // option V_SPACE
632 else if (mystr.startsWith (" V_SPACE ") )
633 {
634 kdDebug (s_area) << " V_Space : ";
635 mystr.remove (0, 9);
636 sscanf ((const char *)mystr.latin1(), "(%d %d %d)",
637 &agRect.vs[0], &agRect.vs[1], &agRect.vs[2]);
638 kdDebug (s_area) << agRect.vs[0] << " " << agRect.vs[1] << " " << agRect.vs[2];
639 }
640 // option XYRAD
641 else if (mystr.startsWith (" XYRAD ") )
642 {
643 kdDebug (s_area) << " XYRad : ";
644 mystr.remove (0, 7);
645 sscanf ((const char *)mystr.latin1(), "<%d %d>",
646 &agRect.xr[0], &agRect.xr[1]);
647 kdDebug (s_area) << agRect.xr[0] << " " << agRect.xr[1];
648 }
649 // option PNTS
650 else if (mystr.startsWith (" PNTS ") )
651 {
652 kdDebug (s_area) << " Pnts : ";
653 mystr.remove (0, 6);
654 sscanf ((const char *)mystr.latin1(), "(%d,%d)(%d,%d)(%d,%d)(%d,%d)(%d,%d)",
655 &agRect.ptX[0], &agRect.ptY[0], &agRect.ptX[1], &agRect.ptY[1],
656 &agRect.ptX[2], &agRect.ptY[2], &agRect.ptX[3], &agRect.ptY[3],
657 &agRect.ptX[4], &agRect.ptY[4]);
658 kdDebug (s_area) << agRect.ptX[0] << " " << agRect.ptY[0] << " " <<
659 agRect.ptX[1] << " " << agRect.ptY[1] << " " <<
660 agRect.ptX[2] << " " << agRect.ptY[2] << " " <<
661 agRect.ptX[3] << " " << agRect.ptY[3] << " " <<
662 agRect.ptX[4] << " " << agRect.ptY[4] << endl;
663 }
664
665//checkSubElement() ende
666 }
667 while ((mystr[0] != '.') && (mystr[0] != 'E'));
668
669 // An die Position zurueckspringen
670 in.at (pos);
671
672 // Werte in die Struktur einlagern
673 str += " <rectangle ";
674 str += "x=\"" ;
675 str += TQString::number ((agRect.offX)/FAKTOR);
676 str += "\" y=\"";
677 str += TQString::number ((agRect.offY)/FAKTOR);
678 str += "\" width=\"" ;
679 str += TQString::number ((agRect.ptX[2])/FAKTOR);
680 str += "\" height=\"";
681 str += TQString::number ((agRect.ptY[2])/FAKTOR);
682 str += "\" >\n";
683 str += " <polyline arrow1=\"0\" arrow2=\"0\" >\n";
684
685 str += " <point x=\"" ;
686 str += TQString::number ((agRect.ptX[0] + agRect.offX)/FAKTOR) ;
687 str += "\" y=\"" ;
688 str += TQString::number ((agRect.ptY[0] + agRect.offY)/FAKTOR) ;
689 str += "\" />\n";
690
691 str += " <point x=\"" ;
692 str += TQString::number ((agRect.ptX[0] + agRect.ptX[2] + agRect.offX)/FAKTOR) ;
693 str += "\" y=\"" ;
694 str += TQString::number ((agRect.ptY[0] + agRect.offY)/FAKTOR) ;
695 str += "\" />\n";
696
697 str += " <point x=\"" ;
698 str += TQString::number ((agRect.ptX[0] + agRect.ptX[2] + agRect.offX)/FAKTOR) ;
699 str += "\" y=\"" ;
700 str += TQString::number ((agRect.ptY[0] + agRect.ptY[2] + agRect.offY)/FAKTOR) ;
701 str += "\" />\n";
702
703 str += " <point x=\"" ;
704 str += TQString::number ((agRect.ptX[0] + agRect.offX)/FAKTOR) ;
705 str += "\" y=\"" ;
706 str += TQString::number ((agRect.ptY[0] + agRect.ptY[2] + agRect.offY)/FAKTOR) ;
707 str += "\" />\n";
708
709
710 str += " <gobject fillstyle=\"0\" linewidth=\"1\" strokecolor=\"#000000\" strokestyle=\"1\" >\n";
711 str += " <matrix dx=\"0\" dy=\"0\" m21=\"0\" m22=\"1\" m11=\"1\" m12=\"0\" />\n";
712 str += " </gobject>\n";
713 str += " </polyline>\n";
714 str += " </rectangle>\n";
715
716
717
718
719
720
721 }
722 /********************************************************************
723 * Element ELL - Ellipse *
724 ********************************************************************/
725 else if (mystr.startsWith ("ELL AT"))
726 {
727 applixGraphicsRect agEll;
728
729 kdDebug (s_area) << " Habe ELL erkannt (keine Werte uebernommen " << endl;
730 mystr.remove (0, 7);
731 sscanf ((const char *)mystr.latin1(), "(%d,%d)",
732 &agEll.offX, &agEll.offY);
733 kdDebug (s_area) << " Offset -> x:" << agEll.offX << " y:" << agEll.offY << endl;
734
735 do
736 {
737 // Aktuelle Position bestimmen
738 pos = in.at ();
739 // read one line
740 mystr = stream.readLine ();
741
742//checkSubElement()
743 // option RECOLOR
744 if (mystr.startsWith (" RECOLOR ") )
745 {
746 kdDebug (s_area) << " Recolor: ";
747 mystr.remove (0, 9);
748 if (mystr == "ON")
749 {
750 kdDebug (s_area) << "On" << endl;
751 agEll.reColor = true;
752 }
753 else if (mystr == "OFF")
754 {
755 kdDebug (s_area) << "Off" << endl;
756 agEll.reColor = false;
757 }
758 else
759 {
760 kdDebug (s_area) << "!!!!! Whats that <" << mystr << ">" << endl;
761 }
762 }
763 else if (mystr.startsWith (" PNTS ") )
764 {
765 kdDebug (s_area) <<(" Pnts : ");
766 mystr.remove (0, 6);
767 //
768 sscanf ((const char *)mystr.latin1(), "(%d,%d)(%d,%d)(%d,%d)(%d,%d)(%d,%d)",
769 &agEll.ptX[0], &agEll.ptY[0], &agEll.ptX[1], &agEll.ptY[1],
770 &agEll.ptX[2], &agEll.ptY[2], &agEll.ptX[3], &agEll.ptY[3],
771 &agEll.ptX[4], &agEll.ptY[4]);
772 kdDebug (s_area) << agEll.ptX[0] << " " << agEll.ptY[0] << " " <<
773 agEll.ptX[1] << " " << agEll.ptY[1] << " " <<
774 agEll.ptX[2] << " " << agEll.ptY[2] << " " <<
775 agEll.ptX[3] << " " << agEll.ptY[3] << " " <<
776 agEll.ptX[4] << " " << agEll.ptY[4] << endl;
777
778 }
779//checkSubElement() ende
780 }
781 while ((mystr[0] != '.') && (mystr[0] != 'E'));
782
783 // An die Position zurueckspringen
784 in.at (pos);
785
786 // Werte in die Struktur einlagern
787 // ???
788
789 }
790 else
791 {
792 kdDebug (s_area) << "Unbekannt : " << mystr << endl;
793 }
794
795 }
796
797
798 if (i>step)
799 {
800 i=0;
801 value+=2;
802 emit sigProgress (value);
803 }
804 }
805 emit sigProgress(100);
806
807 str += " </layer>\n";
808 str += " </karbon>\n";
809// str += "</DOC>\n";
810
811 kdDebug (s_area) << "Text " << str.utf8() << endl;
812
813 KoStoreDevice* out= m_chain->storageFile( "root", KoStore::Write );
814 if (!out)
815 {
816 kdError(s_area) << "Unable to open output file!" << endl;
817 in.close ();
818 return KoFilter::StorageCreationError;
819 }
820
821 TQCString cstring = str.utf8();
822 out->writeBlock ( (const char*)cstring, cstring.size() - 1 );
823
824 in.close ();
825 return KoFilter::OK;
826}
827
828#include <applixgraphicimport.moc>
829
830
831
832