14#if QT_CONFIG(regularexpression)
28#include "private/qdataurl_p.h"
31#include <private/qabstracttextdocumentlayout_p.h>
33#include "private/qpagedpaintdevice_p.h"
34#if QT_CONFIG(textmarkdownreader)
35#include <private/qtextmarkdownimporter_p.h>
37#if QT_CONFIG(textmarkdownwriter)
38#include <private/qtextmarkdownwriter_p.h>
102 for (
int i =
open+1;
i < close; ++
i) {
105 else if (!
tag.isEmpty() &&
text[
i].isSpace())
107 else if (!
tag.isEmpty() &&
text[
i] == u
'/' &&
i + 1 == close)
109 else if (!
text[
i].isSpace() && (!
tag.isEmpty() ||
text[
i] != u
'!'))
112#ifndef QT_NO_TEXTHTMLPARSER
137 for (
int i = 0;
i < plain.
size(); ++
i) {
138 if (plain[
i] == u
'\n'){
140 while (
i+1 < plain.
size() && plain[
i+1] == u
'\n') {
164 else if (plain[
i] == u
'<')
166 else if (plain[
i] == u
'>')
168 else if (plain[
i] == u
'&')
307 if (blockFormat.isValid() && !blockFormat.isEmpty())
311 if (blockCharFormat.isValid() && !blockCharFormat.isEmpty())
318 priv->title =
d->title;
320 priv->cssMedia =
d->cssMedia;
321 priv->pageSize =
d->pageSize;
322 priv->indentWidth =
d->indentWidth;
323 priv->defaultTextOption =
d->defaultTextOption;
324 priv->setDefaultFont(
d->defaultFont());
325 priv->resources =
d->resources;
326 priv->cachedResources.clear();
327 priv->resourceProvider =
d->resourceProvider;
328#ifndef QT_NO_CSSPARSER
329 priv->defaultStyleSheet =
d->defaultStyleSheet;
330 priv->parsedDefaultStyleSheet =
d->parsedDefaultStyleSheet;
343 return d->length() <= 1;
353 d->resources.clear();
371 const int pos =
d->undoRedo(
true);
388 const int pos =
d->undoRedo(
false);
416 d->clearUndoRedoStacks(stacksToClear,
true);
447 d->appendUndoItem(
item);
466 return d->isUndoRedoEnabled();
493 return d->maximumBlockCount;
499 d->maximumBlockCount = maximum;
500 d->ensureMaximumBlockCount();
514 return d->defaultTextOption;
527 d->lout->documentChanged(0, 0,
d->length());
555 if (
d->baseUrl !=
url) {
558 d->lout->documentChanged(0, 0,
d->length());
572 return d->defaultCursorMoveStyle;
583 d->defaultCursorMoveStyle = style;
596 d->documentChange(from,
length);
597 if (!
d->inContentsChange) {
599 d->lout->documentChanged(
d->docChangeFrom,
d->docChangeOldLength,
d->docChangeLength);
600 d->docChangeFrom = -1;
624 if (
b ==
d->defaultTextOption.useDesignMetrics())
626 d->defaultTextOption.setUseDesignMetrics(
b);
628 d->lout->documentChanged(0, 0,
d->length());
634 return d->defaultTextOption.useDesignMetrics();
658 if (
d->layoutEnabled ==
b)
660 d->layoutEnabled =
b;
662 d->lout->documentChanged(0, 0,
d->length());
668 return d->layoutEnabled;
681 if (
rect.isValid()) {
682 p->setClipRect(
rect);
722 return d->pageSize.width();
736 return lout->idealWidth();
749 return d->documentMargin;
755 if (
d->documentMargin != margin) {
756 d->documentMargin = margin;
764 d->lout->documentChanged(0, 0,
d->length());
781 return d->indentWidth;
798 if (
d->indentWidth !=
width) {
801 d->lout->documentChanged(0, 0,
d->length());
824 if (
size.width() != 0) {
829 if (
w*3 < 5*
size.height()) {
873 return d->blockMap().numNodes();
888 return d->blockMap().length(2);
918 if (pos < 0 || pos >=
d->length())
922 const int offsetInFragment =
qMax(0,
pos - fragIt.position());
942#ifndef QT_NO_CSSPARSER
946 d->defaultStyleSheet = sheet;
950 parser.
parse(&
d->parsedDefaultStyleSheet);
956 return d->defaultStyleSheet;
1044 return d->isUndoAvailable();
1055 return d->isRedoAvailable();
1067 return d->availableUndoSteps();
1079 return d->availableRedoSteps();
1178 return d->plainText();
1206 for (; uc !=
e; ++uc) {
1233 bool previousState =
d->isUndoRedoEnabled();
1234 d->enableUndoRedo(
false);
1235 d->beginEditBlock();
1239 d->enableUndoRedo(previousState);
1261#ifndef QT_NO_TEXTHTMLPARSER
1266 bool previousState =
d->isUndoRedoEnabled();
1267 d->enableUndoRedo(
false);
1268 d->beginEditBlock();
1272 d->enableUndoRedo(previousState);
1320 const int start = idx;
1379 block = block.
next();
1383 if (blockOffset == block.
length() - 1)
1389 blockOffset = block.
length() - 2;
1421 return find(subString,
pos, options);
1424#if QT_CONFIG(regularexpression)
1440 const int start = idx;
1505 block = block.
next();
1513 blockOffset = block.
length() - 1;
1548 return find(expr,
pos, options);
1564 if (
f.isListFormat())
1566 else if (
f.isTableFormat())
1568 else if (
f.isFrameFormat())
1582 return d->frameAt(
pos);
1591 return d->rootFrame();
1600 return d->objectForIndex(objectIndex);
1609 return d->objectForFormat(
f);
1714 d->lout->documentChanged(0, 0,
d->length());
1737 d->setDefaultFont(
font);
1739 d->lout->documentChanged(0, 0,
d->length());
1748 return d->defaultFont();
1763 d->formats.setSuperScriptBaseline(baseline);
1777 return d->formats.defaultTextFormat().superScriptBaseline();
1792 d->formats.setSubScriptBaseline(baseline);
1806 return d->formats.defaultTextFormat().subScriptBaseline();
1822 d->formats.setBaselineOffset(baseline);
1837 return d->formats.defaultTextFormat().baselineOffset();
1866 return d->isModified();
1875#ifndef QT_NO_PRINTER
1895 if (!pageNumberPos.
isNull()) {
1933 bool documentPaginated =
d->pageSize.isValid() && !
d->pageSize.isNull()
1934 &&
d->pageSize.height() != INT_MAX;
1938 if (!documentPaginated &&
m.left() == 0. &&
m.right() == 0. &&
m.top() == 0. &&
m.bottom() == 0.) {
1965 if (documentPaginated) {
1974 p.scale(dpiScaleX, dpiScaleY);
1976 QSizeF scaledPageSize =
d->pageSize;
1977 scaledPageSize.
rwidth() *= dpiScaleX;
1978 scaledPageSize.
rheight() *= dpiScaleY;
1983 p.scale(printerPageSize.
width() / scaledPageSize.
width(),
1990 srcBlock.isValid() && dstBlock.isValid();
1991 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) {
1992 dstBlock.layout()->setFormats(srcBlock.layout()->formats());
1996 layout->setPaintDevice(
p.device());
2002 const int horizontalMargin = int((2/2.54)*sourceDpiX);
2003 const int verticalMargin = int((2/2.54)*sourceDpiY);
2005 fmt.setLeftMargin(horizontalMargin);
2006 fmt.setRightMargin(horizontalMargin);
2007 fmt.setTopMargin(verticalMargin);
2008 fmt.setBottomMargin(verticalMargin);
2012 const int dpiy =
p.device()->logicalDpiY();
2014 pageNumberPos =
QPointF(body.
width() - horizontalMargin * dpiScaleX,
2015 body.
height() - verticalMargin * dpiScaleY
2018 clonedDoc->setPageSize(body.
size());
2023 int toPage = pageRanges.
lastPage();
2025 if (fromPage == 0 && toPage == 0) {
2030 fromPage =
qMax(1, fromPage);
2033 if (toPage < fromPage) {
2047 int page = fromPage;
2110 r =
d->cachedResources.value(
url);
2114 if (
d->resourceProvider)
2115 r =
d->resourceProvider(
url);
2117 r = defaultProvider(
url);
2159 return d->resourceProvider;
2179 d->resourceProvider = provider;
2194 qt_defaultResourceProvider = provider;
2206 return qt_defaultResourceProvider;
2253 if (!qobject_cast<QTextDocument *>(
p) &&
r.isNull()) {
2256 if (
name.isRelative()) {
2257 QUrl currentURL =
d->url;
2261 || (currentURL.
scheme() ==
"file"_L1
2263 || (
name.hasFragment() &&
name.path().isEmpty())) {
2273 }
else if (currentURL.
isEmpty()) {
2292 image.loadFromData(
r.toByteArray());
2293 if (!
image.isNull())
2302 d->cachedResources.insert(
name,
r);
2324 if (
color.alpha() == 255) {
2326 }
else if (
color.alpha()) {
2328 while (alphaValue.
size() > 1 && alphaValue.
at(alphaValue.
size() - 1) == u
'0')
2330 if (alphaValue.
at(alphaValue.
size() - 1) == u
'.')
2337 result =
"transparent"_L1;
2344 : doc(_doc), fragmentMarkers(
false)
2347 defaultCharFormat.
setFont(defaultFont);
2352 return format.fontFamilies().toStringList();
2362 html =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
2363 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
2364 "<html><head><meta name=\"qrichtext\" content=\"1\" />"_L1;
2374 html +=
"<style type=\"text/css\">\n"_L1;
2375 html +=
"p, li { white-space: pre-wrap; }\n"_L1;
2376 html +=
"hr { height: 1px; border-width: 0; }\n"_L1;
2377 html +=
"li.unchecked::marker { content: \"\\2610\"; }\n"_L1;
2378 html +=
"li.checked::marker { content: \"\\2612\"; }\n"_L1;
2379 html +=
"</style>"_L1;
2380 html +=
"</head><body"_L1;
2383 html +=
" style=\""_L1;
2388 html +=
" font-size:"_L1;
2392 html +=
" font-size:"_L1;
2397 html +=
" font-weight:"_L1;
2401 html +=
" font-style:"_L1;
2402 html += (defaultCharFormat.
fontItalic() ?
"italic"_L1 :
"normal"_L1);
2408 html +=
" letter-spacing:"_L1;
2413 html += percentSpacing ?
"em;"_L1 :
"px;"_L1;
2418 html +=
" word-spacing:"_L1;
2423 QString decorationTag(
" text-decoration:"_L1);
2424 bool atLeastOneDecorationSet =
false;
2427 decorationTag +=
" underline"_L1;
2428 atLeastOneDecorationSet =
true;
2433 decorationTag +=
" overline"_L1;
2434 atLeastOneDecorationSet =
true;
2439 decorationTag +=
" line-through"_L1;
2440 atLeastOneDecorationSet =
true;
2443 if (atLeastOneDecorationSet)
2444 html += decorationTag + u
';';
2449 emitBackgroundAttribute(
fmt);
2462 if (rootFmt == defaultFmt)
2467 html +=
"</body></html>"_L1;
2482 bool attributesEmitted =
false;
2487 emitFontFamily(families);
2488 attributesEmitted =
true;
2494 html +=
" font-size:"_L1;
2497 attributesEmitted =
true;
2499 static const char sizeNameData[] =
2503 static const quint8 sizeNameOffsets[] = {
2506 sizeof(
"small") +
sizeof(
"medium") + 3,
2507 sizeof(
"small") +
sizeof(
"medium") + 1,
2508 sizeof(
"small") +
sizeof(
"medium"),
2510 const char *
name =
nullptr;
2512 if (idx >= 0 && idx <= 4) {
2513 name = sizeNameData + sizeNameOffsets[idx];
2516 html +=
" font-size:"_L1;
2519 attributesEmitted =
true;
2522 html +=
" font-size:"_L1;
2525 attributesEmitted =
true;
2530 html +=
" font-weight:"_L1;
2533 attributesEmitted =
true;
2538 html +=
" font-style:"_L1;
2539 html += (
format.fontItalic() ?
"italic"_L1 :
"normal"_L1);
2541 attributesEmitted =
true;
2544 const auto decorationTag =
" text-decoration:"_L1;
2545 html += decorationTag;
2546 bool hasDecoration =
false;
2547 bool atLeastOneDecorationSet =
false;
2551 hasDecoration =
true;
2552 if (
format.fontUnderline()) {
2553 html +=
" underline"_L1;
2554 atLeastOneDecorationSet =
true;
2560 hasDecoration =
true;
2561 if (
format.fontOverline()) {
2562 html +=
" overline"_L1;
2563 atLeastOneDecorationSet =
true;
2569 hasDecoration =
true;
2570 if (
format.fontStrikeOut()) {
2571 html +=
" line-through"_L1;
2572 atLeastOneDecorationSet =
true;
2576 if (hasDecoration) {
2577 if (!atLeastOneDecorationSet)
2581 html +=
" text-decoration-color:"_L1;
2585 attributesEmitted =
true;
2587 html.
chop(decorationTag.size());
2595 const qint64 cacheKey = isPixmap ?
brush.texture().cacheKey() :
brush.textureImage().cacheKey();
2597 html +=
" -qt-fg-texture-cachekey:"_L1;
2601 html +=
" color:"_L1;
2605 attributesEmitted =
true;
2610 html +=
" background-color:"_L1;
2613 attributesEmitted =
true;
2619 html +=
" vertical-align:"_L1;
2627 html +=
"middle"_L1;
2631 html +=
"bottom"_L1;
2634 attributesEmitted =
true;
2640 html +=
" text-transform:uppercase;"_L1;
2642 html +=
" text-transform:lowercase;"_L1;
2644 html +=
" font-variant:small-caps;"_L1;
2645 attributesEmitted =
true;
2648 if (
format.fontWordSpacing() != 0.0) {
2649 html +=
" word-spacing:"_L1;
2652 attributesEmitted =
true;
2655 return attributesEmitted;
2674void QTextHtmlExporter::emitAlignment(Qt::Alignment align)
2679 html +=
" align=\"right\""_L1;
2681 html +=
" align=\"center\""_L1;
2683 html +=
" align=\"justify\""_L1;
2691 if (
mode == EmitStyleTag)
2692 html +=
" style=\"float:"_L1;
2694 html +=
" float:"_L1;
2697 html +=
" left;"_L1;
2699 html +=
" right;"_L1;
2701 Q_ASSERT_X(0,
"QTextHtmlExporter::emitFloatStyle()",
"pos should be a valid enum type");
2703 if (
mode == EmitStyleTag)
2721 return "dot-dash"_L1;
2723 return "dot-dot-dash"_L1;
2742 html +=
" border-style:"_L1;
2747void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags
policy)
2750 html +=
" page-break-before:always;"_L1;
2753 html +=
" page-break-after:always;"_L1;
2756void QTextHtmlExporter::emitFontFamily(
const QStringList &families)
2758 html +=
" font-family:"_L1;
2761 for (
const QString &family : families) {
2762 auto quote =
"\'"_L1;
2763 if (family.contains(u
'\''))
2764 quote =
"""_L1;
2779 html +=
" margin-top:"_L1;
2783 html +=
" margin-bottom:"_L1;
2787 html +=
" margin-left:"_L1;
2791 html +=
" margin-right:"_L1;
2796void QTextHtmlExporter::emitFragment(
const QTextFragment &fragment)
2800 bool closeAnchor =
false;
2804 if (!
names.isEmpty()) {
2805 html +=
"<a name=\""_L1;
2807 html +=
"\"></a>"_L1;
2811 html +=
"<a href=\""_L1;
2820 const bool isImage = isObject &&
format.isImageFormat();
2822 const auto styleTag =
"<span style=\""_L1;
2825 bool attributesEmitted =
false;
2827 attributesEmitted = emitCharFormatStyle(
format);
2828 if (attributesEmitted)
2831 html.
chop(styleTag.size());
2834 for (
int i = 0; isImage &&
i <
txt.size(); ++
i) {
2840 emitAttribute(
"src", imgFmt.
name());
2855 html +=
" style=\"vertical-align: middle;\""_L1;
2857 html +=
" style=\"vertical-align: top;\""_L1;
2860 emitFloatStyle(imageFrame->frameFormat().position());
2867 txt =
txt.toHtmlEscaped();
2871 txt.replace(u
'\n',
"<br />"_L1);
2876 if (attributesEmitted)
2877 html +=
"</span>"_L1;
2892void QTextHtmlExporter::emitBlockAttributes(
const QTextBlock &block)
2895 emitAlignment(
format.alignment());
2900 html +=
" dir='rtl'"_L1;
2902 const auto style =
" style=\""_L1;
2905 const bool emptyBlock = block.
begin().
atEnd();
2907 html +=
"-qt-paragraph-type:empty;"_L1;
2915 html +=
" -qt-block-indent:"_L1;
2919 html +=
" text-indent:"_L1;
2924 html +=
" -qt-user-state:"_L1;
2930 html +=
" line-height:"_L1
2932 switch (
format.lineHeightType()) {
2937 html +=
"; -qt-line-height-type: fixed;"_L1;
2943 html +=
"; -qt-line-height-type: line-distance;"_L1;
2951 emitPageBreakPolicy(
format.pageBreakPolicy());
2967 emitCharFormatStyle(diff);
2973void QTextHtmlExporter::emitBlock(
const QTextBlock &block)
2996 if (
list->itemNumber(block) == 0) {
2998 const int style =
format.style();
2999 bool ordered =
false;
3009 default: html +=
"<ul"_L1;
3012 if (ordered &&
format.start() != 1) {
3013 html +=
" start=\""_L1;
3021 styleString +=
" -qt-list-indent: "_L1;
3023 styleString += u
';';
3028 numberPrefix.
replace(u
'"',
"\\22"_L1);
3029 numberPrefix.
replace(u
'\'',
"\\27"_L1);
3030 styleString +=
" -qt-list-number-prefix: "_L1;
3031 styleString += u
'\'';
3032 styleString += numberPrefix;
3033 styleString += u
'\'';
3034 styleString += u
';';
3038 if (
format.numberSuffix() !=
"."_L1) {
3040 numberSuffix.
replace(u
'"',
"\\22"_L1);
3041 numberSuffix.
replace(u
'\'',
"\\27"_L1);
3042 styleString +=
" -qt-list-number-suffix: "_L1;
3043 styleString += u
'\'';
3044 styleString += numberSuffix;
3045 styleString += u
'\'';
3046 styleString += u
';';
3050 html +=
" style=\""_L1;
3051 html += styleString;
3059 html +=
" style=\""_L1;
3060 emitCharFormatStyle(blockFmt);
3068 html +=
" class=\"checked\""_L1;
3071 html +=
" class=\"unchecked\""_L1;
3085 emitTextLength(
"width",
width);
3089 html +=
"style=\""_L1;
3090 html +=
"background-color:"_L1;
3107 if (headingLevel > 0 && headingLevel <= 6)
3113 emitBlockAttributes(block);
3117 html +=
"<br />"_L1;
3120 if (fragmentMarkers && !
it.atEnd() && block == doc->
begin())
3121 html +=
"<!--StartFragment-->"_L1;
3123 for (; !
it.atEnd(); ++
it)
3124 emitFragment(
it.fragment());
3127 html +=
"<!--EndFragment-->"_L1;
3132 html +=
"</pre>"_L1;
3134 closeTags +=
"</li>"_L1;
3137 if (headingLevel > 0 && headingLevel <= 6)
3146 closeTags +=
"</ol>"_L1;
3148 closeTags +=
"</ul>"_L1;
3158 if (!closingTags.isEmpty() &&
list->itemNumber(block) ==
list->
count() - 1)
3159 lastTag = closingTags.takeLast();
3161 closingTags << lastTag;
3166 if (!closingTags.isEmpty())
3167 html += closingTags.takeLast();
3173 defaultCharFormat = oldDefaultCharFormat;
3185 return findUrlForImage(
parent, cacheKey, isPixmap);
3191 for (;
it !=
priv->cachedResources.constEnd(); ++
it) {
3194 if (
v.userType() == QMetaType::QImage && !isPixmap) {
3195 if (qvariant_cast<QImage>(
v).cacheKey() == cacheKey)
3199 if (
v.userType() == QMetaType::QPixmap && isPixmap) {
3200 if (qvariant_cast<QPixmap>(
v).cacheKey() == cacheKey)
3205 if (
it !=
priv->cachedResources.constEnd())
3206 url =
it.key().toString();
3216 cachedResources.
insert(
priv->cachedResources);
3223 emitAttribute(
"background",
url);
3230 const qint64 cacheKey = isPixmap ?
brush.texture().cacheKey() :
brush.textureImage().cacheKey();
3232 const QString url = findUrlForImage(doc, cacheKey, isPixmap);
3235 emitAttribute(
"background",
url);
3244 html +=
"\n<table"_L1;
3249 emitFrameStyle(
format, TableFrame);
3251 emitAlignment(
format.alignment());
3252 emitTextLength(
"width",
format.width());
3259 emitBackgroundAttribute(
format);
3263 const int rows =
table->rows();
3264 const int columns =
table->columns();
3268 columnWidths.
resize(columns);
3274 for (
int i = 0;
i < columns; ++
i)
3275 widthEmittedForColumn[
i] =
false;
3277 const int headerRowCount =
qMin(
format.headerRowCount(), rows);
3278 if (headerRowCount > 0)
3279 html +=
"<thead>"_L1;
3282 html +=
"\n<tr>"_L1;
3284 for (
int col = 0; col < columns; ++col) {
3291 if (cell.
column() != col)
3296 if (!widthEmittedForColumn[col] && cell.
columnSpan() == 1) {
3297 emitTextLength(
"width", columnWidths.
at(col));
3298 widthEmittedForColumn[col] =
true;
3308 emitBackgroundAttribute(cellFormat);
3316 styleString +=
" vertical-align:"_L1;
3319 styleString +=
"middle"_L1;
3322 styleString +=
"top"_L1;
3325 styleString +=
"bottom"_L1;
3330 styleString += u
';';
3334 defaultCharFormat.
merge(temp);
3374 html +=
" style=\""_L1 + styleString + u
'\"';
3378 emitFrame(cell.
begin());
3382 defaultCharFormat = oldDefaultCharFormat;
3386 if (headerRowCount > 0 &&
row == headerRowCount - 1)
3387 html +=
"</thead>"_L1;
3390 html +=
"</table>"_L1;
3395 if (!frameIt.
atEnd()) {
3406 !
it.atEnd(); ++
it) {
3413 }
else if (
it.currentBlock().isValid()) {
3414 emitBlock(
it.currentBlock());
3419void QTextHtmlExporter::emitTextFrame(
const QTextFrame *
f)
3421 FrameType frameType =
f->parentFrame() ? TextFrame : RootFrame;
3423 html +=
"\n<table"_L1;
3429 emitFrameStyle(
format, frameType);
3431 emitTextLength(
"width",
format.width());
3432 emitTextLength(
"height",
format.height());
3435 if (frameType != RootFrame)
3436 emitBackgroundAttribute(
format);
3439 html +=
"\n<tr>\n<td style=\"border: none;\">"_L1;
3440 emitFrame(
f->begin());
3441 html +=
"</td></tr></table>"_L1;
3446 const auto styleAttribute =
" style=\""_L1;
3447 html += styleAttribute;
3448 const int originalHtmlLength = html.
size();
3450 if (frameType == TextFrame)
3451 html +=
"-qt-table-type: frame;"_L1;
3452 else if (frameType == RootFrame)
3453 html +=
"-qt-table-type: root;"_L1;
3457 emitFloatStyle(
format.position(), OmitStyleTag);
3458 emitPageBreakPolicy(
format.pageBreakPolicy());
3461 html +=
" border-color:"_L1;
3467 emitBorderStyle(
format.borderStyle());
3480 html +=
" border-collapse:collapse;"_L1;
3482 if (html.
size() == originalHtmlLength)
3483 html.
chop(styleAttribute.size());
3498#ifndef QT_NO_TEXTHTMLPARSER
3512#if QT_CONFIG(textmarkdownwriter)
3513QString QTextDocument::toMarkdown(QTextDocument::MarkdownFeatures features)
const
3518 if (
w.writeAll(
this))
3554#if QT_CONFIG(textmarkdownreader)
3555void QTextDocument::setMarkdown(
const QString &markdown, QTextDocument::MarkdownFeatures features)
3567 return d->formatCollection()->formats;
3579#include "moc_qtextdocument.cpp"
virtual int pageCount() const =0
Returns the number of pages contained in the layout.
virtual void draw(QPainter *painter, const PaintContext &context)=0
Draws the layout with the given painter using the given context.
QPaintDevice * paintDevice() const
Returns the paint device used to render the document's layout.
virtual QSizeF documentSize() const =0
Returns the total size of the document's layout.
const QColor & color() const
Returns the brush color.
Qt::BrushStyle style() const
Returns the brush style.
constexpr bool isLetterOrNumber() const noexcept
Returns true if the character is a letter or number (Letter_* or Number_* categories); otherwise retu...
@ ObjectReplacementCharacter
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
constexpr bool isSpace() const noexcept
Returns true if the character is a separator character (Separator_* categories or certain code points...
The QColor class provides colors based on RGB, HSV or CMYK values.
QString name(NameFormat format=HexRgb) const
bool parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity=Qt::CaseSensitive)
static QChar separator()
Returns the native directory separator: "/" under Unix and "\\" under Windows.
\inmodule QtCore \reentrant
QString absolutePath() const
Returns a file's path absolute path.
bool isAbsolute() const
Returns true if the file path is absolute, otherwise returns false (i.e.
bool exists() const
Returns true if the file exists; otherwise returns false.
\reentrant \inmodule QtGui
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
int ascent() const
Returns the ascent of the font.
qsizetype size() const noexcept
QList< T > & fill(parameter_type t, qsizetype size=-1)
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
void resize(qsizetype size)
iterator insert(const Key &key, const T &value)
constexpr void setLeft(qreal aleft) noexcept
Sets the left margin to aleft (which must be finite).
QObject * parent() const
Returns a pointer to the parent object.
QMarginsF margins() const
Returns the margins of the page layout using the currently set units.
virtual bool newPage()=0
Starts a new page.
virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units=QPageLayout::Millimeter)
QPageRanges pageRanges() const
QPageLayout pageLayout() const
The QPainter class performs low-level painting on widgets and other paint devices.
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void restore()
Restores the current painter state (pops a saved state off the stack).
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
void save()
Saves the current painter state (pushes the state onto a stack).
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
bool loadFromData(const uchar *buf, uint len, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the len first bytes of the given binary data.
\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.
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
\inmodule QtCore\reentrant
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
bool isValid() const
Returns true if the regular expression is a valid regular expression (that is, it contains no syntax ...
PatternOptions patternOptions() const
Returns the pattern options for the regular expression.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
constexpr qreal & rwidth() noexcept
Returns a reference to the width.
constexpr void setHeight(qreal h) noexcept
Sets the height to the given finite height.
constexpr qreal & rheight() noexcept
Returns a reference to the height.
constexpr void setWidth(qreal w) noexcept
Sets the width to the given finite width.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString & replace(qsizetype i, qsizetype len, QChar after)
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
void chop(qsizetype n)
Removes n characters from the end of the string.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & prepend(QChar c)
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
QString toHtmlEscaped() const
MarkerType marker() const
bool nonBreakableLines() const
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
bool atEnd() const
Returns true if the current item is the last item in the text block.
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
int length() const
Returns the length of the block in characters.
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
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...
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.
Qt::LayoutDirection textDirection() const
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block's character format.
QTextList * textList() const
If the block represents a list item, returns the list that the item belongs to; otherwise returns \nu...
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
qreal fontLetterSpacing() const
VerticalAlignment
This enum describes the ways that adjacent characters can be vertically aligned.
QStringList anchorNames() const
int fontWeight() const
Returns the text format's font weight.
qreal fontPointSize() const
Returns the font size used to display text in this format.
bool fontStrikeOut() const
Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherw...
void setVerticalAlignment(VerticalAlignment alignment)
Sets the vertical alignment used for the characters with this format to the alignment specified.
qreal fontWordSpacing() const
bool fontOverline() const
Returns true if the text format's font is overlined; otherwise returns false.
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
QFont::SpacingType fontLetterSpacingType() const
bool fontItalic() const
Returns true if the text format's font is italic; otherwise returns false.
bool fontUnderline() const
Returns true if the text format's font is underlined; otherwise returns false.
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior=FontPropertiesAll)
static QTextCursor fromPosition(QTextDocumentPrivate *d, int pos)
\reentrant \inmodule QtGui
void setBlockCharFormat(const QTextCharFormat &format)
Sets the block char format of the current block (or all blocks that are contained in the selection) t...
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
QTextCharFormat blockCharFormat() const
Returns the block character format of the block the cursor is in.
void insertFragment(const QTextDocumentFragment &fragment)
Inserts the text fragment at the current position().
void setBlockFormat(const QTextBlockFormat &format)
Sets the block format of the current block (or all blocks that are contained in the selection) to for...
void insertText(const QString &text)
Inserts text at the current position, using the current character format.
static const QTextDocumentPrivate * get(const QTextDocument *document)
FragmentMap::ConstIterator FragmentIterator
FragmentIterator find(int pos) const
void mergeCachedResources(const QTextDocumentPrivate *priv)
\reentrant \inmodule QtGui
void setModified(bool m=true)
QString defaultStyleSheet
QTextDocument * clone(QObject *parent=nullptr) const
Creates a new QTextDocument that is a copy of this text document.
void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)
void setSuperScriptBaseline(qreal baseline)
void setBaselineOffset(qreal baseline)
void setIndentWidth(qreal width)
QTextBlock findBlockByLineNumber(int blockNumber) const
int maximumBlockCount
Specifies the limit for blocks in the document.
void setHtml(const QString &html)
Replaces the entire contents of the document with the given HTML-formatted text in the html string.
bool isEmpty() const
Returns true if the document is empty; otherwise returns false.
QTextFrame * frameAt(int pos) const
MetaInformation
This enum describes the different types of meta information that can be added to a document.
qreal baselineOffset() const
void setDefaultTextOption(const QTextOption &option)
int availableRedoSteps() const
Stacks
\value UndoStack The undo stack.
void setResourceProvider(const ResourceProvider &provider)
bool isLayoutEnabled() const
QList< QTextFormat > allFormats() const
Returns a list of text formats for all the formats used in the document.
bool isRedoAvailable() const
Returns true if redo is available; otherwise returns false.
QFont defaultFont
the default font used to display the document's text
QString toHtml() const
Returns a string containing an HTML representation of the document.
QTextBlock findBlockByNumber(int blockNumber) const
int availableUndoSteps() const
int blockCount
the number of text blocks in the document.
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QString toRawText() const
Returns the raw text contained in the document without any formatting information.
bool useDesignMetrics
whether the document uses design metrics of fonts to improve the accuracy of text layout
QSizeF size
the actual size of the document. This is equivalent to documentLayout()->documentSize();
QSizeF pageSize
the page size that should be used for laying out the document
void appendUndoItem(QAbstractUndoItem *)
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
virtual void clear()
Clears the document.
bool isUndoRedoEnabled() const
void baseUrlChanged(const QUrl &url)
int pageCount() const
returns the number of pages in this document.
QTextBlock begin() const
Returns the document's first text block.
bool isUndoAvailable() const
Returns true if undo is available; otherwise returns false.
void setLayoutEnabled(bool b)
QTextOption defaultTextOption() const
the default text option will be set on all \l{QTextLayout}s in the document.
void print(QPagedPaintDevice *printer) const
Prints the document to the given printer.
QVariant resource(int type, const QUrl &name) const
Returns data of the specified type from the resource with the given name.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
QChar characterAt(int pos) const
void setPageSize(const QSizeF &size)
QTextDocument(QObject *parent=nullptr)
Constructs an empty QTextDocument with the given parent.
QTextDocument::ResourceProvider resourceProvider() const
void setDefaultStyleSheet(const QString &sheet)
void setUndoRedoEnabled(bool enable)
QUrl baseUrl
the base URL used to resolve relative resource URLs within the document.
QString toPlainText() const
Returns the plain text contained in the document.
virtual Q_INVOKABLE QVariant loadResource(int type, const QUrl &name)
Loads data of the specified type from the resource with the given name.
QTextObject * object(int objectIndex) const
Returns the text object associated with the given objectIndex.
void clearUndoRedoStacks(Stacks historyToClear=UndoAndRedoStacks)
QTextCursor find(const QString &subString, int from=0, FindFlags options=FindFlags()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setDocumentMargin(qreal margin)
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
qreal subScriptBaseline() const
QTextBlock end() const
This function returns a block to test for the end of the document while iterating over it.
QString metaInformation(MetaInformation info) const
Returns meta information about the document of the type specified by info.
Qt::CursorMoveStyle defaultCursorMoveStyle() const
QTextBlock firstBlock() const
static void setDefaultResourceProvider(const ResourceProvider &provider)
void setPlainText(const QString &text)
Replaces the entire contents of the document with the given plain text.
void setMaximumBlockCount(int maximum)
QTextFrame * rootFrame() const
Returns the document's root frame.
void setDocumentLayout(QAbstractTextDocumentLayout *layout)
Sets the document to use the given layout.
void setMetaInformation(MetaInformation info, const QString &)
Sets the document's meta information of the type specified by info to the given string.
qreal superScriptBaseline() const
static QTextDocument::ResourceProvider defaultResourceProvider()
void setBaseUrl(const QUrl &url)
QTextBlock lastBlock() const
void addResource(int type, const QUrl &name, const QVariant &resource)
Adds the resource resource to the resource cache, using type and name as identifiers.
void setSubScriptBaseline(qreal baseline)
~QTextDocument()
Destroys the document.
void undo()
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual QTextObject * createObject(const QTextFormat &f)
Creates and returns a new document object (a QTextObject), based on the given format.
std::function< QVariant(const QUrl &)> ResourceProvider
void markContentsDirty(int from, int length)
Marks the contents specified by the given position and length as "dirty", informing the document that...
void setUseDesignMetrics(bool b)
void setTextWidth(qreal width)
void drawContents(QPainter *painter, const QRectF &rect=QRectF())
int characterCount() const
void redo()
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTextCharFormat toCharFormat() const
Returns this format as a character format.
QBrush background() const
Returns the brush used to paint the document's background.
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QString ty...
@ TableCellBottomBorderStyle
@ TableCellTopBorderStyle
@ TableCellBottomBorderBrush
@ TableCellRightBorderStyle
@ BlockTrailingHorizontalRulerWidth
@ TableCellTopBorderBrush
@ TableCellRightBorderBrush
@ TableCellLeftBorderStyle
@ TableCellLeftBorderBrush
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.
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
QTextImageFormat toImageFormat() const
Returns this format as an image format.
QMap< int, QVariant > properties() const
Returns a map with all properties of this text format.
QTextTableCellFormat toTableCellFormat() const
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false.
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
void merge(const QTextFormat &other)
Merges the other format with this format; where there are conflicts the other format takes precedence...
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,...
QString text() const
Returns the text fragment's as plain text.
QTextCharFormat charFormat() const
Returns the text fragment's character format.
QBrush borderBrush() const
BorderStyle borderStyle() const
Position
This enum describes how a frame is located relative to the surrounding text.
void setMargin(qreal margin)
Sets the frame's margin in pixels.
QTextFrame * parentFrame() const
Returns the parent frame of the current frame.
QTextFrame * currentFrame() const
Returns the current frame pointed to by the iterator, or \nullptr if the iterator currently points to...
bool atEnd() const
Returns true if the current item is the last item in the text frame.
Q_GUI_EXPORT QTextBlock currentBlock() const
Returns the current block the iterator points to.
void setFrameFormat(const QTextFrameFormat &format)
Sets the frame's format.
QTextFrameFormat frameFormat() const
Returns the frame's format.
iterator begin() const
Returns an iterator pointing to the first document element inside the frame.
QString toHtml(ExportMode mode=ExportEntireDocument)
Returns the document in HTML format.
QTextHtmlExporter(const QTextDocument *_doc)
static int lookupElement(const QString &element)
qreal width() const
Returns the width of the rectangle occupied by the image.
qreal height() const
Returns the height of the rectangle occupied by the image.
QString name() const
Returns the name of the image.
int indent() const
Returns the list format's indentation.
int itemNumber(const QTextBlock &) const
Returns the index of the list item that corresponds to the given block.
QTextListFormat format() const
Returns the list's format.
void import(QTextDocument *doc, const QString &markdown)
QBrush leftBorderBrush() const
QTextFrameFormat::BorderStyle bottomBorderStyle() const
QTextFrameFormat::BorderStyle rightBorderStyle() const
QBrush rightBorderBrush() const
qreal rightBorder() const
QBrush topBorderBrush() const
qreal bottomBorder() const
qreal leftPadding() const
qreal rightPadding() const
QBrush bottomBorderBrush() const
QTextFrameFormat::BorderStyle leftBorderStyle() const
qreal bottomPadding() const
QTextFrameFormat::BorderStyle topBorderStyle() const
QTextCharFormat format() const
Returns the cell's character format.
int columnSpan() const
Returns the number of columns this cell spans.
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.
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.
static QThread * currentThread()
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
QString scheme() const
Returns the scheme of the URL.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
QSet< QString >::iterator it
@ StyleSheetOrigin_UserAgent
Combined button and popup list for selecting options.
Q_GUI_EXPORT QString convertFromPlainText(const QString &plain, WhiteSpaceMode mode=WhiteSpacePre)
Converts the plain text string plain to an HTML-formatted paragraph while preserving most of its look...
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush &brush)
#define Q_DECL_CONST_FUNCTION
AudioChannelLayoutTag tag
Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray &payload)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
int qRound(qfloat16 d) noexcept
Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n)
\inmodule QtCore \title Global Qt Declarations
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
#define Q_RETURN_ARG(Type, data)
#define Q_ARG(Type, data)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLenum GLuint GLsizei const GLenum * props
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void * table
GLsizei const GLchar *const * string
[0]
static QT_BEGIN_NAMESPACE bool isDigit(ushort ch)
#define Q_ASSERT_X(cond, x, msg)
static QString colorValue(QColor color)
static bool isOrderedList(int style)
static QLatin1StringView richtextBorderStyleToHtmlBorderStyle(QTextFrameFormat::BorderStyle style)
static QStringList resolvedFontFamilies(const QTextCharFormat &format)
static void printPage(int index, QPainter *painter, const QTextDocument *doc, const QRectF &body, const QPointF &pageNumberPos)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n)
\inmodule QtCore \title Global Qt Declarations
static bool findInBlock(const QTextBlock &block, const QString &expression, int offset, QTextDocument::FindFlags options, QTextCursor *cursor)
static QTextFormat formatDifference(const QTextFormat &from, const QTextFormat &to)
bool qHasPixmapTexture(const QBrush &brush)
#define QTextBeginningOfFrame
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
static int compare(quint64 a, quint64 b)
static QString quote(const QString &str)
QVideoFrameFormat::PixelFormat fmt
file open(QIODevice::ReadOnly)
QFileInfo info(fileName)
[8]
QFileInfo fi("c:/temp/foo")
[newstuff]
QUrl url("example.com")
[constructor-url-reference]
\reentrant \inmodule QtGui
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent