summaryrefslogtreecommitdiffstats
path: root/sc/source/ui/app
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/inputwin.cxx19
-rw-r--r--sc/source/ui/app/transobj.cxx31
2 files changed, 40 insertions, 10 deletions
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7f0cf742b0..2b2dcb7ebd 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -799,9 +799,11 @@ void ScInputWindow::MouseButtonDown( const MouseEvent& rMEvt )
// I'd prefer to leave at least a single column header and a
// row but I don't know how to get that value in pixels.
// Use TOOLBOX_WINDOW_HEIGHT for the moment
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- mnMaxY = GetOutputSizePixel().Height() + (pViewSh->GetGridHeight(SC_SPLIT_TOP)
- + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM)) - TOOLBOX_WINDOW_HEIGHT;
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ {
+ mnMaxY = GetOutputSizePixel().Height() + (pViewSh->GetGridHeight(SC_SPLIT_TOP)
+ + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM)) - TOOLBOX_WINDOW_HEIGHT;
+ }
}
}
@@ -2663,11 +2665,12 @@ void ScPosWnd::DoEnter()
if (bOpenManageNamesDialog)
{
const sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- assert(pViewSh);
- SfxViewFrame& rViewFrm = pViewSh->GetViewFrame();
- SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
- SC_MOD()->SetRefDialog( nId, pWnd == nullptr );
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ {
+ SfxViewFrame& rViewFrm = pViewSh->GetViewFrame();
+ SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
+ SC_MOD()->SetRefDialog( nId, pWnd == nullptr );
+ }
}
}
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 5f0599c888..e5ed3b1afe 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 );
}