[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Tue Jul 24 22:10:38 UTC 2007
SVN commit 692032 by okellogg:
UMLObject::loadStereotype(): New, factored from loadFromXMI().
Further adjustments for loading attachment 21243 (Netbeans XMI)
CCBUG:56184
M +1 -0 model_utils.cpp
M +3 -5 umldoc.cpp
M +32 -23 umlobject.cpp
M +8 -0 umlobject.h
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.cpp #692031:692032
@@ -287,6 +287,7 @@
Uml::tagEq(tag, "isActive") ||
Uml::tagEq(tag, "namespace") ||
Uml::tagEq(tag, "ownerScope") ||
+ Uml::tagEq(tag, "ModelElement.stereotype") ||
Uml::tagEq(tag, "GeneralizableElement.generalization") ||
Uml::tagEq(tag, "specialization") || //NYI
Uml::tagEq(tag, "clientDependency") || //NYI
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umldoc.cpp #692031:692032
@@ -1660,16 +1660,14 @@
// From here on, it's support for stereotypes, pre 1.5.5 versions, and foreign files
if (tagEq(type, "Namespace.ownedElement") ||
tagEq(type, "Namespace.contents") ||
- tagEq(type, "Model") || tagEq(type, "ModelElement.stereotype")) {
+ tagEq(type, "Model")) {
//CHECK: Umbrello currently assumes that nested elements
// are ownedElements anyway.
// Therefore the <UML:Namespace.ownedElement> tag is of no
// significance.
if( !loadUMLObjectsFromXMI( tempElement ) ) {
- if (! tagEq(type, "ModelElement.stereotype")) { // not yet implemented
- kWarning() << "failed load on " << type << endl;
- return false;
- }
+ kWarning() << "failed load on " << type << endl;
+ return false;
}
continue;
}
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #692031:692032
@@ -543,6 +543,36 @@
return true;
}
+bool UMLObject::loadStereotype(QDomElement & element) {
+ QString tag = element.tagName();
+ if (!Uml::tagEq(tag, "stereotype"))
+ return false;
+ QString stereo = element.attribute("xmi.value", "");
+ if (stereo.isEmpty() && element.hasChildNodes()) {
+ /* like so:
+ <UML:ModelElement.stereotype>
+ <UML:Stereotype xmi.idref = '07CD'/>
+ </UML:ModelElement.stereotype>
+ */
+ QDomNode stereoNode = element.firstChild();
+ QDomElement stereoElem = stereoNode.toElement();
+ tag = stereoElem.tagName();
+ if (Uml::tagEq(tag, "Stereotype")) {
+ stereo = stereoElem.attribute("xmi.idref", "");
+ }
+ }
+ if (stereo.isEmpty())
+ return false;
+ Uml::IDType stereoID = STR2ID(stereo);
+ UMLDoc *pDoc = UMLApp::app()->getDocument();
+ m_pStereotype = pDoc->findStereotypeById(stereoID);
+ if (m_pStereotype)
+ m_pStereotype->incrRefCount();
+ else
+ m_SecondaryId = stereo; // leave it to resolveRef()
+ return true;
+}
+
bool UMLObject::loadFromXMI( QDomElement & element) {
UMLDoc* umldoc = UMLApp::app()->getDocument();
if (umldoc == NULL) {
@@ -674,29 +704,8 @@
if (ownerScope.isEmpty())
ownerScope = elem.text();
m_bStatic = (ownerScope == "classifier");
- } else if (Uml::tagEq(tag, "stereotype")) {
- QString stereo = elem.attribute("xmi.value", "");
- if (stereo.isEmpty() && elem.hasChildNodes()) {
- /* like so:
- <UML:ModelElement.stereotype>
- <UML:Stereotype xmi.idref = '07CD'/>
- </UML:ModelElement.stereotype>
- */
- QDomNode stereoNode = elem.firstChild();
- QDomElement stereoElem = stereoNode.toElement();
- tag = stereoElem.tagName();
- if (Uml::tagEq(tag, "Stereotype")) {
- stereo = stereoElem.attribute("xmi.idref", "");
- }
- }
- if (! stereo.isEmpty()) {
- Uml::IDType stereoID = STR2ID(stereo);
- m_pStereotype = umldoc->findStereotypeById(stereoID);
- if (m_pStereotype)
- m_pStereotype->incrRefCount();
- else
- m_SecondaryId = stereo; // leave it to resolveRef()
- }
+ } else {
+ loadStereotype(elem);
}
node = node.nextSibling();
if (node.isComment())
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.h #692031:692032
@@ -303,6 +303,14 @@
virtual bool loadFromXMI( QDomElement & element );
/**
+ * Analyzes the given QDomElement for a reference to a stereotype.
+ *
+ * @param element QDomElement to analyze.
+ * @return True if a stereotype reference was found, else false.
+ */
+ bool loadStereotype(QDomElement & element);
+
+ /**
* Returns true if this UMLObject has classifier scope,
* otherwise false (the default).
*/
More information about the umbrello-devel
mailing list