[Libreoffice-commits] .: 2 commits - sc/source
Noel Power
noelp at kemper.freedesktop.org
Tue Jun 26 10:24:49 PDT 2012
sc/source/ui/inc/prevwsh.hxx | 3 -
sc/source/ui/view/preview.cxx | 5 --
sc/source/ui/view/prevwsh.cxx | 96 +++++++++++++++++++++++++-----------------
3 files changed, 61 insertions(+), 43 deletions(-)
New commits:
commit baf87aacce6d75f9b01156ce085ef4487d46a406
Author: Noel Power <noel.power at novell.com>
Date: Tue Jun 26 18:19:21 2012 +0100
fix for fdo#51040 preview crash
Change-Id: I13d3cfa99294bdce8c9f5133f49e91114feb4baa
diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx
index f62165f..1da34f3 100644
--- a/sc/source/ui/inc/prevwsh.hxx
+++ b/sc/source/ui/inc/prevwsh.hxx
@@ -50,7 +50,6 @@ class CommandEvent;
class ScPreviewShell: public SfxViewShell
{
-friend class ScPreview; // allow access to AdjustPosSizePixel
ScDocShell* pDocShell;
SystemWindow* mpFrameWindow;
@@ -66,7 +65,6 @@ friend class ScPreview; // allow access to AdjustPosSizePixel
SfxBroadcaster* pAccessibilityBroadcaster;
bool GetPageSize( Size& aPageSize );
- void UpdateNeededScrollBars();
private:
void Construct( Window* pParent );
DECL_LINK(ScrollHandler, ScrollBar* );
@@ -106,6 +104,7 @@ public:
void InitStartTable(SCTAB nTab);
void UpdateScrollBars();
+ void UpdateNeededScrollBars(bool bFromZoom = false);
sal_Bool ScrollCommand( const CommandEvent& rCEvt );
void Execute( SfxRequest& rReq );
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index ae233ff..8007e0e 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -701,10 +701,7 @@ void ScPreview::SetZoom(sal_uInt16 nNewZoom)
SetMapMode( aMMMode );
bInSetZoom = true; // don't scroll during SetYOffset in UpdateScrollBars
- if ( Window* pWin = ( pViewShell->GetViewFrame() ? &pViewShell->GetViewFrame()->GetWindow() : NULL ) )
- pViewShell->AdjustPosSizePixel( pWin->GetPosPixel(), pWin->GetSizePixel() );
- else
- pViewShell->UpdateScrollBars();
+ pViewShell->UpdateNeededScrollBars(true);
bInSetZoom = false;
bStateValid = false;
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 77f633d..43f9794 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -297,16 +297,9 @@ bool ScPreviewShell::GetPageSize( Size& aPageSize )
return true;
}
-void ScPreviewShell::UpdateNeededScrollBars()
+void ScPreviewShell::UpdateNeededScrollBars( bool bFromZoom )
{
- bool bVert = pVerScroll ? pVerScroll->IsVisible() : false;
- bool bHori = pHorScroll ? pHorScroll->IsVisible() : false;
-
Size aPageSize;
- if ( !GetPageSize( aPageSize ) )
- return;
-
- Size aWindowSize = pPreview->GetOutputSize();
OutputDevice* pDevice = Application::GetDefaultDevice();
long nBarW = GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetScrollBarSize();
@@ -315,49 +308,74 @@ void ScPreviewShell::UpdateNeededScrollBars()
long aHeightOffSet = pDevice ? pDevice->PixelToLogic( Size( nBarW, nBarH ), pPreview->GetMapMode() ).Height() : 0;
long aWidthOffSet = aHeightOffSet;
- if( pHorScroll )
+
+ if (!GetPageSize( aPageSize ))
+ return;
+
+ // for centering, page size without the shadow is used
+ bool bVert = pVerScroll ? pVerScroll->IsVisible() : false;
+ bool bHori = pHorScroll ? pHorScroll->IsVisible() : false;
+ Size aWindowSize = pPreview->GetOutputSize();
+ Point aPos = pPreview->GetPosPixel();
+ Size aWindowPixelSize = pPreview->GetOutputSizePixel();
+
+ // if we are called from Zoom then we need to compensate for whatever
+ // scrollbars were displayed before the zoom was called
+ if ( bFromZoom )
{
- long nMaxPos = aPageSize.Width() - aWindowSize.Width() + aWidthOffSet;
- if ( nMaxPos<0 )
- bHori = false;
- else
- bHori = true;
- pHorScroll->Show( bHori );
+ if ( bVert )
+ {
+ aWindowPixelSize.Width() += nBarH;
+ aWindowSize.Width() += aHeightOffSet;
+ }
+ if ( bHori )
+ {
+ aWindowPixelSize.Height() += nBarW;
+ aWindowSize.Height() += aWidthOffSet;
+ }
}
+ // recalculate any needed scrollbars
+ bHori = false;
+ bVert = false;
- if( pVerScroll )
- {
- nMaxVertPos = aPageSize.Height() - aWindowSize.Height() + aHeightOffSet;
+ long nMaxWidthPos = aPageSize.Width() - aWindowSize.Width();
+ if ( nMaxWidthPos<0 )
+ bHori = false;
+ else
+ bHori = true;
- if ( nMaxVertPos < 0 )
- bVert = false;
- else
+ long nMaxHeightPos = aPageSize.Height() - aWindowSize.Height();
+
+ if ( nMaxHeightPos < 0 )
+ bVert = false;
+ else
+ bVert = true;
+
+ // see if having a scroll bar requires the other
+ if ( bVert != bHori && ( bVert || bHori ) )
+ {
+ if ( bVert && ( (nMaxWidthPos + aWidthOffSet ) > 0 ) )
+ bHori = true;
+ else if ( (nMaxHeightPos + aHeightOffSet ) > 0 )
bVert = true;
- pVerScroll->Show( bVert );
}
+ pHorScroll->Show( bHori );
+ pVerScroll->Show( bVert );
- Size aOutSize = pPreview->GetSizePixel();
- Size aNewSize = aOutSize;
- Point aPos = pPreview->GetPosPixel();
-
+ // make room for needed scrollbars ( and reduce the size
+ // of the preview appropriately )
if ( bHori )
- aNewSize.Height() -= nBarH;
+ aWindowPixelSize.Height() -= nBarW;
if ( bVert )
- aNewSize.Width() -= nBarW;
-
- pPreview->SetPosSizePixel( aPos, aNewSize );
-
- pHorScroll->SetPosSizePixel( Point( aPos.X(), aPos.Y() + aNewSize.Height() ),
- Size( aNewSize.Width(), nBarH ) );
- pVerScroll->SetPosSizePixel( Point( aPos.X() + aNewSize.Width(), aPos.Y() ),
- Size( nBarW, aNewSize.Height() ) );
- pCorner->SetPosSizePixel( Point( aPos.X() + aNewSize.Width(), aPos.Y() + aNewSize.Height() ),
+ aWindowPixelSize.Width() -= nBarH;
+
+ pPreview->SetSizePixel( aWindowPixelSize );
+ pHorScroll->SetPosSizePixel( Point( aPos.X(), aPos.Y() + aWindowPixelSize.Height() ),
+ Size( aWindowPixelSize.Width(), nBarH ) );
+ pVerScroll->SetPosSizePixel( Point( aPos.X() + aWindowPixelSize.Width(), aPos.Y() ),
+ Size( nBarW, aWindowPixelSize.Height() ) );
+ pCorner->SetPosSizePixel( Point( aPos.X() + aWindowPixelSize.Width(), aPos.Y() + aWindowPixelSize.Height() ),
Size( nBarW, nBarH ) );
-
- if ( SVX_ZOOM_WHOLEPAGE == eZoom )
- pPreview->SetZoom( pPreview->GetOptimalZoom( sal_False ) );
- else if ( SVX_ZOOM_PAGEWIDTH == eZoom )
- pPreview->SetZoom( pPreview->GetOptimalZoom( sal_True ) );
UpdateScrollBars();
}
commit ff62d9c4be26096c7f5ea06e4dee2b16d40aa16b
Author: Noel Power <noel.power at novell.com>
Date: Tue Jun 26 18:24:06 2012 +0100
Revert "set the zoom only once, prevents infinite loop, fdo#51040"
This reverts commit 793f1e70ce4c364b366d2e8065ea7fb2815bbf40.
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 4bf5631..77f633d 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -354,6 +354,10 @@ void ScPreviewShell::UpdateNeededScrollBars()
pCorner->SetPosSizePixel( Point( aPos.X() + aNewSize.Width(), aPos.Y() + aNewSize.Height() ),
Size( nBarW, nBarH ) );
+ if ( SVX_ZOOM_WHOLEPAGE == eZoom )
+ pPreview->SetZoom( pPreview->GetOptimalZoom( sal_False ) );
+ else if ( SVX_ZOOM_PAGEWIDTH == eZoom )
+ pPreview->SetZoom( pPreview->GetOptimalZoom( sal_True ) );
UpdateScrollBars();
}
More information about the Libreoffice-commits
mailing list