summaryrefslogtreecommitdiffstats
path: root/include/sfx2
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2020-04-20 21:26:26 +0200
committerAndras Timar <andras.timar@collabora.com>2020-04-29 09:53:54 +0200
commit73bcf660f419a01b0a5377264e88796d91220c2f (patch)
tree13a162d46086202469b95fdfd5c2b16e88442625 /include/sfx2
parenttdf#132381: Avoid XOR paint in Crop dialog (diff)
downloadcore-73bcf660f419a01b0a5377264e88796d91220c2f.tar.gz
core-73bcf660f419a01b0a5377264e88796d91220c2f.zip
lok: set device form factor of the client on view creation
This patch allows the lok core to know about the device form facor of the client requesting the creation of new view, immediately instead of a later time. When a new view is needed a "DeviceFormFactor" parameter is forwarded to lo_documentLoadWithOptions and doc_createViewWithOptions from the client. This parameter can have one of the following values: 'desktop', 'tablet','mobile' and it is used to set a global variable accessible by SfxLokHelper::setDeviceFormFactor and SfxLokHelper::getDeviceFormFactor. This global variable is retrived in the SfxViewShell constructor for setting SfxViewShell::maLOKDeviceFormFactor attribute. In SfxViewShell we have the following 3 methods: - bool isLOKDesktop() - bool isLOKTablet() - bool isLOKMobilePhone() which replace the following boolean functions: - comphelper::LibreOfficeKit::isTablet - comphelper::LibreOfficeKit::::isMobilePhone Change-Id: I9b36f354278df8c216fcb90f6a9da8256ec9c1e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92689 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'include/sfx2')
-rw-r--r--include/sfx2/lokhelper.hxx4
-rw-r--r--include/sfx2/viewsh.hxx16
2 files changed, 20 insertions, 0 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 8f2fa97a38f7..63c88b988b2e 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -63,6 +63,10 @@ public:
static void setDefaultLanguage(const OUString& rBcp47LanguageTag);
/// Set the locale for the given view.
static void setViewLocale(int nId, const OUString& rBcp47LanguageTag);
+ /// Get the device form factor that should be used for a new view.
+ static LOKDeviceFormFactor getDeviceFormFactor();
+ /// Set the device form factor that should be used for a new view.
+ static void setDeviceFormFactor(const OUString& rDeviceFormFactor);
/// Iterate over any view shell, except pThisViewShell, passing it to the f function.
template<typename ViewShellType, typename FunctionType>
static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f);
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 376b55911be8..6628b7f822aa 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -113,6 +113,13 @@ namespace o3tl
<SfxViewShell>.
*/
+enum class LOKDeviceFormFactor
+{
+ UNKNOWN = 0,
+ DESKTOP = 1,
+ TABLET = 2,
+ MOBILE = 3
+};
class SfxViewFactory;
#define SFX_DECL_VIEWFACTORY(Class) \
@@ -156,6 +163,7 @@ friend class SfxPrinterController;
bool mbPrinterSettingsModified;
LanguageTag maLOKLanguageTag;
LanguageTag maLOKLocale;
+ LOKDeviceFormFactor maLOKDeviceFormFactor;
protected:
virtual void Activate(bool IsMDIActivate) override;
@@ -353,6 +361,14 @@ public:
void SetLOKLocale(const OUString& rBcp47LanguageTag);
/// Get the LibreOfficeKit locale of this view.
const LanguageTag& GetLOKLocale() const { return maLOKLocale; }
+ /// Get the form factor of the device where the lok client is running.
+ LOKDeviceFormFactor GetLOKDeviceFormFactor() const { return maLOKDeviceFormFactor; }
+ /// Check if the lok client is running on a desktop machine.
+ bool isLOKDesktop() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::DESKTOP; }
+ /// Check if the lok client is running on a tablet.
+ bool isLOKTablet() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::TABLET; }
+ /// Check if the lok client is running on a mobile device.
+ bool isLOKMobilePhone() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::MOBILE; }
};