summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-05-10 11:15:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-10 15:23:40 +0200
commit99fb06dd8c0e35e519a888e4c5c2c9805104a683 (patch)
tree47722c58b746e157848daacfd4d8d8a8ee6d1071 /sc
parentfbc038cc4f4a12f8302ce5b3bd7d739bd66a674e (diff)
handle empty tools::Rectangle in sc
Change-Id: I397cb6a0d033a78e854c10d9f33e24e94a9d733e Reviewed-on: https://gerrit.libreoffice.org/72112 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/documen3.cxx33
-rw-r--r--sc/source/core/data/drwlayer.cxx8
-rw-r--r--sc/source/ui/view/printfun.cxx12
3 files changed, 29 insertions, 24 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 0bcf1aa37580..3177f0adc888 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1800,20 +1800,23 @@ ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool
bEnd = true;
}
- nTwips = static_cast<long>(aPosRect.Right() / HMM_PER_TWIPS);
SCCOL nX2 = nX1;
- bEnd = false;
- while (!bEnd)
+ if (!aPosRect.IsEmpty())
{
- nAdd = static_cast<long>(pTable->GetColWidth(nX2, bHiddenAsZero));
- if (nSize+nAdd < nTwips && nX2<MAXCOL)
+ bEnd = false;
+ nTwips = static_cast<long>(aPosRect.Right() / HMM_PER_TWIPS);
+ while (!bEnd)
{
- nSize += nAdd;
- ++nX2;
+ nAdd = static_cast<long>(pTable->GetColWidth(nX2, bHiddenAsZero));
+ if (nSize+nAdd < nTwips && nX2<MAXCOL)
+ {
+ nSize += nAdd;
+ ++nX2;
+ }
+ else
+ bEnd = true;
}
- else
- bEnd = true;
}
nSize = 0;
@@ -1824,12 +1827,14 @@ ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool
if (lcl_AddTwipsWhile( nSize, nTwips+2, nY1, MAXROW, pTable, bHiddenAsZero) && nY1 < MAXROW)
++nY1; // original loop ended on last matched +1 unless that was MAXROW
- nTwips = static_cast<long>(aPosRect.Bottom() / HMM_PER_TWIPS);
-
SCROW nY2 = nY1;
- // Was if(nSize+nAdd<nTwips) inside loop => if(nSize+nAdd<nTwips)
- if (lcl_AddTwipsWhile( nSize, nTwips, nY2, MAXROW, pTable, bHiddenAsZero) && nY2 < MAXROW)
- ++nY2; // original loop ended on last matched +1 unless that was MAXROW
+ if (!aPosRect.IsEmpty())
+ {
+ nTwips = static_cast<long>(aPosRect.Bottom() / HMM_PER_TWIPS);
+ // Was if(nSize+nAdd<nTwips) inside loop => if(nSize+nAdd<nTwips)
+ if (lcl_AddTwipsWhile( nSize, nTwips, nY2, MAXROW, pTable, bHiddenAsZero) && nY2 < MAXROW)
+ ++nY2; // original loop ended on last matched +1 unless that was MAXROW
+ }
return ScRange( nX1,nY1,nTab, nX2,nY2,nTab );
}
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index a18b642b94dd..90f92296534c 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -2080,9 +2080,13 @@ void ScDrawLayer::GetCellAnchorFromPosition(
rAnchor.maEnd = aRange.aEnd;
aCellRect = rDoc.GetMMRect( aRange.aEnd.Col(), aRange.aEnd.Row(),
aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab(), bHiddenAsZero );
- rAnchor.maEndOffset.setY( rObjRect.Bottom()-aCellRect.Top() );
+ if (!rObjRect.IsEmpty())
+ rAnchor.maEndOffset.setY( rObjRect.Bottom()-aCellRect.Top() );
if (!rDoc.IsNegativePage(nTab))
- rAnchor.maEndOffset.setX( rObjRect.Right()-aCellRect.Left() );
+ {
+ if (!rObjRect.IsEmpty())
+ rAnchor.maEndOffset.setX( rObjRect.Right()-aCellRect.Left() );
+ }
else
rAnchor.maEndOffset.setX( aCellRect.Right()-rObjRect.Left() );
}
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 25e9f7e10d73..7806f87164ad 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -515,8 +515,6 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr
long nDevSizeX = aRect.Right()-aRect.Left()+1;
long nDevSizeY = aRect.Bottom()-aRect.Top()+1;
- tools::Rectangle aLines;
-
long nTwipsSizeX = 0;
for (SCCOL i=nX1; i<=nX2; i++)
nTwipsSizeX += pDoc->GetColWidth( i, nTab );
@@ -524,8 +522,8 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr
// if no lines, still space for the outline frame (20 Twips = 1pt)
// (HasLines initializes aLines to 0,0,0,0)
- nTwipsSizeX += aLines.Left() + std::max( aLines.Right(), 20L );
- nTwipsSizeY += aLines.Top() + std::max( aLines.Bottom(), 20L );
+ nTwipsSizeX += 20;
+ nTwipsSizeY += 20;
double nScaleX = static_cast<double>(nDevSizeX) / nTwipsSizeX;
double nScaleY = static_cast<double>(nDevSizeY) / nTwipsSizeY;
@@ -554,10 +552,8 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr
// If no lines, still leave space for grid lines
// (would be elseways cut away)
- long nAddX = static_cast<long>( aLines.Left() * nScaleX );
- nScrX += ( nAddX ? nAddX : 1 );
- long nAddY = static_cast<long>( aLines.Top() * nScaleY );
- nScrY += ( nAddY ? nAddY : 1 );
+ nScrX += 1;
+ nScrY += 1;
ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );