diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /umbrello/umbrello/codegenerators/cppcodedocumentation.cpp | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'umbrello/umbrello/codegenerators/cppcodedocumentation.cpp')
-rw-r--r-- | umbrello/umbrello/codegenerators/cppcodedocumentation.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/umbrello/umbrello/codegenerators/cppcodedocumentation.cpp b/umbrello/umbrello/codegenerators/cppcodedocumentation.cpp new file mode 100644 index 00000000..833e648e --- /dev/null +++ b/umbrello/umbrello/codegenerators/cppcodedocumentation.cpp @@ -0,0 +1,141 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * copyright (C) 2004-2006 * + * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * + ***************************************************************************/ + +/* This code generated by: + * Author : thomas + * Date : Mon Jun 23 2003 + */ + +// own header +#include "cppcodedocumentation.h" +// qt/kde includes +#include <qregexp.h> +#include <kdebug.h> +// app includes +#include "../codedocument.h" +#include "../codegenerator.h" +#include "../codegenerationpolicy.h" +#include "../uml.h" + +// Constructors/Destructors +// + +CPPCodeDocumentation::CPPCodeDocumentation ( CodeDocument * doc, const QString & text ) + : CodeComment (doc, text) +{ + +} + +CPPCodeDocumentation::~CPPCodeDocumentation ( ) { } + +// +// Methods +// + + +// Accessor methods +// + +// Other methods +// + +/** + * Save the XMI representation of this object + */ +void CPPCodeDocumentation::saveToXMI ( QDomDocument & doc, QDomElement & root ) { + QDomElement blockElement = doc.createElement( "cppcodedocumentation" ); + setAttributesOnNode(doc, blockElement); // as we added no additional fields to this class we may + // just use parent TextBlock method + root.appendChild( blockElement ); +} + +/** + * @return QString + */ +QString CPPCodeDocumentation::toString ( ) +{ + + QString output = ""; + + // simple output method + if(getWriteOutText()) + { + bool useDoubleDashOutput = true; + + // need to figure out output type from cpp policy + CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy(); + if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine) + useDoubleDashOutput = false; + + QString indent = getIndentationString(); + QString endLine = getNewLineEndingChars(); + QString body = getText(); + if(useDoubleDashOutput) + { + if(!body.isEmpty()) + output.append(formatMultiLineText (body, indent +"// ", endLine)); + } else { + output.append(indent+"/**"+endLine); + output.append(formatMultiLineText (body, indent +" * ", endLine)); + output.append(indent+" */"+endLine); + } + } + + return output; +} + +QString CPPCodeDocumentation::getNewEditorLine ( int amount ) +{ + CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy(); + if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine) + return getIndentationString(amount) + " * "; + else + return getIndentationString(amount) + "// "; +} + +int CPPCodeDocumentation::firstEditableLine() { + CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy(); + if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine) + return 1; + return 0; +} + +int CPPCodeDocumentation::lastEditableLine() { + CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy(); + if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine) + { + return -1; // very last line is NOT editable + } + return 0; +} + +/** UnFormat a long text string. Typically, this means removing + * the indentaion (linePrefix) and/or newline chars from each line. + */ +QString CPPCodeDocumentation::unformatText ( const QString & text , const QString & indent) +{ + + QString mytext = TextBlock::unformatText(text, indent); + CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy(); + // remove leading or trailing comment stuff + mytext.remove(QRegExp('^'+indent)); + if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine) + { + mytext.remove(QRegExp("^\\/\\*\\*\\s*\n?")); + mytext.remove(QRegExp("\\s*\\*\\/\\s*\n?$")); + mytext.remove(QRegExp("^\\s*\\*\\s*")); + } else + mytext.remove(QRegExp("^\\/\\/\\s*")); + + return mytext; +} + + |