64 #include "private/qtextedit_p.h" 65 #include "private/qdataurl_p.h" 68 #include <private/qprinter_p.h> 69 #include <private/qabstracttextdocumentlayout_p.h> 99 while (start < text.
length()) {
101 && start + 2 < text.
length()
126 for (
int i = open+1; i < close; ++i) {
127 if (text[i].
isDigit() || text[i].isLetter())
129 else if (!tag.
isEmpty() && text[i].isSpace())
136 #ifndef QT_NO_TEXTHTMLPARSER 140 #endif // QT_NO_TEXTHTMLPARSER 163 for (
int i = 0; i < plain.
length(); ++i) {
198 for (
int i = 0; i < plain.
length(); ++i) {
216 rich +=
QChar(0x00a0U);
219 rich +=
QChar(0x00a0U);
224 rich +=
QChar(0x00a0U);
241 #ifndef QT_NO_TEXTCODEC 399 #ifndef QT_NO_CSSPARSER 414 return d->length() <= 1;
424 d->resources.clear();
444 const int pos =
d->undoRedo(
true);
445 if (cursor && pos >= 0) {
465 const int pos =
d->undoRedo(
false);
466 if (cursor && pos >= 0) {
496 d->clearUndoRedoStacks(stacksToClear,
true);
534 d->appendUndoItem(item);
550 d->enableUndoRedo(enable);
556 return d->isUndoRedoEnabled();
586 return d->maximumBlockCount;
592 d->maximumBlockCount = maximum;
593 d->ensureMaximumBlockCount();
610 return d->defaultTextOption;
624 d->defaultTextOption = option;
626 d->lout->documentChanged(0, 0,
d->length());
641 return d->defaultCursorMoveStyle;
655 d->defaultCursorMoveStyle = style;
671 d->documentChange(from, length);
672 if (!
d->inContentsChange) {
674 d->lout->documentChanged(
d->docChangeFrom,
d->docChangeOldLength,
d->docChangeLength);
675 d->docChangeFrom = -1;
702 if (b ==
d->defaultTextOption.useDesignMetrics())
704 d->defaultTextOption.setUseDesignMetrics(b);
706 d->lout->documentChanged(0, 0,
d->length());
712 return d->defaultTextOption.useDesignMetrics();
772 return d->pageSize.width();
789 return lout->idealWidth();
805 return d->documentMargin;
811 if (
d->documentMargin != margin) {
812 d->documentMargin = margin;
820 d->lout->documentChanged(0, 0,
d->length());
840 return d->indentWidth;
860 if (
d->indentWidth != width) {
861 d->indentWidth = width;
863 d->lout->documentChanged(0, 0,
d->length());
889 if (size.
width() != 0) {
894 if (w*3 < 5*size.
height()) {
944 return d->blockMap().numNodes();
962 return d->blockMap().length(2);
995 if (pos < 0 || pos >=
d->length())
999 const int offsetInFragment =
qMax(0, pos - fragIt.position());
1022 #ifndef QT_NO_CSSPARSER 1026 d->defaultStyleSheet = sheet;
1030 parser.
parse(&
d->parsedDefaultStyleSheet);
1036 return d->defaultStyleSheet;
1038 #endif // QT_NO_CSSPARSER 1144 return d->isUndoAvailable();
1155 return d->isRedoAvailable();
1170 return d->availableUndoSteps();
1185 return d->availableRedoSteps();
1217 d->setLayout(layout);
1285 for (; uc != e; ++uc) {
1312 bool previousState =
d->isUndoRedoEnabled();
1313 d->enableUndoRedo(
false);
1314 d->beginEditBlock();
1318 d->enableUndoRedo(previousState);
1336 #ifndef QT_NO_TEXTHTMLPARSER 1341 bool previousState =
d->isUndoRedoEnabled();
1342 d->enableUndoRedo(
false);
1343 d->beginEditBlock();
1347 d->enableUndoRedo(previousState);
1350 #endif // QT_NO_TEXTHTMLPARSER 1408 return find(expr, from, options);
1444 return find(expr, pos, options);
1449 QTextDocument::FindFlags options,
QTextCursor &cursor)
1451 const QRegExp expr(expression);
1456 while (offset >=0 && offset <= text.
length()) {
1463 const int start = idx;
1522 if (!(options & FindBackward)) {
1525 if (
findInBlock(block, expr, blockOffset, options, cursor))
1528 block = block.
next();
1531 int blockOffset = pos - block.
position();
1533 if (
findInBlock(block, expr, blockOffset, options, cursor))
1536 blockOffset = block.
length() - 1;
1573 return find(expr, pos, options);
1610 return d->frameAt(pos);
1619 return d->rootFrame();
1628 return d->objectForIndex(objectIndex);
1637 return d->objectForFormat(f);
1752 d->lout->documentChanged(0, 0,
d->length());
1775 d->setDefaultFont(font);
1777 d->lout->documentChanged(0, 0,
d->length());
1786 return d->defaultFont();
1828 #ifndef QT_NO_PRINTER 1846 layout->draw(painter, ctx);
1848 if (!pageNumberPos.
isNull()) {
1854 qRound(pageNumberPos.
y() + view.top()),
1888 if (!printer || !printer->
isValid())
1891 if (!
d->title.isEmpty())
1894 bool documentPaginated =
d->pageSize.isValid() && !
d->pageSize.isNull()
1895 &&
d->pageSize.height() !=
INT_MAX;
1897 if (!documentPaginated && !printer->
fullPage() && !printer->d_func()->hasCustomPageMargins)
1913 if (documentPaginated) {
1915 qreal sourceDpiY = sourceDpiX;
1927 p.
scale(dpiScaleX, dpiScaleY);
1929 QSizeF scaledPageSize =
d->pageSize;
1930 scaledPageSize.
rwidth() *= dpiScaleX;
1931 scaledPageSize.
rheight() *= dpiScaleY;
1936 p.
scale(printerPageSize.width() / scaledPageSize.
width(),
1937 printerPageSize.height() / scaledPageSize.
height());
1939 doc =
clone(const_cast<QTextDocument *>(
this));
1940 clonedDoc.
reset(const_cast<QTextDocument *>(doc));
1943 srcBlock.
isValid() && dstBlock.isValid();
1944 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) {
1945 dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats());
1952 layout->d_func()->handlers =
documentLayout()->d_func()->handlers;
1956 if (printer->
fullPage() && !printer->d_func()->hasCustomPageMargins) {
1958 margin = (int) ((2/2.54)*dpiy);
1965 body =
QRectF(0, 0, pageRect.width(), pageRect.height());
1966 pageNumberPos =
QPointF(body.width() - margin,
1967 body.height() - margin
1983 int fromPage = printer->
fromPage();
1984 int toPage = printer->
toPage();
1985 bool ascending =
true;
1987 if (fromPage == 0 && toPage == 0) {
1992 fromPage =
qMax(1, fromPage);
1995 if (toPage < fromPage) {
2008 for (
int i = 0; i < docCopies; ++i) {
2010 int page = fromPage;
2012 for (
int j = 0; j < pageCopies; ++j) {
2016 printPage(page, &p, doc, body, pageNumberPos);
2017 if (j < pageCopies - 1)
2032 if ( i < docCopies - 1)
2083 r =
d->cachedResources.value(name);
2085 r = const_cast<QTextDocument *>(
this)->loadResource(type, name);
2112 d->resources.insert(name, resource);
2140 #ifndef QT_NO_TEXTEDIT 2142 QUrl resolvedName = edit->d_func()->resolveUrl(name);
2143 r = edit->loadResource(type, resolvedName);
2146 #ifndef QT_NO_TEXTCONTROL 2148 r = control->loadResource(type, name);
2158 QUrl currentURL =
d->url;
2167 resourceUrl = currentURL.
resolved(name);
2176 }
else if (currentURL.
isEmpty()) {
2204 d->cachedResources.insert(name, r);
2223 : doc(_doc), fragmentMarkers(false)
2242 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" 2243 "<html><head><meta name=\"qrichtext\" content=\"1\" />");
2301 if (rootFmt == defaultFmt)
2321 bool attributesEmitted =
false;
2327 attributesEmitted =
true;
2336 attributesEmitted =
true;
2338 static const char *
const sizeNames[] = {
2339 "small",
"medium",
"large",
"x-large",
"xx-large" 2341 const char *
name = 0;
2343 if (idx >= 0 && idx <= 4) {
2344 name = sizeNames[idx];
2350 attributesEmitted =
true;
2356 attributesEmitted =
true;
2364 attributesEmitted =
true;
2372 attributesEmitted =
true;
2376 html += decorationTag;
2377 bool hasDecoration =
false;
2378 bool atLeastOneDecorationSet =
false;
2382 hasDecoration =
true;
2385 atLeastOneDecorationSet =
true;
2391 hasDecoration =
true;
2394 atLeastOneDecorationSet =
true;
2400 hasDecoration =
true;
2403 atLeastOneDecorationSet =
true;
2407 if (hasDecoration) {
2408 if (!atLeastOneDecorationSet)
2411 attributesEmitted =
true;
2421 attributesEmitted =
true;
2429 attributesEmitted =
true;
2450 attributesEmitted =
true;
2461 attributesEmitted =
true;
2468 attributesEmitted =
true;
2471 return attributesEmitted;
2517 Q_ASSERT_X(0,
"QTextHtmlExporter::emitFloatStyle()",
"pos should be a valid enum type");
2617 bool closeAnchor =
false;
2642 bool attributesEmitted =
false;
2645 if (attributesEmitted)
2651 for (
int i = 0; isImage && i < txt.
length(); ++i) {
2685 for (
int i = 0; i < lines.
count(); ++i) {
2692 if (attributesEmitted)
2721 const bool emptyBlock = block.
begin().
atEnd();
2760 if (!diff.properties().isEmpty())
2791 const int style = format.
style();
2818 styleString += numberPrefix;
2830 styleString += numberSuffix;
2837 html += styleString;
2929 if (qvariant_cast<QImage>(v).cacheKey() == cacheKey)
2934 if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey)
2998 const int rows = table->
rows();
2999 const int columns = table->
columns();
3003 columnWidths.
resize(columns);
3009 for (
int i = 0; i < columns; ++i)
3010 widthEmittedForColumn[i] =
false;
3013 if (headerRowCount > 0)
3016 for (
int row = 0; row < rows; ++row) {
3019 for (
int col = 0; col < columns; ++col) {
3023 if (cell.
row() != row)
3026 if (cell.
column() != col)
3031 if (!widthEmittedForColumn[col] && cell.
columnSpan() == 1) {
3033 widthEmittedForColumn[col] =
true;
3084 html += QLatin1Char(
'>');
3094 if (headerRowCount > 0 && row == headerRowCount - 1)
3103 if (!frameIt.
atEnd()) {
3114 !
it.atEnd(); ++
it) {
3116 if (
QTextTable *table = qobject_cast<QTextTable *>(f)) {
3121 }
else if (
it.currentBlock().isValid()) {
3155 html += styleAttribute;
3156 const int originalHtmlLength =
html.
length();
3209 #ifndef QT_NO_TEXTHTMLPARSER 3214 #endif // QT_NO_TEXTHTMLPARSER 3222 return d->formatCollection()->formats;
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVariant class acts like a union for the most common Qt data types.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QPainter class performs low-level painting on widgets and other paint devices.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
bool fullPage() const
Returns true if the origin of the printer's coordinate system is at the corner of the page and false ...
int columns() const
Returns the number of columns in the table.
qreal cellSpacing() const
Returns the table's cell spacing.
QString findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap)
qreal rightPadding() const
Gets the right padding of the table cell.
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
QString text() const
Returns the block's contents as plain text.
QTextCharFormat defaultCharFormat
int toPage() const
Returns the number of the last page in a range of pages to be printed (the "to page" setting)...
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
bool isFrameFormat() const
Returns true if this text format is a FrameFormat; otherwise returns false.
The QTextListFormat class provides formatting information for lists in a QTextDocument.
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n)
void setPatternSyntax(PatternSyntax syntax)
Sets the syntax mode for the regular expression.
#define QT_END_NAMESPACE
This macro expands to.
const QColor & color() const
Returns the brush color.
PrinterState printerState() const
Returns the current state of the printer.
QRect pageRect() const
Returns the page's rectangle; this is usually smaller than the paperRect() since the page normally ha...
const Key key(const T &value) const
Returns the first key with value value.
int lineCount() const
Returns the number of lines of this document (if the layout supports this).
int count() const
Returns the number of items in the list.
QTextList * textList() const
If the block represents a list item, returns the list that the item belongs to; otherwise returns 0...
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...
int lastIndexIn(const QString &str, int offset=-1, CaretMode caretMode=CaretAtZero) const
Attempts to find a match backwards in str from position offset.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
const QChar at(int i) const
Returns the character at the given index position in the string.
The QRegExp class provides pattern matching using regular expressions.
bool fontStrikeOut() const
Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherw...
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
int headerRowCount() const
Returns the number of rows in the table that define the header.
static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int offset, QTextDocument::FindFlags options, QTextCursor &cursor)
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
QTextBlock begin() const
Returns the document's first text block.
#define it(className, varName)
bool isEmpty() const
Returns true if the document is empty; otherwise returns false.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QTextFrame class represents a frame in a QTextDocument.
Type type() const
Returns the type of this length object.
void adjustSize()
Adjusts the document to a reasonable size.
Position
This enum describes how a frame is located relative to the surrounding text.
QTextFrame::iterator begin() const
Returns a frame iterator pointing to the beginning of the table's cell.
qreal width() const
Returns the width.
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn't have a selection.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
QTextTableCellFormat toTableCellFormat() const
Returns this format as a table cell format.
int fromPage() const
Returns the number of the first page in a range of pages to be printed (the "from page" setting)...
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
bool atEnd() const
Returns true if the current item is the last item in the text block.
QTextHtmlExporter(const QTextDocument *_doc)
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...
PageBreakFlags pageBreakPolicy() const
Returns the currently set page break policy for the paragraph.
void chop(int n)
Removes n characters from the end of the string.
void setModified(bool m=true)
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
QTextFrame * currentFrame() const
Returns the current frame pointed to by the iterator, or 0 if the iterator currently points to a bloc...
int length() const
Returns the number of characters in this string.
The QPointF class defines a point in the plane using floating point precision.
qreal height() const
Returns the height.
void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit)
This function sets the left, top, right and bottom page margins for this printer. ...
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
void restore()
Restores the current painter state (pops a saved state off the stack).
int availableUndoSteps() const
Returns the number of available undo steps.
void emitAlignment(Qt::Alignment alignment)
void setVerticalAlignment(VerticalAlignment alignment)
Sets the vertical alignment used for the characters with this format to the alignment specified...
static QTextCodec * codecForHtml(const QByteArray &ba)
Tries to detect the encoding of the provided snippet of HTML in the given byte array, ba, by checking the BOM (Byte Order Mark) and the content-type meta header and returns a QTextCodec instance that is capable of decoding the html to unicode.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
void setFont(const QFont &font)
Sets the text format's font.
int matchedLength() const
Returns the length of the last matched string, or -1 if there was no match.
bool useDesignMetrics() const
const QTextDocument * doc
QString text() const
Returns the text fragment's as plain text.
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
QMap< int, QVariant > properties() const
Returns a map with all properties of this text format.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString anchorName() const
This function is deprecated.
void setDefaultFont(const QFont &f)
void setPageSize(const QSizeF &size)
int count(const T &t) const
Returns the number of occurrences of value in the list.
#define QTextBeginningOfFrame
void setIndentWidth(qreal width)
Sets the width used for text list and text block indenting.
QString anchorHref() const
Returns the text format's hypertext link, or an empty string if none has been set.
QChar characterAt(int pos) const
Returns the character at position pos, or a null character if the position is out of range...
void print(QPrinter *printer) const
Prints the document to the given printer.
qreal leftMargin() const
Returns the width of the frame's left margin in pixels.
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
qreal height() const
Returns the height of the rectangle occupied by the image.
T * qobject_cast(QObject *object)
QFont defaultFont
the default font used to display the document's text
qreal topMargin() const
Returns the paragraph's top margin.
void setWidth(qreal w)
Sets the width to the given width.
QPalette palette
the default color that is used for the text, when no color is specified.
int indent() const
Returns the paragraph's indent.
qreal rightMargin() const
Returns the paragraph's right margin.
Capitalization
Rendering option for text this font applies to.
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
Qt::Alignment alignment() const
Returns the paragraph's alignment.
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
void markContentsDirty(int from, int length)
Marks the contents specified by the given position and length as "dirty", informing the document that...
The QSizeF class defines the size of a two-dimensional object using floating point precision...
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
The QChar class provides a 16-bit Unicode character.
QChar * data()
Returns a pointer to the data stored in the QString.
QString toPlainText() const
Returns the plain text contained in the document.
void insertText(const QString &text)
Inserts text at the current position, using the current character format.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
QTextOption defaultTextOption
void save()
Saves the current painter state (pushes the state onto a stack).
FragmentMap::ConstIterator FragmentIterator
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
void setMetaInformation(MetaInformation info, const QString &)
Sets the document's meta information of the type specified by info to the given string.
void emitBlock(const QTextBlock &block)
void setDefaultTextOption(const QTextOption &option)
Sets the default text option.
QString path() const
Returns the path of the URL.
qreal x() const
Returns the x-coordinate of this point.
void resize(int size)
Sets the size of the vector to size.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
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 rowSpan() const
Returns the number of rows this cell spans.
QTextFrame * rootFrame() const
Returns the document's root frame.
int position() const
Returns the index of the block's first character within the document.
QTextBlock end() const
This function returns a block to test for the end of the document while iterating over it...
void emitTextFrame(const QTextFrame *frame)
QString defaultStyleSheet
Position position() const
Returns the positioning policy for frames with this frame format.
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
void reserve(int size)
Attempts to allocate memory for at least size characters.
void setPlainText(const QString &text)
Replaces the entire contents of the document with the given plain text.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
VerticalAlignment
This enum describes the ways that adjacent characters can be vertically aligned.
Qt::Alignment alignment() const
Returns the table's alignment.
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
QTextCharFormat charFormat() const
Returns the text fragment's character format.
The QTextImageFormat class provides formatting information for images in a QTextDocument.
#define QT_BEGIN_NAMESPACE
This macro expands to.
FragmentIterator find(int pos) const
const char * latin1() const
Returns the Latin-1 string stored in this object.
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Style style() const
Returns the list format's style.
The QRectF class defines a rectangle in the plane using floating point precision. ...
qreal topMargin() const
Returns the width of the frame's top margin in pixels.
bool fontOverline() const
Returns true if the text format's font is overlined; otherwise returns false.
QTextCharFormat format() const
Returns the cell's character format.
QTextTableFormat format() const
Returns the table's format.
int column() const
Returns the number of the column in the table that contains this cell.
void emitBackgroundAttribute(const QTextFormat &format)
int revision() const
Returns the document's revision (if undo is enabled).
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
qreal bottomMargin() const
Returns the width of the frame's bottom margin in pixels.
bool isAnchor() const
Returns true if the text is formatted as an anchor; otherwise returns false.
virtual int pageCount() const =0
Returns the number of pages contained in the layout.
QString numberSuffix() const
Returns the list format's number suffix.
int size() const
Returns the number of characters in this string.
bool isListFormat() const
Returns true if this text format is a ListFormat; otherwise returns false.
The QTextFormat class provides formatting information for a QTextDocument.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QTextFrame * parentFrame() const
Returns the frame's parent frame.
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.
The QTextCursor class offers an API to access and modify QTextDocuments.
virtual QSizeF documentSize() const =0
Returns the total size of the document's layout.
static int lookupElement(const QString &element)
qreal height() const
Returns the height of the rectangle.
The QPrinter class is a paint device that paints on a printer.
const T value(const Key &key) const
Returns the value associated with the key key.
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
QSize size() const
Returns the size of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
bool isUndoRedoEnabled() const
The QStringList class provides a list of strings.
qreal idealWidth() const
Returns the ideal width of the text document.
virtual QVariant loadResource(int type, const QUrl &name)
Loads data of the specified type from the resource with the given name.
QString defaultStyleSheet() const
bool isValid() const
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostSc...
int fontWeight() const
Returns the text format's font weight.
void appendUndoItem(QAbstractUndoItem *)
Appends a custom undo item to the undo stack.
QMap< QUrl, QVariant > cachedResources
bool qHasPixmapTexture(const QBrush &brush)
void emitTable(const QTextTable *table)
The QImage class provides a hardware-independent image representation that allows direct access to th...
The QTextBlock class provides a container for text fragments in a QTextDocument.
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QCss::StyleSheet parsedDefaultStyleSheet
void setMaximumBlockCount(int maximum)
qreal width() const
Returns the width of the rectangle.
static bool isOrderedList(int style)
QString toHtml(const QByteArray &encoding, ExportMode mode=ExportEntireDocument)
Returns the document in HTML format.
int row() const
Returns the number of the row in the table that contains this cell.
void setHtml(const QString &html)
Replaces the entire contents of the document with the given HTML-formatted text in the html string...
static bool isDigit(ushort ch)
void insertFragment(const QTextDocumentFragment &fragment)
Inserts the text fragment at the current position().
int pageCount() const
returns the number of pages in this document.
void setUseDesignMetrics(bool b)
QRectF clip
a hint to the layout specifying the area around paragraphs, frames or text require painting...
bool isTableFormat() const
Returns true if this text format is a TableFormat; otherwise returns false.
int maximumBlockCount() const
int position() const
Returns the absolute position of the cursor within the document.
int length() const
Returns the length of the block in characters.
QBrush background() const
Returns the brush used to paint the document's background.
Qt::BrushStyle style() const
Returns the brush style.
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
The QTextTable class represents a table in a QTextDocument.
bool loadFromData(const uchar *buf, uint len, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the len first bytes of the given binary data.
int itemNumber(const QTextBlock &) const
Returns the index of the list item that corresponds to the given block.
void emitFloatStyle(QTextFrameFormat::Position pos, StyleMode mode=EmitStyleTag)
bool supportsMultipleCopies() const
Returns true if the printer supports printing multiple copies of the same document in one job; otherw...
void emitPageBreakPolicy(QTextFormat::PageBreakFlags policy)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
QTextDocument * clone(QObject *parent=0) const
Creates a new QTextDocument that is a copy of this text document.
bool isUndoAvailable() const
Returns true if undo is available; otherwise returns false.
QTextObject * object(int objectIndex) const
Returns the text object associated with the given objectIndex.
qreal textIndent() const
Returns the paragraph's text indent.
The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock...
QTextBlock findBlockByNumber(int blockNumber) const
Returns the text block with the specified blockNumber.
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block's character format.
static void printPage(int index, QPainter *painter, const QTextDocument *doc, const QRectF &body, const QPointF &pageNumberPos)
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
void emitFontFamily(const QString &family)
const T & at(int i) const
Returns the item at index position i in the vector.
Q_GUI_EXPORT QString escape(const QString &plain)
Converts the plain text string plain to a HTML string with HTML metacharacters <, >...
virtual QTextObject * createObject(const QTextFormat &f)
Creates and returns a new document object (a QTextObject), based on the given format.
bool newPage()
Tells the printer to eject the current page and to continue printing on a new page.
MetaInformation
This enum describes the different types of meta information that can be added to a document...
qreal indentWidth() const
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
The iterator class provides an iterator for reading the contents of a QTextFrame. ...
QTextLength height() const
Returns the height of the frame's border rectangle.
QTextBlock findBlockByLineNumber(int blockNumber) const
Returns the text block that contains the specified lineNumber.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
int userState() const
Returns the integer value previously set with setUserState() or -1.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QVector< QTextFormat > allFormats() const
Returns a vector of text formats for all the formats used in the document.
int characterCount() const
Returns the number of characters of this document.
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
bool isEmpty() const
Returns true if the pattern string is empty; otherwise returns false.
uint qstrlen(const char *str)
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
void undo()
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString scheme() const
Returns the scheme of the URL.
void drawContents(QPainter *painter, const QRectF &rect=QRectF())
Draws the content of the document with painter p, clipped to rect.
#define Q_ASSERT_X(cond, where, what)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
void emitFrame(QTextFrame::Iterator frameIt)
QTextLength width() const
Returns the width of the frame's border rectangle.
QTextImageFormat toImageFormat() const
Returns this format as an image format.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
bool nonBreakableLines() const
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
QString numberPrefix() const
Returns the list format's number prefix.
int compare(const QString &s) const
QTextDocument(QObject *parent=0)
Constructs an empty QTextDocument with the given parent.
void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)
Sets the default cursor movement style to the given style.
The QFile class provides an interface for reading from and writing to files.
void setTextWidth(qreal width)
void merge(const QTextFormat &other)
Merges the other format with this format; where there are conflicts the other format takes precedence...
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
CursorMoveStyle
This enum describes the movement style available to text cursors.
The QFont class specifies a font used for drawing text.
QTextCursor find(const QString &subString, int from=0, FindFlags options=0) const
Finds the next occurrence of the string, subString, in the document.
bool collateCopies() const
Returns true if collation is turned on when multiple copies is selected.
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
void mergeCachedResources(const QTextDocumentPrivate *priv)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Q_GUI_EXPORT int qt_defaultDpi()
Type type() const
Returns the storage type of the value stored in the variant.
qreal bottomMargin() const
Returns the paragraph's bottom margin.
qreal documentMargin() const
void emitBorderStyle(QTextFrameFormat::BorderStyle style)
QObject * parent() const
Returns a pointer to the parent object.
qreal fontWordSpacing() const
Returns the current word spacing value.
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.
int rows() const
Returns the number of rows in the table.
QString metaInformation(MetaInformation info) const
Returns meta information about the document of the type specified by info.
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
qreal rightMargin() const
Returns the width of the frame's right margin in pixels.
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
The QTextTableCell class represents the properties of a cell in a QTextTable.
QBrush borderBrush() const
Returns the brush used for the frame's border.
The QAbstractTextDocumentLayout::PaintContext class is a convenience class defining the parameters us...
The QTextLength class encapsulates the different types of length used in a QTextDocument.
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
bool isNull() const
Returns true if the cursor is null; otherwise returns false.
void emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right)
QTextBlock lastBlock() const
Returns the document's last (valid) text block.
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
QPaintDevice * paintDevice() const
Returns the paint device used to render the document's layout.
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 setUndoRedoEnabled(bool enable)
bool hasFragment() const
Returns true if this URL contains a fragment (i.
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
The QTextOption class provides a description of general rich text properties.
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
void setDocumentMargin(qreal margin)
Qt::CursorMoveStyle defaultCursorMoveStyle() const
The default cursor movement style is used by all QTextCursor objects created from the document...
Qt::LayoutDirection textDirection() const
Returns the resolved text direction.
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
void emitTextLength(const char *attribute, const QTextLength &length)
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
qreal y() const
Returns the y-coordinate of this point.
The QTextTableCellFormat class provides formatting information for table cells in a QTextDocument...
The QPixmap class is an off-screen image representation that can be used as a paint device...
int copyCount() const
Returns the number of copies that will be printed.
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
qreal documentMargin
The margin around the document.
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void setDefaultStyleSheet(const QString &sheet)
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
void setHeight(qreal h)
Sets the height to the given height.
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
~QTextDocument()
Destroys the document.
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
void setPaintDevice(QPaintDevice *device)
Sets the paint device used for rendering the document's layout to the given device.
The QTextTableFormat class provides formatting information for tables in a QTextDocument.
void setMargin(qreal margin)
Sets the frame's margin in pixels.
The QTextList class provides a decorated list of items in a QTextDocument.
QTextCharFormat toCharFormat() const
Returns this format as a character format.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
void setFont(const QFont &f)
Sets the painter's font to the given font.
void setCaseSensitivity(Qt::CaseSensitivity cs)
Sets case sensitive matching to cs.
QTextFrame * parentFrame() const
Returns the parent frame of the current frame.
bool parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity=Qt::CaseSensitive)
QTextFrame * frameAt(int pos) const
Returns the frame that contains the text cursor position pos.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
PageBreakFlags pageBreakPolicy() const
Returns the currently set page break policy for the frame/table.
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
bool atEnd() const
Returns true if the current item is the last item in the text frame.
qreal rawValue() const
Returns the constraint value that is specific for the type of the length.
void setDocName(const QString &)
Sets the document name to name.
void redo()
Redoes the last editing operation on the document if redo is available.
QTextDocumentPrivate * docHandle() const
QVariant resource(int type, const QUrl &name) const
Returns data of the specified type from the resource with the given name.
qreal fontPointSize() const
Returns the font size used to display text in this format.
void emitAttribute(const char *attribute, const QString &value)
void emitBlockAttributes(const QTextBlock &block)
qreal topPadding() const
Gets the top padding of the table cell.
bool isImageFormat() const
Returns true if this text format is an image format; otherwise returns false.
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.
int columnSpan() const
Returns the number of columns this cell spans.
void emitFrameStyle(const QTextFrameFormat &format, FrameType frameType)
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
qreal border() const
Returns the width of the border in pixels.
The QTextCodec class provides conversions between text encodings.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
The QFileInfo class provides system-independent file information.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
QTextFragment fragment() const
Returns the text fragment the iterator currently points to.
qreal cellPadding() const
Returns the table's cell padding.
The QTextObject class is a base class for different kinds of objects that can group parts of a QTextD...
QMap< QUrl, QVariant > resources
qreal & rheight()
Returns a reference to the height.
qreal leftPadding() const
Gets the left padding of the table cell.
QTextOption defaultTextOption() const
the default text option will be set on all QTextLayout in the document.
virtual void close()
Calls QFile::flush() and closes the file.
QImage textureImage() const
Returns the custom brush pattern, or a null image if no custom brush pattern has been set...
bool fontItalic() const
Returns true if the text format's font is italic; otherwise returns false.
QString fontFamily() const
Returns the text format's font family.
virtual void clear()
Clears the document.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
qreal bottomPadding() const
Gets the bottom padding of the table cell.
QTextBlock currentBlock() const
Returns the current block the iterator points to.
BorderStyle
This enum describes different border styles for the text frame.
static QTextFormat formatDifference(const QTextFormat &from, const QTextFormat &to)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void setFrameFormat(const QTextFrameFormat &format)
Sets the frame's format.
int availableRedoSteps() const
Returns the number of available redo steps.
QTextFrameFormat frameFormat() const
Returns the frame's format.
int indent() const
Returns the list format's indentation.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
bool emitCharFormatStyle(const QTextCharFormat &format)
qreal leftMargin() const
Returns the paragraph's left margin.
QString name() const
Returns the name of the color in the format "#RRGGBB"; i.e.
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
qreal & rwidth()
Returns a reference to the width.
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
QFont::Capitalization fontCapitalization() const
Returns the current capitalization type of the font.
PageOrder pageOrder() const
Returns the current page order.
QVector< QTextLength > columnWidthConstraints() const
Returns a list of constraints used by this table format to control the appearance of columns in a tab...
QString toHtml(const QByteArray &encoding=QByteArray()) const
Returns a string containing an HTML representation of the document.
Q_DECL_CONSTEXPR int qRound(qreal d)
qint64 cacheKey() const
Returns a number that identifies the contents of this QImage object.
void clear()
Removes all items from the map.
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn't have a selection.
QString name() const
Returns the name of the image.
bool fontUnderline() const
Returns true if the text format's font is underlined; otherwise returns false.
The QMap class is a template class that provides a skip-list-based dictionary.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Q_CORE_EXPORT QPair< QString, QByteArray > qDecodeDataUrl(const QUrl &uri)
Decode a data: URL into its mimetype and payload.
int open(const char *, int,...)
bool loadFromData(const uchar *buf, int len, const char *format=0)
Loads an image from the first len bytes of the given binary data.
void clearUndoRedoStacks(Stacks historyToClear=UndoAndRedoStacks)
Clears the stacks specified by stacksToClear.
bool isLetterOrNumber() const
Returns true if the character is a letter or number (Letter_* or Number_* categories); otherwise retu...
virtual void draw(QPainter *painter, const PaintContext &context)=0
Draws the layout with the given painter using the given context.
iterator begin() const
Returns an iterator pointing to the first document element inside the frame.
bool isRedoAvailable() const
Returns true if redo is available; otherwise returns false.
qreal width() const
Returns the width of the rectangle occupied by the image.
void setDocumentLayout(QAbstractTextDocumentLayout *layout)
Sets the document to use the given layout.
BorderStyle borderStyle() const
Returns the style of the frame's border.
void emitFragment(const QTextFragment &fragment)
Q_GUI_EXPORT QTextCodec * codecForHtml(const QByteArray &ba)
This function is defined in the <QTextDocument> header file.
QFont defaultFont() const
QTextListFormat format() const
Returns the list's format.
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for ...
QTextLength lengthProperty(int propertyId) const
Returns the value of the property given by propertyId.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
QTextBlock firstBlock() const
Returns the document's first text block.