summaryrefslogtreecommitdiff
authorerik <erik>2007-01-19 01:12:38 (UTC)
committer erik <erik>2007-01-19 01:12:38 (UTC)
commit1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7 (patch) (unidiff)
treeaf4a12bc46e25853386dc53868b869e1bf05d863
parent2b45dc71e79a3eb7d4e8553273c9bc4f4282d50a (diff)
downloadopie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.zip
opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.gz
opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.bz2
Every single file in this commit had a memory leak where a resource is
allocated in the constructor but not de-allocated in the destructor. This commit fixes that.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp32
-rw-r--r--inputmethods/dasher/PPMLanguageModel.cpp3
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp18
-rw-r--r--noncore/apps/opie-reader/Bkmks.h7
-rw-r--r--noncore/apps/opie-reader/StyleConsts.cpp7
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h8
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp7
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h2
9 files changed, 57 insertions, 32 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index 1db34d2..30ff49d 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -36,87 +36,87 @@
36 Since the operations are called by a specific emulation decoder, one may 36 Since the operations are called by a specific emulation decoder, one may
37 collect their different operations here. 37 collect their different operations here.
38 38
39 The state manipulated by the operations is mainly kept in `image', though 39 The state manipulated by the operations is mainly kept in `image', though
40 it is a little more complex bejond this. See the header file of the class. 40 it is a little more complex bejond this. See the header file of the class.
41 41
42 \sa TEWidget \sa VT102Emulation 42 \sa TEWidget \sa VT102Emulation
43*/ 43*/
44 44
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <unistd.h> 47#include <unistd.h>
48// #include <kdebug.h> 48// #include <kdebug.h>
49 49
50#include <assert.h> 50#include <assert.h>
51#include <string.h> 51#include <string.h>
52#include <ctype.h> 52#include <ctype.h>
53 53
54#include <qpe/config.h> 54#include <qpe/config.h>
55#include "TEScreen.h" 55#include "TEScreen.h"
56 56
57#define HERE printf("%s(%d): here\n",__FILE__,__LINE__) 57#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
58 58
59//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. 59//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
60//FIXME: see if we can get this from terminfo. 60//FIXME: see if we can get this from terminfo.
61#define BS_CLEARS FALSE 61#define BS_CLEARS FALSE
62 62
63#define loc(X,Y) ((Y) * columns + (X)) 63#define loc(X,Y) ((Y) * columns + (X))
64 64
65/*! creates a `TEScreen' of `lines' lines and `columns' columns. 65/*! creates a `TEScreen' of `lines' lines and `columns' columns.
66*/ 66*/
67 67
68TEScreen::TEScreen(int lines, int columns) 68TEScreen::TEScreen(int _lines, int _columns) :
69 lines(_lines),
70 columns(_columns),
71 tabstops(0),
72 histCursor(0),
73 horzCursor(0)
69{ 74{
70 this->lines = lines;
71 this->columns = columns;
72// odebug << "Columns " << columns << "" << oendl; 75// odebug << "Columns " << columns << "" << oendl;
73 76
74 image = (ca*) malloc(lines*columns*sizeof(ca)); 77 image = new ca[lines*columns];
75 tabstops = NULL; initTabStops(); 78 initTabStops();
76
77 histCursor = 0;
78 horzCursor = 0;
79 79
80 clearSelection(); 80 clearSelection();
81 reset(); 81 reset();
82} 82}
83 83
84/*! Destructor 84/*! Destructor
85*/ 85*/
86 86
87TEScreen::~TEScreen() 87TEScreen::~TEScreen()
88{ 88{
89 free(image); 89 delete [] image;
90 if (tabstops) free(tabstops); 90 delete [] tabstops;
91} 91}
92 92
93/* ------------------------------------------------------------------------- */ 93/* ------------------------------------------------------------------------- */
94/* */ 94/* */
95/* Normalized Screen Operations */ 95/* Normalized Screen Operations */
96/* */ 96/* */
97/* ------------------------------------------------------------------------- */ 97/* ------------------------------------------------------------------------- */
98 98
99// Cursor Setting -------------------------------------------------------------- 99// Cursor Setting --------------------------------------------------------------
100 100
101/*! \section Cursor 101/*! \section Cursor
102 102
103 The `cursor' is a location within the screen that is implicitely used in 103 The `cursor' is a location within the screen that is implicitely used in
104 many operations. The operations within this section allow to manipulate 104 many operations. The operations within this section allow to manipulate
105 the cursor explicitly and to obtain it's value. 105 the cursor explicitly and to obtain it's value.
106 106
107 The position of the cursor is guarantied to be between (including) 0 and 107 The position of the cursor is guarantied to be between (including) 0 and
108 `columns-1' and `lines-1'. 108 `columns-1' and `lines-1'.
109*/ 109*/
110 110
111/*! 111/*!
112 Move the cursor up. 112 Move the cursor up.
113 113
114 The cursor will not be moved beyond the top margin. 114 The cursor will not be moved beyond the top margin.
115*/ 115*/
116 116
117void TEScreen::cursorUp(int n) 117void TEScreen::cursorUp(int n)
118//=CUU 118//=CUU
119{ 119{
120 if (n == 0) n = 1; // Default 120 if (n == 0) n = 1; // Default
121 int stop = cuY < tmargin ? 0 : tmargin; 121 int stop = cuY < tmargin ? 0 : tmargin;
122 cuX = QMIN(columns-1,cuX); // nowrap! 122 cuX = QMIN(columns-1,cuX); // nowrap!
@@ -367,87 +367,87 @@ void TEScreen::restoreCursor()
367 cu_fg = sa_cu_fg; 367 cu_fg = sa_cu_fg;
368 cu_bg = sa_cu_bg; 368 cu_bg = sa_cu_bg;
369 effectiveRendition(); 369 effectiveRendition();
370} 370}
371 371
372/* ------------------------------------------------------------------------- */ 372/* ------------------------------------------------------------------------- */
373/* */ 373/* */
374/* Screen Operations */ 374/* Screen Operations */
375/* */ 375/* */
376/* ------------------------------------------------------------------------- */ 376/* ------------------------------------------------------------------------- */
377 377
378/*! Assing a new size to the screen. 378/*! Assing a new size to the screen.
379 379
380 The topmost left position is maintained, while lower lines 380 The topmost left position is maintained, while lower lines
381 or right hand side columns might be removed or filled with 381 or right hand side columns might be removed or filled with
382 spaces to fit the new size. 382 spaces to fit the new size.
383 383
384 The region setting is reset to the whole screen and the 384 The region setting is reset to the whole screen and the
385 tab positions reinitialized. 385 tab positions reinitialized.
386*/ 386*/
387 387
388void TEScreen::resizeImage(int new_lines, int new_columns) 388void TEScreen::resizeImage(int new_lines, int new_columns)
389{ 389{
390 if (cuY > new_lines-1) { 390 if (cuY > new_lines-1) {
391// attempt to preserve focus and lines 391// attempt to preserve focus and lines
392 bmargin = lines-1; //FIXME: margin lost 392 bmargin = lines-1; //FIXME: margin lost
393 for (int i = 0; i < cuY-(new_lines-1); i++) { 393 for (int i = 0; i < cuY-(new_lines-1); i++) {
394 addHistLine(); scrollUp(horzCursor,1); 394 addHistLine(); scrollUp(horzCursor,1);
395 } 395 }
396 } 396 }
397 397
398 // make new image 398 // make new image
399 ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); 399 ca* newimg = new ca[new_lines * new_columns];
400 400
401 clearSelection(); 401 clearSelection();
402 402
403 // clear new image 403 // clear new image
404 for (int y = 0; y < new_lines; y++) 404 for (int y = 0; y < new_lines; y++)
405 for (int x = 0; x < new_columns; x++) { 405 for (int x = 0; x < new_columns; x++) {
406 newimg[y*new_columns+x].c = ' '; 406 newimg[y*new_columns+x].c = ' ';
407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; 407 newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR;
408 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; 408 newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
409 newimg[y*new_columns+x].r = DEFAULT_RENDITION; 409 newimg[y*new_columns+x].r = DEFAULT_RENDITION;
410 } 410 }
411 int cpy_lines = QMIN(new_lines, lines); 411 int cpy_lines = QMIN(new_lines, lines);
412 int cpy_columns = QMIN(new_columns,columns); 412 int cpy_columns = QMIN(new_columns,columns);
413 // copy to new image 413 // copy to new image
414 for (int y = 0; y < cpy_lines; y++) 414 for (int y = 0; y < cpy_lines; y++)
415 for (int x = 0; x < cpy_columns; x++) { 415 for (int x = 0; x < cpy_columns; x++) {
416 newimg[y*new_columns+x].c = image[loc(x,y)].c; 416 newimg[y*new_columns+x].c = image[loc(x,y)].c;
417 newimg[y*new_columns+x].f = image[loc(x,y)].f; 417 newimg[y*new_columns+x].f = image[loc(x,y)].f;
418 newimg[y*new_columns+x].b = image[loc(x,y)].b; 418 newimg[y*new_columns+x].b = image[loc(x,y)].b;
419 newimg[y*new_columns+x].r = image[loc(x,y)].r; 419 newimg[y*new_columns+x].r = image[loc(x,y)].r;
420 } 420 }
421 free(image); 421 delete [] image;
422 image = newimg; 422 image = newimg;
423 lines = new_lines; 423 lines = new_lines;
424 columns = new_columns; 424 columns = new_columns;
425 cuX = QMIN(cuX,columns-1); 425 cuX = QMIN(cuX,columns-1);
426 cuY = QMIN(cuY,lines-1); 426 cuY = QMIN(cuY,lines-1);
427 427
428 // FIXME: try to keep values, evtl. 428 // FIXME: try to keep values, evtl.
429 tmargin=0; 429 tmargin=0;
430 bmargin=lines-1; 430 bmargin=lines-1;
431 initTabStops(); 431 initTabStops();
432 clearSelection(); 432 clearSelection();
433} 433}
434 434
435/* 435/*
436 Clarifying rendition here and in TEWidget. 436 Clarifying rendition here and in TEWidget.
437 437
438 currently, TEWidget's color table is 438 currently, TEWidget's color table is
439 0 1 2 .. 9 10 .. 17 439 0 1 2 .. 9 10 .. 17
440 dft_fg, dft_bg, dim 0..7, intensive 0..7 440 dft_fg, dft_bg, dim 0..7, intensive 0..7
441 441
442 cu_fg, cu_bg contain values 0..8; 442 cu_fg, cu_bg contain values 0..8;
443 - 0 = default color 443 - 0 = default color
444 - 1..8 = ansi specified color 444 - 1..8 = ansi specified color
445 445
446 re_fg, re_bg contain values 0..17 446 re_fg, re_bg contain values 0..17
447 due to the TEWidget's color table 447 due to the TEWidget's color table
448 448
449 rendition attributes are 449 rendition attributes are
450 450
451 attr widget screen 451 attr widget screen
452 -------------- ------ ------ 452 -------------- ------ ------
453 RE_UNDERLINE XX XX affects foreground only 453 RE_UNDERLINE XX XX affects foreground only
@@ -478,65 +478,65 @@ void TEScreen::effectiveRendition()
478 if (cu_re & RE_REVERSE) 478 if (cu_re & RE_REVERSE)
479 { 479 {
480 ef_fg = cu_bg; 480 ef_fg = cu_bg;
481 ef_bg = cu_fg; 481 ef_bg = cu_fg;
482 } 482 }
483 else 483 else
484 { 484 {
485 ef_fg = cu_fg; 485 ef_fg = cu_fg;
486 ef_bg = cu_bg; 486 ef_bg = cu_bg;
487 } 487 }
488 if (cu_re & RE_BOLD) 488 if (cu_re & RE_BOLD)
489 { 489 {
490 if (ef_fg < BASE_COLORS) 490 if (ef_fg < BASE_COLORS)
491 ef_fg += BASE_COLORS; 491 ef_fg += BASE_COLORS;
492 else 492 else
493 ef_fg -= BASE_COLORS; 493 ef_fg -= BASE_COLORS;
494 } 494 }
495} 495}
496 496
497/*! 497/*!
498 returns the image. 498 returns the image.
499 499
500 Get the size of the image by \sa getLines and \sa getColumns. 500 Get the size of the image by \sa getLines and \sa getColumns.
501 501
502 NOTE that the image returned by this function must later be 502 NOTE that the image returned by this function must later be
503 freed. 503 freed.
504 504
505*/ 505*/
506 506
507ca* TEScreen::getCookedImage() 507ca* TEScreen::getCookedImage()
508{ 508{
509 int x,y; 509 int x,y;
510 ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); 510 ca* merged = new ca[lines*columns];
511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); 511 ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION);
512 512
513 if (histCursor > hist.getLines()) { 513 if (histCursor > hist.getLines()) {
514 histCursor = hist.getLines(); 514 histCursor = hist.getLines();
515 } 515 }
516 516
517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) 517 for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++)
518 { 518 {
519 int len = QMIN(columns,hist.getLineLen(y+histCursor)); 519 int len = QMIN(columns,hist.getLineLen(y+histCursor));
520 int yp = y*columns; 520 int yp = y*columns;
521 int yq = (y+histCursor)*columns; 521 int yq = (y+histCursor)*columns;
522 522
523 hist.getCells(y+histCursor,0,len,merged+yp); 523 hist.getCells(y+histCursor,0,len,merged+yp);
524 for (x = len; x < columns; x++) merged[yp+x] = dft; 524 for (x = len; x < columns; x++) merged[yp+x] = dft;
525 for (x = 0; x < columns; x++) 525 for (x = 0; x < columns; x++)
526 { int p=x + yp; int q=x + yq; 526 { int p=x + yp; int q=x + yq;
527 if ( ( q >= sel_TL ) && ( q <= sel_BR ) ) 527 if ( ( q >= sel_TL ) && ( q <= sel_BR ) )
528 reverseRendition(&merged[p]); // for selection 528 reverseRendition(&merged[p]); // for selection
529 } 529 }
530 } 530 }
531 if (lines >= hist.getLines()-histCursor) 531 if (lines >= hist.getLines()-histCursor)
532 { 532 {
533 for (y = (hist.getLines()-histCursor); y < lines ; y++) 533 for (y = (hist.getLines()-histCursor); y < lines ; y++)
534 { 534 {
535 int yp = y*columns; 535 int yp = y*columns;
536 int yq = (y+histCursor)*columns; 536 int yq = (y+histCursor)*columns;
537 int yr = (y-hist.getLines()+histCursor)*columns; 537 int yr = (y-hist.getLines()+histCursor)*columns;
538 for (x = 0; x < columns; x++) 538 for (x = 0; x < columns; x++)
539 { int p = x + yp; int q = x + yq; int r = x + yr; 539 { int p = x + yp; int q = x + yq; int r = x + yr;
540 merged[p] = image[r]; 540 merged[p] = image[r];
541 if ( q >= sel_TL && q <= sel_BR ) 541 if ( q >= sel_TL && q <= sel_BR )
542 reverseRendition(&merged[p]); // for selection 542 reverseRendition(&merged[p]); // for selection
@@ -594,66 +594,68 @@ void TEScreen::clear()
594 594
595/*! Moves the cursor left one column. 595/*! Moves the cursor left one column.
596*/ 596*/
597 597
598void TEScreen::BackSpace() 598void TEScreen::BackSpace()
599{ 599{
600 cuX = QMAX(0,cuX-1); 600 cuX = QMAX(0,cuX-1);
601 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; 601 if (BS_CLEARS) image[loc(cuX,cuY)].c = ' ';
602} 602}
603 603
604/*! 604/*!
605*/ 605*/
606 606
607void TEScreen::Tabulate() 607void TEScreen::Tabulate()
608{ 608{
609 // note that TAB is a format effector (does not write ' '); 609 // note that TAB is a format effector (does not write ' ');
610 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1); 610 cursorRight(1); while(cuX < columns-1 && !tabstops[cuX]) cursorRight(1);
611} 611}
612 612
613void TEScreen::clearTabStops() 613void TEScreen::clearTabStops()
614{ 614{
615 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; 615 for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE;
616} 616}
617 617
618void TEScreen::changeTabStop(bool set) 618void TEScreen::changeTabStop(bool set)
619{ 619{
620 if (cuX >= columns) return; 620 if (cuX >= columns) return;
621 tabstops[cuX] = set; 621 tabstops[cuX] = set;
622} 622}
623 623
624void TEScreen::initTabStops() 624void TEScreen::initTabStops()
625{ 625{
626 if (tabstops) free(tabstops); 626 if (tabstops)
627 tabstops = (bool*)malloc(columns*sizeof(bool)); 627 delete [] tabstops;
628
629 tabstops = new bool[columns];
628 // Arrg! The 1st tabstop has to be one longer than the other. 630 // Arrg! The 1st tabstop has to be one longer than the other.
629 // i.e. the kids start counting from 0 instead of 1. 631 // i.e. the kids start counting from 0 instead of 1.
630 // Other programs might behave correctly. Be aware. 632 // Other programs might behave correctly. Be aware.
631 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); 633 for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0);
632} 634}
633 635
634/*! 636/*!
635 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) 637 This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine)
636 depending on the NewLine Mode (LNM). This mode also 638 depending on the NewLine Mode (LNM). This mode also
637 affects the key sequence returned for newline ([CR]LF). 639 affects the key sequence returned for newline ([CR]LF).
638*/ 640*/
639 641
640void TEScreen::NewLine() 642void TEScreen::NewLine()
641{ 643{
642 if (getMode(MODE_NewLine)) Return(); 644 if (getMode(MODE_NewLine)) Return();
643 index(); 645 index();
644} 646}
645 647
646/*! put `c' literally onto the screen at the current cursor position. 648/*! put `c' literally onto the screen at the current cursor position.
647 649
648 VT100 uses the convention to produce an automatic newline (am) 650 VT100 uses the convention to produce an automatic newline (am)
649 with the *first* character that would fall onto the next line (xenl). 651 with the *first* character that would fall onto the next line (xenl).
650*/ 652*/
651 653
652void TEScreen::checkSelection(int from, int to) 654void TEScreen::checkSelection(int from, int to)
653{ 655{
654 if (sel_begin == -1) return; 656 if (sel_begin == -1) return;
655 int scr_TL = loc(0, hist.getLines()); 657 int scr_TL = loc(0, hist.getLines());
656 //Clear entire selection if it overlaps region [from, to] 658 //Clear entire selection if it overlaps region [from, to]
657 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) ) 659 if ( (sel_BR > (from+scr_TL) )&&(sel_TL < (to+scr_TL)) )
658 { 660 {
659 clearSelection(); 661 clearSelection();
diff --git a/inputmethods/dasher/PPMLanguageModel.cpp b/inputmethods/dasher/PPMLanguageModel.cpp
index 137b07f..d767d16 100644
--- a/inputmethods/dasher/PPMLanguageModel.cpp
+++ b/inputmethods/dasher/PPMLanguageModel.cpp
@@ -30,73 +30,74 @@ CPPMLanguageModel::CPPMnode *CPPMLanguageModel::CPPMnode::find_symbol(int sym)
30 found=found->next; 30 found=found->next;
31 } 31 }
32 return 0; 32 return 0;
33} 33}
34 34
35 35
36CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update) 36CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update)
37{ 37{
38 CPPMnode *born,*search; 38 CPPMnode *born,*search;
39 search=find_symbol(sym); 39 search=find_symbol(sym);
40 if (!search) { 40 if (!search) {
41 born = new CPPMnode(sym); 41 born = new CPPMnode(sym);
42 born->next=child; 42 born->next=child;
43 child=born; 43 child=born;
44 // node->count=1; 44 // node->count=1;
45 return born; 45 return born;
46 } else { 46 } else {
47 if (*update) { // perform update exclusions 47 if (*update) { // perform update exclusions
48 search->count++; 48 search->count++;
49 *update=0; 49 *update=0;
50 } 50 }
51 return search; 51 return search;
52 } 52 }
53 53
54} 54}
55 55
56 56
57///////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////
58// CPPMLanguageModel defs 58// CPPMLanguageModel defs
59///////////////////////////////////////////////////////////////////// 59/////////////////////////////////////////////////////////////////////
60 60
61CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization) 61CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization)
62 : CLanguageModel(_alphabet,_normalization) 62 : CLanguageModel(_alphabet,_normalization), root(0), m_rootcontext(0)
63{ 63{
64 root=new CPPMnode(-1); 64 root=new CPPMnode(-1);
65 m_rootcontext=new CPPMContext(root,0); 65 m_rootcontext=new CPPMContext(root,0);
66} 66}
67 67
68 68
69CPPMLanguageModel::~CPPMLanguageModel() 69CPPMLanguageModel::~CPPMLanguageModel()
70{ 70{
71 delete m_rootcontext;
71 delete root; 72 delete root;
72} 73}
73 74
74 75
75bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double ) 76bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double )
76 // get the probability distribution at the context 77 // get the probability distribution at the context
77{ 78{
78 // seems like we have to have this hack for VC++ 79 // seems like we have to have this hack for VC++
79 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context); 80 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context);
80 81
81 82
82 int modelchars=GetNumberModelChars(); 83 int modelchars=GetNumberModelChars();
83 int norm=CLanguageModel::normalization(); 84 int norm=CLanguageModel::normalization();
84 probs.resize(modelchars); 85 probs.resize(modelchars);
85 CPPMnode *temp,*s; 86 CPPMnode *temp,*s;
86 int loop,total; 87 int loop,total;
87 int sym; 88 int sym;
88 // ulong spent=0; 89 // ulong spent=0;
89 ulong size_of_slice; 90 ulong size_of_slice;
90 bool *exclusions=new bool [modelchars]; 91 bool *exclusions=new bool [modelchars];
91 ulong uniform=modelchars; 92 ulong uniform=modelchars;
92 ulong tospend=norm-uniform; 93 ulong tospend=norm-uniform;
93 temp=ppmcontext->head; 94 temp=ppmcontext->head;
94 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */ 95 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */
95 probs[loop]=0; 96 probs[loop]=0;
96 exclusions[loop]=0; 97 exclusions[loop]=0;
97 } 98 }
98 while (temp!=0) { 99 while (temp!=0) {
99 //Usprintf(debug,TEXT("tospend %u\n"),tospend); 100 //Usprintf(debug,TEXT("tospend %u\n"),tospend);
100 //DebugOutput(TEXT("round\n")); 101 //DebugOutput(TEXT("round\n"));
101 total=0; 102 total=0;
102 s=temp->child; 103 s=temp->child;
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 440d8be..28f6318 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -1,54 +1,70 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2 2
3#include "Bkmks.h" 3#include "Bkmks.h"
4 4
5#include "StyleConsts.h" 5#include "StyleConsts.h"
6#include "Markups.h" 6#include "Markups.h"
7#include "my_list.h" 7#include "my_list.h"
8#include "version.h" 8#include "version.h"
9#include "names.h" 9#include "names.h"
10 10
11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); 11const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
12 12
13Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) 13Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) :
14 m_name(0),
15 m_namelen(0),
16 m_anno(0),
17 m_annolen(0),
18 m_position(0)
14{ 19{
15 init(_nm, _nmlen, _anno, _annolen, _p); 20 init(_nm, _nmlen, _anno, _annolen, _p);
16} 21}
17 22
18Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) 23Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p)
19{ 24{
20 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); 25 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p);
21} 26}
22 27
28Bkmk::Bkmk(const Bkmk& rhs) :
29 m_name(0),
30 m_namelen(0),
31 m_anno(0),
32 m_annolen(0),
33 m_position(0)
34{
35 init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(),
36 sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value());
37}
38
23Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) 39Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p)
24{ 40{
25 if (_anno == NULL) 41 if (_anno == NULL)
26 { 42 {
27 tchar t = 0; 43 tchar t = 0;
28 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); 44 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
29 } 45 }
30 else 46 else
31 { 47 {
32 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); 48 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
33 } 49 }
34} 50}
35 51
36Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p) 52Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p)
37{ 53{
38 if (_anno == NULL) 54 if (_anno == NULL)
39 { 55 {
40 tchar t = 0; 56 tchar t = 0;
41 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); 57 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
42 } 58 }
43 else 59 else
44 { 60 {
45 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); 61 init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
46 } 62 }
47 m_position2 = _p2; 63 m_position2 = _p2;
48 m_red = m_green = m_blue = 127; 64 m_red = m_green = m_blue = 127;
49} 65}
50 66
51void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) 67void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p)
52{ 68{
53 m_namelen = _nmlen; 69 m_namelen = _nmlen;
54 if (m_namelen > 0) 70 if (m_namelen > 0)
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h
index c2275e2..985e158 100644
--- a/noncore/apps/opie-reader/Bkmks.h
+++ b/noncore/apps/opie-reader/Bkmks.h
@@ -1,63 +1,60 @@
1#ifndef __Bkmks_h 1#ifndef __Bkmks_h
2#define __Bkmks_h 2#define __Bkmks_h
3 3
4#include "config.h" 4#include "config.h"
5#include "Filedata.h" 5#include "Filedata.h"
6#include <stdio.h> 6#include <stdio.h>
7 7
8template<class T> 8template<class T>
9class CList; 9class CList;
10 10
11class Bkmk 11class Bkmk
12{ 12{
13 friend class BkmkFile; 13 friend class BkmkFile;
14 unsigned char* m_name; 14 unsigned char* m_name;
15 unsigned short m_namelen; 15 unsigned short m_namelen;
16 unsigned char* m_anno; 16 unsigned char* m_anno;
17 unsigned short m_annolen; 17 unsigned short m_annolen;
18 unsigned int m_position; 18 unsigned int m_position;
19 unsigned int m_position2; 19 unsigned int m_position2;
20 unsigned char m_red,m_green,m_blue, m_level; 20 unsigned char m_red,m_green,m_blue, m_level;
21 void init(const void*, unsigned short, const void*, unsigned short, unsigned int); 21 void init(const void*, unsigned short, const void*, unsigned short, unsigned int);
22 public: 22 public:
23 Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; 23 Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {};
24 Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); 24 Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
25 Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); 25 Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
26 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); 26 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p);
27 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); 27 Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2);
28 Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) 28 Bkmk(const Bkmk& rhs);
29 {
30 *this = rhs;
31 }
32 ~Bkmk(); 29 ~Bkmk();
33 unsigned int value() const { return m_position; } 30 unsigned int value() const { return m_position; }
34 void value(unsigned int _v) { m_position = _v; } 31 void value(unsigned int _v) { m_position = _v; }
35 unsigned int value2() const { return m_position2; } 32 unsigned int value2() const { return m_position2; }
36 void value2(unsigned int _v) { m_position2 = _v; } 33 void value2(unsigned int _v) { m_position2 = _v; }
37 unsigned char red() { return m_red; } 34 unsigned char red() { return m_red; }
38 unsigned char green() { return m_green; } 35 unsigned char green() { return m_green; }
39 unsigned char blue() { return m_blue; } 36 unsigned char blue() { return m_blue; }
40 void red(unsigned char _v) { m_red = _v; } 37 void red(unsigned char _v) { m_red = _v; }
41 void green(unsigned char _v) { m_green = _v; } 38 void green(unsigned char _v) { m_green = _v; }
42 void blue(unsigned char _v) { m_blue = _v; } 39 void blue(unsigned char _v) { m_blue = _v; }
43 unsigned char level() { return m_level; } 40 unsigned char level() { return m_level; }
44 void level(unsigned char _v) { m_level = _v; } 41 void level(unsigned char _v) { m_level = _v; }
45 tchar *name() const { return (tchar*)m_name; } 42 tchar *name() const { return (tchar*)m_name; }
46 tchar *anno() const { return (tchar*)m_anno; } 43 tchar *anno() const { return (tchar*)m_anno; }
47 bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } 44 bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); }
48 Bkmk& operator=(const Bkmk& rhs); 45 Bkmk& operator=(const Bkmk& rhs);
49 bool operator==(const Bkmk& rhs); 46 bool operator==(const Bkmk& rhs);
50 void setAnno(tchar* t); 47 void setAnno(tchar* t);
51 void setAnno(unsigned char* t, unsigned short len); 48 void setAnno(unsigned char* t, unsigned short len);
52 unsigned char* filedata() 49 unsigned char* filedata()
53 { 50 {
54 CFiledata fd(anno()); 51 CFiledata fd(anno());
55 return m_anno+fd.length(); 52 return m_anno+fd.length();
56 } 53 }
57 unsigned short filedatalen() 54 unsigned short filedatalen()
58 { 55 {
59 CFiledata fd(anno()); 56 CFiledata fd(anno());
60 return m_annolen - fd.length(); 57 return m_annolen - fd.length();
61 } 58 }
62}; 59};
63 60
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp
index 77c9d3b..c19fa3d 100644
--- a/noncore/apps/opie-reader/StyleConsts.cpp
+++ b/noncore/apps/opie-reader/StyleConsts.cpp
@@ -1,38 +1,45 @@
1 1
2#include <qimage.h> 2#include <qimage.h>
3#include "StyleConsts.h" 3#include "StyleConsts.h"
4 4
5GraphicLink::~GraphicLink() { delete graphic; } 5GraphicLink::~GraphicLink() { delete graphic; }
6 6
7pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) :
8 count(1),
9 m_isScaleable(_canScale)
10{
11 graphic = new GraphicLink(p, isLnk, tgt);
12}
13
7pmstore::~pmstore() 14pmstore::~pmstore()
8{ 15{
9//// qDebug("Deleting image"); 16//// qDebug("Deleting image");
10 delete graphic; 17 delete graphic;
11} 18}
12 19
13CStyle::~CStyle() 20CStyle::~CStyle()
14{ 21{
15 if (graphic != NULL) 22 if (graphic != NULL)
16 { 23 {
17 if (--(graphic->count) == 0) 24 if (--(graphic->count) == 0)
18 { 25 {
19 delete graphic; 26 delete graphic;
20 } 27 }
21 } 28 }
22} 29}
23 30
24CStyle::CStyle(const CStyle& rhs) : graphic(NULL) 31CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
25{ 32{
26 *this = rhs; 33 *this = rhs;
27} 34}
28 35
29CStyle& CStyle::operator=(const CStyle& rhs) 36CStyle& CStyle::operator=(const CStyle& rhs)
30{ 37{
31 if (rhs.graphic != NULL) 38 if (rhs.graphic != NULL)
32 { 39 {
33 (rhs.graphic->count)++; 40 (rhs.graphic->count)++;
34 if (graphic != NULL) 41 if (graphic != NULL)
35 { 42 {
36 if (--(graphic->count) == 0) 43 if (--(graphic->count) == 0)
37 { 44 {
38 delete graphic; 45 delete graphic;
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h
index 4b7ff4b..5fd9669 100644
--- a/noncore/apps/opie-reader/StyleConsts.h
+++ b/noncore/apps/opie-reader/StyleConsts.h
@@ -1,64 +1,62 @@
1#ifndef __STYLECONSTS_H 1#ifndef __STYLECONSTS_H
2#define __STYLECONSTS_H 2#define __STYLECONSTS_H
3 3
4typedef unsigned short StyleType; 4typedef unsigned short StyleType;
5 5
6#ifdef _WINDOWS 6#ifdef _WINDOWS
7#include <string.h> 7#include <string.h>
8#endif 8#endif
9#include <string.h> 9#include <string.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <qglobal.h> 11#include <qglobal.h>
12class QImage; 12class QImage;
13 13
14struct GraphicLink 14struct GraphicLink
15{ 15{
16 QImage* graphic; 16 QImage* graphic;
17 bool isLink; 17 bool isLink;
18 unsigned long link; 18 unsigned long link;
19 GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : 19 GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
20 graphic(p), isLink(isLnk), link(tgt) {} 20 graphic(p), isLink(isLnk), link(tgt) {}
21 ~GraphicLink(); 21 ~GraphicLink();
22}; 22};
23 23
24struct pmstore 24class pmstore
25{ 25{
26 public:
26 unsigned int count; 27 unsigned int count;
27 bool m_isScaleable; 28 bool m_isScaleable;
28 GraphicLink* graphic; 29 GraphicLink* graphic;
29 pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) 30 pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt);
30 {
31 graphic = new GraphicLink(p, isLnk, tgt);
32 }
33 ~pmstore(); 31 ~pmstore();
34}; 32};
35 33
36enum EalignmentType 34enum EalignmentType
37{ 35{
38 m_AlignLeft, 36 m_AlignLeft,
39 m_AlignRight, 37 m_AlignRight,
40 m_AlignCentre, 38 m_AlignCentre,
41 m_AlignJustify, 39 m_AlignJustify,
42 m_AlignNone 40 m_AlignNone
43}; 41};
44 42
45class CBasicStyle 43class CBasicStyle
46{ 44{
47 friend class CStyle; 45 friend class CStyle;
48 bool m_bold, 46 bool m_bold,
49 m_italic; 47 m_italic;
50 unsigned long m_table; 48 unsigned long m_table;
51 int m_fontsize; 49 int m_fontsize;
52 EalignmentType m_align; 50 EalignmentType m_align;
53 unsigned char red, green, blue; 51 unsigned char red, green, blue;
54 unsigned char bred, bgreen, bblue; 52 unsigned char bred, bgreen, bblue;
55 unsigned char pred, pgreen, pblue; 53 unsigned char pred, pgreen, pblue;
56 unsigned long data; 54 unsigned long data;
57 unsigned long offset; 55 unsigned long offset;
58 bool isLink; 56 bool isLink;
59 // bool isVisited; 57 // bool isVisited;
60 bool m_underline; 58 bool m_underline;
61 bool m_strikethru; 59 bool m_strikethru;
62 bool m_monospaced; 60 bool m_monospaced;
63 unsigned char m_leftmargin, m_rightmargin; 61 unsigned char m_leftmargin, m_rightmargin;
64 signed char m_extraspace; 62 signed char m_extraspace;
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index c27eb1e..f040f1e 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -6031,73 +6031,72 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
6031 QString s = style.mid( 16 ).stripWhiteSpace(); 6031 QString s = style.mid( 16 ).stripWhiteSpace();
6032 format.fn.setUnderline( s == "underline" ); 6032 format.fn.setUnderline( s == "underline" );
6033 } else if ( style.startsWith("vertical-align:" ) ) { 6033 } else if ( style.startsWith("vertical-align:" ) ) {
6034 QString s = style.mid( 15 ).stripWhiteSpace(); 6034 QString s = style.mid( 15 ).stripWhiteSpace();
6035 if ( s == "sub" ) 6035 if ( s == "sub" )
6036 format.setVAlign( QTextFormat::AlignSubScript ); 6036 format.setVAlign( QTextFormat::AlignSubScript );
6037 else if ( s == "super" ) 6037 else if ( s == "super" )
6038 format.setVAlign( QTextFormat::AlignSuperScript ); 6038 format.setVAlign( QTextFormat::AlignSuperScript );
6039 else 6039 else
6040 format.setVAlign( QTextFormat::AlignNormal ); 6040 format.setVAlign( QTextFormat::AlignNormal );
6041 } else if ( style.startsWith("color:" ) ) { 6041 } else if ( style.startsWith("color:" ) ) {
6042 format.col.setNamedColor( style.mid(6) ); 6042 format.col.setNamedColor( style.mid(6) );
6043 format.linkColor = FALSE; 6043 format.linkColor = FALSE;
6044 } 6044 }
6045 } 6045 }
6046 } 6046 }
6047 6047
6048 format.update(); 6048 format.update();
6049 return format; 6049 return format;
6050} 6050}
6051 6051
6052struct QPixmapInt 6052struct QPixmapInt
6053{ 6053{
6054 QPixmapInt() : ref( 0 ) {} 6054 QPixmapInt() : ref( 0 ) {}
6055 QPixmap pm; 6055 QPixmap pm;
6056 int ref; 6056 int ref;
6057}; 6057};
6058 6058
6059static QMap<QString, QPixmapInt> *pixmap_map = 0; 6059static QMap<QString, QPixmapInt> *pixmap_map = 0;
6060 6060
6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
6062 QMimeSourceFactory &factory ) 6062 QMimeSourceFactory &factory )
6063 : QTextCustomItem( p ) 6063 : QTextCustomItem( p ), reg( 0 )
6064{ 6064{
6065 width = height = 0; 6065 width = height = 0;
6066 if ( attr.contains("width") ) 6066 if ( attr.contains("width") )
6067 width = attr["width"].toInt(); 6067 width = attr["width"].toInt();
6068 if ( attr.contains("height") ) 6068 if ( attr.contains("height") )
6069 height = attr["height"].toInt(); 6069 height = attr["height"].toInt();
6070 6070
6071 reg = 0;
6072 QString imageName = attr["src"]; 6071 QString imageName = attr["src"];
6073 6072
6074 if (!imageName) 6073 if (!imageName)
6075 imageName = attr["source"]; 6074 imageName = attr["source"];
6076 6075
6077 if ( !imageName.isEmpty() ) { 6076 if ( !imageName.isEmpty() ) {
6078 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); 6077 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
6079 if ( !pixmap_map ) 6078 if ( !pixmap_map )
6080 pixmap_map = new QMap<QString, QPixmapInt>; 6079 pixmap_map = new QMap<QString, QPixmapInt>;
6081 if ( pixmap_map->contains( imgId ) ) { 6080 if ( pixmap_map->contains( imgId ) ) {
6082 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6081 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6083 pm = pmi.pm; 6082 pm = pmi.pm;
6084 pmi.ref++; 6083 pmi.ref++;
6085 width = pm.width(); 6084 width = pm.width();
6086 height = pm.height(); 6085 height = pm.height();
6087 } else { 6086 } else {
6088 QImage img; 6087 QImage img;
6089 const QMimeSource* m = 6088 const QMimeSource* m =
6090 factory.data( imageName, context ); 6089 factory.data( imageName, context );
6091 if ( !m ) { 6090 if ( !m ) {
6092 owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl; 6091 owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
6093 } 6092 }
6094 else { 6093 else {
6095 if ( !QImageDrag::decode( m, img ) ) { 6094 if ( !QImageDrag::decode( m, img ) ) {
6096 owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl; 6095 owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
6097 } 6096 }
6098 } 6097 }
6099 6098
6100 if ( !img.isNull() ) { 6099 if ( !img.isNull() ) {
6101 if ( width == 0 ) { 6100 if ( width == 0 ) {
6102 width = img.width(); 6101 width = img.width();
6103 if ( height != 0 ) { 6102 if ( height != 0 ) {
@@ -6120,76 +6119,76 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co
6120 pm.convertFromImage( img ); 6119 pm.convertFromImage( img );
6121 } 6120 }
6122 if ( !pm.isNull() ) { 6121 if ( !pm.isNull() ) {
6123 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6122 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6124 pmi.pm = pm; 6123 pmi.pm = pm;
6125 pmi.ref++; 6124 pmi.ref++;
6126 } 6125 }
6127 } 6126 }
6128 if ( pm.mask() ) { 6127 if ( pm.mask() ) {
6129 QRegion mask( *pm.mask() ); 6128 QRegion mask( *pm.mask() );
6130 QRegion all( 0, 0, pm.width(), pm.height() ); 6129 QRegion all( 0, 0, pm.width(), pm.height() );
6131 reg = new QRegion( all.subtract( mask ) ); 6130 reg = new QRegion( all.subtract( mask ) );
6132 } 6131 }
6133 } 6132 }
6134 6133
6135 if ( pm.isNull() && (width*height)==0 ) 6134 if ( pm.isNull() && (width*height)==0 )
6136 width = height = 50; 6135 width = height = 50;
6137 6136
6138 place = PlaceInline; 6137 place = PlaceInline;
6139 if ( attr["align"] == "left" ) 6138 if ( attr["align"] == "left" )
6140 place = PlaceLeft; 6139 place = PlaceLeft;
6141 else if ( attr["align"] == "right" ) 6140 else if ( attr["align"] == "right" )
6142 place = PlaceRight; 6141 place = PlaceRight;
6143 6142
6144 tmpwidth = width; 6143 tmpwidth = width;
6145 tmpheight = height; 6144 tmpheight = height;
6146 6145
6147 attributes = attr; 6146 attributes = attr;
6148} 6147}
6149 6148
6150QTextImage::~QTextImage() 6149QTextImage::~QTextImage()
6151{ 6150{
6151 delete reg;
6152 if ( pixmap_map && pixmap_map->contains( imgId ) ) { 6152 if ( pixmap_map && pixmap_map->contains( imgId ) ) {
6153 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6153 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6154 pmi.ref--; 6154 pmi.ref--;
6155 if ( !pmi.ref ) { 6155 if ( !pmi.ref ) {
6156 pixmap_map->remove( imgId ); 6156 pixmap_map->remove( imgId );
6157 if ( pixmap_map->isEmpty() ) { 6157 if ( pixmap_map->isEmpty() ) {
6158 delete pixmap_map; 6158 delete pixmap_map;
6159 pixmap_map = 0; 6159 pixmap_map = 0;
6160 } 6160 }
6161 } 6161 }
6162 } 6162 }
6163 delete reg;
6164} 6163}
6165 6164
6166QString QTextImage::richText() const 6165QString QTextImage::richText() const
6167{ 6166{
6168 QString s; 6167 QString s;
6169 s += "<img "; 6168 s += "<img ";
6170 QMap<QString, QString>::ConstIterator it = attributes.begin(); 6169 QMap<QString, QString>::ConstIterator it = attributes.begin();
6171 for ( ; it != attributes.end(); ++it ) 6170 for ( ; it != attributes.end(); ++it )
6172 s += it.key() + "=" + *it + " "; 6171 s += it.key() + "=" + *it + " ";
6173 s += ">"; 6172 s += ">";
6174 return s; 6173 return s;
6175} 6174}
6176 6175
6177void QTextImage::adjustToPainter( QPainter* p ) 6176void QTextImage::adjustToPainter( QPainter* p )
6178{ 6177{
6179 width = scale( tmpwidth, p ); 6178 width = scale( tmpwidth, p );
6180 height = scale( tmpheight, p ); 6179 height = scale( tmpheight, p );
6181} 6180}
6182 6181
6183#if !defined(Q_WS_X11) 6182#if !defined(Q_WS_X11)
6184#include <qbitmap.h> 6183#include <qbitmap.h>
6185#include "qcleanuphandler.h" 6184#include "qcleanuphandler.h"
6186static QPixmap *qrt_selection = 0; 6185static QPixmap *qrt_selection = 0;
6187static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap; 6186static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap;
6188static void qrt_createSelectionPixmap( const QColorGroup &cg ) 6187static void qrt_createSelectionPixmap( const QColorGroup &cg )
6189{ 6188{
6190 qrt_selection = new QPixmap( 2, 2 ); 6189 qrt_selection = new QPixmap( 2, 2 );
6191 qrt_cleanup_pixmap.set( &qrt_selection ); 6190 qrt_cleanup_pixmap.set( &qrt_selection );
6192 qrt_selection->fill( Qt::color0 ); 6191 qrt_selection->fill( Qt::color0 );
6193 QBitmap m( 2, 2 ); 6192 QBitmap m( 2, 2 );
6194 m.fill( Qt::color1 ); 6193 m.fill( Qt::color1 );
6195 QPainter p( &m ); 6194 QPainter p( &m );
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 539d356..89024f7 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -360,71 +360,76 @@ const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) {
360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; 360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
361 return s; 361 return s;
362 } 362 }
363 } 363 }
364 return 0L; 364 return 0L;
365#endif 365#endif
366} 366}
367 367
368HlCFloat::HlCFloat(int attribute, int context) 368HlCFloat::HlCFloat(int attribute, int context)
369 : HlFloat(attribute,context) { 369 : HlFloat(attribute,context) {
370} 370}
371 371
372const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { 372const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) {
373 373
374 s = HlFloat::checkHgl(s, len, lineStart); 374 s = HlFloat::checkHgl(s, len, lineStart);
375 if (s && ((*s&0xdf) == 'F' )) s++; 375 if (s && ((*s&0xdf) == 'F' )) s++;
376 return s; 376 return s;
377} 377}
378 378
379HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) 379HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len)
380 : HlItem(attribute, context) { 380 : HlItem(attribute, context) {
381 _charList=charList; 381 _charList=charList;
382 _charListLen=len; 382 _charListLen=len;
383} 383}
384 384
385const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) 385const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool)
386{ 386{
387 if (ustrchr(_charList, _charListLen, *s)) return s +1; 387 if (ustrchr(_charList, _charListLen, *s)) return s +1;
388 return 0L; 388 return 0L;
389} 389}
390 390
391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) 391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
392 : HlItem(attribute, context) { 392 : HlItem(attribute, context), Expr(0) {
393 393
394 handlesLinestart=regexp.startsWith("^"); 394 handlesLinestart=regexp.startsWith("^");
395 if(!handlesLinestart) regexp.prepend("^"); 395 if(!handlesLinestart) regexp.prepend("^");
396 Expr=new QRegExp3(regexp); 396 Expr=new QRegExp3(regexp);
397} 397}
398 398
399HlRegExpr::~HlRegExpr()
400{
401 delete Expr;
402}
403
399const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) 404const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart)
400{ 405{
401 if ((!lineStart) && handlesLinestart) return 0; 406 if ((!lineStart) && handlesLinestart) return 0;
402 407
403 QString line(s,len); 408 QString line(s,len);
404 int pos = Expr->search( line, 0 ); 409 int pos = Expr->search( line, 0 );
405 if (pos==-1) return 0L; 410 if (pos==-1) return 0L;
406 else 411 else
407 return (s+Expr->matchedLength()); 412 return (s+Expr->matchedLength());
408}; 413};
409 414
410 415
411HlLineContinue::HlLineContinue(int attribute, int context) 416HlLineContinue::HlLineContinue(int attribute, int context)
412 : HlItem(attribute,context) { 417 : HlItem(attribute,context) {
413} 418}
414 419
415const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { 420const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) {
416 421
417 if ((s[0].latin1() == '\\') && (len == 1)) 422 if ((s[0].latin1() == '\\') && (len == 1))
418 { 423 {
419 return s + 1; 424 return s + 1;
420 } 425 }
421 return 0L; 426 return 0L;
422} 427}
423 428
424 429
425HlCStringChar::HlCStringChar(int attribute, int context) 430HlCStringChar::HlCStringChar(int attribute, int context)
426 : HlItem(attribute,context) { 431 : HlItem(attribute,context) {
427} 432}
428 433
429//checks for hex and oct (for example \x1b or \033) 434//checks for hex and oct (for example \x1b or \033)
430const QChar *checkCharHexOct(const QChar *str) { 435const QChar *checkCharHexOct(const QChar *str) {
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h
index fddf585..f0be27b 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.h
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.h
@@ -155,65 +155,65 @@ class HlCFloat : public HlFloat {
155}; 155};
156 156
157class HlLineContinue : public HlItem { 157class HlLineContinue : public HlItem {
158 public: 158 public:
159 HlLineContinue(int attribute, int context); 159 HlLineContinue(int attribute, int context);
160 virtual bool endEnable(QChar c) {return c == '\0';} 160 virtual bool endEnable(QChar c) {return c == '\0';}
161 virtual const QChar *checkHgl(const QChar *, int len, bool); 161 virtual const QChar *checkHgl(const QChar *, int len, bool);
162}; 162};
163 163
164class HlCStringChar : public HlItem { 164class HlCStringChar : public HlItem {
165 public: 165 public:
166 HlCStringChar(int attribute, int context); 166 HlCStringChar(int attribute, int context);
167 virtual const QChar *checkHgl(const QChar *, int len, bool); 167 virtual const QChar *checkHgl(const QChar *, int len, bool);
168}; 168};
169 169
170class HlCChar : public HlItem { 170class HlCChar : public HlItem {
171 public: 171 public:
172 HlCChar(int attribute, int context); 172 HlCChar(int attribute, int context);
173 virtual const QChar *checkHgl(const QChar *, int len, bool); 173 virtual const QChar *checkHgl(const QChar *, int len, bool);
174}; 174};
175 175
176class HlAnyChar : public HlItem { 176class HlAnyChar : public HlItem {
177 public: 177 public:
178 HlAnyChar(int attribute, int context, const QChar* charList, uint len); 178 HlAnyChar(int attribute, int context, const QChar* charList, uint len);
179 virtual const QChar *checkHgl(const QChar *, int len, bool); 179 virtual const QChar *checkHgl(const QChar *, int len, bool);
180 const QChar* _charList; 180 const QChar* _charList;
181 uint _charListLen; 181 uint _charListLen;
182}; 182};
183 183
184class HlRegExpr : public HlItem { 184class HlRegExpr : public HlItem {
185 public: 185 public:
186 HlRegExpr(int attribute, int context,QString expr); 186 HlRegExpr(int attribute, int context,QString expr);
187 ~HlRegExpr(){delete Expr;}; 187 ~HlRegExpr();
188 virtual const QChar *checkHgl(const QChar *, int len, bool); 188 virtual const QChar *checkHgl(const QChar *, int len, bool);
189 QRegExp3 *Expr; 189 QRegExp3 *Expr;
190 bool handlesLinestart; 190 bool handlesLinestart;
191}; 191};
192 192
193//-------- 193//--------
194 194
195 195
196//Item Style: color, selected color, bold, italic 196//Item Style: color, selected color, bold, italic
197class ItemStyle { 197class ItemStyle {
198 public: 198 public:
199 ItemStyle(); 199 ItemStyle();
200// ItemStyle(const ItemStyle &); 200// ItemStyle(const ItemStyle &);
201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic); 201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;} 202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
203// void setData(const ItemStyle &); 203// void setData(const ItemStyle &);
204 QColor col; 204 QColor col;
205 QColor selCol; 205 QColor selCol;
206 int bold; //boolean value 206 int bold; //boolean value
207 int italic; //boolean value 207 int italic; //boolean value
208}; 208};
209 209
210typedef QList<ItemStyle> ItemStyleList; 210typedef QList<ItemStyle> ItemStyleList;
211 211
212//Item Properties: name, Item Style, Item Font 212//Item Properties: name, Item Style, Item Font
213class ItemData : public ItemStyle { 213class ItemData : public ItemStyle {
214 public: 214 public:
215 ItemData(const QString name, int defStyleNum); 215 ItemData(const QString name, int defStyleNum);
216 ItemData(const QString name, int defStyleNum, 216 ItemData(const QString name, int defStyleNum,
217 const QColor&, const QColor&, bool bold, bool italic); 217 const QColor&, const QColor&, bool bold, bool italic);
218 ItemData(ItemData 218 ItemData(ItemData
219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} 219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}