[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 5 commits - comphelper/source desktop/source include/comphelper include/sfx2 sfx2/source sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 17 06:41:54 PDT 2015


 comphelper/source/misc/lok.cxx    |   12 ++++++++++++
 desktop/source/lib/init.cxx       |   24 +++++++++++++++++++-----
 include/comphelper/lok.hxx        |    5 +++++
 include/sfx2/viewsh.hxx           |    7 +++++++
 sfx2/source/view/viewimp.hxx      |    3 +++
 sfx2/source/view/viewsh.cxx       |   14 ++++++++++++++
 sw/inc/viewsh.hxx                 |    3 ++-
 sw/source/core/view/viewsh.cxx    |    7 +++++++
 sw/source/uibase/docvw/edtwin.cxx |   10 ++++++++--
 9 files changed, 77 insertions(+), 8 deletions(-)

New commits:
commit b144edb9667836980ff906987dad24faf2987370
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 15:39:19 2015 +0200

    lok::Document: register callback in the view, if requested
    
    With this, a postKeyEvent() in one view properly results in one
    LOK_CALLBACK_INVALIDATE_TILES per view, at least in Writer.
    
    Change-Id: Ia0a9a00ea5a98c38f3d399208b9ef028f3036f79

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b30f3de..3d884d5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -49,6 +49,8 @@
 #include <editeng/flstitem.hxx>
 #include <sfx2/objsh.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
 #include <svx/svxids.hrc>
 #include <vcl/svapp.hxx>
 #include <vcl/svpforlokit.hxx>
@@ -758,14 +760,22 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
                                 LibreOfficeKitCallback pCallback,
                                 void* pData)
 {
-    ITiledRenderable* pDoc = getTiledRenderable(pThis);
-    if (!pDoc)
+    if (comphelper::LibreOfficeKit::isViewCallback())
     {
-        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
-        return;
+        if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
+            pViewShell->registerLibreOfficeKitViewCallback(pCallback, pData);
     }
+    else
+    {
+        ITiledRenderable* pDoc = getTiledRenderable(pThis);
+        if (!pDoc)
+        {
+            gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+            return;
+        }
 
-    pDoc->registerCallback(pCallback, pData);
+        pDoc->registerCallback(pCallback, pData);
+    }
 }
 
 static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode)
commit 8394e3ed3ac59f4740056563148575e6ed4a535b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 11:44:53 2015 +0200

    sw: implement per-view LOK_CALLBACK_INVALIDATE_TILES
    
    Change-Id: Id839dc076824e69fe07386c83bf21fc4c7ce2b8e

diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 09a24d2..c32ec9f 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -69,6 +69,7 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
 
 #include <editeng/acorrcfg.hxx>
 #include <SwSmartTagMgr.hxx>
@@ -6224,8 +6225,13 @@ void SwEditWin::LogicInvalidate(const Rectangle* pRectangle)
     else
         sRectangle = pRectangle->toString();
 
-    if ( m_rView.GetWrtShellPtr() )
-        m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+    if (comphelper::LibreOfficeKit::isViewCallback())
+        m_rView.libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+    else
+    {
+        if (m_rView.GetWrtShellPtr())
+            m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+    }
 }
 
 void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
commit 934d23bd41ca4231cc2cf4ce71243973c08b7113
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 10:59:13 2015 +0200

    comphelper: add LibreOfficeKit::set/isViewCallback()
    
    Change-Id: Iad0b2ee419327daf478f3ddda2378effe0184067

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index a6abd2a..279ec65 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -17,6 +17,8 @@ namespace LibreOfficeKit
 
 static bool g_bActive(false);
 
+static bool g_bViewCallback(false);
+
 void setActive(bool bActive)
 {
     g_bActive = bActive;
@@ -27,6 +29,16 @@ bool isActive()
     return g_bActive;
 }
 
+void setViewCallback(bool bViewCallback)
+{
+    g_bViewCallback = bViewCallback;
+}
+
+bool isViewCallback()
+{
+    return g_bViewCallback;
+}
+
 static void (*pStatusIndicatorCallback)(void *data, statusIndicatorCallbackType type, int percent)(nullptr);
 static void *pStatusIndicatorCallbackData(nullptr);
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4f17cb7..b30f3de 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1134,6 +1134,10 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
         return 1;
 
     comphelper::LibreOfficeKit::setActive();
+
+    static bool bViewCallback = getenv("LOK_VIEW_CALLBACK");
+    comphelper::LibreOfficeKit::setViewCallback(bViewCallback);
+
     comphelper::LibreOfficeKit::setStatusIndicatorCallback(lo_status_indicator_callback, pLib);
 
     if (pUserProfilePath)
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index 79fa115..2cc38c6 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -36,6 +36,11 @@ COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(void (*callback)(void *data
 // Check whether the code is running as invoked through LibreOfficeKit.
 COMPHELPER_DLLPUBLIC bool isActive();
 
+/// Check whether clients register a callback for each view.
+COMPHELPER_DLLPUBLIC bool isViewCallback();
+/// Set whether clients register a callback for each view.
+COMPHELPER_DLLPUBLIC void setViewCallback(bool bViewCallback);
+
 // Status indicator handling. Even if in theory there could be several status indicators active at
 // the same time, in practice there is only one at a time, so we don't handle any identification of
 // status indicator in this API.
commit 11e9da731bd4d2334dc436e2c1640732df8308e8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 17 10:58:56 2015 +0200

    sfx2: add SfxViewShell::libreOfficeKitViewCallback()
    
    This is similar to the existing LOK callback, the difference is that the
    existing one assumes there is only one SfxViewShell instance at the same
    time.
    
    This newer callback is precisely per-view, so model notifications can
    invoke all view callbacks, while view notifications can invoke only the
    callback of the relevant view.
    
    This is just the framework, all actual client code has to be still
    ported over (and then the existing callback can be removed).
    
    Change-Id: I3d8f27740c69fcf6ffbbdce12db2ea088321493d

diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index e88203d..70f3931 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -39,6 +39,8 @@
 #include <o3tl/typed_flags_set.hxx>
 #include <vcl/vclptr.hxx>
 #include <sfx2/tabdlg.hxx>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
 
 class SfxBaseController;
 class Size;
@@ -315,6 +317,11 @@ public:
     SAL_DLLPRIVATE void TakeOwnership_Impl();
     SAL_DLLPRIVATE void TakeFrameOwnership_Impl();
     SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
+
+    /// The actual implementation of the lok::Document::registerViewCallback() API.
+    void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+    /// Invokes the registered callback, if there are any.
+    void libreOfficeKitViewCallback(int nType, const char* pPayload) const;
 };
 
 
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index 4900593..b832b15 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -64,6 +64,9 @@ struct SfxViewShell_Impl
 
     mutable SfxInPlaceClientList* mpIPClientList;
 
+    LibreOfficeKitCallback m_pLibreOfficeKitViewCallback;
+    void* m_pLibreOfficeKitViewData;
+
     explicit SfxViewShell_Impl(SfxViewShellFlags const nFlags);
     ~SfxViewShell_Impl();
 
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 62ed8bd..2b9ac3d 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -309,6 +309,8 @@ SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags)
 ,   m_nFamily(0xFFFF)   // undefined, default set by TemplateDialog
 ,   m_pController(0)
 ,   mpIPClientList(NULL)
+,   m_pLibreOfficeKitViewCallback(0)
+,   m_pLibreOfficeKitViewData(0)
 {}
 
 SfxViewShell_Impl::~SfxViewShell_Impl()
@@ -1631,6 +1633,18 @@ bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
     return pImp->m_xAccExec->execute(aKey.GetKeyCode());
 }
 
+void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pData)
+{
+    pImp->m_pLibreOfficeKitViewCallback = pCallback;
+    pImp->m_pLibreOfficeKitViewData = pData;
+}
+
+void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) const
+{
+    if (pImp->m_pLibreOfficeKitViewCallback)
+        pImp->m_pLibreOfficeKitViewCallback(nType, pPayload, pImp->m_pLibreOfficeKitViewData);
+}
+
 bool SfxViewShell::KeyInput( const KeyEvent &rKeyEvent )
 
 /*  [Description]
commit f2b4227fe0ac8d2a95fdf535e37964abb510e68e
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Sep 15 20:22:08 2015 +0200

    tdf#94237 tiled rendering: Use the entire document as the visual area.
    
    Many places were already adapted for the tiled rendering, and the conditions
    checking for the VisArea() were changed so that the checks are ignored when
    tiled rendering is active.
    
    Unfortunately there are still some places left, and they are causing that
    various areas are invalidated only partially.  Let's sort it out for good, and
    report the entire document as the VisArea() when the tiled rendering is
    active, and if there are performance problems, let's profile that & act
    accordingly.
    
    Change-Id: I53f18915ed0aec898704dd1350a9534cfc3f001b
    (cherry picked from commit 12e3b51abe883202af09769873f87b27d7de118b)

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index aed6b40..d0e3d12 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -31,6 +31,7 @@
 #include <vcl/mapmod.hxx>
 #include <vcl/print.hxx>
 #include <vcl/vclptr.hxx>
+
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
 
@@ -262,7 +263,7 @@ public:
     bool SmoothScroll( long lXDiff, long lYDiff, const Rectangle* );//Browser
     void EnableSmooth( bool b ) { mbEnableSmooth = b; }
 
-    const SwRect& VisArea() const { return maVisArea; }
+    const SwRect& VisArea() const;
 
     // If necessary scroll until passed Rect is situated in visible sector.
     void MakeVisible( const SwRect & );
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index cd67637..91bae95 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -575,6 +575,13 @@ void SwViewShell::InvalidateWindows( const SwRect &rRect )
     }
 }
 
+const SwRect& SwViewShell::VisArea() const
+{
+    // when using the tiled rendering, consider the entire document as our
+    // visible area
+    return isTiledRendering()? GetLayout()->Frm(): maVisArea;
+}
+
 void SwViewShell::MakeVisible( const SwRect &rRect )
 {
     if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) )


More information about the Libreoffice-commits mailing list