[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - desktop/qa desktop/source include/LibreOfficeKit sfx2/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 2 16:23:03 UTC 2019


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    3 +-
 desktop/source/lib/init.cxx                 |   29 ++++++++++++++++++++++------
 include/LibreOfficeKit/LibreOfficeKit.h     |    9 ++++++++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |    7 +++---
 sfx2/source/control/shell.cxx               |    7 ++++++
 5 files changed, 45 insertions(+), 10 deletions(-)

New commits:
commit 2f463f9d1f45546318a57de57f6e5e918063af0a
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Nov 30 14:59:02 2019 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 2 17:22:02 2019 +0100

    lok: add viewId to window painting, to allow special-casing on render.
    
    View switching should not cause the sidebar UX to re-build at all.
    Particularly it should not do this when we switch view just to render
    a sidebar.
    
    Change-Id: Iec0427cdc8308fc273d73ea56dd208bfa7036471
    Reviewed-on: https://gerrit.libreoffice.org/84120
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    (cherry picked from commit 92814f3389de346f3ae32cddb38f079763e68ddf)
    Reviewed-on: https://gerrit.libreoffice.org/84129
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/84223

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2c2d03b967ea..1bb185dd5b9e 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2746,10 +2746,11 @@ void DesktopLOKTest::testABI()
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), offsetof(struct _LibreOfficeKitDocumentClass, removeTextContext));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), offsetof(struct _LibreOfficeKitDocumentClass, sendDialogEvent));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), offsetof(struct _LibreOfficeKitDocumentClass, renderFontOrientation));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct _LibreOfficeKitDocumentClass, paintWindowForView));
 
     // Extending is fine, update this, and add new assert for the offsetof the
     // new method
-    CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), sizeof(struct _LibreOfficeKitDocumentClass));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), sizeof(struct _LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bc0fd62eb78a..fcd986512f28 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -901,6 +901,11 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindo
                                const int nWidth, const int nHeight,
                                const double fDPIScale);
 
+static void doc_paintWindowForView(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
+                                   const int nX, const int nY,
+                                   const int nWidth, const int nHeight,
+                                   const double fDPIScale, int viewId);
+
 static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned
  nLOKWindowId, int nAction, const char* pData);
 
@@ -1013,6 +1018,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
 
         m_pDocumentClass->paintWindow = doc_paintWindow;
         m_pDocumentClass->paintWindowDPI = doc_paintWindowDPI;
+        m_pDocumentClass->paintWindowForView = doc_paintWindowForView;
         m_pDocumentClass->postWindow = doc_postWindow;
         m_pDocumentClass->resizeWindow = doc_resizeWindow;
 
@@ -4806,12 +4812,20 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
     doc_paintWindowDPI(pThis, nLOKWindowId, pBuffer, nX, nY, nWidth, nHeight, 1.0);
 }
 
-static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
+static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
                                unsigned char* pBuffer,
                                const int nX, const int nY,
                                const int nWidth, const int nHeight,
                                const double fDPIScale)
 {
+    doc_paintWindowForView(pThis, nLOKWindowId, pBuffer, nX, nY, nWidth, nHeight, fDPIScale, -1);
+}
+
+static void doc_paintWindowForView(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
+                                   unsigned char* pBuffer, const int nX, const int nY,
+                                   const int nWidth, const int nHeight,
+                                   const double fDPIScale, int viewId)
+{
     comphelper::ProfileZone aZone("doc_paintWindowDPI");
 
     SolarMutexGuard aGuard;
@@ -4824,6 +4838,12 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW
         return;
     }
 
+    // Used to avoid work in setView if set.
+    comphelper::LibreOfficeKit::setDialogPainting(true);
+
+    if (viewId >= 0)
+        doc_setView(pThis, viewId);
+
     // Setup cairo (or CoreGraphics, in the iOS case) to draw with the changed DPI scale (and return
     // back to 1.0 when the painting finishes)
     comphelper::ScopeGuard dpiScaleGuard([]() { comphelper::LibreOfficeKit::setDPIScale(1.0); });
@@ -4848,9 +4868,7 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW
     aMapMode.SetOrigin(Point(-(nX / fDPIScale), -(nY / fDPIScale)));
     pDevice->SetMapMode(aMapMode);
 
-    comphelper::LibreOfficeKit::setDialogPainting(true);
     pWindow->PaintToDevice(pDevice.get(), Point(0, 0), Size());
-    comphelper::LibreOfficeKit::setDialogPainting(false);
 
     CGContextRelease(cgc);
 
@@ -4865,11 +4883,10 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW
     aMapMode.SetOrigin(Point(-(nX / fDPIScale), -(nY / fDPIScale)));
     pDevice->SetMapMode(aMapMode);
 
-    comphelper::LibreOfficeKit::setDialogPainting(true);
     pWindow->PaintToDevice(pDevice.get(), Point(0, 0), Size());
-    comphelper::LibreOfficeKit::setDialogPainting(false);
-
 #endif
+
+    comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
 static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction, const char* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 78f2b478e861..a486886c15de 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -427,6 +427,15 @@ struct _LibreOfficeKitDocumentClass
                        int* pFontHeight,
                        int pOrientation);
 
+    /// Switches view to viewId if viewId >= 0, and paints window
+    /// @see lok::Document::paintWindowDPI().
+    void (*paintWindowForView) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
+                                unsigned char* pBuffer,
+                                const int x, const int y,
+                                const int width, const int height,
+                                const double dpiscale,
+                                int viewId);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 18a20c7a2e2d..318bf943cca9 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -177,10 +177,11 @@ public:
                      const int y,
                      const int width,
                      const int height,
-                     const double dpiscale = 1.0)
+                     const double dpiscale = 1.0,
+                     const int viewId = -1)
     {
-        return mpDoc->pClass->paintWindowDPI(mpDoc, nWindowId, pBuffer,
-                                             x, y, width, height, dpiscale);
+        return mpDoc->pClass->paintWindowForView(mpDoc, nWindowId, pBuffer, x, y,
+                                                 width, height, dpiscale, viewId);
     }
 
     /**
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 85c84d632df5..285420a6381b 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -30,6 +30,7 @@
 #include <svtools/asynclink.hxx>
 #include <basic/sbx.hxx>
 #include <unotools/configmgr.hxx>
+#include <comphelper/lok.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/shell.hxx>
 #include <sfx2/bindings.hxx>
@@ -706,6 +707,12 @@ void SfxShell::SetViewShell_Impl( SfxViewShell* pView )
 
 void SfxShell::BroadcastContextForActivation (const bool bIsActivated)
 {
+    // Avoids activation and de-activation (can be seen on switching view) from causing
+    // the sidebar to re-build. Such switching can happen as we change view to render
+    // using LOK for example, and is un-necessary for Online.
+    if (comphelper::LibreOfficeKit::isDialogPainting())
+        return;
+
     SfxViewFrame* pViewFrame = GetFrame();
     if (pViewFrame != nullptr)
     {


More information about the Libreoffice-commits mailing list