56 #if defined(Q_CC_DIAB) // compiler bug 62 src = _source.
d->
priv;
63 dst = _destination.
d->
priv;
65 this->forceCharFormat = forceCharFormat;
66 primaryCharFormatIndex = convertFormatIndex(fmt);
73 if (objectIndexToSet != -1) {
77 if (newObjectIndex == -1) {
104 const int inFragmentOffset =
qMax(0, pos - fragIt.position());
105 int charsToCopy =
qMin(
int(frag->
size_array[0] - inFragmentOffset), endPos - pos);
110 if (nextBlock.
position() == pos + 1) {
118 if (txtToInsert.length() == 1
140 const int userState = nextBlock.
userState();
161 int row_start, col_start, num_rows, num_cols;
170 for (
int r = row_start; r < row_start + num_rows; ++r) {
171 for (
int c = col_start;
c < col_start + num_cols; ++
c) {
173 const int rspan = cell.
rowSpan();
188 if (r + rspan >= row_start + num_rows) {
191 if (
c + cspan >= col_start + num_cols) {
223 : ref(1), doc(new
QTextDocument), importedFromPlainText(false)
300 QTextCursor cursor(const_cast<QTextDocument *>(document));
389 #ifndef QT_NO_TEXTHTMLPARSER 415 #endif // QT_NO_TEXTHTMLPARSER 443 #ifndef QT_NO_TEXTHTMLPARSER 446 : indent(0), compressNextWhitespace(PreserveWhiteSpace), doc(_doc), importMode(mode)
453 if (startFragmentPos != -1) {
457 const bool hasQtRichtextMetaTag = html.
contains(qt3RichTextHeader);
460 if (startFragmentPos < endFragmentPos)
461 html = html.
mid(startFragmentPos, endFragmentPos - startFragmentPos);
463 html = html.
mid(startFragmentPos);
465 if (hasQtRichtextMetaTag)
466 html.
prepend(qt3RichTextHeader);
469 parse(html, resourceProvider ? resourceProvider :
doc);
594 for (
int i = 0; i < text.
length(); ++i) {
631 textToInsert.
clear();
648 textToInsert.
clear();
786 while (depth > endDepth) {
791 switch (closedNode->
id) {
801 blockTagClosed =
true;
825 blockTagClosed =
false;
833 blockTagClosed =
true;
843 blockTagClosed =
true;
856 blockTagClosed =
true;
860 closedNode = &
at(closedNode->
parent);
874 int tableHeaderRowCount = 0;
876 rowNodes.
reserve(
at(tableNodeIdx).children.count());
878 switch (
at(row).
id) {
887 rowNodes += potentialRow;
889 ++tableHeaderRowCount;
898 int effectiveRow = 0;
899 foreach (
int row, rowNodes) {
905 while (colsInRow < rowColSpanForColumn.
size()) {
908 if (spanInfo.
row + spanInfo.
rowSpan > effectiveRow) {
916 const int currentColumn = colsInRow;
920 spanInfo.
row = effectiveRow;
921 spanInfo.
col = currentColumn;
925 rowColSpans.
append(spanInfo);
928 rowColSpanForColumn.
resize(columnWidths.
size());
936 rowColSpanForColumn[i] = spanInfo;
944 table.
rows = effectiveRow;
1005 table.
frame = textTable;
1007 for (
int i = 0; i < rowColSpans.
count(); ++i) {
1022 bool modifiedBlockFormat =
true;
1023 bool modifiedCharFormat =
true;
1056 modifiedBlockFormat =
false;
1057 modifiedCharFormat =
false;
1065 modifiedBlockFormat =
true;
1083 modifiedBlockFormat =
true;
1092 modifiedBlockFormat =
true;
1096 modifiedBlockFormat =
true;
1104 || !
lists.last().list
1109 modifiedBlockFormat =
true;
1113 modifiedBlockFormat =
true;
1118 modifiedCharFormat =
true;
1127 modifiedBlockFormat =
true;
1132 modifiedBlockFormat =
true;
1136 if (modifiedBlockFormat)
1138 if (modifiedCharFormat)
1159 if (listTopMargin > block.
topMargin()) {
1199 #endif // QT_NO_TEXTHTMLPARSER 1213 #ifndef QT_NO_TEXTHTMLPARSER 1217 return fromHtml(html, 0);
1244 #endif // QT_NO_TEXTHTMLPARSER int objectIndex() const
Returns the index of the format object, or -1 if the format object is invalid.
void setRightPadding(qreal padding)
Sets the right padding of the table cell.
QPointer< QTextList > list
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QTextTable * insertTable(int rows, int cols, const QTextTableFormat &format)
Creates a new table with the given number of rows and columns in the specified format, inserts it at the current cursor position() in the document, and returns the table object.
void endEditBlock()
Indicates the end of a block of editing operations on the document that should appear as a single ope...
void setBorderBrush(const QBrush &brush)
Sets the brush used for the frame's border.
QMap< int, int > objectIndexMap
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
The QTextListFormat class provides formatting information for lists in a QTextDocument.
QString toHtml() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
QTextFrameFormat::BorderStyle borderStyle
#define QT_END_NAMESPACE
This macro expands to.
~QTextDocumentFragment()
Destroys the document fragment.
Table scanTable(int tableNodeIdx)
QTextFormatCollection & formatCollection
QTextList * textList() const
If the block represents a list item, returns the list that the item belongs to; otherwise returns 0...
const QTextDocument * resourceProvider
const QChar at(int i) const
Returns the character at the given index position in the string.
int rightMargin(int i) const
void setUserState(int state)
Stores the specified state integer value in the text block.
void setBorder(qreal border)
Sets the width (in pixels) of the frame's border.
void appendFragments(int pos, int endPos)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void setBorderStyle(BorderStyle style)
Sets the style of the frame's border.
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
Type type() const
Returns the type of this length object.
QTextFrame * insertFrame(const QTextFrameFormat &format)
Inserts a frame with the given format at the current cursor position(), moves the cursor position() i...
Position
This enum describes how a frame is located relative to the surrounding text.
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn't have a selection.
QTextTableCellFormat toTableCellFormat() const
Returns this format as a table cell format.
The QByteArray class provides an array of bytes.
PageBreakFlags pageBreakPolicy() const
Returns the currently set page break policy for the paragraph.
int length() const
Returns the number of characters in this string.
void setBlockCharFormat(const QTextCharFormat &format)
Sets the block char format of the current block (or all blocks that are contained in the selection) t...
QString & prepend(QChar c)
void setIndent(int indent)
Sets the list format's indentation.
void insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment)
Inserts the image defined by the given format at the cursor's current position with the specified ali...
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
WhiteSpace compressNextWhitespace
void setWidth(qreal width)
Convenience method that sets the width of the frame's border rectangle's width to the specified fixed...
QTextDocumentFragmentPrivate * d
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
int createObjectIndex(const QTextFormat &f)
const QTextHtmlParserNode & at(int i) const
void setCellPadding(qreal padding)
Sets the cell padding for the table.
QTextDocumentPrivate * dst
QString textListNumberPrefix
TableCellIterator currentCell
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString anchorName() const
This function is deprecated.
#define QTextBeginningOfFrame
void setBlockFormat(const QTextBlock &from, const QTextBlock &to, const QTextBlockFormat &newFormat, FormatChangeMode mode=SetFormat)
bool ref()
Atomically increments the value of this QAtomicInt.
qreal leftMargin() const
Returns the width of the frame's left margin in pixels.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document's background to the brush specified.
void setTableCellRowSpan(int tableCellRowSpan)
If this character format is applied to characters in a table cell, the cell will span tableCellRowSpa...
QTextTableFormat toTableFormat() const
Returns this format as a table format.
The QString class provides a Unicode character string.
QTextFormat format(int idx) const
qreal topMargin() const
Returns the paragraph's top margin.
void mergeCells(int row, int col, int numRows, int numCols)
Merges the cell at the specified row and column with the adjacent cells into one cell.
QTextFormat objectFormat(int objectIndex) const
void setLeftPadding(qreal padding)
Sets the left padding of the table cell.
qreal rightMargin() const
Returns the paragraph's right margin.
The QVector class is a template class that provides a dynamic array.
bool hasOnlyWhitespace() const
void mergeBlockFormat(const QTextBlockFormat &modifier)
Modifies the block format of the current block (or all blocks that are contained in the selection) wi...
Qt::Alignment alignment() const
Returns the paragraph's alignment.
QTextCursor lastCursorPosition() const
Returns the last valid cursor position in this cell.
QSharedDataPointer< QTextCursorPrivate > d
The QChar class provides a 16-bit Unicode character.
QTextListFormat::Style listStyle
int insertBlock(int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation=QTextUndoCommand::MoveCursor)
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.
int topPadding(int i) const
void insert(int pos, const QString &text, int format)
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...
Qt::LayoutDirection layoutDirection() const
Returns the document's layout direction.
const QString originalText
void setMetaInformation(MetaInformation info, const QString &)
Sets the document's meta information of the type specified by info to the given string.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void resize(int size)
Sets the size of the vector to size.
QTextHtmlParserNode::WhiteSpaceMode wsm
void setColumnWidthConstraints(const QVector< QTextLength > &constraints)
Sets the column width constraints for the table.
void setTopMargin(qreal margin)
Sets the paragraph's top margin.
int rowSpan() const
Returns the number of rows this cell spans.
QTextFrame * rootFrame() const
Returns the document's root frame.
void setAnchorNames(const QStringList &names)
Sets the text format's anchor names.
int position() const
Returns the index of the block's first character within the document.
void setPosition(Position f)
Sets the policy for positioning frames with this frame format.
int leftMargin(int i) const
QTextFrame * currentFrame() const
Returns a pointer to the current frame.
void setTopMargin(qreal margin)
Sets the frame's top margin in pixels.
void setTableCellColumnSpan(int tableCellColumnSpan)
If this character format is applied to characters in a table cell, the cell will span tableCellColumn...
void setLeftMargin(qreal margin)
Sets the paragraph's left margin.
void reserve(int size)
Attempts to allocate memory for at least size characters.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const
If the selection spans over table cells, firstRow is populated with the number of the first row in th...
int type() const
Returns the type of this format.
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
void append(const T &t)
Inserts value at the end of the list.
QTextCharFormat charFormat
void setBottomMargin(qreal margin)
Sets the paragraph's bottom margin.
The QTextImageFormat class provides formatting information for images in a QTextDocument.
#define QT_BEGIN_NAMESPACE
This macro expands to.
FragmentIterator find(int pos) const
QTextTableCell cell() const
qreal topMargin() const
Returns the width of the frame's top margin in pixels.
QTextCharFormat format() const
Returns the cell's character format.
QTextTableFormat format() const
Returns the table's format.
void setBottomPadding(qreal padding)
Sets the bottom padding of the table cell.
int column() const
Returns the number of the column in the table that contains this cell.
QTextBlock blocksBegin() const
qreal bottomMargin() const
Returns the width of the frame's bottom margin in pixels.
void setHeaderRowCount(int count)
Declares the first count rows of the table as table header.
int lastPosition() const
Returns the last document position inside the frame.
void appendBlock(const QTextBlockFormat &format, QTextCharFormat charFmt=QTextCharFormat())
static QTextDocumentFragment fromHtml(const QString &html)
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text...
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
QTextTable * currentTable() const
Returns a pointer to the current table if the cursor position() is inside a block that is part of a t...
void setPageBreakPolicy(PageBreakFlags flags)
Sets the page break policy for the frame/table to policy.
bool isAnchor() const
Returns true if the text is formatted as an anchor; otherwise returns false.
QTextDocumentFragment()
Constructs an empty QTextDocumentFragment.
int size() const
Returns the number of characters in this string.
Style
This enum describes the symbols used to decorate list items:
The QTextFormat class provides formatting information for a QTextDocument.
int bottomMargin(int i) const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setBlockFormat(const QTextBlockFormat &format)
Sets the block format of the current block (or all blocks that are contained in the selection) to for...
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.
void setName(const QString &name)
Sets the name of the image.
QTextFormatCollection * formatCollection()
const T value(const Key &key) const
Returns the value associated with the key key.
int primaryCharFormatIndex
bool deref()
Atomically decrements the value of this QAtomicInt.
void setPageBreakPolicy(PageBreakFlags flags)
Sets the page break policy for the paragraph to policy.
QTextBlockFormat blockFormat
static QTextDocumentFragment fromPlainText(const QString &plainText)
Returns a document fragment that contains the given plainText.
void setFormat(const QTextCharFormat &format)
Sets the cell's character format to format.
QTextCopyHelper(const QTextCursor &_source, const QTextCursor &_destination, bool forceCharFormat=false, const QTextCharFormat &fmt=QTextCharFormat())
void append(const T &t)
Inserts value at the end of the vector.
bool isEmpty() const
Returns true if the fragment is empty; otherwise returns false.
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
int topMargin(int i) const
void mergeBlockCharFormat(const QTextCharFormat &modifier)
Modifies the block char format of the current block (or all blocks that are contained in the selectio...
QTextDocumentFragment & operator=(const QTextDocumentFragment &rhs)
Assigns the other fragment to this fragment.
int convertFormatIndex(const QTextFormat &oldFormat, int objectIndexToSet=-1)
int bottomPadding(int i) const
void setNumberPrefix(const QString &numberPrefix)
Sets the list format's number prefix to the string specified by numberPrefix.
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 clear()
Removes all items from the list.
int position() const
Returns the absolute position of the cursor within the document.
QBrush background() const
Returns the brush used to paint the document's background.
Qt::BrushStyle style() const
Returns the brush style.
The QTextTable class represents a table in a QTextDocument.
void setNonBreakableLines(bool b)
If b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable...
void mergeCharFormat(const QTextCharFormat &modifier)
Merges the cursor's current character format with the properties described by format modifier...
void insert(QTextCursor &cursor) const
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block's character format.
QTextBlock block() const
Returns the block that contains the cursor.
const T & at(int i) const
Returns the item at index position i in the vector.
QTextCharFormat blockCharFormat() const
Returns the block character format of the block the cursor is in.
bool isNull() const
Returns true if this string is null; otherwise returns false.
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...
void setColumns(int columns)
Sets the number of columns required by the table format.
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...
QString textListNumberSuffix
QTextDocumentFragmentPrivate(const QTextCursor &cursor=QTextCursor())
void beginEditBlock()
Indicates the start of a block of editing operations on the document that should appear as a single o...
void setCellSpacing(qreal spacing)
Sets the cell spacing for the table.
static QTextListFormat::Style nextListStyle(QTextListFormat::Style style)
void merge(const QTextFormat &other)
Merges the other format with this format; where there are conflicts the other format takes precedence...
void setNumberSuffix(const QString &numberSuffix)
Sets the list format's number suffix to the string specified by numberSuffix.
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
void clear()
Clears the contents of the string and makes it empty.
void setAlignment(Qt::Alignment alignment)
Sets the table's alignment.
void mergeCachedResources(const QTextDocumentPrivate *priv)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
void setHeight(qreal height)
Sets the height of the rectangle occupied by the image.
void setLeftMargin(qreal margin)
Sets the frame's left margin in pixels.
void setHeight(qreal height)
Sets the frame's height.
qreal bottomMargin() const
Returns the paragraph's bottom margin.
T & last()
Returns a reference to the last item in the vector.
qreal rightMargin() const
Returns the width of the frame's right margin in pixels.
void setTopPadding(qreal padding)
Sets the top padding of the table cell.
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
The QTextTableCell class represents the properties of a cell in a QTextTable.
int appendFragment(int pos, int endPos, int objectIndex=-1)
bool hasComplexSelection() const
Returns true if the cursor contains a selection that is not simply a range from selectionStart() to s...
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 add(const QTextBlock &block)
Makes the given block part of the list.
void setUndoRedoEnabled(bool enable)
void setRightMargin(qreal margin)
Sets the frame's right margin in pixels.
qreal value(qreal maximumLength) const
Returns the effective length, constrained by the type of the length object and the specified maximumL...
int leftPadding(int i) const
void clearColumnWidthConstraints()
Clears the column width constraints for the table.
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
void setIndent(int indent)
Sets the paragraph's indentation.
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.
void setRightMargin(qreal margin)
Sets the paragraph's right margin.
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
The QTextTableCellFormat class provides formatting information for table cells in a QTextDocument...
QTextCursor lastCursorPosition() const
Returns the last cursor position inside the frame.
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
void setAnchor(bool anchor)
If anchor is true, text with this format represents an anchor, and is formatted in the appropriate wa...
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
The QTextTableFormat class provides formatting information for tables in a QTextDocument.
const QTextHtmlParserNode * currentNode
QString toPlainText() const
Returns the document fragment's text as plain text (i.e.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
ProcessNodeResult processSpecialNodes()
void reserve(int size)
Attempts to allocate memory for at least size elements.
ProcessNodeResult processBlockNode()
QTextBlock blocksFind(int pos) const
int columnSpan() const
Returns the number of columns this cell spans.
QTextFormat convertFormat(const QTextFormat &fmt)
void setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode=SetFormat)
void setBottomMargin(qreal margin)
Sets the frame's bottom margin in pixels.
void setObjectIndex(int object)
Sets the format object's object index.
static const KeyPair *const end
void setStyle(Style style)
Sets the list format's style.
QTextHtmlImporter(QTextDocument *_doc, const QString &html, ImportMode mode, const QTextDocument *resourceProvider=0)
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the document's layout direction to the specified direction.
void setWidth(qreal width)
Sets the width of the rectangle occupied by the image.
int indexForFormat(const QTextFormat &f)
int propertyCount() const
Returns the number of properties stored in the format.
void setFrameFormat(const QTextFrameFormat &format)
Sets the frame's format.
int size() const
Returns the number of items in the vector.
QPointer< QTextFrame > frame
QTextFrameFormat frameFormat() const
Returns the frame's format.
QTextDocumentPrivate * src
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
int rightPadding(int i) const
qreal leftMargin() const
Returns the paragraph's left margin.
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
uint importedFromPlainText
const QChar * constData() const
Returns a pointer to the data stored in the QString.
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn't have a selection.