summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@novell.com>2010-10-26 15:49:05 +0200
committerThorsten Behrens <tbehrens@novell.com>2010-10-26 15:49:05 +0200
commit94918552e55bd6b1df823d283f6e94f1312c6e62 (patch)
tree3e76174107a0b00e9ebe99933d9d5186cc023d41
parent39790d323a5f82e540c0dcb4998158a13b5f7899 (diff)
Fix broken Impress document zoom behaviour
As outlined in bugs n#380013 and i#88939, in certain cases Impress loads documents nastily offset to the top or left, instead of keeping it nicely centered.
-rwxr-xr-x[-rw-r--r--]sd/source/ui/inc/Window.hxx1
-rwxr-xr-x[-rw-r--r--]sd/source/ui/view/sdwindow.cxx19
2 files changed, 18 insertions, 2 deletions
diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx
index 14919dabc..921f92854 100644..100755
--- a/sd/source/ui/inc/Window.hxx
+++ b/sd/source/ui/inc/Window.hxx
@@ -170,6 +170,7 @@ protected:
Point maWinPos;
Point maViewOrigin;
Size maViewSize;
+ Size maPrevSize; // contains previous window size in logical coords
USHORT mnMinZoom;
USHORT mnMaxZoom;
/** This flag tells whether to re-calculate the minimal zoom factor
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 8defa02f5..86d0bc1c7 100644..100755
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -73,6 +73,7 @@ Window::Window(::Window* pParent)
maWinPos(0, 0), // vorsichtshalber; die Werte sollten aber
maViewOrigin(0, 0), // vom Besitzer des Fensters neu gesetzt
maViewSize(1000, 1000), // werden
+ maPrevSize(-1,-1),
mnMinZoom(MIN_ZOOM),
mnMaxZoom(MAX_ZOOM),
mbMinZoomAutoCalc(false),
@@ -472,6 +473,9 @@ long Window::SetZoomFactor(long nZoom)
aMap.SetScaleY(Fraction(nZoom, 100));
SetMapMode(aMap);
+ // invalidate previous size - it was relative to the old scaling
+ maPrevSize = Size(-1,-1);
+
// Update the map mode's origin (to what effect?).
UpdateMapOrigin();
@@ -668,11 +672,20 @@ void Window::SetMinZoomAutoCalc (bool bAuto)
void Window::UpdateMapOrigin(BOOL bInvalidate)
{
- BOOL bChanged = FALSE;
- Size aWinSize = PixelToLogic(GetOutputSizePixel());
+ BOOL bChanged = FALSE;
+ const Size aWinSize = PixelToLogic(GetOutputSizePixel());
if ( mbCenterAllowed )
{
+ if( maPrevSize != Size(-1,-1) )
+ {
+ // keep view centered around current pos, when window
+ // resizes
+ maWinPos.X() -= (aWinSize.Width() - maPrevSize.Width()) / 2;
+ maWinPos.Y() -= (aWinSize.Height() - maPrevSize.Height()) / 2;
+ bChanged = TRUE;
+ }
+
if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() )
{
maWinPos.X() = maViewSize.Width() - aWinSize.Width();
@@ -697,6 +710,8 @@ void Window::UpdateMapOrigin(BOOL bInvalidate)
UpdateMapMode ();
+ maPrevSize = aWinSize;
+
if (bChanged && bInvalidate)
Invalidate();
}