Blob Blame History Raw
From a5cddfd6432264a781e5418f970da6553db6a57d Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Thu, 17 Sep 2015 10:59:13 +0200
Subject: [PATCH 148/398] comphelper: add LibreOfficeKit::set/isViewCallback()

Change-Id: Iad0b2ee419327daf478f3ddda2378effe0184067
(cherry picked from commit 1704221067e2bc6ba26eaa83573d29964b413a34)
---
 comphelper/source/misc/lok.cxx | 12 ++++++++++++
 desktop/source/lib/init.cxx    |  4 ++++
 include/comphelper/lok.hxx     |  5 +++++
 3 files changed, 21 insertions(+)

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index a6abd2a65486..279ec65c600c 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 617c94638cde..52a78e228a32 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1192,6 +1192,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 79fa115e6585..2cc38c60e455 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.
-- 
2.12.0