editeng: don't preserve escapement attribute on paragraph break.
This fixes a particuarly annoying habit of a trailing superscript ordinal suffix getting dragged into the next bullet and causing the unwary user weird small fonts, and non-aligned bullets. Nail only the most obvious case, leaving multi-line superscript in-place, and ignoring other attributes. Include unit test. Change-Id: I9ba5009ed17377e5c2f24c9edb74c3a1c1393cd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199203 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 03ed94560aaa20070708b265d3a551c862718bc3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204606 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
67326438c6
commit
be1915d07b
@@ -30,6 +30,7 @@
|
||||
#include <editeng/editobj.hxx>
|
||||
#include <editeng/flditem.hxx>
|
||||
#include <editeng/udlnitem.hxx>
|
||||
#include <editeng/escapementitem.hxx>
|
||||
#include <svl/srchitem.hxx>
|
||||
#include <svl/voiditem.hxx>
|
||||
#include <tools/stream.hxx>
|
||||
@@ -139,6 +140,7 @@ public:
|
||||
void testTdf162803StaleKashidaArray();
|
||||
void testTdf157037PasteTextAutoDirection();
|
||||
void testFontVariationsItem();
|
||||
void testEscapementNotPreservedOnParaBreak();
|
||||
|
||||
DECL_STATIC_LINK(Test, CalcFieldValueHdl, EditFieldInfo*, void);
|
||||
|
||||
@@ -175,6 +177,7 @@ public:
|
||||
CPPUNIT_TEST(testTdf162803StaleKashidaArray);
|
||||
CPPUNIT_TEST(testTdf157037PasteTextAutoDirection);
|
||||
CPPUNIT_TEST(testFontVariationsItem);
|
||||
CPPUNIT_TEST(testEscapementNotPreservedOnParaBreak);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
@@ -2498,7 +2501,50 @@ void Test::testFontVariationsItem()
|
||||
SvxFontVariationsItem aItem4(EE_CHAR_FONTVARIATIONS);
|
||||
CPPUNIT_ASSERT(aItem4.PutValue(aAny, 0));
|
||||
CPPUNIT_ASSERT(aItem4.operator==(aItem2));
|
||||
}
|
||||
|
||||
void Test::testEscapementNotPreservedOnParaBreak()
|
||||
{
|
||||
EditEngine aEditEngine(mpItemPool.get());
|
||||
EditDoc& rDoc = aEditEngine.GetEditDoc();
|
||||
|
||||
OUString aParaText = u"item 1st"_ustr;
|
||||
aEditEngine.SetText(aParaText);
|
||||
CPPUNIT_ASSERT_EQUAL(aParaText, rDoc.GetParaAsString(sal_Int32(0)));
|
||||
|
||||
{
|
||||
std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet()));
|
||||
SvxEscapementItem aSuperscript(SvxEscapement::Superscript, EE_CHAR_ESCAPEMENT);
|
||||
pSet->Put(aSuperscript);
|
||||
aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 6, 0, 8));
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet()));
|
||||
SvxWeightItem aBold(WEIGHT_BOLD, EE_CHAR_WEIGHT);
|
||||
pSet->Put(aBold);
|
||||
aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 6, 0, 8));
|
||||
}
|
||||
|
||||
// new para break at the end of the text (cf. pressing enter)
|
||||
ContentNode* pNode = rDoc.GetObject(0);
|
||||
CPPUNIT_ASSERT(pNode);
|
||||
EditPaM aEndPaM(pNode, pNode->Len());
|
||||
rDoc.InsertParaBreak(aEndPaM, true /* bKeepEndingAttribs */);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), rDoc.Count());
|
||||
CPPUNIT_ASSERT_EQUAL(aParaText, rDoc.GetParaAsString(sal_Int32(0)));
|
||||
CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(1)));
|
||||
|
||||
// Check new para's character attributes
|
||||
pNode = rDoc.GetObject(1);
|
||||
CPPUNIT_ASSERT(pNode);
|
||||
|
||||
const EditCharAttrib* pBoldAttr = pNode->GetCharAttribs().FindEmptyAttrib(EE_CHAR_WEIGHT, 0);
|
||||
CPPUNIT_ASSERT_MESSAGE("Bold attribute should be carried over.", pBoldAttr != nullptr);
|
||||
|
||||
const EditCharAttrib* pEscAttr = pNode->GetCharAttribs().FindEmptyAttrib(EE_CHAR_ESCAPEMENT, 0);
|
||||
CPPUNIT_ASSERT_MESSAGE("Escapement attribute should NOT be included.", !pEscAttr);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
|
||||
|
||||
@@ -302,7 +302,8 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool,
|
||||
else if ( pAttrib->GetEnd() == nCut )
|
||||
{
|
||||
// must be copied as an empty attributes.
|
||||
if ( bKeepEndingAttribs && !pAttrib->IsFeature() && !maCharAttribList.FindAttrib( pAttrib->GetItem()->Which(), 0 ) )
|
||||
if ( bKeepEndingAttribs && !pAttrib->IsFeature() && !maCharAttribList.FindAttrib( pAttrib->GetItem()->Which(), 0 )
|
||||
&& pAttrib->GetItem()->Which() != EE_CHAR_ESCAPEMENT )
|
||||
{
|
||||
EditCharAttrib* pNewAttrib = MakeCharAttrib( rPool, *(pAttrib->GetItem()), 0, 0 );
|
||||
assert(pNewAttrib);
|
||||
|
||||
Reference in New Issue
Block a user