comphelper/source/misc/lok.cxx                  |   24 ++++++++++++++++++------
 desktop/source/lib/init.cxx                     |    4 ++--
 embeddedobj/source/commonembedding/embedobj.cxx |    2 +-
 include/comphelper/lok.hxx                      |    4 ++--
 sc/source/ui/condformat/condformatdlg.cxx       |    3 ++-
 sc/source/ui/condformat/condformatdlgentry.cxx  |    3 ++-
 6 files changed, 27 insertions(+), 13 deletions(-)

New commits:
commit f8b2a27365b858ab5653edad75fd089b39d016d8
Author:     Muhammet Kara <muhammet.k...@collabora.com>
AuthorDate: Wed Jul 31 17:04:38 2019 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Aug 29 16:38:36 2019 +0200

    LOK: per-view support for isMobile()
    
    embeddedobj/source/commonembedding/embedobj.cxx will have
    a follow-up patch, which also removes the -1 case.
    
    It is left out because it has many call-sites,
    and inheritance/override relations.
    
    Change-Id: Iaf00530916f3772f7aec151cbd358f255b7aab24
    Reviewed-on: https://gerrit.libreoffice.org/78272
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 0969b5399bd4..253d94500f13 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -12,6 +12,7 @@
 #include <sal/log.hxx>
 
 #include <iostream>
+#include <map>
 
 namespace comphelper
 {
@@ -21,8 +22,6 @@ namespace LibreOfficeKit
 
 static bool g_bActive(false);
 
-static bool g_bMobile(false);
-
 static bool g_bPartInInvalidation(false);
 
 static bool g_bTiledPainting(false);
@@ -44,6 +43,9 @@ static LanguageTag g_aLanguageTag("en-US", true);
 /// Scaling of the cairo or CoreGraphics canvas painting for HiDPI or zooming 
in Calc.
 static double g_fDPIScale(1.0);
 
+/// List of <viewid, bMobile> pairs
+static std::map<int, bool> g_vIsViewMobile;
+
 void setActive(bool bActive)
 {
     g_bActive = bActive;
@@ -54,14 +56,24 @@ bool isActive()
     return g_bActive;
 }
 
-void setMobile(bool bIsMobile)
+void setMobile(int nViewId, bool bMobile)
 {
-    g_bMobile = bIsMobile;
+    if (g_vIsViewMobile.find(nViewId) != g_vIsViewMobile.end())
+        g_vIsViewMobile[nViewId] = bMobile;
+    else
+        g_vIsViewMobile.insert(std::make_pair(nViewId, bMobile));
 }
 
-bool isMobile()
+bool isMobile(int nViewId)
 {
-    return g_bMobile;
+    // No view given, so act as a global var
+    if (nViewId == -1)
+            return g_vIsViewMobile.size() > 0;
+
+    if (g_vIsViewMobile.find(nViewId) != g_vIsViewMobile.end())
+        return g_vIsViewMobile[nViewId];
+    else
+        return false;
 }
 
 void setPartInInvalidation(bool bPartInInvalidation)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3c81ae6b400d..d7b920632fbf 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3214,12 +3214,12 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
     // Set/unset mobile view for LOK
     if (gImpl && aCommand == ".uno:LOKSetMobile")
     {
-        comphelper::LibreOfficeKit::setMobile();
+        comphelper::LibreOfficeKit::setMobile(nView);
         return;
     }
     else if (gImpl && aCommand == ".uno:LOKUnSetMobile")
     {
-        comphelper::LibreOfficeKit::setMobile(false);
+        comphelper::LibreOfficeKit::setMobile(nView, false);
         return;
     }
 
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx 
b/embeddedobj/source/commonembedding/embedobj.cxx
index 7bed8710ba2c..ab91814943bb 100644
--- a/embeddedobj/source/commonembedding/embedobj.cxx
+++ b/embeddedobj/source/commonembedding/embedobj.cxx
@@ -227,7 +227,7 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 
nNextState )
         }
         else
         {
-            if(comphelper::LibreOfficeKit::isActive() && 
comphelper::LibreOfficeKit::isMobile())
+            if(comphelper::LibreOfficeKit::isActive() && 
comphelper::LibreOfficeKit::isMobile(-1))
             {
                 // Disable embedded object editing (e.g. chart) on mobile
                 if(nNextState == embed::EmbedStates::INPLACE_ACTIVE || 
nNextState == embed::EmbedStates::UI_ACTIVE)
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index 3ced9d7b8905..22d2c6931ab3 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -30,7 +30,7 @@ namespace LibreOfficeKit
 COMPHELPER_DLLPUBLIC void setActive(bool bActive = true);
 
 // Set LOK view to mobile
-COMPHELPER_DLLPUBLIC void setMobile(bool bIsMobile = true);
+COMPHELPER_DLLPUBLIC void setMobile(int nViewId, bool bIsMobile = true);
 
 enum class statusIndicatorCallbackType { Start, SetValue, Finish };
 
@@ -43,7 +43,7 @@ COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(void 
(*callback)(void *data
 COMPHELPER_DLLPUBLIC bool isActive();
 
 // Check whether we are serving to a mobile view/device
-COMPHELPER_DLLPUBLIC bool isMobile();
+COMPHELPER_DLLPUBLIC bool isMobile(int nViewId);
 
 /// Shift the coordinates before rendering each bitmap.
 /// Used by Calc to render each tile separately.
diff --git a/sc/source/ui/condformat/condformatdlg.cxx 
b/sc/source/ui/condformat/condformatdlg.cxx
index 0fc144bf897b..fca7434887e1 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -11,6 +11,7 @@
 #include <condformatdlg.hxx>
 
 #include <sfx2/dispatch.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
 
@@ -411,7 +412,7 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, 
SfxChildWindow* pCW,
     weld::Window* pParent, ScViewData* pViewData,
     const ScCondFormatDlgItem* pItem)
         : ScAnyRefDlgController(pB, pCW, pParent,
-                        
(comphelper::LibreOfficeKit::isMobile()?OUString("modules/scalc/ui/conditionalformatdialogmobile.ui"):OUString("modules/scalc/ui/conditionalformatdialog.ui")),
+                        
(comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalformatdialogmobile.ui"):OUString("modules/scalc/ui/conditionalformatdialog.ui")),
                         "ConditionalFormatDialog")
     , mpViewData(pViewData)
     , mpDlgItem(static_cast<ScCondFormatDlgItem*>(pItem->Clone()))
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx 
b/sc/source/ui/condformat/condformatdlgentry.cxx
index 2e4039004644..9e4c16667add 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -20,6 +20,7 @@
 #include <svl/style.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/frame.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <svl/stritem.hxx>
 #include <svl/intitem.hxx>
 #include <svx/colorbox.hxx>
@@ -42,7 +43,7 @@
 
 ScCondFrmtEntry::ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, 
const ScAddress& rPos)
     : mpParent(pParent)
-    , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), 
(comphelper::LibreOfficeKit::isMobile()?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))))
+    , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), 
(comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))))
     , mxBorder(mxBuilder->weld_widget("border"))
     , mxGrid(mxBuilder->weld_container("grid"))
     , mxFtCondNr(mxBuilder->weld_label("number"))
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to