[Libreoffice-commits] core.git: Branch 'feature/calctiledrendering5' - 5 commits - sc/source

Andrzej Hunt andrzej.hunt at collabora.com
Fri Aug 8 04:54:01 PDT 2014


 sc/source/ui/inc/gridwin.hxx   |   17 +++-
 sc/source/ui/view/colrowba.cxx |    2 
 sc/source/ui/view/gridwin.cxx  |  167 ++++++++++++++++++++++++++++++++---------
 sc/source/ui/view/gridwin2.cxx |    8 -
 sc/source/ui/view/gridwin3.cxx |    2 
 sc/source/ui/view/gridwin4.cxx |  117 ++++++++++++++++------------
 sc/source/ui/view/hdrcont.cxx  |   24 +++--
 7 files changed, 241 insertions(+), 96 deletions(-)

New commits:
commit aac188abd53dde9e169919926cc6e8767462259c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Aug 8 13:47:30 2014 +0200

    TEMPORARY: use a different paint rect.
    
    Change-Id: I5fca6c31d0a526aa0a393d2bf68aeda81962ae36

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index af8b87e..e0d7452 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -182,7 +182,8 @@ class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHe
     Point                   aCurMousePos;
 
     sal_uInt16              nPaintCount;
-    Rectangle               aRepaintPixel;
+    // The area to be repainted, in logic coordinates.
+    Rectangle               aRepaintRect;
 
     ScAddress               aAutoMarkPos;
     ScAddress               aListValPos;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 621ec01..659096f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -4608,7 +4608,7 @@ void ScGridWindow::UpdateFormulas()
         //  (dann wuerde zumindest der MapMode nicht mehr stimmen)
 
         bNeedsRepaint = true;           // -> am Ende vom Paint nochmal Invalidate auf alles
-        aRepaintPixel = Rectangle();    // alles
+        aRepaintRect = Rectangle();    // alles
         return;
     }
 
@@ -4696,7 +4696,7 @@ void ScGridWindow::UpdateListValPos( bool bVisible, const ScAddress& rPos )
         if ( !bOldButton || aListValPos != aOldPos )
         {
             // paint area of new button
-            Invalidate( PixelToLogic( GetListValButtonRect( aListValPos ) ) );
+            Invalidate( GetListValButtonRect( aListValPos ) );
         }
     }
     if ( bOldButton )
@@ -4704,7 +4704,7 @@ void ScGridWindow::UpdateListValPos( bool bVisible, const ScAddress& rPos )
         if ( !bListValButton || aListValPos != aOldPos )
         {
             // paint area of old button
-            Invalidate( PixelToLogic( GetListValButtonRect( aOldPos ) ) );
+            Invalidate( GetListValButtonRect( aOldPos ) );
         }
     }
 }
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ef9ffcb..09403b0 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -322,9 +322,14 @@ void ScGridWindow::Paint( const Rectangle& rRect )
     EnableMapMode( false );
 }
 
-void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
+void ScGridWindow::Paint( const Rectangle& rPixRect, OutputDevice* pOutDev )
 {
+    // Convert Pix to logic
+    const Rectangle aLogicRect = PixelToLogic( rPixRect );
+
+//    const Rectangle aLogicRect = rPixRect;
     ScDocument* pDoc = pViewData->GetDocument();
+
     if ( pDoc->IsInInterpreter() )
     {
         //  via Reschedule, interpretierende Zellen nicht nochmal anstossen
@@ -334,12 +339,14 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
         if ( bNeedsRepaint )
         {
             //! Rechtecke zusammenfassen?
-            aRepaintPixel = Rectangle();            // mehrfach -> alles painten
+            aRepaintRect = Rectangle();            // mehrfach -> alles painten
         }
         else
         {
             bNeedsRepaint = true;
-            aRepaintPixel = LogicToPixel(rRect);    // nur betroffenen Bereich
+            // Yes -- this is reused for another paint call, hence we need
+            // to keep pixel coordinates.
+            aRepaintRect = rPixRect;
         }
         return;
     }
@@ -366,13 +373,13 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
 
     SCTAB nTab = pViewData->GetTabNo();
 
-    Rectangle aMirroredRect = rRect;
+    Rectangle aMirroredRect = aLogicRect;
     if ( pDoc->IsLayoutRTL( nTab ) )
     {
         //  mirror and swap
-        long nWidth = PixelToLogic(GetSizePixel()).Width();
-        aMirroredRect.Left()  = nWidth - 1 - rRect.Right();
-        aMirroredRect.Right() = nWidth - 1 - rRect.Left();
+        long nWidth = GetSizePixel().Width();
+        aMirroredRect.Left()  = nWidth - 1 - aLogicRect.Right();
+        aMirroredRect.Right() = nWidth - 1 - aLogicRect.Left();
     }
 
     long nScrX = pDoc->GetColWidth( nX1, nTab );
@@ -389,13 +396,13 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
     }
 
     long nScrY = 0;
-    while ( nScrY < rRect.Top() && nY1 < MAXROW )
+    while ( nScrY < aLogicRect.Top() && nY1 < MAXROW )
     {
         ++nY1;
         nScrY += pDoc->GetRowHeight( nY1, nTab );
     }
     SCROW nY2 = nY1;
-    while ( nScrY <= rRect.Bottom() && nY2 < MAXROW )
+    while ( nScrY <= aLogicRect.Bottom() && nY2 < MAXROW )
     {
         ++nY2;
         nScrY += pDoc->GetRowHeight( nY2, nTab );
@@ -413,6 +420,7 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
     // set in UpdateVisibleRange which however uses the viewdata, which is
     // completely irrelevant for tiled rendering.
     maVisibleRange.set( nX1, nY1, nX2, nY2 );
+
     Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS, pOutDev );           // nicht weiterzeichnen
     bIsInPaint = false;
 }
@@ -481,7 +489,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 
     OSL_ENSURE( ValidCol(nX2) && ValidRow(nY2), "GridWin Draw Bereich zu gross" );
 
-    UpdateVisibleRange();
+//    UpdateVisibleRange();
 
     if (nX2 < maVisibleRange.mnCol1 || nY2 < maVisibleRange.mnRow1)
         return;
@@ -492,7 +500,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         nY1 = maVisibleRange.mnRow1;
 
     if (nX1 > maVisibleRange.mnCol2 || nY1 > maVisibleRange.mnRow2)
+    {
         return;
+    }
 
     if (nX2 > maVisibleRange.mnCol2)
         nX2 = maVisibleRange.mnCol2;
@@ -1015,11 +1025,11 @@ void ScGridWindow::CheckNeedsRepaint()
     if (bNeedsRepaint)
     {
         bNeedsRepaint = false;
-        if (aRepaintPixel.IsEmpty())
+        if (aRepaintRect.IsEmpty())
             Invalidate();
         else
-            Invalidate(PixelToLogic(aRepaintPixel));
-        aRepaintPixel = Rectangle();
+            Invalidate(aRepaintRect);
+        aRepaintRect = Rectangle();
 
         // selection function in status bar might also be invalid
         SfxBindings& rBindings = pViewData->GetBindings();
commit f61391f24adb189dee2656d06478e24f69db24ea
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Aug 8 09:24:15 2014 +0200

    Col/Row Headers: use correct scaling.
    
    This makes the headers behave quite well, still some issues
    with lines occasionally missing etc. though.
    
    Change-Id: Iecbef29afec877e906a322188bc2280018fc8319

diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx
index 27ca257..70b1232 100644
--- a/sc/source/ui/view/colrowba.cxx
+++ b/sc/source/ui/view/colrowba.cxx
@@ -194,6 +194,7 @@ bool ScColBar::ResizeAllowed() const
 void ScColBar::DrawInvert( long nDragPosP )
 {
     Rectangle aRect( nDragPosP,0, nDragPosP+HDR_SLIDERSIZE-1,GetOutputSizePixel().Width()-1 );
+    aRect = PixelToLogic( aRect );
     Update();
     Invert(aRect);
 
@@ -347,6 +348,7 @@ bool ScRowBar::ResizeAllowed() const
 void ScRowBar::DrawInvert( long nDragPosP )
 {
     Rectangle aRect( 0,nDragPosP, GetOutputSizePixel().Width()-1,nDragPosP+HDR_SLIDERSIZE-1 );
+    aRect = PixelToLogic( aRect );
     Update();
     Invert(aRect);
 
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index c25f661..f4ed094 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -196,7 +196,7 @@ long ScHeaderControl::GetScrPos( SCCOLROW nEntryNo ) const
 {
     long nScrPos;
 
-    long nMax = ( bVertical ? GetOutputSizePixel().Height() : GetOutputSizePixel().Width() ) + 1;
+    long nMax = ( bVertical ? GetOutputSize().Height() : GetOutputSize().Width() ) + 1;
     if (nEntryNo >= nSize)
         nScrPos = nMax;
     else
@@ -278,6 +278,8 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
     aMapMode.SetScaleY( rViewData.GetZoomY() * Fraction(0.96) );
     SetMapMode( aMapMode );
 
+    Rectangle aOurRect = PixelToLogic( rRect );
+
     // We occasionally need to be able to measure 1 pixel
     // e.g. for column/row subdivision, but we're working
     // in logic units nowadays, hence we can grab the correct
@@ -318,8 +320,8 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
 
     SCCOLROW    nPos = GetPos();
 
-    long nPStart = bVertical ? rRect.Top() : rRect.Left();
-    long nPEnd = bVertical ? rRect.Bottom() : rRect.Right();
+    long nPStart = bVertical ? aOurRect.Top() : aOurRect.Left();
+    long nPEnd = bVertical ? aOurRect.Bottom() : aOurRect.Right();
 
     long nTransStart = nPEnd + (bVertical ? aOnePixel.Width() : aOnePixel.Height());
     long nTransEnd = 0;
commit df6df0324dcbd2c7e40914108de098c384302394
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Aug 8 09:22:14 2014 +0200

    Introduce GetScrPosPix/Logic in place of plain GetScrPos.
    
    We should make it obvious what we're actually getting, and get
    the most appropriate version as necessary.
    
    Change-Id: I45a2eb6ddc2e24993c2dfdfeea35e831e822adc3

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index e0bff21..af8b87e 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -309,8 +309,11 @@ protected:
 private:
     void            getCellGeometry( Point& rScrPos, Size& rScrSize,
                                      SCCOL nCol, SCROW nRow ) const;
-    Point           GetScrPos( SCCOL nWhereX, SCROW nWhereY,
+    Point           GetScrPosPix( SCCOL nWhereX, SCROW nWhereY,
+                               bool bAllowNeg = false ) const;
+    Point           GetScrPosLogic( SCCOL nWhereX, SCROW nWhereY,
                                 bool bAllowNeg = false ) const;
+
     void            DrawScenarioFrames( OutputDevice* pContentDev,
                                         SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
     void            UpdatePaintMapMode();
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1578e30..621ec01 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -686,7 +686,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
     std::auto_ptr<AutoFilterData> pData(new AutoFilterData);
     pData->maPos = ScAddress(nCol, nRow, nTab);
 
-    Point aPos = GetScrPos( nCol, nRow );
+    Point aPos = GetScrPosPix( nCol, nRow );
     long nSizeX  = 0;
     long nSizeY  = 0;
     pViewData->GetMergeSizePixel(nCol, nRow, nSizeX, nSizeY);
@@ -895,7 +895,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
 void ScGridWindow::getCellGeometry( Point& rScrPos, Size& rScrSize, SCCOL nCol, SCROW nRow ) const
 {
     // Get the screen position of the cell.
-    rScrPos = GetScrPos(nCol, nRow );
+    rScrPos = GetScrPosPix(nCol, nRow );
 
     // Get the screen size of the cell.
     long nSizeX, nSizeY;
@@ -957,7 +957,7 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange )
     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
     // The button height should not use the merged cell height, should still use single row height
     nSizeY = ScViewData::ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
-    Point aPos = GetScrPos( nCol, nRow );
+    Point aPos = GetScrPosPix( nCol, nRow );
     if ( bLayoutRTL )
         aPos.X() -= nSizeX;
     Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
@@ -1078,7 +1078,7 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelec
     long nSizeY  = 0;
     long nHeight = 0;
     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
-    Point aPos = GetScrPos( nCol, nRow );
+    Point aPos = GetScrPosPix( nCol, nRow );
     if ( bLayoutRTL )
         aPos.X() -= nSizeX;
 
@@ -1592,8 +1592,8 @@ bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, bool bAction )
             pDoc->GetEmbedded( aRange );
             if ( pViewData->GetTabNo() == aRange.aStart.Tab() )
             {
-                Point aStartPos = GetScrPos( aRange.aStart.Col(), aRange.aStart.Row() );
-                Point aEndPos   = GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1 );
+                Point aStartPos = GetScrPosPix( aRange.aStart.Col(), aRange.aStart.Row() );
+                Point aEndPos   = GetScrPosPix( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1 );
                 Point aMousePos = rMEvt.GetPosPixel();
                 if ( bLayoutRTL )
                 {
@@ -3079,7 +3079,7 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
 
             SCCOL nCurX = pViewData->GetCurX();
             SCROW nCurY = pViewData->GetCurY();
-            aMenuPos = GetScrPos( nCurX, nCurY, eWhich );
+            aMenuPos = GetScrPosPix( nCurX, nCurY, eWhich );
             long nSizeXPix;
             long nSizeYPix;
             pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix );
@@ -4632,12 +4632,12 @@ void ScGridWindow::UpdateFormulas()
 
     rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
 
-    Point aScrPos = GetScrPos( nX1, nY1 );
+    Point aScrPos = GetScrPosPix( nX1, nY1 );
     long nMirrorWidth = GetSizePixel().Width();
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
     if ( bLayoutRTL )
     {
-        long nEndPixel = GetScrPos( nX2+1, nPosY ).X();
+        long nEndPixel = GetScrPosPix( nX2+1, nPosY ).X();
         nMirrorWidth = aScrPos.X() - nEndPixel;
         aScrPos.X() = nEndPixel + 1;
     }
@@ -4774,7 +4774,7 @@ bool ScGridWindow::HitRangeFinder( const Point& rMouse, RfCorner& rCorner,
             //  zusammengefasste (einzeln/Bereich) ???
             ScAddress aAddr( nPosX, nPosY, nTab );
 
-            Point aCellStart = GetScrPos( nPosX, nPosY, eWhich );
+            Point aCellStart = GetScrPosPix( nPosX, nPosY, eWhich );
             Point aCellEnd = aCellStart;
             long nSizeXPix;
             long nSizeYPix;
@@ -5422,12 +5422,12 @@ bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRang
             Point aButtonPos;
             if ( bTextBelow )
             {
-                aButtonPos = GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1,
+                aButtonPos = GetScrPosPix( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1,
                                                     true );
             }
             else
             {
-                aButtonPos = GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(),
+                aButtonPos = GetScrPosPix( aRange.aEnd.Col()+1, aRange.aStart.Row(),
                                                     true );
                 aButtonPos.Y() -= nBHeight;
             }
@@ -5728,8 +5728,8 @@ void ScGridWindow::UpdateCopySourceOverlay()
         SCCOL nClipEndX   = p->aEnd.Col();
         SCROW nClipEndY   = p->aEnd.Row();
 
-        Point aClipStartScrPos = GetScrPos( nClipStartX, nClipStartY);
-        Point aClipEndScrPos   = GetScrPos( nClipEndX + 1, nClipEndY + 1 );
+        Point aClipStartScrPos = GetScrPosPix( nClipStartX, nClipStartY);
+        Point aClipEndScrPos   = GetScrPosPix( nClipEndX + 1, nClipEndY + 1 );
         aClipStartScrPos -= Point(1, 1);
         long nSizeXPix = aClipEndScrPos.X() - aClipStartScrPos.X();
         long nSizeYPix = aClipEndScrPos.Y() - aClipStartScrPos.Y();
@@ -5796,7 +5796,7 @@ void ScGridWindow::UpdateCursorOverlay()
 
     if ( bVis && !bOverlapped && !pViewData->HasEditView(eWhich) && pViewData->IsActive() )
     {
-        Point aScrPos = GetScrPos( nX, nY, true );
+        Point aScrPos = GetScrPosPix( nX, nY, true );
         bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
         //  completely right of/below the screen?
@@ -5954,7 +5954,7 @@ void ScGridWindow::UpdateAutoFillOverlay()
         ScDocument* pDoc = pViewData->GetDocument();
         bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
-        Point aFillPos = GetScrPos( nX, nY, true );
+        Point aFillPos = GetScrPosPix( nX, nY, true );
         long nSizeXPix;
         long nSizeYPix;
         pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
@@ -6033,7 +6033,7 @@ void ScGridWindow::UpdateDragRectOverlay()
         if (nY1 < nPosY) nY1 = nPosY;
         if (nY2 < nPosY) nY2 = nPosY;
 
-        Point aScrPos( GetScrPos( nX1, nY1 ) );
+        Point aScrPos( GetScrPosPix( nX1, nY1 ) );
 
         long nSizeXPix=0;
         long nSizeYPix=0;
@@ -6199,9 +6199,9 @@ void ScGridWindow::UpdateShrinkOverlay()
         if ( aRange.aStart.Col() <= aRange.aEnd.Col() &&
              aRange.aStart.Row() <= aRange.aEnd.Row() )
         {
-            Point aStart = GetScrPos( aRange.aStart.Col(),
+            Point aStart = GetScrPosPix( aRange.aStart.Col(),
                                                  aRange.aStart.Row() );
-            Point aEnd = GetScrPos( aRange.aEnd.Col()+1,
+            Point aEnd = GetScrPosPix( aRange.aEnd.Col()+1,
                                                aRange.aEnd.Row()+1 );
             aEnd.X() -= 1;
             aEnd.Y() -= 1;
@@ -6278,7 +6278,12 @@ void ScGridWindow::SetInRefMode( bool bInRefMode )
     SetStyle( nBits );
 }
 
-Point ScGridWindow::GetScrPos( SCCOL nWhereX, SCROW nWhereY, bool bAllowNeg ) const
+Point ScGridWindow::GetScrPosPix( SCCOL nWhereX, SCROW nWhereY, bool bAllowNeg ) const
+{
+    return LogicToPixel( GetScrPosLogic( nWhereX, nWhereY, bAllowNeg ), aPaintMapMode );
+}
+
+Point ScGridWindow::GetScrPosLogic( SCCOL nWhereX, SCROW nWhereY, bool bAllowNeg ) const
 {
     ScHSplitPos eWhichX = SC_SPLIT_LEFT;
     ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
@@ -6374,7 +6379,7 @@ Point ScGridWindow::GetScrPos( SCCOL nWhereX, SCROW nWhereY, bool bAllowNeg ) co
         nScrPosX = aScrSize.Width() - 1 - nScrPosX;
     }
 
-    return LogicToPixel( Point( nScrPosX, nScrPosY ), aPaintMapMode );
+    return Point( nScrPosX, nScrPosY );
 }
 
 
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 1d7c7e3..ef9c20f 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -114,7 +114,7 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent&
 {
     ScDocument* pDoc = pViewData->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
-    Point aScrPos  = GetScrPos(nCol, nRow );
+    Point aScrPos  = GetScrPosPix(nCol, nRow );
     Point aDiffPix = rMEvt.GetPosPixel();
 
     aDiffPix -= aScrPos;
@@ -354,7 +354,7 @@ bool ScGridWindow::DPTestFieldPopupArrow(
     bool bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
 
     // Get the geometry of the cell.
-    Point aScrPos = GetScrPos(rPos.Col(), rPos.Row() );
+    Point aScrPos = GetScrPosPix(rPos.Col(), rPos.Row() );
     long nSizeX, nSizeY;
     pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
     Size aScrSize(nSizeX-1, nSizeY-1);
@@ -669,8 +669,8 @@ sal_uInt16 ScGridWindow::HitPageBreak( const Point& rMouse, ScRange* pSource,
         SCsCOL nPosX;
         SCsROW nPosY;
         pViewData->GetPosFromPixel( nMouseX, nMouseY, eWhich, nPosX, nPosY );
-        Point aTL = GetScrPos( nPosX, nPosY );
-        Point aBR = GetScrPos( nPosX+1, nPosY+1 );
+        Point aTL = GetScrPosPix( nPosX, nPosY );
+        Point aBR = GetScrPosPix( nPosX+1, nPosY+1 );
 
         //  Horizontal mehr Toleranz als vertikal, weil mehr Platz ist
         if ( nMouseX <= aTL.X() + 4 )
diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx
index 9f5d0bb..c8ff879 100644
--- a/sc/source/ui/view/gridwin3.cxx
+++ b/sc/source/ui/view/gridwin3.cxx
@@ -300,7 +300,7 @@ void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddres
         if(rOpts.GetOption( VOPT_ANCHOR ))
         {
             bool bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
-            Point aPos = GetScrPos( rAddress.Col(), rAddress.Row(), true );
+            Point aPos = GetScrPosPix( rAddress.Col(), rAddress.Row(), true );
             aPos = PixelToLogic(aPos);
             rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? HDL_ANCHOR_TR : HDL_ANCHOR));
         }
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 3128f1e..ef9ffcb 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -215,9 +215,9 @@ void ScGridWindow::DrawScenarioFrames( OutputDevice* pContentDev, SCCOL nX1, SCR
 
             if ( aRange.Intersects( aViewRange ) )          //! Platz fuer Text/Button?
             {
-                Point aStartPos = GetScrPos(
+                Point aStartPos = GetScrPosLogic(
                                     aRange.aStart.Col(), aRange.aStart.Row(), true );
-                Point aEndPos = GetScrPos(
+                Point aEndPos = GetScrPosLogic(
                                     aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, true );
                 //  on the grid:
                 aStartPos.X() -= nLayoutSign;
@@ -512,13 +512,13 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 
     rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
 
-    Point aScrPos = GetScrPos( nX1, nY1 );
+    Point aScrPos = GetScrPosLogic( nX1, nY1 );
     long nMirrorWidth = GetSizePixel().Width();
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
     long nLayoutSign = bLayoutRTL ? -1 : 1;
     if ( bLayoutRTL )
     {
-        long nEndPixel = GetScrPos( nX2+1, maVisibleRange.mnRow1 ).X();
+        long nEndPixel = GetScrPosLogic( nX2+1, maVisibleRange.mnRow1 ).X();
         nMirrorWidth = aScrPos.X() - nEndPixel;
         aScrPos.X() = nEndPixel + 1;
     }
@@ -929,8 +929,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         SCROW nRow2 = pViewData->GetEditEndRow();
         SetLineColor();
         SetFillColor( pEditView->GetBackgroundColor() );
-        Point aStart = GetScrPos( nCol1, nRow1 );
-        Point aEnd = GetScrPos( nCol2+1, nRow2+1 );
+        Point aStart = GetScrPosPix( nCol1, nRow1 );
+        Point aEnd = GetScrPosPix( nCol2+1, nRow2+1 );
         aEnd.X() -= 2 * nLayoutSign;        // don't overwrite grid
         aEnd.Y() -= 2;
         DrawRect( Rectangle( aStart,aEnd ) );
@@ -1088,9 +1088,9 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                 else
                     pContentDev->SetFillColor( aManual );
 
-                Point aStart = GetScrPos(
+                Point aStart = GetScrPosLogic(
                                     aRange.aStart.Col(), aRange.aStart.Row(), true );
-                Point aEnd = GetScrPos(
+                Point aEnd = GetScrPosLogic(
                                     aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, true );
                 aStart.X() -= 2;
                 aStart.Y() -= 2;
@@ -1124,7 +1124,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                             pContentDev->SetFillColor( aManual );
                         else
                             pContentDev->SetFillColor( aAutomatic );
-                        Point aBreak = GetScrPos(
+                        Point aBreak = GetScrPosLogic(
                                         nBreak, aRange.aStart.Row(), true );
                         pContentDev->DrawRect( Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) );
                     }
@@ -1143,7 +1143,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                             pContentDev->SetFillColor( aManual );
                         else
                             pContentDev->SetFillColor( aAutomatic );
-                        Point aBreak = GetScrPos(
+                        Point aBreak = GetScrPosLogic(
                                         aRange.aStart.Col(), nBreak, true );
                         pContentDev->DrawRect( Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) );
                     }
@@ -1163,9 +1163,9 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                             SCCOL nPrEndX = pColEnd[nColPos];
                             if ( nPrEndX >= nX1 && nPrStartX <= nX2 )
                             {
-                                Point aPageStart = GetScrPos(
+                                Point aPageStart = GetScrPosLogic(
                                                         nPrStartX, nPrStartY, true );
-                                Point aPageEnd = GetScrPos(
+                                Point aPageEnd = GetScrPosLogic(
                                                         nPrEndX+1,nPrEndY+1, true );
 
                                 long nPageNo = rData.GetFirstPage();
@@ -1326,7 +1326,7 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, Out
                     pDoc->ExtendOverlapped(nStartCol, nStartRow,nCol, nRow, nTab);//get nStartCol,nStartRow
                     pViewData->GetMergeSizePixel( nStartCol, nStartRow, nSizeX, nSizeY );//get nSizeX
                     nSizeY = ScViewData::ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
-                    Point aScrPos = GetScrPos( nCol, nRow );
+                    Point aScrPos = GetScrPosLogic( nCol, nRow );
 
                     aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);
                     aCellBtn.setPopupLeft(bLayoutRTL);   // #i114944# AutoFilter button is left-aligned in RTL
@@ -1348,7 +1348,7 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, Out
                 if (pInfo->bHOverlapped || pInfo->bVOverlapped)
                     continue;
 
-                Point aScrPos = GetScrPos( nCol, nRow );
+                Point aScrPos = GetScrPosLogic( nCol, nRow );
                 long nSizeX;
                 long nSizeY;
                 pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
@@ -1421,7 +1421,7 @@ Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos )
     if ( nCellSizeY < aBtnSize.Height() )
         aBtnSize.Height() = nCellSizeY;
 
-    Point aPos = GetScrPos( nCol, nRow, true );
+    Point aPos = GetScrPosPix( nCol, nRow, true );
     aPos.X() += nCellSizeX * nLayoutSign;               // start of next cell
     if (!bNextCell)
         aPos.X() -= aBtnSize.Width() * nLayoutSign;     // right edge of cell if next cell not available
@@ -1526,7 +1526,7 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
 
     ScInvertMerger aInvert( &rPixelRects );
 
-    Point aScrPos = GetScrPos( nX1, nY1 );
+    Point aScrPos = GetScrPosPix( nX1, nY1 );
     long nScrY = aScrPos.Y();
     bool bWasHidden = false;
     for (SCROW nY=nY1; nY<=nY2; nY++)
@@ -1611,7 +1611,7 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
                                 ScMergeAttr* pMerge = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
                                 if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
                                 {
-                                    Point aEndPos = GetScrPos(
+                                    Point aEndPos = GetScrPosPix(
                                             nThisX + pMerge->GetColMerge(),
                                             nThisY + pMerge->GetRowMerge() );
                                     if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
commit b07f066c87eebff6a2a5d27f7725aa2c27c2d962
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Thu Aug 7 21:33:40 2014 +0200

    Introduce GetScrPos to ScGridWin.
    
    The ViewData version still uses old scaling and is therefore problematic.
    
    Change-Id: I42d904251d8bbe1804fd099306d54045c9cf0c92

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index dfb9b84..e0bff21 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -203,6 +203,8 @@ class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHe
     bool                    bAutoMarkVisible:1;
     bool                    bListValButton:1;
 
+    MapMode                 aPaintMapMode;
+
     DECL_LINK( PopupModeEndHdl, void* );
     DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
 
@@ -304,6 +306,15 @@ protected:
     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     virtual void    StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
 
+private:
+    void            getCellGeometry( Point& rScrPos, Size& rScrSize,
+                                     SCCOL nCol, SCROW nRow ) const;
+    Point           GetScrPos( SCCOL nWhereX, SCROW nWhereY,
+                                bool bAllowNeg = false ) const;
+    void            DrawScenarioFrames( OutputDevice* pContentDev,
+                                        SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
+    void            UpdatePaintMapMode();
+
 public:
     enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty, SortAscending, SortDescending };
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index bf777ae..1578e30 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -686,7 +686,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
     std::auto_ptr<AutoFilterData> pData(new AutoFilterData);
     pData->maPos = ScAddress(nCol, nRow, nTab);
 
-    Point aPos = pViewData->GetScrPos(nCol, nRow, eWhich);
+    Point aPos = GetScrPos( nCol, nRow );
     long nSizeX  = 0;
     long nSizeY  = 0;
     pViewData->GetMergeSizePixel(nCol, nRow, nSizeX, nSizeY);
@@ -892,12 +892,10 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
     pDBData->SetQueryParam(aParam);
 }
 
-namespace {
-
-void getCellGeometry(Point& rScrPos, Size& rScrSize, const ScViewData* pViewData, SCCOL nCol, SCROW nRow, ScSplitPos eWhich)
+void ScGridWindow::getCellGeometry( Point& rScrPos, Size& rScrSize, SCCOL nCol, SCROW nRow ) const
 {
     // Get the screen position of the cell.
-    rScrPos = pViewData->GetScrPos(nCol, nRow, eWhich);
+    rScrPos = GetScrPos(nCol, nRow );
 
     // Get the screen size of the cell.
     long nSizeX, nSizeY;
@@ -905,8 +903,6 @@ void getCellGeometry(Point& rScrPos, Size& rScrSize, const ScViewData* pViewData
     rScrSize = Size(nSizeX-1, nSizeY-1);
 }
 
-}
-
 void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
 {
     if (nCol == 0)
@@ -920,7 +916,7 @@ void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
 
     Point aScrPos;
     Size aScrSize;
-    getCellGeometry(aScrPos, aScrSize, pViewData, nCol, nRow, eWhich);
+    getCellGeometry(aScrPos, aScrSize, nCol, nRow);
     DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, ScAddress(nCol-1, nRow, nTab), pDPObj);
 }
 
@@ -933,7 +929,7 @@ void ScGridWindow::LaunchDPFieldMenu( SCCOL nCol, SCROW nRow )
 
     Point aScrPos;
     Size aScrSize;
-    getCellGeometry(aScrPos, aScrSize, pViewData, nCol, nRow, eWhich);
+    getCellGeometry(aScrPos, aScrSize, nCol, nRow);
     DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, ScAddress(nCol, nRow, nTab), pDPObj);
 }
 
@@ -961,7 +957,7 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange )
     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
     // The button height should not use the merged cell height, should still use single row height
     nSizeY = ScViewData::ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
-    Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+    Point aPos = GetScrPos( nCol, nRow );
     if ( bLayoutRTL )
         aPos.X() -= nSizeX;
     Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
@@ -1082,7 +1078,7 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelec
     long nSizeY  = 0;
     long nHeight = 0;
     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
-    Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+    Point aPos = GetScrPos( nCol, nRow );
     if ( bLayoutRTL )
         aPos.X() -= nSizeX;
 
@@ -1596,8 +1592,8 @@ bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, bool bAction )
             pDoc->GetEmbedded( aRange );
             if ( pViewData->GetTabNo() == aRange.aStart.Tab() )
             {
-                Point aStartPos = pViewData->GetScrPos( aRange.aStart.Col(), aRange.aStart.Row(), eWhich );
-                Point aEndPos   = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich );
+                Point aStartPos = GetScrPos( aRange.aStart.Col(), aRange.aStart.Row() );
+                Point aEndPos   = GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1 );
                 Point aMousePos = rMEvt.GetPosPixel();
                 if ( bLayoutRTL )
                 {
@@ -3083,7 +3079,7 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
 
             SCCOL nCurX = pViewData->GetCurX();
             SCROW nCurY = pViewData->GetCurY();
-            aMenuPos = pViewData->GetScrPos( nCurX, nCurY, eWhich, true );
+            aMenuPos = GetScrPos( nCurX, nCurY, eWhich );
             long nSizeXPix;
             long nSizeYPix;
             pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix );
@@ -4636,12 +4632,12 @@ void ScGridWindow::UpdateFormulas()
 
     rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
 
-    Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+    Point aScrPos = GetScrPos( nX1, nY1 );
     long nMirrorWidth = GetSizePixel().Width();
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
     if ( bLayoutRTL )
     {
-        long nEndPixel = pViewData->GetScrPos( nX2+1, nPosY, eWhich ).X();
+        long nEndPixel = GetScrPos( nX2+1, nPosY ).X();
         nMirrorWidth = aScrPos.X() - nEndPixel;
         aScrPos.X() = nEndPixel + 1;
     }
@@ -4778,7 +4774,7 @@ bool ScGridWindow::HitRangeFinder( const Point& rMouse, RfCorner& rCorner,
             //  zusammengefasste (einzeln/Bereich) ???
             ScAddress aAddr( nPosX, nPosY, nTab );
 
-            Point aCellStart = pViewData->GetScrPos( nPosX, nPosY, eWhich, true );
+            Point aCellStart = GetScrPos( nPosX, nPosY, eWhich );
             Point aCellEnd = aCellStart;
             long nSizeXPix;
             long nSizeYPix;
@@ -5426,13 +5422,13 @@ bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRang
             Point aButtonPos;
             if ( bTextBelow )
             {
-                aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1,
-                                                    eWhich, true );
+                aButtonPos = GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1,
+                                                    true );
             }
             else
             {
-                aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(),
-                                                    eWhich, true );
+                aButtonPos = GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(),
+                                                    true );
                 aButtonPos.Y() -= nBHeight;
             }
             if ( bLayoutRTL )
@@ -5732,8 +5728,8 @@ void ScGridWindow::UpdateCopySourceOverlay()
         SCCOL nClipEndX   = p->aEnd.Col();
         SCROW nClipEndY   = p->aEnd.Row();
 
-        Point aClipStartScrPos = pViewData->GetScrPos( nClipStartX, nClipStartY, eWhich );
-        Point aClipEndScrPos   = pViewData->GetScrPos( nClipEndX + 1, nClipEndY + 1, eWhich );
+        Point aClipStartScrPos = GetScrPos( nClipStartX, nClipStartY);
+        Point aClipEndScrPos   = GetScrPos( nClipEndX + 1, nClipEndY + 1 );
         aClipStartScrPos -= Point(1, 1);
         long nSizeXPix = aClipEndScrPos.X() - aClipStartScrPos.X();
         long nSizeYPix = aClipEndScrPos.Y() - aClipStartScrPos.Y();
@@ -5800,7 +5796,7 @@ void ScGridWindow::UpdateCursorOverlay()
 
     if ( bVis && !bOverlapped && !pViewData->HasEditView(eWhich) && pViewData->IsActive() )
     {
-        Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true );
+        Point aScrPos = GetScrPos( nX, nY, true );
         bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
         //  completely right of/below the screen?
@@ -5958,7 +5954,7 @@ void ScGridWindow::UpdateAutoFillOverlay()
         ScDocument* pDoc = pViewData->GetDocument();
         bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
-        Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, true );
+        Point aFillPos = GetScrPos( nX, nY, true );
         long nSizeXPix;
         long nSizeYPix;
         pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
@@ -6037,7 +6033,7 @@ void ScGridWindow::UpdateDragRectOverlay()
         if (nY1 < nPosY) nY1 = nPosY;
         if (nY2 < nPosY) nY2 = nPosY;
 
-        Point aScrPos( pViewData->GetScrPos( nX1, nY1, eWhich ) );
+        Point aScrPos( GetScrPos( nX1, nY1 ) );
 
         long nSizeXPix=0;
         long nSizeYPix=0;
@@ -6203,10 +6199,10 @@ void ScGridWindow::UpdateShrinkOverlay()
         if ( aRange.aStart.Col() <= aRange.aEnd.Col() &&
              aRange.aStart.Row() <= aRange.aEnd.Row() )
         {
-            Point aStart = pViewData->GetScrPos( aRange.aStart.Col(),
-                                                 aRange.aStart.Row(), eWhich );
-            Point aEnd = pViewData->GetScrPos( aRange.aEnd.Col()+1,
-                                               aRange.aEnd.Row()+1, eWhich );
+            Point aStart = GetScrPos( aRange.aStart.Col(),
+                                                 aRange.aStart.Row() );
+            Point aEnd = GetScrPos( aRange.aEnd.Col()+1,
+                                               aRange.aEnd.Row()+1 );
             aEnd.X() -= 1;
             aEnd.Y() -= 1;
 
@@ -6282,4 +6278,104 @@ void ScGridWindow::SetInRefMode( bool bInRefMode )
     SetStyle( nBits );
 }
 
+Point ScGridWindow::GetScrPos( SCCOL nWhereX, SCROW nWhereY, bool bAllowNeg ) const
+{
+    ScHSplitPos eWhichX = SC_SPLIT_LEFT;
+    ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
+    switch( eWhich )
+    {
+        case SC_SPLIT_TOPLEFT:
+            eWhichX = SC_SPLIT_LEFT;
+            eWhichY = SC_SPLIT_TOP;
+            break;
+        case SC_SPLIT_TOPRIGHT:
+            eWhichX = SC_SPLIT_RIGHT;
+            eWhichY = SC_SPLIT_TOP;
+            break;
+        case SC_SPLIT_BOTTOMLEFT:
+            eWhichX = SC_SPLIT_LEFT;
+            eWhichY = SC_SPLIT_BOTTOM;
+            break;
+        case SC_SPLIT_BOTTOMRIGHT:
+            eWhichX = SC_SPLIT_RIGHT;
+            eWhichY = SC_SPLIT_BOTTOM;
+            break;
+    }
+
+    ScDocument* pDoc = pViewData->GetDocument();
+
+    Size aScrSize = PixelToLogic( GetSizePixel() );
+
+    sal_uInt16 nTSize;
+
+    SCCOL   nPosX = pViewData->GetPosX(eWhichX);
+    SCCOL   nX;
+
+    SCTAB nTab = pViewData->GetTabNo();
+
+    long nScrPosX=0;
+    if (nWhereX >= nPosX)
+        for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++)
+        {
+            if ( nX > MAXCOL )
+                nScrPosX = 65535;
+            else
+            {
+                nTSize = pDoc->GetColWidth( nX, nTab );
+                nScrPosX += nTSize;
+            }
+        }
+    else if (bAllowNeg)
+        for (nX=nPosX; nX>nWhereX;)
+        {
+            --nX;
+            nTSize = pDoc->GetColWidth( nX, nTab );
+            nScrPosX -= nTSize;
+        }
+
+    SCROW   nPosY = pViewData->GetPosY(eWhichY);
+    SCROW   nY;
+
+    long nScrPosY=0;
+    if (nWhereY >= nPosY)
+        for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++)
+        {
+            if ( nY > MAXROW )
+                nScrPosY = 65535;
+            else
+            {
+                nTSize = pDoc->GetRowHeight( nY, nTab );
+                if (nTSize)
+                {
+                    nScrPosY += nTSize;
+                }
+                else if ( nY < MAXROW )
+                {
+                    // skip multiple hidden rows (forward only for now)
+                    SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTab );
+                    if ( nNext > MAXROW )
+                        nY = MAXROW;
+                    else
+                        nY = nNext - 1;     // +=nDir advances to next visible row
+                }
+            }
+        }
+    else if (bAllowNeg)
+        for (nY=nPosY; nY>nWhereY;)
+        {
+            --nY;
+            nTSize = pDoc->GetRowHeight( nY, nTab );
+            nScrPosY -= nTSize;
+        }
+
+    if ( pDoc->IsLayoutRTL( nTab ) )
+    {
+        //  mirror horizontal position
+        nScrPosX = aScrSize.Width() - 1 - nScrPosX;
+    }
+
+    return LogicToPixel( Point( nScrPosX, nScrPosY ), aPaintMapMode );
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 6578bd6..1d7c7e3 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -114,7 +114,7 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent&
 {
     ScDocument* pDoc = pViewData->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
-    Point aScrPos  = pViewData->GetScrPos(nCol, nRow, eWhich);
+    Point aScrPos  = GetScrPos(nCol, nRow );
     Point aDiffPix = rMEvt.GetPosPixel();
 
     aDiffPix -= aScrPos;
@@ -354,7 +354,7 @@ bool ScGridWindow::DPTestFieldPopupArrow(
     bool bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
 
     // Get the geometry of the cell.
-    Point aScrPos = pViewData->GetScrPos(rPos.Col(), rPos.Row(), eWhich);
+    Point aScrPos = GetScrPos(rPos.Col(), rPos.Row() );
     long nSizeX, nSizeY;
     pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
     Size aScrSize(nSizeX-1, nSizeY-1);
@@ -669,8 +669,8 @@ sal_uInt16 ScGridWindow::HitPageBreak( const Point& rMouse, ScRange* pSource,
         SCsCOL nPosX;
         SCsROW nPosY;
         pViewData->GetPosFromPixel( nMouseX, nMouseY, eWhich, nPosX, nPosY );
-        Point aTL = pViewData->GetScrPos( nPosX, nPosY, eWhich );
-        Point aBR = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich );
+        Point aTL = GetScrPos( nPosX, nPosY );
+        Point aBR = GetScrPos( nPosX+1, nPosY+1 );
 
         //  Horizontal mehr Toleranz als vertikal, weil mehr Platz ist
         if ( nMouseX <= aTL.X() + 4 )
diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx
index e9ac6ca..9f5d0bb 100644
--- a/sc/source/ui/view/gridwin3.cxx
+++ b/sc/source/ui/view/gridwin3.cxx
@@ -300,7 +300,7 @@ void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddres
         if(rOpts.GetOption( VOPT_ANCHOR ))
         {
             bool bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
-            Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, true );
+            Point aPos = GetScrPos( rAddress.Col(), rAddress.Row(), true );
             aPos = PixelToLogic(aPos);
             rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? HDL_ANCHOR_TR : HDL_ANCHOR));
         }
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 60a6f47..3128f1e 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -178,8 +178,7 @@ static void lcl_DrawOneFrame( OutputDevice* pDev, const Rectangle& rInnerPixel,
     pDev->DrawRect( aOuter );
 }
 
-static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, ScSplitPos eWhich,
-                            SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
+void ScGridWindow::DrawScenarioFrames( OutputDevice* pContentDev, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
 {
     ScDocument* pDoc = pViewData->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
@@ -216,10 +215,10 @@ static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, S
 
             if ( aRange.Intersects( aViewRange ) )          //! Platz fuer Text/Button?
             {
-                Point aStartPos = pViewData->GetScrPos(
-                                    aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true );
-                Point aEndPos = pViewData->GetScrPos(
-                                    aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, true );
+                Point aStartPos = GetScrPos(
+                                    aRange.aStart.Col(), aRange.aStart.Row(), true );
+                Point aEndPos = GetScrPos(
+                                    aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, true );
                 //  on the grid:
                 aStartPos.X() -= nLayoutSign;
                 aStartPos.Y() -= 1;
@@ -244,7 +243,7 @@ static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, S
 
                 //! eigener Text "(keins)" statt "(leer)" ???
 
-                lcl_DrawOneFrame( pDev, Rectangle( aStartPos, aEndPos ),
+                lcl_DrawOneFrame( pContentDev, Rectangle( aStartPos, aEndPos ),
                                     aCurrent, aColor, bTextBelow,
                                     pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomY(),
                                     pDoc, pViewData, bLayoutRTL );
@@ -301,14 +300,26 @@ void ScGridWindow::PrePaint()
     }
 }
 
+void ScGridWindow::UpdatePaintMapMode()
+{
+    aPaintMapMode = GetMapMode();
+    aPaintMapMode.SetMapUnit( MAP_TWIP );
+    aPaintMapMode.SetScaleX( pViewData->GetZoomX() * Fraction(0.96) );
+    aPaintMapMode.SetScaleY( pViewData->GetZoomY() * Fraction(0.96) );
+}
+
 void ScGridWindow::Paint( const Rectangle& rRect )
 {
-    MapMode aMapMode( GetMapMode() );
-    aMapMode.SetMapUnit( MAP_TWIP );
-    aMapMode.SetScaleX( pViewData->GetZoomX() * Fraction(0.96) );
-    aMapMode.SetScaleY( pViewData->GetZoomY() * Fraction(0.96) );
-    SetMapMode( aMapMode );
+    const MapMode aOriginalMapMode = GetMapMode();
+    UpdatePaintMapMode();
+    SetMapMode( aPaintMapMode );
     Paint( rRect, this );
+    // All other functions except for Paint(Rectangle, OutputDevice)
+    // work in pixel coordinates, hence it is simplest to only set
+    // our logic-coordinate mapping only for actual painting, and
+    // reset it for all other uses.
+    SetMapMode( aOriginalMapMode );
+    EnableMapMode( false );
 }
 
 void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
@@ -501,13 +512,13 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 
     rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
 
-    Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+    Point aScrPos = GetScrPos( nX1, nY1 );
     long nMirrorWidth = GetSizePixel().Width();
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
     long nLayoutSign = bLayoutRTL ? -1 : 1;
     if ( bLayoutRTL )
     {
-        long nEndPixel = pViewData->GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ).X();
+        long nEndPixel = GetScrPos( nX2+1, maVisibleRange.mnRow1 ).X();
         nMirrorWidth = aScrPos.X() - nEndPixel;
         aScrPos.X() = nEndPixel + 1;
     }
@@ -825,7 +836,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
                 aOutputData.DrawChangeTrack();
 
             if ( bHasScenario )
-                lcl_DrawScenarioFrames( pContentDev, pViewData, eWhich, nX1,nY1,nX2,nY2 );
+                DrawScenarioFrames( pContentDev, nX1,nY1,nX2,nY2 );
 
             lcl_DrawHighlight( aOutputData, pViewData, rHigh );
 
@@ -918,8 +929,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
         SCROW nRow2 = pViewData->GetEditEndRow();
         SetLineColor();
         SetFillColor( pEditView->GetBackgroundColor() );
-        Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
-        Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
+        Point aStart = GetScrPos( nCol1, nRow1 );
+        Point aEnd = GetScrPos( nCol2+1, nRow2+1 );
         aEnd.X() -= 2 * nLayoutSign;        // don't overwrite grid
         aEnd.Y() -= 2;
         DrawRect( Rectangle( aStart,aEnd ) );
@@ -1077,10 +1088,10 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                 else
                     pContentDev->SetFillColor( aManual );
 
-                Point aStart = pViewData->GetScrPos(
-                                    aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true );
-                Point aEnd = pViewData->GetScrPos(
-                                    aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, true );
+                Point aStart = GetScrPos(
+                                    aRange.aStart.Col(), aRange.aStart.Row(), true );
+                Point aEnd = GetScrPos(
+                                    aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, true );
                 aStart.X() -= 2;
                 aStart.Y() -= 2;
 
@@ -1113,8 +1124,8 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                             pContentDev->SetFillColor( aManual );
                         else
                             pContentDev->SetFillColor( aAutomatic );
-                        Point aBreak = pViewData->GetScrPos(
-                                        nBreak, aRange.aStart.Row(), eWhich, true );
+                        Point aBreak = GetScrPos(
+                                        nBreak, aRange.aStart.Row(), true );
                         pContentDev->DrawRect( Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) );
                     }
                 }
@@ -1132,8 +1143,8 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                             pContentDev->SetFillColor( aManual );
                         else
                             pContentDev->SetFillColor( aAutomatic );
-                        Point aBreak = pViewData->GetScrPos(
-                                        aRange.aStart.Col(), nBreak, eWhich, true );
+                        Point aBreak = GetScrPos(
+                                        aRange.aStart.Col(), nBreak, true );
                         pContentDev->DrawRect( Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) );
                     }
                 }
@@ -1152,10 +1163,10 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                             SCCOL nPrEndX = pColEnd[nColPos];
                             if ( nPrEndX >= nX1 && nPrStartX <= nX2 )
                             {
-                                Point aPageStart = pViewData->GetScrPos(
-                                                        nPrStartX, nPrStartY, eWhich, true );
-                                Point aPageEnd = pViewData->GetScrPos(
-                                                        nPrEndX+1,nPrEndY+1, eWhich, true );
+                                Point aPageStart = GetScrPos(
+                                                        nPrStartX, nPrStartY, true );
+                                Point aPageEnd = GetScrPos(
+                                                        nPrEndX+1,nPrEndY+1, true );
 
                                 long nPageNo = rData.GetFirstPage();
                                 if ( rData.IsTopDown() )
@@ -1315,7 +1326,7 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, Out
                     pDoc->ExtendOverlapped(nStartCol, nStartRow,nCol, nRow, nTab);//get nStartCol,nStartRow
                     pViewData->GetMergeSizePixel( nStartCol, nStartRow, nSizeX, nSizeY );//get nSizeX
                     nSizeY = ScViewData::ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
-                    Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+                    Point aScrPos = GetScrPos( nCol, nRow );
 
                     aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);
                     aCellBtn.setPopupLeft(bLayoutRTL);   // #i114944# AutoFilter button is left-aligned in RTL
@@ -1337,7 +1348,7 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, Out
                 if (pInfo->bHOverlapped || pInfo->bVOverlapped)
                     continue;
 
-                Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+                Point aScrPos = GetScrPos( nCol, nRow );
                 long nSizeX;
                 long nSizeY;
                 pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
@@ -1410,7 +1421,7 @@ Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos )
     if ( nCellSizeY < aBtnSize.Height() )
         aBtnSize.Height() = nCellSizeY;
 
-    Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich, true );
+    Point aPos = GetScrPos( nCol, nRow, true );
     aPos.X() += nCellSizeX * nLayoutSign;               // start of next cell
     if (!bNextCell)
         aPos.X() -= aBtnSize.Width() * nLayoutSign;     // right edge of cell if next cell not available
@@ -1515,7 +1526,7 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
 
     ScInvertMerger aInvert( &rPixelRects );
 
-    Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+    Point aScrPos = GetScrPos( nX1, nY1 );
     long nScrY = aScrPos.Y();
     bool bWasHidden = false;
     for (SCROW nY=nY1; nY<=nY2; nY++)
@@ -1600,9 +1611,9 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
                                 ScMergeAttr* pMerge = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
                                 if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
                                 {
-                                    Point aEndPos = pViewData->GetScrPos(
+                                    Point aEndPos = GetScrPos(
                                             nThisX + pMerge->GetColMerge(),
-                                            nThisY + pMerge->GetRowMerge(), eWhich );
+                                            nThisY + pMerge->GetRowMerge() );
                                     if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
                                     {
                                         aInvert.AddRect( Rectangle( nScrX,nScrY,
commit ff41179619156a1ffaf6026489e68b06b7e0f46d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Aug 5 19:32:51 2014 +0200

    Only use logic mapping during paint for col/rowbars.
    
    Change-Id: I12e59b94f73eea18d0d407d9898c59b8d68eb4a2

diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 2345473..c25f661 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -271,7 +271,8 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
     }
 
     ScViewData& rViewData = pViewSh->GetViewData();
-    MapMode aMapMode( GetMapMode() );
+    const MapMode aOriginalMapMode = GetMapMode();
+    MapMode aMapMode = aOriginalMapMode;
     aMapMode.SetMapUnit( MAP_TWIP );
     aMapMode.SetScaleX( rViewData.GetZoomX() * Fraction(0.96) );
     aMapMode.SetScaleY( rViewData.GetZoomY() * Fraction(0.96) );
@@ -592,10 +593,10 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
                                 aTxtPos = LogicToPixel( aTxtPos );
                                 // Text is in pixels, so easiest just to map that way
                                 // only here.
-                                const MapMode aOriginalMapMode( GetMapMode() );
-                                SetMapMode( MapMode( MAP_PIXEL ) );
-                                DrawText( aTxtPos, aString );
+                                const MapMode aCurrentMode( GetMapMode() );
                                 SetMapMode( aOriginalMapMode );
+                                DrawText( aTxtPos, aString );
+                                SetMapMode( aCurrentMode );
                             }
                             break;
                     }
@@ -611,6 +612,8 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
 
         aGrid.Flush();
     }
+
+    SetMapMode( aOriginalMapMode );
 }
 
 SCCOLROW ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, bool& rBorder ) const
@@ -620,9 +623,10 @@ SCCOLROW ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, bool& rBorder )
     SCCOLROW    nHitNo = nPos;
     SCCOLROW    nEntryNo = 1 + nPos;
     long    nScrPos;
-    long    nMousePos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
+    long    nMousePos = bVertical ? PixelToLogic(rMEvt.GetPosPixel()).Y() :
+                                    PixelToLogic(rMEvt.GetPosPixel()).X();
     long    nDif;
-    Size    aSize = GetOutputSizePixel();
+    Size    aSize = PixelToLogic(GetOutputSizePixel());
     long    nWinSize = bVertical ? aSize.Height() : aSize.Width();
 
     bool bLayoutRTL = IsLayoutRTL();


More information about the Libreoffice-commits mailing list