diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-14 15:24:19 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-14 16:11:53 -0400 |
commit | adf0d7b1fb8eed88f4fcd6d31662ae6f59d00812 (patch) | |
tree | 2e11b46ca8f9b93e3f18e2c74c22c40cd4b7bea1 /sc/source | |
parent | d873fd9fa28a26c6f2b177d26dbbc76c9bd827a3 (diff) |
Preserve the "end of list" flag for xls round-tripping.
This "end of list" flag determines whether the row insertion was an
automatic insertion at the bottom. Calc doesn't use this at the moment
but Excel uses it to differentiate a normal row insertion from an
automatic one.
Change-Id: I6b28669d816c54d1dc1e4c106918ba688415788d
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/chgtrack.cxx | 46 | ||||
-rw-r--r-- | sc/source/filter/inc/XclExpChangeTrack.hxx | 5 | ||||
-rw-r--r-- | sc/source/filter/inc/XclImpChangeTrack.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xcl97/XclExpChangeTrack.cxx | 17 | ||||
-rw-r--r-- | sc/source/filter/xcl97/XclImpChangeTrack.cxx | 11 |
5 files changed, 53 insertions, 28 deletions
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 4b57b717976d..a18d0d387be8 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -652,8 +652,9 @@ void ScChangeAction::AddDependent( sal_uLong nActionNumber, } // ScChangeActionIns -ScChangeActionIns::ScChangeActionIns( const ScRange& rRange ) - : ScChangeAction( SC_CAT_NONE, rRange ) +ScChangeActionIns::ScChangeActionIns( const ScRange& rRange, bool bEndOfList ) : + ScChangeAction(SC_CAT_NONE, rRange), + mbEndOfList(bEndOfList) { if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) { @@ -684,8 +685,10 @@ ScChangeActionIns::ScChangeActionIns( const sal_uLong nActionNumber, const ScChangeActionState eStateP, const sal_uLong nRejectingNumber, const ScBigRange& aBigRangeP, const OUString& aUserP, const DateTime& aDateTimeP, - const OUString& sComment, const ScChangeActionType eTypeP) : - ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment) + const OUString& sComment, const ScChangeActionType eTypeP, + bool bEndOfList ) : + ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment), + mbEndOfList(bEndOfList) { } @@ -728,6 +731,11 @@ void ScChangeActionIns::GetDescription( } } +bool ScChangeActionIns::IsEndOfList() const +{ + return mbEndOfList; +} + bool ScChangeActionIns::Reject( ScDocument* pDoc ) { if ( !aBigRange.IsValid( pDoc ) ) @@ -2848,9 +2856,9 @@ ScChangeActionContent* ScChangeTrack::AppendContentOnTheFly( return pAct; } -void ScChangeTrack::AppendInsert( const ScRange& rRange ) +void ScChangeTrack::AppendInsert( const ScRange& rRange, bool bEndOfList ) { - ScChangeActionIns* pAct = new ScChangeActionIns( rRange ); + ScChangeActionIns* pAct = new ScChangeActionIns(rRange, bEndOfList); Append( pAct ); } @@ -4477,18 +4485,20 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const case SC_CAT_INSERT_COLS: case SC_CAT_INSERT_ROWS: case SC_CAT_INSERT_TABS: - { - pClonedAction = new ScChangeActionIns( - pAction->GetActionNumber(), - pAction->GetState(), - pAction->GetRejectAction(), - pAction->GetBigRange(), - pAction->GetUser(), - pAction->GetDateTimeUTC(), - pAction->GetComment(), - pAction->GetType() ); - } - break; + { + bool bEndOfList = static_cast<const ScChangeActionIns*>(pAction)->IsEndOfList(); + pClonedAction = new ScChangeActionIns( + pAction->GetActionNumber(), + pAction->GetState(), + pAction->GetRejectAction(), + pAction->GetBigRange(), + pAction->GetUser(), + pAction->GetDateTimeUTC(), + pAction->GetComment(), + pAction->GetType(), + bEndOfList ); + } + break; case SC_CAT_DELETE_COLS: case SC_CAT_DELETE_ROWS: case SC_CAT_DELETE_TABS: diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx index 18b040952b7a..2bfa1bb7eded 100644 --- a/sc/source/filter/inc/XclExpChangeTrack.hxx +++ b/sc/source/filter/inc/XclExpChangeTrack.hxx @@ -472,11 +472,12 @@ public: class XclExpChTrInsert : public XclExpChTrAction { + bool mbEndOfList; + protected: ScRange aRange; - XclExpChTrInsert( const XclExpChTrInsert& rCopy ) : - XclExpChTrAction( rCopy ), aRange( rCopy.aRange ) {} + XclExpChTrInsert( const XclExpChTrInsert& rCopy ); virtual void SaveActionData( XclExpStream& rStrm ) const SAL_OVERRIDE; virtual void PrepareSaveAction( XclExpStream& rStrm ) const SAL_OVERRIDE; diff --git a/sc/source/filter/inc/XclImpChangeTrack.hxx b/sc/source/filter/inc/XclImpChangeTrack.hxx index 0d1dc7003807..ac589b91ddad 100644 --- a/sc/source/filter/inc/XclImpChangeTrack.hxx +++ b/sc/source/filter/inc/XclImpChangeTrack.hxx @@ -65,7 +65,7 @@ private: void DoAcceptRejectAction( ScChangeAction* pAction ); void DoAcceptRejectAction( sal_uInt32 nFirst, sal_uInt32 nLast ); - void DoInsertRange( const ScRange& rRange ); + void DoInsertRange( const ScRange& rRange, bool bEndOfList ); void DoDeleteRange( const ScRange& rRange ); inline sal_uInt8 LookAtuInt8(); diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index bb47f2aa6434..a307382cc87b 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -992,19 +992,31 @@ void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm ) pStream->endElement( XML_rcc ); } +XclExpChTrInsert::XclExpChTrInsert( const XclExpChTrInsert& rCopy ) : + XclExpChTrAction(rCopy), + mbEndOfList(rCopy.mbEndOfList), + aRange(rCopy.aRange) {} + XclExpChTrInsert::XclExpChTrInsert( const ScChangeAction& rAction, const XclExpRoot& rRoot, const XclExpChTrTabIdBuffer& rTabIdBuffer, ScChangeTrack& rChangeTrack ) : XclExpChTrAction( rAction, rRoot, rTabIdBuffer ), + mbEndOfList(false), aRange( rAction.GetBigRange().MakeRange() ) { nLength = 0x00000030; switch( rAction.GetType() ) { case SC_CAT_INSERT_COLS: nOpCode = EXC_CHTR_OP_INSCOL; break; - case SC_CAT_INSERT_ROWS: nOpCode = EXC_CHTR_OP_INSROW; break; + case SC_CAT_INSERT_ROWS: + { + const ScChangeActionIns& rIns = static_cast<const ScChangeActionIns&>(rAction); + mbEndOfList = rIns.IsEndOfList(); + nOpCode = EXC_CHTR_OP_INSROW; + } + break; case SC_CAT_DELETE_COLS: nOpCode = EXC_CHTR_OP_DELCOL; break; case SC_CAT_DELETE_ROWS: nOpCode = EXC_CHTR_OP_DELROW; break; default: @@ -1036,7 +1048,8 @@ XclExpChTrInsert::~XclExpChTrInsert() void XclExpChTrInsert::SaveActionData( XclExpStream& rStrm ) const { WriteTabId( rStrm, aRange.aStart.Tab() ); - rStrm << (sal_uInt16) 0x0000; + sal_uInt16 nFlagVal = mbEndOfList ? 0x0001 : 0x0000; + rStrm << nFlagVal; Write2DRange( rStrm, aRange ); rStrm << (sal_uInt32) 0x00000000; } diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx index b6e4180fc76b..f4532086d709 100644 --- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx @@ -93,10 +93,10 @@ void XclImpChangeTrack::DoAcceptRejectAction( sal_uInt32 nFirst, sal_uInt32 nLas DoAcceptRejectAction( pChangeTrack->GetAction( nIndex ) ); } -void XclImpChangeTrack::DoInsertRange( const ScRange& rRange ) +void XclImpChangeTrack::DoInsertRange( const ScRange& rRange, bool bEndOfList ) { sal_uInt32 nFirst = pChangeTrack->GetActionMax() + 1; - pChangeTrack->AppendInsert( rRange ); + pChangeTrack->AppendInsert(rRange, bEndOfList); sal_uInt32 nLast = pChangeTrack->GetActionMax(); DoAcceptRejectAction( nFirst, nLast ); } @@ -297,7 +297,8 @@ void XclImpChangeTrack::ReadChTrInsert() ScRange aRange; aRange.aStart.SetTab( ReadTabNum() ); aRange.aEnd.SetTab( aRange.aStart.Tab() ); - pStrm->Ignore( 2 ); + sal_uInt16 nFlags = pStrm->ReaduInt16(); + bool bEndOfList = (nFlags & 0x0001); // row auto-inserted at the bottom. Read2DRange( aRange ); if( aRecHeader.nOpCode & EXC_CHTR_OP_COLFLAG ) @@ -314,7 +315,7 @@ void XclImpChangeTrack::ReadChTrInsert() if( aRecHeader.nOpCode & EXC_CHTR_OP_DELFLAG ) DoDeleteRange( aRange ); else - DoInsertRange( aRange ); + DoInsertRange(aRange, bEndOfList); } } } @@ -426,7 +427,7 @@ void XclImpChangeTrack::ReadChTrInsertTab() if( pStrm->IsValid() ) { nTabIdCount++; - DoInsertRange( ScRange( 0, 0, nTab, MAXCOL, MAXROW, nTab ) ); + DoInsertRange(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), false); } } } |