10#if QT_CONFIG(cssparser)
11#include "private/qcssutil_p.h"
13#include "private/qguiapplication_p.h"
26#include "private/qfunctions_p.h"
28#include <QtCore/qpointer.h>
81 currentLayoutStruct(
nullptr), sizeDirty(true), layoutDirty(true)
125#ifndef QT_NO_CSSPARSER
155 return other < *
this;
218 Q_ASSERT(
v.userType() == QMetaType::Double ||
v.userType() == QMetaType::Float);
223#ifndef QT_NO_CSSPARSER
235#ifdef QT_NO_CSSPARSER
239#ifndef QT_NO_CSSPARSER
247#ifdef QT_NO_CSSPARSER
251#ifndef QT_NO_CSSPARSER
259#ifdef QT_NO_CSSPARSER
263#ifndef QT_NO_CSSPARSER
271#ifdef QT_NO_CSSPARSER
275#ifndef QT_NO_CSSPARSER
296 if (qobject_cast<QTextTable *>(
f))
300 f->setLayoutData(
data);
314 return f->firstPosition() >
f->lastPosition();
331 const int row = cell.
row();
332 const int rowSpan = cell.
rowSpan();
344 return !nextIt.atEnd()
345 && qobject_cast<QTextTable *>(nextIt.currentFrame())
350 && nextIt.currentFrame()->firstPosition() == block.
position() + 1
357 if (
it.currentFrame())
365 return qobject_cast<const QTextTable *>(previousFrame)
368 && previousFrame->lastPosition() == block.
position() - 1
374 return qobject_cast<const QTextTable *>(previousFrame)
377 && block.
text().
at(0) == QChar::LineSeparator
378 && previousFrame->lastPosition() == block.
position() - 1
450 return checkPoint.y <
y;
455 return checkPoint.positionInFrame <
pos;
462 if (!gradientRect.isNull()) {
464 m.
translate(gradientRect.left(), gradientRect.top());
465 m.
scale(gradientRect.width(), gradientRect.height());
470 p->setBrushOrigin(origin);
512 const QTextBlock &bl,
bool inRootFrame)
const;
537 bool withPageBreaks);
572 : fixedColumnWidth(-1),
574 currentLazyLayoutPosition(-1),
575 lazyLayoutStepSize(1000),
589 || y < 0 || y >
data(rootFrame)->
size.height)
590 return rootFrame->
begin();
594 return rootFrame->
begin();
612 const int blockPos =
map.position(block);
617 if (containingFrame != rootFrame) {
618 while (containingFrame->parentFrame() != rootFrame) {
623 it.cf = containingFrame;
639 const QFixedPoint relativePoint(point.
x -
fd->position.x, point.
y -
fd->position.y);
644 <<
"position" <<
fd->position.toPointF() <<
"size" <<
fd->size.toSizeF();
645 if (
frame != rootFrame) {
646 if (relativePoint.y < 0 || relativePoint.x < 0) {
650 }
else if (relativePoint.y >
fd->size.height || relativePoint.x >
fd->size.width) {
663 const int rows =
table->rows();
664 const int columns =
table->columns();
668 for (
int r = 0;
r < rows; ++
r) {
669 for (
int c = 0;
c < columns; ++
c) {
676 const QFixedPoint pointInCell = relativePoint - cellPos;
679 for (
int i = 0;
i < childFrames.size(); ++
i) {
695 const QList<QTextFrame *> childFrames =
frame->childFrames();
696 for (
int i = 0;
i < childFrames.size(); ++
i) {
708 if (
frame == rootFrame) {
714 if (
it.currentFrame())
715 *
position =
it.currentFrame()->firstPosition();
726 for (; !
it.atEnd(); ++
it) {
798 qCDebug(lcHit) <<
" checking block" << bl.position() <<
"point=" << point.
toPointF() <<
" tlrect" << textrect;
800 if (point.
y.
toReal() < textrect.top() - bl.blockFormat().topMargin()) {
803 }
else if (point.
y.
toReal() > textrect.bottom()) {
819 if (lr.top() >
pos.y()) {
821 }
else if (lr.bottom() <=
pos.y()) {
824 if (lr.left() <=
pos.x() && lr.right() >=
pos.x())
880 if (clipped.bottom() <= clipped.top())
901#ifndef QT_NO_CSSPARSER
910 for (
int i = paginator.topPage;
i <= paginator.bottomPage; ++
i) {
911 QRectF clipped = paginator.clipRect(
i);
912 if (!clipped.isValid())
915#ifndef QT_NO_CSSPARSER
931 if (turn_off_antialiasing)
938 const QBrush bg =
frame->frameFormat().background();
941 bgRect.
adjust((
fd->leftMargin +
fd->border).toReal(),
942 (
fd->topMargin +
fd->border).toReal(),
943 - (
fd->rightMargin +
fd->border).toReal(),
944 - (
fd->bottomMargin +
fd->border).toReal());
947 QPointF origin = bgRect.topLeft();
948 if (!
frame->parentFrame()) {
955 if (
fd->border != 0) {
960 const qreal leftEdge =
rect.left() +
fd->leftMargin.toReal();
962 const qreal topMargin =
fd->topMargin.toReal();
963 const qreal leftMargin =
fd->leftMargin.toReal();
964 const qreal bottomMargin =
fd->bottomMargin.toReal();
965 const qreal rightMargin =
fd->rightMargin.toReal();
970 fd->effectiveTopMargin.toReal(),
fd->effectiveBottomMargin.toReal(),
971 border,
frame->frameFormat().borderBrush(),
frame->frameFormat().borderStyle());
980 const int *selectedTableCells)
982 for (
int i = 0;
i < cell_context.selections.size(); ++
i) {
983 int row_start = selectedTableCells[
i * 4];
984 int col_start = selectedTableCells[
i * 4 + 1];
985 int num_rows = selectedTableCells[
i * 4 + 2];
986 int num_cols = selectedTableCells[
i * 4 + 3];
988 if (row_start != -1) {
989 if (
r >= row_start &&
r < row_start + num_rows
990 &&
c >= col_start &&
c < col_start + num_cols)
996 if (firstPosition == lastPosition)
999 cell_context.selections[
i].cursor.setPosition(firstPosition);
1002 cell_context.selections[
i].cursor.clearSelection();
1016#ifdef QT_NO_CSSPARSER
1021 if (!cell_context.clip.isValid())
1026#ifndef QT_NO_CSSPARSER
1049 if (
fd->layoutDirty)
1059 && (off.
y() >
context.clip.bottom() || off.
y() +
fd->size.height.toReal() <
context.clip.top()
1060 || off.
x() >
context.clip.right() || off.
x() +
fd->size.width.toReal() <
context.clip.left()))
1068 QPointF offsetOfRepaintedCursorBlock = off;
1071 const QRectF frameRect(off,
fd->size.toSizeF());
1074 const int rows =
table->rows();
1075 const int columns =
table->columns();
1078 QVarLengthArray<int> selectedTableCells(
context.selections.size() * 4);
1079 for (
int i = 0;
i <
context.selections.size(); ++
i) {
1081 int row_start = -1, col_start = -1, num_rows = -1, num_cols = -1;
1083 if (
s.cursor.currentTable() ==
table)
1084 s.cursor.selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
1086 selectedTableCells[
i * 4] = row_start;
1087 selectedTableCells[
i * 4 + 1] = col_start;
1088 selectedTableCells[
i * 4 + 2] = num_rows;
1089 selectedTableCells[
i * 4 + 3] = num_cols;
1093 if (pageHeight <= 0)
1098 while (parentFrame) {
1099 absYPos +=
data(parentFrame)->position.y;
1102 const int tableStartPage = (absYPos / pageHeight).truncate();
1103 const int tableEndPage = ((absYPos + td->
size.
height) / pageHeight).truncate();
1111 const int headerRowCount =
qMin(
table->format().headerRowCount(), rows - 1);
1112 int page = tableStartPage + 1;
1113 while (
page <= tableEndPage) {
1116 for (
int r = 0;
r < headerRowCount; ++
r) {
1117 for (
int c = 0;
c < columns; ++
c) {
1128 &offsetOfRepaintedCursorBlock);
1151 for (
int c = 0;
c < columns; ++
c) {
1153 firstRow =
qMin(firstRow, cell.
row());
1156 for (
int r = firstRow;
r < lastRow; ++
r) {
1157 for (
int c = 0;
c < columns; ++
c) {
1168 &offsetOfRepaintedCursorBlock);
1180 QList<QTextFrame *> floats;
1181 const int numFloats =
fd->floats.size();
1182 floats.reserve(numFloats);
1183 for (
int i = 0;
i < numFloats; ++
i)
1184 floats.append(
fd->floats.at(
i));
1189 if (cursorBlockNeedingRepaint.isValid()) {
1192 const int cursorPos =
context.cursorPosition - cursorBlockNeedingRepaint.position();
1193 cursorBlockNeedingRepaint.layout()->drawCursor(
painter, offsetOfRepaintedCursorBlock,
1201#ifndef QT_NO_CSSPARSER
1286 int col = cell.
column() + dc;
1287 int row = cell.
row() + dr;
1289 if (col < 0 || row < 0 || col >=
table->columns() ||
row >=
table->rows())
1314 return cell.
row() ==
1315 competingCell.row() + (competingCellEdge ==
QCss::BottomEdge ? competingCell.rowSpan() : 0);
1318 competingCell.row() + (competingCellEdge ==
QCss::TopEdge ? 0 : competingCell.rowSpan());
1321 competingCell.column() + (competingCellEdge ==
QCss::RightEdge ? competingCell.columnSpan() : 0);
1324 competingCell.column() + (competingCellEdge ==
QCss::LeftEdge ? 0 : competingCell.columnSpan());
1326 Q_UNREACHABLE_RETURN(
false);
1349 const bool outermost =
1383 bool mustCheckThirdCell =
false;
1415 if (mustCheckThirdCell)
1426 bool couldHaveContinuation,
1432 if (competingEdgeData > edgeData) {
1433 *maxCompetingEdgeData = competingEdgeData;
1434 }
else if (competingEdgeData.width == edgeData.
width) {
1435 if ((
isSameAxis(edgeData.
edge, competingEdge) && couldHaveContinuation)
1437 *maxCompetingEdgeData = competingEdgeData;
1441 if (maxOrthogonalEdgeData && competingEdgeData.width > maxOrthogonalEdgeData->width)
1442 *maxOrthogonalEdgeData = competingEdgeData;
1448 return p->scaleToDevice(
w.width) / 2.0;
1493 bool couldHaveContinuation,
1494 bool ignoreEdgesAbove)
1512 &maxCompetingEdgeData, &maxOrthogonalEdgeData);
1518 if (competingCell.isValid()) {
1520 &maxCompetingEdgeData,
nullptr);
1527 if (competingCell.isValid() &&
sharesAxis(cell, orthogonalEdge, competingCell, orthogonalEdge)) {
1529 &maxCompetingEdgeData, &maxOrthogonalEdgeData);
1535 bool hasPriority = edgeData > maxCompetingEdgeData;
1542 return hasPriority ? 0 :
p->scaleToDevice(maxOrthogonalEdgeData.width);
1565 int forceHeaderRow,
bool adjustTopAnchor,
bool adjustBottomAnchor,
1566 bool ignoreEdgesAbove)
1573 if (edgeData.
width == 0)
1581 borderStyle =
table->format().borderStyle();
1585 switch (edgeData.
edge) {
1588 borderStyle =
fmt.topBorderStyle();
1592 borderStyle =
fmt.bottomBorderStyle();
1596 borderStyle =
fmt.leftBorderStyle();
1600 borderStyle =
fmt.rightBorderStyle();
1616 if (forceHeaderRow != -1)
1617 cellOrHeader =
table->cellAt(forceHeaderRow, cell.
column());
1622 wv =
p->scaleToDevice(edgeData.
width);
1623 p1 = borderRect.topLeft()
1625 p2 = borderRect.topRight()
1629 wv =
p->scaleToDevice(edgeData.
width);
1630 p1 = borderRect.bottomLeft()
1632 p2 = borderRect.bottomRight()
1636 wh =
p->scaleToDevice(edgeData.
width);
1637 p1 = borderRect.topLeft()
1640 false, ignoreEdgesAbove))
1642 p2 = borderRect.bottomLeft()
1647 wh =
p->scaleToDevice(edgeData.
width);
1648 p1 = borderRect.topRight()
1651 false, ignoreEdgesAbove))
1653 p2 = borderRect.bottomRight()
1687#ifdef COLLAPSE_DEBUG
1701#ifndef QT_NO_CSSPARSER
1705 const int headerRowCount =
qMin(
table->format().headerRowCount(),
table->rows() - 1);
1706 if (headerRowCount > 0 && cell.
row() >= headerRowCount)
1715 for (
int page = paginator.topPage;
page <= paginator.bottomPage; ++
page) {
1716 const QRectF clipped = paginator.clipRect(
page);
1717 if (!clipped.isValid())
1721 const int lastHeaderRow =
table->format().headerRowCount() - 1;
1722 const bool tableHasHeader =
table->format().headerRowCount() > 0;
1723 const bool isHeaderRow = cell.
row() <
table->format().headerRowCount();
1724 const bool isFirstRow = cell.
row() == lastHeaderRow + 1;
1726 const bool previousRowOnPreviousPage = !isFirstRow
1730 topMarginAfterPageBreak,
1733 const bool nextRowOnNextPage = !isLastRow
1736 topMarginAfterPageBreak,
1739 const bool rowStartsOnPage =
page == paginator.topPage;
1740 const bool rowEndsOnPage =
page == paginator.bottomPage;
1741 const bool rowStartsOnPageTop = !tableHasHeader
1743 && previousRowOnPreviousPage;
1744 const bool rowStartsOnPageBelowHeader = tableHasHeader
1746 && previousRowOnPreviousPage;
1749 ? !isHeaderRow && (!rowStartsOnPage || rowStartsOnPageBelowHeader)
1752 ? !isHeaderRow && (!rowEndsOnPage || nextRowOnNextPage)
1755 ? !tableHasHeader && !rowStartsOnPage
1757 const bool doNotAdjustBottomAnchor = suppressBottomBorder;
1759 if (!suppressTopBorder) {
1761 -1,
true,
true, rowStartsOnPageTop);
1765 suppressTopBorder ? lastHeaderRow : -1,
1766 !doNotAdjustTopAnchor,
1767 !doNotAdjustBottomAnchor,
1768 rowStartsOnPageTop);
1770 suppressTopBorder ? lastHeaderRow : -1,
1771 !doNotAdjustTopAnchor,
1772 !doNotAdjustBottomAnchor,
1773 rowStartsOnPageTop);
1775 if (!suppressBottomBorder) {
1777 -1,
true,
true,
false);
1781 if (turn_off_antialiasing)
1801 int cr = cell.
row();
1817 const int headerRowCount =
qMin(
table->format().headerRowCount(),
table->rows() - 1);
1818 if (
r >= headerRowCount)
1840 switch (cellBorder) {
1858 border,
table->format().borderBrush(), cellBorder);
1868 const int topPage = pageHeight > 0 ?
static_cast<int>(cellRect.
top() / pageHeight) : 0;
1869 const int bottomPage = pageHeight > 0 ?
static_cast<int>((cellRect.
bottom()) / pageHeight) : 0;
1871 if (topPage == bottomPage)
1874 for (
int i = topPage;
i <= bottomPage; ++
i) {
1877 if (topPage != bottomPage) {
1878 const qreal top =
qMax(
i * pageHeight + topMargin, cell_context.clip.top());
1879 const qreal bottom =
qMin((
i + 1) * pageHeight - bottomMargin, cell_context.clip.bottom());
1881 clipped.setTop(
qMax(clipped.top(),
top));
1882 clipped.setBottom(
qMin(clipped.bottom(),
bottom));
1884 if (clipped.bottom() <= clipped.top())
1897 if (cellBorderConfigured)
1903 cellRect.
top() + (topPadding + verticalOffset).toReal());
1909 if (repaintBlock.isValid()) {
1910 *cursorBlockNeedingRepaint = repaintBlock;
1911 *cursorBlockOffset = cellPos;
1922 const bool inRootFrame = (!
it.atEnd() &&
it.parentFrame() &&
it.parentFrame()->parentFrame() ==
nullptr);
1925 if (inRootFrame &&
context.clip.isValid()) {
1932 for (; !
it.atEnd(); ++
it) {
1936 int currentPosInDoc;
1938 currentPosInDoc =
c->firstPosition();
1940 currentPosInDoc =
it.currentBlock().position();
1949 && currentPosInDoc >= lastVisibleCheckPoint->positionInFrame
1970 && previousBlock.contains(
context.cursorPosition)
1972 *cursorBlockNeedingRepaint = previousBlock;
1975 previousBlock =
it.currentBlock();
1979 for (
int i = 0;
i < floats.size(); ++
i) {
1985 const int pos =
frame->firstPosition() - 1;
1997 const QTextBlock &bl,
bool inRootFrame)
const
2002 if (!bl.isVisible() || (
context.clip.isValid() && (
r.bottom() <
context.clip.y() ||
r.top() >
context.clip.bottom())))
2017 rect.setRight((
fd->size.width -
fd->rightMargin).toReal());
2025 QList<QTextLayout::FormatRange> selections;
2026 int blpos = bl.position();
2027 int bllen = bl.length();
2029 for (
int i = 0;
i <
context.selections.size(); ++
i) {
2031 const int selStart =
range.cursor.selectionStart() - blpos;
2032 const int selEnd =
range.cursor.selectionEnd() - blpos;
2033 if (selStart < bllen && selEnd > 0
2034 && selEnd > selStart) {
2037 o.length = selEnd - selStart;
2039 selections.append(
o);
2041 && bl.contains(
range.cursor.position())) {
2048 if (
o.start +
o.length == bllen - 1)
2051 selections.append(
o);
2053 if (selStart < 0 && selEnd >= 1)
2054 selFormat = &
range.format;
2070 && ((
context.cursorPosition >= blpos &&
context.cursorPosition < blpos + bllen)
2072 int cpos =
context.cursorPosition;
2087 if (bl.length() == 1)
2088 y =
r.top() +
r.height() / 2;
2090 const qreal middleX =
r.left() +
r.width() / 2;
2106 if (
q->paintDevice())
2112 int style = lf.
style();
2120 if (
layout->lineCount() == 0)
2160 xoff = -xoff -
size.width();
2168 if (selectionFormat) {
2183 r.adjust(-adj, 0, -adj, 0);
2185 if (selectionFormat)
2205 layout.setCacheEnabled(
true);
2212 line.setLeadingIncluded(
true);
2246 if (
it.currentFrame()) {
2247 return data(
it.currentFrame())->position.y;
2251 if (
layout->lineCount() == 0)
2265 QFixed absoluteTableY,
bool withPageBreaks)
2267 qCDebug(lcTable) <<
"layoutCell";
2270 layoutStruct.minimumWidth = 0;
2275 if (withPageBreaks) {
2276 layoutStruct.frameY = absoluteTableY + td->
rowPositions.
at(cell.
row()) + topPadding;
2278 layoutStruct.x_left = 0;
2279 layoutStruct.x_right =
width;
2289 if (layoutStruct.pageHeight < 0 || !withPageBreaks)
2291 const int currentPage = layoutStruct.currentPage();
2298#ifndef QT_NO_CSSPARSER
2299 const int headerRowCount =
t->format().headerRowCount();
2308 layoutStruct.pageBottom = (currentPage + 1) * layoutStruct.pageHeight - layoutStruct.pageBottomMargin;
2310 layoutStruct.fullLayout =
true;
2312 QFixed pageTop = currentPage * layoutStruct.pageHeight + layoutStruct.pageTopMargin - layoutStruct.frameY;
2313 layoutStruct.y =
qMax(layoutStruct.y, pageTop);
2316 for (
int i = 0;
i < childFrames.size(); ++
i) {
2330 for (
int i = 0;
i < childFrames.size(); ++
i) {
2342 layoutStruct.maximumWidth =
qMax(layoutStruct.maximumWidth, floatMinWidth);
2343 layoutStruct.minimumWidth =
qMax(layoutStruct.minimumWidth, floatMinWidth);
2347 data(
t)->floats.clear();
2351 return layoutStruct;
2354#ifndef QT_NO_CSSPARSER
2357 qreal *outerBorders)
2360 if (
w.width > outerBorders[edge])
2361 outerBorders[edge] =
w.width;
2367 qCDebug(lcTable) <<
"layoutTable from" << layoutFrom <<
"to" << layoutTo <<
"parentY" << parentY;
2370 const int rows =
table->rows();
2371 const int columns =
table->columns();
2385 QList<QTextLength> columnWidthConstraints =
fmt.columnWidthConstraints();
2386 if (columnWidthConstraints.size() != columns)
2387 columnWidthConstraints.resize(columns);
2388 Q_ASSERT(columnWidthConstraints.size() == columns);
2402#ifndef QT_NO_CSSPARSER
2407 outerBorders[
i] = 0;
2409 for (
int r = 0;
r < rows; ++
r) {
2411 for (
int c = 0;
c < columns; ++
c)
2414 if (
r == rows - 1) {
2415 for (
int c = 0;
c < columns; ++
c)
2438recalc_minmax_widths:
2442 remainingWidth -= columns * 2 * td->
borderCell;
2444 remainingWidth -= (columns - 1) * cellSpacing;
2446 remainingWidth -= 2 * cellSpacing;
2454 const QFixed initialTotalWidth = remainingWidth;
2469 for (
int i = 0;
i < columns; ++
i) {
2474 if (cspan > 1 &&
i != cell.
column())
2479 const QFixed widthPadding = leftPadding + rightPadding;
2485 layoutTo, td, absoluteTableY,
2489 QFixed widthToDistribute = layoutStruct.minimumWidth + widthPadding;
2490 for (
int n = 0;
n < cspan; ++
n) {
2491 const int col =
i +
n;
2492 QFixed w = widthToDistribute / (cspan -
n);
2496 if (widthToDistribute <= 0)
2501 if (layoutStruct.maximumWidth !=
QFIXED_MAX) {
2503 maxW = layoutStruct.maximumWidth + widthPadding;
2505 maxW =
qMax(
maxW, layoutStruct.maximumWidth + widthPadding);
2516 widthToDistribute =
maxW;
2517 for (
int n = 0;
n < cspan; ++
n) {
2518 const int col =
i +
n;
2519 QFixed w = widthToDistribute / (cspan -
n);
2524 if (widthToDistribute <= 0)
2533 int variableCols = 0;
2534 QFixed totalMinWidth = 0;
2535 for (
int i = 0;
i < columns; ++
i) {
2540 qCDebug(lcTable) <<
"column" <<
i <<
"has width constraint" << td->
minWidths.
at(
i) <<
"px, remaining width now" << remainingWidth;
2548 qCDebug(lcTable) <<
"column" <<
i <<
"has variable width, min" << td->
minWidths.
at(
i) <<
"remaining width now" << remainingWidth;
2555 const QFixed totalPercentagedWidth = initialTotalWidth * totalPercentage / 100;
2556 QFixed remainingMinWidths = totalMinWidth;
2557 for (
int i = 0;
i < columns; ++
i) {
2562 const QFixed percentWidth = totalPercentagedWidth * allottedPercentage / totalPercentage;
2563 QFixed maxWidth = remainingWidth - remainingMinWidths;
2569 qCDebug(lcTable) <<
"column" <<
i <<
"has width constraint" << columnWidthConstraints.at(
i).rawValue()
2570 <<
"%, allocated width" << td->
widths[
i] <<
"remaining width now" << remainingWidth;
2577 if (variableCols > 0 && remainingWidth > 0) {
2578 QVarLengthArray<int> columnsWithProperMaxSize;
2579 for (
int i = 0;
i < columns; ++
i)
2582 columnsWithProperMaxSize.append(
i);
2584 QFixed lastRemainingWidth = remainingWidth;
2585 while (remainingWidth > 0) {
2586 for (
int k = 0; k < columnsWithProperMaxSize.size(); ++k) {
2587 const int col = columnsWithProperMaxSize[k];
2588 const int colsLeft = columnsWithProperMaxSize.size() - k;
2591 remainingWidth -=
w;
2593 if (remainingWidth == lastRemainingWidth)
2595 lastRemainingWidth = remainingWidth;
2598 if (remainingWidth > 0
2601 const QFixed widthPerAnySizedCol = remainingWidth / variableCols;
2602 for (
int col = 0; col < columns; ++col) {
2604 td->
widths[col] += widthPerAnySizedCol;
2615 for (
int i = 0;
i < columns; ++
i) {
2624 for (
int i = 1;
i < columns; ++
i)
2636 goto recalc_minmax_widths;
2649 bool haveRowSpannedCells =
false;
2652 QList<QFixed> cellHeights;
2653 cellHeights.reserve(rows * columns);
2656 if (pageHeight <= 0)
2659 QList<QFixed> heightToDistribute;
2660 heightToDistribute.resize(columns);
2663 const int headerRowCount =
qMin(
table->format().headerRowCount(), rows - 1);
2665 bool hasDroppedTable =
false;
2671 for (
int r = 0;
r < rows; ++
r) {
2674 const int tableStartPage = (absoluteTableY / pageHeight).truncate();
2675 const int currentPage = ((td->
rowPositions.
at(
r) + absoluteTableY) / pageHeight).truncate();
2678 const QFixed nextPageTop = pageTop + pageHeight;
2685 bool dropRowToNextPage =
true;
2686 int cellCountBeforeRow = cellHeights.
size();
2696 if (r <= headerRowCount && rowStartPage > tableStartPage && !hasDroppedTable) {
2698 cellHeights.
clear();
2700 hasDroppedTable =
true;
2705 int rowCellCount = 0;
2706 for (
int c = 0;
c < columns; ++
c) {
2708 const int rspan = cell.
rowSpan();
2711 if (cspan > 1 && cell.
column() !=
c)
2715 haveRowSpannedCells =
true;
2717 const int cellRow = cell.
row();
2720 if (cellRow + rspan - 1 ==
r)
2730 const QFixed widthPadding = leftPadding + rightPadding;
2736 layoutFrom, layoutTo,
2740 const QFixed height = (layoutStruct.y + bottomPadding + topPadding).round();
2743 heightToDistribute[
c] =
height + dropDistance;
2747 cellHeights.append(layoutStruct.y);
2750 if (childPos < pageBottom)
2751 dropRowToNextPage =
false;
2754 if (rowCellCount > 0 && dropRowToNextPage) {
2758 dropRowToNextPage =
false;
2759 cellHeights.
resize(cellCountBeforeRow);
2760 if (
r > headerRowCount)
2765 if (haveRowSpannedCells) {
2767 for (
int c = 0;
c < columns; ++
c)
2768 heightToDistribute[
c] =
qMax(heightToDistribute.at(
c) - effectiveHeight - dropDistance,
QFixed(0));
2771 if (
r == headerRowCount - 1) {
2784 for (
int r = 0;
r < rows; ++
r) {
2785 for (
int c = 0;
c < columns; ++
c) {
2790 const int rowSpan = cell.
rowSpan();
2797 switch (cellFormat.verticalAlignment()) {
2799 offset = (availableHeight - cellHeight) / 2;
2802 offset = availableHeight - cellHeight;
2809 for (
int cd = 0; cd < cell.
columnSpan(); ++cd) {
2810 const int index = (
c + cd) + (
r +
rd) * columns;
2818 for (
int i = 0;
i < columns; ++
i) {
2824 for (
int i = 0;
i < columns; ++
i) {
2850 fd->layoutDirty =
true;
2860 layoutStruct->pendingFloats.append(
frame);
2866 bool frameSpansIntoNextPage = (
y + layoutStruct->frameY +
fd->size.height > layoutStruct->pageBottom);
2867 if (frameSpansIntoNextPage &&
fd->size.height <= layoutStruct->pageHeight) {
2868 layoutStruct->newPage();
2869 y = layoutStruct->y;
2871 frameSpansIntoNextPage =
false;
2874 y =
findY(
y, layoutStruct,
fd->size.width);
2883 fd->position.x =
right -
fd->size.width;
2887 layoutStruct->minimumWidth =
qMax(layoutStruct->minimumWidth,
fd->minimumWidth);
2888 layoutStruct->maximumWidth =
qMin(layoutStruct->maximumWidth,
fd->maximumWidth);
2891 fd->layoutDirty =
false;
2895 if (qobject_cast<QTextTable *>(
frame) !=
nullptr)
2896 fd->sizeDirty = frameSpansIntoNextPage;
2901 qCDebug(lcLayout,
"layoutFrame (%d--%d), parent=%p",
f->firstPosition(),
f->lastPosition(),
f->parentFrame());
2924 qCDebug(lcLayout,
"layoutFrame (%d--%d), parent=%p",
f->firstPosition(),
f->lastPosition(),
f->parentFrame());
2930 bool fullLayout =
false;
2935 if (tm !=
fd->topMargin) {
2940 if (bm !=
fd->bottomMargin) {
2941 fd->bottomMargin = bm;
2947 if (
b !=
fd->border) {
2952 if (
p !=
fd->padding) {
2965 if (qobject_cast<QTextTable *>(
parent)) {
2971 fd->effectiveTopMargin =
fd->topMargin +
fd->border +
fd->padding;
2972 fd->effectiveBottomMargin =
fd->bottomMargin +
fd->border +
fd->padding;
2975 newContentsWidth = frameWidth - 2*(
fd->border +
fd->padding)
2976 -
fd->leftMargin -
fd->rightMargin;
2978 if (frameHeight != -1) {
2979 fd->contentsHeight = frameHeight - 2*(
fd->border +
fd->padding)
2980 -
fd->topMargin -
fd->bottomMargin;
2982 fd->contentsHeight = frameHeight;
2992 fd->contentsWidth = newContentsWidth;
2999 fd->contentsWidth = newContentsWidth;
3003 layoutStruct.x_left =
fd->leftMargin +
fd->border +
fd->padding;
3004 layoutStruct.x_right = layoutStruct.x_left + newContentsWidth;
3005 layoutStruct.y =
fd->topMargin +
fd->border +
fd->padding;
3006 layoutStruct.frameY = parentY +
fd->position.y;
3007 layoutStruct.contentsWidth = 0;
3008 layoutStruct.minimumWidth = 0;
3010 layoutStruct.fullLayout = fullLayout || (
fd->oldContentsWidth != newContentsWidth);
3012 qCDebug(lcLayout) <<
"layoutStruct: x_left" << layoutStruct.x_left <<
"x_right" << layoutStruct.x_right
3013 <<
"fullLayout" << layoutStruct.fullLayout;
3014 fd->oldContentsWidth = newContentsWidth;
3017 if (layoutStruct.pageHeight < 0)
3020 const int currentPage = layoutStruct.pageHeight == 0 ? 0 : (layoutStruct.frameY / layoutStruct.pageHeight).truncate();
3021 layoutStruct.pageTopMargin =
fd->effectiveTopMargin;
3022 layoutStruct.pageBottomMargin =
fd->effectiveBottomMargin;
3023 layoutStruct.pageBottom = (currentPage + 1) * layoutStruct.pageHeight - layoutStruct.pageBottomMargin;
3025 if (!
f->parentFrame())
3031 QFixed maxChildFrameWidth = 0;
3032 QList<QTextFrame *>
children =
f->childFrames();
3036 maxChildFrameWidth =
qMax(maxChildFrameWidth, cd->
size.
width);
3039 const QFixed marginWidth = 2*(
fd->border +
fd->padding) +
fd->leftMargin +
fd->rightMargin;
3040 if (!
f->parentFrame()) {
3041 idealWidth =
qMax(maxChildFrameWidth, layoutStruct.contentsWidth).toReal();
3045 QFixed actualWidth =
qMax(newContentsWidth,
qMax(maxChildFrameWidth, layoutStruct.contentsWidth));
3046 fd->contentsWidth = actualWidth;
3047 if (newContentsWidth <= 0) {
3048 fd->contentsWidth = newContentsWidth;
3051 fd->minimumWidth = layoutStruct.minimumWidth;
3052 fd->maximumWidth = layoutStruct.maximumWidth;
3054 fd->size.height =
fd->contentsHeight == -1
3055 ? layoutStruct.y +
fd->border +
fd->padding +
fd->bottomMargin
3056 :
fd->contentsHeight + 2*(
fd->border +
fd->padding) +
fd->topMargin +
fd->bottomMargin;
3057 fd->size.width = actualWidth + marginWidth;
3058 fd->sizeDirty =
false;
3059 if (layoutStruct.updateRectForFloats.isValid())
3060 layoutStruct.updateRect |= layoutStruct.updateRectForFloats;
3061 return layoutStruct.updateRect;
3067 qCDebug(lcLayout) <<
"layoutFlow from=" << layoutFrom <<
"to=" << layoutTo;
3070 fd->currentLayoutStruct = layoutStruct;
3078 if (!redoCheckPoints) {
3084 layoutStruct->y = checkPoint->y;
3085 layoutStruct->frameY = checkPoint->frameY;
3086 layoutStruct->minimumWidth = checkPoint->minimumWidth;
3087 layoutStruct->maximumWidth = checkPoint->maximumWidth;
3088 layoutStruct->contentsWidth = checkPoint->contentsWidth;
3090 if (layoutStruct->pageHeight > 0) {
3091 int page = layoutStruct->currentPage();
3092 layoutStruct->pageBottom = (
page + 1) * layoutStruct->pageHeight - layoutStruct->pageBottomMargin;
3103 redoCheckPoints =
true;
3107 if (redoCheckPoints) {
3110 cp.
y = layoutStruct->y;
3111 cp.
frameY = layoutStruct->frameY;
3120 QTextBlockFormat previousBlockFormat = previousIt.currentBlock().blockFormat();
3122 QFixed maximumBlockWidth = 0;
3123 while (!
it.atEnd() && layoutStruct->absoluteY() <
QFIXED_MAX) {
3127 if (
it.currentFrame())
3128 docPos =
it.currentFrame()->firstPosition();
3130 docPos =
it.currentBlock().position();
3136 if (
left == layoutStruct->x_left &&
right == layoutStruct->x_right) {
3138 p.
y = layoutStruct->y;
3139 p.frameY = layoutStruct->frameY;
3140 p.positionInFrame = docPos;
3141 p.minimumWidth = layoutStruct->minimumWidth;
3142 p.maximumWidth = layoutStruct->maximumWidth;
3143 p.contentsWidth = layoutStruct->contentsWidth;
3162 layoutStruct->newPage();
3170 layoutStruct->y =
findY(layoutStruct->y, layoutStruct, cd->
size.
width);
3197 layoutFrame(
c, layoutFrom, layoutTo, layoutStruct->frameY);
3200 absoluteChildPos += layoutStruct->frameY;
3203 if (absoluteChildPos > layoutStruct->pageBottom) {
3204 layoutStruct->newPage();
3205 pos.y = layoutStruct->y;
3213 layoutFrame(
c, layoutFrom, layoutTo, layoutStruct->frameY);
3228 const int page = layoutStruct->currentPage();
3229 layoutStruct->pageBottom = (
page + 1) * layoutStruct->pageHeight - layoutStruct->pageBottomMargin;
3234 layoutStruct->newPage();
3250 if (frameRect == oldFrameRect && updateRect.
isValid())
3253 updateRect = frameRect;
3255 layoutStruct->addUpdateRectForFloat(updateRect);
3256 if (oldFrameRect.isValid())
3257 layoutStruct->addUpdateRectForFloat(oldFrameRect);
3260 layoutStruct->minimumWidth =
qMax(layoutStruct->minimumWidth, cd->
minimumWidth);
3261 layoutStruct->maximumWidth =
qMin(layoutStruct->maximumWidth, cd->
maximumWidth);
3267 if (!previousIt.atEnd() && previousIt !=
it)
3268 lastIt = previousIt;
3276 layoutStruct->newPage();
3278 const QFixed origY = layoutStruct->y;
3279 const QFixed origPageBottom = layoutStruct->pageBottom;
3280 const QFixed origMaximumWidth = layoutStruct->maximumWidth;
3281 layoutStruct->maximumWidth = 0;
3284 if (lastIt.currentBlock().isValid())
3285 previousBlockFormatPtr = &previousBlockFormat;
3288 layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr);
3298 const QTextBlock lastBlock = lastIt.currentBlock();
3301 layoutStruct->pageBottom = origPageBottom;
3312 layoutStruct->y = origY;
3313 layoutStruct->pageBottom = origPageBottom;
3323 if (layoutStruct->pageBottom == origPageBottom) {
3324 layoutStruct->y -=
height;
3328 layoutStruct->y = origY -
height;
3329 layoutStruct->pageBottom = origPageBottom;
3330 layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr);
3333 if (
layout->lineCount() > 0) {
3337 layout->lineAt(0).setPosition(linePos -
layout->position());
3342 layoutStruct->newPage();
3345 maximumBlockWidth =
qMax(maximumBlockWidth, layoutStruct->maximumWidth);
3346 layoutStruct->maximumWidth = origMaximumWidth;
3347 previousBlockFormat = blockFormat;
3350 if (layoutStruct->maximumWidth ==
QFIXED_MAX && maximumBlockWidth > 0)
3351 layoutStruct->maximumWidth = maximumBlockWidth;
3353 layoutStruct->maximumWidth =
qMax(layoutStruct->maximumWidth, maximumBlockWidth);
3358 if (!qobject_cast<QTextTable *>(layoutStruct->frame)) {
3359 QList<QTextFrame *>
children = layoutStruct->frame->childFrames();
3363 layoutStruct->y =
qMax(layoutStruct->y,
fd->position.y +
fd->size.height);
3370 if (!
fd->floats.isEmpty())
3373 if (
it.atEnd() || layoutStruct->absoluteY() >=
QFIXED_MAX) {
3377 cp.
y = layoutStruct->y;
3392 fd->currentLayoutStruct =
nullptr;
3405 *lineBreakHeight = *lineBottom;
3413 *lineAdjustment = 0;
3421 if (!bl.isVisible())
3425 const int blockLength = bl.length();
3427 qCDebug(lcLayout) <<
"layoutBlock from=" << layoutFrom <<
"to=" << layoutTo
3428 <<
"; width" << layoutStruct->x_right - layoutStruct->x_left <<
"(maxWidth is btw" << tl->
maximumWidth() <<
')';
3430 if (previousBlockFormat) {
3432 if (margin > 0 &&
q->paintDevice()) {
3455 if (layoutStruct->fullLayout
3456 || (blockPosition + blockLength > layoutFrom && blockPosition <= layoutTo)
3460 qCDebug(lcLayout) <<
"do layout";
3479 const QFixed cy = layoutStruct->y;
3480 const QFixed l = layoutStruct->x_left + totalLeftMargin;
3481 const QFixed r = layoutStruct->x_right - totalRightMargin;
3485 bool firstLine =
true;
3488 if (!
line.isValid())
3490 line.setLeadingIncluded(
true);
3500 left += text_indent;
3502 right -= text_indent;
3517 left += text_indent;
3519 right -= text_indent;
3523 layoutStruct->pendingFloats.clear();
3527 if (haveWordOrAnyWrapMode) {
3532 layoutStruct->pendingFloats.clear();
3539 left += text_indent;
3541 right -= text_indent;
3544 if (haveWordOrAnyWrapMode) {
3552 QFixed lineBreakHeight, lineHeight, lineAdjustment, lineBottom;
3557 while (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom &&
3558 layoutStruct->contentHeight() >= lineBreakHeight) {
3559 if (layoutStruct->pageHeight ==
QFIXED_MAX) {
3560 layoutStruct->y =
QFIXED_MAX - layoutStruct->frameY;
3564 layoutStruct->newPage();
3570 left += text_indent;
3572 right -= text_indent;
3575 line.setPosition(
QPointF((
left - layoutStruct->x_left).toReal(), (layoutStruct->y - cy - lineAdjustment).toReal()));
3576 bottom = layoutStruct->y + lineBottom;
3577 layoutStruct->y += lineHeight;
3578 layoutStruct->contentsWidth
3579 = qMax<QFixed>(layoutStruct->contentsWidth,
QFixed::fromReal(
line.x() +
line.naturalTextWidth()) + totalRightMargin);
3582 for (
int i = 0;
i < layoutStruct->pendingFloats.size(); ++
i) {
3586 layoutStruct->pendingFloats.clear();
3588 layoutStruct->y =
qMax(layoutStruct->y,
bottom);
3593 for (
int i = 0;
i < cnt; ++
i) {
3594 qCDebug(lcLayout) <<
"going to move text line" <<
i;
3596 layoutStruct->contentsWidth
3599 QFixed lineBreakHeight, lineHeight, lineAdjustment, lineBottom;
3604 if (layoutStruct->pageHeight !=
QFIXED_MAX) {
3605 if (layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom)
3606 layoutStruct->newPage();
3609 bottom = layoutStruct->y + lineBottom;
3610 layoutStruct->y += lineHeight;
3612 layoutStruct->y =
qMax(layoutStruct->y,
bottom);
3613 if (layoutStruct->updateRect.isValid()
3614 && blockLength > 1) {
3615 if (layoutFrom >= blockPosition + blockLength) {
3619 layoutStruct->updateRect.setTop(
qMax(layoutStruct->updateRect.top(), layoutStruct->y.toReal()));
3620 }
else if (layoutTo < blockPosition) {
3626 layoutStruct->updateRect.setBottom(
qMin(layoutStruct->updateRect.bottom(), tl->
position().
y()));
3628 layoutStruct->updateRect.setBottom(
qreal(INT_MAX));
3634 const QFixed margins = totalLeftMargin + totalRightMargin;
3640 if (layoutStruct->maximumWidth ==
QFIXED_MAX)
3641 layoutStruct->maximumWidth =
maxW;
3643 layoutStruct->maximumWidth =
qMax(layoutStruct->maximumWidth,
maxW);
3651 *
left = layoutStruct->x_left;
3652 *
right = layoutStruct->x_right;
3654 for (
int i = 0;
i < lfd->floats.size(); ++
i) {
3656 if (!
fd->layoutDirty) {
3657 if (
fd->position.y <=
y &&
fd->position.y +
fd->size.height >
y) {
3672 requiredWidth =
qMin(requiredWidth, layoutStruct->x_right - layoutStruct->x_left);
3684 for (
int i = 0;
i < lfd->floats.size(); ++
i) {
3686 if (!
fd->layoutDirty) {
3687 if (
fd->position.y <= yFrom &&
fd->position.y +
fd->size.height > yFrom)
3688 newY =
qMin(newY,
fd->position.y +
fd->size.height);
3717 d->ensureLayoutFinished();
3721 if (
d->document->pageSize().width() == 0 &&
d->viewportRect.isValid()) {
3728 d->clipRect =
QRectF(
fd->position.toPointF(),
fd->size.toSizeF()).
adjusted(
fd->leftMargin.toReal(), 0, -
fd->rightMargin.toReal(), 0);
3748 fd->floats.removeAll(
nullptr);
3750 fd->layoutDirty =
true;
3751 fd->sizeDirty =
true;
3754 QList<QTextFrame *> children = current->
childFrames();
3755 for (
int i = 0;
i < children.size(); ++
i)
3765 if (endIt.isValid())
3766 endIt = endIt.
next();
3767 for (; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next())
3770 if (!
d->docPrivate->canLayout())
3775 d->lazyLayoutStepSize = 1000;
3776 d->sizeChangedTimer.stop();
3777 d->insideDocumentChange =
true;
3779 const int documentLength =
d->docPrivate->length();
3780 const bool fullLayout = (oldLength == 0 &&
length == documentLength);
3781 const bool smallChange = documentLength > 0
3782 && (
qMax(
length, oldLength) * 100 / documentLength) < 5;
3789 && (
d->currentLazyLayoutPosition == -1 ||
d->showLayoutProgress ==
false))
3790 d->showLayoutProgress =
false;
3792 d->showLayoutProgress =
true;
3795 d->contentHasAlignment =
false;
3796 d->currentLazyLayoutPosition = 0;
3797 d->checkPoints.clear();
3800 d->ensureLayoutedByPosition(from);
3801 updateRect = doLayout(from, oldLength,
length);
3804 if (!
d->layoutTimer.isActive() &&
d->currentLazyLayoutPosition != -1)
3805 d->layoutTimer.start(10,
this);
3807 d->insideDocumentChange =
false;
3809 if (
d->showLayoutProgress) {
3811 if (newSize !=
d->lastReportedSize) {
3812 d->lastReportedSize = newSize;
3825QRectF QTextDocumentLayout::doLayout(
int from,
int oldLength,
int length)
3837 if (
data(root)->sizeDirty)
3838 updateRect =
d->layoutFrame(root, from, from +
length);
3839 data(root)->layoutDirty =
false;
3841 if (
d->currentLazyLayoutPosition == -1)
3843 else if (
d->showLayoutProgress)
3844 d->sizeChangedTimer.start(0,
this);
3864 int lastPos =
f->lastPosition();
3887 QTextFrame *
frame = qobject_cast<QTextFrame *>(
d->document->objectForFormat(
f));
3889 pos =
frame->frameFormat().position();
3891 fd->sizeDirty =
false;
3893 fd->minimumWidth =
fd->maximumWidth =
fd->size.width;
3897 item.setWidth(inlineSize.width());
3901 qreal halfX =
m.xHeight()/2.;
3902 item.setAscent((inlineSize.height() + halfX) / 2.);
3903 item.setDescent((inlineSize.height() - halfX) / 2.);
3906 item.setAscent(inlineSize.height());
3914 if (
item.width() != 0)
3924 QTextFrame *
frame = qobject_cast<QTextFrame *>(
d->document->objectForFormat(
f));
3930 if (
b.position() <=
frame->firstPosition() &&
b.position() +
b.length() >
frame->lastPosition())
3931 line =
b.layout()->lineAt(
b.layout()->lineCount()-1);
3943 QTextFrame *
frame = qobject_cast<QTextFrame *>(
d->document->objectForFormat(
f));
3954 const QSizeF pgSize =
d->document->pageSize();
3955 if (pgSize.height() < 0)
3963 return data(
d->docPrivate->rootFrame())->size.toSizeF();
3969 d->ensureLayoutFinished();
3976 d->ensureLayoutFinished();
3985 const QSizeF oldSize =
q->dynamicDocumentSize();
4023 return d->cursorWidth;
4029 d->fixedColumnWidth =
width;
4042 return cellRect.
translated(tableRect.topLeft());
4048 if (!
d->docPrivate->canLayout())
4050 d->ensureLayoutFinished();
4053 const int framePos =
table->firstPosition();
4057 pos +=
fd->position.toPointF();
4067 f =
f->parentFrame();
4075 if (!
d->docPrivate->canLayout())
4077 d->ensureLayoutFinished();
4078 return d->frameBoundingRectInternal(
frame);
4084 const int framePos =
frame->firstPosition();
4088 pos +=
fd->position.toPointF();
4096 f =
f->parentFrame();
4109 const int blockPos = block.
position();
4133 int pos =
d->currentLazyLayoutPosition;
4142 if (e->
timerId() ==
d->layoutTimer.timerId()) {
4143 if (
d->currentLazyLayoutPosition != -1)
4145 }
else if (e->
timerId() ==
d->sizeChangedTimer.timerId()) {
4148 d->sizeChangedTimer.stop();
4150 if (
d->currentLazyLayoutPosition == -1) {
4152 if (newCount !=
d->lastPageCount) {
4153 d->lastPageCount = newCount;
4162void QTextDocumentLayout::layoutFinished()
4165 d->layoutTimer.stop();
4166 if (!
d->insideDocumentChange)
4167 d->sizeChangedTimer.start(0,
this);
4169 d->showLayoutProgress =
true;
4180 d->ensureLayoutFinished();
4181 return d->idealWidth;
4187 return d->contentHasAlignment;
4206#include "moc_qtextdocumentlayout_p.cpp"
QPaintDevice * paintDevice
QTextDocumentPrivate * docPrivate
void pageCountChanged(int newPages)
This signal is emitted when the number of pages in the layout changes; newPages is the updated page c...
virtual void drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextFormat &format)
This function is called to draw the inline object, object, with the given painter within the rectangl...
void documentSizeChanged(const QSizeF &newSize)
This signal is emitted when the size of the document layout changes to newSize.
QTextDocument * document() const
Returns the text document that this layout is operating on.
void registerHandler(int objectType, QObject *component)
Registers the given component as a handler for items of the given objectType.
void update(const QRectF &=QRectF(0., 0., 1000000000., 1000000000.))
This signal is emitted when the rectangle rect has been updated.
Qt::BrushStyle style() const
Returns the brush style.
The QColor class provides colors based on RGB, HSV or CMYK values.
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
QLayout * layout() override
\reimp
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
qsizetype size() const noexcept
QList< T > & fill(parameter_type t, qsizetype size=-1)
bool isEmpty() const noexcept
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
const_iterator constBegin() const noexcept
void reserve(qsizetype size)
void resize(qsizetype size)
void append(parameter_type t)
const_iterator constEnd() const noexcept
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
bool isEmpty() const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
The QPainter class performs low-level painting on widgets and other paint devices.
const QPen & pen() const
Returns the painter's current pen.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void restore()
Restores the current painter state (pops a saved state off the stack).
const QBrush & brush() const
Returns the painter's current brush.
void save()
Saves the current painter state (pushes the state onto a stack).
QPoint brushOrigin() const
Returns the currently set brush origin.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
QColor color() const
Returns the color of this pen's brush.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
bool intersects(const QRectF &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e.
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
constexpr void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void translate(qreal dx, qreal dy) noexcept
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
qreal bottomMargin() const
Returns the paragraph's bottom margin.
qreal topMargin() const
Returns the paragraph's top margin.
Qt::Alignment alignment() const
Returns the paragraph's alignment.
QList< QTextOption::Tab > tabPositions() const
PageBreakFlags pageBreakPolicy() const
bool nonBreakableLines() const
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
int indent() const
Returns the paragraph's indent.
qreal leftMargin() const
Returns the paragraph's left margin.
qreal textIndent() const
Returns the paragraph's text indent.
qreal lineHeight(qreal scriptLineHeight, qreal scaling) const
qreal rightMargin() const
Returns the paragraph's right margin.
int lineHeightType() const
int length() const
Returns the length of the block in characters.
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
const QTextDocument * document() const
Returns the text document this text block belongs to, or \nullptr if the text block does not belong t...
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents.
int position() const
Returns the index of the block's first character within the document.
QString text() const
Returns the block's contents as plain text.
QFont font() const
Returns the font for this character format.
void setCellPosition(QTextTable *t, const QTextTableCell &cell, const QPointF &pos)
QBasicTimer sizeChangedTimer
int currentLazyLayoutPosition
QFixed findY(QFixed yFrom, const QTextLayoutStruct *layoutStruct, QFixed requiredWidth) const
uint insideDocumentChange
void layoutBlock(const QTextBlock &bl, int blockPosition, const QTextBlockFormat &blockFormat, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, const QTextBlockFormat *previousBlockFormat)
QTextOption::WrapMode wordWrapMode
void floatMargins(QFixed y, const QTextLayoutStruct *layoutStruct, QFixed *left, QFixed *right) const
void ensureLayoutedByPosition(int position) const
QTextLayoutStruct layoutCell(QTextTable *t, const QTextTableCell &cell, QFixed width, int layoutFrom, int layoutTo, QTextTableData *tableData, QFixed absoluteTableY, bool withPageBreaks)
HitPoint hitTest(QTextFrame *frame, const QFixedPoint &point, int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const
void drawBlock(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, const QTextBlock &bl, bool inRootFrame) const
QList< QCheckPoint > checkPoints
QFixed blockIndent(const QTextBlockFormat &blockFormat) const
QTextFrame::Iterator frameIteratorForTextPosition(int position) const
QRectF layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY=0)
void drawTableCellBorder(const QRectF &cellRect, QPainter *painter, QTextTable *table, QTextTableData *td, const QTextTableCell &cell) const
QTextDocumentLayoutPrivate()
void drawBorder(QPainter *painter, const QRectF &rect, qreal topMargin, qreal bottomMargin, qreal border, const QBrush &brush, QTextFrameFormat::BorderStyle style) const
void drawFrame(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, QTextFrame *f) const
void layoutFlow(QTextFrame::Iterator it, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, QFixed width=0)
qreal scaleToDevice(qreal value) const
QRectF layoutTable(QTextTable *t, int layoutFrom, int layoutTo, QFixed parentY)
void ensureLayoutFinished() const
void positionFloat(QTextFrame *frame, QTextLine *currentLine=nullptr)
void drawFrameDecoration(QPainter *painter, QTextFrame *frame, QTextFrameData *fd, const QRectF &clip, const QRectF &rect) const
QTextFrame::Iterator frameIteratorForYPosition(QFixed y) const
void drawListItem(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, const QTextBlock &bl, const QTextCharFormat *selectionFormat) const
void drawFlow(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, QTextFrame::Iterator it, const QList< QTextFrame * > &floats, QTextBlock *cursorBlockNeedingRepaint) const
void ensureLayouted(QFixed y) const
QRectF frameBoundingRectInternal(QTextFrame *frame) const
void drawTableCell(const QRectF &cellRect, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &cell_context, QTextTable *table, QTextTableData *td, int r, int c, QTextBlock *cursorBlockNeedingRepaint, QPointF *cursorBlockOffset) const
void setFixedColumnWidth(int width)
QSizeF documentSize() const override
Returns the total size of the document's layout.
QRectF tableCellBoundingRect(QTextTable *table, const QTextTableCell &cell) const
void documentChanged(int from, int oldLength, int length) override
This function is called whenever the contents of the document change.
virtual QRectF blockBoundingRect(const QTextBlock &block) const override
Returns the bounding rectangle of block.
void draw(QPainter *painter, const PaintContext &context) override
Draws the layout with the given painter using the given context.
void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, int posInDocument, const QTextFormat &format) override
This function is called to draw the inline object, object, with the given painter within the rectangl...
QTextDocumentLayout(QTextDocument *doc)
int pageCount() const override
Returns the number of pages contained in the layout.
void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override
Sets the size of the inline object item corresponding to the text format.
virtual QRectF frameBoundingRect(QTextFrame *frame) const override
Returns the bounding rectangle of frame.
void setViewport(const QRectF &viewport)
int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const override
Returns the cursor position for the given point with the specified accuracy.
QRectF tableBoundingRect(QTextTable *table) const
void setCursorWidth(int width)
void ensureLayouted(qreal)
QSizeF dynamicDocumentSize() const
virtual void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
int dynamicPageCount() const
void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override
Lays out the inline object item using the given text format.
const BlockMap & blockMap() const
QTextFrame * frameAt(int pos) const
QTextFrame * rootFrame() const
static const QTextDocumentPrivate * get(const QTextDocument *document)
QTextOption defaultTextOption
\reentrant \inmodule QtGui
QSizeF pageSize
the page size that should be used for laying out the document
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
QTextFrame * rootFrame() const
Returns the document's root frame.
QTextCharFormat toCharFormat() const
Returns this format as a character format.
QBrush background() const
Returns the brush used to paint the document's background.
Property
This enum describes the different properties a format can have.
@ TableCellBottomBorderStyle
@ TableCellTopBorderStyle
@ TableCellRightBorderStyle
@ BlockTrailingHorizontalRulerWidth
@ TableCellLeftBorderStyle
QTextLength lengthProperty(int propertyId) const
Returns the value of the property given by propertyId.
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.
QTextTableCellFormat toTableCellFormat() const
QTextListFormat toListFormat() const
Returns this format as a list format.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false.
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines,...
QFixed effectiveBottomMargin
QList< QPointer< QTextFrame > > floats
QFixed effectiveTopMargin
QTextLayoutStruct * currentLayoutStruct
Position
This enum describes how a frame is located relative to the surrounding text.
int lastPosition() const
Returns the last document position inside the frame.
QList< QTextFrame * > childFrames() const
Returns a (possibly empty) list of the frame's child frames.
iterator begin() const
Returns an iterator pointing to the first document element inside the frame.
QTextFrame * parentFrame() const
Returns the frame's parent frame.
int firstPosition() const
Returns the first document position inside the frame.
const QTextOption & textOption() const
Returns the current text option used to control the layout process.
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
qreal minimumWidth() const
The minimum width the layout needs.
void setPosition(const QPointF &p)
Moves the text layout to point p.
int lineCount() const
Returns the number of lines in this text layout.
int preeditAreaPosition() const
Returns the position of the area in the text layout that will be processed before editing occurs.
qreal maximumWidth() const
The maximum width the layout could expand to; this is essentially the width of the entire text.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
void draw(QPainter *p, const QPointF &pos, const QList< FormatRange > &selections=QList< FormatRange >(), const QRectF &clip=QRectF()) const
Draws the whole layout on the painter p at the position specified by pos.
void endLayout()
Ends the layout process.
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
void drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
qreal value(qreal maximumLength) const
Returns the effective length, constrained by the type of the length object and the specified maximumL...
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
@ CursorBetweenCharacters
int textLength() const
Returns the length of the text in the line.
Style
This enum describes the symbols used to decorate list items:
Style style() const
Returns the list format's style.
int indent() const
Returns the list format's indentation.
The QTextObjectInterface class allows drawing of custom text objects in \l{QTextDocument}s.
virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format)=0
Draws this text object using the specified painter.
virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format)=0
The intrinsicSize() function returns the size of the text object represented by format in the given d...
QTextFormat format() const
Returns the text object's format.
void setTextDirection(Qt::LayoutDirection aDirection)
Sets the direction of the text layout defined by the option to the given direction.
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
Qt::Alignment alignment() const
Returns the text alignment defined by the option.
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
Flags flags() const
Returns the flags associated with the option.
@ AddSpaceForLineAndParagraphSeparators
WrapMode
This enum describes how text is wrapped in a document.
@ WrapAtWordBoundaryOrAnywhere
QTextCharFormat format() const
Returns the cell's character format.
int columnSpan() const
Returns the number of columns this cell spans.
int firstPosition() const
int row() const
Returns the number of the row in the table that contains this cell.
int rowSpan() const
Returns the number of rows this cell spans.
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
int column() const
Returns the number of the column in the table that contains this cell.
QTextFrame::iterator begin() const
Returns a frame iterator pointing to the beginning of the table's cell.
void calcRowPosition(int row)
QList< QFixed > maxWidths
QFixedPoint cellPosition(QTextTable *table, const QTextTableCell &cell) const
QFixed rightPadding(QTextTable *table, const QTextTableCell &cell) const
QList< QFixed > rowPositions
QFixed effectiveBottomBorder
QFixed effectiveRightBorder
QList< QFixed > cellVerticalOffsets
QList< QFixed > columnPositions
QRectF cellRect(const QTextTableCell &cell) const
QFixed topPadding(QTextTable *table, const QTextTableCell &cell) const
QFixed effectiveLeftBorder
QFixed cellWidth(int column, int colspan) const
QFixed bottomPadding(QTextTable *table, const QTextTableCell &cell) const
QFixed cellBorderWidth(QTextTable *table, const QTextTableCell &cell, QCss::Edge edge) const
QFixed leftPadding(QTextTable *table, const QTextTableCell &cell) const
QFixed effectiveTopBorder
QList< QFixed > minWidths
QFixed paddingProperty(const QTextFormat &format, QTextFormat::Property property) const
QMultiHash< int, QTextFrame * > childFrameMap
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
double toDouble(bool *ok=nullptr) const
Returns the variant as a double if the variant has userType() \l QMetaType::Double,...
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, qreal dw2, QCss::Edge edge, QCss::BorderStyle style, QBrush c)
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qIsNull(qfloat16 f) noexcept
Q_GUI_EXPORT int qt_defaultDpi()
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxW
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLenum GLenum GLenum scale
GLenum GLenum GLsizei void * table
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static void drawCellBorder(const QTextDocumentLayoutPrivate *p, QPainter *painter, QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, const QRectF &borderRect, QCss::Edge edge, int forceHeaderRow, bool adjustTopAnchor, bool adjustBottomAnchor, bool ignoreEdgesAbove)
static bool sharesAxis(const QTextTableCell &cell, QCss::Edge edge, const QTextTableCell &competingCell, QCss::Edge competingCellEdge)
static bool isSameAxis(QCss::Edge e1, QCss::Edge e2)
static EdgeData axisEdgeData(QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, QCss::Edge edge)
static QTextFormat::Property borderStylePropertyForEdge(QCss::Edge edge)
static bool isLineSeparatorBlockAfterTable(const QTextBlock &block, const QTextFrame *previousFrame)
static void adjustContextSelectionsForCell(QAbstractTextDocumentLayout::PaintContext &cell_context, const QTextTableCell &cell, int r, int c, const int *selectedTableCells)
static QTextFormat::Property borderPropertyForEdge(QCss::Edge edge)
static EdgeData cellEdgeData(QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, QCss::Edge edge)
static bool cellClipTest(QTextTable *table, QTextTableData *td, const QAbstractTextDocumentLayout::PaintContext &cell_context, const QTextTableCell &cell, QRectF cellRect)
static bool isEmptyBlockBeforeTable(const QTextBlock &block, const QTextBlockFormat &format, const QTextFrame::Iterator &nextIt)
static void checkJoinedEdge(QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, QCss::Edge competingEdge, const EdgeData &edgeData, bool couldHaveContinuation, EdgeData *maxCompetingEdgeData, EdgeData *maxOrthogonalEdgeData)
static bool operator<(const QCheckPoint &checkPoint, QFixed y)
static QTextTableCell adjacentCell(QTextTable *table, const QTextTableCell &cell, QCss::Edge edge)
static QFixed firstChildPos(const QTextFrame *f)
static void findWidestOutermostBorder(QTextTable *table, QTextTableData *td, const QTextTableCell &cell, QCss::Edge edge, qreal *outerBorders)
static QFixed flowPosition(const QTextFrame::iterator &it)
static bool isEmptyBlockAfterTable(const QTextBlock &block, const QTextFrame *previousFrame)
static QTextFrameData * createData(QTextFrame *f)
static bool isVerticalAxis(QCss::Edge e)
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect=QRectF())
static qreal collapseOffset(const QTextDocumentLayoutPrivate *p, const EdgeData &w)
static void markFrames(QTextFrame *current, int from, int oldLength, int length)
static bool isFrameFromInlineObject(QTextFrame *f)
static double prioritizedEdgeAnchorOffset(const QTextDocumentLayoutPrivate *p, QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, const EdgeData &edgeData, QCss::Edge orthogonalEdge, bool couldHaveContinuation, bool ignoreEdgesAbove)
static QCss::Edge adjacentEdge(QCss::Edge edge)
static void getLineHeightParams(const QTextBlockFormat &blockFormat, const QTextLine &line, qreal scaling, QFixed *lineAdjustment, QFixed *lineBreakHeight, QFixed *lineHeight, QFixed *lineBottom)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
QVideoFrameFormat::PixelFormat fmt
QRandomGenerator64 rd
[10]
view viewport() -> scroll(dx, dy, deviceRect)
QRectF clipRect(int page) const
BorderPaginator(QTextDocument *document, const QRectF &rect, qreal topMarginAfterPageBreak, qreal bottomMargin, qreal border)
qreal topMarginAfterPageBreak
EdgeData(qreal width, const QTextTableCell &cell, QCss::Edge edge, EdgeClass edgeClass)
bool operator>(const EdgeData &other) const
bool operator<(const EdgeData &other) const
\reentrant \inmodule QtGui
QList< Selection > selections
\variable QAbstractTextDocumentLayout::PaintContext::cursorPosition
constexpr QPointF toPointF() const
static constexpr QFixedPoint fromPointF(const QPointF &p)
static constexpr QFixedSize fromSizeF(const QSizeF &s)
constexpr QSizeF toSizeF() const
static constexpr QFixed fromReal(qreal r)
constexpr qreal toReal() const
constexpr int truncate() const
bool contains(const AT &t) const noexcept
QList< QTextFrame * > pendingFloats
QRectF updateRectForFloats
QFixed contentHeight() const
void addUpdateRectForFloat(const QRectF &rect)
QPointer< QObject > component
QTextObjectInterface * iface