chart2/source/controller/main/ChartController_Window.cxx | 4 - comphelper/source/misc/lok.cxx | 31 ++++++++++----- desktop/source/lib/init.cxx | 20 +++++++-- include/comphelper/lok.hxx | 14 ++++-- sc/source/ui/app/inputhdl.cxx | 2 sc/source/ui/app/inputwin.cxx | 2 sc/source/ui/condformat/condformatdlg.cxx | 2 sc/source/ui/condformat/condformatdlgentry.cxx | 2 sc/source/ui/drawfunc/fuins2.cxx | 2 sc/source/ui/sidebar/AlignmentPropertyPanel.cxx | 2 sc/source/ui/view/gridwin.cxx | 5 +- sc/source/ui/view/viewfun5.cxx | 2 sd/source/core/sdpage.cxx | 20 ++++----- sd/source/ui/func/futext.cxx | 2 sfx2/source/sidebar/Deck.cxx | 2 sfx2/source/sidebar/SidebarController.cxx | 4 - sfx2/source/sidebar/SidebarDockingWindow.cxx | 6 +- svx/source/sidebar/text/TextPropertyPanel.cxx | 10 ++-- 18 files changed, 81 insertions(+), 51 deletions(-)
New commits: commit fc5400b167f1f6a9a788acfd5894622f440ee5f5 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Mon Mar 16 13:50:00 2020 +0200 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Mon Mar 16 15:14:01 2020 +0100 Rename isMobile to isMobilePhone and introduce a separate isTablet The intended semantics of isMobile() has been to say whether the device is a mobile phone ot not. Not whether it is a mobile device in general. So make that explicit. Adjust call sites as necessary. Also, in a couple of places where it is likely that what is relevant is whether it is a mobile device in general, not just whether it is a mobile phone, check both isMobile() and isTablet(). For stable interoperability with current Online, keep accepting also the .uno:LOKSetMobile "command" (and .uno:LOKUnSetMobile, except that Online never sends that), but Online will be changed to use .uno:LOKSetMobilePhone. Also drop the default value for the bool parameter to setMobilePhone(). Default bool parameters can be quite confusing, and it was especially silly in this case as there is one (1) call site. Change-Id: I2a71c37323ee151cbc671bd8e714e1dee10f8b1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90560 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 8cd01a2e1e09..df059206c4ba 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -931,8 +931,8 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) void ChartController::execute_DoubleClick( const Point* pMousePixel ) { - bool isMobile = comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()); - if (isMobile) + bool isMobilePhone = comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()); + if (isMobilePhone) return; bool bEditText = false; diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index 7bfd776369e3..1f78c29f8b97 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -87,8 +87,11 @@ static LanguageAndLocale g_aLanguageAndLocale; /// Scaling of the cairo or CoreGraphics canvas painting for hi-dpi static double g_fDPIScale(1.0); -/// List of <viewid, bMobile> pairs -static std::map<int, bool> g_vIsViewMobile; +/// 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) { @@ -100,18 +103,28 @@ bool isActive() return g_bActive; } -void setMobile(int nViewId, bool bMobile) +void setMobilePhone(int nViewId, bool bIsMobilePhone) +{ + g_vIsViewMobilePhone[nViewId] = bIsMobilePhone; +} + +bool isMobilePhone(int nViewId) { - if (g_vIsViewMobile.find(nViewId) != g_vIsViewMobile.end()) - g_vIsViewMobile[nViewId] = bMobile; + if (g_vIsViewMobilePhone.find(nViewId) != g_vIsViewMobilePhone.end()) + return g_vIsViewMobilePhone[nViewId]; else - g_vIsViewMobile.insert(std::make_pair(nViewId, bMobile)); + return false; +} + +void setTablet(int nViewId, bool bIsTablet) +{ + g_vIsViewTablet[nViewId] = bIsTablet; } -bool isMobile(int nViewId) +bool isTablet(int nViewId) { - if (g_vIsViewMobile.find(nViewId) != g_vIsViewMobile.end()) - return g_vIsViewMobile[nViewId]; + if (g_vIsViewTablet.find(nViewId) != g_vIsViewTablet.end()) + return g_vIsViewTablet[nViewId]; else return false; } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d64e827e006a..95762d537e1c 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3623,15 +3623,25 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma if (nView < 0) return; - // Set/unset mobile view for LOK - if (gImpl && aCommand == ".uno:LOKSetMobile") + // Set/unset mobile phone view for LOK + if (gImpl && (aCommand == ".uno:LOKSetMobile" || aCommand == ".uno:LOKSetMobilePhone")) { - comphelper::LibreOfficeKit::setMobile(nView); + comphelper::LibreOfficeKit::setMobilePhone(nView, true); return; } - else if (gImpl && aCommand == ".uno:LOKUnSetMobile") + else if (gImpl && (aCommand == ".uno:LOKUnSetMobile" || aCommand == ".uno:LOKUnSetMobilePhone")) { - comphelper::LibreOfficeKit::setMobile(nView, false); + comphelper::LibreOfficeKit::setMobilePhone(nView, false); + return; + } + else if (gImpl && aCommand == ".uno:LOKSetTablet") + { + comphelper::LibreOfficeKit::setTablet(nView, true); + return; + } + else if (gImpl && aCommand == ".uno:LOKUnSetTablet") + { + comphelper::LibreOfficeKit::setTablet(nView, false); return; } else if (gImpl && aCommand == ".uno:ToggleOrientation") diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx index ca875b8df4a2..d88ddfd1dfa5 100644 --- a/include/comphelper/lok.hxx +++ b/include/comphelper/lok.hxx @@ -29,8 +29,11 @@ namespace LibreOfficeKit COMPHELPER_DLLPUBLIC void setActive(bool bActive = true); -// Set LOK view to mobile -COMPHELPER_DLLPUBLIC void setMobile(int nViewId, bool bIsMobile = true); +// 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); + +// Tell that LOK view is on a tablet +COMPHELPER_DLLPUBLIC void setTablet(int nViewId, bool bIsTablet); enum class statusIndicatorCallbackType { Start, SetValue, Finish }; @@ -42,8 +45,11 @@ 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 view/device -COMPHELPER_DLLPUBLIC bool isMobile(int nViewId); +// 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. diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 5c4d4de77f96..cdbf075e0161 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1304,7 +1304,7 @@ namespace { void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec ) { if (comphelper::LibreOfficeKit::isActive() && - comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) { SfxViewShell* pViewShell = SfxViewShell::Current(); if (pViewShell && rFuncStrVec.size()) diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 5193e9e28d6e..fa84747e17be 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -866,7 +866,7 @@ 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())) + if (!comphelper::LibreOfficeKit::isActive() || !comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) maButton->Show(); maScrollbar->SetSizePixel(aSize); diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 4cf3fd1fc951..6048d2bf1d64 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::isMobile(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalformatdialogmobile.ui"):OUString("modules/scalc/ui/conditionalformatdialog.ui"))) + (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())?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 487f08d0eb05..6e892f338d71 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::isMobile(SfxLokHelper::getView())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui")))); + m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())?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/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index 3ece0c405d6a..bcc40e20b438 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::isMobile(SfxLokHelper::getView())) + else if (!comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) { //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 68760df7c81d..b17684e845a0 100644 --- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx @@ -170,7 +170,7 @@ boost::property_tree::ptree AlignmentPropertyPanel::DumpAsPropertyTree() { boost::property_tree::ptree aTree = PanelLayout::DumpAsPropertyTree(); - if (comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) { eraseNode(aTree, "textorientbox"); } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 2a751f77ac99..a3e3cc793118 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -2194,10 +2194,11 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) ScGlobal::OpenURL(aUrl, aTarget, isTiledRendering); return; } - // in mobile view there is no ctrl+click and for hyperlink popup + // 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::isMobile(SfxLokHelper::getView())) + (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) || + comphelper::LibreOfficeKit::isTablet(SfxLokHelper::getView()))) { ScTabViewShell* pViewShell = pViewData->GetViewShell(); Point aPos = rMEvt.GetPosPixel(); diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index de6cfd7e137a..300b740bf2f1 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -338,7 +338,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId, { // Do CSV dialog if more than one line. But not if invoked from Automation. sal_Int32 nDelim = pStrBuffer->indexOf('\n'); - if (!comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()) && !comphelper::Automation::AutomationInvokedZone::isActive() + if (!comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) && !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 c3c81c926906..53819a6dc416 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -2609,9 +2609,9 @@ OUString SdPage::GetPresObjText(PresObjKind eObjKind) const OUString aString; #if defined(IOS) || defined(ANDROID) - bool isMobile = true; + bool isMobileDevice = true; #else - bool isMobile = comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()); + bool isMobileDevice = comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) || comphelper::LibreOfficeKit::isTablet(SfxLokHelper::getView()); #endif if (eObjKind == PRESOBJ_TITLE) @@ -2620,20 +2620,20 @@ OUString SdPage::GetPresObjText(PresObjKind eObjKind) const { if (mePageKind != PageKind::Notes) { - if (isMobile) + if (isMobileDevice) aString = SdResId(STR_PRESOBJ_MPTITLE_MOBILE); else aString = SdResId(STR_PRESOBJ_MPTITLE); } else { - if (isMobile) + if (isMobileDevice) aString = SdResId(STR_PRESOBJ_MPNOTESTITLE_MOBILE); else aString = SdResId(STR_PRESOBJ_MPNOTESTITLE); } } - else if (isMobile) + else if (isMobileDevice) aString = SdResId(STR_PRESOBJ_TITLE_MOBILE); else aString = SdResId(STR_PRESOBJ_TITLE); @@ -2642,12 +2642,12 @@ OUString SdPage::GetPresObjText(PresObjKind eObjKind) const { if (mbMaster) { - if (isMobile) + if (isMobileDevice) aString = SdResId(STR_PRESOBJ_MPOUTLINE_MOBILE); else aString = SdResId(STR_PRESOBJ_MPOUTLINE); } - else if (isMobile) + else if (isMobileDevice) aString = SdResId(STR_PRESOBJ_OUTLINE_MOBILE); else aString = SdResId(STR_PRESOBJ_OUTLINE); @@ -2656,19 +2656,19 @@ OUString SdPage::GetPresObjText(PresObjKind eObjKind) const { if (mbMaster) { - if (isMobile) + if (isMobileDevice) aString = SdResId(STR_PRESOBJ_MPNOTESTEXT_MOBILE); else aString = SdResId(STR_PRESOBJ_MPNOTESTEXT); } - else if (isMobile) + else if (isMobileDevice) aString = SdResId(STR_PRESOBJ_NOTESTEXT_MOBILE); else aString = SdResId(STR_PRESOBJ_NOTESTEXT); } else if (eObjKind == PRESOBJ_TEXT) { - if (isMobile) + if (isMobileDevice) aString = SdResId(STR_PRESOBJ_TEXT_MOBILE); else aString = SdResId(STR_PRESOBJ_TEXT); diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 8b2b1108119b..e5d1597735b4 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -530,7 +530,7 @@ void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj) pTxtObj->AdjustTextFrameWidthAndHeight(); aSet.Put(makeSdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height())); pTxtObj->SetMergedItemSet(aSet); - if (comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()) || comphelper::LibreOfficeKit::isTablet(SfxLokHelper::getView())) pTxtObj->SetText(SdResId(STR_PRESOBJ_TEXT_EDIT_MOBILE)); } else if( nSlotId == SID_ATTR_CHAR_VERTICAL ) diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index ba8f4928ac0b..fd87430a9b70 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -300,7 +300,7 @@ void Deck::RequestLayout() bChangeNeeded = true; } if (mnMinimalWidth > 0 && (mnMinimalWidth != aParentSize.Width() || GetSizePixel().Width() != mnMinimalWidth) - && comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) { aParentSize.setWidth(mnMinimalWidth); bChangeNeeded = true; diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index c885066ef5c9..10cd448771fa 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1222,9 +1222,9 @@ void SidebarController::RequestCloseDeck() { const vcl::ILibreOfficeKitNotifier* pNotifier = mpCurrentDeck->GetLOKNotifier(); auto pMobileNotifier = SfxViewShell::Current(); - if (pMobileNotifier && comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + if (pMobileNotifier && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) { - // Mobile. + // Mobile phone. std::stringstream aStream; boost::property_tree::ptree aTree; aTree.put("id", mpCurrentDeck->GetLOKWindowId()); diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index 2bf4ea7258bb..13aa2b13dba4 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -62,9 +62,9 @@ public: try { - if (comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) { - // Mobile. + // Mobile phone. std::stringstream aStream; boost::property_tree::ptree aTree = m_rSidebarDockingWin.DumpAsPropertyTree(); aTree.put("id", m_rSidebarDockingWin.GetLOKWindowId()); @@ -78,7 +78,7 @@ public: } // Notify the sidebar is created, and its LOKWindowId, which - // is needed on both Mobile and Desktop. + // is needed on mobile phones, tablets, and desktop. const Point pos = Point(m_rSidebarDockingWin.GetOutOffXPixel(), m_rSidebarDockingWin.GetOutOffYPixel()); const OString posMessage = pos.toString(); diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx index eae6f95aa366..6aa27cd3cd59 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.cxx +++ b/svx/source/sidebar/text/TextPropertyPanel.cxx @@ -47,14 +47,14 @@ TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Ref get(mpToolBoxFontColor, "colorbar_others"); get(mpToolBoxBackgroundColor, "colorbar_background"); - bool isMobile = false; + bool isMobilePhone = false; if (comphelper::LibreOfficeKit::isActive() && - comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) - isMobile = true; + comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView())) + isMobilePhone = true; VclPtr<ToolBox> xSpacingBar; get(xSpacingBar, "spacingbar"); - xSpacingBar->Show(!isMobile); - xSpacingBar->ShowItem(0, !isMobile); + xSpacingBar->Show(!isMobilePhone); + xSpacingBar->ShowItem(0, !isMobilePhone); } TextPropertyPanel::~TextPropertyPanel() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits