sc/source/ui/docshell/docfunc.cxx | 12 ++++- sc/source/ui/docshell/docsh.cxx | 80 +++++++++++++++++++++++++++++++++++++- sc/source/ui/inc/docfunc.hxx | 4 + sc/source/ui/inc/viewfunc.hxx | 6 +- sc/source/ui/view/cellsh3.cxx | 2 sc/source/ui/view/viewfun4.cxx | 8 ++- sc/source/ui/view/viewfunc.cxx | 17 +++----- 7 files changed, 109 insertions(+), 20 deletions(-)
New commits: commit de709a5b0d0a0c774c9997fad98ce607103140a7 Author: Michael Meeks <michael.me...@suse.com> Date: Wed Mar 21 15:58:52 2012 +0000 dummy interception of ScFunc methods with INTERCEPT env var set. diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index ab5dcd9..0485370 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2507,6 +2507,82 @@ sal_Bool ScDocShell::HasAutomaticTableName( const String& rFilter ) || rFilter.EqualsAscii( pFilterRtf ); } +namespace { + +class ScDocFuncIntercept : public ScDocFunc +{ +public: + ScDocFuncIntercept( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) + { + fprintf( stderr, "Interceptor created !\n" ); + } + virtual ~ScDocFuncIntercept() {} + virtual void EnterListAction( sal_uInt16 nNameResId ) + { + // Want to group these operations for the other side ... + String aUndo( ScGlobal::GetRscString( nNameResId ) ); + } + virtual void EndListAction() + { + } + virtual ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, + const String& rFormulaNmsp, + const formula::FormulaGrammar::Grammar eGrammar, + short* pRetFormatType ) + { + fprintf( stderr, "interp. english string '%s'\n", + rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); + return ScDocFunc::InterpretEnglishString( rPos, rText, rFormulaNmsp, + eGrammar, pRetFormatType ); + } + virtual sal_Bool SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi ) + { + fprintf( stderr, "set normal string '%s'\n", + rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); + return ScDocFunc::SetNormalString( rPos, rText, bApi ); + } + + virtual sal_Bool PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi ) + { + fprintf( stderr, "put cell string '%p' %d\n", pNewCell, bApi ); + return ScDocFunc::PutCell( rPos, pNewCell, bApi ); + } + + virtual sal_Bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, + sal_Bool bInterpret, sal_Bool bApi ) + { + fprintf( stderr, "put data\n" ); + return ScDocFunc::PutData( rPos, rEngine, bInterpret, bApi ); + } + + virtual sal_Bool SetCellText( const ScAddress& rPos, const String& rText, + sal_Bool bInterpret, sal_Bool bEnglish, sal_Bool bApi, + const String& rFormulaNmsp, + const formula::FormulaGrammar::Grammar eGrammar ) + { + fprintf( stderr, "set cell text '%s'\n", + rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); + return ScDocFunc::SetCellText( rPos, rText, bInterpret, bEnglish, bApi, rFormulaNmsp, eGrammar ); + } + + virtual bool ShowNote( const ScAddress& rPos, bool bShow = true ) + { + fprintf( stderr, "%s note\n", bShow ? "show" : "hide" ); + return ScDocFunc::ShowNote( rPos, bShow ); + } +}; + +static ScDocFunc * +createDocFunc( ScDocShell *pThis ) +{ + if (getenv ("INTERCEPT")) + return new ScDocFuncIntercept( *pThis ); + else + return new ScDocFuncDirect( *pThis ); +} + +} // anonymous namespace + ScDocShell::ScDocShell( const ScDocShell& rShell ) : SvRefBase(), SotObject(), @@ -2538,7 +2614,7 @@ ScDocShell::ScDocShell( const ScDocShell& rShell ) : bIsInplace = rShell.bIsInplace; - pDocFunc = new ScDocFuncDirect(*this); + pDocFunc = createDocFunc( this ); // SetBaseModel needs exception handling ScModelObj::CreateAndSet( this ); @@ -2585,7 +2661,7 @@ ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags ) : bIsInplace = (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED); // wird zurueckgesetzt, wenn nicht inplace - pDocFunc = new ScDocFuncDirect(*this); + pDocFunc = createDocFunc( this ); // SetBaseModel needs exception handling ScModelObj::CreateAndSet( this ); commit 5d6ca544b4e9030be60f31583551b31c8d4c2f9a Author: Michael Meeks <michael.me...@suse.com> Date: Wed Mar 21 15:57:35 2012 +0000 EnterData - remove un-necessary bRecord parameter for corner-case diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index e6be63c..9e72fac 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -90,10 +90,10 @@ public: String GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr ); void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString, - sal_Bool bRecord = sal_True, const EditTextObject* pData = NULL ); + const EditTextObject* pData = NULL ); + void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, + const EditTextObject* pData, bool bTestSimple = false ); void EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue ); - void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextObject* pData, - sal_Bool bRecord = sal_True, sal_Bool bTestSimple = false ); void EnterMatrix( const String& rString, ::formula::FormulaGrammar::Grammar eGram ); void EnterBlock( const String& rString, const EditTextObject* pData ); diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index f90c7c6..7dca36a 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -246,7 +246,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) } else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) ) { - pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, sal_True, pData ); + pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, pData ); } else { diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 94672a7..3451dca 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -136,15 +136,19 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow, } SCROW nRow = nStartRow; + + // Temporarily turn off undo generation for this lot + bool bUndoEnabled = pDoc->IsUndoEnabled(); + pDoc->EnableUndo( false ); for( sal_uInt16 n = 0; n < nParCnt; n++ ) { EditTextObject* pObject = pEngine->CreateTextObject( n ); - EnterData( nStartCol, nRow, nTab, pObject, false, sal_True ); - // kein Undo, auf einfache Strings testen + EnterData( nStartCol, nRow, nTab, pObject, true ); delete pObject; if( ++nRow > MAXROW ) break; } + pDoc->EnableUndo(bUndoEnabled); if (bRecord) { diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index cf1b9db..28600b5 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -353,15 +353,15 @@ sal_Bool lcl_AddFunction( ScAppOptions& rAppOpt, sal_uInt16 nOpCode ) // input - undo OK -void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString, - sal_Bool bRecord, const EditTextObject* pData ) +void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, + const String& rString, + const EditTextObject* pData ) { ScDocument* pDoc = GetViewData()->GetDocument(); ScMarkData& rMark = GetViewData()->GetMarkData(); SCTAB nSelCount = rMark.GetSelectCount(); + bool bRecord = pDoc->IsUndoEnabled(); SCTAB i; - if (bRecord && !pDoc->IsUndoEnabled()) - bRecord = false; ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocShellModificator aModificator( *pDocSh ); @@ -727,14 +727,13 @@ void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& r } } -void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextObject* pData, - sal_Bool bRecord, sal_Bool bTestSimple ) +void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, + const EditTextObject* pData, bool bTestSimple ) { ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScMarkData& rMark = GetViewData()->GetMarkData(); ScDocument* pDoc = pDocSh->GetDocument(); - if (bRecord && !pDoc->IsUndoEnabled()) - bRecord = false; + bool bRecord = pDoc->IsUndoEnabled(); ScDocShellModificator aModificator( *pDocSh ); @@ -823,7 +822,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb if (bCommon) AdjustRowHeight(nRow,nRow); - EnterData(nCol,nRow,nTab,aString,bRecord); + EnterData(nCol,nRow,nTab,aString); } else { commit e685b124983a5cdb6bb25b0d9dda1b640761cf24 Author: Michael Meeks <michael.me...@suse.com> Date: Wed Mar 21 14:12:27 2012 +0000 Add undo / redo lists to ScDocFunc diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 973968d..5cb7c18 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -4949,8 +4949,6 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter, const ScRange& rDestRange, sal_uLong nRefresh, sal_Bool bFitBlock, sal_Bool bApi ) { - //! auch fuer ScViewFunc::InsertAreaLink benutzen! - ScDocument* pDoc = rDocShell.GetDocument(); sal_Bool bUndo (pDoc->IsUndoEnabled()); @@ -5034,7 +5032,15 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter, return sal_True; } +void ScDocFunc::EnterListAction( sal_uInt16 nNameResId ) +{ + String aUndo( ScGlobal::GetRscString( nNameResId ) ); + rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo ); +} - +void ScDocFunc::EndListAction() +{ + rDocShell.GetUndoManager()->LeaveListAction(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index e7f6b4d..629e726 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -74,6 +74,10 @@ public: DECL_LINK( NotifyDrawUndo, SdrUndoAction* ); + // for grouping multiple operations into one with a new name + virtual void EnterListAction( sal_uInt16 nNameResId ); + virtual void EndListAction(); + virtual sal_Bool DetectiveAddPred(const ScAddress& rPos); virtual sal_Bool DetectiveDelPred(const ScAddress& rPos); virtual sal_Bool DetectiveAddSucc(const ScAddress& rPos); _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits