umbrello API Documentation

javacodedocumentation.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2004-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 /*  This code generated by:
00013  *      Author : thomas
00014  *      Date   : Mon Jun 23 2003
00015  */
00016 
00017 // own header
00018 #include "javacodedocumentation.h"
00019 
00020 // qt/kde includes
00021 #include <qregexp.h>
00022 #include <kdebug.h>
00023 
00024 // local includes
00025 #include "javaclassifiercodedocument.h"
00026 #include "../codegenerationpolicy.h"
00027 #include "../uml.h"
00028 
00029 // Constructors/Destructors
00030 //
00031 
00032 JavaCodeDocumentation::JavaCodeDocumentation ( JavaClassifierCodeDocument * doc, const QString & text )
00033         : CodeComment(doc, text)
00034 {
00035 
00036 }
00037 
00038 JavaCodeDocumentation::~JavaCodeDocumentation ( ) { }
00039 
00040 //
00041 // Methods
00042 //
00043 
00044 
00045 // Accessor methods
00046 //
00047 
00048 // Other methods
00049 //
00050 
00054 void JavaCodeDocumentation::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00055     QDomElement blockElement = doc.createElement( "javacodedocumentation" );
00056     setAttributesOnNode(doc, blockElement); // as we added no additional fields to this class we may
00057     // just use parent TextBlock method
00058     root.appendChild( blockElement );
00059 }
00060 
00064 QString JavaCodeDocumentation::toString ( )
00065 {
00066 
00067     QString output = "";
00068 
00069     // simple output method
00070     if(getWriteOutText())
00071     {
00072         bool useDoubleDashOutput = true;
00073 
00074         // need to figure out output type from java policy
00075         CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00076         if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00077             useDoubleDashOutput = false;
00078 
00079         QString indent = getIndentationString();
00080         QString endLine = getNewLineEndingChars();
00081         QString body = getText();
00082         if(useDoubleDashOutput)
00083         {
00084             if(!body.isEmpty())
00085                 output.append(formatMultiLineText (body, indent +"// ", endLine));
00086         } else {
00087             output.append(indent+""+endLine);
00090         }
00091     }
00092 
00093     return output;
00094 }
00095 
00096 QString JavaCodeDocumentation::getNewEditorLine ( int amount )
00097 {
00098     CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00099     if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00100         return getIndentationString(amount) + " * ";
00101     else
00102         return getIndentationString(amount) + "// ";
00103 }
00104 
00105 int JavaCodeDocumentation::firstEditableLine() {
00106     CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00107     if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00108         return 1;
00109     return 0;
00110 }
00111 
00112 int JavaCodeDocumentation::lastEditableLine() {
00113     CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00114     if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00115     {
00116         return -1; // very last line is NOT editable
00117     }
00118     return 0;
00119 }
00120 
00124 QString JavaCodeDocumentation::unformatText ( const QString & text , const QString & indent)
00125 {
00126 
00127     QString mytext = TextBlock::unformatText(text, indent);
00128     CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00129     // remove leading or trailing comment stuff
00130     mytext.remove(QRegExp('^'+indent));
00131     if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00132     {
00133         mytext.remove(QRegExp("^\\/\\*\\*\\s*\n?"));
00134         mytext.remove(QRegExp("\\s*\\*\\/\\s*\n?$"));
00135         mytext.remove(QRegExp("^\\s*\\*\\s*"));
00136     } else
00137         mytext.remove(QRegExp("^\\/\\/\\s*"));
00138 
00139     return mytext;
00140 }
00141 
00142 
00143 #include "javacodedocumentation.moc"
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:07:57 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003