diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-04-02 08:54:59 +0100 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-04-03 09:43:56 +0200 |
commit | b9955b2083ffdc1f99bc8be6b09d806fa3279a16 (patch) | |
tree | 8deabb3c56c55833392d8454feac519740caaafd /editeng/qa | |
parent | 14198f2191f216592f00b72221771704b3ce4636 (diff) |
tdf#93173: Remove arbitrary line spacing limit
OASIS Open Document Format for Office Applications (OpenDocument) v.1.2
doesn't limit the value of fo:line-height. But we have arbitrary limits
in proportional mode for both minimal (50%) and maximal (200%) values.
The implementation uses sal_uInt16 to store the value, so fix places
where sal_uInt8 was unreasonably used to set it, change the upper limit
to max sal_uInt16 value, and set lower limit to 6% (to match Word's
minimal factor of 0.06).
Change-Id: I4c2ac5f0acf65d7573328e71bcf36ac9abb5ffd5
Reviewed-on: https://gerrit.libreoffice.org/52252
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'editeng/qa')
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 92 |
1 files changed, 42 insertions, 50 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 5346dae6a0aa..cb9b49cc7275 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -171,63 +171,55 @@ void Test::testLineSpacing() CPPUNIT_ASSERT_EQUAL(sal_uLong(aTextLen), rDoc.GetTextLen()); CPPUNIT_ASSERT_EQUAL(aText, rDoc.GetParaAsString(sal_Int32(0))); - // Get ItemSet for line spacing - 60% - std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); - SvxLineSpacingItem aLineSpacing(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL); - aLineSpacing.SetPropLineSpace(60); - pSet->Put(aLineSpacing); - - // Set font - SvxFontItem aFont(EE_CHAR_FONTINFO); - aFont.SetFamilyName("Liberation Sans"); - pSet->Put(aFont); - SvxFontHeightItem aFontSize(240, 100, EE_CHAR_FONTHEIGHT); - pSet->Put(aFontSize); - - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(3), pSet->Count()); - - // Select all paragraphs and set spacing + // Select all paragraphs ESelection aSelection(0, 0, 0, aTextLen); - aEditEngine.QuickSetAttribs(*pSet, aSelection); + + auto doTest = [&](sal_uInt16 nSpace, sal_uInt16 nExpMaxAscent, sal_uInt32 nExpLineHeight) + { + std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); + SvxLineSpacingItem aLineSpacing(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL); + aLineSpacing.SetPropLineSpace(nSpace); + pSet->Put(aLineSpacing); + + // Set font + SvxFontItem aFont(EE_CHAR_FONTINFO); + aFont.SetFamilyName("Liberation Sans"); + pSet->Put(aFont); + SvxFontHeightItem aFontSize(240, 100, EE_CHAR_FONTHEIGHT); + pSet->Put(aFontSize); + + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(3), pSet->Count()); + + aEditEngine.QuickSetAttribs(*pSet, aSelection); + + // Assert changes + ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0]; + ContentNode* const pNode = pParaPortion->GetNode(); + const SvxLineSpacingItem& rLSItem = pNode->GetContentAttribs().GetItem(EE_PARA_SBL); + CPPUNIT_ASSERT_EQUAL(SvxInterLineSpaceRule::Prop, rLSItem.GetInterLineSpaceRule()); + CPPUNIT_ASSERT_EQUAL(nSpace, rLSItem.GetPropLineSpace()); + + // Check the first line + ParagraphInfos aInfo = aEditEngine.GetParagraphInfos(0); + CPPUNIT_ASSERT_EQUAL(nExpMaxAscent, aInfo.nFirstLineMaxAscent); + CPPUNIT_ASSERT_EQUAL(nExpLineHeight, aEditEngine.GetLineHeight(0)); + }; + + // Test first case - 60% + doTest(60, 122, 153); // Force multiple lines aEditEngine.SetPaperSize(Size(1000, 6000)); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aEditEngine.GetLineCount(0)); - // Assert changes - ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0]; - ContentNode* const pNode = pParaPortion->GetNode(); - const SvxLineSpacingItem& rLSItem = pNode->GetContentAttribs().GetItem(EE_PARA_SBL); - CPPUNIT_ASSERT_EQUAL(SvxInterLineSpaceRule::Prop, rLSItem.GetInterLineSpaceRule()); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(60), rLSItem.GetPropLineSpace()); - - // Check the first line - ParagraphInfos aInfo = aEditEngine.GetParagraphInfos(0); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(122), aInfo.nFirstLineMaxAscent); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(153), static_cast<sal_uInt16>(aEditEngine.GetLineHeight(0))); - - // Prepare second case - 150% - std::unique_ptr<SfxItemSet> pSet2(new SfxItemSet(aEditEngine.GetEmptyItemSet())); - SvxLineSpacingItem aLineSpacing2(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL); - aLineSpacing2.SetPropLineSpace(150); - pSet2->Put(aLineSpacing2); - pSet2->Put(aFont); - pSet2->Put(aFontSize); - - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(3), pSet2->Count()); - - // Select all paragraphs and set spacing - aEditEngine.QuickSetAttribs(*pSet2, aSelection); + // Test second case - 150% + doTest(150, 337, 382); - // Assert changes - const SvxLineSpacingItem& rLSItem2 = pNode->GetContentAttribs().GetItem(EE_PARA_SBL); - CPPUNIT_ASSERT_EQUAL(SvxInterLineSpaceRule::Prop, rLSItem2.GetInterLineSpaceRule()); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(150), rLSItem2.GetPropLineSpace()); - - // Check the first line - ParagraphInfos aInfo2 = aEditEngine.GetParagraphInfos(0); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(337), aInfo2.nFirstLineMaxAscent); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(382), static_cast<sal_uInt16>(aEditEngine.GetLineHeight(0))); + // Test lower Word limit - 6% (factor 0.06) + doTest(6, 12, 15); + + // Test upper Word limit - 13200% (factor 132) + doTest(13200, 33615, 33660); } void Test::testConstruction() |