1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt3Support module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "q3richtext_p.h"
|
---|
43 |
|
---|
44 | #ifndef QT_NO_RICHTEXT
|
---|
45 |
|
---|
46 | QT_BEGIN_NAMESPACE
|
---|
47 |
|
---|
48 | Q3TextCommand::~Q3TextCommand() {}
|
---|
49 | Q3TextCommand::Commands Q3TextCommand::type() const { return Invalid; }
|
---|
50 |
|
---|
51 |
|
---|
52 | #ifndef QT_NO_TEXTCUSTOMITEM
|
---|
53 | Q3TextCustomItem::~Q3TextCustomItem() {}
|
---|
54 | void Q3TextCustomItem::adjustToPainter(QPainter* p){ if (p) width = 0; }
|
---|
55 | Q3TextCustomItem::Placement Q3TextCustomItem::placement() const { return PlaceInline; }
|
---|
56 |
|
---|
57 | bool Q3TextCustomItem::ownLine() const { return false; }
|
---|
58 | void Q3TextCustomItem::resize(int nwidth){ width = nwidth; }
|
---|
59 | void Q3TextCustomItem::invalidate() {}
|
---|
60 |
|
---|
61 | bool Q3TextCustomItem::isNested() const { return false; }
|
---|
62 | int Q3TextCustomItem::minimumWidth() const { return 0; }
|
---|
63 |
|
---|
64 | QString Q3TextCustomItem::richText() const { return QString(); }
|
---|
65 |
|
---|
66 | bool Q3TextCustomItem::enter(Q3TextCursor *, Q3TextDocument*&, Q3TextParagraph *&, int &, int &, int &, bool)
|
---|
67 | {
|
---|
68 | return true;
|
---|
69 | }
|
---|
70 | bool Q3TextCustomItem::enterAt(Q3TextCursor *, Q3TextDocument *&, Q3TextParagraph *&, int &, int &, int &, const QPoint &)
|
---|
71 | {
|
---|
72 | return true;
|
---|
73 | }
|
---|
74 | bool Q3TextCustomItem::next(Q3TextCursor *, Q3TextDocument *&, Q3TextParagraph *&, int &, int &, int &)
|
---|
75 | {
|
---|
76 | return true;
|
---|
77 | }
|
---|
78 | bool Q3TextCustomItem::prev(Q3TextCursor *, Q3TextDocument *&, Q3TextParagraph *&, int &, int &, int &)
|
---|
79 | {
|
---|
80 | return true;
|
---|
81 | }
|
---|
82 | bool Q3TextCustomItem::down(Q3TextCursor *, Q3TextDocument *&, Q3TextParagraph *&, int &, int &, int &)
|
---|
83 | {
|
---|
84 | return true;
|
---|
85 | }
|
---|
86 | bool Q3TextCustomItem::up(Q3TextCursor *, Q3TextDocument *&, Q3TextParagraph *&, int &, int &, int &)
|
---|
87 | {
|
---|
88 | return true;
|
---|
89 | }
|
---|
90 | #endif // QT_NO_TEXTCUSTOMITEM
|
---|
91 |
|
---|
92 | void Q3TextFlow::setPageSize(int ps) { pagesize = ps; }
|
---|
93 | #ifndef QT_NO_TEXTCUSTOMITEM
|
---|
94 | bool Q3TextFlow::isEmpty() { return leftItems.isEmpty() && rightItems.isEmpty(); }
|
---|
95 | #else
|
---|
96 | bool Q3TextFlow::isEmpty() { return true; }
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | #ifndef QT_NO_TEXTCUSTOMITEM
|
---|
100 | void Q3TextTableCell::invalidate() { cached_width = -1; cached_sizehint = -1; }
|
---|
101 |
|
---|
102 | void Q3TextTable::invalidate() { cachewidth = -1; }
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | Q3TextParagraphData::~Q3TextParagraphData() {}
|
---|
106 | void Q3TextParagraphData::join(Q3TextParagraphData *) {}
|
---|
107 |
|
---|
108 | Q3TextFormatter::~Q3TextFormatter() {}
|
---|
109 | void Q3TextFormatter::setWrapEnabled(bool b) { wrapEnabled = b; }
|
---|
110 | void Q3TextFormatter::setWrapAtColumn(int c) { wrapColumn = c; }
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 | int Q3TextCursor::x() const
|
---|
115 | {
|
---|
116 | if (idx >= para->length())
|
---|
117 | return 0;
|
---|
118 | Q3TextStringChar *c = para->at(idx);
|
---|
119 | int curx = c->x;
|
---|
120 | if (!c->rightToLeft &&
|
---|
121 | c->c.isSpace() &&
|
---|
122 | idx > 0 &&
|
---|
123 | para->at(idx - 1)->c != QLatin1Char('\t') &&
|
---|
124 | !c->lineStart &&
|
---|
125 | (para->alignment() & Qt::AlignJustify) == Qt::AlignJustify)
|
---|
126 | curx = para->at(idx - 1)->x + para->string()->width(idx - 1);
|
---|
127 | if (c->rightToLeft)
|
---|
128 | curx += para->string()->width(idx);
|
---|
129 | return curx;
|
---|
130 | }
|
---|
131 |
|
---|
132 | int Q3TextCursor::y() const
|
---|
133 | {
|
---|
134 | int dummy, line;
|
---|
135 | para->lineStartOfChar(idx, &dummy, &line);
|
---|
136 | return para->lineY(line);
|
---|
137 | }
|
---|
138 |
|
---|
139 | int Q3TextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); }
|
---|
140 | int Q3TextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); }
|
---|
141 |
|
---|
142 | Q3TextDocument *Q3TextCursor::document() const
|
---|
143 | {
|
---|
144 | return para ? para->document() : 0;
|
---|
145 | }
|
---|
146 |
|
---|
147 | void Q3TextCursor::gotoPosition(Q3TextParagraph* p, int index)
|
---|
148 | {
|
---|
149 | if (para && p != para) {
|
---|
150 | while (!indices.isEmpty() && para->document() != p->document())
|
---|
151 | pop();
|
---|
152 | Q_ASSERT(indices.isEmpty() || para->document() == p->document());
|
---|
153 | }
|
---|
154 | para = p;
|
---|
155 | if (index < 0 || index >= para->length()) {
|
---|
156 | qWarning("Q3TextCursor::gotoParagraph Index: %d out of range", index);
|
---|
157 | if (index < 0 || para->length() == 0)
|
---|
158 | index = 0;
|
---|
159 | else
|
---|
160 | index = para->length() - 1;
|
---|
161 | }
|
---|
162 |
|
---|
163 | tmpX = -1;
|
---|
164 | idx = index;
|
---|
165 | fixCursorPosition();
|
---|
166 | }
|
---|
167 |
|
---|
168 | bool Q3TextDocument::hasSelection(int id, bool visible) const
|
---|
169 | {
|
---|
|
---|