summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 4902a42cd7..6156f56ae1 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1425,7 +1425,20 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
qreal xoff = fontMetrics.width(QLatin1Char(' '));
if (dir == Qt::LeftToRight)
xoff = -xoff - size.width();
- r.translate( xoff, (fontMetrics.height() / 2 - size.height() / 2));
+ r.translate( xoff, (fontMetrics.height() / 2) - (size.height() / 2));
+
+ // Prevent clipping the left side of the list decorator (on left to
+ // right layouts) and clipping the right side of the list
+ // decorator (on right to left layouts).
+ if ((r.left() < 0) && (dir == Qt::LeftToRight)) {
+ int horizontalOffset = -r.left();
+ r.translate(horizontalOffset, 0);
+ layout->setPosition(layout->position() + QPointF(horizontalOffset, 0));
+ } else if ((r.right() > document->pageSize().width()) && (dir == Qt::RightToLeft)) {
+ int horizontalOffset = r.right() - document->pageSize().width();
+ r.translate(-horizontalOffset, 0);
+ layout->setPosition(layout->position() - QPointF(horizontalOffset, 0));
+ }
painter->save();