comphelper/source/misc/lok.cxx | 12 ++++++++---- desktop/source/lib/init.cxx | 15 ++------------- include/comphelper/lok.hxx | 11 +++++------ 3 files changed, 15 insertions(+), 23 deletions(-)
New commits: commit 91b66b621ba6bb71dc36facbad5f8a3a616103d8 Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Mar 24 09:12:07 2020 +0200 Commit: Tor Lillqvist <[email protected]> CommitDate: Tue May 19 12:43:02 2020 +0200 Simplify the LibreOfficeKit mobile phone and tablet API There is not need to ever change the kind of device a view is for, so why bother with the bool parameter to setMobilePhone() and setTablet(). Also, make sure just either of them is called, at most once, for a view. Change-Id: I9ac872f0ab4772e4a7c40c49f62b32fa7b1e47f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90969 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tor Lillqvist <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94485 Tested-by: Tor Lillqvist <[email protected]> diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index c4ff1c641240..dd4a280f52c5 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -59,9 +59,11 @@ bool isActive() return g_bActive; } -void setMobilePhone(int nViewId, bool bIsMobilePhone) +void setMobilePhone(int nViewId) { - g_vIsViewMobilePhone[nViewId] = bIsMobilePhone; + assert(!isMobilePhone(nViewId)); + assert(!isTablet(nViewId)); + g_vIsViewMobilePhone[nViewId] = true; } bool isMobilePhone(int nViewId) @@ -72,9 +74,11 @@ bool isMobilePhone(int nViewId) return false; } -void setTablet(int nViewId, bool bIsTablet) +void setTablet(int nViewId) { - g_vIsViewTablet[nViewId] = bIsTablet; + assert(!isMobilePhone(nViewId)); + assert(!isTablet(nViewId)); + g_vIsViewTablet[nViewId] = true; } bool isTablet(int nViewId) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9f56344b640f..34adc76124fd 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3711,25 +3711,14 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma if (nView < 0) return; - // Set/unset mobile phone view for LOK if (gImpl && (aCommand == ".uno:LOKSetMobile" || aCommand == ".uno:LOKSetMobilePhone")) { - comphelper::LibreOfficeKit::setMobilePhone(nView, true); - return; - } - else if (gImpl && (aCommand == ".uno:LOKUnSetMobile" || aCommand == ".uno:LOKUnSetMobilePhone")) - { - comphelper::LibreOfficeKit::setMobilePhone(nView, false); + comphelper::LibreOfficeKit::setMobilePhone(nView); return; } else if (gImpl && aCommand == ".uno:LOKSetTablet") { - comphelper::LibreOfficeKit::setTablet(nView, true); - return; - } - else if (gImpl && aCommand == ".uno:LOKUnSetTablet") - { - comphelper::LibreOfficeKit::setTablet(nView, false); + comphelper::LibreOfficeKit::setTablet(nView); return; } else if (gImpl && aCommand == ".uno:ToggleOrientation") diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx index 58a55f34a722..53b923f45fe2 100644 --- a/include/comphelper/lok.hxx +++ b/include/comphelper/lok.hxx @@ -29,16 +29,15 @@ namespace LibreOfficeKit COMPHELPER_DLLPUBLIC void setActive(bool bActive = true); -// Note that currently it is undefined behaviour to call both setMobilePhone() and setTablet(). This -// will be remedied in the future. For now, just make sure you call just either for a view, and just -// once, with the bool parameter as true. In the future, this will probably be changed into using an -// enum for the kind of the view, that can be DESKTOP, MOBILEPHONE, or TABLET. +// Call either setMobilePhone() or setTablet() for a view, and at most once. (If neither is called, +// the view is assumed to be on a desktop browser.) In the future, this will possibly be changed +// into using an enum for the kind of the view, that can be DESKTOP, MOBILEPHONE, or TABLET. // Tell that LOK view is on a mobile phone (regardless what its pixel resolution is, whether its form factor is "phablet" or not) -COMPHELPER_DLLPUBLIC void setMobilePhone(int nViewId, bool bIsMobilePhone); +COMPHELPER_DLLPUBLIC void setMobilePhone(int nViewId); // Tell that LOK view is on a tablet -COMPHELPER_DLLPUBLIC void setTablet(int nViewId, bool bIsTablet); +COMPHELPER_DLLPUBLIC void setTablet(int nViewId); enum class statusIndicatorCallbackType { Start, SetValue, Finish }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
