Skip to content

Commit

Permalink
Merge pull request '[ve] Move group geometry to bottom and group text…
Browse files Browse the repository at this point in the history
… to top; Fix bug 72848' (#592) from feature/visio into release/v8.3.0

Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/sdkjs/pulls/592
  • Loading branch information
K0R0L committed Jan 29, 2025
2 parents e1afe23 + 4d8d52b commit be57dfb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
2 changes: 2 additions & 0 deletions visio/model/VisioDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@
shapeOrGroup.recalculate();
shapeOrGroup.recalculateTransformText && shapeOrGroup.recalculateTransformText();
shapeOrGroup.recalculateLocalTransform(shapeOrGroup.transform);
shapeOrGroup.recalculateContent && shapeOrGroup.recalculateContent();

}
}
}
Expand Down
55 changes: 47 additions & 8 deletions visio/model/ooxmlApi/convertFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,18 @@
groupShape.pen = cShapeOrCGroupShape.pen;
groupShape.Id = cShapeOrCGroupShape.Id + "_Group";

// add group geometry to bottom
if (cShapeOrCGroupShape instanceof CGroupShape) {
groupShape.addToSpTree(groupShape.spTree.length, cShapeOrCGroupShape.spTree[0]);
} else {
groupShape.addToSpTree(groupShape.spTree.length, cShapeOrCGroupShape);
}
groupShape.spTree[groupShape.spTree.length - 1].setGroup(groupShape);


cShapeOrCGroupShape.spPr.xfrm.setOffX(0);
cShapeOrCGroupShape.spPr.xfrm.setOffY(0);

// cShape.setLocks(1)?;

groupShape.setParent2(visioDocument);
Expand All @@ -1966,7 +1978,7 @@

currentGroupHandling.addToSpTree(currentGroupHandling.spTree.length, groupShape);
currentGroupHandling.spTree[currentGroupHandling.spTree.length - 1].setGroup(currentGroupHandling);
groupShape.recalculateLocalTransform(groupShape.transform);
// groupShape.recalculateLocalTransform(groupShape.transform);

currentGroupHandling = groupShape;
let subShapes = this.getSubshapes();
Expand All @@ -1976,15 +1988,39 @@
}
}

// add group own geometry and text to bottom of spTree bcs so it will be brought to top on drawing
groupShape.addToSpTree(groupShape.spTree.length, cShapeOrCGroupShape);
groupShape.spTree[groupShape.spTree.length - 1].setGroup(groupShape);

cShapeOrCGroupShape.spPr.xfrm.setOffX(0);
cShapeOrCGroupShape.spPr.xfrm.setOffY(0);
// add group text to top
if (cShapeOrCGroupShape instanceof CGroupShape) {
groupShape.addToSpTree(groupShape.spTree.length, cShapeOrCGroupShape.spTree[1]);
groupShape.spTree[groupShape.spTree.length - 1].setGroup(groupShape);
}

// recalculate positions to local (group) coordinates
cShapeOrCGroupShape.recalculateLocalTransform(cShapeOrCGroupShape.transform);
// cShapeOrCGroupShape.recalculateLocalTransform(cShapeOrCGroupShape.transform);

if (cShapeOrCGroupShape instanceof CGroupShape) {
cShapeOrCGroupShape.spTree[0].recalculateLocalTransform(cShapeOrCGroupShape.spTree[0].transform);
cShapeOrCGroupShape.spTree[0].recalculateTransformText && cShapeOrCGroupShape.spTree[0].recalculateTransformText();
cShapeOrCGroupShape.spTree[0].recalculateContent && cShapeOrCGroupShape.spTree[0].recalculateContent();
cShapeOrCGroupShape.spTree[0].recalculate();


cShapeOrCGroupShape.spTree[1].recalculateLocalTransform(cShapeOrCGroupShape.spTree[1].transform);
cShapeOrCGroupShape.spTree[1].recalculateTransformText && cShapeOrCGroupShape.spTree[1].recalculateTransformText();
cShapeOrCGroupShape.spTree[1].recalculateContent && cShapeOrCGroupShape.spTree[1].recalculateContent();

cShapeOrCGroupShape.spTree[1].recalculate();
} else {
cShapeOrCGroupShape.recalculateLocalTransform(cShapeOrCGroupShape.transform);
cShapeOrCGroupShape.recalculateTransformText && cShapeOrCGroupShape.recalculateTransformText();
cShapeOrCGroupShape.recalculateContent && cShapeOrCGroupShape.recalculateContent();
cShapeOrCGroupShape.recalculate();
}

groupShape.recalculateTransformText && groupShape.recalculateTransformText();
groupShape.recalculateContent && groupShape.recalculateContent();
groupShape.recalculateLocalTransform(groupShape.transform);
groupShape.recalculate();

// cShapes.geometryCShape.recalculateTransformText();
// cShapes.geometryCShape.recalculateContent();
// cShapes.geometryCShape.recalculate(); // doesnt work here
Expand Down Expand Up @@ -2023,6 +2059,9 @@
}

if (currentGroupHandling) {
currentGroupHandling.recalculateLocalTransform(currentGroupHandling.transform);
currentGroupHandling.recalculateTransformText && currentGroupHandling.recalculateTransformText();
currentGroupHandling.recalculateContent && currentGroupHandling.recalculateContent();
currentGroupHandling.recalculate();
}

Expand Down

0 comments on commit be57dfb

Please sign in to comment.