34#include <bitmaps.hlst>
36#include <com/sun/star/beans/PropertyValue.hpp>
37#include <com/sun/star/frame/XFrame.hpp>
38#include <com/sun/star/lang/XServiceInfo.hpp>
40#include <svx/strings.hrc>
48class SelectionTypePopup
51 std::unique_ptr<weld::Builder> m_xBuilder;
52 std::unique_ptr<weld::Menu> m_xMenu;
53 static OUString state_to_id(sal_uInt16 nState);
55 SelectionTypePopup(
weld::Window* pPopupParent, sal_uInt16 nCurrent);
56 OUString GetItemTextForState(sal_uInt16 nState) {
return m_xMenu->get_label(state_to_id(nState)); }
59 return m_xMenu->popup_at_rect(m_pPopupParent, rRect);
61 void HideSelectionType(
const OUString& rIdent)
63 m_xMenu->remove(rIdent);
65 static sal_uInt16 id_to_state(std::u16string_view ident);
70sal_uInt16 SelectionTypePopup::id_to_state(std::u16string_view ident)
72 if (ident == u
"block")
74 else if (ident == u
"adding")
76 else if (ident == u
"extending")
82OUString SelectionTypePopup::state_to_id(sal_uInt16 nState)
87 case 0:
return "standard";
88 case 1:
return "extending";
89 case 2:
return "adding";
90 case 3:
return "block";
94SelectionTypePopup::SelectionTypePopup(
weld::Window* pPopupParent, sal_uInt16 nCurrent)
95 : m_pPopupParent(pPopupParent)
96 , m_xBuilder(
Application::CreateBuilder(m_pPopupParent,
"svx/ui/selectionmenu.ui"))
97 , m_xMenu(m_xBuilder->weld_menu(
"menu"))
99 m_xMenu->set_active(state_to_id(nCurrent),
true);
111 mbFeatureEnabled(false)
127 SvxResId(RID_SVXSTR_SELECTIONMODE_HELPTEXT).
128 replaceFirst(
"%1", aPop.GetItemTextForState(
mnState)));
140 SelectionTypePopup aPop(pPopupParent,
mnState);
143 const css::uno::Reference < css::frame::XModel >
xModel =
m_xFrame->getController()->getModel();
144 css::uno::Reference< css::lang::XServiceInfo > xServices(
xModel, css::uno::UNO_QUERY );
145 if ( xServices.is() )
147 bool bSpecModeCalc = xServices->supportsService(
"com.sun.star.sheet.SpreadsheetDocument");
149 aPop.HideSelectionType(
"block");
152 OUString sIdent = aPop.popup_at_rect(aRect);
153 if (!sIdent.isEmpty())
155 sal_uInt16 nNewState = SelectionTypePopup::id_to_state(sIdent);
css::uno::Reference< css::lang::XComponent > m_xFrame
sal_uInt16 GetValue() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const Point & GetPosPixel() const
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
StatusBar & GetStatusBar() const
sal_uInt16 GetSlotId() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
Status bar control that indicates or changes the selection mode (standard / block / etc....
SvxSelectionModeControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb)
virtual void Click() override
virtual void Paint(const UserDrawEvent &rEvt) override
virtual bool MouseButtonDown(const MouseEvent &rEvt) override
virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
vcl::RenderContext * GetRenderContext() const
const tools::Rectangle & GetRect() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
SFX_IMPL_STATUSBAR_CONTROL(SvxSelectionModeControl, SfxUInt16Item)
Reference< XModel > xModel