[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Jan 14 01:35:30 PST 2015


 sw/inc/viewsh.hxx                 |    4 ++++
 sw/source/core/layout/pagechg.cxx |    6 +++---
 sw/source/core/view/viewsh.cxx    |   13 ++++++++++++-
 sw/source/uibase/uno/unotxdoc.cxx |    7 +++++++
 4 files changed, 26 insertions(+), 4 deletions(-)

New commits:
commit 1275a16ebe1fc0e7777d4e78aa798e6ff71ba3aa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jan 14 10:28:40 2015 +0100

    SwRootFrm::CheckViewLayout: never center pages when doing tiled rendering
    
    The size of the root frame is usually the max of the page frame widths,
    except when the visual area is larger, in which case the root frame is
    the visual area width, and page frames are centered (when there is a
    single column).
    
    When doing tiled rendering, we are not interested in the gray area
    around the pages (not more than just having a gap between pages), so
    never do this centering. This has two benefits:
    
    1) When painting the tiles, we change the visual area already to always
    have the given tile visible, that would undo this centering anyway, but
    changing the size of the root frame causes a pointless
    mass-invalidation.
    
    2) When getting the size of the document, this way the width of the
    document (root frame) will independent from the visual area, i.e. it'll
    be always the same.
    
    Change-Id: Ib0d86bbe6c7b5a83646264a2f308624179ad6982

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 574933c..89ebbc6 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -581,6 +581,10 @@ public:
     void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
     /// Invokes the registered callback, if there are any.
     void libreOfficeKitCallback(int nType, const char* pPayload);
+    /// Set if we are doing tiled rendering.
+    void setTiledRendering(bool bTiledRendering);
+    /// Are we doing tiled rendering?
+    bool isTiledRendering();
 
     SwViewShell* GetNext()
         { return GetNextInRing(); }
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index cd1314b..9bda8c4 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -2025,9 +2025,9 @@ void SwRootFrm::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVi
             }
 
             // center page if possible
-            const long nSizeDiff = nVisWidth > nCurrentRowWidth ?
-                                   ( nVisWidth - nCurrentRowWidth ) / 2 :
-                                   0;
+            long nSizeDiff = 0;
+            if (nVisWidth > nCurrentRowWidth && !GetCurrShell()->isTiledRendering())
+                nSizeDiff = ( nVisWidth - nCurrentRowWidth ) / 2;
 
             // adjust positions of pages in current row
             long nX = nSizeDiff;
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index adbaaba..39bc4b1 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -129,6 +129,16 @@ void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload)
         mpLibreOfficeKitCallback(nType, pPayload, mpLibreOfficeKitData);
 }
 
+void SwViewShell::setTiledRendering(bool bTiledRendering)
+{
+    mbTiledRendering = bTiledRendering;
+}
+
+bool SwViewShell::isTiledRendering()
+{
+    return mbTiledRendering;
+}
+
 static void
 lcl_PaintTransparentFormControls(SwViewShell & rShell, SwRect const& rRect)
 {
@@ -1762,6 +1772,7 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
     // them - mpBufferedOut, mpOut, mpWin, ..., and get rid of
     // mbTiledRendering)
     OutputDevice *pSaveOut = mpOut;
+    bool bTiledRendering = mbTiledRendering;
     mbTiledRendering = true;
     mpOut = &rDevice;
 
@@ -1810,7 +1821,7 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
 
     // SwViewShell's output device tear down
     mpOut = pSaveOut;
-    mbTiledRendering = false;
+    mbTiledRendering = bTiledRendering;
 }
 
 #if !HAVE_FEATURE_DESKTOP
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 4655298..e3d57dd 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3149,6 +3149,13 @@ Size SwXTextDocument::getDocumentSize()
 void SwXTextDocument::initializeForTiledRendering()
 {
     SolarMutexGuard aGuard;
+
+    // Call setTiledRendering() first, so that when we change the view layout,
+    // we already don't center the pages.
+    SwDoc* pDoc = pDocShell->GetDoc();
+    SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
+    pViewShell->setTiledRendering(true);
+
     bool      bBookMode = false;
     sal_Int16 nColumns = 1;
 


More information about the Libreoffice-commits mailing list