sc/source/ui/collab/sendfunc.cxx | 17 +++++++++++++++++ sc/source/ui/collab/sendfunc.hxx | 25 ++++++++++++++++++++++++- sc/source/ui/docshell/docfunc.cxx | 29 +++++++++++++++++++++++++++++ sc/source/ui/inc/docfunc.hxx | 7 +++++++ sc/source/ui/unoobj/cellsuno.cxx | 6 +++--- sc/source/ui/view/viewfunc.cxx | 2 +- 6 files changed, 81 insertions(+), 5 deletions(-)
New commits: commit 41e7185b92a0978f592945327e423083ff652974 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Mar 20 17:30:43 2013 -0400 ScDocFunc::SetFormulaCell() to replace use of PutCell() for formula cells. Due to the complexity of the formula cell class, we'll keep this cell class until further notice. Change-Id: I0e11d0aa6ca2ee959a1963c606ad0684aeec27ed diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index 60b1f0f..ca79471 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -68,6 +68,11 @@ void ScDocFuncSend::RecvMessage( const rtl::OString &rString ) mpDirect->SetEditCell( aReader.getAddress(1), aReader.getEdit(2), aReader.getBool(3)); } + else if (aReader.getMethod() == "setFormulaCell") + { + mpDirect->SetFormulaCell( + aReader.getAddress(1), aReader.getFormulaCell(2), aReader.getBool(3)); + } else if ( aReader.getMethod() == "enterListAction" ) mpDirect->EnterListAction( aReader.getInt( 1 ) ); else if ( aReader.getMethod() == "endListAction" ) @@ -171,6 +176,17 @@ bool ScDocFuncSend::SetEditCell( const ScAddress& rPos, const EditTextObject& rS return true; // needs some code auditing action } +bool ScDocFuncSend::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction ) +{ + ScChangeOpWriter aOp("setFormulaCell"); + aOp.appendAddress( rPos ); + aOp.appendFormulaCell( pCell ); + aOp.appendBool( bInteraction ); + SendMessage( aOp ); + pCell->Delete(); + return true; // needs some code auditing action +} + sal_Bool ScDocFuncSend::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi ) { ScChangeOpWriter aOp( "putCell" ); @@ -178,6 +194,7 @@ sal_Bool ScDocFuncSend::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sa aOp.appendCell( pNewCell ); aOp.appendBool( bApi ); SendMessage( aOp ); + pCell->Delete(); return true; // needs some code auditing action } diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx index 6b17a2e..5499fd0 100644 --- a/sc/source/ui/collab/sendfunc.hxx +++ b/sc/source/ui/collab/sendfunc.hxx @@ -24,6 +24,12 @@ rtl::OUString cellToString( ScBaseCell *pCell ) return rtl::OUString(); } +OUString formulaCellToString( ScFormulaCell *pCell ) +{ + (void)pCell; // FIXME: implement me + return OUString(); +} + OUString editToString( const EditTextObject& /*rEditText*/ ) { // FIXME: implement me. @@ -36,7 +42,13 @@ EditTextObject stringToEdit( const OUString& rStr ) return EditTextObject(); } -ScBaseCell *stringToCell( const rtl::OUString &rString ) +ScBaseCell* stringToCell( const rtl::OUString &rString ) +{ + (void)rString; // FIXME: implement me + return NULL; +} + +ScFormulaCell* stringToFormulaCell( const OUString &rString ) { (void)rString; // FIXME: implement me return NULL; @@ -98,6 +110,11 @@ public: appendString( cellToString( pCell ) ); } + void appendFormulaCell( ScFormulaCell *pCell ) + { + appendString( formulaCellToString( pCell ) ); + } + void appendEditText( const EditTextObject& rStr ) { appendString( editToString(rStr) ); @@ -219,6 +236,11 @@ public: return stringToCell( getString( n ) ); } + ScFormulaCell* getFormulaCell( sal_Int32 n ) + { + return stringToFormulaCell( getString( n ) ); + } + double getDouble( sal_Int32 n ) { return getString(n).toDouble(); @@ -254,6 +276,7 @@ public: virtual bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction ); 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 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 08c96e3..efec66a 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -931,6 +931,35 @@ bool ScDocFunc::SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, return true; } +bool ScDocFunc::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction ) +{ + SAL_WNODEPRECATED_DECLARATIONS_PUSH + std::auto_ptr<ScFormulaCell> xCell(pCell); + SAL_WNODEPRECATED_DECLARATIONS_POP + + ScDocShellModificator aModificator( rDocShell ); + ScDocument* pDoc = rDocShell.GetDocument(); + bool bUndo = pDoc->IsUndoEnabled(); + + bool bHeight = pDoc->HasAttrib(rPos, HASATTR_NEEDHEIGHT); + + if (bUndo) + pushUndoSetCell(rDocShell, pDoc, rPos, *xCell); + + pDoc->SetFormulaCell(rPos, xCell.release()); + + if (bHeight) + AdjustRowHeight(rPos); + + aModificator.SetDocumentModified(); + + // #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 ) { ScDocShellModificator aModificator( rDocShell ); diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index 962697a..dfb4ab0 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -39,6 +39,7 @@ class ScPatternAttr; class ScRange; class ScRangeList; class ScBaseCell; +class ScFormulaCell; class ScTokenArray; struct ScTabOpParam; class ScTableProtection; @@ -91,6 +92,12 @@ public: virtual bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction ); virtual bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction ); virtual bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction ); + + /** + * This method takes ownership of the formula cell instance. The caller + * must not delete it after passing it to this call. + */ + virtual bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, 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/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index abfdbfe..198bbb7 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6576,7 +6576,7 @@ void SAL_CALL ScCellObj::setFormulaString( const rtl::OUString& aFormula) throw( { ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos ); pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE ); - pDocSh->GetDocFunc().PutCell( aCellPos, pCell, sal_True ); + pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false); } } void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException) @@ -6690,8 +6690,8 @@ void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rT ScTokenArray aTokenArray; (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens ); - ScBaseCell* pNewCell = new ScFormulaCell( pDoc, aCellPos, &aTokenArray ); - (void)pDocSh->GetDocFunc().PutCell( aCellPos, pNewCell, sal_True ); + ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aCellPos, &aTokenArray ); + (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false); } } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index b253ff8..be08448 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -520,7 +520,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, if(pCell->GetCode()->IsHyperLink()) pCell->GetCode()->SetHyperLink(false); } - rFunc.PutCell( aPos, pCell, sal_False ); + rFunc.SetFormulaCell(aPos, pCell, true); } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits