comphelper/source/misc/lok.cxx | 24 ++++++++++++++++++------ desktop/source/lib/init.cxx | 4 ++-- embeddedobj/source/commonembedding/embedobj.cxx | 7 ------- include/comphelper/lok.hxx | 4 ++-- sc/source/ui/condformat/condformatdlg.cxx | 3 ++- sc/source/ui/condformat/condformatdlgentry.cxx | 3 ++- sfx2/source/view/ipclient.cxx | 11 +++++++++++ 7 files changed, 37 insertions(+), 19 deletions(-)
New commits: commit 3b9dfb7acd8b2625c39de4af94b4e01794fcd315 Author: Muhammet Kara <muhammet.k...@collabora.com> AuthorDate: Wed Jul 31 21:41:41 2019 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Tue Sep 3 21:43:36 2019 +0200 LOK: Proper use of isMobile() on embedded charts We are moving the isMobile() check to a higher layer, to avoid changing a published API method This is the follow-up of the commit feae0c186e700f6a48c3fad124fb4795ad1a8f83 (cherry picked from commit 9083a07e98a32e3ce7af4bd1a817f2b870df0f55) Change-Id: Ia84baa36d66d5832e00e6466f5206631df0de443 Reviewed-on: https://gerrit.libreoffice.org/78310 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 93f121cee31b..14e7246b7b42 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -227,13 +227,6 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) } else { - 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) - return; - } - if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE ) { if ( !m_xClientSite.is() ) diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 9dd4503eff7f..55fbdbaea2eb 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -932,6 +932,17 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb ) { m_xImp->m_xObject->setClientSite( m_xImp->m_xClient ); + // Disable embedded object editing (e.g. chart) on mobile + if ( comphelper::LibreOfficeKit::isActive() && comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()) + && m_xImp->m_xObject->getCurrentState() == embed::EmbedStates::RUNNING ) + { + // Also check next state + // Needs to be embed::EmbedStates::UI_ACTIVE or embed::EmbedStates::INPLACE_ACTIVE + // Conversion table is in embeddedobj/source/commonembedding/miscobj.cxx + if (nVerb != embed::EmbedVerbs::MS_OLEVERB_OPEN && nVerb != embed::EmbedVerbs::MS_OLEVERB_HIDE) + return nError; + } + m_xImp->m_xObject->doVerb( nVerb ); } catch ( embed::UnreachableStateException& ) commit 9389bdcd6e796f4f4f9044fa7f905699eb8c9ab3 Author: Muhammet Kara <muhammet.k...@collabora.com> AuthorDate: Wed Jul 31 17:04:38 2019 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Tue Sep 3 21:43:21 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. (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.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> 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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits