[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Jul 14 14:36:38 PDT 2014


 sc/inc/chgtrack.hxx                          |   26 +++++++++------
 sc/source/core/tool/chgtrack.cxx             |   46 ++++++++++++++++-----------
 sc/source/filter/inc/XclExpChangeTrack.hxx   |    5 +-
 sc/source/filter/inc/XclImpChangeTrack.hxx   |    2 -
 sc/source/filter/xcl97/XclExpChangeTrack.cxx |   17 ++++++++-
 sc/source/filter/xcl97/XclImpChangeTrack.cxx |   11 +++---
 6 files changed, 68 insertions(+), 39 deletions(-)

New commits:
commit 8fd0951429bfa00a054ebbc195a480f89af9f912
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jul 14 15:24:19 2014 -0400

    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.
    
    (cherry picked from commit adf0d7b1fb8eed88f4fcd6d31662ae6f59d00812)
    
    Conflicts:
    	sc/inc/chgtrack.hxx
    	sc/source/filter/xcl97/XclExpChangeTrack.cxx
    
    Change-Id: I6b28669d816c54d1dc1e4c106918ba688415788d

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 8f83d06..3d4026b 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -423,7 +423,9 @@ class ScChangeActionIns : public ScChangeAction
 {
     friend class ScChangeTrack;
 
-                                ScChangeActionIns( const ScRange& rRange );
+    bool mbEndOfList; /// whether or not a row was auto-inserted at the bottom.
+
+    ScChangeActionIns( const ScRange& rRange, bool bEndOfList = false );
     virtual                     ~ScChangeActionIns();
 
     virtual void                AddContent( ScChangeActionContent* ) {}
@@ -434,17 +436,21 @@ class ScChangeActionIns : public ScChangeAction
     virtual const ScChangeTrack*    GetChangeTrack() const { return 0; }
 
 public:
-    ScChangeActionIns(const sal_uLong nActionNumber,
-            const ScChangeActionState eState,
-            const sal_uLong nRejectingNumber,
-            const ScBigRange& aBigRange,
-            const OUString& aUser,
-            const DateTime& aDateTime,
-            const OUString &sComment,
-            const ScChangeActionType eType); // only to use in the XML import
+    ScChangeActionIns(
+        const sal_uLong nActionNumber,
+        const ScChangeActionState eState,
+        const sal_uLong nRejectingNumber,
+        const ScBigRange& aBigRange,
+        const OUString& aUser,
+        const DateTime& aDateTime,
+        const OUString &sComment,
+        const ScChangeActionType eType,
+        bool bEndOfList = false );
 
     virtual void GetDescription(
         OUString& rStr, ScDocument* pDoc, bool bSplitRange = false, bool bWarning = true) const;
+
+    SC_DLLPUBLIC bool IsEndOfList() const;
 };
 
 //  ScChangeActionDel
@@ -1144,7 +1150,7 @@ public:
     // Only use the following two if there is no different solution! (Assign
     // string for NewValue or creation of a formula respectively)
 
-    SC_DLLPUBLIC void AppendInsert( const ScRange& );
+    SC_DLLPUBLIC void AppendInsert( const ScRange& rRange, bool bEndOfList = false );
 
                                 // pRefDoc may be NULL => no lookup of contents
                                 // => no generation of deleted contents
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 87d0cdb..7512f7b 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -660,8 +660,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 )
     {
@@ -692,8 +693,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)
 {
 }
 
@@ -736,6 +739,11 @@ void ScChangeActionIns::GetDescription(
     }
 }
 
+bool ScChangeActionIns::IsEndOfList() const
+{
+    return mbEndOfList;
+}
+
 bool ScChangeActionIns::Reject( ScDocument* pDoc )
 {
     if ( !aBigRange.IsValid( pDoc ) )
@@ -2827,9 +2835,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 );
 }
 
@@ -4459,18 +4467,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 6651a75..3818535 100644
--- a/sc/source/filter/inc/XclExpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclExpChangeTrack.hxx
@@ -491,11 +491,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;
     virtual void                PrepareSaveAction( XclExpStream& rStrm ) const;
diff --git a/sc/source/filter/inc/XclImpChangeTrack.hxx b/sc/source/filter/inc/XclImpChangeTrack.hxx
index ffce967..c1b06d6 100644
--- a/sc/source/filter/inc/XclImpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclImpChangeTrack.hxx
@@ -73,7 +73,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 7033b3e..9682964 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -1033,7 +1033,10 @@ 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,
@@ -1041,13 +1044,20 @@ XclExpChTrInsert::XclExpChTrInsert(
         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:
@@ -1079,7 +1089,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 58c2540..cf1babc 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -95,10 +95,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 );
 }
@@ -299,7 +299,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 )
@@ -316,7 +317,7 @@ void XclImpChangeTrack::ReadChTrInsert()
             if( aRecHeader.nOpCode & EXC_CHTR_OP_DELFLAG )
                 DoDeleteRange( aRange );
             else
-                DoInsertRange( aRange );
+                DoInsertRange(aRange, bEndOfList);
         }
     }
 }
@@ -428,7 +429,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);
         }
     }
 }


More information about the Libreoffice-commits mailing list