summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/tabview2.cxx
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2001-02-28 13:58:13 +0000
committerNiklas Nebel <nn@openoffice.org>2001-02-28 13:58:13 +0000
commit80c94b5d47a27aba6c112e24add58b2c3826dd16 (patch)
tree3875012d8bb29b3965236d134ba42aa3a2258231 /sc/source/ui/view/tabview2.cxx
parentdaa5e5917162901723a4b27b3fa7fd182a4c76c6 (diff)
#84412# optimal zoom: handle frozen panes correctly
Diffstat (limited to 'sc/source/ui/view/tabview2.cxx')
-rw-r--r--sc/source/ui/view/tabview2.cxx121
1 files changed, 91 insertions, 30 deletions
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 47e77d9a3..cde3a289c 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: tabview2.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: nn $ $Date: 2000-09-22 18:32:16 $
+ * last change: $Author: nn $ $Date: 2001-02-28 14:58:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -465,15 +465,18 @@ void ScTabView::SelectAllTables()
BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom,
long nWindowX, long nWindowY, ScDocument* pDoc, USHORT nTab,
- USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow )
+ USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
+ USHORT nFixPosX, USHORT nFixPosY )
{
double fZoomFactor = (double)Fraction(nZoom,100);
fScaleX *= fZoomFactor;
fScaleY *= fZoomFactor;
long nBlockX = 0;
- for (USHORT nCol=nStartCol; nCol<=nEndCol; nCol++)
+ USHORT nCol;
+ for (nCol=0; nCol<nFixPosX; nCol++)
{
+ // for frozen panes, add both parts
USHORT nColTwips = pDoc->GetColWidth( nCol, nTab );
if (nColTwips)
{
@@ -482,9 +485,22 @@ BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom,
return FALSE;
}
}
+ for (nCol=nStartCol; nCol<=nEndCol; nCol++)
+ {
+ USHORT nColTwips = pDoc->GetColWidth( nCol, nTab );
+ if (nColTwips)
+ {
+ nBlockX += (long)(nColTwips * fScaleX);
+ if (nBlockX > nWindowX)
+ return FALSE;
+ }
+ }
+
long nBlockY = 0;
- for (USHORT nRow=nStartRow; nRow<=nEndRow; nRow++)
+ USHORT nRow;
+ for (nRow=0; nRow<nFixPosY; nRow++)
{
+ // for frozen panes, add both parts
USHORT nRowTwips = pDoc->GetRowHeight( nRow, nTab );
if (nRowTwips)
{
@@ -493,6 +509,17 @@ BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom,
return FALSE;
}
}
+ for (nRow=nStartRow; nRow<=nEndRow; nRow++)
+ {
+ USHORT nRowTwips = pDoc->GetRowHeight( nRow, nTab );
+ if (nRowTwips)
+ {
+ nBlockY += (long)(nRowTwips * fScaleY);
+ if (nBlockY > nWindowY)
+ return FALSE;
+ }
+ }
+
return TRUE;
}
@@ -530,36 +557,70 @@ USHORT ScTabView::CalcZoom( SvxZoomType eType, USHORT nOldZoom )
if ( nTab < nStartTab && nTab > nEndTab )
nTab = nStartTab;
- // Wegen der Pixel-Rundungs-Arie kann man zuverlaessig nur nachrechnen,
- // ob ein bestimmter Zoom in das Fenster passt - darum wird geschachtelt
-
- Size aWinSize = pGridWin[aViewData.GetActivePart()]->GetOutputSizePixel();
+ ScSplitPos eUsedPart = aViewData.GetActivePart();
- ScDocShell* pDocSh = aViewData.GetDocShell();
- double nPPTX = ScGlobal::nScreenPPTX / pDocSh->GetOutputFactor();
- double nPPTY = ScGlobal::nScreenPPTY;
-
- USHORT nMin = MINZOOM;
- USHORT nMax = MAXZOOM;
- while ( nMax > nMin )
+ USHORT nFixPosX = 0;
+ USHORT nFixPosY = 0;
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
{
- USHORT nTest = (nMin+nMax+1)/2;
- if ( lcl_FitsInWindow(
- nPPTX, nPPTY, nTest, aWinSize.Width(), aWinSize.Height(),
- pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow ) )
- nMin = nTest;
- else
- nMax = nTest-1;
+ // use right part
+ eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
+ nFixPosX = aViewData.GetFixPosX();
+ if ( nStartCol < nFixPosX )
+ nStartCol = nFixPosX;
}
- DBG_ASSERT( nMin == nMax, "Schachtelung ist falsch" );
- nZoom = nMin;
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ {
+ // use bottom part
+ eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+ nFixPosY = aViewData.GetFixPosY();
+ if ( nStartRow < nFixPosY )
+ nStartRow = nFixPosY;
+ }
+
+ if (pGridWin[eUsedPart])
+ {
+ // Because scale is rounded to pixels, the only reliable way to find
+ // the right scale is to check if a zoom fits
+
+ Size aWinSize = pGridWin[eUsedPart]->GetOutputSizePixel();
- // 1 paar {} wg compiler bug
- if ( nZoom != nOldZoom )
- { for (USHORT i=0; i<2; i++)
+ // for frozen panes, use sum of both parts for calculation
+
+ if ( nFixPosX )
+ aWinSize.Width() += GetGridWidth( SC_SPLIT_LEFT );
+ if ( nFixPosY )
+ aWinSize.Height() += GetGridHeight( SC_SPLIT_TOP );
+
+ ScDocShell* pDocSh = aViewData.GetDocShell();
+ double nPPTX = ScGlobal::nScreenPPTX / pDocSh->GetOutputFactor();
+ double nPPTY = ScGlobal::nScreenPPTY;
+
+ USHORT nMin = MINZOOM;
+ USHORT nMax = MAXZOOM;
+ while ( nMax > nMin )
{
- aViewData.SetPosX( (ScHSplitPos) i, nStartCol );
- aViewData.SetPosY( (ScVSplitPos) i, nStartRow );
+ USHORT nTest = (nMin+nMax+1)/2;
+ if ( lcl_FitsInWindow(
+ nPPTX, nPPTY, nTest, aWinSize.Width(), aWinSize.Height(),
+ pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow,
+ nFixPosX, nFixPosY ) )
+ nMin = nTest;
+ else
+ nMax = nTest-1;
+ }
+ DBG_ASSERT( nMin == nMax, "Schachtelung ist falsch" );
+ nZoom = nMin;
+
+ if ( nZoom != nOldZoom )
+ {
+ // scroll to block only in active split part
+ // (the part for which the size was calculated)
+
+ if ( nStartCol <= nEndCol )
+ aViewData.SetPosX( WhichH(eUsedPart), nStartCol );
+ if ( nStartRow <= nEndRow )
+ aViewData.SetPosY( WhichV(eUsedPart), nStartRow );
}
}
}