lib

KoTextObject Class Reference

#include <KoTextObject.h>

Inheritance diagram for KoTextObject:

KoTextFormatInterface List of all members.

Detailed Description

The KoTextObject is the high-level object that contains a KoTextDocument (the list of paragraphs), and takes care of the operations on it (particularly the undo/redo commands).

Editing the text isn't done by KoTextObject but by KoTextView (document/view design).

Definition at line 181 of file KoTextObject.h.


Public Types

enum  InsertFlag {
  DefaultInsertFlags = 0, CheckNewLine = 1, OverwriteMode = 2, DoNotRemoveSelected = 4,
  DoNotRepaint = 8
}
enum  KeyboardAction { ActionBackspace, ActionDelete, ActionReturn, ActionKill }
enum  ParagModifyType { AddChar = 0, RemoveChar = 1, ChangeFormat = 2 }

Public Slots

bool formatMore (int count=10, bool emitAfterFormatting=true)
void emitRepaintChanged ()

Signals

void availableHeightNeeded ()
void afterFormatting (int bottom, KoTextParag *m_lastFormatted, bool *abort)
void chapterParagraphFormatted (KoTextParag *parag)
void formattingFirstParag ()
void newCommand (KCommand *cmd)
void repaintChanged (KoTextObject *)
void hideCursor ()
void showCursor ()
void setCursor (KoTextCursor *cursor)
void updateUI (bool updateFormat, bool force=false)
void showCurrentFormat ()
void ensureCursorVisible ()
void selectionChanged (bool hasSelection)
void showFormatObject (const KoTextFormat &)
void paragraphCreated (KoTextParag *parag)
void paragraphModified (KoTextParag *parag, int, int pos, int length)
void paragraphDeleted (KoTextParag *parag)

Public Member Functions

 KoTextObject (KoTextZoomHandler *zh, const QFont &defaultFont, const QString &defaultLanguage, bool defaultHyphenation, KoParagStyle *defaultStyle, int tabStopWidth=-1, QObject *parent=0, const char *name=0)
 KoTextObject (KoTextDocument *textdoc, KoParagStyle *defaultStyle, QObject *parent=0, const char *name=0)
virtual ~KoTextObject ()
void setNeedSpellCheck (bool b)
bool needSpellCheck () const
void setProtectContent (bool b)
bool protectContent () const
KoTextDocumenttextDocument () const
void setAvailableHeight (int avail)
int availableHeight () const
void undo ()
void redo ()
void clearUndoRedoInfo ()
bool hasSelection () const
QString selectedText (KoTextDocument::SelectionId selectionId=KoTextDocument::Standard) const
bool selectionHasCustomItems (KoTextDocument::SelectionId selectionId=KoTextDocument::Standard) const
void insert (KoTextCursor *cursor, KoTextFormat *currentFormat, const QString &text, const QString &commandName, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard, int insertFlags=DefaultInsertFlags, CustomItemsMap customItemsMap=CustomItemsMap())
void removeSelectedText (KoTextCursor *cursor, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard, const QString &cmdName=QString::null, bool createUndoRedo=true)
KCommandreplaceSelectionCommand (KoTextCursor *cursor, const QString &replacement, const QString &cmdName, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard, int insertFlags=DefaultInsertFlags, CustomItemsMap customItemsMap=CustomItemsMap())
KCommandremoveSelectedTextCommand (KoTextCursor *cursor, KoTextDocument::SelectionId selectionId, bool repaint=true)
KCommandinsertParagraphCommand (KoTextCursor *cursor)
void pasteText (KoTextCursor *cursor, const QString &text, KoTextFormat *currentFormat, bool removeSelected)
void selectAll (bool select)
void highlightPortion (KoTextParag *parag, int index, int length, bool repaint)
void removeHighlight (bool repaint)
KCommandsetFormatCommand (const KoTextFormat *format, int flags, bool zoomFont=false)
KCommandsetFormatCommand (KoTextCursor *cursor, KoTextFormat **currentFormat, const KoTextFormat *format, int flags, bool zoomFont=false, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
void doKeyboardAction (KoTextCursor *cursor, KoTextFormat *&currentFormat, KeyboardAction action)
KCommandsetCounterCommand (KoTextCursor *cursor, const KoParagCounter &counter, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetAlignCommand (KoTextCursor *cursor, int align, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetLineSpacingCommand (KoTextCursor *cursor, double spacing, KoParagLayout::SpacingType _type, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetBordersCommand (KoTextCursor *cursor, const KoBorder &leftBorder, const KoBorder &rightBorder, const KoBorder &topBorder, const KoBorder &bottomBorder, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetJoinBordersCommand (KoTextCursor *cursor, bool join, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetMarginCommand (KoTextCursor *cursor, QStyleSheetItem::Margin m, double margin, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetTabListCommand (KoTextCursor *cursor, const KoTabulatorList &tabList, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetBackgroundColorCommand (KoTextCursor *cursor, const QColor &color, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
KCommandsetParagDirectionCommand (KoTextCursor *cursor, QChar::Direction d, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
void applyStyle (KoTextCursor *cursor, const KoParagStyle *style, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard, int paragLayoutFlags=KoParagLayout::All, int formatFlags=KoTextFormat::Format, bool createUndoRedo=true, bool interactive=true)
KCommandapplyStyleCommand (KoTextCursor *cursor, const KoParagStyle *style, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard, int paragLayoutFlags=KoParagLayout::All, int formatFlags=KoTextFormat::Format, bool createUndoRedo=true, bool interactive=true)
void applyStyleChange (KoStyleChangeDefMap changed)
void setFormat (KoTextCursor *cursor, KoTextFormat **currentFormat, KoTextFormat *format, int flags, bool zoomFont=false)
virtual KoTextFormatcurrentFormat () const
virtual const KoParagLayoutcurrentParagLayoutFormat () const
virtual bool rtl () const
virtual KCommandsetParagLayoutFormatCommand (KoParagLayout *newLayout, int flags, int marginIndex=-1)
KCommandsetParagLayoutCommand (KoTextCursor *cursor, const KoParagLayout &paragLayout, KoTextDocument::SelectionId selectionId, int paragLayoutFlags, int marginIndex, bool createUndoRedo)
virtual void setFormat (KoTextFormat *newFormat, int flags, bool zoomFont=false)
int docFontSize (KoTextFormat *format) const
int zoomedFontSize (int docFontSize) const
void setViewArea (QWidget *w, int maxY)
void ensureFormatted (KoTextParag *parag, bool emitAfterFormatting=true)
void setLastFormattedParag (KoTextParag *parag)
void emitHideCursor ()
void emitShowCursor ()
void emitEnsureCursorVisible ()
void emitUpdateUI (bool updateFormat, bool force=false)
void typingStarted ()
void typingDone ()
void abortFormatting ()
void selectionChangedNotify (bool enableActions=true)
void emitNewCommand (KCommand *cmd)
virtual KCommandsetChangeCaseOfTextCommand (KoChangeCaseDia::TypeOfCase _type)
KCommandchangeCaseOfText (KoTextCursor *cursor, KoChangeCaseDia::TypeOfCase _type)
QString textChangedCase (const QString &_text, KoChangeCaseDia::TypeOfCase _type)
KCommandchangeCaseOfTextParag (int cursorPosStart, int cursorPosEnd, KoChangeCaseDia::TypeOfCase _type, KoTextCursor *cursor, KoTextParag *parag)
void loadOasisContent (const QDomElement &bodyElem, KoOasisContext &context, KoStyleCollection *styleColl)
void saveOasisContent (KoXmlWriter &writer, KoSavingContext &context) const
KoTextCursor pasteOasisText (const QDomElement &bodyElem, KoOasisContext &context, KoTextCursor &cursor, KoStyleCollection *styleColl)
void printRTDebug (int)
bool statistics (QProgressDialog *progress, ulong &charsWithSpace, ulong &charsWithoutSpace, ulong &words, ulong &sentences, ulong &syllables, ulong &lines, bool selected)
int numberOfparagraphLineSelected (KoTextParag *parag)
KoVariablevariableAtPoint (const QPoint &iPoint) const
KoVariablevariableAtPosition (KoTextParag *parag, int index) const
void storeParagUndoRedoInfo (KoTextCursor *cursor, KoTextDocument::SelectionId selectionId=KoTextDocument::Standard)
void copyCharFormatting (KoTextParag *parag, int position, int index, bool moveCustomItems)
void readFormats (KoTextCursor &c1, KoTextCursor &c2, bool copyParagLayouts=false, bool moveCustomItems=false)
void newPlaceHolderCommand (const QString &name)
void checkUndoRedoInfo (KoTextCursor *cursor, UndoRedoInfo::Type t)
UndoRedoInfoundoRedoInfoStruct ()
void setVisible (bool vis)
bool isVisible () const

Static Public Member Functions

static const char * acceptSelectionMimeType ()
static QCString providesOasis (QMimeSource *mime)
static QChar customItemChar ()

Classes

struct  UndoRedoInfo
 The undo-redo structure holds the _temporary_ information for the current undo/redo command. More...

Member Enumeration Documentation

Enumerator:
OverwriteMode  < if true, the text to be inserted is checked for '\n' (as a paragraph delimiter)
DoNotRemoveSelected  whether to remove selected text before
DoNotRepaint  usually we repaint in insert(), this allows to turn it off

Definition at line 248 of file KoTextObject.h.


Constructor & Destructor Documentation

KoTextObject::KoTextObject ( KoTextZoomHandler zh,
const QFont &  defaultFont,
const QString &  defaultLanguage,
bool  defaultHyphenation,
KoParagStyle defaultStyle,
int  tabStopWidth = -1,
QObject *  parent = 0,
const char *  name = 0 
)

Constructor.

This constructor creates the contained KoTextDocument automatically.

Parameters:
zh the zoom handler (to be passed to the KoTextDocument ctor)
defaultFont the font to use by default (see KoTextFormatCollection)
defaultLanguage the language to use by default (see KoTextFormatCollection)
defaultHyphenation the default setting for hyphenation (see KoTextFormatCollection)
defaultStyle the style to use by default (initial pararaph, and when deleting a used style)
tabStopWidth the global value for the tabstop width
parent parent widget for this object
name name for this object

Definition at line 60 of file KoTextObject.cpp.

KoTextObject::KoTextObject ( KoTextDocument textdoc,
KoParagStyle defaultStyle,
QObject *  parent = 0,
const char *  name = 0 
)

Alternative constructor.

This constructor allows to use a derived class from KoTextDocument.

Parameters:
textdoc the text document to use in this text object. Ownership is transferred to the text object.
defaultStyle the style to use by default (initial pararaph, and when deleting a used style)
parent parent widget for this object
name name for this object

Definition at line 72 of file KoTextObject.cpp.


Member Function Documentation

QCString KoTextObject::providesOasis ( QMimeSource *  mime  )  [static]

Check if the mimesource mime provides one of the OASIS mimetypes, and if so, return it.

Otherwise return an empty string.

Definition at line 2437 of file KoTextObject.cpp.

KoTextDocument* KoTextObject::textDocument (  )  const [inline]

Return the text document contained in this KoTextObject.

Definition at line 229 of file KoTextObject.h.

void KoTextObject::clearUndoRedoInfo (  ) 

Terminate our current undo/redo info, to start with a new one.

Definition at line 202 of file KoTextObject.cpp.

bool KoTextObject::hasSelection (  )  const [inline]

return true if some text is selected

Definition at line 240 of file KoTextObject.h.

QString KoTextObject::selectedText ( KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard  )  const [inline]

returns the selected text [without formatting] if hasSelection()

Definition at line 242 of file KoTextObject.h.

bool KoTextObject::selectionHasCustomItems ( KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard  )  const

returns true if the given selection has any custom item in it

Definition at line 186 of file KoTextObject.cpp.

void KoTextObject::insert ( KoTextCursor cursor,
KoTextFormat currentFormat,
const QString &  text,
const QString &  commandName,
KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard,
int  insertFlags = DefaultInsertFlags,
CustomItemsMap  customItemsMap = CustomItemsMap() 
)

The main "insert" method, including undo/redo creation/update.

Parameters:
cursor the insertion point
currentFormat the current textformat, to apply to the inserted text
text the text to be inserted
insertFlags flags, see InsertFlag
commandName the name to give the undo/redo command if we haven't created it already
customItemsMap the map of custom items to include in the new text
selectionId which selection to use (See KoTextDocument::SelectionId)

Definition at line 597 of file KoTextObject.cpp.

void KoTextObject::removeSelectedText ( KoTextCursor cursor,
KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard,
const QString &  cmdName = QString::null,
bool  createUndoRedo = true 
)

Remove the text currently selected, including undo/redo creation/update.

Parameters:
cursor the caret position
selectionId which selection to remove (usually Standard)
cmdName the name to give the undo/redo command, if we haven't created it already
createUndoRedo create an undo history entry for this removal

Definition at line 1525 of file KoTextObject.cpp.

void KoTextObject::pasteText ( KoTextCursor cursor,
const QString &  text,
KoTextFormat currentFormat,
bool  removeSelected 
)

Paste plain text at the given cursor.

Parameters:
cursor location to paste text
text the text to paste
currentFormat format to apply to the pasted text
removeSelected true when pasting with the keyboard, but false when dropping text.
Todo:
Can currentFormat be NULL?
Todo:
Besides saying when removeSelected is true, perhaps explain what it does (presumably, removes the selection and replaces it with the pasted text).

Definition at line 744 of file KoTextObject.cpp.

void KoTextObject::highlightPortion ( KoTextParag parag,
int  index,
int  length,
bool  repaint 
)

Highlighting support (for search/replace, spellchecking etc.

). Don't forget to ensure the paragraph is visible.

Definition at line 1656 of file KoTextObject.cpp.

KCommand * KoTextObject::setFormatCommand ( const KoTextFormat format,
int  flags,
bool  zoomFont = false 
) [virtual]

Implementation of setFormatCommand from KoTextFormatInterface - apply change to the whole document.

Implements KoTextFormatInterface.

Definition at line 985 of file KoTextObject.cpp.

KCommand * KoTextObject::setFormatCommand ( KoTextCursor cursor,
KoTextFormat **  currentFormat,
const KoTextFormat format,
int  flags,
bool  zoomFont = false,
KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard 
)

Set format changes on selection or current cursor.

Returns a command if the format was applied to a selection

Definition at line 993 of file KoTextObject.cpp.

void KoTextObject::doKeyboardAction ( KoTextCursor cursor,
KoTextFormat *&  currentFormat,
KeyboardAction  action 
)

Executes keyboard action action.

This is normally called by a key event handler.

Definition at line 426 of file KoTextObject.cpp.

void KoTextObject::applyStyle ( KoTextCursor cursor,
const KoParagStyle style,
KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard,
int  paragLayoutFlags = KoParagLayout::All,
int  formatFlags = KoTextFormat::Format,
bool  createUndoRedo = true,
bool  interactive = true 
)

Apply a KoParagStyle to a selection.

Parameters:
cursor the current cursor; used if there is no selection. Can be 0L if there is one.
style the KoParagStyle to apply
selectionId the id of the selection, usually Standard or Temp
paragLayoutFlags which settings from the paragraph layout to apply
formatFlags which settings from the text format to apply
createUndoRedo if true, an undo/redo command will be created and emitted
interactive if true, the text will be reformatted/repainted to show the new style

Definition at line 815 of file KoTextObject.cpp.

KCommand * KoTextObject::applyStyleCommand ( KoTextCursor cursor,
const KoParagStyle style,
KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard,
int  paragLayoutFlags = KoParagLayout::All,
int  formatFlags = KoTextFormat::Format,
bool  createUndoRedo = true,
bool  interactive = true 
)

Helper for applyStyle.

Can also be called directly, so that the command isn't emitted, e.g. to put it into a macro-command.

Returns:
the command for 'apply style', or 0L if createUndoRedo is false.

Applying a style is three distinct operations : 1 - Changing the paragraph settings (setParagLayout) 2 - Changing the character formatting for each char in the paragraph (setFormat(indices)) 3 - Changing the character formatting for the whole paragraph (setFormat()) [just in case] -> We need a macro command to hold the 3 commands

Definition at line 829 of file KoTextObject.cpp.

void KoTextObject::applyStyleChange ( KoStyleChangeDefMap  changed  ) 

Update the paragraph that use the given style, after this style was changed.

The flags tell which changes should be applied.

Parameters:
changed map of styles that have changed

Definition at line 938 of file KoTextObject.cpp.

void KoTextObject::setFormat ( KoTextCursor cursor,
KoTextFormat **  currentFormat,
KoTextFormat format,
int  flags,
bool  zoomFont = false 
)

Set format changes on selection or current cursor.

Creates a command if the format was applied to a selection

Definition at line 1078 of file KoTextObject.cpp.

KoTextFormat * KoTextObject::currentFormat (  )  const [virtual]

Support for treating the whole textobject as a single object Use this format for displaying the properties (font/color/.

..) of the object. Interface for accessing the current format

Implements KoTextFormatInterface.

Definition at line 2093 of file KoTextObject.cpp.

const KoParagLayout * KoTextObject::currentParagLayoutFormat (  )  const [virtual]

Use this format for displaying the properties (Align/counter/.

..) of the object

Implements KoTextFormatInterface.

Definition at line 2101 of file KoTextObject.cpp.

KCommand * KoTextObject::setParagLayoutFormatCommand ( KoParagLayout newLayout,
int  flags,
int  marginIndex = -1 
) [virtual]

Support for changing the format in the whole textobject.

Implements KoTextFormatInterface.

Definition at line 2218 of file KoTextObject.cpp.

void KoTextObject::setFormat ( KoTextFormat newFormat,
int  flags,
bool  zoomFont = false 
) [virtual]

Support for changing the format in the whole textobject.

Reimplemented from KoTextFormatInterface.

Definition at line 2231 of file KoTextObject.cpp.

int KoTextObject::docFontSize ( KoTextFormat format  )  const

Return the user-visible font size for this format (i.e.

LU to pt conversion)

Definition at line 155 of file KoTextObject.cpp.

int KoTextObject::zoomedFontSize ( int  docFontSize  )  const

Return the font size in LU, for this user-visible font size in pt.

Definition at line 161 of file KoTextObject.cpp.

void KoTextObject::setViewArea ( QWidget *  w,
int  maxY 
)

Set the bottom of the view - in LU.

Definition at line 1708 of file KoTextObject.cpp.

void KoTextObject::ensureFormatted ( KoTextParag parag,
bool  emitAfterFormatting = true 
)

Make sure that parag is formatted.

Definition at line 1721 of file KoTextObject.cpp.

void KoTextObject::abortFormatting (  ) 

Abort the current formatMore() loop, or prevent the next one from starting.

Use with care. This is e.g. for KWFootNoteVariable, so that it can do a frame layout before formatting the main text again. It is important to make sure that formatMore will be called again ;)

Definition at line 1889 of file KoTextObject.cpp.

KoVariable * KoTextObject::variableAtPoint ( const QPoint &  iPoint  )  const

Return the variable at the given point (in document coordinates), if any.

Definition at line 2414 of file KoTextObject.cpp.

KoVariable * KoTextObject::variableAtPosition ( KoTextParag parag,
int  index 
) const

Return the variable at the given position, if any.

Passing KoTextView's m_cursor here is usually wrong, index must come from the variablePosition value returned by KoTextCursor::place().

Definition at line 2424 of file KoTextObject.cpp.

void KoTextObject::availableHeightNeeded (  )  [signal]

Emitted by availableHeight() when the available height hasn't been calculated yet or is invalid.

Connect to a slot that calls setAvailableHeight()

void KoTextObject::afterFormatting ( int  bottom,
KoTextParag m_lastFormatted,
bool *  abort 
) [signal]

Emitted by formatMore() after formatting a bunch of paragraphs.

KWord uses this signal to check for things like 'I need to create a new page'

void KoTextObject::chapterParagraphFormatted ( KoTextParag parag  )  [signal]

Emitted by formatMore() when formatting a "Head 1" paragraph.

Used for the Section variable

void KoTextObject::formattingFirstParag (  )  [signal]

Emitted by formatMore() when formatting the first paragraph.

void KoTextObject::newCommand ( KCommand cmd  )  [signal]

Emitted when a new command has been created and should be added to the main list of commands (usually in the KoDocument).

Make sure to connect to that one, otherwise the commands will just leak away...

void KoTextObject::repaintChanged ( KoTextObject  )  [signal]

Tell the world that we'd like some repainting to happen.

void KoTextObject::setCursor ( KoTextCursor cursor  )  [signal]

Special hack for undo/redo - used by KoTextView.

void KoTextObject::updateUI ( bool  updateFormat,
bool  force = false 
) [signal]

Emitted when the formatting under the cursor may have changed.

The Edit object should re-read settings and update the UI.

void KoTextObject::showCurrentFormat (  )  [signal]

Same thing, when the current format (of the edit object) was changed.

void KoTextObject::ensureCursorVisible (  )  [signal]

The views should make sure the cursor is visible.

void KoTextObject::selectionChanged ( bool  hasSelection  )  [signal]

Tell the views that the selection changed (for cut/copy.

..)

void KoTextObject::storeParagUndoRedoInfo ( KoTextCursor cursor,
KoTextDocument::SelectionId  selectionId = KoTextDocument::Standard 
)

This prepares undoRedoInfo for a paragraph formatting change If this does too much, we could pass an enum flag to it.

But the main point is to avoid too much duplicated code

Definition at line 400 of file KoTextObject.cpp.

void KoTextObject::copyCharFormatting ( KoTextParag parag,
int  position,
int  index,
bool  moveCustomItems 
)

Copies a formatted char, <parag, position>, into undoRedoInfo.text, at position index.

Definition at line 328 of file KoTextObject.cpp.

void KoTextObject::newPlaceHolderCommand ( const QString &  name  ) 

Creates a place holder for a command that will be completed later on.

This is used for the insert and delete text commands, which are build delayed (see the UndoRedoInfo structure), in order to have an entry in the undo/redo history asap.

Definition at line 392 of file KoTextObject.cpp.

UndoRedoInfo& KoTextObject::undoRedoInfoStruct (  )  [inline]

for KWTextFrameSet

Definition at line 582 of file KoTextObject.h.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys