diff options
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/valueacc.cxx | 19 | ||||
-rw-r--r-- | svtools/source/control/valueimp.hxx | 3 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 75 |
3 files changed, 95 insertions, 2 deletions
diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx index 219243548702..d661c6f48064 100644 --- a/svtools/source/control/valueacc.cxx +++ b/svtools/source/control/valueacc.cxx @@ -1405,6 +1405,25 @@ sal_Int64 SAL_CALL SvtValueItemAcc::getSomething( const uno::Sequence< sal_Int8 return nRet; } +void SvtValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue ) +{ + if( !nEventId ) + return; + + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); + accessibility::AccessibleEventObject aEvtObject; + + aEvtObject.EventId = nEventId; + aEvtObject.Source = static_cast<uno::XWeak*>(this); + aEvtObject.NewValue = rNewValue; + aEvtObject.OldValue = rOldValue; + + for (auto const& tmpListener : aTmpListeners) + { + tmpListener->notifyEvent( aEvtObject ); + } +} + SvtValueSetAcc::SvtValueSetAcc( SvtValueSet* pParent ) : ValueSetAccComponentBase (m_aMutex), mpParent( pParent ), diff --git a/svtools/source/control/valueimp.hxx b/svtools/source/control/valueimp.hxx index 7be6ca57b85a..ee685d283afd 100644 --- a/svtools/source/control/valueimp.hxx +++ b/svtools/source/control/valueimp.hxx @@ -75,6 +75,7 @@ struct SvtValueSetItem sal_uInt16 mnId; sal_uInt8 meType; bool mbVisible; + Image maImage; Color maColor; OUString maText; css::uno::Reference< css::accessibility::XAccessible > mxAcc; @@ -408,6 +409,8 @@ public: SvtValueItemAcc(SvtValueSetItem* pParent, bool bIsTransientChildrenDisabled); virtual ~SvtValueItemAcc() override; + void FireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue ); + static SvtValueItemAcc* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw(); public: diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 50e674bee2da..e45cf996137c 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -3463,17 +3463,28 @@ void SvtValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, SvtV } else { + Size aImageSize = pItem->maImage.GetSizePixel(); Size aRectSize = aRect.GetSize(); Point aPos(aRect.Left(), aRect.Top()); - aPos.AdjustX(aRectSize.Width() / 2 ); + aPos.AdjustX((aRectSize.Width() - aImageSize.Width()) / 2 ); if (pItem->meType != VALUESETITEM_IMAGE_AND_TEXT) - aPos.AdjustY(aRectSize.Height() / 2 ); + aPos.AdjustY((aRectSize.Height() - aImageSize.Height()) / 2 ); DrawImageFlags nImageStyle = DrawImageFlags::NONE; if (!IsEnabled()) nImageStyle |= DrawImageFlags::Disable; + if (aImageSize.Width() > aRectSize.Width() || + aImageSize.Height() > aRectSize.Height()) + { + maVirDev->SetClipRegion(vcl::Region(aRect)); + maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); + maVirDev->SetClipRegion(); + } + else + maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); + if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT) { maVirDev->SetFont(rRenderContext.GetFont()); @@ -3638,6 +3649,18 @@ Size SvtValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesire return aSize; } +void SvtValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage, + const OUString& rText, size_t nPos, + bool bShowLegend ) +{ + SvtValueSetItem* pItem = new SvtValueSetItem( *this ); + pItem->mnId = nItemId; + pItem->meType = bShowLegend ? VALUESETITEM_IMAGE_AND_TEXT : VALUESETITEM_IMAGE; + pItem->maImage = rImage; + pItem->maText = rText; + ImplInsertItem( pItem, nPos ); +} + void SvtValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor, const OUString& rText ) { @@ -3771,4 +3794,52 @@ OUString SvtValueSet::GetItemText(sal_uInt16 nItemId) const return OUString(); } +void SvtValueSet::SetExtraSpacing( sal_uInt16 nNewSpacing ) +{ + if ( GetStyle() & WB_ITEMBORDER ) + { + mnSpacing = nNewSpacing; + + mbFormat = true; + queue_resize(); + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); + } +} + +void SvtValueSet::SetItemText(sal_uInt16 nItemId, const OUString& rText) +{ + size_t nPos = GetItemPos( nItemId ); + + if ( nPos == VALUESET_ITEM_NOTFOUND ) + return; + + SvtValueSetItem* pItem = mItemList[nPos]; + + // Remember old and new name for accessibility event. + Any aOldName; + Any aNewName; + OUString sString (pItem->maText); + aOldName <<= sString; + sString = rText; + aNewName <<= sString; + + pItem->maText = rText; + + if (!mbFormat && IsReallyVisible() && IsUpdateMode()) + { + sal_uInt16 nTempId = mnSelItemId; + + if (nTempId == nItemId) + Invalidate(); + } + + if (ImplHasAccessibleListeners()) + { + Reference<XAccessible> xAccessible(pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/)); + SvtValueItemAcc* pValueItemAcc = static_cast<SvtValueItemAcc*>(xAccessible.get()); + pValueItemAcc->FireAccessibleEvent(AccessibleEventId::NAME_CHANGED, aOldName, aNewName); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |