[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Thu Mar 21 13:38:49 PDT 2013


 sc/source/ui/collab/sendfunc.cxx  |    5 -
 sc/source/ui/collab/sendfunc.hxx  |    3 
 sc/source/ui/docshell/docfunc.cxx |   35 ++++-----
 sc/source/ui/inc/docfunc.hxx      |    3 
 sc/source/ui/inc/undocell.hxx     |   41 ++++++-----
 sc/source/ui/undo/undocell.cxx    |  138 +++++++++++++++++++-------------------
 sc/source/ui/unoobj/textuno.cxx   |    2 
 sc/source/ui/view/viewfunc.cxx    |   23 +-----
 8 files changed, 121 insertions(+), 129 deletions(-)

New commits:
commit a2b9aec93e98cad0b36f62f7c0092a8f14b300c6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 21 16:36:57 2013 -0400

    Modernize ScUndoEnterData a bit.
    
    Change-Id: I2cf86a445b4820ec89fc610e8e4eec7862195d21

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 5bc31f5..c1caa2e 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -760,31 +760,29 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos,
         return false;
     }
 
-    SCTAB* pTabs = NULL;
-    ScBaseCell** ppOldCells = NULL;
-    sal_Bool* pHasFormat = NULL;
-    sal_uLong* pOldFormats = NULL;
     ScBaseCell* pDocCell = pDoc->GetCell( rPos );
     sal_Bool bEditDeleted = (pDocCell && pDocCell->GetCellType() == CELLTYPE_EDIT);
+    ScUndoEnterData::ValuesType aOldValues;
+
     if (bUndo)
     {
-        pTabs = new SCTAB[1];
-        pTabs[0] = rPos.Tab();
-        ppOldCells  = new ScBaseCell*[1];
-        ppOldCells[0] = pDocCell ? pDocCell->Clone( *pDoc ) : 0;
+        ScUndoEnterData::Value aOldValue;
+
+        aOldValue.mnTab = rPos.Tab();
+        aOldValue.mpCell = pDocCell ? pDocCell->Clone( *pDoc ) : 0;
 
-        pHasFormat = new sal_Bool[1];
-        pOldFormats = new sal_uLong[1];
         const SfxPoolItem* pItem;
         const ScPatternAttr* pPattern = pDoc->GetPattern( rPos.Col(),rPos.Row(),rPos.Tab() );
         if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState(
                                 ATTR_VALUE_FORMAT,false,&pItem) )
         {
-            pHasFormat[0] = sal_True;
-            pOldFormats[0] = ((const SfxUInt32Item*)pItem)->GetValue();
+            aOldValue.mbHasFormat = true;
+            aOldValue.mnFormat = ((const SfxUInt32Item*)pItem)->GetValue();
         }
         else
-            pHasFormat[0] = false;
+            aOldValue.mbHasFormat = false;
+
+        aOldValues.push_back(aOldValue);
     }
 
     o_rbNumFmtSet = pDoc->SetString( rPos.Col(), rPos.Row(), rPos.Tab(), rText );
@@ -792,8 +790,8 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos,
     if (bUndo)
     {
         //  wegen ChangeTracking darf UndoAction erst nach SetString angelegt werden
-        rDocShell.GetUndoManager()->AddUndoAction(new ScUndoEnterData( &rDocShell, rPos, 1, pTabs,
-                                     ppOldCells, pHasFormat, pOldFormats, rText, NULL ) );
+        rDocShell.GetUndoManager()->AddUndoAction(
+            new ScUndoEnterData(&rDocShell, rPos, aOldValues, rText, NULL));
     }
 
     if ( bEditDeleted || pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) )
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index a41c558..76d9032 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -24,6 +24,7 @@
 #include "postit.hxx"
 
 #include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
 
 class ScDocShell;
 class ScBaseCell;
@@ -74,12 +75,24 @@ private:
 class ScUndoEnterData: public ScSimpleUndo
 {
 public:
+    struct Value
+    {
+        SCTAB mnTab;
+        bool mbHasFormat;
+        sal_uInt32 mnFormat;
+        ScBaseCell* mpCell;
+
+        Value();
+    };
+
+    typedef std::vector<Value> ValuesType;
+
                     TYPEINFO();
-                    ScUndoEnterData( ScDocShell* pNewDocShell, const ScAddress& rPos,
-                            SCTAB nNewCount, SCTAB* pNewTabs,
-                            ScBaseCell** ppOldData, sal_Bool* pHasForm, sal_uLong* pOldForm,
-                            const String& rNewStr, EditTextObject* pObj = NULL );
-    virtual         ~ScUndoEnterData();
+    ScUndoEnterData(
+        ScDocShell* pNewDocShell, const ScAddress& rPos,
+        ValuesType& rOldValues, const OUString& rNewStr, EditTextObject* pObj = NULL );
+
+    virtual ~ScUndoEnterData();
 
     virtual void    Undo();
     virtual void    Redo();
@@ -89,15 +102,12 @@ public:
     virtual rtl::OUString GetComment() const;
 
 private:
-    String          aNewString;
-    SCTAB*          pTabs;
-    ScBaseCell**    ppOldCells;
-    sal_Bool*           pHasFormat;
-    sal_uLong*          pOldFormats;
-    EditTextObject* pNewEditData;
-    sal_uLong           nEndChangeAction;
+    ValuesType maOldValues;
+
+    OUString maNewString;
+    boost::scoped_ptr<EditTextObject> mpNewEditData;
+    sal_uLong mnEndChangeAction;
     ScAddress maPos;
-    SCTAB           nCount;             //  Marked sheet
 
     void            DoChange() const;
     void            SetChangeTrack();
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index b0f15f1..d969d14 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -164,35 +164,37 @@ sal_Bool ScUndoCursorAttr::CanRepeat(SfxRepeatTarget& rTarget) const
     return (rTarget.ISA(ScTabViewTarget));
 }
 
-ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell, const ScAddress& rPos,
-            SCTAB nNewCount, SCTAB* pNewTabs, ScBaseCell** ppOldData,
-            sal_Bool* pHasForm, sal_uLong* pOldForm,
-            const String& rNewStr, EditTextObject* pObj ) :
+ScUndoEnterData::Value::Value() : mnTab(-1), mbHasFormat(false), mnFormat(0), mpCell(NULL) {}
+
+ScUndoEnterData::ScUndoEnterData(
+    ScDocShell* pNewDocShell, const ScAddress& rPos, ValuesType& rOldValues,
+    const OUString& rNewStr, EditTextObject* pObj ) :
     ScSimpleUndo( pNewDocShell ),
-    aNewString( rNewStr ),
-    pTabs( pNewTabs ),
-    ppOldCells( ppOldData ),
-    pHasFormat( pHasForm ),
-    pOldFormats( pOldForm ),
-    pNewEditData( pObj ),
-    maPos(rPos),
-    nCount( nNewCount )
+    maNewString(rNewStr),
+    mpNewEditData(pObj),
+    mnEndChangeAction(0),
+    maPos(rPos)
 {
+    maOldValues.swap(rOldValues);
+
     SetChangeTrack();
 }
 
-ScUndoEnterData::~ScUndoEnterData()
+namespace {
+
+struct DeleteCell : std::unary_function<ScUndoEnterData::Value, void>
 {
-    for (sal_uInt16 i=0; i<nCount; i++)
-        if (ppOldCells[i])
-            ppOldCells[i]->Delete();
-    delete[] ppOldCells;
+    void operator() (ScUndoEnterData::Value& rVal)
+    {
+        rVal.mpCell->Delete();
+    }
+};
 
-    delete[] pHasFormat;
-    delete[] pOldFormats;
-    delete[] pTabs;
+}
 
-    delete pNewEditData;
+ScUndoEnterData::~ScUndoEnterData()
+{
+    std::for_each(maOldValues.begin(), maOldValues.end(), DeleteCell());
 }
 
 rtl::OUString ScUndoEnterData::GetComment() const
@@ -203,8 +205,8 @@ rtl::OUString ScUndoEnterData::GetComment() const
 void ScUndoEnterData::DoChange() const
 {
     // only when needed (old or new Edit cell, or Attribute)?
-    for (sal_uInt16 i=0; i<nCount; i++)
-        pDocShell->AdjustRowHeight(maPos.Row(), maPos.Row(), pTabs[i]);
+    for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
+        pDocShell->AdjustRowHeight(maPos.Row(), maPos.Row(), maOldValues[i].mnTab);
 
     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
@@ -221,24 +223,21 @@ void ScUndoEnterData::SetChangeTrack()
     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     if ( pChangeTrack )
     {
-        nEndChangeAction = pChangeTrack->GetActionMax() + 1;
+        mnEndChangeAction = pChangeTrack->GetActionMax() + 1;
         ScAddress aPos(maPos);
-        for (sal_uInt16 i=0; i<nCount; i++)
+        for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
         {
-            aPos.SetTab( pTabs[i] );
+            aPos.SetTab(maOldValues[i].mnTab);
             sal_uLong nFormat = 0;
-            if ( pHasFormat && pOldFormats )
-            {
-                if ( pHasFormat[i] )
-                    nFormat = pOldFormats[i];
-            }
-            pChangeTrack->AppendContent( aPos, ppOldCells[i], nFormat );
+            if (maOldValues[i].mbHasFormat)
+                nFormat = maOldValues[i].mnFormat;
+            pChangeTrack->AppendContent(aPos, maOldValues[i].mpCell, nFormat);
         }
-        if ( nEndChangeAction > pChangeTrack->GetActionMax() )
-            nEndChangeAction = 0;       // nothing is appended
+        if ( mnEndChangeAction > pChangeTrack->GetActionMax() )
+            mnEndChangeAction = 0;       // nothing is appended
     }
     else
-        nEndChangeAction = 0;
+        mnEndChangeAction = 0;
 }
 
 void ScUndoEnterData::Undo()
@@ -246,29 +245,28 @@ void ScUndoEnterData::Undo()
     BeginUndo();
 
     ScDocument* pDoc = pDocShell->GetDocument();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
     {
-        ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
-        pDoc->PutCell(maPos.Col(), maPos.Row(), pTabs[i], pNewCell);
+        Value& rVal = maOldValues[i];
+        ScBaseCell* pNewCell = rVal.mpCell ? rVal.mpCell->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
+        pDoc->PutCell(maPos.Col(), maPos.Row(), rVal.mnTab, pNewCell);
 
-        if (pHasFormat && pOldFormats)
+        if (rVal.mbHasFormat)
+            pDoc->ApplyAttr(maPos.Col(), maPos.Row(), rVal.mnTab,
+                            SfxUInt32Item(ATTR_VALUE_FORMAT, rVal.mnFormat));
+        else
         {
-            if ( pHasFormat[i] )
-                pDoc->ApplyAttr(maPos.Col(), maPos.Row(), pTabs[i],
-                                SfxUInt32Item(ATTR_VALUE_FORMAT, pOldFormats[i]));
-            else
-            {
-                ScPatternAttr aPattern( *pDoc->GetPattern(maPos.Col(), maPos.Row(), pTabs[i]));
-                aPattern.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
-                pDoc->SetPattern(maPos.Col(), maPos.Row(), pTabs[i], aPattern, true);
-            }
+            ScPatternAttr aPattern(*pDoc->GetPattern(maPos.Col(), maPos.Row(), rVal.mnTab));
+            aPattern.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
+            pDoc->SetPattern(maPos.Col(), maPos.Row(), rVal.mnTab, aPattern, true);
         }
-        pDocShell->PostPaintCell(maPos.Col(), maPos.Row(), pTabs[i]);
+        pDocShell->PostPaintCell(maPos.Col(), maPos.Row(), rVal.mnTab);
     }
 
     ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
-    if ( pChangeTrack && nEndChangeAction >= sal::static_int_cast<sal_uLong>(nCount) )
-        pChangeTrack->Undo( nEndChangeAction - nCount + 1, nEndChangeAction );
+    size_t nCount = maOldValues.size();
+    if ( pChangeTrack && mnEndChangeAction >= sal::static_int_cast<sal_uLong>(nCount) )
+        pChangeTrack->Undo( mnEndChangeAction - nCount + 1, mnEndChangeAction );
 
     DoChange();
     EndUndo();
@@ -278,9 +276,9 @@ void ScUndoEnterData::Undo()
     if ( pModelObj && pModelObj->HasChangesListeners() )
     {
         ScRangeList aChangeRanges;
-        for ( sal_uInt16 i = 0; i < nCount; ++i )
+        for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
         {
-            aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), pTabs[i]));
+            aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), maOldValues[i].mnTab));
         }
         pModelObj->NotifyChanges( ::rtl::OUString( "cell-change" ), aChangeRanges );
     }
@@ -291,15 +289,20 @@ void ScUndoEnterData::Redo()
     BeginRedo();
 
     ScDocument* pDoc = pDocShell->GetDocument();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
     {
-        if (pNewEditData)
-            // A clone of pNewEditData will be stored in ScEditCell.
-            pDoc->PutCell(maPos.Col(), maPos.Row(), pTabs[i], new ScEditCell(*pNewEditData,
-                pDoc, NULL));
+        SCTAB nTab = maOldValues[i].mnTab;
+        if (mpNewEditData)
+        {
+            ScAddress aPos = maPos;
+            aPos.SetTab(nTab);
+            // edit text wil be cloned.
+            pDoc->SetEditText(aPos, *mpNewEditData, NULL);
+        }
         else
-            pDoc->SetString(maPos.Col(), maPos.Row(), pTabs[i], aNewString);
-        pDocShell->PostPaintCell(maPos.Col(), maPos.Row(), pTabs[i]);
+            pDoc->SetString(maPos.Col(), maPos.Row(), nTab, maNewString);
+
+        pDocShell->PostPaintCell(maPos.Col(), maPos.Row(), nTab);
     }
 
     SetChangeTrack();
@@ -312,9 +315,9 @@ void ScUndoEnterData::Redo()
     if ( pModelObj && pModelObj->HasChangesListeners() )
     {
         ScRangeList aChangeRanges;
-        for ( sal_uInt16 i = 0; i < nCount; ++i )
+        for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
         {
-            aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), pTabs[i]));
+            aChangeRanges.Append(ScRange(maPos.Col(), maPos.Row(), maOldValues[i].mnTab));
         }
         pModelObj->NotifyChanges( ::rtl::OUString( "cell-change" ), aChangeRanges );
     }
@@ -324,7 +327,7 @@ void ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget)
 {
     if (rTarget.ISA(ScTabViewTarget))
     {
-        String aTemp = aNewString;
+        OUString aTemp = maNewString;
         ((ScTabViewTarget&)rTarget).GetViewShell()->EnterDataAtCursor( aTemp );
     }
 }
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 398fdf7..6d376fb 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -668,29 +668,22 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
         //      undo
         //
 
-        SCTAB nSelCount = rMark.GetSelectCount();
-        ScBaseCell** ppOldCells = NULL;
-        SCTAB* pTabs            = NULL;
-        SCTAB nPos = 0;
         EditTextObject* pUndoData = NULL;
+        ScUndoEnterData::ValuesType aOldValues;
+
         if (bRecord && !bSimple)
         {
-            ppOldCells  = new ScBaseCell*[nSelCount];
-            pTabs       = new SCTAB[nSelCount];
-            nPos = 0;
-
             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
             for (; itr != itrEnd; ++itr)
             {
-                pTabs[nPos] = *itr;
+                ScUndoEnterData::Value aOldValue;
+                aOldValue.mnTab = *itr;
                 ScBaseCell* pDocCell;
                 pDoc->GetCell( nCol, nRow, *itr, pDocCell );
-                ppOldCells[nPos] = pDocCell ? pDocCell->Clone( *pDoc ) : 0;
-                ++nPos;
+                aOldValue.mpCell = pDocCell ? pDocCell->Clone( *pDoc ) : 0;
+                aOldValues.push_back(aOldValue);
             }
 
-            OSL_ENSURE( nPos==nSelCount, "nPos!=nSelCount" );
-
             pUndoData = rData.Clone();
         }
 
@@ -717,9 +710,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
             if ( bRecord )
             {   //  because of ChangeTrack current first
                 pDocSh->GetUndoManager()->AddUndoAction(
-                    new ScUndoEnterData( pDocSh, ScAddress(nCol, nRow, nTab), nPos, pTabs,
-                                        ppOldCells, NULL, NULL, aString,
-                                        pUndoData ) );
+                    new ScUndoEnterData(pDocSh, ScAddress(nCol,nRow,nTab), aOldValues, aString, pUndoData));
             }
 
             HideAllCursors();
commit 47d72729ef2a66727c3755256c47fc46726bf823
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 21 15:53:15 2013 -0400

    Reduce the number of parameters.
    
    Change-Id: I0424ca0da103cdcf3f76b6b7afe25cc0ad230bc2

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index fc7e84e..5bc31f5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -792,7 +792,7 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos,
     if (bUndo)
     {
         //  wegen ChangeTracking darf UndoAction erst nach SetString angelegt werden
-        rDocShell.GetUndoManager()->AddUndoAction(new ScUndoEnterData( &rDocShell, rPos.Col(),rPos.Row(),rPos.Tab(), 1,pTabs,
+        rDocShell.GetUndoManager()->AddUndoAction(new ScUndoEnterData( &rDocShell, rPos, 1, pTabs,
                                      ppOldCells, pHasFormat, pOldFormats, rText, NULL ) );
     }
 
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index 39c7595..a41c558 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -75,8 +75,7 @@ class ScUndoEnterData: public ScSimpleUndo
 {
 public:
                     TYPEINFO();
-                    ScUndoEnterData( ScDocShell* pNewDocShell,
-                            SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+                    ScUndoEnterData( ScDocShell* pNewDocShell, const ScAddress& rPos,
                             SCTAB nNewCount, SCTAB* pNewTabs,
                             ScBaseCell** ppOldData, sal_Bool* pHasForm, sal_uLong* pOldForm,
                             const String& rNewStr, EditTextObject* pObj = NULL );
@@ -97,9 +96,7 @@ private:
     sal_uLong*          pOldFormats;
     EditTextObject* pNewEditData;
     sal_uLong           nEndChangeAction;
-    SCCOL           nCol;
-    SCROW           nRow;
-    SCTAB           nTab;
+    ScAddress maPos;
     SCTAB           nCount;             //  Marked sheet
 
     void            DoChange() const;
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 023245a..b0f15f1 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -164,8 +164,7 @@ sal_Bool ScUndoCursorAttr::CanRepeat(SfxRepeatTarget& rTarget) const
     return (rTarget.ISA(ScTabViewTarget));
 }
 
-ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell,
-            SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell, const ScAddress& rPos,
             SCTAB nNewCount, SCTAB* pNewTabs, ScBaseCell** ppOldData,
             sal_Bool* pHasForm, sal_uLong* pOldForm,
             const String& rNewStr, EditTextObject* pObj ) :
@@ -176,9 +175,7 @@ ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell,
     pHasFormat( pHasForm ),
     pOldFormats( pOldForm ),
     pNewEditData( pObj ),
-    nCol( nNewCol ),
-    nRow( nNewRow ),
-    nTab( nNewTab ),
+    maPos(rPos),
     nCount( nNewCount )
 {
     SetChangeTrack();
@@ -207,13 +204,13 @@ void ScUndoEnterData::DoChange() const
 {
     // only when needed (old or new Edit cell, or Attribute)?
     for (sal_uInt16 i=0; i<nCount; i++)
-        pDocShell->AdjustRowHeight( nRow, nRow, pTabs[i] );
+        pDocShell->AdjustRowHeight(maPos.Row(), maPos.Row(), pTabs[i]);
 
     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
     {
-        pViewShell->SetTabNo( nTab );
-        pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, false, false );
+        pViewShell->SetTabNo(maPos.Tab());
+        pViewShell->MoveCursorAbs(maPos.Col(), maPos.Row(), SC_FOLLOW_JUMP, false, false);
     }
 
     pDocShell->PostDataChanged();
@@ -225,7 +222,7 @@ void ScUndoEnterData::SetChangeTrack()
     if ( pChangeTrack )
     {
         nEndChangeAction = pChangeTrack->GetActionMax() + 1;
-        ScAddress aPos( nCol, nRow, nTab );
+        ScAddress aPos(maPos);
         for (sal_uInt16 i=0; i<nCount; i++)
         {
             aPos.SetTab( pTabs[i] );
@@ -252,21 +249,21 @@ void ScUndoEnterData::Undo()
     for (sal_uInt16 i=0; i<nCount; i++)
     {
         ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
-        pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell );
+        pDoc->PutCell(maPos.Col(), maPos.Row(), pTabs[i], pNewCell);
 
         if (pHasFormat && pOldFormats)
         {
             if ( pHasFormat[i] )
-                pDoc->ApplyAttr( nCol, nRow, pTabs[i],
-                                    SfxUInt32Item( ATTR_VALUE_FORMAT, pOldFormats[i] ) );
+                pDoc->ApplyAttr(maPos.Col(), maPos.Row(), pTabs[i],
+                                SfxUInt32Item(ATTR_VALUE_FORMAT, pOldFormats[i]));
             else
             {
-                ScPatternAttr aPattern( *pDoc->GetPattern( nCol, nRow, pTabs[i] ) );
+                ScPatternAttr aPattern( *pDoc->GetPattern(maPos.Col(), maPos.Row(), pTabs[i]));
                 aPattern.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
-                pDoc->SetPattern( nCol, nRow, pTabs[i], aPattern, sal_True );
+                pDoc->SetPattern(maPos.Col(), maPos.Row(), pTabs[i], aPattern, true);
             }
         }
-        pDocShell->PostPaintCell( nCol, nRow, pTabs[i] );
+        pDocShell->PostPaintCell(maPos.Col(), maPos.Row(), pTabs[i]);
     }
 
     ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
@@ -283,7 +280,7 @@ void ScUndoEnterData::Undo()
         ScRangeList aChangeRanges;
         for ( sal_uInt16 i = 0; i < nCount; ++i )
         {
-            aChangeRanges.Append( ScRange( nCol, nRow, pTabs[i] ) );
+            aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), pTabs[i]));
         }
         pModelObj->NotifyChanges( ::rtl::OUString( "cell-change" ), aChangeRanges );
     }
@@ -298,11 +295,11 @@ void ScUndoEnterData::Redo()
     {
         if (pNewEditData)
             // A clone of pNewEditData will be stored in ScEditCell.
-            pDoc->PutCell( nCol, nRow, pTabs[i], new ScEditCell(*pNewEditData,
-                pDoc, NULL ) );
+            pDoc->PutCell(maPos.Col(), maPos.Row(), pTabs[i], new ScEditCell(*pNewEditData,
+                pDoc, NULL));
         else
-            pDoc->SetString( nCol, nRow, pTabs[i], aNewString );
-        pDocShell->PostPaintCell( nCol, nRow, pTabs[i] );
+            pDoc->SetString(maPos.Col(), maPos.Row(), pTabs[i], aNewString);
+        pDocShell->PostPaintCell(maPos.Col(), maPos.Row(), pTabs[i]);
     }
 
     SetChangeTrack();
@@ -317,7 +314,7 @@ void ScUndoEnterData::Redo()
         ScRangeList aChangeRanges;
         for ( sal_uInt16 i = 0; i < nCount; ++i )
         {
-            aChangeRanges.Append( ScRange( nCol, nRow, pTabs[i] ) );
+            aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), pTabs[i]));
         }
         pModelObj->NotifyChanges( ::rtl::OUString( "cell-change" ), aChangeRanges );
     }
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index be08448..398fdf7 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -717,7 +717,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
             if ( bRecord )
             {   //  because of ChangeTrack current first
                 pDocSh->GetUndoManager()->AddUndoAction(
-                    new ScUndoEnterData( pDocSh, nCol, nRow, nTab, nPos, pTabs,
+                    new ScUndoEnterData( pDocSh, ScAddress(nCol, nRow, nTab), nPos, pTabs,
                                         ppOldCells, NULL, NULL, aString,
                                         pUndoData ) );
             }
commit 4cfaae0e336276d4c354f2bc71d1e5c563d65916
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 21 15:33:02 2013 -0400

    bInterpret is always set false. Remove it.
    
    Change-Id: I067f8eb4b81231e3ea7f084a6608c29e0dfeaf2b

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index f5cde9b..3e45a8c 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -181,11 +181,10 @@ bool ScDocFuncSend::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell,
     return true; // needs some code auditing action
 }
 
-sal_Bool ScDocFuncSend::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
-                          sal_Bool bInterpret, sal_Bool bApi )
+bool ScDocFuncSend::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi )
 {
     SAL_INFO( "sc.tubes", "PutData not implemented!" );
-    return ScDocFunc::PutData( rPos, rEngine, bInterpret, bApi );
+    return ScDocFunc::PutData( rPos, rEngine, bApi );
 }
 
 bool ScDocFuncSend::SetCellText(
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index e1866ff..5e4d147 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -277,8 +277,7 @@ public:
     virtual bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
     virtual bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction );
     virtual bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction );
-    virtual sal_Bool    PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
-                                sal_Bool bInterpret, sal_Bool bApi );
+    virtual bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi );
     virtual bool SetCellText(
         const ScAddress& rPos, const OUString& rText, bool bInterpret, bool bEnglish,
         bool bApi, const formula::FormulaGrammar::Grammar eGrammar );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index c2f3df6..fc7e84e 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1005,7 +1005,7 @@ void ScDocFunc::NotifyInputHandler( const ScAddress& rPos )
 
         typedef ::std::list<ScMyRememberItem*> ScMyRememberItemList;
 
-sal_Bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, sal_Bool bInterpret, sal_Bool bApi )
+bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi )
 {
     //  PutData ruft PutCell oder SetNormalString
 
@@ -1053,7 +1053,6 @@ sal_Bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngi
         // Set the paragraph attributes back to the EditEngine.
         if (!aRememberItems.empty())
         {
-//            ScMyRememberItem* pRememberItem = NULL;
             ScMyRememberItemList::iterator aItr = aRememberItems.begin();
             while (aItr != aRememberItems.end())
             {
@@ -1070,8 +1069,8 @@ sal_Bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngi
     }
     else
     {
-        String aText = rEngine.GetText();
-        if ( bInterpret || !aText.Len() )
+        OUString aText = rEngine.GetText();
+        if (aText.isEmpty())
         {
             bool bNumFmtSet = false;
             bRet = SetNormalString( bNumFmtSet, rPos, aText, bApi );
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index da96bb9..6b6d1d4 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -100,8 +100,7 @@ public:
      * must not delete it after passing it to this call.
      */
     virtual bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction );
-    virtual sal_Bool        PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
-                                      sal_Bool bInterpret, sal_Bool bApi );
+    virtual bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi );
     virtual bool SetCellText(
         const ScAddress& rPos, const OUString& rText, bool bInterpret, bool bEnglish, bool bApi,
         const formula::FormulaGrammar::Grammar eGrammar );
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 62f5234..fbd48a5 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -1031,7 +1031,7 @@ void ScCellTextData::UpdateData()
             //  or things like attributes after the text would be lost
             //  (are not stored in the cell)
             bInUpdate = sal_True;   // prevents bDataValid from being reset
-            pDocShell->GetDocFunc().PutData( aCellPos, *pEditEngine, false, sal_True ); // always as text
+            pDocShell->GetDocFunc().PutData(aCellPos, *pEditEngine, true); // always as text
 
             bInUpdate = false;
             bDirty = false;


More information about the Libreoffice-commits mailing list