diff options
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 42 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 39 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 36 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 25 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 71 |
6 files changed, 100 insertions, 127 deletions
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 4159dd583c9e..1e1808b8b83d 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 785a253bc5bb..53fb213f774f 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 710105601dc5..106a0771894c 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 2d03320bc918..8ee0da43db1d 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 6698164fca99..5f4dac21e73e 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 1bf2741d65cf..033b828afc48 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"); } } } |