SmartArt: bullet list improvements
by default start bullet list at second level use stBulletLvl parameter to change this behaviour Change-Id: I5084e7bf1902fdca83bea6d57a8c1f37dd2e65be Reviewed-on: https://gerrit.libreoffice.org/73440 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
committed by
Miklos Vajna
parent
8caa7d1824
commit
1e1535d46f
@@ -1227,27 +1227,30 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
|
|||||||
nBaseLevel = aParagraph->getProperties().getLevel();
|
nBaseLevel = aParagraph->getProperties().getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start bullets at:
|
||||||
|
// 1 - top level
|
||||||
|
// 2 - with children (default)
|
||||||
|
int nStartBulletsAtLevel = 2;
|
||||||
ParamMap::const_iterator aBulletLvl = maMap.find(XML_stBulletLvl);
|
ParamMap::const_iterator aBulletLvl = maMap.find(XML_stBulletLvl);
|
||||||
int nStartBulletsAtLevel = 0;
|
|
||||||
if (aBulletLvl != maMap.end())
|
if (aBulletLvl != maMap.end())
|
||||||
{
|
|
||||||
nBaseLevel -= aBulletLvl->second;
|
|
||||||
nStartBulletsAtLevel = aBulletLvl->second;
|
nStartBulletsAtLevel = aBulletLvl->second;
|
||||||
}
|
nStartBulletsAtLevel--;
|
||||||
|
|
||||||
|
bool isBulletList = false;
|
||||||
for (auto & aParagraph : pTextBody->getParagraphs())
|
for (auto & aParagraph : pTextBody->getParagraphs())
|
||||||
{
|
{
|
||||||
sal_Int32 nLevel = aParagraph->getProperties().getLevel();
|
sal_Int32 nLevel = aParagraph->getProperties().getLevel() - nBaseLevel;
|
||||||
aParagraph->getProperties().setLevel(nLevel - nBaseLevel);
|
aParagraph->getProperties().setLevel(nLevel);
|
||||||
if (nStartBulletsAtLevel > 0 && nLevel >= nStartBulletsAtLevel)
|
if (nLevel >= nStartBulletsAtLevel)
|
||||||
{
|
{
|
||||||
// It is not possible to change the bullet style for text.
|
// It is not possible to change the bullet style for text.
|
||||||
sal_Int32 nLeftMargin = 285750 * (nLevel - nStartBulletsAtLevel) / EMU_PER_HMM;
|
sal_Int32 nLeftMargin = 285750 * (nLevel - nStartBulletsAtLevel + 1) / EMU_PER_HMM;
|
||||||
aParagraph->getProperties().getParaLeftMargin() = nLeftMargin;
|
aParagraph->getProperties().getParaLeftMargin() = nLeftMargin;
|
||||||
aParagraph->getProperties().getFirstLineIndentation() = -285750 / EMU_PER_HMM;
|
aParagraph->getProperties().getFirstLineIndentation() = -285750 / EMU_PER_HMM;
|
||||||
OUString aBulletChar = OUString::fromUtf8(u8"•");
|
OUString aBulletChar = OUString::fromUtf8(u8"•");
|
||||||
aParagraph->getProperties().getBulletList().setBulletChar(aBulletChar);
|
aParagraph->getProperties().getBulletList().setBulletChar(aBulletChar);
|
||||||
aParagraph->getProperties().getBulletList().setSuffixNone();
|
aParagraph->getProperties().getBulletList().setSuffixNone();
|
||||||
|
isBulletList = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1260,8 +1263,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
|
|||||||
for (auto & aParagraph : pTextBody->getParagraphs())
|
for (auto & aParagraph : pTextBody->getParagraphs())
|
||||||
aParagraph->getProperties().setParaAdjust(aAlignment);
|
aParagraph->getProperties().setParaAdjust(aAlignment);
|
||||||
}
|
}
|
||||||
else if (std::all_of(pTextBody->getParagraphs().begin(), pTextBody->getParagraphs().end(),
|
else if (!isBulletList)
|
||||||
[](const std::shared_ptr<TextParagraph>& aParagraph) { return aParagraph->getProperties().getLevel() == 0; }))
|
|
||||||
{
|
{
|
||||||
// if not list use default alignment - centered
|
// if not list use default alignment - centered
|
||||||
for (auto & aParagraph : pTextBody->getParagraphs())
|
for (auto & aParagraph : pTextBody->getParagraphs())
|
||||||
|
BIN
sd/qa/unit/data/pptx/smartart-bullet-list.pptx
Normal file
BIN
sd/qa/unit/data/pptx/smartart-bullet-list.pptx
Normal file
Binary file not shown.
@@ -78,6 +78,7 @@ public:
|
|||||||
void testCenterCycle();
|
void testCenterCycle();
|
||||||
void testFontSize();
|
void testFontSize();
|
||||||
void testVerticalBlockList();
|
void testVerticalBlockList();
|
||||||
|
void testBulletList();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
|
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
|
||||||
|
|
||||||
@@ -117,6 +118,7 @@ public:
|
|||||||
CPPUNIT_TEST(testCenterCycle);
|
CPPUNIT_TEST(testCenterCycle);
|
||||||
CPPUNIT_TEST(testFontSize);
|
CPPUNIT_TEST(testFontSize);
|
||||||
CPPUNIT_TEST(testVerticalBlockList);
|
CPPUNIT_TEST(testVerticalBlockList);
|
||||||
|
CPPUNIT_TEST(testBulletList);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
};
|
};
|
||||||
@@ -674,7 +676,7 @@ void SdImportTestSmartArt::testAccentProcess()
|
|||||||
|
|
||||||
uno::Reference<container::XIndexAccess> xRules(xPara->getPropertyValue("NumberingRules"),
|
uno::Reference<container::XIndexAccess> xRules(xPara->getPropertyValue("NumberingRules"),
|
||||||
uno::UNO_QUERY);
|
uno::UNO_QUERY);
|
||||||
comphelper::SequenceAsHashMap aRule(xRules->getByIndex(1));
|
comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
|
||||||
CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule["BulletChar"].get<OUString>());
|
CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule["BulletChar"].get<OUString>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1244,6 +1246,34 @@ void SdImportTestSmartArt::testVerticalBlockList()
|
|||||||
xDocShRef->DoClose();
|
xDocShRef->DoClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SdImportTestSmartArt::testBulletList()
|
||||||
|
{
|
||||||
|
sd::DrawDocShellRef xDocShRef = loadURL(
|
||||||
|
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-bullet-list.pptx"),
|
||||||
|
PPTX);
|
||||||
|
uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
|
||||||
|
CPPUNIT_ASSERT(xGroup.is());
|
||||||
|
|
||||||
|
uno::Reference<text::XText> xText(xGroup->getByIndex(1), uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XEnumerationAccess> xParasAccess(xText, uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XEnumeration> xParas = xParasAccess->createEnumeration();
|
||||||
|
xParas->nextElement(); // skip parent
|
||||||
|
|
||||||
|
// child levels should have bullets
|
||||||
|
uno::Reference<beans::XPropertySet> xPara1(xParas->nextElement(), uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XIndexAccess> xRules1(xPara1->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
|
||||||
|
comphelper::SequenceAsHashMap aRule1(xRules1->getByIndex(1));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule1["BulletChar"].get<OUString>());
|
||||||
|
|
||||||
|
uno::Reference<beans::XPropertySet> xPara2(xParas->nextElement(), uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XIndexAccess> xRules2(xPara2->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
|
||||||
|
comphelper::SequenceAsHashMap aRule2(xRules2->getByIndex(2));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule2["BulletChar"].get<OUString>());
|
||||||
|
|
||||||
|
xDocShRef->DoClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
|
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
Reference in New Issue
Block a user