summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2020-04-20 21:26:26 +0200
committerMichael Meeks <michael.meeks@collabora.com>2020-05-27 22:32:05 +0100
commit0469cdc945908a7c478d2ca715b0412d1e75c1e0 (patch)
tree213581f9a4986299a458dfc5bbfb91651b375f87
parent2bfbc4d4c83954bb46d0dc34e2838cefa62cf5a2 (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/+/93340 Tested-by: Jenkins 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.cxx6
-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
-rw-r--r--sw/source/ui/dialog/wordcountdialog.cxx4
26 files changed, 85 insertions, 81 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 396b5ab69a88..622052d9af38 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();
if (isMobilePhone)
return;
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index c58a1aa6f547..0f665f1be202 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -91,12 +91,6 @@ static LanguageAndLocale g_aLanguageAndLocale;
/// Scaling of the cairo 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;
@@ -107,36 +101,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 3de57d8cee3c..648e7421c54f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2170,6 +2170,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,
@@ -3766,17 +3769,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;
@@ -5029,6 +5022,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 a5770473356c..52c5668ccb84 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1083,11 +1083,11 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
-
if (comphelper::LibreOfficeKit::isActive())
{
- // For mobile phone, send the context menu structure
- if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ // For mobile phones, send the context menu structure
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (pViewShell && pViewShell->isLOKMobilePhone())
{
LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
return;
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 9e91d148e438..a7a64a18a4ba 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -62,6 +62,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 e81d2db11b7b..f416dcf07706 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -109,6 +109,13 @@ namespace o3tl
<SfxViewShell>.
*/
+enum class LOKDeviceFormFactor
+{
+ UNKNOWN = 0,
+ DESKTOP = 1,
+ TABLET = 2,
+ MOBILE = 3
+};
class SfxViewFactory;
#define SFX_DECL_VIEWFACTORY(Class) \
@@ -152,6 +159,7 @@ friend class SfxPrinterController;
bool mbPrinterSettingsModified;
LanguageTag maLOKLanguageTag;
LanguageTag maLOKLocale;
+ LOKDeviceFormFactor maLOKDeviceFormFactor;
protected:
virtual void Activate(bool IsMDIActivate) override;
@@ -352,6 +360,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 f50d41e029ae..db6286f431d3 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1300,11 +1300,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 55e6613d5256..626c5b2d0a71 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -821,7 +821,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::isMobile(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (!comphelper::LibreOfficeKit::isActive() || !(pViewShell && pViewShell->isLOKMobilePhone()))
maButton->Show();
}
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 2ebfaee33d27..921e3715310d 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -412,7 +412,7 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW,
weld::Window* pParent, ScViewData* pViewData,
const ScCondFormatDlgItem* pItem)
: ScAnyRefDlgController(pB, pCW, pParent,
- (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"),
"ConditionalFormatDialog")
, mpViewData(pViewData)
, mpDlgItem(static_cast<ScCondFormatDlgItem*>(pItem->Clone()))
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index fea85d23506e..5ada364b730a 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -47,7 +47,7 @@
ScCondFrmtEntry::ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos)
: mpParent(pParent)
- , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))))
+ , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), (SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui")))
, mxBorder(mxBuilder->weld_widget("border"))
, mxGrid(mxBuilder->weld_container("grid"))
, mxFtCondNr(mxBuilder->weld_label("number"))
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index eb05faccc730..a07f60d6679a 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -246,7 +246,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 db92bb27766b..0dec8ec99270 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -609,7 +609,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 e69356709fa9..8fdb2673e6c4 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 8360419b0bff..4e90c3c26127 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2218,11 +2218,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 44122ae91f43..facb25c9ddb1 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -336,8 +336,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 6c9cbe0d9e42..19487e808b6a 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2594,7 +2594,9 @@ OUString SdPage::GetPresObjText(PresObjKind eObjKind) const
#if defined(IOS) || defined(ANDROID)
bool isMobile = true;
#else
- bool isMobile = comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView());
+ bool isMobile = 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 1f693e7356cb..7e3b351f9ebe 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -524,7 +524,8 @@ void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
pTxtObj->AdjustTextFrameWidthAndHeight();
aSet.Put(makeSdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
pTxtObj->SetMergedItemSet(aSet);
- if (comphelper::LibreOfficeKit::isMobile(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 940b8dddbdad..693e11746349 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1147,7 +1147,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 110e331065ff..ade850c6388d 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -347,8 +347,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 93c56b1b92b9..ba61d0c23a11 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1228,7 +1228,8 @@ void SidebarController::RequestCloseDeck()
{
const vcl::ILibreOfficeKitNotifier* pNotifier = mpCurrentDeck->GetLOKNotifier();
auto pMobileNotifier = SfxViewShell::Current();
- if (pMobileNotifier && comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (pMobileNotifier && pViewShell && pViewShell->isLOKMobilePhone())
{
// Mobile.
std::stringstream aStream;
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index dd23ffbca51f..0544c998b8aa 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -65,7 +65,7 @@ public:
try
{
- if (comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
+ if (pMobileNotifier && pMobileNotifier->isLOKMobilePhone())
{
// Mobile.
std::stringstream aStream;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 576c364e72c5..0f78af7ebb74 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -65,6 +65,7 @@ int DisableCallbacks::m_nDisabled = 0;
namespace
{
static LanguageTag g_defaultLanguageTag("en-US", true);
+static LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
}
int SfxLokHelper::createView()
@@ -209,6 +210,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 0109448d1b79..50549d2ddb3e 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1083,8 +1083,8 @@ SfxViewShell::SfxViewShell
, mbPrinterSettingsModified(false)
, maLOKLanguageTag(LANGUAGE_NONE)
, maLOKLocale(LANGUAGE_NONE)
+, maLOKDeviceFormFactor(LOKDeviceFormFactor::UNKNOWN)
{
-
SetMargin( pViewFrame->GetMargin_Impl() );
SetPool( &pViewFrame->GetObjectShell()->GetPool() );
@@ -1099,6 +1099,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 f2b3d9ae492d..9accfcdd0c6a 100644
--- a/svx/source/sidebar/text/TextPropertyPanel.cxx
+++ b/svx/source/sidebar/text/TextPropertyPanel.cxx
@@ -50,8 +50,9 @@ TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Ref
get(mpSetDefault, "defaultattr");
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");
diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index b7ef6dda23ca..3dd7149b558e 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -34,7 +34,7 @@
#include <comphelper/lok.hxx>
#include <sfx2/lokhelper.hxx>
-#define IS_MOBILE (comphelper::LibreOfficeKit::isActive() && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+#define IS_MOBILE_PHONE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
SwWordCountFloatDlg::~SwWordCountFloatDlg()
{
@@ -107,7 +107,7 @@ SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
SfxChildWindow* pChild,
weld::Window *pParent,
SfxChildWinInfo const * pInfo)
- : SfxModelessDialogController(_pBindings, pChild, pParent, IS_MOBILE ? OUString("modules/swriter/ui/wordcount-mobile.ui") : OUString("modules/swriter/ui/wordcount.ui"), "WordCountDialog")
+ : SfxModelessDialogController(_pBindings, pChild, pParent, IS_MOBILE_PHONE ? OUString("modules/swriter/ui/wordcount-mobile.ui") : OUString("modules/swriter/ui/wordcount.ui"), "WordCountDialog")
, m_xCurrentWordFT(m_xBuilder->weld_label("selectwords"))
, m_xCurrentCharacterFT(m_xBuilder->weld_label("selectchars"))
, m_xCurrentCharacterExcludingSpacesFT(m_xBuilder->weld_label("selectcharsnospaces"))