summaryrefslogtreecommitdiff
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
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>
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx3
-rw-r--r--comphelper/source/misc/lok.cxx36
-rw-r--r--desktop/source/lib/init.cxx18
-rw-r--r--editeng/source/editeng/editview.cxx5
-rw-r--r--include/comphelper/lok.hxx6
-rw-r--r--include/sfx2/lokhelper.hxx4
-rw-r--r--include/sfx2/viewsh.hxx16
-rw-r--r--sc/source/ui/app/inputhdl.cxx6
-rw-r--r--sc/source/ui/app/inputwin.cxx3
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx2
-rw-r--r--sc/source/ui/condformat/condformatdlgentry.cxx2
-rw-r--r--sc/source/ui/drawfunc/fudraw.cxx2
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx2
-rw-r--r--sc/source/ui/sidebar/AlignmentPropertyPanel.cxx3
-rw-r--r--sc/source/ui/view/gridwin.cxx7
-rw-r--r--sc/source/ui/view/viewfun5.cxx3
-rw-r--r--sd/source/core/sdpage.cxx4
-rw-r--r--sd/source/ui/func/futext.cxx3
-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
-rw-r--r--svx/source/sidebar/text/TextPropertyPanel.cxx3
25 files changed, 83 insertions, 78 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index df059206c4ba..859644a221ec 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -931,7 +931,8 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
void ChartController::execute_DoubleClick( const Point* pMousePixel )
{
- bool isMobilePhone = comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView());
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ bool isMobilePhone = pViewShell ? pViewShell->isLOKMobilePhone() : false;
if (isMobilePhone)
return;
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index ed2b3dac3f03..3527597f6961 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -87,12 +87,6 @@ static LanguageAndLocale g_aLanguageAndLocale;
/// Scaling of the cairo or CoreGraphics canvas painting for hi-dpi
static double g_fDPIScale(1.0);
-/// Which views are on mobile phones?
-static std::map<int, bool> g_vIsViewMobilePhone;
-
-/// Which views are on tablets?
-static std::map<int, bool> g_vIsViewTablet;
-
void setActive(bool bActive)
{
g_bActive = bActive;
@@ -103,36 +97,6 @@ bool isActive()
return g_bActive;
}
-void setMobilePhone(int nViewId)
-{
- assert(!isMobilePhone(nViewId));
- assert(!isTablet(nViewId));
- g_vIsViewMobilePhone[nViewId] = true;
-}
-
-bool isMobilePhone(int nViewId)
-{
- if (g_vIsViewMobilePhone.find(nViewId) != g_vIsViewMobilePhone.end())
- return g_vIsViewMobilePhone[nViewId];
- else
- return false;
-}
-
-void setTablet(int nViewId)
-{
- assert(!isMobilePhone(nViewId));
- assert(!isTablet(nViewId));
- g_vIsViewTablet[nViewId] = true;
-}
-
-bool isTablet(int nViewId)
-{
- if (g_vIsViewTablet.find(nViewId) != g_vIsViewTablet.end())
- return g_vIsViewTablet[nViewId];
- else
- return false;
-}
-
void setPartInInvalidation(bool bPartInInvalidation)
{
g_bPartInInvalidation = bPartInInvalidation;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cde112ba3fa4..c735451b8e0c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2165,6 +2165,9 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
SvNumberFormatter::resetTheCurrencyTable();
}
+ const OUString aDeviceFormFactor = extractParameter(aOptions, "DeviceFormFactor");
+ SfxLokHelper::setDeviceFormFactor(aDeviceFormFactor);
+
uno::Sequence<css::beans::PropertyValue> aFilterOptions(2);
aFilterOptions[0] = css::beans::PropertyValue( "FilterOptions",
0,
@@ -3637,17 +3640,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
if (nView < 0)
return;
- if (gImpl && (aCommand == ".uno:LOKSetMobile" || aCommand == ".uno:LOKSetMobilePhone"))
- {
- comphelper::LibreOfficeKit::setMobilePhone(nView);
- return;
- }
- else if (gImpl && aCommand == ".uno:LOKSetTablet")
- {
- comphelper::LibreOfficeKit::setTablet(nView);
- return;
- }
- else if (gImpl && aCommand == ".uno:ToggleOrientation")
+ if (gImpl && aCommand == ".uno:ToggleOrientation")
{
ExecuteOrientationChange();
return;
@@ -4894,6 +4887,9 @@ static int doc_createViewWithOptions(LibreOfficeKitDocument* pThis,
comphelper::LibreOfficeKit::setLocale(LanguageTag(aLanguage));
}
+ const OUString aDeviceFormFactor = extractParameter(aOptions, "DeviceFormFactor");
+ SfxLokHelper::setDeviceFormFactor(aDeviceFormFactor);
+
int nId = SfxLokHelper::createView();
#ifdef IOS
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index c598f36afbfa..aa39a3ce9716 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1083,13 +1083,14 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
if (comphelper::LibreOfficeKit::isActive())
{
// For mobile, send the context menu structure
- if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (pViewShell && pViewShell->isLOKMobilePhone())
{
LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
return;
}
else // For desktop, we use the tunneled dialog
- aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+ aPopupMenu->SetLOKNotifier(pViewShell);
}
sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index 09d4f682341e..88901a24d991 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -49,12 +49,6 @@ COMPHELPER_DLLPUBLIC void setStatusIndicatorCallback(void (*callback)(void *data
// Check whether the code is running as invoked through LibreOfficeKit.
COMPHELPER_DLLPUBLIC bool isActive();
-// Check whether we are serving to a mobile phone
-COMPHELPER_DLLPUBLIC bool isMobilePhone(int nViewId);
-
-// Check whether we are serving to a tablet
-COMPHELPER_DLLPUBLIC bool isTablet(int nViewId);
-
/// Shift the coordinates before rendering each bitmap.
/// Used by Calc to render each tile separately.
/// This should be unnecessary (and removed) once Calc
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; }
};
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index cdbf075e0161..cc686f65834b 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1303,11 +1303,11 @@ namespace {
void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec )
{
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
if (comphelper::LibreOfficeKit::isActive() &&
- comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ pViewShell && pViewShell->isLOKMobilePhone())
{
- SfxViewShell* pViewShell = SfxViewShell::Current();
- if (pViewShell && rFuncStrVec.size())
+ if (rFuncStrVec.size())
{
OUString aFuncNameStr;
OUString aDescFuncNameStr;
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 161cb90806c1..3dd89beb22ae 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -868,7 +868,8 @@ ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, ScTabViewShell* pViewSh)
maButton->SetSymbol(SymbolType::SPIN_DOWN);
maButton->SetQuickHelpText(ScResId(SCSTR_QHELP_EXPAND_FORMULA));
// disable the multiline toggle on the mobile phones
- if (!comphelper::LibreOfficeKit::isActive() || !comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (!comphelper::LibreOfficeKit::isActive() || !(pViewShell && pViewShell->isLOKMobilePhone()))
maButton->Show();
maScrollbar->SetSizePixel(aSize);
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 6048d2bf1d64..93fb8b25360e 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -518,7 +518,7 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW,
vcl::Window* pParent, ScViewData* pViewData,
const ScCondFormatDlgItem* pItem)
: ScAnyRefDlg(pB, pCW, pParent, "ConditionalFormatDialog",
- (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalformatdialogmobile.ui"):OUString("modules/scalc/ui/conditionalformatdialog.ui")))
+ ((SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())?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 6e892f338d71..f6993fde5ac8 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -50,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::isMobilePhone(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))));
+ m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), ((SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))));
get(maGrid, "grid");
get(maFtCondNr, "number");
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index c60890c23c15..46ee788ad770 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -250,7 +250,7 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt)
if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
{
SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
- bool isMobilePhone = comphelper::LibreOfficeKit::isActive() && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView());
+ bool isMobilePhone = comphelper::LibreOfficeKit::isActive() && rViewShell.isLOKMobilePhone();
// Double tapping on charts on phone may result in activating the edit mode which is not wanted.
// It happens due to the delay of selection message of the object from kit to javascript
// in that case F2 is sent instead of double click
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index bcc40e20b438..b19a1392e5db 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -670,7 +670,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
if( xChartModel.is() )
xChartModel->unlockControllers();
}
- else if (!comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ else if (!rViewSh.isLOKMobilePhone())
{
//the controller will be unlocked by the dialog when the dialog is told to do so
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index b17684e845a0..b29caa4276b0 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -170,7 +170,8 @@ boost::property_tree::ptree AlignmentPropertyPanel::DumpAsPropertyTree()
{
boost::property_tree::ptree aTree = PanelLayout::DumpAsPropertyTree();
- if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (pViewShell && pViewShell->isLOKMobilePhone())
{
eraseNode(aTree, "textorientbox");
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0e7701fb913a..14d96448f283 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2233,11 +2233,10 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
}
// On a mobile device view there is no ctrl+click and for hyperlink popup
// the cell coordinates must be sent along with click position for elegance
- if (isTiledRendering &&
- (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) ||
- comphelper::LibreOfficeKit::isTablet(SfxLokHelper::getView())))
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ if (isTiledRendering && pViewShell &&
+ (pViewShell->isLOKMobilePhone() || pViewShell->isLOKTablet()))
{
- ScTabViewShell* pViewShell = pViewData->GetViewShell();
Point aPos = rMEvt.GetPosPixel();
SCCOL nPosX;
SCROW nPosY;
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 300b740bf2f1..71fe749ec456 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -337,8 +337,9 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
&& aDataHelper.GetString( nFormatId, *pStrBuffer ))
{
// Do CSV dialog if more than one line. But not if invoked from Automation.
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
sal_Int32 nDelim = pStrBuffer->indexOf('\n');
- if (!comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) && !comphelper::Automation::AutomationInvokedZone::isActive()
+ if (!(pViewShell && pViewShell->isLOKMobilePhone()) && !comphelper::Automation::AutomationInvokedZone::isActive()
&& nDelim >= 0 && nDelim != pStrBuffer->getLength () - 1)
{
vcl::Window* pParent = GetActiveWin();
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 53819a6dc416..91ad345e8edf 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2611,7 +2611,9 @@ OUString SdPage::GetPresObjText(PresObjKind eObjKind) const
#if defined(IOS) || defined(ANDROID)
bool isMobileDevice = true;
#else
- bool isMobileDevice = comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) || comphelper::LibreOfficeKit::isTablet(SfxLokHelper::getView());
+ bool isMobileDevice = false;
+ if (const SfxViewShell* pCurrentViewShell = SfxViewShell::Current())
+ isMobileDevice = pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKMobilePhone();
#endif
if (eObjKind == PRESOBJ_TITLE)
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index e5d1597735b4..294d3c6a53e2 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -530,7 +530,8 @@ void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
pTxtObj->AdjustTextFrameWidthAndHeight();
aSet.Put(makeSdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
pTxtObj->SetMergedItemSet(aSet);
- if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) || comphelper::LibreOfficeKit::isTablet(SfxLokHelper::getView()))
+ const SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
+ if (pCurrentViewShell && (pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet()))
pTxtObj->SetText(SdResId(STR_PRESOBJ_TEXT_EDIT_MOBILE));
}
else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
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);
diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx
index 6aa27cd3cd59..2c8e0ccf20cc 100644
--- a/svx/source/sidebar/text/TextPropertyPanel.cxx
+++ b/svx/source/sidebar/text/TextPropertyPanel.cxx
@@ -48,8 +48,9 @@ TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Ref
get(mpToolBoxBackgroundColor, "colorbar_background");
bool isMobilePhone = false;
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
if (comphelper::LibreOfficeKit::isActive() &&
- comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ pViewShell && pViewShell->isLOKMobilePhone())
isMobilePhone = true;
VclPtr<ToolBox> xSpacingBar;
get(xSpacingBar, "spacingbar");