Kaydet (Commit) 8193e697 authored tarafından Miklos Vajna's avatar Miklos Vajna

oox smartart, cycle matrix: fix fill and line props of shape

The topmost shape may not have 0 depth, but something larger.

In that case at least it's safe to still use fill & line properties. The
B1 quadrant of the test file now has the proper orange background, and
B2's border is also properly orange.

Change-Id: Iccc5f6993693a0f1cf8f50d163003c24d3ad690e
Reviewed-on: https://gerrit.libreoffice.org/68104Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 3a85c2db
...@@ -1168,6 +1168,14 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode ...@@ -1168,6 +1168,14 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
pPresNode->msModelId); pPresNode->msModelId);
if( aNodeName != mrDgm.getData()->getPresOfNameMap().end() ) if( aNodeName != mrDgm.getData()->getPresOfNameMap().end() )
{ {
// Calculate the depth of what is effectively the topmost element.
sal_Int32 nMinDepth = std::numeric_limits<sal_Int32>::max();
for (const auto& rPair : aNodeName->second)
{
if (rPair.second.mnDepth < nMinDepth)
nMinDepth = rPair.second.mnDepth;
}
for (const auto& rPair : aNodeName->second) for (const auto& rPair : aNodeName->second)
{ {
const DiagramData::SourceIdAndDepth& rItem = rPair.second; const DiagramData::SourceIdAndDepth& rItem = rPair.second;
...@@ -1199,6 +1207,13 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode ...@@ -1199,6 +1207,13 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
<< " added for layout node named \"" << msName << " added for layout node named \"" << msName
<< "\""); << "\"");
} }
else if (rItem.mnDepth == nMinDepth)
{
// If no real topmost element, then take properties from the one that's the closest
// to topmost.
rShape->getLineProperties() = aDataNode2->second->mpShape->getLineProperties();
rShape->getFillProperties() = aDataNode2->second->mpShape->getFillProperties();
}
// append text with right outline level // append text with right outline level
if( aDataNode2->second->mpShape->getTextBody() && if( aDataNode2->second->mpShape->getTextBody() &&
......
...@@ -829,6 +829,19 @@ void SdImportTestSmartArt::testCycleMatrix() ...@@ -829,6 +829,19 @@ void SdImportTestSmartArt::testCycleMatrix()
CPPUNIT_ASSERT(xA1.is()); CPPUNIT_ASSERT(xA1.is());
CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1->getString()); CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1->getString());
// Test fill color of B1, should be orange.
uno::Reference<text::XText> xB1(getChildShape(getChildShape(xGroup, 1), 1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xB1.is());
CPPUNIT_ASSERT_EQUAL(OUString("B1"), xB1->getString());
uno::Reference<beans::XPropertySet> xB1Props(xB1, uno::UNO_QUERY);
CPPUNIT_ASSERT(xB1Props.is());
sal_Int32 nFillColor = 0;
xB1Props->getPropertyValue("FillColor") >>= nFillColor;
// Without the accompanying fix in place, this test would have failed: the background color was
// 0x4f81bd, i.e. blue, not orange.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nFillColor);
// Without the accompanying fix in place, this test would have failed: the // Without the accompanying fix in place, this test would have failed: the
// content of the "A2" shape was lost. // content of the "A2" shape was lost.
uno::Reference<text::XText> xA2(getChildShape(getChildShape(getChildShape(xGroup, 0), 0), 1), uno::Reference<text::XText> xA2(getChildShape(getChildShape(getChildShape(xGroup, 0), 0), 1),
...@@ -850,6 +863,13 @@ void SdImportTestSmartArt::testCycleMatrix() ...@@ -850,6 +863,13 @@ void SdImportTestSmartArt::testCycleMatrix()
uno::Reference<drawing::XShape> xB2Shape(xB2, uno::UNO_QUERY); uno::Reference<drawing::XShape> xB2Shape(xB2, uno::UNO_QUERY);
CPPUNIT_ASSERT(xB2Shape.is()); CPPUNIT_ASSERT(xB2Shape.is());
// Test line color of B2, should be orange.
uno::Reference<beans::XPropertySet> xB2Props(xB2, uno::UNO_QUERY);
CPPUNIT_ASSERT(xB2Props.is());
sal_Int32 nLineColor = 0;
xB2Props->getPropertyValue("LineColor") >>= nLineColor;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nLineColor);
uno::Reference<text::XText> xC2(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1), uno::Reference<text::XText> xC2(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1),
uno::UNO_QUERY); uno::UNO_QUERY);
CPPUNIT_ASSERT(xC2.is()); CPPUNIT_ASSERT(xC2.is());
......
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