Commit 74abf217 authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

Followup to commit 776c2eaa : Various fixes for writing of XMI

umbrello/umldoc.cpp
- In function saveToXMI1 reenable call to UMLListView::saveToXMI1 and
  CodeGenerator::saveToXMI1.

umbrello/uml1model/classifier.cpp
- In function saveToXMI1, avoid writing the <UML:Classifier.feature>
  element if both attList and opList are empty.

umbrello/umlwidgets/associationwidgetrole.{h,cpp}
- At function saveToXMI1 remove argument 'suffix'.

umbrello/umlwidgets/associationwidgetrole.cpp
- In function saveToXMI1 remove writing of attributes index[ab] and
  totalcount[ab].
  Writing of attributes shall not be mixed with writing the subelements
  multiplicityWidget/roleWidget/changeabilityWidget because
  attributes may not follow subelements (in particular, attributes of
  role B may not follow subelements of role A).

umbrello/umlwidgets/associationwidget.cpp
- In function saveToXMI1:
  - Postpone saving of m_nameWidget and m_associationLine until after
    all attributes have been written.
    Reason: Subelements may not precede attributes.
  - Save attributes of m_role[A] and m_role[B].  Reason: Their saving
    has been removed from AssociationWidgetRole::saveToXMI1.

CCBUG: 363582
parent cbb0c90c
......@@ -1404,19 +1404,21 @@ void UMLClassifier::saveToXMI1(QXmlStreamWriter& writer)
writer.writeEndElement();
}
// save attributes
writer.writeStartElement(QLatin1String("UML:Classifier.feature"));
UMLClassifierListItemList attList = getFilteredList(UMLObject::ot_Attribute);
foreach (UMLClassifierListItem *pAtt, attList) {
pAtt->saveToXMI1(writer);
}
UMLOperationList opList = getOpList();
// save operations
UMLOperationList opList = getOpList();
foreach (UMLOperation *pOp, opList) {
pOp->saveToXMI1(writer);
if (attList.count() || opList.count()) {
writer.writeStartElement(QLatin1String("UML:Classifier.feature"));
// save attributes
foreach (UMLClassifierListItem *pAtt, attList) {
pAtt->saveToXMI1(writer);
}
// save operations
foreach (UMLOperation *pOp, opList) {
pOp->saveToXMI1(writer);
}
writer.writeEndElement();
}
writer.writeEndElement();
// save contained objects
if (m_objects.count()) {
......@@ -1427,7 +1429,7 @@ void UMLClassifier::saveToXMI1(QXmlStreamWriter& writer)
}
writer.writeEndElement();
}
writer.writeEndElement();
writer.writeEndElement(); // from UMLObject::save1(tag)
}
/**
......
......@@ -2153,13 +2153,13 @@ void UMLDoc::saveToXMI1(QIODevice& file)
writer.writeEndElement(); // docsettings
// save listview
//UMLApp::app()->listView()->saveToXMI1(doc, extensions);
UMLApp::app()->listView()->saveToXMI1(writer);
// save code generator
CodeGenerator *codegen = UMLApp::app()->generator();
if (codegen) {
writer.writeStartElement(QLatin1String("codegeneration"));
//codegen->saveToXMI1(doc, codeGenElement);
codegen->saveToXMI1(writer);
writer.writeEndElement(); // codegeneration
}
......
......@@ -3988,14 +3988,6 @@ void AssociationWidget::saveToXMI1(QXmlStreamWriter& writer)
}
writer.writeAttribute(QLatin1String("widgetaid"), Uml::ID::toString(widgetIDForRole(RoleType::A)));
writer.writeAttribute(QLatin1String("widgetbid"), Uml::ID::toString(widgetIDForRole(RoleType::B)));
m_associationLine->saveToXMI1(writer);
if (m_nameWidget) {
m_nameWidget->saveToXMI1(writer);
}
m_role[RoleType::A].saveToXMI1(writer, QLatin1String("a"));
m_role[RoleType::B].saveToXMI1(writer, QLatin1String("b"));
if (m_associationClass) {
QString acid = Uml::ID::toString(m_associationClass->id());
......@@ -4003,6 +3995,27 @@ void AssociationWidget::saveToXMI1(QXmlStreamWriter& writer)
writer.writeAttribute(QLatin1String("aclsegindex"), QString::number(m_nLinePathSegmentIndex));
}
// save attributes of m_role[A]
const AssociationWidgetRole& roleA = m_role[RoleType::A];
writer.writeAttribute(QLatin1String("indexa"), QString::number(roleA.m_nIndex));
writer.writeAttribute(QLatin1String("totalcounta"), QString::number(roleA.m_nTotalCount));
// save attributes of m_role[B]
const AssociationWidgetRole& roleB = m_role[RoleType::B];
writer.writeAttribute(QLatin1String("indexb"), QString::number(roleB.m_nIndex));
writer.writeAttribute(QLatin1String("totalcountb"), QString::number(roleB.m_nTotalCount));
// Save subelements of m_role[A] and m_role[B].
m_role[RoleType::A].saveToXMI1(writer);
// This is separated from attributes because attributes may not follow
// elements, i.e. all attributes must be written before the first subelement.
m_role[RoleType::B].saveToXMI1(writer);
if (m_nameWidget) {
m_nameWidget->saveToXMI1(writer);
}
m_associationLine->saveToXMI1(writer);
writer.writeEndElement(); // assocwidget
}
......
......@@ -106,11 +106,11 @@ void AssociationWidgetRole::clipSize()
changeabilityWidget->clipSize();
}
void AssociationWidgetRole::saveToXMI1(QXmlStreamWriter& writer, const QString& suffix)
void AssociationWidgetRole::saveToXMI1(QXmlStreamWriter& writer)
{
writer.writeAttribute(QString(QLatin1String("index%1")).arg(suffix), QString::number(m_nIndex));
writer.writeAttribute(QString(QLatin1String("totalcount%1")).arg(suffix), QString::number(m_nTotalCount));
// For attributes index[ab] and totalcount[ab] see AssociationWidget::saveToXMI.
// They are not written here because attributes may not follow elements
// (in particular, attributes of role B may not follow elements of role A)
if (multiplicityWidget)
multiplicityWidget->saveToXMI1(writer);
if (roleWidget)
......
......@@ -58,7 +58,7 @@ public:
void setSelected(bool select);
void clipSize();
void saveToXMI1(QXmlStreamWriter& writer, const QString& suffix);
void saveToXMI1(QXmlStreamWriter& writer);
bool loadFromXMI1(QDomElement &qElement, const QString &suffix);
bool getStartMove();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment