From 53ad646f54f8aa33b86c696c04500fd08ea6f3b6 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 28 Oct 2012 23:23:53 +0100 Subject: Enforce use of accessors on gen.hxx structures Change-Id: Icd1b2937fdeaba6de1877258731f53ddf996002e Reviewed-on: https://gerrit.libreoffice.org/936 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- sw/source/ui/uiview/viewport.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sw/source/ui/uiview') diff --git a/sw/source/ui/uiview/viewport.cxx b/sw/source/ui/uiview/viewport.cxx index 6b0b80668eac..967b410e5577 100644 --- a/sw/source/ui/uiview/viewport.cxx +++ b/sw/source/ui/uiview/viewport.cxx @@ -89,14 +89,13 @@ static void lcl_GetPos(SwView* pView, const Size aDocSz( rSh.GetDocSize() ); const long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2; - sal_Bool bHori = pScrollbar->IsHoriScroll(); + const bool bHori = pScrollbar->IsHoriScroll(); const long lPos = pScrollbar->GetThumbPos() + (bBorder ? DOCUMENTBORDER : 0); - long Point:: *pPt = bHori ? &Point::nA : &Point::nB; - long Size:: *pSz = bHori ? &Size::nA : &Size::nB; - long lDelta = lPos - rSh.VisArea().Pos().*pPt; - const long lSize = aDocSz.*pSz + lBorder; + long lDelta = lPos - (bHori ? rSh.VisArea().Pos().X() : rSh.VisArea().Pos().Y()); + + const long lSize = (bHori ? aDocSz.A() : aDocSz.B()) + lBorder; // sollte rechts oder unten zuviel Wiese sein, dann muss // diese von der VisArea herausgerechnet werden! long nTmp = pView->GetVisArea().Right()+lDelta; @@ -106,9 +105,12 @@ static void lcl_GetPos(SwView* pView, if ( !bHori && nTmp > lSize ) lDelta -= nTmp - lSize; - rPos.*pPt += lDelta; - if ( bBorder && rPos.*pPt < DOCUMENTBORDER ) - rPos.*pPt = DOCUMENTBORDER; + // use a reference to access/moodify the correct coordinate + // returned by accessors to non-const object + long & rCoord = bHori ? rPos.X() : rPos.Y(); + rCoord += lDelta; + if ( bBorder && rCoord < DOCUMENTBORDER ) + rCoord = DOCUMENTBORDER; } /*-------------------------------------------------------------------- -- cgit distro/collabora/cd-5.3-3.2'>distro/collabora/cd-5.3-3.2 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author