sc/source/ui/inc/docsh.hxx | 32 +++++++++++++ sc/source/ui/undo/undoblk3.cxx | 18 ------- sc/source/ui/undo/undocell.cxx | 43 +++++++++--------- sc/source/ui/view/viewfun2.cxx | 36 +++------------ sc/source/ui/view/viewfun3.cxx | 7 +-- sc/source/ui/view/viewfunc.cxx | 95 +++++++++++++++-------------------------- 6 files changed, 102 insertions(+), 129 deletions(-)
New commits: commit 1cb01c477cf1e84f6e1b2ca1771a9af53d81dc59 Author: Caolán McNamara <caol...@redhat.com> Date: Tue Oct 15 13:23:28 2013 +0100 Resolves: fdo#47958 shrink cut/paste more and rework a bit I'm concerned that the scoping of the dtor will cause events to happen in different order to the original. So rework the require explicit Notify calls rather than implicit dtor calls instead of going about the place putting in scoping brackets Change-Id: I7f3ac4ef3c073da74a9cc49888a59dec12805b0f diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 4159dd5..1e1808b 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -475,32 +475,34 @@ public: void SetDocumentModified(); }; -class HelperNotifyChanges +//#i97876# Spreadsheet data changes are not notified +namespace HelperNotifyChanges { - private: - ScModelObj* pModelObj; - bool mbMustPropagateChanges; - ScRangeList* mpChangeRanges; - OUString mpOperation; - - public: - HelperNotifyChanges(ScRangeList* pChangeRanges, const OUString& pOperation) + inline ScModelObj* getMustPropagateChangesModel(ScDocShell &rDocShell) { - mpChangeRanges = pChangeRanges; - mpOperation = pOperation; - if ( pModelObj && pModelObj->HasChangesListeners() ) - mbMustPropagateChanges = true; + ScModelObj* pModelObj = ScModelObj::getImplementation(rDocShell.GetModel()); + if (pModelObj && pModelObj->HasChangesListeners()) + return pModelObj; + return NULL; } - ~HelperNotifyChanges() + + inline void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, + const OUString &rType = OUString("cell-change"), + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProperties = + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >()) { - if (mbMustPropagateChanges && mpChangeRanges) - { - pModelObj->NotifyChanges(mpOperation, *mpChangeRanges); - } + rModelObj.NotifyChanges(rType, rChangeRanges, rProperties); } - bool getMustPropagateChanges() + + inline void NotifyIfChangesListeners(ScDocShell &rDocShell, const ScRange &rRange, + const OUString &rType = OUString("cell-change")) { - return mbMustPropagateChanges; + if (ScModelObj* pModelObj = getMustPropagateChangesModel(rDocShell)) + { + ScRangeList aChangeRanges; + aChangeRanges.Append(rRange); + Notify(*pModelObj, aChangeRanges, rType); + } } }; diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 785a253..53fb213 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -182,12 +182,7 @@ void ScUndoDeleteContents::Undo() DoChange( sal_True ); EndUndo(); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - aChangeRanges.Append(aRange); - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocShell, aRange); } void ScUndoDeleteContents::Redo() @@ -196,12 +191,7 @@ void ScUndoDeleteContents::Redo() DoChange( false ); EndRedo(); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - aChangeRanges.Append(aRange); - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocShell, aRange); } void ScUndoDeleteContents::Repeat(SfxRepeatTarget& rTarget) diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 7101056..106a077 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -47,6 +47,25 @@ using ::boost::shared_ptr; +namespace HelperNotifyChanges +{ + void NotifyIfChangesListeners(ScDocShell &rDocShell, const ScAddress &rPos, + const ScUndoEnterData::ValuesType &rOldValues, const OUString &rType = OUString("cell-change")) + { + if (ScModelObj* pModelObj = getMustPropagateChangesModel(rDocShell)) + { + ScRangeList aChangeRanges; + + for (size_t i = 0, n = rOldValues.size(); i < n; ++i) + { + aChangeRanges.Append( ScRange(rPos.Col(), rPos.Row(), rOldValues[i].mnTab)); + } + + Notify(*pModelObj, aChangeRanges, rType); + } + } +} + TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo); TYPEINIT1(ScUndoEnterData, ScSimpleUndo); TYPEINIT1(ScUndoEnterValue, ScSimpleUndo); @@ -260,15 +279,7 @@ void ScUndoEnterData::Undo() DoChange(); EndUndo(); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - for (size_t i = 0, n = maOldValues.size(); i < n; ++i) - { - aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), maOldValues[i].mnTab)); - } - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocShell, maPos, maOldValues); } void ScUndoEnterData::Redo() @@ -297,15 +308,7 @@ void ScUndoEnterData::Redo() DoChange(); EndRedo(); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - for (size_t i = 0, n = maOldValues.size(); i < n; ++i) - { - aChangeRanges.Append(ScRange(maPos.Col(), maPos.Row(), maOldValues[i].mnTab)); - } - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocShell, maPos, maOldValues); } void ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 2d03320..8ee0da4 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1284,12 +1284,7 @@ void ScViewFunc::FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, pDocSh->UpdateOle(GetViewData()); UpdateScrollBars(); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - aChangeRanges.Append(aRange); - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange); } } else @@ -1314,40 +1309,29 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, pDocSh->UpdateOle(GetViewData()); UpdateScrollBars(); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) + if (ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh)) { + ScRangeList aChangeRanges; ScRange aChangeRange( aRange ); - switch ( eDir ) + switch (eDir) { case FILL_TO_BOTTOM: - { - aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 ); - } + aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 ); break; case FILL_TO_TOP: - { - aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 ); - } + aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 ); break; case FILL_TO_RIGHT: - { - aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 ); - } + aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 ); break; case FILL_TO_LEFT: - { - aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 ); - } + aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 ); break; default: - { - - } break; } - aChangeRanges.Append(aChangeRange); + aChangeRanges.Append( aChangeRange ); + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); } } } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 6698164..5f4dac2 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -1703,23 +1703,24 @@ void ScViewFunc::PostPasteFromClip(const ScRangeList& rPasteRanges, const ScMark SelectionChanged(); + ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh); + if (!pModelObj) + return; + ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) + for (size_t i = 0, n = rPasteRanges.size(); i < n; ++i) { - for (size_t i = 0, n = rPasteRanges.size(); i < n; ++i) + const ScRange& r = *rPasteRanges[i]; + ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) { - const ScRange& r = *rPasteRanges[i]; - ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); - for (; itr != itrEnd; ++itr) - { - ScRange aChangeRange(r); - aChangeRange.aStart.SetTab(*itr); - aChangeRange.aEnd.SetTab(*itr); - aChangeRanges.Append(aChangeRange); - } + ScRange aChangeRange(r); + aChangeRange.aStart.SetTab(*itr); + aChangeRange.aEnd.SetTab(*itr); + aChangeRanges.Append(aChangeRange); } } + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 1bf2741..033b828 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -322,6 +322,23 @@ static sal_Bool lcl_AddFunction( ScAppOptions& rAppOpt, sal_uInt16 nOpCode ) return sal_True; // list has changed } +namespace HelperNotifyChanges +{ + void NotifyIfChangesListeners(ScDocShell &rDocShell, ScMarkData& rMark, SCCOL nCol, SCROW nRow, + const OUString &rType = OUString("cell-change")) + { + if (ScModelObj *pModelObj = getMustPropagateChangesModel(rDocShell)) + { + ScRangeList aChangeRanges; + ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); + + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, rType); + } + } +} + // actual functions // input - undo OK @@ -551,14 +568,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, pDocSh->UpdateOle(GetViewData()); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); - for (; itr != itrEnd; ++itr) - aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, rMark, nCol, nRow); if ( bRecord ) rFunc.EndListAction(); @@ -725,16 +735,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, pDocSh->UpdateOle(GetViewData()); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - itr = rMark.begin(); - for (; itr != itrEnd; ++itr) - { - aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); - } - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, rMark, nCol, nRow); + aModificator.SetDocumentModified(); } lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh ); @@ -1240,8 +1242,8 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, CellContentChanged(); } - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "attribute"); - if (aHelperNotifyChanges.getMustPropagateChanges()) + ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh); + if (pModelObj) { ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aProperties; sal_Int32 nCount = 0; @@ -1268,7 +1270,9 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, } } } + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "attribute", aProperties); } + StartFormatArea(); } @@ -1481,17 +1485,12 @@ bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste ) CellContentChanged(); ResetAutoSpell(); - ScRangeList aChangeRanges; if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS ) { OUString aOperation = ( eCmd == INS_INSROWS) ? OUString("insert-rows"): OUString("insert-columns"); - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, aOperation); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - aChangeRanges.Append( aRange ); - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation); } } return bSuccess; @@ -1545,15 +1544,10 @@ void ScViewFunc::DeleteCells( DelCellCmd eCmd, bool bRecord ) if ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS ) { - ScRangeList aChangeRanges; OUString aOperation = ( eCmd == DEL_DELROWS) ? OUString("delete-rows"): OUString("delete-columns"); - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, aOperation); - if (aHelperNotifyChanges.getMustPropagateChanges()) - { - aChangeRanges.Append(aRange); - } + HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation); } // put cursor directly behind deleted range @@ -1911,10 +1905,9 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, bool bRecord ) pDocSh->UpdateOle(GetViewData()); - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); - if (aHelperNotifyChanges.getMustPropagateChanges()) + if (ScModelObj *pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh)) { + ScRangeList aChangeRanges; if ( bSimple ) { aChangeRanges.Append( aMarkRange ); @@ -1923,6 +1916,7 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, bool bRecord ) { aFuncMark.FillRangeListWithMarks( &aChangeRanges, false ); } + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); } aModificator.SetDocumentModified(); @@ -2204,13 +2198,11 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR aModificator.SetDocumentModified(); } - // #i97876# Spreadsheet data changes are not notified if ( bWidth ) { - ScRangeList aChangeRanges; - HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "column-resize"); - if (aHelperNotifyChanges.getMustPropagateChanges()) + if (ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh)) { + ScRangeList aChangeRanges; itr = pMarkData->begin(); for (; itr != itrEnd; ++itr) { @@ -2226,6 +2218,7 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR } } } + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize"); } } } commit a1077b3cbdb847a452fccd15d9b834bc262cfb62 Author: Julien Nabet <serval2...@yahoo.fr> Date: Sat Sep 28 14:48:59 2013 +0200 fdo#47958: gross cut/paste signal emission nonsense Change-Id: I60b7a4c5b80410429e5489ee6517bbda8cf328dd diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 964c3ee..4159dd5 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -35,6 +35,7 @@ #include "shellids.hxx" #include "refreshtimer.hxx" #include "optutil.hxx" +#include "docuno.hxx" #include <boost/unordered_map.hpp> #include <cppuhelper/implbase1.hxx> @@ -62,6 +63,7 @@ class ScDocShellModificator; class ScOptSolverSave; class ScSheetSaveData; class ScFlatBoolRowSegments; +class HelperModelObj; struct ScColWidthParam; #if ENABLE_TELEPATHY class ScCollaboration; @@ -473,6 +475,34 @@ public: void SetDocumentModified(); }; +class HelperNotifyChanges +{ + private: + ScModelObj* pModelObj; + bool mbMustPropagateChanges; + ScRangeList* mpChangeRanges; + OUString mpOperation; + + public: + HelperNotifyChanges(ScRangeList* pChangeRanges, const OUString& pOperation) + { + mpChangeRanges = pChangeRanges; + mpOperation = pOperation; + if ( pModelObj && pModelObj->HasChangesListeners() ) + mbMustPropagateChanges = true; + } + ~HelperNotifyChanges() + { + if (mbMustPropagateChanges && mpChangeRanges) + { + pModelObj->NotifyChanges(mpOperation, *mpChangeRanges); + } + } + bool getMustPropagateChanges() + { + return mbMustPropagateChanges; + } +}; #endif diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 00ae959..785a253 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -182,13 +182,11 @@ void ScUndoDeleteContents::Undo() DoChange( sal_True ); EndUndo(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; - aChangeRanges.Append( aRange ); - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); + aChangeRanges.Append(aRange); } } @@ -198,13 +196,11 @@ void ScUndoDeleteContents::Redo() DoChange( false ); EndRedo(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; - aChangeRanges.Append( aRange ); - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); + aChangeRanges.Append(aRange); } } diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 24f27a9..7101056 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -260,16 +260,14 @@ void ScUndoEnterData::Undo() DoChange(); EndUndo(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; for (size_t i = 0, n = maOldValues.size(); i < n; ++i) { aChangeRanges.Append( ScRange(maPos.Col(), maPos.Row(), maOldValues[i].mnTab)); } - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); } } @@ -299,16 +297,14 @@ void ScUndoEnterData::Redo() DoChange(); EndRedo(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; for (size_t i = 0, n = maOldValues.size(); i < n; ++i) { aChangeRanges.Append(ScRange(maPos.Col(), maPos.Row(), maOldValues[i].mnTab)); } - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); } } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index c848d08..2d03320 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1284,13 +1284,11 @@ void ScViewFunc::FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, pDocSh->UpdateOle(GetViewData()); UpdateScrollBars(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; - aChangeRanges.Append( aRange ); - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); + aChangeRanges.Append(aRange); } } } @@ -1316,11 +1314,10 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, pDocSh->UpdateOle(GetViewData()); UpdateScrollBars(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; ScRange aChangeRange( aRange ); switch ( eDir ) { @@ -1350,8 +1347,7 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, } break; } - aChangeRanges.Append( aChangeRange ); - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); + aChangeRanges.Append(aChangeRange); } } } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 4d2ba29..6698164 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -1703,25 +1703,23 @@ void ScViewFunc::PostPasteFromClip(const ScRangeList& rPasteRanges, const ScMark SelectionChanged(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if (!pModelObj || !pModelObj->HasChangesListeners()) - return; - ScRangeList aChangeRanges; - for (size_t i = 0, n = rPasteRanges.size(); i < n; ++i) + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - const ScRange& r = *rPasteRanges[i]; - ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); - for (; itr != itrEnd; ++itr) + for (size_t i = 0, n = rPasteRanges.size(); i < n; ++i) { - ScRange aChangeRange(r); - aChangeRange.aStart.SetTab(*itr); - aChangeRange.aEnd.SetTab(*itr); - aChangeRanges.Append(aChangeRange); + const ScRange& r = *rPasteRanges[i]; + ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); + for (; itr != itrEnd; ++itr) + { + ScRange aChangeRange(r); + aChangeRange.aStart.SetTab(*itr); + aChangeRange.aEnd.SetTab(*itr); + aChangeRanges.Append(aChangeRange); + } } } - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index c5493cd..1bf2741 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -551,16 +551,13 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, pDocSh->UpdateOle(GetViewData()); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end(); for (; itr != itrEnd; ++itr) aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); - - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); } if ( bRecord ) @@ -728,19 +725,16 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, pDocSh->UpdateOle(GetViewData()); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; itr = rMark.begin(); for (; itr != itrEnd; ++itr) { aChangeRanges.Append( ScRange( nCol, nRow, *itr ) ); } - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); } - aModificator.SetDocumentModified(); } lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh ); @@ -1246,9 +1240,8 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, CellContentChanged(); } - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "attribute"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aProperties; sal_Int32 nCount = 0; @@ -1275,9 +1268,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, } } } - pModelObj->NotifyChanges( OUString( "attribute" ), aChangeRanges, aProperties ); } - StartFormatArea(); } @@ -1490,18 +1481,16 @@ bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste ) CellContentChanged(); ResetAutoSpell(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS ) { - if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS ) + OUString aOperation = ( eCmd == INS_INSROWS) ? + OUString("insert-rows"): + OUString("insert-columns"); + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, aOperation); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; aChangeRanges.Append( aRange ); - OUString aOperation = ( eCmd == INS_INSROWS ? - OUString( "insert-rows" ) : - OUString( "insert-columns" ) ); - pModelObj->NotifyChanges( aOperation, aChangeRanges ); } } } @@ -1554,18 +1543,16 @@ void ScViewFunc::DeleteCells( DelCellCmd eCmd, bool bRecord ) CellContentChanged(); ResetAutoSpell(); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + if ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS ) { - if ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS ) + ScRangeList aChangeRanges; + OUString aOperation = ( eCmd == DEL_DELROWS) ? + OUString("delete-rows"): + OUString("delete-columns"); + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, aOperation); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; - aChangeRanges.Append( aRange ); - OUString aOperation = ( eCmd == DEL_DELROWS ? - OUString( "delete-rows" ) : - OUString( "delete-columns" ) ); - pModelObj->NotifyChanges( aOperation, aChangeRanges ); + aChangeRanges.Append(aRange); } } @@ -1924,11 +1911,10 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, bool bRecord ) pDocSh->UpdateOle(GetViewData()); - // #i97876# Spreadsheet data changes are not notified - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "cell-change"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; if ( bSimple ) { aChangeRanges.Append( aMarkRange ); @@ -1937,7 +1923,6 @@ void ScViewFunc::DeleteContents( sal_uInt16 nFlags, bool bRecord ) { aFuncMark.FillRangeListWithMarks( &aChangeRanges, false ); } - pModelObj->NotifyChanges( OUString( "cell-change" ), aChangeRanges ); } aModificator.SetDocumentModified(); @@ -2222,10 +2207,10 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR // #i97876# Spreadsheet data changes are not notified if ( bWidth ) { - ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() ); - if ( pModelObj && pModelObj->HasChangesListeners() ) + ScRangeList aChangeRanges; + HelperNotifyChanges aHelperNotifyChanges(&aChangeRanges, "column-resize"); + if (aHelperNotifyChanges.getMustPropagateChanges()) { - ScRangeList aChangeRanges; itr = pMarkData->begin(); for (; itr != itrEnd; ++itr) { @@ -2241,7 +2226,6 @@ void ScViewFunc::SetWidthOrHeight( bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR } } } - pModelObj->NotifyChanges( OUString( "column-resize" ), aChangeRanges ); } } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits