sc/source/ui/docshell/docfunc.cxx | 72 +++++++++++++++++++++++++++++++++- sc/source/ui/inc/docfunc.hxx | 8 ++- sc/source/ui/view/viewfunc.cxx | 79 +------------------------------------- 3 files changed, 79 insertions(+), 80 deletions(-)
New commits: commit ab58a180bdf08b38517e5ff603614c69e07bbbf2 Author: Kohei Yoshida <[email protected]> Date: Fri Oct 10 20:07:54 2014 -0400 Have ScViewFunc::DeleteContents() to call ScDocFunc's. If bSimple = true, call DeleteCell(), otherwise call DeleteContents(). Change-Id: Ic08d9501797b537430bef0b6f3d920c3b497104b diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 3ed06d2..4f89e13 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1766,8 +1766,6 @@ void ScViewFunc::DeleteContents( InsertDeleteFlags nFlags, bool bRecord ) if (bRecord && !pDoc->IsUndoEnabled()) bRecord = false; - ScDocShellModificator aModificator( *pDocSh ); - if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() ) { aMarkRange.aStart.SetCol(GetViewData().GetCurX()); @@ -1782,81 +1780,13 @@ void ScViewFunc::DeleteContents( InsertDeleteFlags nFlags, bool bRecord ) bSimple = true; } - aFuncMark.SetMarking(false); // for MarkToMulti - aFuncMark.MarkToSimple(); // before bMulti test below - - OSL_ENSURE( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() || bSimple, "delete what?" ); - - ScDocument* pUndoDoc = NULL; - bool bMulti = !bSimple && aFuncMark.IsMultiMarked(); - if (!bSimple) - { - aFuncMark.MarkToMulti(); - aFuncMark.GetMultiMarkArea( aMarkRange ); - } - ScRange aExtendedRange(aMarkRange); - if (!bSimple) - { - if ( pDoc->ExtendMerge( aExtendedRange, true ) ) - bMulti = false; - } - - // no objects on protected tabs - bool bObjects = (nFlags & IDF_OBJECTS) && !sc::DocFuncUtil::hasProtectedTab(*pDoc, aFuncMark); - - sal_uInt16 nExtFlags = 0; // extra flags are needed only if attributes are deleted - if ( nFlags & IDF_ATTRIB ) - pDocSh->UpdatePaintExt( nExtFlags, aMarkRange ); - - // order op opeeration: - // 1) BeginDrawUndo - // 2) delete objects (DrawUndo is filled) - // 3) copy contents for undo - // 4) delete contents - // 5) add undo-action - - bool bDrawUndo = bObjects || ( nFlags & IDF_NOTE ); // needed for shown notes - if ( bDrawUndo && bRecord ) - pDoc->BeginDrawUndo(); - - if (bObjects) - { - if (bMulti) - pDoc->DeleteObjectsInSelection( aFuncMark ); - else - pDoc->DeleteObjectsInArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), -/*!*/ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), - aFuncMark ); - } - - // To keep track of all non-empty cells within the deleted area. - boost::shared_ptr<ScSimpleUndo::DataSpansType> pDataSpans; - - if ( bRecord ) - { - pUndoDoc = sc::DocFuncUtil::createDeleteContentsUndoDoc(*pDoc, aFuncMark, aExtendedRange, nFlags, bMulti); - pDataSpans.reset(sc::DocFuncUtil::getNonEmptyCellSpans(*pDoc, aFuncMark, aExtendedRange)); - } - HideAllCursors(); // for if summary is cancelled + + ScDocFunc& rDocFunc = pDocSh->GetDocFunc(); if (bSimple) - pDoc->DeleteArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), - aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), - aFuncMark, nFlags ); + rDocFunc.DeleteCell(aMarkRange.aStart, aFuncMark, nFlags, bRecord, false); else - { - pDoc->DeleteSelection( nFlags, aFuncMark ); - } - - if ( bRecord ) - { - sc::DocFuncUtil::addDeleteContentsUndo( - pDocSh->GetUndoManager(), pDocSh, aFuncMark, aExtendedRange, pUndoDoc, - nFlags, pDataSpans, bMulti, bDrawUndo); - } - - if (!AdjustRowHeight( aExtendedRange.aStart.Row(), aExtendedRange.aEnd.Row() )) - pDocSh->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags ); + rDocFunc.DeleteContents(aFuncMark, nFlags, bRecord, false); pDocSh->UpdateOle(&GetViewData()); @@ -1874,7 +1804,6 @@ void ScViewFunc::DeleteContents( InsertDeleteFlags nFlags, bool bRecord ) HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); } - aModificator.SetDocumentModified(); CellContentChanged(); ShowAllCursors(); commit 7168096fdf35ee8b2afd330e3d9b3aab09772807 Author: Kohei Yoshida <[email protected]> Date: Fri Oct 10 19:59:57 2014 -0400 Add DeleteCell to ScDocFunc, which is a variant of DeleteContents ... for a single cell case. This is equivalent of ScViewFunc::DeleteConents with bSimple = true. Change-Id: I5eccce21843f4cb21b29f96b0360617a180aebee diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 03a3a9d..b308544 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -559,8 +559,8 @@ void ScDocFunc::DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, vector<S lcl_collectAllPredOrSuccRanges(rSrcRanges, rRefTokens, rDocShell, false); } -bool ScDocFunc::DeleteContents( const ScMarkData& rMark, InsertDeleteFlags nFlags, - bool bRecord, bool bApi ) +bool ScDocFunc::DeleteContents( + const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi ) { ScDocShellModificator aModificator( rDocShell ); @@ -652,6 +652,74 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, InsertDeleteFlags nFlag return true; } +bool ScDocFunc::DeleteCell( + const ScAddress& rPos, const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi ) +{ + ScDocShellModificator aModificator(rDocShell); + + ScDocument& rDoc = rDocShell.GetDocument(); + + if (bRecord && !rDoc.IsUndoEnabled()) + bRecord = false; + + ScEditableTester aTester(&rDoc, rPos.Col(), rPos.Row(), rPos.Col(), rPos.Row(), rMark); + if (!aTester.IsEditable()) + { + if (!bApi) + rDocShell.ErrorMessage(aTester.GetMessageId()); + return false; + } + + // no objects on protected tabs + bool bObjects = (nFlags & IDF_OBJECTS) && !sc::DocFuncUtil::hasProtectedTab(rDoc, rMark); + + sal_uInt16 nExtFlags = 0; // extra flags are needed only if attributes are deleted + if (nFlags & IDF_ATTRIB) + rDocShell.UpdatePaintExt(nExtFlags, rPos); + + // order op opeeration: + // 1) BeginDrawUndo + // 2) delete objects (DrawUndo is filled) + // 3) copy contents for undo + // 4) delete contents + // 5) add undo-action + + bool bDrawUndo = bObjects || (nFlags & IDF_NOTE); // needed for shown notes + if (bDrawUndo && bRecord) + rDoc.BeginDrawUndo(); + + if (bObjects) + rDoc.DeleteObjectsInArea(rPos.Col(), rPos.Row(), rPos.Col(), rPos.Row(), rMark); + + // To keep track of all non-empty cells within the deleted area. + boost::shared_ptr<ScSimpleUndo::DataSpansType> pDataSpans; + + ScDocument* pUndoDoc = NULL; + if (bRecord) + { + pUndoDoc = sc::DocFuncUtil::createDeleteContentsUndoDoc(rDoc, rMark, rPos, nFlags, false); + pDataSpans.reset(sc::DocFuncUtil::getNonEmptyCellSpans(rDoc, rMark, rPos)); + } + + rDoc.DeleteArea(rPos.Col(), rPos.Row(), rPos.Col(), rPos.Row(), rMark, nFlags); + + if (bRecord) + { + sc::DocFuncUtil::addDeleteContentsUndo( + rDocShell.GetUndoManager(), &rDocShell, rMark, rPos, pUndoDoc, + nFlags, pDataSpans, false, bDrawUndo); + } + + if (!AdjustRowHeight(rPos)) + rDocShell.PostPaint( + rPos.Col(), rPos.Row(), rPos.Tab(), rPos.Col(), rPos.Row(), rPos.Tab(), + PAINT_GRID, nExtFlags); + + aModificator.SetDocumentModified(); + + return true; +} + bool ScDocFunc::TransliterateText( const ScMarkData& rMark, sal_Int32 nType, bool bRecord, bool bApi ) { diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index ebd7ac3..5cd2513 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -85,9 +85,11 @@ public: void DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens); void DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens); - SC_DLLPUBLIC bool - DeleteContents( const ScMarkData& rMark, InsertDeleteFlags nFlags, - bool bRecord, bool bApi ); + SC_DLLPUBLIC bool DeleteContents( + const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi ); + + bool DeleteCell( + const ScAddress& rPos, const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi ); bool TransliterateText( const ScMarkData& rMark, sal_Int32 nType, bool bRecord, bool bApi ); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
