[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sun Feb 5 11:50:04 UTC 2006


SVN commit 506105 by okellogg:

m_SecondaryFallback: New. Required by Roseimport.


 M  +29 -16    umlobject.cpp  
 M  +24 -5     umlobject.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #506104:506105
@@ -1,8 +1,3 @@
-/*
- *  copyright (C) 2002-2006
- *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>
- */
-
 /***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -10,6 +5,8 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
+ *  copyright (C) 2002-2006                                                *
+ *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>                  *
  ***************************************************************************/
 
 #include <qregexp.h>
@@ -381,6 +378,14 @@
     m_SecondaryId = id;
 }
 
+QString UMLObject::getSecondaryFallback() const {
+    return m_SecondaryFallback;
+}
+
+void UMLObject::setSecondaryFallback(QString id) {
+    m_SecondaryFallback = id;
+}
+
 void UMLObject::maybeSignalObjectCreated() {
     if (!m_bCreationWasSignalled &&
             m_BaseType != Uml::ot_Stereotype &&
@@ -393,7 +398,7 @@
 }
 
 bool UMLObject::resolveRef() {
-    if (m_pSecondary || m_SecondaryId.isEmpty()) {
+    if (m_pSecondary || (m_SecondaryId.isEmpty() && m_SecondaryFallback.isEmpty())) {
         maybeSignalObjectCreated();
         return true;
     }
@@ -404,18 +409,26 @@
     UMLDoc *pDoc = UMLApp::app()->getDocument();
     // In the new, XMI standard compliant save format,
     // the type is the xmi.id of a UMLClassifier.
-    Uml::IDType id = STR2ID(m_SecondaryId);
-    m_pSecondary = pDoc->findObjectById(id);
-    if (m_pSecondary != NULL) {
-        m_SecondaryId = "";
-        maybeSignalObjectCreated();
-        return true;
+    if (! m_SecondaryId.isEmpty()) {
+        m_pSecondary = pDoc->findObjectById(STR2ID(m_SecondaryId));
+        if (m_pSecondary != NULL) {
+            m_SecondaryId = "";
+            maybeSignalObjectCreated();
+            return true;
+        }
     }
     if (!pDoc->isNativeXMIFile() || !m_SecondaryId.contains(QRegExp("\\D"))) {
-        kdError() << "UMLObject::resolveRef(" << m_Name
-        << "): cannot find type with id "
-        << ID2STR(id) << endl;
-        return false;
+        if (m_SecondaryFallback.isEmpty()) {
+            kdError() << "UMLObject::resolveRef(" << m_Name
+                      << "): cannot find type with id "
+                      << m_SecondaryId << endl;
+            return false;
+        }
+        kdDebug() << "UMLObject::resolveRef(" << m_Name 
+                  << "): could not resolve secondary ID " << m_SecondaryId
+                  << ", using secondary fallback " << m_SecondaryFallback
+                  << endl;
+        m_SecondaryId = m_SecondaryFallback;
     }
     // Assume we're dealing with the older Umbrello format where
     // the type name was saved in the "type" attribute rather
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.h #506104:506105
@@ -1,8 +1,3 @@
-/*
- *  copyright (C) 2002-2006
- *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>
- */
-
 /***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -10,6 +5,8 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
+ *  copyright (C) 2002-2006                                                *
+ *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>                  *
  ***************************************************************************/
 
 #ifndef UMLOBJECT_H
@@ -327,6 +324,18 @@
     void setSecondaryId(QString id);
 
     /**
+     * Return secondary ID fallback.
+     * Required by resolveRef() for imported model files.
+     */
+    QString getSecondaryFallback() const;
+
+    /**
+     * Set the secondary ID fallback.
+     * Currently only used by petalTree2Uml().
+     */
+    void setSecondaryFallback(QString id);
+
+    /**
      * Returns true if this object resides in an externalized folder.
      * CHECK: It is probably cleaner to move this to the UMLListViewItem.
      */
@@ -446,6 +455,16 @@
      * in the course of resolveRef() at the end of loading.
      */
     QString m_SecondaryId;
+
+    /**
+     * Last-chance backup for when m_SecondaryId is not found.
+     * Used by Rose import: MDL files specify both a "quidu"
+     * (which corresponds to m_SecondaryId) and the human readable
+     * fully qualified target name of a reference.
+     * In case the quidu is not found, the human readable name is
+     * used which we store in m_SecondaryFallback.
+     */
+    QString m_SecondaryFallback;
 };
 
 /**




More information about the umbrello-devel mailing list