sc/inc/docuno.hxx              |   15 +--
 sc/source/ui/inc/gridwin.hxx   |   12 ++
 sc/source/ui/inc/output.hxx    |    1 
 sc/source/ui/unoobj/docuno.cxx |   30 ++++++
 sc/source/ui/view/gridwin.cxx  |   20 ++++
 sc/source/ui/view/gridwin4.cxx |  197 +++++++++++++++++------------------------
 sc/source/ui/view/output3.cxx  |    3 
 7 files changed, 156 insertions(+), 122 deletions(-)

New commits:
commit b256187042fbcba5d4a1047fc8dccf6693d4b823
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Sat Mar 7 00:48:03 2015 +0100

    sc tiled mouse events: Proof-of-concept.
    
    One has to click & press enter to be able to type into the cell.  The typing
    is visible only in the top left tile, but even in the other tiles, the text
    gets there - when you manage to invalidate everything, the text appears.
    
    Change-Id: I7c9c0a52949a514eb3de7a7fe64f11597377d39f

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index f277efc..ab7b6e9 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -368,7 +368,7 @@ public:
     virtual sal_Int32 SAL_CALL getFormulaCellNumberLimit()
                                 throw 
(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
-    // @see vcl::ITiledRenderable::paintTile().
+    /// @see vcl::ITiledRenderable::paintTile().
     virtual void paintTile( VirtualDevice& rDevice,
                             int nOutputWidth,
                             int nOutputHeight,
@@ -377,21 +377,24 @@ public:
                             long nTileWidth,
                             long nTileHeight ) SAL_OVERRIDE;
 
-    // @see vcl::ITiledRenderable::getDocumentSize().
+    /// @see vcl::ITiledRenderable::getDocumentSize().
     virtual Size getDocumentSize() SAL_OVERRIDE;
 
-    // @see vcl::ITiledRenderable::setPart().
+    /// @see vcl::ITiledRenderable::setPart().
     virtual void setPart(int nPart) SAL_OVERRIDE;
 
-    // @see vcl::ITiledRenderable::getPart().
+    /// @see vcl::ITiledRenderable::getPart().
     virtual int getPart() SAL_OVERRIDE;
 
-    // @see vcl::ITiledRenderable::getParts().
+    /// @see vcl::ITiledRenderable::getParts().
     virtual int getParts() SAL_OVERRIDE;
 
-    // @see vcl::ITiledRenderable::registerCallback().
+    /// @see vcl::ITiledRenderable::registerCallback().
     virtual void registerCallback(LibreOfficeKitCallback pCallback, void* 
pData) SAL_OVERRIDE;
 
+    /// @see vcl::ITiledRenderable::postMouseEvent().
+    virtual void postMouseEvent(int nType, int nX, int nY, int nCount) 
SAL_OVERRIDE;
+
     /// @see vcl::ITiledRenderable::initializeForTiledRendering().
     virtual void initializeForTiledRendering() SAL_OVERRIDE;
 };
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 7bc053d..56498ab 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -325,6 +325,12 @@ public:
     /// @see OutputDevice::LogicInvalidate().
     void LogicInvalidate(const ::vcl::Region* pRegion) SAL_OVERRIDE;
 
+    /// Same as MouseButtonDown(), but coordinates are in logic unit.
+    void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+
+    /// Same as MouseButtonUp(), but coordinates are in logic unit.
+    void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
+
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
 
     void            FakeButtonUp();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d8697d4..eb22350 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -27,6 +27,7 @@
 #include <svx/svxids.hrc>
 #include <svx/unoshape.hxx>
 
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <officecfg/Office/Common.hxx>
 #include <officecfg/Office/Calc.hxx>
 #include <svl/numuno.hxx>
@@ -518,6 +519,35 @@ void ScModelObj::registerCallback(LibreOfficeKitCallback 
pCallback, void* pData)
     
pDocShell->GetDocument().GetDrawLayer()->registerLibreOfficeKitCallback(pCallback,
 pData);
 }
 
+void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount)
+{
+    SolarMutexGuard aGuard;
+
+    // There seems to be no clear way of getting the grid window for this
+    // particular document, hence we need to hope we get the right window.
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+    if (!pGridWindow)
+        return;
+
+    // Calc operates in pixels...
+    MouseEvent aEvent(Point(nX / TWIPS_PER_PIXEL, nY / TWIPS_PER_PIXEL), 
nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
+
+    switch (nType)
+    {
+    case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
+        pGridWindow->LogicMouseButtonDown(aEvent);
+        break;
+    case LOK_MOUSEEVENT_MOUSEBUTTONUP:
+        pGridWindow->LogicMouseButtonUp(aEvent);
+        break;
+    default:
+        assert(false);
+        break;
+    }
+}
+
 void ScModelObj::initializeForTiledRendering()
 {
     SolarMutexGuard aGuard;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index b65c209..d980dfc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2416,6 +2416,26 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& 
rMEvt )
     }
 }
 
+void ScGridWindow::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as 
pixels.
+    ScDocShell* pDocSh = pViewData->GetDocShell();
+    ScDocument& rDoc = pDocSh->GetDocument();
+    assert(rDoc.GetDrawLayer()->isTiledRendering());
+
+    MouseButtonDown(rMouseEvent);
+}
+
+void ScGridWindow::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as 
pixels.
+    ScDocShell* pDocSh = pViewData->GetDocShell();
+    ScDocument& rDoc = pDocSh->GetDocument();
+    assert(rDoc.GetDrawLayer()->isTiledRendering());
+
+    MouseButtonUp(rMouseEvent);
+}
+
 void ScGridWindow::FakeButtonUp()
 {
     if ( nButtonDown )
commit 8ae5e7247bb856663b5c7f3bf827073c32f94633
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Fri Mar 6 22:27:27 2015 +0100

    sc tiled rendering: Simplify the zoom computation.
    
    In principle, we should avoid messing up with zoom, and instead just work 
with
    the MapMode, but we are not there yet - lots of places are hardcoded to work
    in pixels.
    
    Change-Id: I572b0d54fbfc72494c44ef95e7fda5e655f83fde

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 56a3aa0..22d4171 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -927,22 +927,18 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 
     // FIXME the painting works using a mixture of drawing with coordinates in
     // pixels and in logic coordinates; it should be cleaned up to use logic
-    // coords only.
+    // coords only, and avoid all the SetMapMode()'s.
+    // Similarly to Writer, we should set the mapmode once on the rDevice, and
+    // not care about any zoom settings.
 
-    // TODO : zooming isn't perfect.  Find out why.
-    double nOutWTwips = static_cast<double>(nOutputWidth) / PIXEL_PER_TWIPS;
-    double nOutHTwips = static_cast<double>(nOutputHeight) / PIXEL_PER_TWIPS;
-
-    nOutWTwips /= nTileWidth;
-    nOutHTwips /= nTileHeight;
-    Fraction aFracX(nOutWTwips);
-    Fraction aFracY(nOutHTwips);
+    Fraction aFracX(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
+    Fraction aFracY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
 
     pViewData->SetZoom(aFracX, aFracY, true);
     pViewData->RefreshZoom();
 
-    double fTilePosXPixel = static_cast<double>(nTilePosX) * PIXEL_PER_TWIPS * 
static_cast<double>(aFracX);
-    double fTilePosYPixel = static_cast<double>(nTilePosY) * PIXEL_PER_TWIPS * 
static_cast<double>(aFracY);
+    double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / 
nTileWidth;
+    double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / 
nTileHeight;
 
     SCTAB nTab = pViewData->GetTabNo();
     ScDocument* pDoc = pViewData->GetDocument();
@@ -957,7 +953,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     ScTableInfo aTabInfo;
     pDoc->FillInfo(aTabInfo, nCol1, nRow1, nCol2, nRow2, nTab, fPPTX, fPPTY, 
false, false, NULL);
 
-    ScOutputData aOutputData(&rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, 
-fTilePosXPixel, -fTilePosYPixel, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
+    ScOutputData aOutputData(&rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
+            -fTilePosXPixel, -fTilePosYPixel, nCol1, nRow1, nCol2, nRow2,
+            fPPTX, fPPTY);
 
     DrawContent(rDevice, aTabInfo, aOutputData, true, SC_UPDATE_ALL);
 }
commit 74468e423f91015074e13003c762613fb5ef36da
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Fri Mar 6 22:00:15 2015 +0100

    sc tiled rendering: Make the drawings and charts work.
    
    Change-Id: Ibd7e9e398fe24ec2b3553c8488b46b65de316da6

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 17a255f..7bc053d 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -375,6 +375,7 @@ public:
     bool            ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard 
);
     void            HideNoteMarker();
 
+    /// MapMode for the drawinglayer objects.
     MapMode         GetDrawMapMode( bool bForce = false );
 
     void            ContinueDrag();
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index d605d53..d9e1a46 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -60,6 +60,7 @@ class ScFieldEditEngine;
 class ScOutputData
 {
 friend class ScDrawStringsVars;
+friend class ScGridWindow;
 private:
     struct OutputAreaParam
     {
@@ -147,7 +148,6 @@ private:
     RowInfo* pRowInfo;          // Info block
     SCSIZE nArrCount;           // occupied lines in info block
     ScDocument* mpDoc;          // Document
-public:
     SCTAB nTab;                 // sheet
     long nScrX;                 // Output Startpos. (Pixel)
     long nScrY;
@@ -158,7 +158,6 @@ public:
     SCROW nY1;                  //  ( incl. hidden )
     SCCOL nX2;
     SCROW nY2;
-private:
     SCCOL nVisX1;               // Start-/End coordinates
     SCROW nVisY1;               //  ( visible range )
     SCCOL nVisX2;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 0deb69e..56a3aa0 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -531,6 +531,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const 
ScTableInfo& rTableI
     ScDocShell* pDocSh = pViewData->GetDocShell();
     ScDocument& rDoc = pDocSh->GetDocument();
     const ScViewOptions& rOpts = pViewData->GetOptions();
+    bool bIsTiledRendering = rDoc.GetDrawLayer()->isTiledRendering();
 
     SCTAB nTab = aOutputData.nTab;
     SCCOL nX1 = aOutputData.nX1;
@@ -595,7 +596,15 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
     }
 
     // define drawing layer map mode and paint rectangle
-    const MapMode aDrawMode = GetDrawMapMode();
+    MapMode aDrawMode = GetDrawMapMode();
+    if (bIsTiledRendering)
+    {
+        // FIXME this shouldn't be necessary once we change this to work in the
+        // logic coordinates instead of in pixels (and get rid of all the
+        // SetMapMode()'s)
+        aDrawMode = pViewData->GetLogicMode(eWhich);
+        aDrawMode.SetOrigin(PixelToLogic(Point(nScrX, nScrY), aDrawMode));
+    }
     Rectangle aDrawingRectLogic;
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
 
@@ -628,7 +637,6 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const 
ScTableInfo& rTableI
 
     OutputDevice* pContentDev = &rDevice;   // device for document content, 
used by overlay manager
     SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with 
SdrPaintWindow directly
-    bool bIsTiledRendering = rDoc.GetDrawLayer()->isTiledRendering();
 
     if (!bIsTiledRendering)
     {
@@ -894,10 +902,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
         flushOverlayManager();
 
         // set MapMode for text edit
-        SetMapMode(pViewData->GetLogicMode());
+        rDevice.SetMapMode(pViewData->GetLogicMode());
     }
     else
-        SetMapMode(aDrawMode);
+        rDevice.SetMapMode(aDrawMode);
 
     if ( pNoteMarker )
         pNoteMarker->Draw();        // ueber den Cursor, im Drawing-MapMode
@@ -917,6 +925,10 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     // dependent of the zoom level.  Determine the correct zoom level before
     // we start.
 
+    // FIXME the painting works using a mixture of drawing with coordinates in
+    // pixels and in logic coordinates; it should be cleaned up to use logic
+    // coords only.
+
     // TODO : zooming isn't perfect.  Find out why.
     double nOutWTwips = static_cast<double>(nOutputWidth) / PIXEL_PER_TWIPS;
     double nOutHTwips = static_cast<double>(nOutputHeight) / PIXEL_PER_TWIPS;
commit 22f035de62a2f90ca7658d94075c12cd2c62cc50
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Fri Mar 6 18:47:29 2015 +0100

    Kill this return.
    
    Change-Id: Ic05fbba4f431d9ccbe09377ec02e8eb84e3d3b17

diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx
index 91c8da8..f2b0a05 100644
--- a/sc/source/ui/view/output3.cxx
+++ b/sc/source/ui/view/output3.cxx
@@ -213,9 +213,6 @@ void ScOutputData::DrawSelectiveObjects(const sal_uInt16 
nLayer)
     }
 
     mpDev->SetDrawMode(nOldDrawMode);
-
-    // #109985#
-    return;
 }
 
 //  Teile nur fuer Bildschirm
commit de7083db5576e7c55a5c420b0897e41d80d66ad3
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Fri Mar 6 18:21:02 2015 +0100

    sc tiled rendering: tdf#85848: Use DrawContent() in PaintTile() too.
    
    From now on, the code for the tiled rendering is shared with the desktop
    rendering, modulo few isTiledRendering() calls.
    
    Drawing of the shapes & charts needs fixing, it does not honor the
    output device settings.
    
    Change-Id: I74cdb4e09da59aa71f31b18130829de28a93fab4

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 314df1d..0deb69e 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -382,6 +382,16 @@ void ScGridWindow::Paint( const Rectangle& rRect )
 
 void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 
ScUpdateMode eMode )
 {
+    ScDocShell* pDocSh = pViewData->GetDocShell();
+    ScDocument& rDoc = pDocSh->GetDocument();
+
+    // let's ignore the normal Draw() attempts when doing the tiled rendering,
+    // all the rendering should go through PaintTile() in that case.
+    // TODO revisit if we can actually turn this into an assert(), and clean
+    // up the callers
+    if (rDoc.GetDrawLayer()->isTiledRendering())
+        return;
+
     ScModule* pScMod = SC_MOD();
     bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
 
@@ -418,10 +428,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
 
     ++nPaintCount;                  // merken, dass gemalt wird (wichtig beim 
Invertieren)
 
-    ScDocShell* pDocSh = pViewData->GetDocShell();
-    ScDocument& rDoc = pDocSh->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
-
     rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
 
     Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
@@ -619,9 +626,11 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
         aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
     }
 
-    OutputDevice* pContentDev = this;       // device for document content, 
used by overlay manager
+    OutputDevice* pContentDev = &rDevice;   // device for document content, 
used by overlay manager
     SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with 
SdrPaintWindow directly
+    bool bIsTiledRendering = rDoc.GetDrawLayer()->isTiledRendering();
 
+    if (!bIsTiledRendering)
     {
         // init redraw
         ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
@@ -832,6 +841,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const 
ScTableInfo& rTableI
         }
     }
 
+    if (!bIsTiledRendering)
     {
         // end redraw
         ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
@@ -858,25 +868,24 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
     if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) )
     {
         //! use pContentDev for EditView?
-        SetMapMode(MAP_PIXEL);
+        rDevice.SetMapMode(MAP_PIXEL);
         SCCOL nCol1 = pViewData->GetEditStartCol();
         SCROW nRow1 = pViewData->GetEditStartRow();
         SCCOL nCol2 = pViewData->GetEditEndCol();
         SCROW nRow2 = pViewData->GetEditEndRow();
-        SetLineColor();
-        SetFillColor( pEditView->GetBackgroundColor() );
+        rDevice.SetLineColor();
+        rDevice.SetFillColor(pEditView->GetBackgroundColor());
         Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
         Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
 
         long nLayoutSign = bLayoutRTL ? -1 : 1;
         aEnd.X() -= 2 * nLayoutSign;        // don't overwrite grid
         aEnd.Y() -= 2;
-        DrawRect( Rectangle( aStart,aEnd ) );
+        rDevice.DrawRect(Rectangle(aStart, aEnd));
 
-        SetMapMode(pViewData->GetLogicMode());
-        pEditView->Paint( PixelToLogic( Rectangle( Point( nScrX, nScrY ),
-                            Size( aOutputData.GetScrW(), aOutputData.GetScrH() 
) ) ) );
-        SetMapMode(MAP_PIXEL);
+        rDevice.SetMapMode(pViewData->GetLogicMode());
+        pEditView->Paint(PixelToLogic(Rectangle(Point(nScrX, nScrY), 
Size(aOutputData.GetScrW(), aOutputData.GetScrH()))), &rDevice);
+        rDevice.SetMapMode(MAP_PIXEL);
     }
 
     if (pViewData->HasEditView(eWhich))
@@ -936,74 +945,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     ScTableInfo aTabInfo;
     pDoc->FillInfo(aTabInfo, nCol1, nRow1, nCol2, nRow2, nTab, fPPTX, fPPTY, 
false, false, NULL);
 
-    ScOutputData aOutData(
-        &rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, -fTilePosXPixel, 
-fTilePosYPixel, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
-
-    const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
-    Color aGridColor = rColorCfg.GetColorValue(svtools::CALCGRID, 
false).nColor;
-    if (aGridColor.GetColor() == COL_TRANSPARENT)
-    {
-        //  use view options' grid color only if color config has "automatic" 
color
-        const ScViewOptions& rOpts = pViewData->GetOptions();
-        aGridColor = rOpts.GetGridColor();
-    }
-    aOutData.SetGridColor(aGridColor);
-
-    aOutData.DrawClear();
-    aOutData.DrawDocumentBackground();
-    aOutData.DrawBackground();
-    aOutData.DrawGrid(true, false);
-
-    aOutData.DrawShadow();
-    aOutData.DrawFrame();
-
-    // Set scaling to map mode only for text rendering, to get texts to scale
-    // correctly.
-    MapMode aOldMapMode = rDevice.GetMapMode();
-    MapMode aNewMapMode = aOldMapMode;
-    aNewMapMode.SetScaleX(aFracX);
-    aNewMapMode.SetScaleY(aFracY);
-    rDevice.SetMapMode(aNewMapMode);
+    ScOutputData aOutputData(&rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, 
-fTilePosXPixel, -fTilePosYPixel, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
 
-    aOutData.DrawStrings(true);
-
-    // Edit texts need 1/100mm map mode to be rendered correctly.
-    aNewMapMode.SetMapUnit(MAP_100TH_MM);
-    rDevice.SetMapMode(aNewMapMode);
-    aOutData.DrawEdit(true);
-
-    rDevice.SetMapMode(aOldMapMode);
-
-    EditView*   pEditView = NULL;
-    {
-        SCCOL nEditCol;
-        SCROW nEditRow;
-        pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
-    }
-    //  InPlace Edit-View
-    // moved after EndDrawLayers() to get it outside the overlay buffer and
-    // on top of everything
-    if (pEditView)
-    {
-        //! use pContentDev for EditView?
-        rDevice.SetMapMode(MAP_PIXEL);
-        SCCOL nEditCol1 = pViewData->GetEditStartCol();
-        SCROW nEditRow1 = pViewData->GetEditStartRow();
-        SCCOL nEditCol2 = pViewData->GetEditEndCol();
-        SCROW nEditRow2 = pViewData->GetEditEndRow();
-        rDevice.SetLineColor();
-        rDevice.SetFillColor( pEditView->GetBackgroundColor() );
-        Point aStart = pViewData->GetScrPos( nEditCol1, nEditRow1, eWhich );
-        Point aEnd = pViewData->GetScrPos( nEditCol2+1, nEditRow2+1, eWhich );
-        aEnd.X() -= 2;        // don't overwrite grid
-        aEnd.Y() -= 2;
-        rDevice.DrawRect( Rectangle( aStart,aEnd ) );
-
-        rDevice.SetMapMode(pViewData->GetLogicMode());
-        pEditView->Paint( PixelToLogic( Rectangle( Point( fTilePosXPixel, 
fTilePosYPixel ),
-                            Size( aOutData.GetScrW(), aOutData.GetScrH() ) ) 
), &rDevice );
-        rDevice.SetMapMode(MAP_PIXEL);
-    }
+    DrawContent(rDevice, aTabInfo, aOutputData, true, SC_UPDATE_ALL);
 }
 
 void ScGridWindow::LogicInvalidate(const ::vcl::Region* pRegion)
commit 0f429de1a8516ca50659df3d1748f30a8e38f738
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Fri Mar 6 16:44:46 2015 +0100

    sc tiled rendering: Split ScGridWindow::Draw() to setup and drawing.
    
    The drawing part is planned to be shared with the tiled rendering, while the
    setup part has to be different.
    
    Change-Id: I9101111d44f4602cdb92916ff3889b52bf10a8bf

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 712fb72..17a255f 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -355,12 +355,15 @@ public:
 
     ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( 
SCCOL nCol, SCROW nRow ) const;
 
-    void DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, 
OutputDevice* pContentDev);
+    void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, 
OutputDevice* pContentDev);
 
     using Window::Draw;
     void            Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
                           ScUpdateMode eMode = SC_UPDATE_ALL );
 
+    /// Draw content of the gridwindow; shared between the desktop and the 
tiled rendering.
+    void DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableInfo, 
ScOutputData& aOutputData, bool bLogicText, ScUpdateMode eMode);
+
     void            CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& 
rAddress);
 
     void            HideCursor();
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index ffb6bea..d605d53 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -147,6 +147,7 @@ private:
     RowInfo* pRowInfo;          // Info block
     SCSIZE nArrCount;           // occupied lines in info block
     ScDocument* mpDoc;          // Document
+public:
     SCTAB nTab;                 // sheet
     long nScrX;                 // Output Startpos. (Pixel)
     long nScrY;
@@ -157,6 +158,7 @@ private:
     SCROW nY1;                  //  ( incl. hidden )
     SCCOL nX2;
     SCROW nY2;
+private:
     SCCOL nVisX1;               // Start-/End coordinates
     SCROW nVisY1;               //  ( visible range )
     SCCOL nVisX2;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 17f1ae0..314df1d 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -427,7 +427,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
     Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
     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();
@@ -463,14 +462,12 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
     double nPPTY = pViewData->GetPPTY();
 
     const ScViewOptions& rOpts = pViewData->GetOptions();
-    bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
-    bool bMarkClipped = rOpts.GetOption( VOPT_CLIPMARKS );
 
         // Datenblock
 
     ScTableInfo aTabInfo;
     rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
-                                        nPPTX, nPPTY, false, bFormulaMode,
+                                        nPPTX, nPPTY, false, 
rOpts.GetOption(VOPT_FORMULAS),
                                         &pViewData->GetMarkData() );
 
     Fraction aZoomX = pViewData->GetZoomX();
@@ -505,6 +502,37 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
         bLogicText = true;                      // use logic MapMode
     }
 
+    DrawContent(*this, aTabInfo, aOutputData, bLogicText, eMode);
+
+    //  Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert 
aus Basic-Macro),
+    //  ist das jetzt durcheinandergekommen und es muss neu gemalt werden
+
+    OSL_ENSURE(nPaintCount, "nPaintCount falsch");
+    --nPaintCount;
+    if (!nPaintCount)
+        CheckNeedsRepaint();
+
+    // Flag drawn formula cells "unchanged".
+    rDoc.ResetChanged(ScRange(nX1, nY1, nTab, nX2, nY2, nTab));
+    rDoc.ClearFormulaContext();
+}
+
+void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& 
rTableInfo, ScOutputData& aOutputData,
+        bool bLogicText, ScUpdateMode eMode)
+{
+    ScModule* pScMod = SC_MOD();
+    ScDocShell* pDocSh = pViewData->GetDocShell();
+    ScDocument& rDoc = pDocSh->GetDocument();
+    const ScViewOptions& rOpts = pViewData->GetOptions();
+
+    SCTAB nTab = aOutputData.nTab;
+    SCCOL nX1 = aOutputData.nX1;
+    SCROW nY1 = aOutputData.nY1;
+    SCCOL nX2 = aOutputData.nX2;
+    SCROW nY2 = aOutputData.nY2;
+    long nScrX = aOutputData.nScrX;
+    long nScrY = aOutputData.nScrY;
+
     const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
     Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID, false 
).nColor );
     if ( aGridColor.GetColor() == COL_TRANSPARENT )
@@ -516,9 +544,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
     aOutputData.SetSyntaxMode       ( pViewData->IsSyntaxMode() );
     aOutputData.SetGridColor        ( aGridColor );
     aOutputData.SetShowNullValues   ( rOpts.GetOption( VOPT_NULLVALS ) );
-    aOutputData.SetShowFormulas     ( bFormulaMode );
+    aOutputData.SetShowFormulas     ( rOpts.GetOption( VOPT_FORMULAS ) );
     aOutputData.SetShowSpellErrors  ( rDoc.GetDocOptions().IsAutoSpell() );
-    aOutputData.SetMarkClipped      ( bMarkClipped );
+    aOutputData.SetMarkClipped      ( rOpts.GetOption( VOPT_CLIPMARKS ) );
 
     aOutputData.SetUseStyleColor( true );       // always set in table view
 
@@ -562,6 +590,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
     // define drawing layer map mode and paint rectangle
     const MapMode aDrawMode = GetDrawMapMode();
     Rectangle aDrawingRectLogic;
+    bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
 
     {
         // get drawing pixel rect
@@ -704,13 +733,13 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
 
     pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich));
     if ( bLogicText )
-        aOutputData.DrawStrings(true);      // in logic MapMode if 
bTextWysiwyg is set
+        aOutputData.DrawStrings(true);      // in logic MapMode if bLogicText 
is set
     aOutputData.DrawEdit(true);
     pContentDev->SetMapMode(MAP_PIXEL);
 
         // Autofilter- und Pivot-Buttons
 
-    DrawButtons( nX1, nX2, aTabInfo, pContentDev );          // Pixel
+    DrawButtons(nX1, nX2, rTableInfo, pContentDev);          // Pixel
 
         // Notiz-Anzeiger
 
@@ -838,6 +867,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
         SetFillColor( pEditView->GetBackgroundColor() );
         Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
         Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
+
+        long nLayoutSign = bLayoutRTL ? -1 : 1;
         aEnd.X() -= 2 * nLayoutSign;        // don't overwrite grid
         aEnd.Y() -= 2;
         DrawRect( Rectangle( aStart,aEnd ) );
@@ -861,18 +892,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, 
SCROW nY2, ScUpdateMod
 
     if ( pNoteMarker )
         pNoteMarker->Draw();        // ueber den Cursor, im Drawing-MapMode
-
-    //  Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert 
aus Basic-Macro),
-    //  ist das jetzt durcheinandergekommen und es muss neu gemalt werden
-
-    OSL_ENSURE(nPaintCount, "nPaintCount falsch");
-    --nPaintCount;
-    if (!nPaintCount)
-        CheckNeedsRepaint();
-
-    // Flag drawn formula cells "unchanged".
-    rDoc.ResetChanged(ScRange(nX1,nY1,nTab,nX2,nY2,nTab));
-    rDoc.ClearFormulaContext();
 }
 
 void ScGridWindow::PaintTile( VirtualDevice& rDevice,
@@ -1219,7 +1238,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, 
SCCOL nX2, SCROW nY2,
     }
 }
 
-void ScGridWindow::DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, 
OutputDevice* pContentDev)
+void ScGridWindow::DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& 
rTabInfo, OutputDevice* pContentDev)
 {
     aComboButton.SetOutputDevice( pContentDev );
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to