diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-21 12:12:51 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-21 17:05:02 +0200 |
commit | f240f073d228e62afd3f60563c23626efad0df7f (patch) | |
tree | 901cefc01ce33d540e035c02e4f8c839402a70e0 | |
parent | d0ebd056868e96469ca1356a0a2f37c433456f75 (diff) |
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
-rw-r--r-- | sw/inc/redline.hxx | 14 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 18 |
3 files changed, 29 insertions, 14 deletions
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index f6a0eacc97b4..0cf123b7d5c8 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 4e5f9ccc835e..54755d373d0a 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 b15883f74aef..a3d3bb18f0ae 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 ) |