diff options
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/dbgui/scuiasciiopt.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh6.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh5.cxx | 85 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/inscodlg.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 23 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 29 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 28 |
14 files changed, 188 insertions, 72 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index f76842429912..5b1d3cbdbced 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1292,7 +1292,7 @@ void ScInputHandler::ShowArgumentsTip( OUString& rSelText ) } const SfxViewShell* pViewShell = SfxViewShell::Current(); - if (comphelper::LibreOfficeKit::isActive() && pViewShell->isLOKDesktop()) + if (comphelper::LibreOfficeKit::isActive() && pViewShell && pViewShell->isLOKDesktop()) { tools::JsonWriter writer; writer.put("type", "formulausage"); diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 5f0599c888b3..e5ed3b1afe2a 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -405,11 +405,38 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt aReducedBlock.aEnd.Col(), aReducedBlock.aEnd.Row(), aReducedBlock.aStart.Tab() ); ScopedVclPtrInstance< VirtualDevice > pVirtDev; - pVirtDev->SetOutputSizePixel(pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM))); + + // tdf#160855 fix crash due to Skia's internal maximum pixel limit + // Somewhere in the tens of thousands of selected fill cells, + // the size of the VirtualDevice exceeds 1 GB of pixels. But + // Skia, at least on macOS, will fail to create a surface. + // Even if there is ample free memory, Skia/Raster will fail. + // The second problem is that even if you disable Skia, the + // crash is just delayed when a BitmapEx is created from the + // VirtualDevice and malloc() fails. + // Since this data flavor really triggers one or more system + // memory limits, lower the resolution of the bitmap by keeping + // the VirtualDevice pixel size within an arbitrary number of + // pixels. + // Note: the artibrary "maximum number of pixels" limit that + // that Skia can handle may need to be raised or lowered for + // platforms other than macOS. + static constexpr tools::Long nCopyToImageMaxPixels = 8192 * 8192; + Fraction aScale(1.0); + Size aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM)); + tools::Long nPixels(aPixelSize.Width() * aPixelSize.Height()); + if (nPixels < 0 || nPixels > nCopyToImageMaxPixels) + { + aScale = Fraction(nCopyToImageMaxPixels, nPixels); + aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM, Point(), aScale, aScale)); + nPixels = aPixelSize.Width() * aPixelSize.Height(); + } + + pVirtDev->SetOutputSizePixel(aPixelSize); PaintToDev( pVirtDev, *m_pDoc, 1.0, aReducedBlock ); - pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel ) ); + pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel, Point(), aScale, aScale ) ); BitmapEx aBmp = pVirtDev->GetBitmapEx( Point(), pVirtDev->GetOutputSize() ); bOK = SetBitmapEx( aBmp, rFlavor ); } diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 601323a6586d..b4b446ea7d58 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -605,6 +605,9 @@ ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, std::u16string_view aD mxCkbSkipEmptyCells->set_active(false); mxCkbSkipEmptyCells->hide(); } + + if (comphelper::LibreOfficeKit::isActive()) + m_xBuilder->weld_button("cancel")->hide(); m_xDialog->SetInstallLOKNotifierHdl(LINK(this, ScImportAsciiDlg, InstallLOKNotifierHdl)); } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 72739573afe0..c33daee69b14 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2275,12 +2275,12 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, if (bInsertCols) { - pViewSh->OnLOKInsertDeleteColumn(rRange.aStart.Col(), 1); + pViewSh->OnLOKInsertDeleteColumn(rRange.aStart.Col() - (eCmd == INS_INSCOLS_BEFORE ? 1: 0), 1); } if (bInsertRows) { - pViewSh->OnLOKInsertDeleteRow(rRange.aStart.Row(), 1); + pViewSh->OnLOKInsertDeleteRow(rRange.aStart.Row() - (eCmd == INS_INSROWS_BEFORE ? 1: 0), 1); } } @@ -2856,11 +2856,11 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, { if (eCmd == DelCellCmd::Cols) { - pViewSh->OnLOKInsertDeleteColumn(rRange.aStart.Col(), -1); + pViewSh->OnLOKInsertDeleteColumn(rRange.aStart.Col(), -1 * (rRange.aEnd.Col() - rRange.aStart.Col() + 1)); } if (eCmd == DelCellCmd::Rows) { - pViewSh->OnLOKInsertDeleteRow(rRange.aStart.Row(), -1); + pViewSh->OnLOKInsertDeleteRow(rRange.aStart.Row(), -1 * (rRange.aEnd.Row() - rRange.aStart.Row() + 1)); } } diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 344b52953faf..0e147f14c3fe 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -496,7 +496,7 @@ void ScDocShell::CheckConfigOptions() pScMod->SetFormulaOptions(aNew); // Launch a nice warning dialog to let the users know of this change. - ScTabViewShell* pViewShell = GetBestViewShell(); + ScTabViewShell* pViewShell = comphelper::LibreOfficeKit::isActive() ? nullptr : GetBestViewShell(); if (pViewShell) { std::shared_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pViewShell->GetFrameWeld(), diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 7c39afc2de0d..0ff2cf6fc468 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -509,58 +509,64 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) if(SC_LAYER_INTERN != pSelected->GetLayer()) { - OUString aName = pSelected->GetName(); + OUString aOldName = pSelected->GetName(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); vcl::Window* pWin = rViewData.GetActiveWin(); - ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aName)); + VclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aOldName)); pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl)); - if(RET_OK == pDlg->Execute()) - { - ScDocShell* pDocSh = rViewData.GetDocShell(); - pDlg->GetName(aName); - - if (aName != pSelected->GetName()) + pDlg->StartExecuteAsync( + [this, pDlg, pSelected] (sal_Int32 nResult)->void { - // handle name change - const SdrObjKind nObjType(pSelected->GetObjIdentifier()); - - if (SdrObjKind::Graphic == nObjType && aName.isEmpty()) + if (nResult == RET_OK) { - // graphics objects must have names - // (all graphics are supposed to be in the navigator) - ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer(); + ScDocShell* pDocSh = rViewData.GetDocShell(); + OUString aNewName = pDlg->GetName(); - if(pModel) + if (aNewName != pSelected->GetName()) { - aName = pModel->GetNewGraphicName(); + // handle name change + const SdrObjKind nObjType(pSelected->GetObjIdentifier()); + + if (SdrObjKind::Graphic == nObjType && aNewName.isEmpty()) + { + // graphics objects must have names + // (all graphics are supposed to be in the navigator) + ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer(); + + if(pModel) + { + aNewName = pModel->GetNewGraphicName(); + } + } + + // An undo action for renaming is missing in svdraw (99363). + // For OLE objects (which can be identified using the persist name), + // ScUndoRenameObject can be used until there is a common action for all objects. + if(SdrObjKind::OLE2 == nObjType) + { + const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName(); + + if(!aPersistName.isEmpty()) + { + pDocSh->GetUndoManager()->AddUndoAction( + std::make_unique<ScUndoRenameObject>(pDocSh, aPersistName, pSelected->GetName(), aNewName)); + } + } + + // set new name + pSelected->SetName(aNewName); } - } - - // An undo action for renaming is missing in svdraw (99363). - // For OLE objects (which can be identified using the persist name), - // ScUndoRenameObject can be used until there is a common action for all objects. - if(SdrObjKind::OLE2 == nObjType) - { - const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName(); - if(!aPersistName.isEmpty()) - { - pDocSh->GetUndoManager()->AddUndoAction( - std::make_unique<ScUndoRenameObject>(pDocSh, aPersistName, pSelected->GetName(), aName)); - } + // ChartListenerCollectionNeedsUpdate is needed for Navigator update + pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true ); + pDocSh->SetDrawModified(); } - - // set new name - pSelected->SetName(aName); + pDlg->disposeOnce(); } - - // ChartListenerCollectionNeedsUpdate is needed for Navigator update - pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true ); - pDocSh->SetDrawModified(); - } + ); } } break; @@ -647,8 +653,7 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxObjectNameDialog&, rDialog, bool ) { - OUString aName; - rDialog.GetName( aName ); + OUString aName = rDialog.GetName(); ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer(); if ( !aName.isEmpty() && pModel ) diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx b/sc/source/ui/miscdlgs/inscodlg.cxx index 84292dcd91c4..378b10f37fd0 100644 --- a/sc/source/ui/miscdlgs/inscodlg.cxx +++ b/sc/source/ui/miscdlgs/inscodlg.cxx @@ -231,7 +231,9 @@ void ScInsertContentsDlg::SetInsContentsCmdBits(const InsertDeleteFlags eFlags) mxBtnInsNumbers->set_active((InsertDeleteFlags::VALUE & eFlags) == InsertDeleteFlags::VALUE); mxBtnInsDateTime->set_active((InsertDeleteFlags::DATETIME & eFlags) == InsertDeleteFlags::DATETIME); mxBtnInsStrings->set_active((InsertDeleteFlags::STRING & eFlags) == InsertDeleteFlags::STRING); - mxBtnInsNotes->set_active((InsertDeleteFlags::NOTE & eFlags) == InsertDeleteFlags::NOTE); + // tdf#160765 - additionally check either NOTE or ADDNOTES + mxBtnInsNotes->set_active(((InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES) & eFlags) + != InsertDeleteFlags::NONE); mxBtnInsFormulas->set_active((InsertDeleteFlags::FORMULA & eFlags) == InsertDeleteFlags::FORMULA); mxBtnInsAttrs->set_active((InsertDeleteFlags::ATTRIB & eFlags) == InsertDeleteFlags::ATTRIB); mxBtnInsObjects->set_active((InsertDeleteFlags::OBJECTS & eFlags) == InsertDeleteFlags::OBJECTS); diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index d16f61411016..5694fe40fe84 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -1451,7 +1451,7 @@ void ScContentTree::SelectEntryByName(const ScContentId nRoot, std::u16string_vi { weld::TreeIter* pParent = m_aRootNodes[nRoot].get(); - if (pParent || !m_xTreeView->iter_has_child(*pParent)) + if (!pParent || !m_xTreeView->iter_has_child(*pParent)) return; std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator(pParent)); diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index c9a233604281..9c7f5571dd71 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -37,6 +37,7 @@ #include <sortparam.hxx> #include <columnspanset.hxx> #include <undomanager.hxx> +#include <sizedev.hxx> ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) : @@ -286,18 +287,26 @@ bool ScBlockUndo::AdjustHeight() { ScDocument& rDoc = pDocShell->GetDocument(); - ScopedVclPtrInstance< VirtualDevice > pVirtDev; + ScSizeDeviceProvider aProv(pDocShell); Fraction aZoomX( 1, 1 ); Fraction aZoomY = aZoomX; double nPPTX, nPPTY; ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) { - ScViewData& rData = pViewShell->GetViewData(); - nPPTX = rData.GetPPTX(); - nPPTY = rData.GetPPTY(); - aZoomX = rData.GetZoomX(); - aZoomY = rData.GetZoomY(); + if (aProv.IsPrinter()) + { + nPPTX = aProv.GetPPTX(); + nPPTY = aProv.GetPPTY(); + } + else + { + ScViewData& rData = pViewShell->GetViewData(); + nPPTX = rData.GetPPTX(); + nPPTY = rData.GetPPTY(); + aZoomX = rData.GetZoomX(); + aZoomY = rData.GetZoomY(); + } } else { @@ -306,7 +315,7 @@ bool ScBlockUndo::AdjustHeight() nPPTY = ScGlobal::nScreenPPTY; } - sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, pVirtDev); + sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice()); bool bRet = rDoc.SetOptimalHeight( aCxt, aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), aBlockRange.aStart.Tab(), true); diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 4907b6b50c05..dfdcb2281251 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -873,6 +873,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) SCROW nFillRow = GetViewData().GetRefEndY(); ScDocument& rDoc = GetViewData().GetDocument(); + sal_uInt16 nOrigScFillModeMouseModifier = nScFillModeMouseModifier; + bool bUseSelection = true; + if( pReqArgs != nullptr ) { if( const SfxStringItem* pItem = pReqArgs->GetItemIfSet( FID_FILL_AUTO ) ) @@ -885,13 +888,33 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) nFillRow = aScAddress.Row(); nFillCol = aScAddress.Col(); } + + SCTAB nStartTab, nEndTab; + GetViewData().GetSimpleArea(nStartCol, nStartRow, nStartTab, nEndCol, + nEndRow, nEndTab); + bUseSelection = false; } - SCTAB nStartTab, nEndTab; - GetViewData().GetSimpleArea( nStartCol,nStartRow,nStartTab, - nEndCol,nEndRow,nEndTab ); + const SfxPoolItem* pItem; + if (pReqArgs->HasItem(FN_PARAM_1, &pItem)) + { + /* + nScFillModeMouseModifier controls if we "Copy cells" or "Fill series" + - if nScFillModeMouseModifier is set to "KEY_MOD1", use "Copy cells" + - otherwise use "Fill series" + + This is also the same with auto fill by dragging mouse + - dragging with Ctrl key will set nScFillModeMouseModifier to KEY_MOD1, use "Copy cells" + - only dragging will use "Fill series" (no Ctrl key) + */ + const bool bCopyCells = static_cast<const SfxBoolItem*>(pItem)->GetValue(); + nScFillModeMouseModifier &= ~KEY_MOD1; // turn off, reset to 0 + + if (bCopyCells) + nScFillModeMouseModifier |= KEY_MOD1; // turn on + } } - else // call via mouse + if (bUseSelection) // call via mouse or if FN_PARAM_1 exists { // not in a merged cell @@ -965,6 +988,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) OSL_FAIL( "Direction not unique for autofill" ); } } + + // reset nScFillModeMouseModifier to its original state + // otherwise, auto fill by dragging will not work as expected + nScFillModeMouseModifier = nOrigScFillModeMouseModifier; } break; case FID_FILL_SINGLE_EDIT: diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1a36f83d88a8..b5cd268e4cc4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -2366,7 +2366,36 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) } } else + { mrViewData.GetDispatcher().Execute( FID_FILL_AUTO, SfxCallMode::SLOT | SfxCallMode::RECORD ); + + // prepare AutoFill menu items for "Copy Cells" and "Fill Series" + ScTabViewShell* pViewShell = mrViewData.GetViewShell(); + boost::property_tree::ptree aMenu; + boost::property_tree::ptree aItemTree; + + aItemTree.put("text", "~Copy Cells"); + aItemTree.put("type", "command"); + aItemTree.put("command", ".uno:AutoFill?Copy:bool=true"); + aItemTree.put("enabled", "true"); + aMenu.push_back(std::make_pair("", aItemTree)); + + aItemTree.put("text", "~Fill Series"); + aItemTree.put("type", "command"); + aItemTree.put("command", ".uno:AutoFill?Copy:bool=false"); + aItemTree.put("enabled", "true"); + aMenu.push_back(std::make_pair("", aItemTree)); + aItemTree.clear(); + + boost::property_tree::ptree aRoot; + aRoot.add_child("menu", aMenu); + + std::stringstream aStream; + boost::property_tree::write_json(aStream, aRoot, true); + + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, + OString(aStream.str())); + } } else if (mrViewData.GetFillMode() == ScFillMode::MATRIX) { diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 8345ba9f42d0..602256a34900 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -2211,14 +2211,15 @@ void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW // MapMode must be set after HideCursor pGridWin[i]->SetMapMode(aViewData.GetLogicMode()); - aViewData.SetEditEngine( static_cast<ScSplitPos>(i), pEngine, pGridWin[i], nCol, nRow ); - if ( !bPosVisible ) { // move the edit view area to the real (possibly negative) position, // or hide if completely above or left of the window pGridWin[i]->UpdateEditViewPos(); } + + aViewData.SetEditEngine(static_cast<ScSplitPos>(i), pEngine, pGridWin[i], nCol, + nRow); } } } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 6003878133cd..f4e777587a9e 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -896,7 +896,8 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, // undo: save all or no content InsertDeleteFlags nContFlags = InsertDeleteFlags::NONE; - if (nFlags & InsertDeleteFlags::CONTENTS) + // tdf#160765 - save content for undo when pasting notes, even if no content was changed + if (nFlags & (InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ADDNOTES)) nContFlags |= InsertDeleteFlags::CONTENTS; if (nFlags & InsertDeleteFlags::ATTRIB) nContFlags |= InsertDeleteFlags::ATTRIB; diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 88261c5e561a..db2bb7c8e717 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1716,11 +1716,17 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, tools::Long nOffset) if (pTabViewShell->getPart() == nCurrentTabIndex) { SCCOL nX = pTabViewShell->GetViewData().GetCurX(); - if (nX > nStartCol || (nX == nStartCol && nOffset > 0)) + if (nX > nStartCol) { + tools::Long offset = nOffset; + if (nOffset + nStartCol > nX) + offset = nX - nStartCol; + else if (nOffset < 0 && nStartCol - nOffset > nX) + offset = -1 * (nX - nStartCol); + ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler(); SCROW nY = pTabViewShell->GetViewData().GetCurY(); - pTabViewShell->SetCursor(nX + nOffset, nY); + pTabViewShell->SetCursor(nX + offset, nY); if (pInputHdl && pInputHdl->IsInputMode()) { pInputHdl->SetModified(); @@ -1729,8 +1735,8 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, tools::Long nOffset) ScMarkData aMultiMark( pTabViewShell->GetViewData().GetMarkData() ); aMultiMark.SetMarking( false ); - aMultiMark.MarkToMulti(); - if (aMultiMark.IsMultiMarked()) + + if (aMultiMark.IsMultiMarked() || aMultiMark.IsMarked()) { aMultiMark.ShiftCols(pTabViewShell->GetViewData().GetDocument(), nStartCol, nOffset); pTabViewShell->SetMarkData(aMultiMark); @@ -1773,11 +1779,17 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, tools::Long nOffset) if (pTabViewShell->getPart() == nCurrentTabIndex) { SCROW nY = pTabViewShell->GetViewData().GetCurY(); - if (nY > nStartRow || (nY == nStartRow && nOffset > 0)) + if (nY > nStartRow) { + tools::Long offset = nOffset; + if (nOffset + nStartRow > nY) + offset = nY - nStartRow; + else if (nOffset < 0 && nStartRow - nOffset > nY) + offset = -1 * (nY - nStartRow); + ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler(); SCCOL nX = pTabViewShell->GetViewData().GetCurX(); - pTabViewShell->SetCursor(nX, nY + nOffset); + pTabViewShell->SetCursor(nX, nY + offset); if (pInputHdl && pInputHdl->IsInputMode()) { pInputHdl->SetModified(); @@ -1786,8 +1798,8 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, tools::Long nOffset) ScMarkData aMultiMark( pTabViewShell->GetViewData().GetMarkData() ); aMultiMark.SetMarking( false ); - aMultiMark.MarkToMulti(); - if (aMultiMark.IsMultiMarked()) + + if (aMultiMark.IsMultiMarked() || aMultiMark.IsMarked()) { aMultiMark.ShiftRows(pTabViewShell->GetViewData().GetDocument(), nStartRow, nOffset); pTabViewShell->SetMarkData(aMultiMark); |