com.trolltech.qt.gui
Class QTextDocumentFragment

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.gui.QTextDocumentFragment
All Implemented Interfaces:
QtJambiInterface, java.lang.Cloneable

public class QTextDocumentFragment
extends QtJambiObject
implements java.lang.Cloneable

The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument. A QTextDocumentFragment is a fragment of rich text, that can be inserted into a QTextDocument. A document fragment can be created from a QTextDocument, from a QTextCursor's selection, or from another document fragment. Document fragments can also be created by the static functions, fromPlainText() and fromHtml().

The contents of a document fragment can be obtained as plain text by using the toPlainText() function, or it can be obtained as HTML with toHtml().


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QTextDocumentFragment()
          Constructs an empty QTextDocumentFragment.
QTextDocumentFragment(QTextCursor range)
          Creates a QTextDocumentFragment from the cursor's selection.
QTextDocumentFragment(QTextDocument document)
          Converts the given document into a QTextDocumentFragment.
QTextDocumentFragment(QTextDocumentFragment rhs)
          Copy constructor.
 
Method Summary
 QTextDocumentFragment clone()
          This method is reimplemented for internal reasons
static QTextDocumentFragment fromHtml(java.lang.String html)
          Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text.
static QTextDocumentFragment fromHtml(java.lang.String html, QTextDocument resourceProvider)
          Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text.
static QTextDocumentFragment fromPlainText(java.lang.String plainText)
          Returns a document fragment that contains the given plainText.
 boolean isEmpty()
          Returns true if the fragment is empty; otherwise returns false.
 java.lang.String toHtml()
          Returns the contents of the document fragment as HTML, using the specified encoding (e.g., "UTF-8", "ISO 8859-1").
 java.lang.String toHtml(QByteArray encoding)
          Returns the contents of the document fragment as HTML, using the specified encoding (e.
 java.lang.String toPlainText()
          Returns the document fragment's text as plain text (i.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTextDocumentFragment

public QTextDocumentFragment()
Constructs an empty QTextDocumentFragment.

See also:
isEmpty().


QTextDocumentFragment

public QTextDocumentFragment(QTextCursor range)
Creates a QTextDocumentFragment from the cursor's selection. If the cursor doesn't have a selection, the created fragment is empty.

See also:
isEmpty(), and QTextCursor::selection().


QTextDocumentFragment

public QTextDocumentFragment(QTextDocument document)
Converts the given document into a QTextDocumentFragment. Note that the QTextDocumentFragment only stores the document contents, not meta information like the document's title.


QTextDocumentFragment

public QTextDocumentFragment(QTextDocumentFragment rhs)
Copy constructor. Creates a copy of the other fragment.

Method Detail

isEmpty

public final boolean isEmpty()
Returns true if the fragment is empty; otherwise returns false.


toHtml

public final java.lang.String toHtml()
Returns the contents of the document fragment as HTML, using the specified encoding (e.g., "UTF-8", "ISO 8859-1").


toHtml

public final java.lang.String toHtml(QByteArray encoding)
Returns the contents of the document fragment as HTML, using the specified encoding (e. ., "UTF-8", "ISO 8859-1").

See also:
toPlainText(), QTextDocument::toHtml(), and QTextCodec.


toPlainText

public final java.lang.String toPlainText()
Returns the document fragment's text as plain text (i. . with no formatting information).

See also:
toHtml().


fromHtml

public static QTextDocumentFragment fromHtml(java.lang.String html)
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text. The formatting is preserved as much as possible; for example, "<b>bold</b>" will become a document fragment with the text "bold" with a bold character format.


fromHtml

public static QTextDocumentFragment fromHtml(java.lang.String html,
                                             QTextDocument resourceProvider)
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text. The formatting is preserved as much as possible; for example, "<b>bold</b>" will become a document fragment with the text "bold" with a bold character format.

If the provided HTML contains references to external resources such as imported style sheets, then they will be loaded through the resourceProvider.


fromPlainText

public static QTextDocumentFragment fromPlainText(java.lang.String plainText)
Returns a document fragment that contains the given plainText.

When inserting such a fragment into a QTextDocument the current char format of the QTextCursor used for insertion is used as format for the text.


clone

public QTextDocumentFragment clone()
This method is reimplemented for internal reasons

Overrides:
clone in class java.lang.Object