Kaydet (Commit) f240f073 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst d0ebd056
...@@ -150,19 +150,7 @@ public: ...@@ -150,19 +150,7 @@ public:
void SetAutoFormatFlag() void SetAutoFormatFlag()
{ eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); } { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
bool CanCombine( const SwRedlineData& rCmp ) const 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 ));
}
// ExtraData gets copied, the pointer is therefore not taken over by // ExtraData gets copied, the pointer is therefore not taken over by
// the RedlineObject // the RedlineObject
......
...@@ -3960,11 +3960,20 @@ void SwUiWriterTest::testRedlineTimestamp() ...@@ -3960,11 +3960,20 @@ void SwUiWriterTest::testRedlineTimestamp()
pWrtShell->EndDoc(); pWrtShell->EndDoc();
pWrtShell->Insert("zzz"); 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. // Now assert that at least one of the the seconds are not 0.
const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); 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()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rTable.size());
sal_uInt16 nSec1 = rTable[0]->GetRedlineData().GetTimeStamp().GetSec(); 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. // This failed, seconds was always 0.
CPPUNIT_ASSERT(nSec1 != 0 || nSec2 != 0); CPPUNIT_ASSERT(nSec1 != 0 || nSec2 != 0);
} }
......
...@@ -871,6 +871,24 @@ SwRedlineData::~SwRedlineData() ...@@ -871,6 +871,24 @@ SwRedlineData::~SwRedlineData()
delete pNext; 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 /// ExtraData is copied. The Pointer's ownership is thus NOT transferred
/// to the Redline Object! /// to the Redline Object!
void SwRedlineData::SetExtraData( const SwRedlineExtraData* pData ) void SwRedlineData::SetExtraData( const SwRedlineExtraData* pData )
......
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