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

Kohei Yoshida kohei.yoshida at gmail.com
Wed Mar 20 10:49:19 PDT 2013


 sc/inc/cell.hxx                                   |    4 
 sc/source/core/data/cell.cxx                      |    5 +
 sc/source/ui/Accessibility/AccessibleCellBase.cxx |    2 
 sc/source/ui/collab/sendfunc.cxx                  |   15 +++
 sc/source/ui/collab/sendfunc.hxx                  |   12 ++
 sc/source/ui/docshell/docfunc.cxx                 |   63 +++++++++++++
 sc/source/ui/inc/docfunc.hxx                      |    1 
 sc/source/ui/inc/undocell.hxx                     |   44 ++++++++-
 sc/source/ui/miscdlgs/optsolver.cxx               |    4 
 sc/source/ui/undo/undocell.cxx                    |  105 ++++++++++++++++++++++
 sc/source/ui/unoobj/cellsuno.cxx                  |    2 
 sc/source/ui/view/viewfun6.cxx                    |    2 
 12 files changed, 252 insertions(+), 7 deletions(-)

New commits:
commit beba5332cf6e6ed5699e72863125c9f5b5313dc0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 20 13:50:57 2013 -0400

    Convert some of ScDocFunc::PutCell() to SetValueCell().
    
    Also implement the telepathy serialization part.
    
    Change-Id: Ie67b26d5f7778d0c1f09a9ef748e0fe846ac3dc5

diff --git a/sc/source/ui/Accessibility/AccessibleCellBase.cxx b/sc/source/ui/Accessibility/AccessibleCellBase.cxx
index a109f4f..d6491d4 100644
--- a/sc/source/ui/Accessibility/AccessibleCellBase.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCellBase.cxx
@@ -259,7 +259,7 @@ sal_Bool SAL_CALL
         if (IsEditable(xParentStates))
         {
             ScDocShell* pDocShell = (ScDocShell*) mpDoc->GetDocumentShell();
-            bResult = pDocShell->GetDocFunc().PutCell( maCellAddress, new ScValueCell(fValue), true);
+            bResult = pDocShell->GetDocFunc().SetValueCell(maCellAddress, fValue, false);
         }
     }
     return bResult;
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index f074c3d..4b96934 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -53,6 +53,11 @@ void ScDocFuncSend::RecvMessage( const rtl::OString &rString )
             if ( pNewCell )
                 mpDirect->PutCell( aReader.getAddress( 1 ), pNewCell, aReader.getBool( 3 ) );
         }
+        else if (aReader.getMethod() == "setValueCell")
+        {
+            mpDirect->SetValueCell(
+                aReader.getAddress(1), aReader.getDouble(2), aReader.getBool(3));
+        }
         else if ( aReader.getMethod() == "enterListAction" )
             mpDirect->EnterListAction( aReader.getInt( 1 ) );
         else if ( aReader.getMethod() == "endListAction" )
@@ -126,10 +131,13 @@ sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& r
     return true; // needs some code auditing action
 }
 
-void ScDocFuncSend::SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction )
+bool ScDocFuncSend::SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction )
 {
-    // TODO: How do we implement this?
-
+    ScChangeOpWriter aOp("setValueCell");
+    aOp.appendAddress( rPos );
+    aOp.appendDouble( fVal );
+    aOp.appendBool( bInteraction );
+    SendMessage( aOp );
     return true; // needs some code auditing action
 }
 
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 2a4ee4e..4684148 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -86,6 +86,12 @@ public:
         appendString( cellToString( pCell ) );
     }
 
+    void appendDouble( double fVal )
+    {
+        aMessage.append(fVal);
+        appendSeparator();
+    }
+
     rtl::OString toString()
     {
         return rtl::OUStringToOString( aMessage.toString(), RTL_TEXTENCODING_UTF8 );
@@ -195,6 +201,11 @@ public:
     {
         return stringToCell( getString( n ) );
     }
+
+    double getDouble( sal_Int32 n )
+    {
+        return getString(n).toDouble();
+    }
 };
 
 } // anonymous namespace
@@ -217,7 +228,7 @@ public:
     virtual void        EndListAction();
 
     virtual sal_Bool    SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi );
-    virtual void SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
+    virtual bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
     virtual sal_Bool    PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi );
     virtual sal_Bool    PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
                                 sal_Bool bInterpret, sal_Bool bApi );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index e37abb0..5cc714a 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -808,7 +808,7 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos,
     return sal_True;
 }
 
-void ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction )
+bool ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction )
 {
     ScDocShellModificator aModificator( rDocShell );
     ScDocument* pDoc = rDocShell.GetDocument();
@@ -867,6 +867,8 @@ void ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteract
     // #103934#; notify editline and cell in edit mode
     if (!bInteraction)
         NotifyInputHandler( rPos );
+
+    return true;
 }
 
 sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi )
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 67611ac..2b31f46 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -88,7 +88,7 @@ public:
                                                sal_Bool bRecord, sal_Bool bApi );
 
     virtual sal_Bool        SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi );
-    virtual void SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
+    virtual bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
     virtual sal_Bool        PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi );
     virtual sal_Bool        PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
                                       sal_Bool bInterpret, sal_Bool bApi );
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
index 0e87111..c9f7a79 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -1017,7 +1017,7 @@ bool ScOptSolverDlg::CallSolver()       // return true -> close dialog after cal
             {
                 ScAddress aCellPos;
                 ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
-                rFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), sal_True );
+                rFunc.SetValueCell(aCellPos, aSolution[nVarPos], false);
             }
             mpDocShell->UnlockPaint();
         }
@@ -1054,7 +1054,7 @@ bool ScOptSolverDlg::CallSolver()       // return true -> close dialog after cal
         {
             ScAddress aCellPos;
             ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
-            rFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), sal_True );
+            rFunc.SetValueCell(aCellPos, aOldValues[nVarPos], false);
         }
         mpDocShell->UnlockPaint();
     }
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index ab082b5..abfdbfe 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6313,7 +6313,7 @@ void ScCellObj::SetValue_Impl(double fValue)
 {
     ScDocShell* pDocSh = GetDocShell();
     if ( pDocSh )
-        (void)pDocSh->GetDocFunc().PutCell( aCellPos, new ScValueCell(fValue), sal_True );
+        pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
 }
 
 // only for XML import
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index eeb93a9..7a4a4ab 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -259,7 +259,7 @@ void ScViewFunc::InsertCurrentTime(short nCellFmt, const OUString& rUndoStr)
         (aActTime.GetMin() * 60.0) + (aActTime.GetHour() * 3600.0);
     fTime /= D_TIMEFACTOR;
     pUndoMgr->EnterListAction(rUndoStr, rUndoStr);
-    pDocSh->GetDocFunc().PutCell(aCurPos, new ScValueCell(fDate+fTime), false);
+    pDocSh->GetDocFunc().SetValueCell(aCurPos, fDate+fTime, true);
 
     // Set the new cell format only when it differs from the current cell
     // format type.
commit 5c9610b229d65f5d6441dc7cbec5f7b9ec9a22f5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 20 13:36:21 2013 -0400

    Implement the undo of arbitrary cells. Not used yet.
    
    Change-Id: I99635829768ec7604f3387c4b0a22cb112fb9aca

diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index 979b238..799ef4d 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -193,6 +193,9 @@ public:
     virtual OUString GetComment() const;
 
 private:
+    void SetValue( const Value& rVal );
+
+private:
     ScAddress maPos;
     Value maOldValue;
     Value maNewValue;
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 756df86..13319d8 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -41,6 +41,7 @@
 #include "chgtrack.hxx"
 #include "sc.hrc"
 #include "docuno.hxx"
+#include "stringutil.hxx"
 
 using ::boost::shared_ptr;
 
@@ -546,10 +547,12 @@ ScUndoSetCell::~ScUndoSetCell() {}
 
 void ScUndoSetCell::Undo()
 {
+    SetValue(maOldValue);
 }
 
 void ScUndoSetCell::Redo()
 {
+    SetValue(maNewValue);
 }
 
 void ScUndoSetCell::Repeat( SfxRepeatTarget& /*rTarget*/ )
@@ -567,6 +570,37 @@ OUString ScUndoSetCell::GetComment() const
     return ScGlobal::GetRscString(STR_UNDO_ENTERDATA); // "Input"
 }
 
+void ScUndoSetCell::SetValue( const Value& rVal )
+{
+    ScDocument* pDoc = pDocShell->GetDocument();
+
+    switch (rVal.meType)
+    {
+        case CELLTYPE_NONE:
+            // empty cell
+            pDoc->SetEmptyCell(maPos);
+        break;
+        case CELLTYPE_VALUE:
+            pDoc->SetValue(maPos, rVal.mfValue);
+        break;
+        case CELLTYPE_STRING:
+        {
+            ScSetStringParam aParam;
+            aParam.setTextInput();
+            pDoc->SetString(maPos, *rVal.mpString);
+        }
+        break;
+        case CELLTYPE_EDIT:
+            pDoc->SetEditText(maPos, rVal.mpEditText->Clone());
+        break;
+        case CELLTYPE_FORMULA:
+            pDoc->SetFormula(maPos, *rVal.mpFormulaCell->GetCode());
+        break;
+        default:
+            ;
+    }
+}
+
 ScUndoPageBreak::ScUndoPageBreak( ScDocShell* pNewDocShell,
             SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
             sal_Bool bNewColumn, sal_Bool bNewInsert ) :
commit 5f0ed89f0e37d7ea47c030206ffd9bc041b41f20
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 20 12:30:55 2013 -0400

    First cut on implementing SetValueCell in ScDocFunc. Not tested yet.
    
    Also, I have yet to implement the undo and redo for this.
    
    ScDocFunc::PutCell needs to be eventually eliminated, in order to avoid
    direct use of cell classes outside the document.
    
    Change-Id: Iae7abc048fc67214037fa0a080fdadbadfa074fd

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index fa5cf23..71aee73 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -411,6 +411,10 @@ public:
 
                     ~ScFormulaCell();
 
+    using ScBaseCell::Clone;
+
+    ScFormulaCell* Clone() const;
+
     /** Empty formula cell, or with a preconstructed token array. */
     ScFormulaCell( ScDocument*, const ScAddress&, const ScTokenArray* = NULL,
                     const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 8305127..a8aab98 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -884,6 +884,11 @@ ScFormulaCell::~ScFormulaCell()
 #endif
 }
 
+ScFormulaCell* ScFormulaCell::Clone() const
+{
+    return new ScFormulaCell(*this, *pDocument, aPos);
+}
+
 size_t ScFormulaCell::GetHash() const
 {
     return pCode->GetHash();
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 3c761fb..f074c3d 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -126,6 +126,13 @@ sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& r
     return true; // needs some code auditing action
 }
 
+void ScDocFuncSend::SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction )
+{
+    // TODO: How do we implement this?
+
+    return true; // needs some code auditing action
+}
+
 sal_Bool ScDocFuncSend::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi )
 {
     ScChangeOpWriter aOp( "putCell" );
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index ba747eb..2a4ee4e 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -217,6 +217,7 @@ public:
     virtual void        EndListAction();
 
     virtual sal_Bool    SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi );
+    virtual void SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
     virtual sal_Bool    PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi );
     virtual sal_Bool    PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
                                 sal_Bool bInterpret, sal_Bool bApi );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 97cb218..e37abb0 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -808,6 +808,67 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos,
     return sal_True;
 }
 
+void ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction )
+{
+    ScDocShellModificator aModificator( rDocShell );
+    ScDocument* pDoc = rDocShell.GetDocument();
+    bool bUndo = pDoc->IsUndoEnabled();
+
+    bool bHeight = pDoc->HasAttrib(ScRange(rPos), HASATTR_NEEDHEIGHT);
+
+    if (bUndo)
+    {
+        svl::IUndoManager* pUndoMgr = rDocShell.GetUndoManager();
+        switch (pDoc->GetCellType(rPos))
+        {
+            case CELLTYPE_NONE:
+            case CELLTYPE_NOTE:
+                // Empty cell.
+                pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, fVal));
+            break;
+            case CELLTYPE_VALUE:
+            {
+                double fOldVal = pDoc->GetValue(rPos);
+                pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, fOldVal, fVal));
+            }
+            break;
+            case CELLTYPE_STRING:
+            {
+                OUString aOldStr = pDoc->GetString(rPos);
+                pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, aOldStr, fVal));
+            }
+            break;
+            case CELLTYPE_EDIT:
+            {
+                const EditTextObject* pOldText = pDoc->GetEditText(rPos);
+                if (pOldText)
+                    pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, *pOldText, fVal));
+            }
+            break;
+            case CELLTYPE_FORMULA:
+            {
+                const ScFormulaCell* pFCell = static_cast<const ScFormulaCell*>(pDoc->GetCell(rPos));
+                if (pFCell)
+                    pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, *pFCell, fVal));
+            }
+            break;
+            default:
+                ;
+        }
+    }
+
+    pDoc->SetValue(rPos, fVal);
+
+    if (bHeight)
+        AdjustRowHeight( ScRange(rPos) );
+
+    aModificator.SetDocumentModified();
+
+    // #103934#; notify editline and cell in edit mode
+    if (!bInteraction)
+        NotifyInputHandler( rPos );
+}
+
 sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi )
 {
     ScDocShellModificator aModificator( rDocShell );
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 041599e..67611ac 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -88,6 +88,7 @@ public:
                                                sal_Bool bRecord, sal_Bool bApi );
 
     virtual sal_Bool        SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi );
+    virtual void SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
     virtual sal_Bool        PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi );
     virtual sal_Bool        PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
                                       sal_Bool bInterpret, sal_Bool bApi );
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index d38c04a..979b238 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -34,8 +34,6 @@ class ScDetOpList;
 class ScDetOpData;
 class ScRangeName;
 
-//----------------------------------------------------------------------------
-
 class ScUndoCursorAttr: public ScSimpleUndo
 {
 public:
@@ -160,6 +158,45 @@ private:
     void            SetChangeTrack();
 };
 
+class ScUndoSetCell : public ScSimpleUndo
+{
+public:
+    struct Value
+    {
+        CellType meType;
+        union {
+            double mfValue;
+            OUString* mpString;
+            EditTextObject* mpEditText;
+            ScFormulaCell* mpFormulaCell;
+        };
+
+        Value();
+        Value( double fValue );
+        Value( const OUString& rString );
+        Value( const EditTextObject& rEditText );
+        Value( const ScFormulaCell& rFormula );
+        Value( const Value& r );
+        ~Value();
+    };
+
+    TYPEINFO();
+    ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const Value& rNewVal );
+    ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const Value& rOldVal, const Value& rNewVal );
+
+    virtual ~ScUndoSetCell();
+
+    virtual void Undo();
+    virtual void Redo();
+    virtual void Repeat( SfxRepeatTarget& rTarget );
+    virtual sal_Bool CanRepeat( SfxRepeatTarget& rTarget ) const;
+    virtual OUString GetComment() const;
+
+private:
+    ScAddress maPos;
+    Value maOldValue;
+    Value maNewValue;
+};
 
 class ScUndoPageBreak: public ScSimpleUndo
 {
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index fd09d19..756df86 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -48,6 +48,7 @@ TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo);
 TYPEINIT1(ScUndoEnterData, ScSimpleUndo);
 TYPEINIT1(ScUndoEnterValue, ScSimpleUndo);
 TYPEINIT1(ScUndoPutCell, ScSimpleUndo);
+TYPEINIT1(ScUndoSetCell, ScSimpleUndo);
 TYPEINIT1(ScUndoPageBreak, ScSimpleUndo);
 TYPEINIT1(ScUndoPrintZoom, ScSimpleUndo);
 TYPEINIT1(ScUndoThesaurus, ScSimpleUndo);
@@ -496,6 +497,76 @@ sal_Bool ScUndoPutCell::CanRepeat(SfxRepeatTarget& /* rTarget */) const
     return false;
 }
 
+ScUndoSetCell::Value::Value() : meType(CELLTYPE_NONE), mfValue(0.0) {}
+ScUndoSetCell::Value::Value( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
+ScUndoSetCell::Value::Value( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {}
+ScUndoSetCell::Value::Value( const EditTextObject& rEditText ) : meType(CELLTYPE_EDIT), mpEditText(rEditText.Clone()) {}
+ScUndoSetCell::Value::Value( const ScFormulaCell& rFormula ) : meType(CELLTYPE_FORMULA), mpFormulaCell(rFormula.Clone()) {}
+
+ScUndoSetCell::Value::Value( const Value& r ) : meType(r.meType), mfValue(r.mfValue)
+{
+    switch (r.meType)
+    {
+        case CELLTYPE_STRING:
+            mpString = new OUString(*r.mpString);
+        break;
+        case CELLTYPE_EDIT:
+            mpEditText = r.mpEditText->Clone();
+        break;
+        case CELLTYPE_FORMULA:
+            mpFormulaCell = r.mpFormulaCell->Clone();
+        default:
+            ;
+    }
+}
+
+ScUndoSetCell::Value::~Value()
+{
+    switch (meType)
+    {
+        case CELLTYPE_STRING:
+            delete mpString;
+        break;
+        case CELLTYPE_EDIT:
+            delete mpEditText;
+        case CELLTYPE_FORMULA:
+            mpFormulaCell->Delete();
+        default:
+            ;
+    }
+}
+
+ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const Value& rNewVal ) :
+    ScSimpleUndo(pDocSh), maPos(rPos), maNewValue(rNewVal) {}
+
+ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const Value& rOldVal, const Value& rNewVal ) :
+    ScSimpleUndo(pDocSh), maPos(rPos), maOldValue(rOldVal), maNewValue(rNewVal) {}
+
+ScUndoSetCell::~ScUndoSetCell() {}
+
+void ScUndoSetCell::Undo()
+{
+}
+
+void ScUndoSetCell::Redo()
+{
+}
+
+void ScUndoSetCell::Repeat( SfxRepeatTarget& /*rTarget*/ )
+{
+    // Makes no sense.
+}
+
+sal_Bool ScUndoSetCell::CanRepeat( SfxRepeatTarget& /*rTarget*/ ) const
+{
+    return false;
+}
+
+OUString ScUndoSetCell::GetComment() const
+{
+    return ScGlobal::GetRscString(STR_UNDO_ENTERDATA); // "Input"
+}
+
 ScUndoPageBreak::ScUndoPageBreak( ScDocShell* pNewDocShell,
             SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
             sal_Bool bNewColumn, sal_Bool bNewInsert ) :


More information about the Libreoffice-commits mailing list