sw/inc/redline.hxx | 14 +------------- sw/qa/extras/uiwriter/uiwriter.cxx | 11 ++++++++++- sw/source/core/doc/docredln.cxx | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-)
New commits: commit f240f073d228e62afd3f60563c23626efad0df7f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Sep 21 12:12:51 2016 +0200 Related: tdf#102308 sw: ignore seconds when combining redlines The purpose of storing seconds was to get a better timestamp, not to make combining impossible. Also fix two issues with the existing testcase: - read both timestamps, so test doesn't fail if the second is 0 in the first redline - don't fail if minute changes while waiting for a second Change-Id: Ib6c8ecdcf2f0da9191f0b48e6aaefc0b2449583e diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index f6a0eac..0cf123b 100644 --- a/sw/inc/redline.hxx +++ b/sw/inc/redline.hxx @@ -150,19 +150,7 @@ public: void SetAutoFormatFlag() { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); } - bool CanCombine( const SwRedlineData& rCmp ) const - { - return nAuthor == rCmp.nAuthor && - eType == rCmp.eType && - sComment == rCmp.sComment && - GetTimeStamp() == rCmp.GetTimeStamp() && - (( !pNext && !rCmp.pNext ) || - ( pNext && rCmp.pNext && - pNext->CanCombine( *rCmp.pNext ))) && - (( !pExtraData && !rCmp.pExtraData ) || - ( pExtraData && rCmp.pExtraData && - *pExtraData == *rCmp.pExtraData )); - } + bool CanCombine( const SwRedlineData& rCmp ) const; // ExtraData gets copied, the pointer is therefore not taken over by // the RedlineObject diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 4e5f9cc..54755d3 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -3960,11 +3960,20 @@ void SwUiWriterTest::testRedlineTimestamp() pWrtShell->EndDoc(); pWrtShell->Insert("zzz"); + // Inserting additional characters at the start changed the table size to + // 3, i.e. the first and the second "aaa" wasn't combined. + pWrtShell->SttDoc(); + pWrtShell->Insert("aaa"); + // Now assert that at least one of the the seconds are not 0. const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); + if (rTable.size() >= 2 && rTable[0]->GetRedlineData().GetTimeStamp().GetMin() != rTable[1]->GetRedlineData().GetTimeStamp().GetMin()) + // The relatively rare case when waiting for a second also changes the minute. + return; + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rTable.size()); sal_uInt16 nSec1 = rTable[0]->GetRedlineData().GetTimeStamp().GetSec(); - sal_uInt16 nSec2 = rTable[0]->GetRedlineData().GetTimeStamp().GetSec(); + sal_uInt16 nSec2 = rTable[1]->GetRedlineData().GetTimeStamp().GetSec(); // This failed, seconds was always 0. CPPUNIT_ASSERT(nSec1 != 0 || nSec2 != 0); } diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index b15883f..a3d3bb1 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -871,6 +871,24 @@ SwRedlineData::~SwRedlineData() delete pNext; } +bool SwRedlineData::CanCombine(const SwRedlineData& rCmp) const +{ + DateTime aTime = GetTimeStamp(); + aTime.SetSec(0); + DateTime aCompareTime = rCmp.GetTimeStamp(); + aCompareTime.SetSec(0); + return nAuthor == rCmp.nAuthor && + eType == rCmp.eType && + sComment == rCmp.sComment && + aTime == aCompareTime && + (( !pNext && !rCmp.pNext ) || + ( pNext && rCmp.pNext && + pNext->CanCombine( *rCmp.pNext ))) && + (( !pExtraData && !rCmp.pExtraData ) || + ( pExtraData && rCmp.pExtraData && + *pExtraData == *rCmp.pExtraData )); +} + /// ExtraData is copied. The Pointer's ownership is thus NOT transferred /// to the Redline Object! void SwRedlineData::SetExtraData( const SwRedlineExtraData* pData ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits