oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 14 ++++++++++++++ sd/qa/unit/import-tests-smartart.cxx | 17 +++++++++++++++++ 2 files changed, 31 insertions(+)
New commits: commit 6277a767f33bb5327408dafff2fed199087e938d Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Dec 14 16:01:27 2018 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Dec 14 17:59:20 2018 +0100 oox smartart, accent process: fix missing bullets and large para indent Bulleted paragraphs had a large left indent because we assumed the bullet levels are inherited from the normal master page styles. But that's not true, as <https://support.office.com/en-us/article/add-bullets-to-a-shape-in-a-smartart-graphic-47edc03d-a2f8-4b54-acfd-ca103c515ab4> points out: "It is not possible to change the bullet style for text in a SmartArt graphic." This explains why the margin and bullet char info is missing from the file format, and hints that just hardcoding these to the importer is correct. The result is less linebreaks in the shape text and the lost bullets are also fixed. Change-Id: I60bbee75f3e834551ebb1963a2f42101f3bd91d4 Reviewed-on: https://gerrit.libreoffice.org/65168 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index bea44faf8784..1aa8d6753a4a 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -867,13 +867,27 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, } ParamMap::const_iterator aBulletLvl = maMap.find(XML_stBulletLvl); + int nStartBulletsAtLevel = 0; if (aBulletLvl != maMap.end()) + { nBaseLevel -= aBulletLvl->second; + nStartBulletsAtLevel = aBulletLvl->second; + } for (auto & aParagraph : pTextBody->getParagraphs()) { sal_Int32 nLevel = aParagraph->getProperties().getLevel(); aParagraph->getProperties().setLevel(nLevel - nBaseLevel); + if (nStartBulletsAtLevel > 0 && nLevel >= nStartBulletsAtLevel) + { + // It is not possible to change the bullet style for text. + sal_Int32 nLeftMargin = 285750 * (nLevel - nStartBulletsAtLevel) / EMU_PER_HMM; + aParagraph->getProperties().getParaLeftMargin() = nLeftMargin; + aParagraph->getProperties().getFirstLineIndentation() = -285750 / EMU_PER_HMM; + OUString aBulletChar = OUString::fromUtf8(u8"•"); + aParagraph->getProperties().getBulletList().setBulletChar(aBulletChar); + aParagraph->getProperties().getBulletList().setSuffixNone(); + } } // explicit alignment diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 5eda257f6bf0..c54fdb873036 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -576,6 +576,23 @@ void SdImportTestSmartArt::testAccentProcess() CPPUNIT_ASSERT_EQUAL(OUString("b"), xFirstChildText->getString()); uno::Reference<drawing::XShape> xFirstChild(xFirstChildText, uno::UNO_QUERY); CPPUNIT_ASSERT(xFirstChildText.is()); + + { + uno::Reference<container::XEnumerationAccess> xParasAccess(xFirstChildText, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParas = xParasAccess->createEnumeration(); + uno::Reference<beans::XPropertySet> xPara(xParas->nextElement(), uno::UNO_QUERY); + // Without the accompanying fix in place, this test would have failed + // with 'Expected: 0; Actual : 1270', i.e. there was a large + // unexpected left margin. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), + xPara->getPropertyValue("ParaLeftMargin").get<sal_Int32>()); + + uno::Reference<container::XIndexAccess> xRules(xPara->getPropertyValue("NumberingRules"), + uno::UNO_QUERY); + comphelper::SequenceAsHashMap aRule(xRules->getByIndex(1)); + CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule["BulletChar"].get<OUString>()); + } + int nFirstChildTop = xFirstChild->getPosition().Y; int nFirstChildRight = xFirstChild->getPosition().X + xFirstChild->getSize().Width; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits