Commit d7b73a16 authored by Craig Watson's avatar Craig Watson

Save the transform matrix of group items to SVG

Solves issue where items (other than strokes) that had been grouped then
moved (and/or rotated) lost their new position after saving and loading
the document.
parent 67d3a34b
...@@ -938,6 +938,8 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() ...@@ -938,6 +938,8 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
if(mStrokesList.contains(id)) if(mStrokesList.contains(id))
shouldSkipSubElements = true; shouldSkipSubElements = true;
QStringRef svgTransform = mXmlReader.attributes().value("transform");
mXmlReader.readNext(); mXmlReader.readNext();
while (!mXmlReader.atEnd()) while (!mXmlReader.atEnd())
{ {
...@@ -981,6 +983,12 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() ...@@ -981,6 +983,12 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
group->destroy(false); group->destroy(false);
} }
} }
if (!svgTransform.isNull()) {
QMatrix itemMatrix = fromSvgTransform(svgTransform.toString());
group->setMatrix(itemMatrix);
}
return group; return group;
} }
...@@ -1346,6 +1354,10 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(UBDocumentProxy* proxy, ...@@ -1346,6 +1354,10 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(UBDocumentProxy* proxy,
if(curElement.hasAttribute("locked")){ if(curElement.hasAttribute("locked")){
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri,"locked",curElement.attribute("locked")); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri,"locked",curElement.attribute("locked"));
} }
if (curElement.hasAttribute("transform"))
mXmlWriter.writeAttribute("transform", curElement.attribute("transform"));
QDomElement curSubElement = curElement.firstChildElement(); QDomElement curSubElement = curElement.firstChildElement();
while (!curSubElement.isNull()) { while (!curSubElement.isNull()) {
if (curSubElement.hasAttribute(aId)) { if (curSubElement.hasAttribute(aId)) {
...@@ -1391,6 +1403,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro ...@@ -1391,6 +1403,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro
else else
curGroupElement.setAttribute("locked", xmlFalse); curGroupElement.setAttribute("locked", xmlFalse);
} }
curGroupElement.setAttribute("transform", toSvgTransform(groupItem->sceneMatrix()));
curParent->appendChild(curGroupElement); curParent->appendChild(curGroupElement);
foreach (QGraphicsItem *item, groupItem->childItems()) { foreach (QGraphicsItem *item, groupItem->childItems()) {
QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item); QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item);
......
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