diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-07-31 17:04:38 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2019-09-03 21:43:21 +0200 |
commit | 9389bdcd6e796f4f4f9044fa7f905699eb8c9ab3 (patch) | |
tree | c254b856639ea9583b7d80dd33d686eae8a71257 | |
parent | lok: Disable chart editing on mobile (diff) | |
download | core-9389bdcd6e796f4f4f9044fa7f905699eb8c9ab3.tar.gz core-9389bdcd6e796f4f4f9044fa7f905699eb8c9ab3.zip |
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 <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | comphelper/source/misc/lok.cxx | 24 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 4 | ||||
-rw-r--r-- | embeddedobj/source/commonembedding/embedobj.cxx | 2 | ||||
-rw-r--r-- | include/comphelper/lok.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlg.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 3 |
6 files changed, 27 insertions, 13 deletions
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 <iostream> #include <sstream> +#include <map> 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 <viewid, bMobile> pairs +static std::map<int, bool> 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) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 81bb6af9f9a0..7208a536441d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3198,12 +3198,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 de57bec51ed3..93f121cee31b 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 4d5748c8f78f..babe15ecb4b5 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 91ea772d8065..ac066450531c 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -17,6 +17,7 @@ #include <svl/intitem.hxx> #include <svx/xtable.hxx> #include <svx/drawitem.hxx> +#include <sfx2/lokhelper.hxx> #include <vcl/settings.hxx> #include <vcl/builderfactory.hxx> #include <vcl/lstbox.hxx> @@ -516,7 +517,7 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, ScViewData* pViewData, const ScCondFormatDlgItem* pItem) : ScAnyRefDlg(pB, pCW, pParent, "ConditionalFormatDialog", - (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"))) , mpViewData(pViewData) , mpLastEdit(nullptr) , mpDlgItem(static_cast<ScCondFormatDlgItem*>(pItem->Clone())) diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 4c6682253fa0..487f08d0eb05 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -20,6 +20,7 @@ #include <vcl/vclevent.hxx> #include <svl/style.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/lokhelper.hxx> #include <svl/stritem.hxx> #include <svl/intitem.hxx> #include <svx/colorbox.hxx> @@ -49,7 +50,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(vcl::Window* pParent, ScDocument* pDoc, const S , mpDoc(pDoc) , maPos(rPos) { - m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), (comphelper::LibreOfficeKit::isMobile()?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui")))); + m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), (comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui")))); get(maGrid, "grid"); get(maFtCondNr, "number"); |