summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-write
Unidiff
Diffstat (limited to 'noncore/apps/opie-write') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-write/mainwindow.cpp12
-rw-r--r--noncore/apps/opie-write/opie-write.pro3
-rw-r--r--noncore/apps/opie-write/qcomplextext.cpp4
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp28
-rw-r--r--noncore/apps/opie-write/qrichtext_p.cpp15
5 files changed, 37 insertions, 25 deletions
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp
index 90e1a70..aa03060 100644
--- a/noncore/apps/opie-write/mainwindow.cpp
+++ b/noncore/apps/opie-write/mainwindow.cpp
@@ -1,52 +1,56 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** Licensees holding valid Qtopia Developer license may use this 6** Licensees holding valid Qtopia Developer license may use this
7** file in accordance with the Qtopia Developer License Agreement 7** file in accordance with the Qtopia Developer License Agreement
8** provided with the Software. 8** provided with the Software.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
11** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 11** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12** PURPOSE. 12** PURPOSE.
13** 13**
14** email sales@trolltech.com for information about Qtopia License 14** email sales@trolltech.com for information about Qtopia License
15** Agreements. 15** Agreements.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "mainwindow.h" 22#include "mainwindow.h"
23
24/* OPIE */
25#include <opie2/odebug.h>
23#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
24#include <qpe/applnk.h> 27#include <qpe/applnk.h>
25#include <qpe/resource.h> 28#include <qpe/resource.h>
26#include <qpe/fontdatabase.h> 29#include <qpe/fontdatabase.h>
30using namespace Opie::Core;
27 31
28//#include "qspellchecker.h" 32/* QT */
29#include "qtextedit.h" 33#include "qtextedit.h"
30#include <qaction.h> 34#include <qaction.h>
31#include <qtoolbar.h> 35#include <qtoolbar.h>
32#include <qtoolbutton.h> 36#include <qtoolbutton.h>
33#include <qtabwidget.h> 37#include <qtabwidget.h>
34#include <qapplication.h> 38#include <qapplication.h>
35#include <qfontdatabase.h> 39#include <qfontdatabase.h>
36#include <qcombobox.h> 40#include <qcombobox.h>
37#include <qlineedit.h> 41#include <qlineedit.h>
38#include <qfileinfo.h> 42#include <qfileinfo.h>
39#include <qfile.h> 43#include <qfile.h>
40#include <qfiledialog.h> 44#include <qfiledialog.h>
41#include <qprinter.h> 45#include <qprinter.h>
42#include <qpaintdevicemetrics.h> 46#include <qpaintdevicemetrics.h>
43#include <qmenubar.h> 47#include <qmenubar.h>
44#include <qpopupmenu.h> 48#include <qpopupmenu.h>
45#include <qcolordialog.h> 49#include <qcolordialog.h>
46#include <qpainter.h> 50#include <qpainter.h>
47#include <qstyle.h> 51#include <qstyle.h>
48 52
49class ButtonMenu : public QToolButton 53class ButtonMenu : public QToolButton
50{ 54{
51 Q_OBJECT 55 Q_OBJECT
52public: 56public:
@@ -423,80 +427,80 @@ void MainWindow::alignmentChanged( int a )
423} 427}
424 428
425void MainWindow::editorChanged( QWidget * ) 429void MainWindow::editorChanged( QWidget * )
426{ 430{
427 if ( !currentEditor() ) 431 if ( !currentEditor() )
428 return; 432 return;
429 fontChanged( currentEditor()->font() ); 433 fontChanged( currentEditor()->font() );
430 colorChanged( currentEditor()->color() ); 434 colorChanged( currentEditor()->color() );
431 alignmentChanged( currentEditor()->alignment() ); 435 alignmentChanged( currentEditor()->alignment() );
432} 436}
433 437
434void MainWindow::fileOpen() 438void MainWindow::fileOpen()
435{ 439{
436 save(); 440 save();
437 editorStack->raiseWidget( fileSelector ); 441 editorStack->raiseWidget( fileSelector );
438 fileSelector->reread(); 442 fileSelector->reread();
439 hideEditTools(); 443 hideEditTools();
440 fileSelector->setNewVisible( TRUE ); 444 fileSelector->setNewVisible( TRUE );
441 clear(); 445 clear();
442 updateCaption(); 446 updateCaption();
443} 447}
444 448
445void MainWindow::fileRevert() 449void MainWindow::fileRevert()
446{ 450{
447 qDebug( "QMainWindow::fileRevert needs to be done" ); 451 odebug << "QMainWindow::fileRevert needs to be done" << oendl;
448} 452}
449 453
450void MainWindow::fileNew() 454void MainWindow::fileNew()
451{ 455{
452 editor->setTextFormat( Qt::RichText ); 456 editor->setTextFormat( Qt::RichText );
453 save(); 457 save();
454 newFile(DocLnk()); 458 newFile(DocLnk());
455} 459}
456 460
457void MainWindow::insertTable() 461void MainWindow::insertTable()
458{ 462{
459 qDebug( "MainWindow::insertTable() needs to be done" ); 463 odebug << "MainWindow::insertTable() needs to be done" << oendl;
460} 464}
461 465
462void MainWindow::newFile( const DocLnk &dl ) 466void MainWindow::newFile( const DocLnk &dl )
463{ 467{
464 DocLnk nf = dl; 468 DocLnk nf = dl;
465 nf.setType( "text/html" ); 469 nf.setType( "text/html" );
466 clear(); 470 clear();
467 editorStack->raiseWidget( editor ); 471 editorStack->raiseWidget( editor );
468 editor->viewport()->setFocus(); 472 editor->viewport()->setFocus();
469 doc = new DocLnk( nf ); 473 doc = new DocLnk( nf );
470 updateCaption(); 474 updateCaption();
471} 475}
472 476
473void MainWindow::openFile( const DocLnk &dl ) 477void MainWindow::openFile( const DocLnk &dl )
474{ 478{
475 FileManager fm; 479 FileManager fm;
476 QString txt; 480 QString txt;
477 if ( !fm.loadFile( dl, txt ) ) 481 if ( !fm.loadFile( dl, txt ) )
478 qDebug( "couldn't open file" ); 482 odebug << "couldn't open file" << oendl;
479 clear(); 483 clear();
480 editorStack->raiseWidget( editor ); 484 editorStack->raiseWidget( editor );
481 editor->viewport()->setFocus(); 485 editor->viewport()->setFocus();
482 doc = new DocLnk( dl ); 486 doc = new DocLnk( dl );
483 editor->setText( txt ); 487 editor->setText( txt );
484 editor->setModified( FALSE ); 488 editor->setModified( FALSE );
485 updateCaption(); 489 updateCaption();
486} 490}
487 491
488void MainWindow::showEditTools( void ) 492void MainWindow::showEditTools( void )
489{ 493{
490 tbMenu->show(); 494 tbMenu->show();
491 tbEdit->show(); 495 tbEdit->show();
492 tbFont->show(); 496 tbFont->show();
493 tbStyle->show(); 497 tbStyle->show();
494} 498}
495 499
496void MainWindow::hideEditTools( void ) 500void MainWindow::hideEditTools( void )
497{ 501{
498 // let's reset the buttons... 502 // let's reset the buttons...
499 actionTextBold->setOn( FALSE ); 503 actionTextBold->setOn( FALSE );
500 actionTextItalic->setOn( FALSE ); 504 actionTextItalic->setOn( FALSE );
501 actionTextUnderline->setOn( FALSE ); 505 actionTextUnderline->setOn( FALSE );
502 //comboFont->setCurrentText( QApplication::font().family() ); 506 //comboFont->setCurrentText( QApplication::font().family() );
diff --git a/noncore/apps/opie-write/opie-write.pro b/noncore/apps/opie-write/opie-write.pro
index 044ce7e..8e514d4 100644
--- a/noncore/apps/opie-write/opie-write.pro
+++ b/noncore/apps/opie-write/opie-write.pro
@@ -1,27 +1,26 @@
1 1
2CONFIG += qt warn on quick-app 2CONFIG += qt warn on quick-app
3
4 3
5HEADERS = qcleanuphandler.h \ 4HEADERS = qcleanuphandler.h \
6 qcomplextext_p.h \ 5 qcomplextext_p.h \
7 qrichtext_p.h \ 6 qrichtext_p.h \
8 qstylesheet.h \ 7 qstylesheet.h \
9 qtextedit.h \ 8 qtextedit.h \
10 mainwindow.h 9 mainwindow.h
11 10
12SOURCES = qcomplextext.cpp \ 11SOURCES = qcomplextext.cpp \
13 qstylesheet.cpp \ 12 qstylesheet.cpp \
14 qrichtext_p.cpp \ 13 qrichtext_p.cpp \
15 qrichtext.cpp \ 14 qrichtext.cpp \
16 qtextedit.cpp \ 15 qtextedit.cpp \
17 main.cpp \ 16 main.cpp \
18 mainwindow.cpp 17 mainwindow.cpp
19 18
20INCLUDEPATH += $(OPIEDIR)/include 19INCLUDEPATH += $(OPIEDIR)/include
21DEPENDPATH += $(OPIEDIR)/include 20DEPENDPATH += $(OPIEDIR)/include
22LIBS += -lqpe -lopiecore2 21LIBS += -lqpe -lopiecore2
23 22
24TARGET = opie-write 23TARGET = opie-write
25 24
26 25
27include ( $(OPIEDIR)/include.pro ) 26include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-write/qcomplextext.cpp b/noncore/apps/opie-write/qcomplextext.cpp
index 473f184..00a91c5 100644
--- a/noncore/apps/opie-write/qcomplextext.cpp
+++ b/noncore/apps/opie-write/qcomplextext.cpp
@@ -85,62 +85,62 @@ QBidiContext::~QBidiContext()
85 will get form XRight 85 will get form XRight
86 R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right 86 R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right
87 will get form XLeft 87 will get form XLeft
88 R7 Otherwise the character will get form XIsolated 88 R7 Otherwise the character will get form XIsolated
89 89
90 Additionally we have to do the minimal ligature support for lam-alef ligatures: 90 Additionally we have to do the minimal ligature support for lam-alef ligatures:
91 91
92 L1 Transparent characters do not affect ligature behaviour. 92 L1 Transparent characters do not affect ligature behaviour.
93 L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft) 93 L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft)
94 L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated) 94 L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated)
95 95
96 The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with 96 The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with
97 previous and left with next in the above rules ;-) 97 previous and left with next in the above rules ;-)
98*/ 98*/
99 99
100/* 100/*
101 Two small helper functions for arabic shaping. They get the next shape causing character on either 101 Two small helper functions for arabic shaping. They get the next shape causing character on either
102 side of the char in question. Implements rule R1. 102 side of the char in question. Implements rule R1.
103 103
104 leftChar() returns true if the char to the left is a left join-causing char 104 leftChar() returns true if the char to the left is a left join-causing char
105 rightChar() returns true if the char to the right is a right join-causing char 105 rightChar() returns true if the char to the right is a right join-causing char
106*/ 106*/
107static inline const QChar *prevChar( const QString &str, int pos ) 107static inline const QChar *prevChar( const QString &str, int pos )
108{ 108{
109 //qDebug("leftChar: pos=%d", pos); 109 //odebug << "leftChar: pos=" << pos << "" << oendl;
110 pos--; 110 pos--;
111 const QChar *ch = str.unicode() + pos; 111 const QChar *ch = str.unicode() + pos;
112 while( pos > -1 ) { 112 while( pos > -1 ) {
113 if( !ch->isMark() ) 113 if( !ch->isMark() )
114 return ch; 114 return ch;
115 pos--; 115 pos--;
116 ch--; 116 ch--;
117 } 117 }
118 return &QChar::replacement; 118 return &QChar::replacement;
119} 119}
120 120
121static inline const QChar *nextChar( const QString &str, int pos) 121static inline const QChar *nextChar( const QString &str, int pos)
122{ 122{
123 pos++; 123 pos++;
124 int len = str.length(); 124 int len = str.length();
125 const QChar *ch = str.unicode() + pos; 125 const QChar *ch = str.unicode() + pos;
126 while( pos < len ) { 126 while( pos < len ) {
127 //qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining()); 127 //odebug << "rightChar: " << pos << " isLetter=" << ch.isLetter() << ", joining=" << ch.joining() << "" << oendl;
128 if( !ch->isMark() ) 128 if( !ch->isMark() )
129 return ch; 129 return ch;
130 // assume it's a transparent char, this might not be 100% correct 130 // assume it's a transparent char, this might not be 100% correct
131 pos++; 131 pos++;
132 ch++; 132 ch++;
133 } 133 }
134 return &QChar::replacement; 134 return &QChar::replacement;
135} 135}
136 136
137static inline bool prevVisualCharJoins( const QString &str, int pos) 137static inline bool prevVisualCharJoins( const QString &str, int pos)
138{ 138{
139 return ( prevChar( str, pos )->joining() != QChar::OtherJoining ); 139 return ( prevChar( str, pos )->joining() != QChar::OtherJoining );
140} 140}
141 141
142static inline bool nextVisualCharJoins( const QString &str, int pos) 142static inline bool nextVisualCharJoins( const QString &str, int pos)
143{ 143{
144 QChar::Joining join = nextChar( str, pos )->joining(); 144 QChar::Joining join = nextChar( str, pos )->joining();
145 return ( join == QChar::Dual || join == QChar::Center ); 145 return ( join == QChar::Dual || join == QChar::Center );
146} 146}
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index b77a0fc..c27eb1e 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -16,53 +16,59 @@
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qrichtext_p.h" 38#include "qrichtext_p.h"
39 39
40/* OPIE */
41#include <opie2/odebug.h>
42using namespace Opie::Core;
43
44/* QT */
40#include "qdragobject.h" 45#include "qdragobject.h"
41#include "qpaintdevicemetrics.h" 46#include "qpaintdevicemetrics.h"
42#include "qdrawutil.h" 47#include "qdrawutil.h"
43#include "qcleanuphandler.h" 48#include "qcleanuphandler.h"
44 49
50/* STD */
45#include <stdlib.h> 51#include <stdlib.h>
46 52
47using namespace Qt3; 53using namespace Qt3;
48 54
49static QTextCursor* richTextExportStart = 0; 55static QTextCursor* richTextExportStart = 0;
50static QTextCursor* richTextExportEnd = 0; 56static QTextCursor* richTextExportEnd = 0;
51 57
52static QTextFormatCollection *qFormatCollection = 0; 58static QTextFormatCollection *qFormatCollection = 0;
53 59
54const int border_tolerance = 2; 60const int border_tolerance = 2;
55 61
56#ifdef Q_WS_WIN 62#ifdef Q_WS_WIN
57#include "qt_windows.h" 63#include "qt_windows.h"
58#endif 64#endif
59 65
60#define QChar_linesep QChar(0x2028U) 66#define QChar_linesep QChar(0x2028U)
61 67
62static inline bool is_printer( QPainter *p ) 68static inline bool is_printer( QPainter *p )
63{ 69{
64 if ( !p || !p->device() ) 70 if ( !p || !p->device() )
65 return FALSE; 71 return FALSE;
66 return p->device()->devType() == QInternal::Printer; 72 return p->device()->devType() == QInternal::Printer;
67} 73}
68 74
@@ -163,77 +169,77 @@ QTextDeleteCommand::QTextDeleteCommand( QTextDocument *d, int i, int idx, const
163} 169}
164 170
165QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) 171QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str )
166 : QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str ) 172 : QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str )
167{ 173{
168 for ( int i = 0; i < (int)text.size(); ++i ) { 174 for ( int i = 0; i < (int)text.size(); ++i ) {
169 if ( text[ i ].format() ) 175 if ( text[ i ].format() )
170 text[ i ].format()->addRef(); 176 text[ i ].format()->addRef();
171 } 177 }
172} 178}
173 179
174QTextDeleteCommand::~QTextDeleteCommand() 180QTextDeleteCommand::~QTextDeleteCommand()
175{ 181{
176 for ( int i = 0; i < (int)text.size(); ++i ) { 182 for ( int i = 0; i < (int)text.size(); ++i ) {
177 if ( text[ i ].format() ) 183 if ( text[ i ].format() )
178 text[ i ].format()->removeRef(); 184 text[ i ].format()->removeRef();
179 } 185 }
180 text.resize( 0 ); 186 text.resize( 0 );
181} 187}
182 188
183QTextCursor *QTextDeleteCommand::execute( QTextCursor *c ) 189QTextCursor *QTextDeleteCommand::execute( QTextCursor *c )
184{ 190{
185 QTextParagraph *s = doc ? doc->paragAt( id ) : parag; 191 QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
186 if ( !s ) { 192 if ( !s ) {
187 qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() ); 193 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
188 return 0; 194 return 0;
189 } 195 }
190 196
191 cursor.setParagraph( s ); 197 cursor.setParagraph( s );
192 cursor.setIndex( index ); 198 cursor.setIndex( index );
193 int len = text.size(); 199 int len = text.size();
194 if ( c ) 200 if ( c )
195 *c = cursor; 201 *c = cursor;
196 if ( doc ) { 202 if ( doc ) {
197 doc->setSelectionStart( QTextDocument::Temp, cursor ); 203 doc->setSelectionStart( QTextDocument::Temp, cursor );
198 for ( int i = 0; i < len; ++i ) 204 for ( int i = 0; i < len; ++i )
199 cursor.gotoNextLetter(); 205 cursor.gotoNextLetter();
200 doc->setSelectionEnd( QTextDocument::Temp, cursor ); 206 doc->setSelectionEnd( QTextDocument::Temp, cursor );
201 doc->removeSelectedText( QTextDocument::Temp, &cursor ); 207 doc->removeSelectedText( QTextDocument::Temp, &cursor );
202 if ( c ) 208 if ( c )
203 *c = cursor; 209 *c = cursor;
204 } else { 210 } else {
205 s->remove( index, len ); 211 s->remove( index, len );
206 } 212 }
207 213
208 return c; 214 return c;
209} 215}
210 216
211QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c ) 217QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
212{ 218{
213 QTextParagraph *s = doc ? doc->paragAt( id ) : parag; 219 QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
214 if ( !s ) { 220 if ( !s ) {
215 qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() ); 221 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
216 return 0; 222 return 0;
217 } 223 }
218 224
219 cursor.setParagraph( s ); 225 cursor.setParagraph( s );
220 cursor.setIndex( index ); 226 cursor.setIndex( index );
221 QString str = QTextString::toString( text ); 227 QString str = QTextString::toString( text );
222 cursor.insert( str, TRUE, &text ); 228 cursor.insert( str, TRUE, &text );
223 cursor.setParagraph( s ); 229 cursor.setParagraph( s );
224 cursor.setIndex( index ); 230 cursor.setIndex( index );
225 if ( c ) { 231 if ( c ) {
226 c->setParagraph( s ); 232 c->setParagraph( s );
227 c->setIndex( index ); 233 c->setIndex( index );
228 for ( int i = 0; i < (int)text.size(); ++i ) 234 for ( int i = 0; i < (int)text.size(); ++i )
229 c->gotoNextLetter(); 235 c->gotoNextLetter();
230 } 236 }
231 237
232 if ( !styleInformation.isEmpty() ) { 238 if ( !styleInformation.isEmpty() ) {
233 QDataStream styleStream( styleInformation, IO_ReadOnly ); 239 QDataStream styleStream( styleInformation, IO_ReadOnly );
234 int num; 240 int num;
235 styleStream >> num; 241 styleStream >> num;
236 QTextParagraph *p = s; 242 QTextParagraph *p = s;
237 while ( num-- && p ) { 243 while ( num-- && p ) {
238 p->readStyleInformation( styleStream ); 244 p->readStyleInformation( styleStream );
239 p = p->next(); 245 p = p->next();
@@ -1523,52 +1529,52 @@ void QTextDocument::setRichTextInternal( const QString &text, QTextCursor* curso
1523 emptyTag = space = TRUE; 1529 emptyTag = space = TRUE;
1524 int index = QMAX( curpar->length(),1) - 1; 1530 int index = QMAX( curpar->length(),1) - 1;
1525 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); 1531 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
1526 curpar->append( QChar_linesep ); 1532 curpar->append( QChar_linesep );
1527 curpar->setFormat( index, 1, &format ); 1533 curpar->setFormat( index, 1, &format );
1528 } else if ( tagname == "hr" ) { 1534 } else if ( tagname == "hr" ) {
1529 emptyTag = space = TRUE; 1535 emptyTag = space = TRUE;
1530 custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this ); 1536 custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this );
1531 NEWPAR; 1537 NEWPAR;
1532 } else if ( tagname == "table" ) { 1538 } else if ( tagname == "table" ) {
1533 emptyTag = space = TRUE; 1539 emptyTag = space = TRUE;
1534 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); 1540 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
1535 curpar->setAlignment( curtag.alignment ); 1541 curpar->setAlignment( curtag.alignment );
1536 custom = parseTable( attr, format, doc, length, pos, curpar ); 1542 custom = parseTable( attr, format, doc, length, pos, curpar );
1537 } else if ( tagname == "qt" || tagname == "body" ) { 1543 } else if ( tagname == "qt" || tagname == "body" ) {
1538 if ( attr.contains( "bgcolor" ) ) { 1544 if ( attr.contains( "bgcolor" ) ) {
1539 QBrush *b = new QBrush( QColor( attr["bgcolor"] ) ); 1545 QBrush *b = new QBrush( QColor( attr["bgcolor"] ) );
1540 setPaper( b ); 1546 setPaper( b );
1541 } 1547 }
1542 if ( attr.contains( "background" ) ) { 1548 if ( attr.contains( "background" ) ) {
1543 QImage img; 1549 QImage img;
1544 QString bg = attr["background"]; 1550 QString bg = attr["background"];
1545 const QMimeSource* m = factory_->data( bg, contxt ); 1551 const QMimeSource* m = factory_->data( bg, contxt );
1546 if ( !m ) { 1552 if ( !m ) {
1547 qWarning("QRichText: no mimesource for %s", bg.latin1() ); 1553 owarn << "QRichText: no mimesource for " << bg.latin1() << "" << oendl;
1548 } else { 1554 } else {
1549 if ( !QImageDrag::decode( m, img ) ) { 1555 if ( !QImageDrag::decode( m, img ) ) {
1550 qWarning("QTextImage: cannot decode %s", bg.latin1() ); 1556 owarn << "QTextImage: cannot decode " << bg.latin1() << "" << oendl;
1551 } 1557 }
1552 } 1558 }
1553 if ( !img.isNull() ) { 1559 if ( !img.isNull() ) {
1554 QPixmap pm; 1560 QPixmap pm;
1555 pm.convertFromImage( img ); 1561 pm.convertFromImage( img );
1556 QBrush *b = new QBrush( QColor(), pm ); 1562 QBrush *b = new QBrush( QColor(), pm );
1557 setPaper( b ); 1563 setPaper( b );
1558 } 1564 }
1559 } 1565 }
1560 if ( attr.contains( "text" ) ) { 1566 if ( attr.contains( "text" ) ) {
1561 QColor c( attr["text"] ); 1567 QColor c( attr["text"] );
1562 if ( formatCollection()->defaultFormat()->color() != c ) { 1568 if ( formatCollection()->defaultFormat()->color() != c ) {
1563 QDict<QTextFormat> formats = formatCollection()->dict(); 1569 QDict<QTextFormat> formats = formatCollection()->dict();
1564 QDictIterator<QTextFormat> it( formats ); 1570 QDictIterator<QTextFormat> it( formats );
1565 while ( it.current() ) { 1571 while ( it.current() ) {
1566 if ( it.current() == formatCollection()->defaultFormat() ) { 1572 if ( it.current() == formatCollection()->defaultFormat() ) {
1567 ++it; 1573 ++it;
1568 continue; 1574 continue;
1569 } 1575 }
1570 it.current()->setColor( c ); 1576 it.current()->setColor( c );
1571 ++it; 1577 ++it;
1572 } 1578 }
1573 formatCollection()->defaultFormat()->setColor( c ); 1579 formatCollection()->defaultFormat()->setColor( c );
1574 curtag.format.setColor( c ); 1580 curtag.format.setColor( c );
@@ -2131,49 +2137,49 @@ static QString margin_to_string( QStyleSheetItem* style, int t, int b, int l, in
2131 if ( fl > 0 ) 2137 if ( fl > 0 )
2132 s += QString(!!s?";":"") + "text-indent:" + QString::number(fl+QMAX(0,style->margin(QStyleSheetItem::MarginFirstLine))) + "px"; 2138 s += QString(!!s?";":"") + "text-indent:" + QString::number(fl+QMAX(0,style->margin(QStyleSheetItem::MarginFirstLine))) + "px";
2133 if ( !!s ) 2139 if ( !!s )
2134 return " style=\"" + s + "\""; 2140 return " style=\"" + s + "\"";
2135 return QString::null; 2141 return QString::null;
2136} 2142}
2137 2143
2138QString QTextDocument::richText() const 2144QString QTextDocument::richText() const
2139{ 2145{
2140 QString s = ""; 2146 QString s = "";
2141 if ( !par ) { 2147 if ( !par ) {
2142 s += "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:" ; 2148 s += "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:" ;
2143 s += QString::number( formatCollection()->defaultFormat()->font().pointSize() ); 2149 s += QString::number( formatCollection()->defaultFormat()->font().pointSize() );
2144 s += "pt;font-family:"; 2150 s += "pt;font-family:";
2145 s += formatCollection()->defaultFormat()->font().family(); 2151 s += formatCollection()->defaultFormat()->font().family();
2146 s +="\">"; 2152 s +="\">";
2147 } 2153 }
2148 QTextParagraph* p = fParag; 2154 QTextParagraph* p = fParag;
2149 2155
2150 QStyleSheetItem* item_p = styleSheet()->item("p"); 2156 QStyleSheetItem* item_p = styleSheet()->item("p");
2151 QStyleSheetItem* item_ul = styleSheet()->item("ul"); 2157 QStyleSheetItem* item_ul = styleSheet()->item("ul");
2152 QStyleSheetItem* item_ol = styleSheet()->item("ol"); 2158 QStyleSheetItem* item_ol = styleSheet()->item("ol");
2153 QStyleSheetItem* item_li = styleSheet()->item("li"); 2159 QStyleSheetItem* item_li = styleSheet()->item("li");
2154 if ( !item_p || !item_ul || !item_ol || !item_li ) { 2160 if ( !item_p || !item_ul || !item_ol || !item_li ) {
2155 qWarning( "QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, ul, ol, or li)" ); 2161 owarn << "QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, ul, ol, or li)" << oendl;
2156 return QString::null; 2162 return QString::null;
2157 } 2163 }
2158 int pastListDepth = 0; 2164 int pastListDepth = 0;
2159 int listDepth = 0; 2165 int listDepth = 0;
2160 int futureListDepth = 0; 2166 int futureListDepth = 0;
2161 QMemArray<int> listStyles(10); 2167 QMemArray<int> listStyles(10);
2162 2168
2163 while ( p ) { 2169 while ( p ) {
2164 listDepth = p->listDepth(); 2170 listDepth = p->listDepth();
2165 if ( listDepth < pastListDepth ) { 2171 if ( listDepth < pastListDepth ) {
2166 for ( int i = listDepth+1; i <= pastListDepth; i++ ) 2172 for ( int i = listDepth+1; i <= pastListDepth; i++ )
2167 s += list_is_ordered( listStyles[i] ) ? "</ol>" : "</ul>"; 2173 s += list_is_ordered( listStyles[i] ) ? "</ol>" : "</ul>";
2168 s += '\n'; 2174 s += '\n';
2169 } else if ( listDepth > pastListDepth ) { 2175 } else if ( listDepth > pastListDepth ) {
2170 s += '\n'; 2176 s += '\n';
2171 listStyles.resize( QMAX( (int)listStyles.size(), listDepth+1 ) ); 2177 listStyles.resize( QMAX( (int)listStyles.size(), listDepth+1 ) );
2172 QString list_type; 2178 QString list_type;
2173 listStyles[listDepth] = p->listStyle(); 2179 listStyles[listDepth] = p->listStyle();
2174 if ( !list_is_ordered( p->listStyle() ) || item_ol->listStyle() != p->listStyle() ) 2180 if ( !list_is_ordered( p->listStyle() ) || item_ol->listStyle() != p->listStyle() )
2175 list_type = " type=" + list_style_to_string( p->listStyle() ); 2181 list_type = " type=" + list_style_to_string( p->listStyle() );
2176 for ( int i = pastListDepth; i < listDepth; i++ ) { 2182 for ( int i = pastListDepth; i < listDepth; i++ ) {
2177 s += list_is_ordered( p->listStyle() ) ? "<ol" : "<ul" ; 2183 s += list_is_ordered( p->listStyle() ) ? "<ol" : "<ul" ;
2178 s += list_type + ">"; 2184 s += list_type + ">";
2179 } 2185 }
@@ -4075,102 +4081,102 @@ void QTextParagraph::format( int start, bool doMove )
4075 invalid = -1; 4081 invalid = -1;
4076 //##### string()->setTextChanged( FALSE ); 4082 //##### string()->setTextChanged( FALSE );
4077} 4083}
4078 4084
4079int QTextParagraph::lineHeightOfChar( int i, int *bl, int *y ) const 4085int QTextParagraph::lineHeightOfChar( int i, int *bl, int *y ) const
4080{ 4086{
4081 if ( !isValid() ) 4087 if ( !isValid() )
4082 ( (QTextParagraph*)this )->format(); 4088 ( (QTextParagraph*)this )->format();
4083 4089
4084 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end(); 4090 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end();
4085 --it; 4091 --it;
4086 for ( ;; ) { 4092 for ( ;; ) {
4087 if ( i >= it.key() ) { 4093 if ( i >= it.key() ) {
4088 if ( bl ) 4094 if ( bl )
4089 *bl = ( *it )->baseLine; 4095 *bl = ( *it )->baseLine;
4090 if ( y ) 4096 if ( y )
4091 *y = ( *it )->y; 4097 *y = ( *it )->y;
4092 return ( *it )->h; 4098 return ( *it )->h;
4093 } 4099 }
4094 if ( it == lineStarts.begin() ) 4100 if ( it == lineStarts.begin() )
4095 break; 4101 break;
4096 --it; 4102 --it;
4097 } 4103 }
4098 4104
4099 qWarning( "QTextParagraph::lineHeightOfChar: couldn't find lh for %d", i ); 4105 owarn << "QTextParagraph::lineHeightOfChar: couldn't find lh for " << i << "" << oendl;
4100 return 15; 4106 return 15;
4101} 4107}
4102 4108
4103QTextStringChar *QTextParagraph::lineStartOfChar( int i, int *index, int *line ) const 4109QTextStringChar *QTextParagraph::lineStartOfChar( int i, int *index, int *line ) const
4104{ 4110{
4105 if ( !isValid() ) 4111 if ( !isValid() )
4106 ( (QTextParagraph*)this )->format(); 4112 ( (QTextParagraph*)this )->format();
4107 4113
4108 int l = (int)lineStarts.count() - 1; 4114 int l = (int)lineStarts.count() - 1;
4109 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end(); 4115 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end();
4110 --it; 4116 --it;
4111 for ( ;; ) { 4117 for ( ;; ) {
4112 if ( i >= it.key() ) { 4118 if ( i >= it.key() ) {
4113 if ( index ) 4119 if ( index )
4114 *index = it.key(); 4120 *index = it.key();
4115 if ( line ) 4121 if ( line )
4116 *line = l; 4122 *line = l;
4117 return &str->at( it.key() ); 4123 return &str->at( it.key() );
4118 } 4124 }
4119 if ( it == lineStarts.begin() ) 4125 if ( it == lineStarts.begin() )
4120 break; 4126 break;
4121 --it; 4127 --it;
4122 --l; 4128 --l;
4123 } 4129 }
4124 4130
4125 qWarning( "QTextParagraph::lineStartOfChar: couldn't find %d", i ); 4131 owarn << "QTextParagraph::lineStartOfChar: couldn't find " << i << "" << oendl;
4126 return 0; 4132 return 0;
4127} 4133}
4128 4134
4129int QTextParagraph::lines() const 4135int QTextParagraph::lines() const
4130{ 4136{
4131 if ( !isValid() ) 4137 if ( !isValid() )
4132 ( (QTextParagraph*)this )->format(); 4138 ( (QTextParagraph*)this )->format();
4133 4139
4134 return (int)lineStarts.count(); 4140 return (int)lineStarts.count();
4135} 4141}
4136 4142
4137QTextStringChar *QTextParagraph::lineStartOfLine( int line, int *index ) const 4143QTextStringChar *QTextParagraph::lineStartOfLine( int line, int *index ) const
4138{ 4144{
4139 if ( !isValid() ) 4145 if ( !isValid() )
4140 ( (QTextParagraph*)this )->format(); 4146 ( (QTextParagraph*)this )->format();
4141 4147
4142 if ( line >= 0 && line < (int)lineStarts.count() ) { 4148 if ( line >= 0 && line < (int)lineStarts.count() ) {
4143 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 4149 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
4144 while ( line-- > 0 ) 4150 while ( line-- > 0 )
4145 ++it; 4151 ++it;
4146 int i = it.key(); 4152 int i = it.key();
4147 if ( index ) 4153 if ( index )
4148 *index = i; 4154 *index = i;
4149 return &str->at( i ); 4155 return &str->at( i );
4150 } 4156 }
4151 4157
4152 qWarning( "QTextParagraph::lineStartOfLine: couldn't find %d", line ); 4158 owarn << "QTextParagraph::lineStartOfLine: couldn't find " << line << "" << oendl;
4153 return 0; 4159 return 0;
4154} 4160}
4155 4161
4156int QTextParagraph::leftGap() const 4162int QTextParagraph::leftGap() const
4157{ 4163{
4158 if ( !isValid() ) 4164 if ( !isValid() )
4159 ( (QTextParagraph*)this )->format(); 4165 ( (QTextParagraph*)this )->format();
4160 4166
4161 int line = 0; 4167 int line = 0;
4162 int x = str->at(0).x; /* set x to x of first char */ 4168 int x = str->at(0).x; /* set x to x of first char */
4163 if ( str->isBidi() ) { 4169 if ( str->isBidi() ) {
4164 for ( int i = 1; i < str->length()-1; ++i ) 4170 for ( int i = 1; i < str->length()-1; ++i )
4165 x = QMIN(x, str->at(i).x); 4171 x = QMIN(x, str->at(i).x);
4166 return x; 4172 return x;
4167 } 4173 }
4168 4174
4169 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 4175 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
4170 while (line < (int)lineStarts.count()) { 4176 while (line < (int)lineStarts.count()) {
4171 int i = it.key(); /* char index */ 4177 int i = it.key(); /* char index */
4172 x = QMIN(x, str->at(i).x); 4178 x = QMIN(x, str->at(i).x);
4173 ++it; 4179 ++it;
4174 ++line; 4180 ++line;
4175 } 4181 }
4176 return x; 4182 return x;
@@ -5676,49 +5682,49 @@ QTextFormat *QTextFormatCollection::format( QTextFormat *of, QTextFormat *nf, in
5676QTextFormat *QTextFormatCollection::format( const QFont &f, const QColor &c ) 5682QTextFormat *QTextFormatCollection::format( const QFont &f, const QColor &c )
5677{ 5683{
5678 if ( cachedFormat && cfont == f && ccol == c ) { 5684 if ( cachedFormat && cfont == f && ccol == c ) {
5679 cachedFormat->addRef(); 5685 cachedFormat->addRef();
5680 return cachedFormat; 5686 return cachedFormat;
5681 } 5687 }
5682 5688
5683 QString key = QTextFormat::getKey( f, c, FALSE, QTextFormat::AlignNormal ); 5689 QString key = QTextFormat::getKey( f, c, FALSE, QTextFormat::AlignNormal );
5684 cachedFormat = cKey.find( key ); 5690 cachedFormat = cKey.find( key );
5685 cfont = f; 5691 cfont = f;
5686 ccol = c; 5692 ccol = c;
5687 5693
5688 if ( cachedFormat ) { 5694 if ( cachedFormat ) {
5689 cachedFormat->addRef(); 5695 cachedFormat->addRef();
5690 return cachedFormat; 5696 return cachedFormat;
5691 } 5697 }
5692 5698
5693 if ( key == defFormat->key() ) 5699 if ( key == defFormat->key() )
5694 return defFormat; 5700 return defFormat;
5695 5701
5696 cachedFormat = createFormat( f, c ); 5702 cachedFormat = createFormat( f, c );
5697 cachedFormat->collection = this; 5703 cachedFormat->collection = this;
5698 cKey.insert( cachedFormat->key(), cachedFormat ); 5704 cKey.insert( cachedFormat->key(), cachedFormat );
5699 if ( cachedFormat->key() != key ) 5705 if ( cachedFormat->key() != key )
5700 qWarning("ASSERT: keys for format not identical: '%s '%s'", cachedFormat->key().latin1(), key.latin1() ); 5706 owarn << "ASSERT: keys for format not identical: '" << cachedFormat->key().latin1() << " '" << key.latin1() << "'" << oendl;
5701 return cachedFormat; 5707 return cachedFormat;
5702} 5708}
5703 5709
5704void QTextFormatCollection::remove( QTextFormat *f ) 5710void QTextFormatCollection::remove( QTextFormat *f )
5705{ 5711{
5706 if ( lastFormat == f ) 5712 if ( lastFormat == f )
5707 lastFormat = 0; 5713 lastFormat = 0;
5708 if ( cres == f ) 5714 if ( cres == f )
5709 cres = 0; 5715 cres = 0;
5710 if ( cachedFormat == f ) 5716 if ( cachedFormat == f )
5711 cachedFormat = 0; 5717 cachedFormat = 0;
5712 cKey.remove( f->key() ); 5718 cKey.remove( f->key() );
5713} 5719}
5714 5720
5715#define UPDATE( up, lo, rest ) \ 5721#define UPDATE( up, lo, rest ) \
5716 if ( font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest() ) \ 5722 if ( font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest() ) \
5717 fm->fn.set##up##rest( font.lo##rest() ) 5723 fm->fn.set##up##rest( font.lo##rest() )
5718 5724
5719void QTextFormatCollection::updateDefaultFormat( const QFont &font, const QColor &color, QStyleSheet *sheet ) 5725void QTextFormatCollection::updateDefaultFormat( const QFont &font, const QColor &color, QStyleSheet *sheet )
5720{ 5726{
5721 QDictIterator<QTextFormat> it( cKey ); 5727 QDictIterator<QTextFormat> it( cKey );
5722 QTextFormat *fm; 5728 QTextFormat *fm;
5723 bool usePixels = font.pointSize() == -1; 5729 bool usePixels = font.pointSize() == -1;
5724 bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() : 5730 bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() :
@@ -6062,53 +6068,53 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co
6062 if ( attr.contains("height") ) 6068 if ( attr.contains("height") )
6063 height = attr["height"].toInt(); 6069 height = attr["height"].toInt();
6064 6070
6065 reg = 0; 6071 reg = 0;
6066 QString imageName = attr["src"]; 6072 QString imageName = attr["src"];
6067 6073
6068 if (!imageName) 6074 if (!imageName)
6069 imageName = attr["source"]; 6075 imageName = attr["source"];
6070 6076
6071 if ( !imageName.isEmpty() ) { 6077 if ( !imageName.isEmpty() ) {
6072 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); 6078 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
6073 if ( !pixmap_map ) 6079 if ( !pixmap_map )
6074 pixmap_map = new QMap<QString, QPixmapInt>; 6080 pixmap_map = new QMap<QString, QPixmapInt>;
6075 if ( pixmap_map->contains( imgId ) ) { 6081 if ( pixmap_map->contains( imgId ) ) {
6076 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6082 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6077 pm = pmi.pm; 6083 pm = pmi.pm;
6078 pmi.ref++; 6084 pmi.ref++;
6079 width = pm.width(); 6085 width = pm.width();
6080 height = pm.height(); 6086 height = pm.height();
6081 } else { 6087 } else {
6082 QImage img; 6088 QImage img;
6083 const QMimeSource* m = 6089 const QMimeSource* m =
6084 factory.data( imageName, context ); 6090 factory.data( imageName, context );
6085 if ( !m ) { 6091 if ( !m ) {
6086 qWarning("QTextImage: no mimesource for %s", imageName.latin1() ); 6092 owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
6087 } 6093 }
6088 else { 6094 else {
6089 if ( !QImageDrag::decode( m, img ) ) { 6095 if ( !QImageDrag::decode( m, img ) ) {
6090 qWarning("QTextImage: cannot decode %s", imageName.latin1() ); 6096 owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
6091 } 6097 }
6092 } 6098 }
6093 6099
6094 if ( !img.isNull() ) { 6100 if ( !img.isNull() ) {
6095 if ( width == 0 ) { 6101 if ( width == 0 ) {
6096 width = img.width(); 6102 width = img.width();
6097 if ( height != 0 ) { 6103 if ( height != 0 ) {
6098 width = img.width() * height / img.height(); 6104 width = img.width() * height / img.height();
6099 } 6105 }
6100 } 6106 }
6101 if ( height == 0 ) { 6107 if ( height == 0 ) {
6102 height = img.height(); 6108 height = img.height();
6103 if ( width != img.width() ) { 6109 if ( width != img.width() ) {
6104 height = img.height() * width / img.width(); 6110 height = img.height() * width / img.width();
6105 } 6111 }
6106 } 6112 }
6107 if ( img.width() != width || img.height() != height ){ 6113 if ( img.width() != width || img.height() != height ){
6108#ifndef QT_NO_IMAGE_SMOOTHSCALE 6114#ifndef QT_NO_IMAGE_SMOOTHSCALE
6109 img = img.smoothScale(width, height); 6115 img = img.smoothScale(width, height);
6110#endif 6116#endif
6111 width = img.width(); 6117 width = img.width();
6112 height = img.height(); 6118 height = img.height();
6113 } 6119 }
6114 pm.convertFromImage( img ); 6120 pm.convertFromImage( img );
diff --git a/noncore/apps/opie-write/qrichtext_p.cpp b/noncore/apps/opie-write/qrichtext_p.cpp
index 6783e0b..2e8b09c 100644
--- a/noncore/apps/opie-write/qrichtext_p.cpp
+++ b/noncore/apps/opie-write/qrichtext_p.cpp
@@ -14,48 +14,51 @@
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include <opie2/odebug.h>
39using namespace Opie::Core;
40
38#include "qrichtext_p.h" 41#include "qrichtext_p.h"
39 42
40using namespace Qt3; 43using namespace Qt3;
41 44
42QTextCommand::~QTextCommand() {} 45QTextCommand::~QTextCommand() {}
43QTextCommand::Commands QTextCommand::type() const { return Invalid; } 46QTextCommand::Commands QTextCommand::type() const { return Invalid; }
44 47
45 48
46QTextCustomItem::~QTextCustomItem() {} 49QTextCustomItem::~QTextCustomItem() {}
47void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; } 50void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; }
48QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; } 51QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; }
49 52
50bool QTextCustomItem::ownLine() const { return FALSE; } 53bool QTextCustomItem::ownLine() const { return FALSE; }
51void QTextCustomItem::resize( int nwidth ){ width = nwidth; } 54void QTextCustomItem::resize( int nwidth ){ width = nwidth; }
52void QTextCustomItem::invalidate() {} 55void QTextCustomItem::invalidate() {}
53 56
54bool QTextCustomItem::isNested() const { return FALSE; } 57bool QTextCustomItem::isNested() const { return FALSE; }
55int QTextCustomItem::minimumWidth() const { return 0; } 58int QTextCustomItem::minimumWidth() const { return 0; }
56 59
57QString QTextCustomItem::richText() const { return QString::null; } 60QString QTextCustomItem::richText() const { return QString::null; }
58 61
59bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool ) 62bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool )
60{ 63{
61 return TRUE; 64 return TRUE;
@@ -116,49 +119,49 @@ int QTextCursor::y() const
116{ 119{
117 int dummy, line; 120 int dummy, line;
118 para->lineStartOfChar( idx, &dummy, &line ); 121 para->lineStartOfChar( idx, &dummy, &line );
119 return para->lineY( line ); 122 return para->lineY( line );
120} 123}
121 124
122int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } 125int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); }
123int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } 126int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); }
124 127
125QTextDocument *QTextCursor::document() const 128QTextDocument *QTextCursor::document() const
126{ 129{
127 return para ? para->document() : 0; 130 return para ? para->document() : 0;
128} 131}
129 132
130void QTextCursor::gotoPosition( QTextParagraph* p, int index ) 133void QTextCursor::gotoPosition( QTextParagraph* p, int index )
131{ 134{
132 if ( para && p != para ) { 135 if ( para && p != para ) {
133 while ( para->document() != p->document() && !indices.isEmpty() ) 136 while ( para->document() != p->document() && !indices.isEmpty() )
134 pop(); 137 pop();
135 Q_ASSERT( indices.isEmpty() || para->document() == p->document() ); 138 Q_ASSERT( indices.isEmpty() || para->document() == p->document() );
136 } 139 }
137 para = p; 140 para = p;
138 if ( index < 0 || index >= para->length() ) { 141 if ( index < 0 || index >= para->length() ) {
139#if defined(QT_CHECK_RANGE) 142#if defined(QT_CHECK_RANGE)
140 qWarning( "QTextCursor::gotoParagraph Index: %d out of range", index ); 143 owarn << "QTextCursor::gotoParagraph Index: " << index << " out of range" << oendl;
141#endif 144#endif
142 index = index < 0 ? 0 : para->length() - 1; 145 index = index < 0 ? 0 : para->length() - 1;
143 } 146 }
144 147
145 tmpIndex = -1; 148 tmpIndex = -1;
146 idx = index; 149 idx = index;
147} 150}
148 151
149bool QTextDocument::hasSelection( int id, bool visible ) const 152bool QTextDocument::hasSelection( int id, bool visible ) const
150{ 153{
151 return ( selections.find( id ) != selections.end() && 154 return ( selections.find( id ) != selections.end() &&
152 ( !visible || 155 ( !visible ||
153 ( (QTextDocument*)this )->selectionStartCursor( id ) != 156 ( (QTextDocument*)this )->selectionStartCursor( id ) !=
154 ( (QTextDocument*)this )->selectionEndCursor( id ) ) ); 157 ( (QTextDocument*)this )->selectionEndCursor( id ) ) );
155} 158}
156 159
157void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor ) 160void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor )
158{ 161{
159 QTextDocumentSelection sel; 162 QTextDocumentSelection sel;
160 sel.startCursor = cursor; 163 sel.startCursor = cursor;
161 sel.endCursor = cursor; 164 sel.endCursor = cursor;
162 sel.swapped = FALSE; 165 sel.swapped = FALSE;
163 selections[ id ] = sel; 166 selections[ id ] = sel;
164} 167}
@@ -456,98 +459,98 @@ int QTextParagraph::selectionEnd( int id ) const
456 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); 459 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
457 if ( it == mSelections->end() ) 460 if ( it == mSelections->end() )
458 return -1; 461 return -1;
459 return ( *it ).end; 462 return ( *it ).end;
460} 463}
461 464
462bool QTextParagraph::hasSelection( int id ) const 465bool QTextParagraph::hasSelection( int id ) const
463{ 466{
464 return mSelections ? mSelections->contains( id ) : FALSE; 467 return mSelections ? mSelections->contains( id ) : FALSE;
465} 468}
466 469
467bool QTextParagraph::fullSelected( int id ) const 470bool QTextParagraph::fullSelected( int id ) const
468{ 471{
469 if ( !mSelections ) 472 if ( !mSelections )
470 return FALSE; 473 return FALSE;
471 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); 474 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
472 if ( it == mSelections->end() ) 475 if ( it == mSelections->end() )
473 return FALSE; 476 return FALSE;
474 return ( *it ).start == 0 && ( *it ).end == str->length() - 1; 477 return ( *it ).start == 0 && ( *it ).end == str->length() - 1;
475} 478}
476 479
477int QTextParagraph::lineY( int l ) const 480int QTextParagraph::lineY( int l ) const
478{ 481{
479 if ( l > (int)lineStarts.count() - 1 ) { 482 if ( l > (int)lineStarts.count() - 1 ) {
480 qWarning( "QTextParagraph::lineY: line %d out of range!", l ); 483 owarn << "QTextParagraph::lineY: line " << l << " out of range!" << oendl;
481 return 0; 484 return 0;
482 } 485 }
483 486
484 if ( !isValid() ) 487 if ( !isValid() )
485 ( (QTextParagraph*)this )->format(); 488 ( (QTextParagraph*)this )->format();
486 489
487 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 490 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
488 while ( l-- > 0 ) 491 while ( l-- > 0 )
489 ++it; 492 ++it;
490 return ( *it )->y; 493 return ( *it )->y;
491} 494}
492 495
493int QTextParagraph::lineBaseLine( int l ) const 496int QTextParagraph::lineBaseLine( int l ) const
494{ 497{
495 if ( l > (int)lineStarts.count() - 1 ) { 498 if ( l > (int)lineStarts.count() - 1 ) {
496 qWarning( "QTextParagraph::lineBaseLine: line %d out of range!", l ); 499 owarn << "QTextParagraph::lineBaseLine: line " << l << " out of range!" << oendl;
497 return 10; 500 return 10;
498 } 501 }
499 502
500 if ( !isValid() ) 503 if ( !isValid() )
501 ( (QTextParagraph*)this )->format(); 504 ( (QTextParagraph*)this )->format();
502 505
503 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 506 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
504 while ( l-- > 0 ) 507 while ( l-- > 0 )
505 ++it; 508 ++it;
506 return ( *it )->baseLine; 509 return ( *it )->baseLine;
507} 510}
508 511
509int QTextParagraph::lineHeight( int l ) const 512int QTextParagraph::lineHeight( int l ) const
510{ 513{
511 if ( l > (int)lineStarts.count() - 1 ) { 514 if ( l > (int)lineStarts.count() - 1 ) {
512 qWarning( "QTextParagraph::lineHeight: line %d out of range!", l ); 515 owarn << "QTextParagraph::lineHeight: line " << l << " out of range!" << oendl;
513 return 15; 516 return 15;
514 } 517 }
515 518
516 if ( !isValid() ) 519 if ( !isValid() )
517 ( (QTextParagraph*)this )->format(); 520 ( (QTextParagraph*)this )->format();
518 521
519 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 522 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
520 while ( l-- > 0 ) 523 while ( l-- > 0 )
521 ++it; 524 ++it;
522 return ( *it )->h; 525 return ( *it )->h;
523} 526}
524 527
525void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const 528void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const
526{ 529{
527 if ( l > (int)lineStarts.count() - 1 ) { 530 if ( l > (int)lineStarts.count() - 1 ) {
528 qWarning( "QTextParagraph::lineInfo: line %d out of range!", l ); 531 owarn << "QTextParagraph::lineInfo: line " << l << " out of range!" << oendl;
529 qDebug( "%d %d", (int)lineStarts.count() - 1, l ); 532 odebug << "" << (int)lineStarts.count() - 1 << " " << l << "" << oendl;
530 y = 0; 533 y = 0;
531 h = 15; 534 h = 15;
532 bl = 10; 535 bl = 10;
533 return; 536 return;
534 } 537 }
535 538
536 if ( !isValid() ) 539 if ( !isValid() )
537 ( (QTextParagraph*)this )->format(); 540 ( (QTextParagraph*)this )->format();
538 541
539 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 542 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
540 while ( l-- > 0 ) 543 while ( l-- > 0 )
541 ++it; 544 ++it;
542 y = ( *it )->y; 545 y = ( *it )->y;
543 h = ( *it )->h; 546 h = ( *it )->h;
544 bl = ( *it )->baseLine; 547 bl = ( *it )->baseLine;
545} 548}
546 549
547 550
548void QTextParagraph::setAlignment( int a ) 551void QTextParagraph::setAlignment( int a )
549{ 552{
550 if ( a == (int)align ) 553 if ( a == (int)align )
551 return; 554 return;
552 align = a; 555 align = a;
553 invalidate( 0 ); 556 invalidate( 0 );