37#include <svx/strings.hrc>
48#include <svx/svxids.hrc>
49#include <bitmaps.hlst>
52#include <com/sun/star/beans/PropertyValue.hpp>
73 sal_Int64 nConvVal =
vcl::ConvertValue( nVal * 100, 0, 0, FieldUnit::MM_100TH, eOutUnit );
75 if ( nConvVal < 0 && ( nConvVal / 100 == 0 ) )
77 sMetric += OUString::number(nConvVal / 100);
79 if( FieldUnit::NONE != eOutUnit )
81 sMetric += OUStringChar(cSep);
82 sal_Int64 nFract = nConvVal % 100;
88 sMetric += OUString::number(nFract);
99class FunctionPopup_Impl
101 std::unique_ptr<weld::Builder> m_xBuilder;
102 std::unique_ptr<weld::Menu> m_xMenu;
103 sal_uInt32 m_nSelected;
104 static sal_uInt16 id_to_function(std::u16string_view rIdent);
105 static OUString function_to_id(sal_uInt16 nFunc);
107 explicit FunctionPopup_Impl(sal_uInt32 nCheckEncoded);
110 return m_xMenu->popup_at_rect(pParent, rRect);
112 sal_uInt32 GetSelected(std::u16string_view curident)
const;
117sal_uInt16 FunctionPopup_Impl::id_to_function(std::u16string_view rIdent)
119 if (rIdent == u
"avg")
121 else if (rIdent == u
"counta")
123 else if (rIdent == u
"count")
125 else if (rIdent == u
"max")
127 else if (rIdent == u
"min")
129 else if (rIdent == u
"sum")
131 else if (rIdent == u
"selection")
133 else if (rIdent == u
"none")
138OUString FunctionPopup_Impl::function_to_id(sal_uInt16 nFunc)
162FunctionPopup_Impl::FunctionPopup_Impl(sal_uInt32 nCheckEncoded)
163 : m_xBuilder(
Application::CreateBuilder(nullptr,
"svx/ui/functionmenu.ui"))
164 , m_xMenu(m_xBuilder->weld_menu(
"menu"))
165 , m_nSelected(nCheckEncoded)
167 for ( sal_uInt16 nCheck = 1; nCheck < 32; ++nCheck )
168 if ( nCheckEncoded & (1u << nCheck) )
169 m_xMenu->set_active(function_to_id(nCheck),
true);
172sal_uInt32 FunctionPopup_Impl::GetSelected(std::u16string_view curident)
const
174 sal_uInt32 nSelected = m_nSelected;
175 sal_uInt16 nCurItemId = id_to_function(curident);
181 nSelected ^= ( 1u << nCurItemId );
220#define STR_POSITION ".uno:Position"
221#define STR_TABLECELL ".uno:StateTableCell"
222#define STR_FUNC ".uno:StatusBarFunc"
231 pImpl->bSize =
false;
232 pImpl->bTable =
false;
233 pImpl->bHasMenu =
false;
234 pImpl->nFunctionSet = 0;
235 pImpl->aPosImage =
Image(StockImage::Yes, RID_SVXBMP_POSITION);
236 pImpl->aSizeImage =
Image(StockImage::Yes, RID_SVXBMP_SIZE);
286 if ( nSID == SID_PSZ_FUNCTION )
288 if ( eState == SfxItemState::DEFAULT )
290 pImpl->bHasMenu =
true;
291 if (
auto pUInt32Item =
dynamic_cast< const SfxUInt32Item*
>(pState) )
292 pImpl->nFunctionSet = pUInt32Item->GetValue();
295 pImpl->bHasMenu =
false;
297 else if ( SfxItemState::DEFAULT != eState )
302 if ( nSID == SID_TABLE_CELL )
303 pImpl->bTable =
false;
304 else if ( nSID == SID_ATTR_POSITION )
307 pImpl->bSize =
false;
310 SAL_WARN(
"svx.stbcrtls",
"unknown slot id");
313 else if (
auto pPointItem =
dynamic_cast<const SfxPointItem*
>( pState) )
316 pImpl->aPos = pPointItem->GetValue();
318 pImpl->bTable =
false;
320 else if (
auto pSizeItem =
dynamic_cast<const SvxSizeItem*
>( pState) )
323 pImpl->aSize = pSizeItem->GetSize();
325 pImpl->bTable =
false;
327 else if (
auto pStatusItem =
dynamic_cast<const SvxStatusItem*
>( pState) )
330 pImpl->aStr = pStatusItem->GetValue();
331 pImpl->bTable =
true;
333 pImpl->bSize =
false;
334 if (!
pImpl->aStr.isEmpty())
337 switch (pStatusItem->GetCategory())
340 sTip =
SvxResId(RID_SVXSTR_TABLECELL_HINT);
343 sTip =
SvxResId(RID_SVXSTR_SECTION_HINT);
346 sTip =
SvxResId(RID_SVXSTR_TOC_HINT);
349 sTip =
SvxResId(RID_SVXSTR_NUMBERING_HINT);
352 sTip =
SvxResId(RID_SVXSTR_LIST_STYLE_HINT);
355 sTip =
SvxResId(RID_SVXSTR_FORMULA_HINT);
358 sTip =
SvxResId(RID_SVXSTR_ROW_COLUMN_HINT);
366 else if (
auto pStringItem =
dynamic_cast<const SfxStringItem*
>( pState) )
368 SAL_WARN(
"svx.stbcrtls",
"this should be a SvxStatusItem not a SfxStringItem" );
370 pImpl->aStr = pStringItem->GetValue();
371 pImpl->bTable =
true;
373 pImpl->bSize =
false;
377 SAL_WARN(
"svx.stbcrtls",
"invalid item type" );
379 pImpl->bSize =
false;
380 pImpl->bTable =
false;
396 if ( rCEvt.
GetCommand() == CommandEventId::ContextMenu &&
pImpl->bHasMenu )
398 sal_uInt32 nSelect =
pImpl->nFunctionSet;
403 FunctionPopup_Impl aMenu(nSelect);
404 OUString sIdent = aMenu.Execute(pParent, aRect);
405 if (!sIdent.isEmpty())
407 nSelect = aMenu.GetSelected(sIdent);
417 "StatusBarFunc",
a) };
418 execute(
".uno:StatusBarFunc", aArgs );
455 (rRect.
GetHeight() -
pImpl->aPosImage.GetSizePixel().Height()) / 2;
471 aPnt.
setX( nSizePosX );
476 aPnt.
AdjustX(
pImpl->aSizeImage.GetSizePixel().Width() );
477 Point aDrwPnt = aPnt;
491 else if (
pImpl->bTable )
496 aItemPos.
Y() ),
pImpl->aStr );
514 int nCharsWidth = -1;
520 nCharsWidth = 1 + 6 + 3 + 6;
525 nCharsWidth += 1 + 1 + 4 + 3 + 4;
528 else if (
pImpl->bTable )
const LocaleDataWrapper & GetLocaleDataWrapper() const
static const AllSettings & GetSettings()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
const OUString & getNumDecimalSep() const
vcl::Region GetClipRegion() const
void DrawRect(const tools::Rectangle &rRect)
const Wallpaper & GetBackground() const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
const Color & GetLineColor() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetFillColor() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
static FieldUnit GetModuleFieldUnit(css::uno::Reference< css::frame::XFrame > const &i_frame)
StatusBar & GetStatusBar() const
virtual void Command(const CommandEvent &rCEvt)
sal_uInt16 GetSlotId() const
void SetItemText(sal_uInt16 nItemId, const OUString &rText, int nCharsWidth=-1)
void SetHelpText(sal_uInt16 nItemId, const OUString &rText)
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
void SetHelpId(sal_uInt16 nItemId, const OUString &rHelpId)
void SetItemData(sal_uInt16 nItemId, void *pNewData)
Point GetItemTextPos(sal_uInt16 nItemId) const
virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
virtual ~SvxPosSizeStatusBarControl() override
SvxPosSizeStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb)
std::unique_ptr< SvxPosSizeStatusBarControl_Impl > pImpl
virtual void Command(const CommandEvent &rCEvt) override
virtual void Paint(const UserDrawEvent &rEvt) override
SVX_DLLPRIVATE OUString GetMetricStr_Impl(tools::Long nVal) const
void ImplUpdateItemText()
vcl::RenderContext * GetRenderContext() const
const tools::Rectangle & GetRect() const
const Color & GetColor() const
OUString SvxResId(TranslateId aId)
#define SAL_WARN(area, stream)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
SFX_IMPL_STATUSBAR_CONTROL(SvxPosSizeStatusBarControl, SvxSizeItem)
#define PSZ_FUNC_SELECTION_COUNT