summaryrefslogtreecommitdiff
path: root/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 /sfx2
parent56b207065ce0b4c86178131ae43fbbc31165727e (diff)
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 'sfx2')
-rw-r--r--sfx2/source/control/unoctitm.cxx3
-rw-r--r--sfx2/source/sidebar/Deck.cxx3
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx3
-rw-r--r--sfx2/source/sidebar/SidebarDockingWindow.cxx2
-rw-r--r--sfx2/source/view/lokhelper.cxx18
-rw-r--r--sfx2/source/view/viewsh.cxx4
6 files changed, 28 insertions, 5 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index cedf079234ff..27daebaf3e9e 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1114,7 +1114,8 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
aEvent.FeatureURL.Path == "TransformWidth" ||
aEvent.FeatureURL.Path == "TransformHeight")
{
- if (aEvent.IsEnabled && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (aEvent.IsEnabled && pViewShell && pViewShell->isLOKMobilePhone())
{
boost::property_tree::ptree aTree;
boost::property_tree::ptree aState;
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index fd87430a9b70..ea1c920fd962 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -299,8 +299,9 @@ void Deck::RequestLayout()
aParentSize.setHeight(mnMinimalHeight);
bChangeNeeded = true;
}
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
if (mnMinimalWidth > 0 && (mnMinimalWidth != aParentSize.Width() || GetSizePixel().Width() != mnMinimalWidth)
- && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ && pViewShell && pViewShell->isLOKMobilePhone())
{
aParentSize.setWidth(mnMinimalWidth);
bChangeNeeded = true;
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 10cd448771fa..ac3bd38f1743 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1222,7 +1222,8 @@ void SidebarController::RequestCloseDeck()
{
const vcl::ILibreOfficeKitNotifier* pNotifier = mpCurrentDeck->GetLOKNotifier();
auto pMobileNotifier = SfxViewShell::Current();
- if (pMobileNotifier && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (pMobileNotifier && pViewShell && pViewShell->isLOKMobilePhone())
{
// Mobile phone.
std::stringstream aStream;
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 13aa2b13dba4..ed4ac31d81c6 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -62,7 +62,7 @@ public:
try
{
- if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ if (pMobileNotifier->isLOKMobilePhone())
{
// Mobile phone.
std::stringstream aStream;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 012ee8cf633d..4fb7761cec95 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -61,6 +61,7 @@ int DisableCallbacks::m_nDisabled = 0;
namespace
{
static LanguageTag g_defaultLanguageTag("en-US", true);
+static LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
}
int SfxLokHelper::createView()
@@ -205,6 +206,23 @@ void SfxLokHelper::setViewLocale(int nId, const OUString& rBcp47LanguageTag)
}
}
+LOKDeviceFormFactor SfxLokHelper::getDeviceFormFactor()
+{
+ return g_deviceFormFactor;
+}
+
+void SfxLokHelper::setDeviceFormFactor(const OUString& rDeviceFormFactor)
+{
+ if (rDeviceFormFactor == "desktop")
+ g_deviceFormFactor = LOKDeviceFormFactor::DESKTOP;
+ else if (rDeviceFormFactor == "tablet")
+ g_deviceFormFactor = LOKDeviceFormFactor::TABLET;
+ else if (rDeviceFormFactor == "mobile")
+ g_deviceFormFactor = LOKDeviceFormFactor::MOBILE;
+ else
+ g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
+}
+
static OString lcl_escapeQuotes(const OString &rStr)
{
if (rStr.getLength() < 1)
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 5ac368075d15..6728f866d0cf 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1069,8 +1069,8 @@ SfxViewShell::SfxViewShell
, mbPrinterSettingsModified(false)
, maLOKLanguageTag(LANGUAGE_NONE)
, maLOKLocale(LANGUAGE_NONE)
+, maLOKDeviceFormFactor(LOKDeviceFormFactor::UNKNOWN)
{
-
SetMargin( pViewFrame->GetMargin_Impl() );
SetPool( &pViewFrame->GetObjectShell()->GetPool() );
@@ -1085,6 +1085,8 @@ SfxViewShell::SfxViewShell
maLOKLanguageTag = SfxLokHelper::getDefaultLanguage();
maLOKLocale = SfxLokHelper::getDefaultLanguage();
+ maLOKDeviceFormFactor = SfxLokHelper::getDeviceFormFactor();
+
vcl::Window* pFrameWin = pViewFrame->GetWindow().GetFrameWindow();
if (pFrameWin && !pFrameWin->GetLOKNotifier())
pFrameWin->SetLOKNotifier(this, true);