umbrello API Documentation

TextBlock Class Reference

class TextBlock The fundemental unit of text within an output file containing code. More...

#include <textblock.h>

Inheritance diagram for TextBlock:

CodeBlock CodeComment CodeBlockWithComments CPPCodeComment CPPCodeDocumentation JavaCodeComment JavaCodeDocumentation RubyCodeComment RubyCodeDocumentation XMLCodeComment List of all members.

Public Member Functions

 TextBlock (CodeDocument *parent, const QString &text="")
 Constructors.
void setText (const QString &new_var)
 Set the value of m_text The actual text of this code block.
void appendText (const QString &new_text)
 Add text to this object.
QString getText () const
 Get the value of m_text The actual text of this code block.
QString getTag () const
 Get the tag of this text block.
void setTag (const QString &value)
 Set the tag of this text block.
CodeDocumentgetParentDocument ()
 Get the value of m_parentDoc.
void setWriteOutText (bool new_var)
 Set the value of m_writeOutText Whether or not to include the text of this TextBlock into a file.
bool getWriteOutText ()
 Get the value of m_writeOutText Whether or not to include the text of this TextBlock into a file.
void setIndentationLevel (int level)
 Set how many times to indent this text block.
int getIndentationLevel ()
 Get how many times to indent this text block.
QString getIndentationString (int level=0)
 Get the actual amount of indentation for a given level of indentation.
QString getIndentation ()
 Get how much a single "level" of indentation will actually indent.
QString getNewLineEndingChars ()
QString formatMultiLineText (const QString &text, const QString &linePrefix, const QString &breakStr, bool alwaysAddBreak=true, bool lastLineHasBreak=true)
 Format a long text string to be more readable.
virtual QString unformatText (const QString &text, const QString &indent="")
 UnFormat a long text string.
virtual QString toString ()
virtual void saveToXMI (QDomDocument &doc, QDomElement &root)=0
 Save the XMI representation of this object.
virtual void loadFromXMI (QDomElement &root)=0
 load params from the appropriate XMI element node.
bool canDelete ()
 Determine if its OK to delete this textblock from the document.
virtual void setAttributesFromObject (TextBlock *obj)
 set the class attributes from a passed object
virtual QString getNewEditorLine (int indentAmount=0)
 Used by the CodeEditor.
virtual int firstEditableLine ()
 Ush.
virtual int lastEditableLine ()

Static Public Member Functions

static QString encodeText (const QString &text, const QString &endChars)
 encode text for XML storage we simply convert all types of newLines to the "\n" or &#010; entity.
static QString decodeText (const QString &text, const QString &endChars)
 decode text from XML storage We simply convert all newLine entity &#010; to chosen line ending.

Protected Member Functions

virtual void release ()
 causes the text block to release all of its connections and any other text blocks that it 'owns'.
void setParentDocument (CodeDocument *new_var)
 Set the value of m_parentDocument.
virtual void setAttributesOnNode (QDomDocument &doc, QDomElement &blockElement)
 set attributes of the node that represents this class in the XMI document.
virtual void setAttributesFromNode (QDomElement &element)
 set the class attributes of this object from the passed element node.

Protected Attributes

bool m_canDelete

Friends

class CodeGenObjectWithTextBlocks
class ClassifierCodeDocument

Detailed Description

class TextBlock The fundemental unit of text within an output file containing code.

Definition at line 32 of file textblock.h.


Constructor & Destructor Documentation

TextBlock::TextBlock CodeDocument parent,
const QString &  text = ""
[explicit]
 

Constructors.

Definition at line 33 of file textblock.cpp.

References setText().


Member Function Documentation

void TextBlock::setText const QString &  new_var  ) 
 

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

Parameters:
new_var the new value of m_text

Definition at line 76 of file textblock.cpp.

Referenced by CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeBlockWithComments(), CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment(), CodeGenObjectWithTextBlocks::getCodeBlockWithComments(), setAttributesFromNode(), setAttributesFromObject(), CodeParameter::syncToParent(), and TextBlock().

void TextBlock::appendText const QString &  new_text  ) 
 

Add text to this object.

Definition at line 84 of file textblock.cpp.

QString TextBlock::getText  )  const
 

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

Returns:
the value of m_text

Definition at line 93 of file textblock.cpp.

Referenced by XMLCodeComment::toString(), RubyCodeDocumentation::toString(), RubyCodeComment::toString(), JavaCodeDocumentation::toString(), JavaCodeComment::toString(), CPPCodeDocumentation::toString(), CPPCodeComment::toString(), CodeMethodBlock::toString(), and CodeBlockWithComments::toString().

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.

Definition at line 102 of file textblock.cpp.

Referenced by CodeGenObjectWithTextBlocks::addTextBlock(), CodeDocument::insertTextBlock(), CodeBlockWithComments::setAttributesFromNode(), and setAttributesOnNode().

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.

Definition at line 111 of file textblock.cpp.

Referenced by CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeBlockWithComments(), CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment(), CodeGenObjectWithTextBlocks::addTextBlock(), CodeGenObjectWithTextBlocks::getCodeBlockWithComments(), CodeDocument::insertTextBlock(), and setAttributesFromNode().

CodeDocument * TextBlock::getParentDocument  ) 
 

Get the value of m_parentDoc.

Returns:
the value of m_parentDoc

Definition at line 67 of file textblock.cpp.

Referenced by CodeGenObjectWithTextBlocks::addTextBlock().

void TextBlock::setWriteOutText bool  new_var  ) 
 

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

Parameters:
new_var the new value of m_writeOutText

Definition at line 120 of file textblock.cpp.

Referenced by CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeBlockWithComments(), CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment(), CodeGenObjectWithTextBlocks::getCodeBlockWithComments(), setAttributesFromNode(), setAttributesFromObject(), and CPPHeaderCodeDocument::updateContent().

bool TextBlock::getWriteOutText  ) 
 

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

Definition at line 129 of file textblock.cpp.

Referenced by setAttributesOnNode(), XMLCodeComment::toString(), RubyCodeDocumentation::toString(), RubyCodeComment::toString(), JavaCodeDocumentation::toString(), JavaCodeComment::toString(), CPPCodeDocumentation::toString(), CPPCodeComment::toString(), CodeMethodBlock::toString(), and CodeBlockWithComments::toString().

void TextBlock::setIndentationLevel int  level  ) 
 

Set how many times to indent this text block.

The amount of each indenatation is determined from the parent codedocument codegeneration policy.

Definition at line 135 of file textblock.cpp.

Referenced by CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment(), setAttributesFromNode(), setAttributesFromObject(), and CodeBlockWithComments::setOverallIndentationLevel().

int TextBlock::getIndentationLevel  ) 
 

Get how many times to indent this text block.

The amount of each indenatation is determined from the parent codedocument codegeneration policy.

Definition at line 143 of file textblock.cpp.

Referenced by setAttributesOnNode(), and CodeMethodBlock::toString().

QString TextBlock::getIndentationString int  level = 0  ) 
 

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

Definition at line 157 of file textblock.cpp.

References getIndentation().

Referenced by getNewEditorLine(), RubyCodeDocumentation::getNewEditorLine(), RubyCodeComment::getNewEditorLine(), JavaCodeDocumentation::getNewEditorLine(), JavaCodeComment::getNewEditorLine(), CPPCodeDocumentation::getNewEditorLine(), CPPCodeComment::getNewEditorLine(), XMLCodeComment::toString(), toString(), RubyCodeDocumentation::toString(), RubyCodeComment::toString(), JavaCodeDocumentation::toString(), JavaCodeComment::toString(), CPPCodeDocumentation::toString(), CPPCodeComment::toString(), CodeMethodBlock::toString(), CodeBlockWithComments::toString(), and unformatText().

QString TextBlock::getIndentation  ) 
 

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

Definition at line 152 of file textblock.cpp.

References UMLApp::getCommonPolicy(), and CodeGenerationPolicy::getIndentation().

Referenced by getIndentationString().

QString TextBlock::formatMultiLineText const QString &  text,
const QString &  linePrefix,
const QString &  breakStr,
bool  alwaysAddBreak = true,
bool  lastLineHasBreak = true
 

Format a long text string to be more readable.

Definition at line 203 of file textblock.cpp.

Referenced by toString(), RubyCodeComment::toString(), CodeMethodBlock::toString(), and CodeBlockWithComments::toString().

QString TextBlock::unformatText const QString &  text,
const QString &  indent = ""
[virtual]
 

UnFormat a long text string.

Typically, this means removing the indentaion (linePrefix) and/or newline chars from each line. If an indentation isnt specified, then the current indentation is used.

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

Definition at line 185 of file textblock.cpp.

References getIndentationString().

Referenced by RubyCodeDocumentation::unformatText(), RubyCodeComment::unformatText(), JavaCodeDocumentation::unformatText(), JavaCodeComment::unformatText(), CPPCodeDocumentation::unformatText(), and CPPCodeComment::unformatText().

QString TextBlock::toString  )  [virtual]
 

Returns:
QString

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

Definition at line 299 of file textblock.cpp.

References formatMultiLineText(), UMLApp::getCommonPolicy(), getIndentationString(), and CodeGenerationPolicy::getNewLineEndingChars().

Referenced by CodeMethodBlock::toString(), CodeDocument::toString(), and CodeBlockWithComments::toString().

QString TextBlock::encodeText const QString &  text,
const QString &  endChars
[static]
 

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

Definition at line 281 of file textblock.cpp.

Referenced by setAttributesOnNode(), and CodeMethodBlock::setAttributesOnNode().

QString TextBlock::decodeText const QString &  text,
const QString &  endChars
[static]
 

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

Definition at line 290 of file textblock.cpp.

Referenced by setAttributesFromNode(), and CodeMethodBlock::setAttributesFromNode().

virtual void TextBlock::saveToXMI QDomDocument &  doc,
QDomElement &  root
[pure virtual]
 

Save the XMI representation of this object.

Implemented in CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeComment, CPPCodeComment, CPPCodeDocumentation, JavaCodeDocumentation, RubyCodeDocumentation, and OwnedHierarchicalCodeBlock.

Referenced by CodeGenObjectWithTextBlocks::setAttributesOnNode().

virtual void TextBlock::loadFromXMI QDomElement &  root  )  [pure virtual]
 

load params from the appropriate XMI element node.

Implemented in CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeComment, and OwnedHierarchicalCodeBlock.

bool TextBlock::canDelete  ) 
 

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.

Definition at line 59 of file textblock.cpp.

Referenced by setAttributesOnNode().

void TextBlock::setAttributesFromObject TextBlock obj  )  [virtual]
 

set the class attributes from a passed object

Reimplemented in CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, and OwnedHierarchicalCodeBlock.

Definition at line 255 of file textblock.cpp.

References setIndentationLevel(), setText(), and setWriteOutText().

Referenced by CodeBlockWithComments::setAttributesFromObject(), and CodeBlock::setAttributesFromObject().

QString TextBlock::getNewEditorLine int  indentAmount = 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 indentationString will be used.

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

Definition at line 180 of file textblock.cpp.

References getIndentationString().

int TextBlock::firstEditableLine  )  [virtual]
 

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.

Reimplemented in CPPCodeDocumentation, JavaCodeDocumentation, and RubyCodeDocumentation.

Definition at line 177 of file textblock.cpp.

void TextBlock::release  )  [protected, virtual]
 

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.

Reimplemented in CodeClassFieldDeclarationBlock, CodeMethodBlock, and OwnedHierarchicalCodeBlock.

Definition at line 198 of file textblock.cpp.

Referenced by CodeMethodBlock::release().

void TextBlock::setParentDocument CodeDocument new_var  )  [protected]
 

Set the value of m_parentDocument.

Parameters:
new_var the new value of m_parentDoc

Definition at line 55 of file textblock.cpp.

void TextBlock::setAttributesOnNode QDomDocument &  doc,
QDomElement &  blockElement
[protected, virtual]
 

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

Reimplemented in CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, and OwnedHierarchicalCodeBlock.

Definition at line 232 of file textblock.cpp.

References canDelete(), encodeText(), UMLApp::getCommonPolicy(), getIndentationLevel(), CodeGenerationPolicy::getNewLineEndingChars(), getTag(), and getWriteOutText().

Referenced by RubyCodeDocumentation::saveToXMI(), JavaCodeDocumentation::saveToXMI(), CPPCodeDocumentation::saveToXMI(), CPPCodeComment::saveToXMI(), CodeComment::saveToXMI(), and CodeBlock::setAttributesOnNode().

void TextBlock::setAttributesFromNode QDomElement &  element  )  [protected, virtual]
 

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

Reimplemented in CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, and OwnedHierarchicalCodeBlock.

Definition at line 266 of file textblock.cpp.

References decodeText(), UMLApp::getCommonPolicy(), CodeGenerationPolicy::getNewLineEndingChars(), setIndentationLevel(), setTag(), setText(), and setWriteOutText().

Referenced by CodeComment::loadFromXMI(), and CodeBlock::setAttributesFromNode().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:06 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003