[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - oox/source sd/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 5 08:46:37 UTC 2020
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 58 ++++++++++++++++++--
sd/qa/unit/data/pptx/smartart-linear-rule.pptx |binary
sd/qa/unit/import-tests-smartart.cxx | 11 +++
3 files changed, 66 insertions(+), 3 deletions(-)
New commits:
commit 2b4d3b05b345280368d6277dbbcf470e92937e46
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Aug 3 11:18:49 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 5 10:46:17 2020 +0200
oox smartart, linear layout: limit height of children to parent size
Constraints are OK to request more, but it seems PowerPoint doesn't
allow leaving the parent, which simplifies the layout as well.
(cherry picked from commit b7481a026348c3417fa13a440312521dccee9ec8)
Change-Id: Id67a8740f1eff506e4beae0c797ad50e0218dfe6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100114
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index e23226de61a8..13e684d7b76f 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -927,9 +927,21 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
LayoutProperty& rProperty = aProperties[rConstraint.msForName];
if (rConstraint.mnType == XML_w)
+ {
rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor;
+ if (rProperty[XML_w] > rShape->getSize().Width)
+ {
+ rProperty[XML_w] = rShape->getSize().Width;
+ }
+ }
if (rConstraint.mnType == XML_h)
+ {
rProperty[XML_h] = rShape->getSize().Height * rConstraint.mfFactor;
+ if (rProperty[XML_h] > rShape->getSize().Height)
+ {
+ rProperty[XML_h] = rShape->getSize().Height;
+ }
+ }
// TODO: get values from differently named constraints as well
if (rConstraint.msForName == "sp" || rConstraint.msForName == "space" || rConstraint.msForName == "sibTrans")
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 7e5dd78b8b44..4425c560d676 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1520,6 +1520,12 @@ void SdImportTestSmartArt::testLinearRule()
sal_Int32 nArrowLeft = xShape->getPosition().X;
CPPUNIT_ASSERT_EQUAL(nGroupLeft, nArrowLeft);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected less or equal than: 10092
+ // - Actual : 20183
+ // i.e. the arrow height was larger than the canvas given to the smartart on slide 1.
+ CPPUNIT_ASSERT_LESSEQUAL(static_cast<sal_Int32>(10092), xShape->getSize().Height);
+
xDocShRef->DoClose();
}
commit 1d68ea619ca08264ec357e4388ac2da2b7473d2b
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Aug 3 09:57:57 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 5 10:46:00 2020 +0200
oox smartart, linear layout: fix scaling of spacing without rules
With this, finally the arrow shape has the correct horizontal position
and width, even if the markup is as complex as the PowerPoint UI
generates it (the previous version was a more minimal version).
(cherry picked from commit 880673412143a7db7ea1bf4766040662dfc085dc)
Change-Id: I59f237c582053067e890180a1ae40471e5f46dea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100113
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index fc1b58e24d27..e23226de61a8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -964,6 +964,8 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
{
fCount -= 1.0;
+ bool bIsDependency = false;
+ double fFactor = 0;
for (const auto& rConstraint : rConstraints)
{
if (rConstraint.msForName != aCurrShape->getInternalName())
@@ -971,16 +973,25 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
continue;
}
- if (aChildrenToShrink.find(rConstraint.msRefForName) == aChildrenToShrink.end())
+ if ((nDir == XML_fromL || nDir == XML_fromR) && rConstraint.mnType != XML_w)
{
continue;
}
+ if ((nDir == XML_fromL || nDir == XML_fromR) && rConstraint.mnType == XML_w)
+ {
+ fFactor = rConstraint.mfFactor;
+ }
- if ((nDir == XML_fromL || nDir == XML_fromR) && rConstraint.mnType != XML_w)
+ if ((nDir == XML_fromT || nDir == XML_fromB) && rConstraint.mnType != XML_h)
{
continue;
}
- if ((nDir == XML_fromT || nDir == XML_fromB) && rConstraint.mnType != XML_h)
+ if ((nDir == XML_fromT || nDir == XML_fromB) && rConstraint.mnType == XML_h)
+ {
+ fFactor = rConstraint.mfFactor;
+ }
+
+ if (aChildrenToShrink.find(rConstraint.msRefForName) == aChildrenToShrink.end())
{
continue;
}
@@ -989,8 +1000,29 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
// other child which will be scaled.
fCount += rConstraint.mfFactor;
aChildrenToShrinkDeps.insert(aCurrShape->getInternalName());
+ bIsDependency = true;
break;
}
+
+ if (!bIsDependency && aCurrShape->getServiceName() == "com.sun.star.drawing.GroupShape")
+ {
+ bool bScaleDownEmptySpacing = false;
+ if (nDir == XML_fromL || nDir == XML_fromR)
+ {
+ oox::OptValue<sal_Int32> oWidth = findProperty(aProperties, aCurrShape->getInternalName(), XML_w);
+ bScaleDownEmptySpacing = oWidth.has() && oWidth.get() > 0;
+ }
+ if (!bScaleDownEmptySpacing && (nDir == XML_fromT || nDir == XML_fromB))
+ {
+ oox::OptValue<sal_Int32> oHeight = findProperty(aProperties, aCurrShape->getInternalName(), XML_h);
+ bScaleDownEmptySpacing = oHeight.has() && oHeight.get() > 0;
+ }
+ if (bScaleDownEmptySpacing && aCurrShape->getChildren().empty())
+ {
+ fCount += fFactor;
+ aChildrenToShrinkDeps.insert(aCurrShape->getInternalName());
+ }
+ }
}
}
}
@@ -1084,6 +1116,14 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
aCurrPos.Y = (rShape->getSize().Height - aSize.Height) / 2;
if (nIncY)
aCurrPos.X = (rShape->getSize().Width - aSize.Width) / 2;
+ if (aCurrPos.X < 0)
+ {
+ aCurrPos.X = 0;
+ }
+ if (aCurrPos.Y < 0)
+ {
+ aCurrPos.Y = 0;
+ }
aCurrShape->setPosition(aCurrPos);
diff --git a/sd/qa/unit/data/pptx/smartart-linear-rule.pptx b/sd/qa/unit/data/pptx/smartart-linear-rule.pptx
index e76dfd9ee770..05905299ed27 100644
Binary files a/sd/qa/unit/data/pptx/smartart-linear-rule.pptx and b/sd/qa/unit/data/pptx/smartart-linear-rule.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index b64f7f997412..7e5dd78b8b44 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1511,6 +1511,11 @@ void SdImportTestSmartArt::testLinearRule()
// - Expected: 3160
// - Actual : 8770
// i.e. there was unexpected spacing on the left of the arrow.
+ // Then the imporoved version of the test document failed with:
+ // - Expected: 3160
+ // - Actual : 19828
+ // i.e. the spacing on the left of the arrow was so large that the shape was mostly outside the
+ // slide.
sal_Int32 nGroupLeft = xGroup->getPosition().X;
sal_Int32 nArrowLeft = xShape->getPosition().X;
CPPUNIT_ASSERT_EQUAL(nGroupLeft, nArrowLeft);
More information about the Libreoffice-commits
mailing list