From 9389bdcd6e796f4f4f9044fa7f905699eb8c9ab3 Mon Sep 17 00:00:00 2001 From: Muhammet Kara Date: Wed, 31 Jul 2019 17:04:38 +0300 Subject: 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. (cherry picked from commit f8b2a27365b858ab5653edad75fd089b39d016d8) Conflicts: comphelper/source/misc/lok.cxx sc/source/ui/condformat/condformatdlg.cxx sc/source/ui/condformat/condformatdlgentry.cxx Change-Id: Iaf00530916f3772f7aec151cbd358f255b7aab24 Reviewed-on: https://gerrit.libreoffice.org/78309 Reviewed-by: Andras Timar Tested-by: Andras Timar --- comphelper/source/misc/lok.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'comphelper') diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index a5d9689137d0..8862568608a8 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -13,6 +13,7 @@ #include #include +#include namespace comphelper { @@ -22,8 +23,6 @@ namespace LibreOfficeKit static bool g_bActive(false); -static bool g_bMobile(false); - static bool g_bPartInInvalidation(false); static bool g_bTiledPainting(false); @@ -45,6 +44,9 @@ static LanguageTag g_aLanguageTag("en-US", true); /// Scaling of the cairo or CoreGraphics canvas painting for hi-dpi or zooming in Calc. static double g_fDPIScale(1.0); +/// List of pairs +static std::map g_vIsViewMobile; + void setActive(bool bActive) { g_bActive = bActive; @@ -55,14 +57,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) -- cgit v1.2.3