umbrello: TextBlock Class Reference

umbrello 2.32.3 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
TextBlock Class Referenceabstract

`#include <textblock.h>`

Inheritance diagram for TextBlock:

## Public Member Functions
| TextBlock (CodeDocument *parent, const QString &text=QString())
virtual | ~TextBlock ()
void | setText (const QString &text)
QString | getText () const
void | appendText (const QString &text)
void | setTag (const QString &value)
QString | getTag () const
CodeDocument * | getParentDocument () const
void | setWriteOutText (bool write)
bool | getWriteOutText () const
void | setIndentationLevel (int level)
int | getIndentationLevel () const
QString | getIndentationString (int level=0) const
virtual QString | unformatText (const QString &text, const QString &indent=QString())
virtual QString | toString () const
virtual void | saveToXMI1 (QXmlStreamWriter &writer)=0
virtual void | loadFromXMI1 (QDomElement &root)=0
bool | canDelete () const
virtual void | setAttributesFromObject (TextBlock *obj)
virtual QString | getNewEditorLine (int amount=0)
virtual int | firstEditableLine ()
virtual int | lastEditableLine ()

## Static Public Member Functions
static QString | getIndentation ()
static QString | getNewLineEndingChars ()
static QString | formatMultiLineText (const QString &work, const QString &linePrefix, const QString &breakStr, bool addBreak=true, bool lastLineHasBreak=true)
static QString | encodeText (const QString &text, const QString &endLine)
static QString | decodeText (const QString &text, const QString &endLine)

## Protected Member Functions
void | setCanDelete (bool canDelete)
virtual void | release ()
virtual void | setAttributesOnNode (QXmlStreamWriter &writer)
virtual void | setAttributesFromNode (QDomElement &root)

## Private Attributes
QString | m_text
QString | m_tag
bool | m_canDelete
bool | m_writeOutText
int | m_indentationLevel
CodeDocument * | m_parentDocument

## Friends
class | CodeGenObjectWithTextBlocks
class | ClassifierCodeDocument
QDebug | operator<< (QDebug os, const TextBlock &obj)

## Detailed Description

The fundamental unit of text within an output file containing code.

## Constructor & Destructor Documentation

## ◆ TextBlock()

TextBlock::TextBlock | ( | CodeDocument * | parent,
|  | const QString & | text = `QString()`
| ) |  |
| explicit

Constructor.

## ◆ ~TextBlock()

TextBlock::~TextBlock | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ appendText()

void TextBlock::appendText | ( | const QString & | text | ) |

Add text to this object.

Parameters

  text | the text to add

## ◆ canDelete()

bool TextBlock::canDelete | ( |  | ) | const

Determine if its OK to delete this textblock from the document. Used by the text editor to know if deletion could cause a crash of the program.

Returns
  the value of m_canDelete

## ◆ decodeText()

QString TextBlock::decodeText | ( | const QString & | text,
|  | const QString & | endLine
| ) |  |
| static

Decode text from XML storage. We simply convert all newLine entity &#010; to chosen line ending.

Parameters

  text | the not yet decoded text
  endLine | the chars at the end of each line

Returns
  the decoded text

## ◆ encodeText()

QString TextBlock::encodeText | ( | const QString & | text,
|  | const QString & | endLine
| ) |  |
| static

Encode text for XML storage. We simply convert all types of newLines to the "\n" or &#010; entity.

Parameters

  text | the not yet encoded text
  endLine | the chars at the end of each line

Returns
  the encoded text

## ◆ firstEditableLine()

int TextBlock::firstEditableLine | ( |  | ) |
| virtual

TODO: Ush. These are terrifically bad and must one day go away. Both methods indicate the range of lines in this textblock which may be edited by the codeeditor (assuming that any are actually editable). The default case is no lines are editable. The line numbering starts with '0' and a '-1' means no line qualifies.

Returns
  line number

Reimplemented in CPPCodeDocumentation, DCodeDocumentation, JavaCodeDocumentation, and RubyCodeDocumentation.

## ◆ formatMultiLineText()

QString TextBlock::formatMultiLineText | ( | const QString & | work,
|  | const QString & | linePrefix,
|  | const QString & | breakStr,
|  | bool | addBreak = `true`,
|  | bool | lastLineHasBreak = `true`
| ) |  |
| static

Format a long text string to be more readable.

Parameters

  work | the original text for formatting
  linePrefix | a line prefix
  breakStr | a break string
  addBreak | control to add always a break string
  lastLineHasBreak | control to add a break string to the last line

Returns
  the new formatted text

## ◆ getIndentation()

QString TextBlock::getIndentation | ( |  | ) |
| static

Get how much a single "level" of indentation will actually indent.

Returns
  the unit of indentation (for one level)

## ◆ getIndentationLevel()

int TextBlock::getIndentationLevel | ( |  | ) | const

Get how many times to indent this text block. The amount of each indentation is determined from the parent codedocument codegeneration policy.

Returns
  the indentation level

## ◆ getIndentationString()

QString TextBlock::getIndentationString | ( | int | level = `0` | ) | const

Get the actual amount of indentation for a given level of indentation.

Parameters

  level | the level of interest

Returns
  the indentation string

## ◆ getNewEditorLine()

QString TextBlock::getNewEditorLine | ( | int | amount = `0` | ) |
| virtual

Used by the CodeEditor. It provides it with an appropriate starting string for a new line of text within the given textblock (for example a string with the proper indentation). If the indentation amount is '0' the current indentation string will be used.

TODO: Can be refactored away and replaced with getIndentationString.

Parameters

  amount | the number of indent steps to use

Returns
  the new line

Reimplemented in CPPCodeComment, CPPCodeDocumentation, DCodeComment, DCodeDocumentation, JavaCodeComment, JavaCodeDocumentation, RubyCodeComment, and RubyCodeDocumentation.

## ◆ getNewLineEndingChars()

QString TextBlock::getNewLineEndingChars | ( |  | ) |
| static

Get the new line chars which ends the line.

Returns
  the ending chars for new line

## ◆ getParentDocument()

CodeDocument * TextBlock::getParentDocument | ( |  | ) | const

Get the value of m_parentDoc

Returns
  the value of m_parentDoc

## ◆ getTag()

QString TextBlock::getTag | ( |  | ) | const

Get the tag of this text block. This tag may be used to find this text block in the code document to which it belongs.

Returns
  the tag

## ◆ getText()

QString TextBlock::getText | ( |  | ) | const

Get the value of m_text The actual text of this code block.

Returns
  the value of m_text

## ◆ getWriteOutText()

bool TextBlock::getWriteOutText | ( |  | ) | const

Get the value of m_writeOutText Whether or not to include the text of this TextBlock into a file.

Returns
  the value of m_writeOutText

## ◆ lastEditableLine()

int TextBlock::lastEditableLine | ( |  | ) |
| virtual

See also
  firstEditableLine

Reimplemented in CPPCodeDocumentation, CPPHeaderCodeOperation, DCodeDocumentation, DCodeOperation, JavaCodeDocumentation, JavaCodeOperation, RubyCodeDocumentation, and RubyCodeOperation.

## ◆ loadFromXMI1()

virtual void TextBlock::loadFromXMI1 | ( | QDomElement & | root | ) |
| pure virtual

Load params from the appropriate XMI element node.

Parameters

  root | the starting point in the xmi document to load from

Implemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeComment, CodeOperation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, HierarchicalCodeBlock, JavaClassDeclarationBlock, RubyClassDeclarationBlock, XMLElementCodeBlock, and OwnedHierarchicalCodeBlock.

## ◆ release()

void TextBlock::release | ( |  | ) |
| protectedvirtual

Causes the text block to release all of its connections and any other text blocks that it 'owns'. Needed to be called prior to deletion of the textblock. TODO: Does nothing.

Reimplemented in CodeAccessorMethod, CodeClassFieldDeclarationBlock, CodeMethodBlock, HierarchicalCodeBlock, and OwnedHierarchicalCodeBlock.

## ◆ saveToXMI1()

virtual void TextBlock::saveToXMI1 | ( | QXmlStreamWriter & | writer | ) |
| pure virtual

Save the XMI representation of this object

Parameters

  doc | the xmi document
  root | the starting point to append

Implemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeComment, CodeOperation, CPPCodeComment, CPPCodeDocumentation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, DCodeComment, DCodeDocumentation, HierarchicalCodeBlock, JavaClassDeclarationBlock, JavaCodeDocumentation, RubyClassDeclarationBlock, RubyCodeDocumentation, XMLElementCodeBlock, and OwnedHierarchicalCodeBlock.

## ◆ setAttributesFromNode()

void TextBlock::setAttributesFromNode | ( | QDomElement & | root | ) |
| protectedvirtual

Set the class attributes of this object from the passed element node.

Parameters

  root | the xmi element from which to load

Reimplemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, DCodeAccessorMethod, HierarchicalCodeBlock, JavaCodeAccessorMethod, OwnedHierarchicalCodeBlock, RubyCodeAccessorMethod, and XMLElementCodeBlock.

## ◆ setAttributesFromObject()

void TextBlock::setAttributesFromObject | ( | TextBlock * | obj | ) |
| virtual

Set the class attributes from a passed object.

Parameters

  obj | text block from which the attributes are taken

Reimplemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, HierarchicalCodeBlock, and OwnedHierarchicalCodeBlock.

## ◆ setAttributesOnNode()

void TextBlock::setAttributesOnNode | ( | QXmlStreamWriter & | writer | ) |
| protectedvirtual

Set attributes of the node that represents this class in the XMI document.

Parameters

  doc | the xmi document
  blockElement | the xmi element holding the attributes

Reimplemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, DCodeAccessorMethod, HierarchicalCodeBlock, JavaCodeAccessorMethod, OwnedHierarchicalCodeBlock, RubyCodeAccessorMethod, and XMLElementCodeBlock.

## ◆ setCanDelete()

void TextBlock::setCanDelete | ( | bool | canDelete | ) |
| protected

Set the attribute m_canDelete.

Parameters

  canDelete | the new value to set

## ◆ setIndentationLevel()

void TextBlock::setIndentationLevel | ( | int | level | ) |

Set how many times to indent this text block. The amount of each indentation is determined from the parent codedocument codegeneration policy.

Parameters

  level | the new value for the indentation level

## ◆ setTag()

void TextBlock::setTag | ( | const QString & | value | ) |

Set the tag of this text block. This tag may be used to find this text block in the code document to which it belongs.

Parameters

  value | the new value for the tag

## ◆ setText()

void TextBlock::setText | ( | const QString & | text | ) |

Set the value of m_text The actual text of this code block.

Parameters

  text | the new value of m_text

## ◆ setWriteOutText()

void TextBlock::setWriteOutText | ( | bool | write | ) |

Set the value of m_writeOutText Whether or not to include the text of this TextBlock into a file.

Parameters

  write | the new value of m_writeOutText

## ◆ toString()

QString TextBlock::toString | ( |  | ) | const
| virtual

Return the text in the right format. Returned string is empty if m_writeOutText is false.

Returns
  QString

Reimplemented in CodeBlockWithComments, CodeMethodBlock, CPPCodeComment, CPPCodeDocumentation, DCodeComment, DCodeDocumentation, HierarchicalCodeBlock, JavaCodeComment, JavaCodeDocumentation, RubyCodeComment, RubyCodeDocumentation, and XMLCodeComment.

## ◆ unformatText()

QString TextBlock::unformatText | ( | const QString & | text,
|  | const QString & | indent = `QString()`
| ) |  |
| virtual

UnFormat a long text string. Typically, this means removing the indentation (linePrefix) and/or newline chars from each line. If an indentation is not specified, then the current indentation is used.

Parameters

  text | the original text for unformatting
  indent | the indentation

Returns
  the unformatted text

Reimplemented in CPPCodeComment, CPPCodeDocumentation, DCodeComment, DCodeDocumentation, JavaCodeComment, JavaCodeDocumentation, RubyCodeComment, and RubyCodeDocumentation.

## Friends And Related Function Documentation

## ◆ ClassifierCodeDocument

friend class ClassifierCodeDocument
| friend

## ◆ CodeGenObjectWithTextBlocks

friend class CodeGenObjectWithTextBlocks
| friend

## ◆ operator<<

QDebug operator<< | ( | QDebug | os,
|  | const TextBlock & | obj
| ) |  |
| friend

Operator '<<' for TextBlock.

## Member Data Documentation

## ◆ m_canDelete

bool TextBlock::m_canDelete
| private

## ◆ m_indentationLevel

int TextBlock::m_indentationLevel
| private

## ◆ m_parentDocument

CodeDocument* TextBlock::m_parentDocument
| private

## ◆ m_tag

QString TextBlock::m_tag
| private

## ◆ m_text

QString TextBlock::m_text
| private

## ◆ m_writeOutText

bool TextBlock::m_writeOutText
| private

The documentation for this class was generated from the following files:

- umbrello/codegenerators/textblock.h
- umbrello/codegenerators/textblock.cpp