summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp6
-rw-r--r--src/gui/text/qabstracttextdocumentlayout_p.h3
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp2
-rw-r--r--src/gui/text/qtextcursor.cpp8
-rw-r--r--src/gui/text/qtextdocument.cpp82
-rw-r--r--src/gui/text/qtextdocument.h2
-rw-r--r--src/gui/text/qtextdocument_p.h30
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp9
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp31
-rw-r--r--src/gui/text/qtextengine_p.h14
-rw-r--r--src/gui/text/qtexthtmlparser.cpp6
-rw-r--r--src/gui/text/qtextlayout.cpp14
-rw-r--r--src/gui/text/qtextlist.cpp4
-rw-r--r--src/gui/text/qtextobject.cpp28
-rw-r--r--src/gui/text/qtextobject.h3
-rw-r--r--src/gui/text/qtextodfwriter.cpp6
-rw-r--r--src/gui/text/qtexttable.cpp16
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp2
19 files changed, 140 insertions, 130 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index bfce38797a..48b7f85413 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -567,7 +567,7 @@ void QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(QObject *obj)
*/
int QAbstractTextDocumentLayout::formatIndex(int pos)
{
- QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle();
+ QTextDocumentPrivate *pieceTable = QTextDocumentPrivate::get(qobject_cast<QTextDocument *>(parent()));
return pieceTable->find(pos).value()->format;
}
@@ -578,7 +578,7 @@ int QAbstractTextDocumentLayout::formatIndex(int pos)
*/
QTextCharFormat QAbstractTextDocumentLayout::format(int pos)
{
- QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle();
+ QTextDocumentPrivate *pieceTable = QTextDocumentPrivate::get(qobject_cast<QTextDocument *>(parent()));
int idx = pieceTable->find(pos).value()->format;
return pieceTable->formatCollection()->charFormat(idx);
}
@@ -644,7 +644,7 @@ QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const
block = block.next();
}
- QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle();
+ const QTextDocumentPrivate *pieceTable = QTextDocumentPrivate::get(qobject_cast<const QTextDocument *>(parent()));
QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
return pieceTable->formatCollection()->format(it->format);
}
diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h
index d631ce3197..88035eb66d 100644
--- a/src/gui/text/qabstracttextdocumentlayout_p.h
+++ b/src/gui/text/qabstracttextdocumentlayout_p.h
@@ -53,6 +53,7 @@
#include <QtGui/private/qtguiglobal_p.h>
#include "private/qobject_p.h"
+#include "qtextdocument_p.h"
#include "QtCore/qhash.h"
QT_BEGIN_NAMESPACE
@@ -78,7 +79,7 @@ public:
document = doc;
docPrivate = nullptr;
if (doc)
- docPrivate = doc->docHandle();
+ docPrivate = QTextDocumentPrivate::get(doc);
}
inline int _q_dynamicPageCountSlot() const
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index b50957d63d..8abcac5dec 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -173,7 +173,7 @@ void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int c
if (lastBlock.isValid())
endPosition = lastBlock.position() + lastBlock.length();
else
- endPosition = doc->docHandle()->length();
+ endPosition = QTextDocumentPrivate::get(doc)->length();
bool forceHighlightOfNextBlock = false;
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index fa323ef4bd..c579eca1ff 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -1052,7 +1052,7 @@ QTextCursor::QTextCursor()
Constructs a cursor pointing to the beginning of the \a document.
*/
QTextCursor::QTextCursor(QTextDocument *document)
- : d(new QTextCursorPrivate(document->docHandle()))
+ : d(new QTextCursorPrivate(QTextDocumentPrivate::get(document)))
{
}
@@ -1060,7 +1060,7 @@ QTextCursor::QTextCursor(QTextDocument *document)
Constructs a cursor pointing to the beginning of the \a frame.
*/
QTextCursor::QTextCursor(QTextFrame *frame)
- : d(new QTextCursorPrivate(frame->document()->docHandle()))
+ : d(new QTextCursorPrivate(QTextDocumentPrivate::get(frame->document())))
{
d->adjusted_anchor = d->anchor = d->position = frame->firstPosition();
}
@@ -1070,7 +1070,7 @@ QTextCursor::QTextCursor(QTextFrame *frame)
Constructs a cursor pointing to the beginning of the \a block.
*/
QTextCursor::QTextCursor(const QTextBlock &block)
- : d(new QTextCursorPrivate(block.docHandle()))
+ : d(new QTextCursorPrivate(const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block))))
{
d->adjusted_anchor = d->anchor = d->position = block.position();
}
@@ -2264,7 +2264,7 @@ void QTextCursor::insertFragment(const QTextDocumentFragment &fragment)
d->setX();
if (fragment.d && fragment.d->doc)
- d->priv->mergeCachedResources(fragment.d->doc->docHandle());
+ d->priv->mergeCachedResources(QTextDocumentPrivate::get(fragment.d->doc));
}
/*!
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 64ba01d4e5..ddccfe5999 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -40,6 +40,7 @@
#include "qtextdocument.h"
#include <qtextformat.h>
#include "qtextcursor_p.h"
+#include "qtextdocument_p.h"
#include "qtextdocumentlayout_p.h"
#include "qtextdocumentfragment.h"
#include "qtextdocumentfragment_p.h"
@@ -1328,7 +1329,8 @@ static bool findInBlock(const QTextBlock &block, const QString &expression, int
}
}
//we have a hit, return the cursor for that.
- *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);
+ *cursor = QTextCursorPrivate::fromPosition(const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block)),
+ block.position() + idx);
cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor);
return true;
}
@@ -1448,7 +1450,8 @@ static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int
}
}
//we have a hit, return the cursor for that.
- *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);
+ *cursor = QTextCursorPrivate::fromPosition(const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block)),
+ block.position() + idx);
cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor);
return true;
}
@@ -1576,7 +1579,8 @@ static bool findInBlock(const QTextBlock &block, const QRegularExpression &expre
}
}
//we have a hit, return the cursor for that.
- *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);
+ *cursor = QTextCursorPrivate::fromPosition(const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block)),
+ block.position() + idx);
cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor);
return true;
}
@@ -1737,7 +1741,7 @@ QTextObject *QTextDocument::objectForFormat(const QTextFormat &f) const
QTextBlock QTextDocument::findBlock(int pos) const
{
Q_D(const QTextDocument);
- return QTextBlock(docHandle(), d->blockMap().findNode(pos));
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), d->blockMap().findNode(pos));
}
/*!
@@ -1749,7 +1753,7 @@ QTextBlock QTextDocument::findBlock(int pos) const
QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const
{
Q_D(const QTextDocument);
- return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), d->blockMap().findNode(blockNumber, 1));
}
/*!
@@ -1761,7 +1765,7 @@ QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const
QTextBlock QTextDocument::findBlockByLineNumber(int lineNumber) const
{
Q_D(const QTextDocument);
- return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), d->blockMap().findNode(lineNumber, 2));
}
/*!
@@ -1772,7 +1776,7 @@ QTextBlock QTextDocument::findBlockByLineNumber(int lineNumber) const
QTextBlock QTextDocument::begin() const
{
Q_D(const QTextDocument);
- return QTextBlock(docHandle(), d->blockMap().begin().n);
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), d->blockMap().begin().n);
}
/*!
@@ -1789,7 +1793,8 @@ QTextBlock QTextDocument::begin() const
*/
QTextBlock QTextDocument::end() const
{
- return QTextBlock(docHandle(), 0);
+ Q_D(const QTextDocument);
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), 0);
}
/*!
@@ -1799,7 +1804,7 @@ QTextBlock QTextDocument::end() const
QTextBlock QTextDocument::firstBlock() const
{
Q_D(const QTextDocument);
- return QTextBlock(docHandle(), d->blockMap().begin().n);
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), d->blockMap().begin().n);
}
/*!
@@ -1809,7 +1814,7 @@ QTextBlock QTextDocument::firstBlock() const
QTextBlock QTextDocument::lastBlock() const
{
Q_D(const QTextDocument);
- return QTextBlock(docHandle(), d->blockMap().last().n);
+ return QTextBlock(const_cast<QTextDocumentPrivate *>(d), d->blockMap().last().n);
}
/*!
@@ -1893,12 +1898,14 @@ QFont QTextDocument::defaultFont() const
bool QTextDocument::isModified() const
{
- return docHandle()->isModified();
+ Q_D(const QTextDocument);
+ return d->isModified();
}
void QTextDocument::setModified(bool m)
{
- docHandle()->setModified(m);
+ Q_D(QTextDocument);
+ d->setModified(m);
}
#ifndef QT_NO_PRINTER
@@ -2319,7 +2326,7 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode)
html = QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" />");
- html.reserve(doc->docHandle()->length());
+ html.reserve(QTextDocumentPrivate::get(doc)->length());
fragmentMarkers = (mode == ExportFragment);
@@ -2889,8 +2896,9 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
int p = block.position();
if (p > 0)
--p;
- QTextDocumentPrivate::FragmentIterator frag = doc->docHandle()->find(p);
- QChar ch = doc->docHandle()->buffer().at(frag->stringPosition);
+
+ QTextDocumentPrivate::FragmentIterator frag = QTextDocumentPrivate::get(doc)->find(p);
+ QChar ch = QTextDocumentPrivate::get(doc)->buffer().at(frag->stringPosition);
if (ch == QTextBeginningOfFrame
|| ch == QTextEndOfFrame)
return;
@@ -3008,7 +3016,7 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
for (; !it.atEnd(); ++it)
emitFragment(it.fragment());
- if (fragmentMarkers && block.position() + block.length() == doc->docHandle()->length())
+ if (fragmentMarkers && block.position() + block.length() == QTextDocumentPrivate::get(doc)->length())
html += QLatin1String("<!--EndFragment-->");
if (pre)
@@ -3046,27 +3054,27 @@ QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cach
if (QTextDocument *parent = qobject_cast<QTextDocument *>(doc->parent()))
return findUrlForImage(parent, cacheKey, isPixmap);
- if (doc && doc->docHandle()) {
- QTextDocumentPrivate *priv = doc->docHandle();
- QMap<QUrl, QVariant>::const_iterator it = priv->cachedResources.constBegin();
- for (; it != priv->cachedResources.constEnd(); ++it) {
+ const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(doc);
+ Q_ASSERT(priv != nullptr);
- const QVariant &v = it.value();
- if (v.userType() == QMetaType::QImage && !isPixmap) {
- if (qvariant_cast<QImage>(v).cacheKey() == cacheKey)
- break;
- }
+ QMap<QUrl, QVariant>::const_iterator it = priv->cachedResources.constBegin();
+ for (; it != priv->cachedResources.constEnd(); ++it) {
- if (v.userType() == QMetaType::QPixmap && isPixmap) {
- if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey)
- break;
- }
+ const QVariant &v = it.value();
+ if (v.userType() == QMetaType::QImage && !isPixmap) {
+ if (qvariant_cast<QImage>(v).cacheKey() == cacheKey)
+ break;
}
- if (it != priv->cachedResources.constEnd())
- url = it.key().toString();
+ if (v.userType() == QMetaType::QPixmap && isPixmap) {
+ if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey)
+ break;
+ }
}
+ if (it != priv->cachedResources.constEnd())
+ url = it.key().toString();
+
return url;
}
@@ -3435,18 +3443,6 @@ QVector<QTextFormat> QTextDocument::allFormats() const
return d->formatCollection()->formats;
}
-
-/*!
- \internal
-
- So that not all classes have to be friends of each other...
-*/
-QTextDocumentPrivate *QTextDocument::docHandle() const
-{
- Q_D(const QTextDocument);
- return const_cast<QTextDocumentPrivate *>(d);
-}
-
/*!
\since 4.4
\fn QTextDocument::undoCommandAdded()
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 2459c78768..1a1a3da8e8 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -316,8 +316,6 @@ protected:
Q_INVOKABLE virtual QVariant loadResource(int type, const QUrl &name);
QTextDocument(QTextDocumentPrivate &dd, QObject *parent);
-public:
- QTextDocumentPrivate *docHandle() const;
private:
Q_DISABLE_COPY(QTextDocument)
Q_DECLARE_PRIVATE(QTextDocument)
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index ce8e905eb0..95f5f89925 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -295,6 +295,36 @@ public:
bool ensureMaximumBlockCount();
+ static inline const QTextDocumentPrivate *get(const QTextDocument *document)
+ {
+ return document->d_func();
+ }
+
+ static inline QTextDocumentPrivate *get(QTextDocument *document)
+ {
+ return document->d_func();
+ }
+
+ static inline QTextDocumentPrivate *get(QTextBlock &block)
+ {
+ return block.p;
+ }
+
+ static inline const QTextDocumentPrivate *get(const QTextBlock &block)
+ {
+ return block.p;
+ }
+
+ static inline QTextDocumentPrivate *get(QTextObject *object)
+ {
+ return get(object->document());
+ }
+
+ static inline const QTextDocumentPrivate *get(const QTextObject *object)
+ {
+ return get(object->document());
+ }
+
private:
QTextDocumentPrivate(const QTextDocumentPrivate& m);
QTextDocumentPrivate& operator= (const QTextDocumentPrivate& m);
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index d7bc707491..96d690fda4 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -224,13 +224,14 @@ QTextDocumentFragmentPrivate::QTextDocumentFragmentPrivate(const QTextCursor &_c
if (!_cursor.hasSelection())
return;
- doc->docHandle()->beginEditBlock();
+ QTextDocumentPrivate *p = QTextDocumentPrivate::get(doc);
+ p->beginEditBlock();
QTextCursor destCursor(doc);
QTextCopyHelper(_cursor, destCursor).copy();
- doc->docHandle()->endEditBlock();
+ p->endEditBlock();
if (_cursor.d)
- doc->docHandle()->mergeCachedResources(_cursor.d->priv);
+ p->mergeCachedResources(_cursor.d->priv);
}
void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const
@@ -353,7 +354,7 @@ QTextDocumentFragment::~QTextDocumentFragment()
*/
bool QTextDocumentFragment::isEmpty() const
{
- return !d || !d->doc || d->doc->docHandle()->length() <= 1;
+ return d == nullptr || d->doc == nullptr || QTextDocumentPrivate::get(d->doc)->length() <= 1;
}
/*!
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 9d70873590..91e5595fbf 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -3400,7 +3400,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
} else {
currentLazyLayoutPosition = checkPoints.constLast().positionInFrame;
// #######
- //checkPoints.last().positionInFrame = q->document()->docHandle()->length();
+ //checkPoints.last().positionInFrame = QTextDocumentPrivate::get(q->document())->length();
}
}
@@ -4146,7 +4146,7 @@ int QTextDocumentLayout::layoutStatus() const
int pos = d->currentLazyLayoutPosition;
if (pos == -1)
return 100;
- return pos * 100 / d->document->docHandle()->length();
+ return pos * 100 / QTextDocumentPrivate::get(d->document)->length();
}
void QTextDocumentLayout::timerEvent(QTimerEvent *e)
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 81ed8fa97a..6a5c443455 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1984,7 +1984,7 @@ void QTextEngine::shape(int item) const
auto &li = layoutData->items[item];
if (li.analysis.flags == QScriptAnalysis::Object) {
ensureSpace(1);
- if (block.docHandle()) {
+ if (QTextDocumentPrivate::get(block) != nullptr) {
docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast<QTextEngine *>(this)),
li.position + block.position(),
format(&li));
@@ -2040,7 +2040,7 @@ void QTextEngine::validate() const
if (layoutData)
return;
layoutData = new LayoutData();
- if (block.docHandle()) {
+ if (QTextDocumentPrivate::get(block) != nullptr) {
layoutData->string = block.text();
const bool nextBlockValid = block.next().isValid();
if (!nextBlockValid && option.flags() & QTextOption::ShowDocumentTerminator) {
@@ -2135,7 +2135,7 @@ void QTextEngine::itemize() const
Itemizer itemizer(layoutData->string, scriptAnalysis.data(), layoutData->items);
- const QTextDocumentPrivate *p = block.docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(block);
if (p) {
SpecialData *s = specialData;
@@ -2413,9 +2413,10 @@ QFont QTextEngine::font(const QScriptItem &si) const
QTextCharFormat f = format(&si);
font = f.font();
- if (block.docHandle() && block.docHandle()->layout()) {
+ const QTextDocumentPrivate *document_d = QTextDocumentPrivate::get(block);
+ if (document_d != nullptr && document_d->layout() != nullptr) {
// Make sure we get the right dpi on printers
- QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();
+ QPaintDevice *pdev = document_d->layout()->paintDevice();
if (pdev)
font = QFont(font, pdev);
} else {
@@ -2490,9 +2491,9 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
QTextCharFormat f = format(&si);
font = f.font();
- if (block.docHandle() && block.docHandle()->layout()) {
+ if (QTextDocumentPrivate::get(block) != nullptr && QTextDocumentPrivate::get(block)->layout() != nullptr) {
// Make sure we get the right dpi on printers
- QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();
+ QPaintDevice *pdev = QTextDocumentPrivate::get(block)->layout()->paintDevice();
if (pdev)
font = QFont(font, pdev);
} else {
@@ -2789,10 +2790,10 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng)
QFont f;
QFontEngine *e;
- if (eng->block.docHandle() && eng->block.docHandle()->layout()) {
+ if (QTextDocumentPrivate::get(eng->block) != nullptr && QTextDocumentPrivate::get(eng->block)->layout() != nullptr) {
f = eng->block.charFormat().font();
// Make sure we get the right dpi on printers
- QPaintDevice *pdev = eng->block.docHandle()->layout()->paintDevice();
+ QPaintDevice *pdev = QTextDocumentPrivate::get(eng->block)->layout()->paintDevice();
if (pdev)
f = QFont(f, pdev);
e = f.d->engineForScript(QChar::Script_Common);
@@ -2954,7 +2955,7 @@ int QTextEngine::formatIndex(const QScriptItem *si) const
return collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items.at(0)));
}
- QTextDocumentPrivate *p = block.docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(block);
if (!p)
return -1;
int pos = si->position;
@@ -3079,7 +3080,7 @@ void QTextEngine::indexFormats()
{
QTextFormatCollection *collection = formatCollection();
if (!collection) {
- Q_ASSERT(!block.docHandle());
+ Q_ASSERT(QTextDocumentPrivate::get(block) == nullptr);
specialData->formatCollection.reset(new QTextFormatCollection);
collection = specialData->formatCollection.data();
}
@@ -3341,8 +3342,8 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
const QScriptItem &si = layoutData->items[item];
QFixed dpiScale = 1;
- if (block.docHandle() && block.docHandle()->layout()) {
- QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();
+ if (QTextDocumentPrivate::get(block) != nullptr && QTextDocumentPrivate::get(block)->layout() != nullptr) {
+ QPaintDevice *pdev = QTextDocumentPrivate::get(block)->layout()->paintDevice();
if (pdev)
dpiScale = QFixed::fromReal(pdev->logicalDpiY() / qreal(qt_defaultDpiY()));
} else {
@@ -3504,8 +3505,8 @@ void QTextEngine::resolveFormats() const
}
QTextCharFormat &format = resolvedFormats[i];
- if (block.docHandle()) {
- // when we have a docHandle, formatIndex might still return a valid index based
+ if (QTextDocumentPrivate::get(block) != nullptr) {
+ // when we have a QTextDocumentPrivate, formatIndex might still return a valid index based
// on the preeditPosition. for all other cases, we cleared the resolved format indices
format = collection->charFormat(formatIndex(si));
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index f069951ce5..84c983160f 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -525,14 +525,14 @@ public:
int findItem(int strPos, int firstItem = 0) const;
inline QTextFormatCollection *formatCollection() const {
- if (block.docHandle())
- return block.docHandle()->formatCollection();
+ if (QTextDocumentPrivate::get(block) != nullptr)
+ return const_cast<QTextFormatCollection *>(QTextDocumentPrivate::get(block)->formatCollection());
return specialData ? specialData->formatCollection.data() : nullptr;
}
QTextCharFormat format(const QScriptItem *si) const;
inline QAbstractTextDocumentLayout *docLayout() const {
- Q_ASSERT(block.docHandle());
- return block.docHandle()->document()->documentLayout();
+ Q_ASSERT(QTextDocumentPrivate::get(block) != nullptr);
+ return QTextDocumentPrivate::get(block)->document()->documentLayout();
}
int formatIndex(const QScriptItem *si) const;
@@ -589,14 +589,14 @@ public:
ItemDecorationList overlineList;
inline bool visualCursorMovement() const
- { return visualMovement || (block.docHandle() && block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle); }
+ { return visualMovement || (QTextDocumentPrivate::get(block) != nullptr && QTextDocumentPrivate::get(block)->defaultCursorMoveStyle == Qt::VisualMoveStyle); }
inline int preeditAreaPosition() const { return specialData ? specialData->preeditPosition : -1; }
inline QString preeditAreaText() const { return specialData ? specialData->preeditText : QString(); }
void setPreeditArea(int position, const QString &text);
inline bool hasFormats() const
- { return block.docHandle() || (specialData && !specialData->formats.isEmpty()); }
+ { return QTextDocumentPrivate::get(block) != nullptr || (specialData && !specialData->formats.isEmpty()); }
inline QVector<QTextLayout::FormatRange> formats() const
{ return specialData ? specialData->formats : QVector<QTextLayout::FormatRange>(); }
void setFormats(const QVector<QTextLayout::FormatRange> &formats);
@@ -609,7 +609,7 @@ private:
QString preeditText;
QVector<QTextLayout::FormatRange> formats;
QVector<QTextCharFormat> resolvedFormats;
- // only used when no docHandle is available
+ // only used when no QTextDocumentPrivate is available
QScopedPointer<QTextFormatCollection> formatCollection;
};
SpecialData *specialData;
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index f003544391..76ff99aae0 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1373,7 +1373,7 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration>
case QCss::QtForegroundTextureCacheKey:
{
- if (resourceProvider != nullptr && resourceProvider->docHandle() != nullptr) {
+ if (resourceProvider != nullptr && QTextDocumentPrivate::get(resourceProvider) != nullptr) {
bool ok;
qint64 searchKey = decl.d->values.first().variant.toLongLong(&ok);
if (ok)
@@ -1415,7 +1415,7 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration>
void QTextHtmlParserNode::applyForegroundImage(qint64 searchKey, const QTextDocument *resourceProvider)
{
- QTextDocumentPrivate *priv = resourceProvider->docHandle();
+ const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(resourceProvider);
for (int i = 0; i < priv->formats.numFormats(); ++i) {
QTextCharFormat format = priv->formats.charFormat(i);
if (format.isValid()) {
@@ -2110,7 +2110,7 @@ QVector<QCss::Declaration> QTextHtmlParser::declarationsForNode(int node) const
+ externalStyleSheets.count()
+ inlineStyleSheets.count());
if (resourceProvider)
- selector.styleSheets[idx++] = resourceProvider->docHandle()->parsedDefaultStyleSheet;
+ selector.styleSheets[idx++] = QTextDocumentPrivate::get(resourceProvider)->parsedDefaultStyleSheet;
for (int i = 0; i < externalStyleSheets.count(); ++i, ++idx)
selector.styleSheets[idx] = externalStyleSheets.at(i).sheet;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 02c42eaf03..3d7a097cd9 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -491,8 +491,8 @@ void QTextLayout::setPreeditArea(int position, const QString &text)
return;
d->setPreeditArea(position, text);
- if (d->block.docHandle())
- d->block.docHandle()->documentChange(d->block.position(), d->block.length());
+ if (QTextDocumentPrivate::get(d->block) != nullptr)
+ QTextDocumentPrivate::get(d->block)->documentChange(d->block.position(), d->block.length());
}
/*!
@@ -538,8 +538,8 @@ void QTextLayout::setFormats(const QVector<FormatRange> &formats)
{
d->setFormats(formats);
- if (d->block.docHandle())
- d->block.docHandle()->documentChange(d->block.position(), d->block.length());
+ if (QTextDocumentPrivate::get(d->block) != nullptr)
+ QTextDocumentPrivate::get(d->block)->documentChange(d->block.position(), d->block.length());
}
#if QT_DEPRECATED_SINCE(5, 6)
@@ -1913,7 +1913,7 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.whiteSpaceOrObject = true;
lbh.tmpData.length++;
- if (eng->block.docHandle()) {
+ if (QTextDocumentPrivate::get(eng->block) != nullptr) {
QTextInlineObject inlineObject(item, eng);
QTextFormat f = inlineObject.format();
eng->docLayout()->positionInlineObject(inlineObject, eng->block.position() + current.position, f);
@@ -2062,7 +2062,7 @@ found:
line += lbh.tmpData;
}
- if (hasInlineObject && eng->block.docHandle()) {
+ if (hasInlineObject && QTextDocumentPrivate::get(eng->block) != nullptr) {
// position top/bottom aligned inline objects
if (maxInlineObjectHeight > line.ascent + line.descent) {
// extend line height if required
@@ -2568,7 +2568,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
if (eng->hasFormats()) {
p->save();
- if (si.analysis.flags == QScriptAnalysis::Object && eng->block.docHandle()) {
+ if (si.analysis.flags == QScriptAnalysis::Object && QTextDocumentPrivate::get(eng->block)) {
QFixed itemY = y - si.ascent;
if (format.verticalAlignment() == QTextCharFormat::AlignTop) {
itemY = y - lineBase;
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp
index 5857afa048..25f2d7adf8 100644
--- a/src/gui/text/qtextlist.cpp
+++ b/src/gui/text/qtextlist.cpp
@@ -304,7 +304,7 @@ void QTextList::remove(const QTextBlock &block)
QTextBlockFormat fmt = block.blockFormat();
fmt.setIndent(fmt.indent() + format().indent());
fmt.setObjectIndex(-1);
- block.docHandle()->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat);
+ const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block))->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat);
}
/*!
@@ -316,7 +316,7 @@ void QTextList::add(const QTextBlock &block)
{
QTextBlockFormat fmt = block.blockFormat();
fmt.setObjectIndex(objectIndex());
- block.docHandle()->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat);
+ const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block))->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat);
}
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 77dcae0dc8..1476a8a58f 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -171,14 +171,6 @@ QTextDocument *QTextObject::document() const
}
/*!
- \internal
-*/
-QTextDocumentPrivate *QTextObject::docHandle() const
-{
- return static_cast<const QTextDocument *>(parent())->docHandle();
-}
-
-/*!
\class QTextBlockGroup
\reentrant
@@ -270,7 +262,7 @@ void QTextBlockGroup::blockRemoved(const QTextBlock &block)
d->blocks.removeAll(block);
d->markBlocksDirty();
if (d->blocks.isEmpty()) {
- document()->docHandle()->deleteObject(this);
+ QTextDocumentPrivate::get(document())->deleteObject(this);
return;
}
}
@@ -576,7 +568,7 @@ void QTextFramePrivate::remove_me()
Q_Q(QTextFrame);
if (fragment_start == 0 && fragment_end == 0
&& !parentFrame) {
- q->document()->docHandle()->deleteObject(q);
+ QTextDocumentPrivate::get(q->document())->deleteObject(q);
return;
}
@@ -630,7 +622,7 @@ void QTextFramePrivate::remove_me()
*/
QTextFrame::iterator QTextFrame::begin() const
{
- const QTextDocumentPrivate *priv = docHandle();
+ const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(this);
int b = priv->blockMap().findNode(firstPosition());
int e = priv->blockMap().findNode(lastPosition()+1);
return iterator(const_cast<QTextFrame *>(this), b, b, e);
@@ -643,7 +635,7 @@ QTextFrame::iterator QTextFrame::begin() const
*/
QTextFrame::iterator QTextFrame::end() const
{
- const QTextDocumentPrivate *priv = docHandle();
+ const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(this);
int b = priv->blockMap().findNode(firstPosition());
int e = priv->blockMap().findNode(lastPosition()+1);
return iterator(const_cast<QTextFrame *>(this), e, b, e);
@@ -724,7 +716,7 @@ QTextBlock QTextFrame::iterator::currentBlock() const
{
if (!f)
return QTextBlock();
- return QTextBlock(f->docHandle(), cb);
+ return QTextBlock(QTextDocumentPrivate::get(f), cb);
}
/*!
@@ -734,7 +726,7 @@ QTextBlock QTextFrame::iterator::currentBlock() const
*/
QTextFrame::iterator &QTextFrame::iterator::operator++()
{
- const QTextDocumentPrivate *priv = f->docHandle();
+ const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(f);
const QTextDocumentPrivate::BlockMap &map = priv->blockMap();
if (cf) {
int end = cf->lastPosition() + 1;
@@ -772,7 +764,7 @@ QTextFrame::iterator &QTextFrame::iterator::operator++()
*/
QTextFrame::iterator &QTextFrame::iterator::operator--()
{
- const QTextDocumentPrivate *priv = f->docHandle();
+ const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(f);
const QTextDocumentPrivate::BlockMap &map = priv->blockMap();
if (cf) {
int start = cf->firstPosition() - 1;
@@ -1014,12 +1006,6 @@ bool QTextBlock::isValid() const
*/
/*!
- \fn QTextDocumentPrivate *QTextBlock::docHandle() const
-
- \internal
-*/
-
-/*!
\fn int QTextBlock::fragmentIndex() const
\internal
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index 215a76fb4d..22e5e4e593 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -75,8 +75,6 @@ public:
int objectIndex() const;
- QTextDocumentPrivate *docHandle() const;
-
protected:
QTextObject(QTextObjectPrivate &p, QTextDocument *doc);
@@ -287,7 +285,6 @@ public:
QTextBlock next() const;
QTextBlock previous() const;
- inline QTextDocumentPrivate *docHandle() const { return p; }
inline int fragmentIndex() const { return n; }
private:
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 155ec43c50..be13615aa6 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -1036,16 +1036,16 @@ bool QTextOdfWriter::writeAll()
writer.writeAttribute(officeNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
// add fragments. (for character formats)
- QTextDocumentPrivate::FragmentIterator fragIt = m_document->docHandle()->begin();
+ QTextDocumentPrivate::FragmentIterator fragIt = QTextDocumentPrivate::get(m_document)->begin();
QSet<int> formats;
- while (fragIt != m_document->docHandle()->end()) {
+ while (fragIt != QTextDocumentPrivate::get(m_document)->end()) {
const QTextFragmentData * const frag = fragIt.value();
formats << frag->format;
++fragIt;
}
// add blocks (for blockFormats)
- QTextDocumentPrivate::BlockMap &blocks = m_document->docHandle()->blockMap();
+ QTextDocumentPrivate::BlockMap &blocks = const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(m_document))->blockMap();
QTextDocumentPrivate::BlockMap::Iterator blockIt = blocks.begin();
while (blockIt != blocks.end()) {
const QTextBlockData * const block = blockIt.value();
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 39f26d5d42..ceef4d785a 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -121,7 +121,7 @@ void QTextTableCell::setFormat(const QTextCharFormat &format)
QTextCharFormat fmt = format;
fmt.clearProperty(QTextFormat::ObjectIndex);
fmt.setObjectType(QTextFormat::TableCellObject);
- QTextDocumentPrivate *p = table->docHandle();
+ QTextDocumentPrivate *p = const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(table));
QTextDocumentPrivate::FragmentIterator frag(&p->fragmentMap(), fragment);
QTextFormatCollection *c = p->formatCollection();
@@ -137,8 +137,8 @@ void QTextTableCell::setFormat(const QTextCharFormat &format)
*/
QTextCharFormat QTextTableCell::format() const
{
- QTextDocumentPrivate *p = table->docHandle();
- QTextFormatCollection *c = p->formatCollection();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(table);
+ const QTextFormatCollection *c = p->formatCollection();
QTextCharFormat fmt = c->charFormat(tableCellFormatIndex());
fmt.setObjectType(QTextFormat::TableCellObject);
@@ -154,7 +154,7 @@ QTextCharFormat QTextTableCell::format() const
*/
int QTextTableCell::tableCellFormatIndex() const
{
- QTextDocumentPrivate *p = table->docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(table);
return QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format;
}
@@ -248,7 +248,7 @@ QTextCursor QTextTableCell::lastCursorPosition() const
*/
int QTextTableCell::firstPosition() const
{
- QTextDocumentPrivate *p = table->docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(table);
return p->fragmentMap().position(fragment) + 1;
}
@@ -259,7 +259,7 @@ int QTextTableCell::firstPosition() const
*/
int QTextTableCell::lastPosition() const
{
- QTextDocumentPrivate *p = table->docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(table);
const QTextTablePrivate *td = table->d_func();
int index = table->d_func()->findCellIndex(fragment);
int f;
@@ -278,7 +278,7 @@ int QTextTableCell::lastPosition() const
*/
QTextFrame::iterator QTextTableCell::begin() const
{
- QTextDocumentPrivate *p = table->docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(table);
int b = p->blockMap().findNode(firstPosition());
int e = p->blockMap().findNode(lastPosition()+1);
return QTextFrame::iterator(const_cast<QTextTable *>(table), b, b, e);
@@ -291,7 +291,7 @@ QTextFrame::iterator QTextTableCell::begin() const
*/
QTextFrame::iterator QTextTableCell::end() const
{
- QTextDocumentPrivate *p = table->docHandle();
+ const QTextDocumentPrivate *p = QTextDocumentPrivate::get(table);
int b = p->blockMap().findNode(firstPosition());
int e = p->blockMap().findNode(lastPosition()+1);
return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e);
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 87e8af1382..d19e7e9ff9 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -1430,7 +1430,7 @@ QString QPlainTextEdit::anchorAt(const QPoint &pos) const
if (cursorPos < 0)
return QString();
- QTextDocumentPrivate *pieceTable = document()->docHandle();
+ QTextDocumentPrivate *pieceTable = QTextDocumentPrivate::get(document());
QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
return fmt.anchorHref();