Kaydet (Commit) 3482a706 authored tarafından Henry Castro's avatar Henry Castro

sw lok: include the field name in the description of the redline

In tiled rendering case, when the text node is a field,
the description shows incorrect characters

Change-Id: I1e3a456b6e2a19a7629b58a8a6ae77e2090a06a1
Reviewed-on: https://gerrit.libreoffice.org/48538Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarHenry Castro <hcastro@collabora.com>
üst 63d4ab4b
......@@ -38,6 +38,7 @@
#include <redline.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <vcl/scheduler.hxx>
#include <flddat.hxx>
static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/";
......@@ -100,6 +101,7 @@ public:
void testPageHeader();
void testPageFooter();
void testTdf115088();
void testRedlineField();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
......@@ -150,6 +152,7 @@ public:
CPPUNIT_TEST(testPageHeader);
CPPUNIT_TEST(testPageFooter);
CPPUNIT_TEST(testTdf115088);
CPPUNIT_TEST(testRedlineField);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -2061,6 +2064,30 @@ void SwTiledRenderingTest::testTdf115088()
comphelper::LibreOfficeKit::setActive(false);
}
void SwTiledRenderingTest::testRedlineField()
{
// Load a document.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
// Turn on track changes and type "x".
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
SwDateTimeField aDate(static_cast<SwDateTimeFieldType*>(pWrtShell->GetFieldType(0, SwFieldIds::DateTime)));
//aDate->SetDateTime(::DateTime(::DateTime::SYSTEM));
pWrtShell->Insert(aDate);
// Get the redline just created
const SwRedlineTable& rTable = pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size());
SwRangeRedline* pRedline = rTable[0];
CPPUNIT_ASSERT(pRedline->GetDescr().indexOf(aDate.GetFieldName())!= -1);
comphelper::LibreOfficeKit::setActive(false);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -57,6 +57,7 @@
#include <strings.hrc>
#include <unoport.hxx>
#include <wrtsh.hxx>
#include <txtfld.hxx>
#include <flowfrm.hxx>
......@@ -1789,9 +1790,18 @@ OUString SwRangeRedline::GetDescr()
bDeletePaM = true;
}
OUString sDescr = pPaM->GetText();
if (const SwTextNode *pTextNode = pPaM->GetNode().GetTextNode())
{
if (const SwTextAttr* pTextAttr = pTextNode->GetFieldTextAttrAt(pPaM->GetPoint()->nContent.GetIndex() - 1, true ))
{
sDescr = pTextAttr->GetFormatField().GetField()->GetFieldName();
}
}
// replace $1 in description by description of the redlines text
const OUString aTmpStr = SwResId(STR_START_QUOTE)
+ ShortenString(pPaM->GetText(), nUndoStringLength, SwResId(STR_LDOTS))
+ ShortenString(sDescr, nUndoStringLength, SwResId(STR_LDOTS))
+ SwResId(STR_END_QUOTE);
SwRewriter aRewriter;
......
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