summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-04-24 20:50:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-04-25 22:42:56 +0200
commit34bb3c51783f6cd5d17bff1b259886eeb91f25da (patch)
tree53145ee5562fecdc12a01f476f73d830628286dc /svtools
parent0ffbaecea3316a5c723f6e0eb7250611b5d0f3d7 (diff)
remove newly unused ValueSet
Change-Id: Ia2c587af9846129278caf66ab504d1a1a1ac6256 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92897 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/Library_svt.mk1
-rw-r--r--svtools/inc/uitest/uiobject.hxx36
-rw-r--r--svtools/source/control/valueacc.cxx978
-rw-r--r--svtools/source/control/valueimp.hxx194
-rw-r--r--svtools/source/control/valueset.cxx1807
-rw-r--r--svtools/source/uitest/uiobject.cxx66
6 files changed, 0 insertions, 3082 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index a2c968306bd9..568fb6a63a59 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -164,7 +164,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/table/mousefunction \
svtools/source/table/cellvalueconversion \
svtools/source/table/tablegeometry \
- svtools/source/uitest/uiobject \
svtools/source/uno/addrtempuno \
svtools/source/uno/fpicker \
svtools/source/uno/framestatuslistener \
diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx
deleted file mode 100644
index 2fcc486fa892..000000000000
--- a/svtools/inc/uitest/uiobject.hxx
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <memory>
-#include <vcl/uitest/uiobject.hxx>
-
-class ValueSet;
-
-class ValueSetUIObject final : public WindowUIObject
-{
-private:
- VclPtr<ValueSet> mxValueSet;
-
-public:
- ValueSetUIObject(const VclPtr<ValueSet>& xValueSet);
- virtual ~ValueSetUIObject() override;
-
- virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
-
- virtual StringMap get_state() override;
-
- static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
-
- virtual OUString get_action(VclEventId nEvent) const override;
-
-private:
- virtual OUString get_name() const override;
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx
index 3f16bc926c23..5f5aafaad7c3 100644
--- a/svtools/source/control/valueacc.cxx
+++ b/svtools/source/control/valueacc.cxx
@@ -36,33 +36,6 @@
using namespace ::com::sun::star;
-ValueSetItem::ValueSetItem( ValueSet& rParent )
- : mrParent(rParent)
- , mnId(0)
- , meType(VALUESETITEM_NONE)
- , mbVisible(true)
- , mxAcc()
-{
-}
-
-
-ValueSetItem::~ValueSetItem()
-{
- if( mxAcc.is() )
- {
- mxAcc->ParentDestroyed();
- }
-}
-
-
-uno::Reference< accessibility::XAccessible > ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled )
-{
- if( !mxAcc.is() )
- mxAcc = new ValueItemAcc( this, bIsTransientChildrenDisabled );
-
- return mxAcc.get();
-}
-
SvtValueSetItem::SvtValueSetItem( SvtValueSet& rParent )
: mrParent(rParent)
, mnId(0)
@@ -90,957 +63,6 @@ uno::Reference< accessibility::XAccessible > SvtValueSetItem::GetAccessible( boo
return mxAcc.get();
}
-ValueSetAcc::ValueSetAcc( ValueSet* pParent ) :
- ValueSetAccComponentBase (m_aMutex),
- mpParent( pParent ),
- mbIsFocused(false)
-{
-}
-
-
-ValueSetAcc::~ValueSetAcc()
-{
-}
-
-
-void ValueSetAcc::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)
- {
- try
- {
- tmpListener->notifyEvent( aEvtObject );
- }
- catch(const uno::Exception&)
- {
- }
- }
-}
-
-namespace
-{
- class theValueSetAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theValueSetAccUnoTunnelId > {};
-}
-
-const uno::Sequence< sal_Int8 >& ValueSetAcc::getUnoTunnelId()
-{
- return theValueSetAccUnoTunnelId::get().getSeq();
-}
-
-
-ValueSetAcc* ValueSetAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
- throw()
-{
- try
- {
- return comphelper::getUnoTunnelImplementation<ValueSetAcc>(rxData);
- }
- catch(const css::uno::Exception&)
- {
- return nullptr;
- }
-}
-
-
-void ValueSetAcc::GetFocus()
-{
- mbIsFocused = true;
-
- // Broadcast the state change.
- css::uno::Any aOldState, aNewState;
- aNewState <<= css::accessibility::AccessibleStateType::FOCUSED;
- FireAccessibleEvent(
- css::accessibility::AccessibleEventId::STATE_CHANGED,
- aOldState, aNewState);
-}
-
-
-void ValueSetAcc::LoseFocus()
-{
- mbIsFocused = false;
-
- // Broadcast the state change.
- css::uno::Any aOldState, aNewState;
- aOldState <<= css::accessibility::AccessibleStateType::FOCUSED;
- FireAccessibleEvent(
- css::accessibility::AccessibleEventId::STATE_CHANGED,
- aOldState, aNewState);
-}
-
-
-uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueSetAcc::getAccessibleContext()
-{
- ThrowIfDisposed();
- return this;
-}
-
-
-sal_Int32 SAL_CALL ValueSetAcc::getAccessibleChildCount()
-{
- const SolarMutexGuard aSolarGuard;
- ThrowIfDisposed();
-
- sal_Int32 nCount = mpParent->ImplGetVisibleItemCount();
- if (HasNoneField())
- nCount += 1;
- return nCount;
-}
-
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleChild( sal_Int32 i )
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
-
- if( !pItem )
- throw lang::IndexOutOfBoundsException();
-
- uno::Reference< accessibility::XAccessible > xRet = pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
- return xRet;
-}
-
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleParent()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- vcl::Window* pParent = mpParent->GetParent();
- uno::Reference< accessibility::XAccessible > xRet;
-
- if( pParent )
- xRet = pParent->GetAccessible();
-
- return xRet;
-}
-
-
-sal_Int32 SAL_CALL ValueSetAcc::getAccessibleIndexInParent()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- vcl::Window* pParent = mpParent->GetParent();
- sal_Int32 nRet = 0;
-
- if( pParent )
- {
- bool bFound = false;
-
- for( sal_uInt16 i = 0, nCount = pParent->GetChildCount(); ( i < nCount ) && !bFound; i++ )
- {
- if( pParent->GetChild( i ) == mpParent )
- {
- nRet = i;
- bFound = true;
- }
- }
- }
-
- return nRet;
-}
-
-
-sal_Int16 SAL_CALL ValueSetAcc::getAccessibleRole()
-{
- ThrowIfDisposed();
- return accessibility::AccessibleRole::LIST;
-}
-
-
-OUString SAL_CALL ValueSetAcc::getAccessibleDescription()
-{
- ThrowIfDisposed();
- return "ValueSet";
-}
-
-
-OUString SAL_CALL ValueSetAcc::getAccessibleName()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- OUString aRet;
-
- if (mpParent)
- {
- aRet = mpParent->GetAccessibleName();
-
- if ( aRet.isEmpty() )
- {
- vcl::Window* pLabel = mpParent->GetAccessibleRelationLabeledBy();
- if ( pLabel && pLabel != mpParent )
- aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
-
- if (aRet.isEmpty())
- aRet = mpParent->GetQuickHelpText();
- }
- }
-
- return aRet;
-}
-
-
-uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSetAcc::getAccessibleRelationSet()
-{
- ThrowIfDisposed();
- SolarMutexGuard g;
- uno::Reference< accessibility::XAccessibleRelationSet > xRelSet;
- vcl::Window* pWindow = mpParent;
- if ( pWindow )
- {
- utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper;
- xRelSet = pRelationSet;
-
- vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
- if ( pLabeledBy && pLabeledBy != pWindow )
- {
- uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabeledBy->GetAccessible() };
- pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) );
- }
-
- vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
- if ( pMemberOf && pMemberOf != pWindow )
- {
- uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() };
- pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
- }
- }
- return xRelSet;
-}
-
-
-uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueSetAcc::getAccessibleStateSet()
-{
- ThrowIfDisposed();
- ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
-
- // Set some states.
- pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
- pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
- pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
- pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
- pStateSet->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS);
- pStateSet->AddState (accessibility::AccessibleStateType::FOCUSABLE);
- if (mbIsFocused)
- pStateSet->AddState (accessibility::AccessibleStateType::FOCUSED);
-
- return pStateSet;
-}
-
-
-lang::Locale SAL_CALL ValueSetAcc::getLocale()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
- lang::Locale aRet( "", "", "" );
-
- if( xParent.is() )
- {
- uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
-
- if( xParentContext.is() )
- aRet = xParentContext->getLocale ();
- }
-
- return aRet;
-}
-
-
-void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
-{
- ThrowIfDisposed();
- ::osl::MutexGuard aGuard (m_aMutex);
-
- if( !rxListener.is() )
- return;
-
- bool bFound = false;
-
- for (auto const& eventListener : mxEventListeners)
- {
- if(eventListener == rxListener)
- {
- bFound = true;
- break;
- }
- }
-
- if (!bFound)
- mxEventListeners.push_back( rxListener );
-}
-
-
-void SAL_CALL ValueSetAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
-{
- ThrowIfDisposed();
- ::osl::MutexGuard aGuard (m_aMutex);
-
- if( rxListener.is() )
- {
- ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
- std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
-
- if (aIter != mxEventListeners.end())
- mxEventListeners.erase(aIter);
- }
-}
-
-
-sal_Bool SAL_CALL ValueSetAcc::containsPoint( const awt::Point& aPoint )
-{
- ThrowIfDisposed();
- const awt::Rectangle aRect( getBounds() );
- const Point aSize( aRect.Width, aRect.Height );
- const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
-
- return tools::Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
-}
-
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
- uno::Reference< accessibility::XAccessible > xRet;
-
- if ( nItemId )
- {
- const size_t nItemPos = mpParent->GetItemPos( nItemId );
-
- if( VALUESET_ITEM_NONEITEM != nItemPos )
- {
- ValueSetItem *const pItem = mpParent->mItemList[nItemPos].get();
- xRet = pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
- }
- }
-
- return xRet;
-}
-
-
-awt::Rectangle SAL_CALL ValueSetAcc::getBounds()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- const Point aOutPos( mpParent->GetPosPixel() );
- const Size aOutSize( mpParent->GetOutputSizePixel() );
- awt::Rectangle aRet;
-
- aRet.X = aOutPos.X();
- aRet.Y = aOutPos.Y();
- aRet.Width = aOutSize.Width();
- aRet.Height = aOutSize.Height();
-
- return aRet;
-}
-
-
-awt::Point SAL_CALL ValueSetAcc::getLocation()
-{
- ThrowIfDisposed();
- const awt::Rectangle aRect( getBounds() );
- awt::Point aRet;
-
- aRet.X = aRect.X;
- aRet.Y = aRect.Y;
-
- return aRet;
-}
-
-
-awt::Point SAL_CALL ValueSetAcc::getLocationOnScreen()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- const Point aScreenPos( mpParent->OutputToAbsoluteScreenPixel( Point() ) );
- awt::Point aRet;
-
- aRet.X = aScreenPos.X();
- aRet.Y = aScreenPos.Y();
-
- return aRet;
-}
-
-
-awt::Size SAL_CALL ValueSetAcc::getSize()
-{
- ThrowIfDisposed();
- const awt::Rectangle aRect( getBounds() );
- awt::Size aRet;
-
- aRet.Width = aRect.Width;
- aRet.Height = aRect.Height;
-
- return aRet;
-}
-
-void SAL_CALL ValueSetAcc::grabFocus()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- mpParent->GrabFocus();
-}
-
-sal_Int32 SAL_CALL ValueSetAcc::getForeground( )
-{
- ThrowIfDisposed();
- Color nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
- return static_cast<sal_Int32>(nColor);
-}
-
-sal_Int32 SAL_CALL ValueSetAcc::getBackground( )
-{
- ThrowIfDisposed();
- Color nColor = Application::GetSettings().GetStyleSettings().GetWindowColor();
- return static_cast<sal_Int32>(nColor);
-}
-
-void SAL_CALL ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex )
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
-
- if(pItem == nullptr)
- throw lang::IndexOutOfBoundsException();
-
- mpParent->SelectItem( pItem->mnId );
- mpParent->Select ();
-}
-
-
-sal_Bool SAL_CALL ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
-
- if (pItem == nullptr)
- throw lang::IndexOutOfBoundsException();
-
- bool bRet = mpParent->IsItemSelected( pItem->mnId );
- return bRet;
-}
-
-
-void SAL_CALL ValueSetAcc::clearAccessibleSelection()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- mpParent->SetNoSelection();
-}
-
-
-void SAL_CALL ValueSetAcc::selectAllAccessibleChildren()
-{
- ThrowIfDisposed();
- // unsupported due to single selection only
-}
-
-
-sal_Int32 SAL_CALL ValueSetAcc::getSelectedAccessibleChildCount()
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- sal_Int32 nRet = 0;
-
- for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
- {
- ValueSetItem* pItem = getItem (i);
-
- if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
- ++nRet;
- }
-
- return nRet;
-}
-
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- uno::Reference< accessibility::XAccessible > xRet;
-
- for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
- {
- ValueSetItem* pItem = getItem(i);
-
- if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
- xRet = pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
- }
-
- return xRet;
-}
-
-
-void SAL_CALL ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex )
-{
- ThrowIfDisposed();
- const SolarMutexGuard aSolarGuard;
- // Because of the single selection we can reset the whole selection when
- // the specified child is currently selected.
- if (isAccessibleChildSelected(nChildIndex))
- mpParent->SetNoSelection();
-}
-
-
-sal_Int64 SAL_CALL ValueSetAcc::getSomething( const uno::Sequence< sal_Int8 >& rId )
-{
- sal_Int64 nRet;
-
- if( isUnoTunnelId<ValueSetAcc>(rId) )
- nRet = reinterpret_cast< sal_Int64 >( this );
- else
- nRet = 0;
-
- return nRet;
-}
-
-
-void SAL_CALL ValueSetAcc::disposing()
-{
- ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
-
- {
- // Make a copy of the list and clear the original.
- const SolarMutexGuard aSolarGuard;
- ::osl::MutexGuard aGuard (m_aMutex);
- aListenerListCopy.swap(mxEventListeners);
-
- // Reset the pointer to the parent. It has to be the one who has
- // disposed us because he is dying.
- mpParent = nullptr;
- }
-
- // Inform all listeners that this objects is disposing.
- lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
- for (auto const& listenerCopy : aListenerListCopy)
- {
- try
- {
- listenerCopy->disposing (aEvent);
- }
- catch(const uno::Exception&)
- {
- // Ignore exceptions.
- }
- }
-}
-
-
-sal_uInt16 ValueSetAcc::getItemCount() const
-{
- sal_uInt16 nCount = mpParent->ImplGetVisibleItemCount();
- // When the None-Item is visible then increase the number of items by
- // one.
- if (HasNoneField())
- nCount += 1;
- return nCount;
-}
-
-
-ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const
-{
- ValueSetItem* pItem = nullptr;
-
- if (HasNoneField())
- {
- if (nIndex == 0)
- // When present the first item is the then always visible none field.
- pItem = mpParent->ImplGetItem (VALUESET_ITEM_NONEITEM);
- else
- // Shift down the index to compensate for the none field.
- nIndex -= 1;
- }
- if (pItem == nullptr)
- pItem = mpParent->ImplGetItem (nIndex);
-
- return pItem;
-}
-
-
-void ValueSetAcc::ThrowIfDisposed()
-{
- if (rBHelper.bDisposed || rBHelper.bInDispose)
- {
- SAL_WARN("svx", "Calling disposed object. Throwing exception:");
- throw lang::DisposedException (
- "object has been already disposed",
- static_cast<uno::XWeak*>(this));
- }
- else
- {
- DBG_ASSERT (mpParent!=nullptr, "ValueSetAcc not disposed but mpParent == NULL");
- }
-}
-
-bool ValueSetAcc::HasNoneField() const
-{
- assert(mpParent && "ValueSetAcc::HasNoneField called with mpParent==NULL");
- return ((mpParent->GetStyle() & WB_NONEFIELD) != 0);
-}
-
-ValueItemAcc::ValueItemAcc( ValueSetItem* pParent, bool bIsTransientChildrenDisabled ) :
- mpParent( pParent ),
- mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
-{
-}
-
-ValueItemAcc::~ValueItemAcc()
-{
-}
-
-void ValueItemAcc::ParentDestroyed()
-{
- const ::osl::MutexGuard aGuard( maMutex );
- mpParent = nullptr;
-}
-
-namespace
-{
- class theValueItemAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theValueItemAccUnoTunnelId > {};
-}
-
-const uno::Sequence< sal_Int8 >& ValueItemAcc::getUnoTunnelId()
-{
- return theValueItemAccUnoTunnelId::get().getSeq();
-}
-
-
-ValueItemAcc* ValueItemAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
- throw()
-{
- try
- {
- return comphelper::getUnoTunnelImplementation<ValueItemAcc>(rxData);
- }
- catch(const css::uno::Exception&)
- {
- return nullptr;
- }
-}
-
-
-uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueItemAcc::getAccessibleContext()
-{
- return this;
-}
-
-
-sal_Int32 SAL_CALL ValueItemAcc::getAccessibleChildCount()
-{
- return 0;
-}
-
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleChild( sal_Int32 )
-{
- throw lang::IndexOutOfBoundsException();
-}
-
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleParent()
-{
- const SolarMutexGuard aSolarGuard;
- uno::Reference< accessibility::XAccessible > xRet;
-
- if( mpParent )
- xRet = mpParent->mrParent.GetAccessible();
-
- return xRet;
-}
-
-
-sal_Int32 SAL_CALL ValueItemAcc::getAccessibleIndexInParent()
-{
- const SolarMutexGuard aSolarGuard;
- // The index defaults to -1 to indicate the child does not belong to its
- // parent.
- sal_Int32 nIndexInParent = -1;
-
- if( mpParent )
- {
- bool bDone = false;
-
- sal_uInt16 nCount = mpParent->mrParent.ImplGetVisibleItemCount();
- ValueSetItem* pItem;
- for (sal_uInt16 i=0; i<nCount && !bDone; i++)
- {
- // Guard the retrieval of the i-th child with a try/catch block
- // just in case the number of children changes in the meantime.
- try
- {
- pItem = mpParent->mrParent.ImplGetItem(i);
- }
- catch (const lang::IndexOutOfBoundsException&)
- {
- pItem = nullptr;
- }
-
- // Do not create an accessible object for the test.
- if (pItem != nullptr && pItem->mxAcc.is())
- if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
- {
- nIndexInParent = i;
- bDone = true;
- }
- }
- }
-
- //if this valueset contain a none field(common value is default), then we should increase the real index and set the noitem index value equal 0.
- if ( mpParent && ( (mpParent->mrParent.GetStyle() & WB_NONEFIELD) != 0 ) )
- {
- ValueSetItem* pFirstItem = mpParent->mrParent.ImplGetItem (VALUESET_ITEM_NONEITEM);
- if( pFirstItem && pFirstItem ->GetAccessible(mbIsTransientChildrenDisabled).get() == this )
- nIndexInParent = 0;
- else
- nIndexInParent++;
- }
- return nIndexInParent;
-}
-
-
-sal_Int16 SAL_CALL ValueItemAcc::getAccessibleRole()
-{
- return accessibility::AccessibleRole::LIST_ITEM;
-}
-
-
-OUString SAL_CALL ValueItemAcc::getAccessibleDescription()
-{
- return OUString();
-}
-
-
-OUString SAL_CALL ValueItemAcc::getAccessibleName()
-{
- const SolarMutexGuard aSolarGuard;
-
- if( mpParent )
- {
- if (mpParent->maText.isEmpty())
- return "Item " + OUString::number(static_cast<sal_Int32>(mpParent->mnId));
- else
- return mpParent->maText;
- }
-
- return OUString();
-}
-
-
-uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueItemAcc::getAccessibleRelationSet()
-{
- return uno::Reference< accessibility::XAccessibleRelationSet >();
-}
-
-
-uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueItemAcc::getAccessibleStateSet()
-{
- const SolarMutexGuard aSolarGuard;
- ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
-
- if( mpParent )
- {
- pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
- pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
- pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
- pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
- if ( !mbIsTransientChildrenDisabled )
- pStateSet->AddState (accessibility::AccessibleStateType::TRANSIENT);
-
- // SELECTABLE
- pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
- // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
-
- // SELECTED
- if( mpParent->mrParent.GetSelectedItemId() == mpParent->mnId )
- {
- pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
- // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
- }
- }
-
- return pStateSet;
-}
-
-
-lang::Locale SAL_CALL ValueItemAcc::getLocale()
-{
- const SolarMutexGuard aSolarGuard;
- uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
- lang::Locale aRet( "", "", "" );
-
- if( xParent.is() )
- {
- uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
-
- if( xParentContext.is() )
- aRet = xParentContext->getLocale();
- }
-
- return aRet;
-}
-
-
-void SAL_CALL ValueItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
-{
- const ::osl::MutexGuard aGuard( maMutex );
-
- if( !rxListener.is() )
- return;
-
- bool bFound = false;
-
- for (auto const& eventListener : mxEventListeners)
- {
- if(eventListener == rxListener)
- {
- bFound = true;
- break;
- }
- }
-
- if (!bFound)
- mxEventListeners.push_back( rxListener );
-}
-
-
-void SAL_CALL ValueItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
-{
- const ::osl::MutexGuard aGuard( maMutex );
-
- if( rxListener.is() )
- {
- ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
- std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
-
- if (aIter != mxEventListeners.end())
- mxEventListeners.erase(aIter);
- }
-}
-
-
-sal_Bool SAL_CALL ValueItemAcc::containsPoint( const awt::Point& aPoint )
-{
- const awt::Rectangle aRect( getBounds() );
- const Point aSize( aRect.Width, aRect.Height );
- const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
-
- return tools::Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
-}
-
-uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleAtPoint( const awt::Point& )
-{
- uno::Reference< accessibility::XAccessible > xRet;
- return xRet;
-}
-
-awt::Rectangle SAL_CALL ValueItemAcc::getBounds()
-{
- const SolarMutexGuard aSolarGuard;
- awt::Rectangle aRet;
-
- if( mpParent )
- {
- tools::Rectangle aRect( mpParent->mrParent.GetItemRect(mpParent->mnId) );
- tools::Rectangle aParentRect( Point(), mpParent->mrParent.GetOutputSizePixel() );
-
- aRect.Intersection( aParentRect );
-
- aRet.X = aRect.Left();
- aRet.Y = aRect.Top();
- aRet.Width = aRect.GetWidth();
- aRet.Height = aRect.GetHeight();
- }
-
- return aRet;
-}
-
-awt::Point SAL_CALL ValueItemAcc::getLocation()
-{
- const awt::Rectangle aRect( getBounds() );
- awt::Point aRet;
-
- aRet.X = aRect.X;
- aRet.Y = aRect.Y;
-
- return aRet;
-}
-
-awt::Point SAL_CALL ValueItemAcc::getLocationOnScreen()
-{
- const SolarMutexGuard aSolarGuard;
- awt::Point aRet;
-
- if( mpParent )
- {
- const Point aPos = mpParent->mrParent.GetItemRect(mpParent->mnId).TopLeft();
- const Point aScreenPos( mpParent->mrParent.OutputToAbsoluteScreenPixel( aPos ) );
-
- aRet.X = aScreenPos.X();
- aRet.Y = aScreenPos.Y();
- }
-
- return aRet;
-}
-
-awt::Size SAL_CALL ValueItemAcc::getSize()
-{
- const awt::Rectangle aRect( getBounds() );
- awt::Size aRet;
-
- aRet.Width = aRect.Width;
- aRet.Height = aRect.Height;
-
- return aRet;
-}
-
-void SAL_CALL ValueItemAcc::grabFocus()
-{
- // nothing to do
-}
-
-sal_Int32 SAL_CALL ValueItemAcc::getForeground( )
-{
- Color nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
- return static_cast<sal_Int32>(nColor);
-}
-
-sal_Int32 SAL_CALL ValueItemAcc::getBackground( )
-{
- Color nColor;
- if (mpParent && mpParent->meType == VALUESETITEM_COLOR)
- nColor = mpParent->maColor;
- else
- nColor = Application::GetSettings().GetStyleSettings().GetWindowColor();
- return static_cast<sal_Int32>(nColor);
-}
-
-sal_Int64 SAL_CALL ValueItemAcc::getSomething( const uno::Sequence< sal_Int8 >& rId )
-{
- sal_Int64 nRet;
-
- if( isUnoTunnelId<ValueItemAcc>(rId) )
- nRet = reinterpret_cast< sal_Int64 >( this );
- else
- nRet = 0;
-
- return nRet;
-}
-
SvtValueItemAcc::SvtValueItemAcc( SvtValueSetItem* pParent, bool bIsTransientChildrenDisabled ) :
mpParent( pParent ),
mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
diff --git a/svtools/source/control/valueimp.hxx b/svtools/source/control/valueimp.hxx
index 4584a27faaed..4d1bb79ae25c 100644
--- a/svtools/source/control/valueimp.hxx
+++ b/svtools/source/control/valueimp.hxx
@@ -45,29 +45,9 @@ enum ValueSetItemType
VALUESETITEM_USERDRAW
};
-class ValueItemAcc;
-class ValueSet;
class SvtValueItemAcc;
class SvtValueSet;
-struct ValueSetItem
-{
- ValueSet& mrParent;
- sal_uInt16 mnId;
- sal_uInt8 meType;
- bool mbVisible;
- Image maImage;
- Color maColor;
- OUString maText;
- rtl::Reference< ValueItemAcc > mxAcc;
-
- explicit ValueSetItem( ValueSet& rParent );
- ~ValueSetItem();
-
- css::uno::Reference< css::accessibility::XAccessible >
- GetAccessible( bool bIsTransientChildrenDisabled );
-};
-
struct SvtValueSetItem
{
SvtValueSet& mrParent;
@@ -96,119 +76,6 @@ typedef ::cppu::WeakComponentImplHelper<
css::lang::XUnoTunnel >
ValueSetAccComponentBase;
-class ValueSetAcc :
- public ::cppu::BaseMutex,
- public ValueSetAccComponentBase
-{
-public:
-
- explicit ValueSetAcc(ValueSet* pParent);
- virtual ~ValueSetAcc() override;
-
- void FireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue );
- bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
-
- static ValueSetAcc* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw();
-
-public:
-
- /** Called by the corresponding ValueSet when it gets the focus.
- Stores the new focus state and broadcasts a state change event.
- */
- void GetFocus();
-
- /** Called by the corresponding ValueSet when it loses the focus.
- Stores the new focus state and broadcasts a state change event.
- */
- void LoseFocus();
-
- // XAccessible
- virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
-
- // XAccessibleEventBroadcaster
- virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
- virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
-
- // XAccessibleContext
- virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
- virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
- virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
- virtual OUString SAL_CALL getAccessibleDescription( ) override;
- virtual OUString SAL_CALL getAccessibleName( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
- virtual css::lang::Locale SAL_CALL getLocale( ) override;
-
- // XAccessibleComponent
- virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
- virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
- virtual css::awt::Point SAL_CALL getLocation( ) override;
- virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
- virtual css::awt::Size SAL_CALL getSize( ) override;
- virtual void SAL_CALL grabFocus( ) override;
- virtual sal_Int32 SAL_CALL getForeground( ) override;
- virtual sal_Int32 SAL_CALL getBackground( ) override;
-
- // XAccessibleSelection
- virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override;
- virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override;
- virtual void SAL_CALL clearAccessibleSelection( ) override;
- virtual void SAL_CALL selectAllAccessibleChildren( ) override;
- virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
- virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
-
- // XUnoTunnel
- static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
-
-private:
- ::std::vector< css::uno::Reference<
- css::accessibility::XAccessibleEventListener > > mxEventListeners;
- VclPtr<ValueSet> mpParent;
- /// The current FOCUSED state.
- bool mbIsFocused;
-
- /** Tell all listeners that the object is dying. This callback is
- usually called from the WeakComponentImplHelper class.
- */
- virtual void SAL_CALL disposing() override;
-
- /** Return the number of items. This takes the None-Item into account.
- */
- sal_uInt16 getItemCount() const;
-
- /** Return the item associated with the given index. The None-Item is
- taken into account which, when present, is taken to be the first
- (with index 0) item.
- @param nIndex
- Index of the item to return. The index 0 denotes the None-Item
- when present.
- @return
- Returns NULL when the given index is out of range.
- */
- ValueSetItem* getItem (sal_uInt16 nIndex) const;
-
- /** Check whether or not the object has been disposed (or is in the
- state of being disposed). If that is the case then
- DisposedException is thrown to inform the (indirect) caller of the
- foul deed.
- @throws css::lang::DisposedException
- */
- void ThrowIfDisposed();
-
- /** Check whether the value set has a 'none' field, i.e. a field (button)
- that deselects any items (selects none of them).
- @return
- Returns <true/> if there is a 'none' field and <false/> if it is
- missing.
- */
- bool HasNoneField() const;
-};
-
class SvtValueSetAcc :
public ::cppu::BaseMutex,
public ValueSetAccComponentBase
@@ -322,67 +189,6 @@ private:
bool HasNoneField() const;
};
-
-class ValueItemAcc : public ::cppu::WeakImplHelper< css::accessibility::XAccessible,
- css::accessibility::XAccessibleEventBroadcaster,
- css::accessibility::XAccessibleContext,
- css::accessibility::XAccessibleComponent,
- css::lang::XUnoTunnel >
-{
-private:
-
- ::std::vector< css::uno::Reference<
- css::accessibility::XAccessibleEventListener > > mxEventListeners;
- ::osl::Mutex maMutex;
- ValueSetItem* mpParent;
- bool mbIsTransientChildrenDisabled;
-
-public:
-
- ValueItemAcc( ValueSetItem* pParent, bool bIsTransientChildrenDisabled );
- virtual ~ValueItemAcc() override;
-
- void ParentDestroyed();
-
- static ValueItemAcc* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw();
-
-public:
-
- // XAccessible
- virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
-
- // XAccessibleEventBroadcaster
- virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
- virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
-
- // XAccessibleContext
- virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
- virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
- virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
- virtual OUString SAL_CALL getAccessibleDescription( ) override;
- virtual OUString SAL_CALL getAccessibleName( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
- virtual css::lang::Locale SAL_CALL getLocale( ) override;
-
- // XAccessibleComponent
- virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
- virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
- virtual css::awt::Point SAL_CALL getLocation( ) override;
- virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
- virtual css::awt::Size SAL_CALL getSize( ) override;
- virtual void SAL_CALL grabFocus( ) override;
- virtual sal_Int32 SAL_CALL getForeground( ) override;
- virtual sal_Int32 SAL_CALL getBackground( ) override;
-
- // XUnoTunnel
- static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
-};
-
class SvtValueItemAcc : public ::cppu::WeakImplHelper< css::accessibility::XAccessible,
css::accessibility::XAccessibleEventBroadcaster,
css::accessibility::XAccessibleContext,
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 9f505ffea1da..90f3f362fe1f 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -33,7 +33,6 @@
#include <vcl/settings.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/virdev.hxx>
-#include <uitest/uiobject.hxx>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -64,1812 +63,6 @@ enum
}
-ValueSet::ValueSet( vcl::Window* pParent, WinBits nWinStyle ) :
- Control( pParent, nWinStyle ),
- maColor( COL_TRANSPARENT )
-{
- mnItemWidth = 0;
- mnItemHeight = 0;
- mnTextOffset = 0;
- mnVisLines = 0;
- mnLines = 0;
- mnUserItemWidth = 0;
- mnUserItemHeight = 0;
- mnFirstLine = 0;
- mnSelItemId = 0;
- mnHighItemId = 0;
- mnCols = 0;
- mnCurCol = 0;
- mnUserCols = 0;
- mnUserVisLines = 0;
- mnFrameStyle = DrawFrameStyle::NONE;
- mbFormat = true;
- mbHighlight = false;
- mbNoSelection = true;
- mbDrawSelection = true;
- mbBlackSel = false;
- mbDoubleSel = false;
- mbScroll = false;
- mbEdgeBlending = false;
- mbHasVisibleItems = false;
-
- ImplInitSettings( true, true, true );
-}
-
-ValueSet::~ValueSet()
-{
- disposeOnce();
-}
-
-void ValueSet::dispose()
-{
- Reference<XComponent> xComponent(GetAccessible(false), UNO_QUERY);
- if (xComponent.is())
- xComponent->dispose();
-
- ImplDeleteItems();
- mxScrollBar.disposeAndClear();
- Control::dispose();
-}
-
-void ValueSet::ImplDeleteItems()
-{
- const size_t n = mItemList.size();
-
- for ( size_t i = 0; i < n; ++i )
- {
- ValueSetItem* pItem = mItemList[i].get();
- if ( pItem->mbVisible && ImplHasAccessibleListeners() )
- {
- Any aOldAny;
- Any aNewAny;
-
- aOldAny <<= pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
- ImplFireAccessibleEvent(AccessibleEventId::CHILD, aOldAny, aNewAny);
- }
-
- mItemList[i].reset();
- }
-
- mItemList.clear();
-}
-
-void ValueSet::ApplySettings(vcl::RenderContext& rRenderContext)
-{
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
-
- ApplyControlFont(rRenderContext, rStyleSettings.GetAppFont());
- ApplyControlForeground(rRenderContext, rStyleSettings.GetButtonTextColor());
- SetTextFillColor();
- Color aColor;
- if (GetStyle() & WB_MENUSTYLEVALUESET)
- aColor = rStyleSettings.GetMenuColor();
- else if (IsEnabled() && (GetStyle() & WB_FLATVALUESET))
- aColor = rStyleSettings.GetWindowColor();
- else
- aColor = rStyleSettings.GetFaceColor();
- if (GetBackground().GetColor() == COL_TRANSPARENT)
- ApplyControlBackground(rRenderContext, aColor);
-}
-
-void ValueSet::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
-{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
- if (bFont)
- {
- ApplyControlFont(*this, rStyleSettings.GetAppFont());
- }
-
- if (bForeground || bFont)
- {
- ApplyControlForeground(*this, rStyleSettings.GetButtonTextColor());
- SetTextFillColor();
- }
-
- if (bBackground)
- {
- Color aColor;
- if (GetStyle() & WB_MENUSTYLEVALUESET)
- aColor = rStyleSettings.GetMenuColor();
- else if (IsEnabled() && (GetStyle() & WB_FLATVALUESET))
- aColor = rStyleSettings.GetWindowColor();
- else
- aColor = rStyleSettings.GetFaceColor();
- ApplyControlBackground(*this, aColor);
- }
-}
-
-void ValueSet::ImplInitScrollBar()
-{
- if (!(GetStyle() & WB_VSCROLL))
- return;
-
- if (!mxScrollBar.get())
- {
- mxScrollBar.reset(VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG));
- mxScrollBar->SetScrollHdl(LINK(this, ValueSet, ImplScrollHdl));
- }
- else
- {
- // adapt the width because of the changed settings
- long nScrBarWidth = Application::GetSettings().GetStyleSettings().GetScrollBarSize();
- mxScrollBar->setPosSizePixel(0, 0, nScrBarWidth, 0, PosSizeFlags::Width);
- }
-}
-
-void ValueSet::ImplFormatItem(vcl::RenderContext& rRenderContext, ValueSetItem* pItem, tools::Rectangle aRect)
-{
- WinBits nStyle = GetStyle();
- if (nStyle & WB_ITEMBORDER)
- {
- aRect.AdjustLeft(1 );
- aRect.AdjustTop(1 );
- aRect.AdjustRight( -1 );
- aRect.AdjustBottom( -1 );
-
- if (nStyle & WB_FLATVALUESET)
- {
- sal_Int32 nBorder = (nStyle & WB_DOUBLEBORDER) ? 2 : 1;
-
- aRect.AdjustLeft(nBorder );
- aRect.AdjustTop(nBorder );
- aRect.AdjustRight( -nBorder );
- aRect.AdjustBottom( -nBorder );
- }
- else
- {
- DecorationView aView(&rRenderContext);
- aRect = aView.DrawFrame(aRect, mnFrameStyle);
- }
- }
-
- if (pItem == mpNoneItem.get())
- pItem->maText = GetText();
-
- if (!((aRect.GetHeight() > 0) && (aRect.GetWidth() > 0)))
- return;
-
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
-
- if (pItem == mpNoneItem.get())
- {
- rRenderContext.SetTextColor((nStyle & WB_MENUSTYLEVALUESET)
- ? rStyleSettings.GetMenuTextColor()
- : rStyleSettings.GetWindowTextColor());
- rRenderContext.SetTextFillColor();
- rRenderContext.SetFillColor((nStyle & WB_MENUSTYLEVALUESET)
- ? rStyleSettings.GetMenuColor()
- : rStyleSettings.GetWindowColor());
- rRenderContext.DrawRect(aRect);
- Point aTxtPos(aRect.Left() + 2, aRect.Top());
- long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText);
- if ((aTxtPos.X() + nTxtWidth) > aRect.Right())
- {
- rRenderContext.SetClipRegion(vcl::Region(aRect));
- rRenderContext.DrawText(aTxtPos, pItem->maText);
- rRenderContext.SetClipRegion();
- }
- else
- rRenderContext.DrawText(aTxtPos, pItem->maText);
- }
- else if (pItem->meType == VALUESETITEM_COLOR)
- {
- rRenderContext.SetFillColor(pItem->maColor);
- rRenderContext.DrawRect(aRect);
- }
- else
- {
- if (IsColor())
- rRenderContext.SetFillColor(maColor);
- else if (nStyle & WB_MENUSTYLEVALUESET)
- rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
- else if (IsEnabled())
- rRenderContext.SetFillColor(rStyleSettings.GetWindowColor());
- else
- rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
- rRenderContext.DrawRect(aRect);
-
- if (pItem->meType == VALUESETITEM_USERDRAW)
- {
- }
- else
- {
- Size aImageSize = pItem->maImage.GetSizePixel();
- Size aRectSize = aRect.GetSize();
- Point aPos(aRect.Left(), aRect.Top());
- aPos.AdjustX((aRectSize.Width() - aImageSize.Width()) / 2 );
-
- if (pItem->meType != VALUESETITEM_IMAGE_AND_TEXT)
- 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())
- {
- rRenderContext.SetClipRegion(vcl::Region(aRect));
- rRenderContext.DrawImage(aPos, pItem->maImage, nImageStyle);
- rRenderContext.SetClipRegion();
- }
- else
- rRenderContext.DrawImage(aPos, pItem->maImage, nImageStyle);
-
- if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT)
- {
- rRenderContext.SetFont(rRenderContext.GetFont());
- rRenderContext.SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor());
- rRenderContext.SetTextFillColor();
-
- long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText);
-
- if (nTxtWidth > aRect.GetWidth())
- rRenderContext.SetClipRegion(vcl::Region(aRect));
-
- rRenderContext.DrawText(Point(aRect.Left() + (aRect.GetWidth() - nTxtWidth) / 2,
- aRect.Bottom() - rRenderContext.GetTextHeight()),
- pItem->maText);
-
- if (nTxtWidth > aRect.GetWidth())
- rRenderContext.SetClipRegion();
- }
- }
- }
-
- const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
-
- if (nEdgeBlendingPercent)
- {
- const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor());
- const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor());
- const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100);
- const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight));
-
- if (!aBlendFrame.IsEmpty())
- {
- rRenderContext.DrawBitmapEx(aRect.TopLeft(), aBlendFrame);
- }
- }
-}
-
-Reference<XAccessible> ValueSet::CreateAccessible()
-{
- return new ValueSetAcc( this );
-}
-
-void ValueSet::Format(vcl::RenderContext& rRenderContext)
-{
- Size aWinSize(GetOutputSizePixel());
- size_t nItemCount = mItemList.size();
- WinBits nStyle = GetStyle();
- long nTxtHeight = rRenderContext.GetTextHeight();
- long nOff;
- long nNoneHeight;
- long nNoneSpace;
- VclPtr<ScrollBar> xDeletedScrollBar;
-
- // consider the scrolling
- if (nStyle & WB_VSCROLL)
- ImplInitScrollBar();
- else
- {
- xDeletedScrollBar = mxScrollBar;
- mxScrollBar.clear();
- }
-
- // calculate item offset
- if (nStyle & WB_ITEMBORDER)
- {
- if (nStyle & WB_DOUBLEBORDER)
- nOff = ITEM_OFFSET_DOUBLE;
- else
- nOff = ITEM_OFFSET;
- }
- else
- nOff = 0;
-
- // consider size, if NameField does exist
- if (nStyle & WB_NAMEFIELD)
- {
- mnTextOffset = aWinSize.Height() - nTxtHeight - NAME_OFFSET;
- aWinSize.AdjustHeight( -(nTxtHeight + NAME_OFFSET) );
-
- if (!(nStyle & WB_FLATVALUESET))
- {
- mnTextOffset -= NAME_LINE_HEIGHT + NAME_LINE_OFF_Y;
- aWinSize.AdjustHeight( -(NAME_LINE_HEIGHT + NAME_LINE_OFF_Y) );
- }
- }
- else
- mnTextOffset = 0;
-
- // consider offset and size, if NoneField does exist
- if (nStyle & WB_NONEFIELD)
- {
- nNoneHeight = nTxtHeight + nOff;
- nNoneSpace = 0;
- }
- else
- {
- nNoneHeight = 0;
- nNoneSpace = 0;
- mpNoneItem.reset();
- }
-
- // calculate ScrollBar width
- long nScrBarWidth = 0;
- if (mxScrollBar.get())
- nScrBarWidth = mxScrollBar->GetSizePixel().Width() + SCRBAR_OFFSET;
-
- // calculate number of columns
- if (!mnUserCols)
- {
- if (mnUserItemWidth)
- {
- mnCols = static_cast<sal_uInt16>((aWinSize.Width() - nScrBarWidth) / mnUserItemWidth);
- if (mnCols <= 0)
- mnCols = 1;
- }
- else
- {
- mnCols = 1;
- }
- }
- else
- {
- mnCols = mnUserCols;
- }
-
- // calculate number of rows
- mbScroll = false;
-
- // Floor( (M+N-1)/N )==Ceiling( M/N )
- mnLines = (static_cast<long>(nItemCount) + mnCols - 1) / mnCols;
- if (mnLines <= 0)
- mnLines = 1;
-
- long nCalcHeight = aWinSize.Height() - nNoneHeight;
- if (mnUserVisLines)
- {
- mnVisLines = mnUserVisLines;
- }
- else if (mnUserItemHeight)
- {
- mnVisLines = (nCalcHeight - nNoneSpace) / mnUserItemHeight;
- if (!mnVisLines)
- mnVisLines = 1;
- }
- else
- {
- mnVisLines = mnLines;
- }
-
- if (mnLines > mnVisLines)
- mbScroll = true;
-
- if (mnLines <= mnVisLines)
- {
- mnFirstLine = 0;
- }
- else
- {
- if (mnFirstLine > o3tl::make_unsigned(mnLines - mnVisLines))
- mnFirstLine = static_cast<sal_uInt16>(mnLines - mnVisLines);
- }
-
- // calculate item size
- const long nLineSpace = nNoneSpace;
- if (mnUserItemWidth && !mnUserCols)
- {
- mnItemWidth = mnUserItemWidth;
- if (mnItemWidth > aWinSize.Width() - nScrBarWidth)
- mnItemWidth = aWinSize.Width() - nScrBarWidth;
- }
- else
- mnItemWidth = (aWinSize.Width() - nScrBarWidth) / mnCols;
- if (mnUserItemHeight && !mnUserVisLines)
- {
- mnItemHeight = mnUserItemHeight;
- if (mnItemHeight > nCalcHeight - nNoneSpace)
- mnItemHeight = nCalcHeight - nNoneSpace;
- }
- else
- {
- nCalcHeight -= nLineSpace;
- mnItemHeight = nCalcHeight / mnVisLines;
- }
-
- // nothing is changed in case of too small items
- if ((mnItemWidth <= 0) ||
- (mnItemHeight <= ((nStyle & WB_ITEMBORDER) ? 4 : 2)) ||
- !nItemCount)
- {
- mbHasVisibleItems = false;
-
- if ((nStyle & WB_NONEFIELD) && mpNoneItem)
- {
- mpNoneItem->mbVisible = false;
- mpNoneItem->maText = GetText();
- }
-
- for (size_t i = 0; i < nItemCount; i++)
- {
- mItemList[i]->mbVisible = false;
- }
-
- if (mxScrollBar.get())
- mxScrollBar->Hide();
- }
- else
- {
- mbHasVisibleItems = true;
-
- // determine Frame-Style
- if (nStyle & WB_DOUBLEBORDER)
- mnFrameStyle = DrawFrameStyle::DoubleIn;
- else
- mnFrameStyle = DrawFrameStyle::In;
-
- // determine selected color and width
- // if necessary change the colors, to make the selection
- // better detectable
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- Color aHighColor(rStyleSettings.GetHighlightColor());
- if (((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
- (aHighColor.GetBlue() > 0x80)) ||
- ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
- (aHighColor.GetBlue() == 0x80)))
- {
- mbBlackSel = true;
- }
- else
- {
- mbBlackSel = false;
- }
- // draw the selection with double width if the items are bigger
- if ((nStyle & WB_DOUBLEBORDER) &&
- ((mnItemWidth >= 25) && (mnItemHeight >= 20)))
- {
- mbDoubleSel = true;
- }
- else
- {
- mbDoubleSel = false;
- }
-
- // calculate offsets
- long nAllItemWidth = mnItemWidth * mnCols;
- long nAllItemHeight = (mnItemHeight * mnVisLines) + nNoneHeight + nLineSpace;
- long nStartX = (aWinSize.Width() - nScrBarWidth - nAllItemWidth) / 2;
- long nStartY = (aWinSize.Height() - nAllItemHeight) / 2;
-
- // calculate and draw items
- rRenderContext.SetLineColor();
- long x = nStartX;
- long y = nStartY;
-
- // create NoSelection field and show it
- if (nStyle & WB_NONEFIELD)
- {
- if (mpNoneItem == nullptr)
- mpNoneItem.reset(new ValueSetItem(*this));
-
- mpNoneItem->mnId = 0;
- mpNoneItem->meType = VALUESETITEM_NONE;
- mpNoneItem->mbVisible = true;
- maNoneItemRect.SetLeft( x );
- maNoneItemRect.SetTop( y );
- maNoneItemRect.SetRight( maNoneItemRect.Left() + aWinSize.Width() - x - 1 );
- maNoneItemRect.SetBottom( y + nNoneHeight - 1 );
-
- ImplFormatItem(rRenderContext, mpNoneItem.get(), maNoneItemRect);
-
- y += nNoneHeight + nNoneSpace;
- }
-
- // draw items
- sal_uLong nFirstItem = static_cast<sal_uLong>(mnFirstLine) * mnCols;
- sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
-
- maItemListRect.SetLeft( x );
- maItemListRect.SetTop( y );
- maItemListRect.SetRight( x + mnCols * mnItemWidth - 1 );
- maItemListRect.SetBottom( y + mnVisLines * mnItemHeight - 1 );
-
- for (size_t i = 0; i < nItemCount; i++)
- {
- ValueSetItem* pItem = mItemList[i].get();
-
- if (i >= nFirstItem && i < nLastItem)
- {
- if (!pItem->mbVisible && ImplHasAccessibleListeners())
- {
- Any aOldAny;
- Any aNewAny;
-
- aNewAny <<= pItem->GetAccessible(false/*bIsTransientChildrenDisabled*/);
- ImplFireAccessibleEvent(AccessibleEventId::CHILD, aOldAny, aNewAny);
- }
-
- pItem->mbVisible = true;
- ImplFormatItem(rRenderContext, pItem, tools::Rectangle(Point(x, y), Size(mnItemWidth, mnItemHeight)));
-
- if (!((i + 1) % mnCols))
- {
- x = nStartX;
- y += mnItemHeight;
- }
- else
- x += mnItemWidth;
- }
- else
- {
- if (pItem->mbVisible && ImplHasAccessibleListeners())
- {
- Any aOldAny;
- Any aNewAny;
-
- aOldAny <<= pItem->GetAccessible(false/*bIsTransientChildrenDisabled*/);
- ImplFireAccessibleEvent(AccessibleEventId::CHILD, aOldAny, aNewAny);
- }
-
- pItem->mbVisible = false;
- }
- }
-
- // arrange ScrollBar, set values and show it
- if (mxScrollBar.get())
- {
- Point aPos(aWinSize.Width() - nScrBarWidth + SCRBAR_OFFSET, 0);
- Size aSize(nScrBarWidth - SCRBAR_OFFSET, aWinSize.Height());
- // If a none field is visible, then we center the scrollbar
- if (nStyle & WB_NONEFIELD)
- {
- aPos.setY( nStartY + nNoneHeight + 1 );
- aSize.setHeight( (mnItemHeight * mnVisLines) - 2 );
- }
- mxScrollBar->SetPosSizePixel(aPos, aSize);
- mxScrollBar->SetRangeMax(mnLines);
- mxScrollBar->SetVisibleSize(mnVisLines);
- mxScrollBar->SetThumbPos(static_cast<long>(mnFirstLine));
- long nPageSize = mnVisLines;
- if (nPageSize < 1)
- nPageSize = 1;
- mxScrollBar->SetPageSize(nPageSize);
- mxScrollBar->Show();
- }
- }
-
- // waiting for the next since the formatting is finished
- mbFormat = false;
-
- xDeletedScrollBar.disposeAndClear();
-}
-
-void ValueSet::ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rText)
-{
- if (!(GetStyle() & WB_NAMEFIELD))
- return;
-
- Size aWinSize(GetOutputSizePixel());
- long nTxtWidth = rRenderContext.GetTextWidth(rText);
- long nTxtOffset = mnTextOffset;
-
- // delete rectangle and show text
- if (GetStyle() & WB_FLATVALUESET)
- {
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- rRenderContext.SetLineColor();
- rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
- rRenderContext.DrawRect(tools::Rectangle(Point(0, nTxtOffset), Point(aWinSize.Width(), aWinSize.Height())));
- rRenderContext.SetTextColor(rStyleSettings.GetButtonTextColor());
- }
- else
- {
- nTxtOffset += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
- rRenderContext.Erase(tools::Rectangle(Point(0, nTxtOffset), Point(aWinSize.Width(), aWinSize.Height())));
- }
- rRenderContext.DrawText(Point((aWinSize.Width() - nTxtWidth) / 2, nTxtOffset + (NAME_OFFSET / 2)), rText);
-}
-
-void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext)
-{
- if (!IsReallyVisible())
- return;
-
- const bool bFocus = HasFocus();
- const bool bDrawSel = !((mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight));
-
- if (!bFocus && !bDrawSel)
- {
- ImplDrawItemText(rRenderContext, OUString());
- return;
- }
-
- ImplDrawSelect(rRenderContext, mnSelItemId, bFocus, bDrawSel);
- if (mbHighlight)
- {
- ImplDrawSelect(rRenderContext, mnHighItemId, bFocus, bDrawSel);
- }
-}
-
-void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel )
-{
- ValueSetItem* pItem;
- tools::Rectangle aRect;
- if (nItemId)
- {
- const size_t nPos = GetItemPos( nItemId );
- pItem = mItemList[ nPos ].get();
- aRect = ImplGetItemRect( nPos );
- }
- else if (mpNoneItem)
- {
- pItem = mpNoneItem.get();
- aRect = maNoneItemRect;
- }
- else if (bFocus && (pItem = ImplGetFirstItem()))
- {
- aRect = ImplGetItemRect(0);
- }
- else
- {
- return;
- }
-
- if (!pItem->mbVisible)
- return;
-
- // draw selection
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- rRenderContext.SetFillColor();
-
- Color aDoubleColor(rStyleSettings.GetHighlightColor());
- Color aSingleColor(rStyleSettings.GetHighlightTextColor());
- if (!mbDoubleSel)
- {
- /*
- * #99777# contrast enhancement for thin mode
- */
- const Wallpaper& rWall = GetDisplayBackground();
- if (!rWall.IsBitmap() && ! rWall.IsGradient())
- {
- const Color& rBack = rWall.GetColor();
- if (rBack.IsDark() && ! aDoubleColor.IsBright())
- {
- aDoubleColor = COL_WHITE;
- aSingleColor = COL_BLACK;
- }
- else if (rBack.IsBright() && ! aDoubleColor.IsDark())
- {
- aDoubleColor = COL_BLACK;
- aSingleColor = COL_WHITE;
- }
- }
- }
-
- // specify selection output
- WinBits nStyle = GetStyle();
- if (nStyle & WB_MENUSTYLEVALUESET)
- {
- if (bFocus)
- ShowFocus(aRect);
-
- if (bDrawSel)
- {
- rRenderContext.SetLineColor(mbBlackSel ? COL_BLACK : aDoubleColor);
- rRenderContext.DrawRect(aRect);
- }
- }
- else
- {
- if (bDrawSel)
- {
- rRenderContext.SetLineColor(mbBlackSel ? COL_BLACK : aDoubleColor);
- rRenderContext.DrawRect(aRect);
- }
- if (mbDoubleSel)
- {
- aRect.AdjustLeft( 1 );
- aRect.AdjustTop( 1 );
- aRect.AdjustRight( -1 );
- aRect.AdjustBottom( -1 );
- if (bDrawSel)
- rRenderContext.DrawRect(aRect);
- }
- aRect.AdjustLeft( 1 );
- aRect.AdjustTop( 1 );
- aRect.AdjustRight( -1 );
- aRect.AdjustBottom( -1 );
- tools::Rectangle aRect2 = aRect;
- aRect.AdjustLeft( 1 );
- aRect.AdjustTop( 1 );
- aRect.AdjustRight( -1 );
- aRect.AdjustBottom( -1 );
- if (bDrawSel)
- rRenderContext.DrawRect(aRect);
- if (mbDoubleSel)
- {
- aRect.AdjustLeft( 1 );
- aRect.AdjustTop( 1 );
- aRect.AdjustRight( -1 );
- aRect.AdjustBottom( -1 );
- if (bDrawSel)
- rRenderContext.DrawRect(aRect);
- }
-
- if (bDrawSel)
- {
- rRenderContext.SetLineColor(mbBlackSel ? COL_WHITE : aSingleColor);
- }
- else
- {
- rRenderContext.SetLineColor(COL_LIGHTGRAY);
- }
- rRenderContext.DrawRect(aRect2);
-
- if (bFocus)
- ShowFocus(aRect2);
- }
-
- ImplDrawItemText(rRenderContext, pItem->maText);
-}
-
-void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection )
-{
- if ( mnHighItemId == nItemId )
- return;
-
- mnHighItemId = nItemId;
-
- // don't draw the selection if nothing is selected
- if ( !bIsSelection && mbNoSelection )
- mbDrawSelection = false;
-
- // remove the old selection and draw the new one
- Invalidate();
- mbDrawSelection = true;
-}
-
-void ValueSet::ImplDraw(vcl::RenderContext& rRenderContext)
-{
- Format(rRenderContext);
- HideFocus();
-
- // draw parting line to the Namefield
- if (GetStyle() & WB_NAMEFIELD)
- {
- if (!(GetStyle() & WB_FLATVALUESET))
- {
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- Size aWinSize(GetOutputSizePixel());
- Point aPos1(NAME_LINE_OFF_X, mnTextOffset + NAME_LINE_OFF_Y);
- Point aPos2(aWinSize.Width() - (NAME_LINE_OFF_X * 2), mnTextOffset + NAME_LINE_OFF_Y);
- if (!(rStyleSettings.GetOptions() & StyleSettingsOptions::Mono))
- {
- rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
- rRenderContext.DrawLine(aPos1, aPos2);
- aPos1.AdjustY( 1 );
- aPos2.AdjustY( 1 );
- rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
- }
- else
- rRenderContext.SetLineColor(rStyleSettings.GetWindowTextColor());
- rRenderContext.DrawLine(aPos1, aPos2);
- }
- }
-
- ImplDrawSelect(rRenderContext);
-}
-
-size_t ValueSet::ImplGetItem( const Point& rPos ) const
-{
- if (!mbHasVisibleItems)
- {
- return VALUESET_ITEM_NOTFOUND;
- }
-
- if (mpNoneItem.get() && maNoneItemRect.IsInside(rPos))
- {
- return VALUESET_ITEM_NONEITEM;
- }
-
- if (maItemListRect.IsInside(rPos))
- {
- const int xc = rPos.X() - maItemListRect.Left();
- const int yc = rPos.Y() - maItemListRect.Top();
- // The point is inside the area of item list,
- // let's find the containing item.
- const int col = xc / mnItemWidth;
- const int x = xc % mnItemWidth;
- const int row = yc / mnItemHeight;
- const int y = yc % mnItemHeight;
-
- if (x < mnItemWidth && y < mnItemHeight)
- {
- // the point is inside item rect and not inside spacing
- const size_t item = (mnFirstLine + row) * static_cast<size_t>(mnCols) + col;
- if (item < mItemList.size())
- {
- return item;
- }
- }
- }
-
- return VALUESET_ITEM_NOTFOUND;
-}
-
-ValueSetItem* ValueSet::ImplGetItem( size_t nPos )
-{
- if (nPos == VALUESET_ITEM_NONEITEM)
- return mpNoneItem.get();
- else
- return (nPos < mItemList.size()) ? mItemList[nPos].get() : nullptr;
-}
-
-ValueSetItem* ValueSet::ImplGetFirstItem()
-{
- return !mItemList.empty() ? mItemList[0].get() : nullptr;
-}
-
-sal_uInt16 ValueSet::ImplGetVisibleItemCount() const
-{
- sal_uInt16 nRet = 0;
- const size_t nItemCount = mItemList.size();
-
- for ( size_t n = 0; n < nItemCount; ++n )
- {
- if ( mItemList[n]->mbVisible )
- ++nRet;
- }
-
- return nRet;
-}
-
-void ValueSet::ImplFireAccessibleEvent( short nEventId, const Any& rOldValue, const Any& rNewValue )
-{
- ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( false ) );
-
- if( pAcc )
- pAcc->FireAccessibleEvent( nEventId, rOldValue, rNewValue );
-}
-
-bool ValueSet::ImplHasAccessibleListeners()
-{
- ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( false ) );
- return( pAcc && pAcc->HasAccessibleListeners() );
-}
-
-IMPL_LINK( ValueSet,ImplScrollHdl, ScrollBar*, pScrollBar, void )
-{
- sal_uInt16 nNewFirstLine = static_cast<sal_uInt16>(pScrollBar->GetThumbPos());
- if ( nNewFirstLine != mnFirstLine )
- {
- mnFirstLine = nNewFirstLine;
- mbFormat = true;
- Invalidate();
- }
-}
-
-void ValueSet::ImplTracking( const Point& rPos )
-{
- ValueSetItem* pItem = ImplGetItem( ImplGetItem( rPos ) );
- if ( pItem )
- {
- if( GetStyle() & WB_MENUSTYLEVALUESET || GetStyle() & WB_FLATVALUESET )
- mbHighlight = true;
-
- ImplHighlightItem( pItem->mnId );
- }
- else
- {
- if( GetStyle() & WB_MENUSTYLEVALUESET || GetStyle() & WB_FLATVALUESET )
- mbHighlight = true;
-
- ImplHighlightItem( mnSelItemId, false );
- }
-}
-
-void ValueSet::ImplEndTracking( const Point& rPos, bool bCancel )
-{
- ValueSetItem* pItem;
-
- // restore the old status in case of termination
- if ( bCancel )
- pItem = nullptr;
- else
- pItem = ImplGetItem( ImplGetItem( rPos ) );
-
- if ( pItem )
- {
- SelectItem( pItem->mnId );
- if ( !(GetStyle() & WB_NOPOINTERFOCUS) )
- GrabFocus();
- mbHighlight = false;
- Select();
- }
- else
- {
- ImplHighlightItem( mnSelItemId, false );
- mbHighlight = false;
- }
-}
-
-void ValueSet::MouseButtonDown( const MouseEvent& rMouseEvent )
-{
- if ( rMouseEvent.IsLeft() )
- {
- ValueSetItem* pItem = ImplGetItem( ImplGetItem( rMouseEvent.GetPosPixel() ) );
- if ( pItem && !rMouseEvent.IsMod2() )
- {
- if ( rMouseEvent.GetClicks() == 1 )
- {
- mbHighlight = true;
- mnHighItemId = mnSelItemId;
- ImplHighlightItem( pItem->mnId );
- StartTracking( StartTrackingFlags::ScrollRepeat );
- }
-
- return;
- }
- }
-
- Control::MouseButtonDown( rMouseEvent );
-}
-
-void ValueSet::MouseMove( const MouseEvent& rMouseEvent )
-{
- // because of SelectionMode
- if ( (GetStyle() & WB_MENUSTYLEVALUESET) || (GetStyle() & WB_FLATVALUESET))
- ImplTracking( rMouseEvent.GetPosPixel() );
- Control::MouseMove( rMouseEvent );
-}
-
-void ValueSet::Tracking( const TrackingEvent& rTrackingEvent )
-{
- Point aMousePos = rTrackingEvent.GetMouseEvent().GetPosPixel();
-
- if ( rTrackingEvent.IsTrackingEnded() )
- ImplEndTracking( aMousePos, rTrackingEvent.IsTrackingCanceled() );
- else
- ImplTracking( aMousePos );
-}
-
-void ValueSet::KeyInput( const KeyEvent& rKeyEvent )
-{
- size_t nLastItem = mItemList.size();
-
- if ( !nLastItem || !ImplGetFirstItem() )
- {
- Control::KeyInput( rKeyEvent );
- return;
- }
-
- if (mbFormat)
- Invalidate();
-
- --nLastItem;
-
- const size_t nCurPos
- = mnSelItemId ? GetItemPos(mnSelItemId) : (mpNoneItem ? VALUESET_ITEM_NONEITEM : 0);
- size_t nItemPos = VALUESET_ITEM_NOTFOUND;
- size_t nVStep = mnCols;
-
- switch (rKeyEvent.GetKeyCode().GetCode())
- {
- case KEY_HOME:
- nItemPos = mpNoneItem ? VALUESET_ITEM_NONEITEM : 0;
- break;
-
- case KEY_END:
- nItemPos = nLastItem;
- break;
-
- case KEY_LEFT:
- if (nCurPos != VALUESET_ITEM_NONEITEM)
- {
- if (nCurPos)
- {
- nItemPos = nCurPos-1;
- }
- else if (mpNoneItem)
- {
- nItemPos = VALUESET_ITEM_NONEITEM;
- }
- }
- break;
-
- case KEY_RIGHT:
- if (nCurPos < nLastItem)
- {
- if (nCurPos == VALUESET_ITEM_NONEITEM)
- {
- nItemPos = 0;
- }
- else
- {
- nItemPos = nCurPos+1;
- }
- }
- break;
-
- case KEY_PAGEUP:
- if (rKeyEvent.GetKeyCode().IsShift() || rKeyEvent.GetKeyCode().IsMod1() || rKeyEvent.GetKeyCode().IsMod2())
- {
- Control::KeyInput( rKeyEvent );
- return;
- }
- nVStep *= mnVisLines;
- [[fallthrough]];
- case KEY_UP:
- if (nCurPos != VALUESET_ITEM_NONEITEM)
- {
- if (nCurPos == nLastItem)
- {
- const size_t nCol = mnCols ? nLastItem % mnCols : 0;
- if (nCol < mnCurCol)
- {
- // Move to previous row/page, keeping the old column
- nVStep -= mnCurCol - nCol;
- }
- }
- if (nCurPos >= nVStep)
- {
- // Go up of a whole page
- nItemPos = nCurPos-nVStep;
- }
- else if (mpNoneItem)
- {
- nItemPos = VALUESET_ITEM_NONEITEM;
- }
- else if (nCurPos > mnCols)
- {
- // Go to same column in first row
- nItemPos = nCurPos % mnCols;
- }
- }
- break;
-
- case KEY_PAGEDOWN:
- if (rKeyEvent.GetKeyCode().IsShift() || rKeyEvent.GetKeyCode().IsMod1() || rKeyEvent.GetKeyCode().IsMod2())
- {
- Control::KeyInput( rKeyEvent );
- return;
- }
- nVStep *= mnVisLines;
- [[fallthrough]];
- case KEY_DOWN:
- if (nCurPos != nLastItem)
- {
- if (nCurPos == VALUESET_ITEM_NONEITEM)
- {
- nItemPos = nVStep-mnCols+mnCurCol;
- }
- else
- {
- nItemPos = nCurPos+nVStep;
- }
- if (nItemPos > nLastItem)
- {
- nItemPos = nLastItem;
- }
- }
- break;
-
- case KEY_RETURN:
- if (GetStyle() & WB_NO_DIRECTSELECT)
- {
- Select();
- break;
- }
- [[fallthrough]];
- default:
- Control::KeyInput( rKeyEvent );
- return;
- }
-
- // This point is reached only if key travelling was used,
- // in which case selection mode should be switched off
- EndSelection();
-
- if ( nItemPos == VALUESET_ITEM_NOTFOUND )
- return;
-
- if ( nItemPos!=VALUESET_ITEM_NONEITEM && nItemPos<nLastItem )
- {
- // update current column only in case of a new position
- // which is also not a "specially" handled one.
- mnCurCol = mnCols ? nItemPos % mnCols : 0;
- }
- const sal_uInt16 nItemId = (nItemPos != VALUESET_ITEM_NONEITEM) ? GetItemId( nItemPos ) : 0;
- if ( nItemId != mnSelItemId )
- {
- SelectItem( nItemId );
- if (!(GetStyle() & WB_NO_DIRECTSELECT))
- {
- // select only if WB_NO_DIRECTSELECT is not set
- Select();
- }
- }
-}
-
-void ValueSet::Command( const CommandEvent& rCommandEvent )
-{
- if ( rCommandEvent.GetCommand() == CommandEventId::Wheel ||
- rCommandEvent.GetCommand() == CommandEventId::StartAutoScroll ||
- rCommandEvent.GetCommand() == CommandEventId::AutoScroll )
- {
- if ( HandleScrollCommand( rCommandEvent, nullptr, mxScrollBar.get() ) )
- return;
- }
-
- Control::Command( rCommandEvent );
-}
-
-void ValueSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
-{
- if (GetStyle() & WB_FLATVALUESET)
- {
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- rRenderContext.SetLineColor();
- rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
- }
-
- ImplDraw(rRenderContext);
-}
-
-void ValueSet::GetFocus()
-{
- SAL_INFO("svtools", "value set getting focus");
- Invalidate();
- Control::GetFocus();
-
- // Tell the accessible object that we got the focus.
- ValueSetAcc* pAcc = ValueSetAcc::getImplementation(GetAccessible(false));
- if (pAcc)
- pAcc->GetFocus();
-}
-
-void ValueSet::LoseFocus()
-{
- SAL_INFO("svtools", "value set losing focus");
- if (!mbNoSelection || !mnSelItemId)
- HideFocus();
- Control::LoseFocus();
-
- // Tell the accessible object that we lost the focus.
- ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( false ) );
- if( pAcc )
- pAcc->LoseFocus();
-}
-
-void ValueSet::Resize()
-{
- mbFormat = true;
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
- Control::Resize();
-}
-
-void ValueSet::RequestHelp( const HelpEvent& rHelpEvent )
-{
- if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))
- {
- Point aPos = ScreenToOutputPixel( rHelpEvent.GetMousePosPixel() );
- size_t nItemPos = ImplGetItem( aPos );
- if ( nItemPos != VALUESET_ITEM_NOTFOUND )
- {
- tools::Rectangle aItemRect = ImplGetItemRect( nItemPos );
- Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
- aItemRect.SetLeft( aPt.X() );
- aItemRect.SetTop( aPt.Y() );
- aPt = OutputToScreenPixel( aItemRect.BottomRight() );
- aItemRect.SetRight( aPt.X() );
- aItemRect.SetBottom( aPt.Y() );
- Help::ShowQuickHelp( this, aItemRect, GetItemText( ImplGetItem( nItemPos )->mnId ) );
- return;
- }
- }
-
- Control::RequestHelp( rHelpEvent );
-}
-
-void ValueSet::StateChanged(StateChangedType nType)
-{
- Control::StateChanged(nType);
-
- if (nType == StateChangedType::InitShow)
- {
- if (mbFormat)
- Invalidate();
- }
- else if (nType == StateChangedType::UpdateMode)
- {
- if (IsReallyVisible() && IsUpdateMode())
- Invalidate();
- }
- else if (nType == StateChangedType::Text)
- {
- if (mpNoneItem.get() && !mbFormat && IsReallyVisible() && IsUpdateMode())
- {
- Invalidate(maNoneItemRect);
- }
- }
- else if ((nType == StateChangedType::Zoom) ||
- (nType == StateChangedType::ControlFont))
- {
- ImplInitSettings(true, false, false);
- Invalidate();
- }
- else if (nType == StateChangedType::ControlForeground)
- {
- ImplInitSettings(false, true, false);
- Invalidate();
- }
- else if (nType == StateChangedType::ControlBackground)
- {
- ImplInitSettings(false, false, true);
- Invalidate();
- }
- else if ((nType == StateChangedType::Style) || (nType == StateChangedType::Enable))
- {
- mbFormat = true;
- ImplInitSettings(false, false, true);
- Invalidate();
- }
-}
-
-void ValueSet::DataChanged( const DataChangedEvent& rDataChangedEvent )
-{
- Control::DataChanged( rDataChangedEvent );
-
- if ( rDataChangedEvent.GetType() == DataChangedEventType::FONTS ||
- rDataChangedEvent.GetType() == DataChangedEventType::DISPLAY ||
- rDataChangedEvent.GetType() == DataChangedEventType::FONTSUBSTITUTION ||
- (rDataChangedEvent.GetType() == DataChangedEventType::SETTINGS &&
- rDataChangedEvent.GetFlags() & AllSettingsFlags::STYLE) )
- {
- mbFormat = true;
- ImplInitSettings( true, true, true );
- Invalidate();
- }
-}
-
-boost::property_tree::ptree ValueSet::DumpAsPropertyTree()
-{
- boost::property_tree::ptree aTree(Control::DumpAsPropertyTree());
- boost::property_tree::ptree aEntries;
-
- ErrCode nErrCode;
- OUStringBuffer aBuffer;
- SvMemoryStream aStream;
- const size_t nSize = mItemList.size();
-
- for ( size_t nIt = 0; nIt < nSize; ++nIt )
- {
- boost::property_tree::ptree aEntry;
- ValueSetItem* pItem = mItemList[nIt].get();
- aEntry.put("id", pItem->mnId);
- if ( !pItem->maImage.GetStock().isEmpty() )
- {
- aEntry.put("image", pItem->maImage.GetStock());
- }
- else
- {
- Graphic aGraphic(pItem->maImage);
-
- nErrCode = GraphicConverter::Export(aStream, aGraphic, ConvertDataFormat::PNG);
- if ( nErrCode )
- {
- SAL_WARN("svtools", "GraphicConverter::Export() invalid Graphic? error: " << nErrCode );
- }
- else
- {
- css::uno::Sequence<sal_Int8> aSeq(static_cast<sal_Int8 const *>(aStream.GetData()), aStream.TellEnd());
- aStream.Seek(0);
-
- aBuffer.append("data:image/png;base64,");
- ::comphelper::Base64::encode(aBuffer, aSeq);
- aEntry.put("image64", aBuffer.makeStringAndClear().toUtf8());
- }
- }
-
- if (mnSelItemId == pItem->mnId)
- {
- aEntry.put("selected", true);
- }
-
- aEntries.push_back(std::make_pair("", aEntry));
- }
-
- aTree.put("type", "valueset");
- aTree.add_child("entries", aEntries);
- return aTree;
-}
-
-FactoryFunction ValueSet::GetUITestFactory() const
-{
- return ValueSetUIObject::create;
-}
-
-void ValueSet::Select()
-{
- maSelectHdl.Call( this );
-}
-
-void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage,
- const OUString& rText, size_t nPos )
-{
- std::unique_ptr<ValueSetItem> pItem(new ValueSetItem( *this ));
- pItem->mnId = nItemId;
- pItem->meType = VALUESETITEM_IMAGE;
- pItem->maImage = rImage;
- pItem->maText = rText;
- ImplInsertItem( std::move(pItem), nPos );
-}
-
-void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor,
- const OUString& rText )
-{
- std::unique_ptr<ValueSetItem> pItem(new ValueSetItem( *this ));
- pItem->mnId = nItemId;
- pItem->meType = VALUESETITEM_COLOR;
- pItem->maColor = rColor;
- pItem->maText = rText;
- ImplInsertItem( std::move(pItem), VALUESET_APPEND );
-}
-
-void ValueSet::InsertItem( sal_uInt16 nItemId, size_t nPos )
-{
- std::unique_ptr<ValueSetItem> pItem(new ValueSetItem( *this ));
- pItem->mnId = nItemId;
- pItem->meType = VALUESETITEM_USERDRAW;
- ImplInsertItem( std::move(pItem), nPos );
-}
-
-void ValueSet::ImplInsertItem( std::unique_ptr<ValueSetItem> pItem, const size_t nPos )
-{
- DBG_ASSERT( pItem->mnId, "ValueSet::InsertItem(): ItemId == 0" );
- DBG_ASSERT( GetItemPos( pItem->mnId ) == VALUESET_ITEM_NOTFOUND,
- "ValueSet::InsertItem(): ItemId already exists" );
-
- if ( nPos < mItemList.size() ) {
- mItemList.insert( mItemList.begin() + nPos, std::move(pItem) );
- } else {
- mItemList.push_back( std::move(pItem) );
- }
-
- queue_resize();
-
- mbFormat = true;
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
-}
-
-tools::Rectangle ValueSet::ImplGetItemRect( size_t nPos ) const
-{
- const size_t nVisibleBegin = static_cast<size_t>(mnFirstLine)*mnCols;
- const size_t nVisibleEnd = nVisibleBegin + static_cast<size_t>(mnVisLines)*mnCols;
-
- // Check if the item is inside the range of the displayed ones,
- // taking into account that last row could be incomplete
- if ( nPos<nVisibleBegin || nPos>=nVisibleEnd || nPos>=mItemList.size() )
- return tools::Rectangle();
-
- nPos -= nVisibleBegin;
-
- const size_t row = mnCols ? nPos/mnCols : 0;
- const size_t col = mnCols ? nPos%mnCols : 0;
- const long x = maItemListRect.Left()+col*mnItemWidth;
- const long y = maItemListRect.Top()+row*mnItemHeight;
-
- return tools::Rectangle( Point(x, y), Size(mnItemWidth, mnItemHeight) );
-}
-
-void ValueSet::Clear()
-{
- ImplDeleteItems();
-
- // reset variables
- mnFirstLine = 0;
- mnCurCol = 0;
- mnHighItemId = 0;
- mnSelItemId = 0;
- mbNoSelection = true;
-
- mbFormat = true;
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
-}
-
-size_t ValueSet::GetItemCount() const
-{
- return mItemList.size();
-}
-
-size_t ValueSet::GetItemPos( sal_uInt16 nItemId ) const
-{
- for ( size_t i = 0, n = mItemList.size(); i < n; ++i ) {
- if ( mItemList[i]->mnId == nItemId ) {
- return i;
- }
- }
- return VALUESET_ITEM_NOTFOUND;
-}
-
-sal_uInt16 ValueSet::GetItemId( size_t nPos ) const
-{
- return ( nPos < mItemList.size() ) ? mItemList[nPos]->mnId : 0 ;
-}
-
-sal_uInt16 ValueSet::GetItemId( const Point& rPos ) const
-{
- size_t nItemPos = ImplGetItem( rPos );
- if ( nItemPos != VALUESET_ITEM_NOTFOUND )
- return GetItemId( nItemPos );
-
- return 0;
-}
-
-tools::Rectangle ValueSet::GetItemRect( sal_uInt16 nItemId ) const
-{
- const size_t nPos = GetItemPos( nItemId );
-
- if ( nPos!=VALUESET_ITEM_NOTFOUND && mItemList[nPos]->mbVisible )
- return ImplGetItemRect( nPos );
-
- return tools::Rectangle();
-}
-
-void ValueSet::SetColCount( sal_uInt16 nNewCols )
-{
- if ( mnUserCols != nNewCols )
- {
- mnUserCols = nNewCols;
- mbFormat = true;
- queue_resize();
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
- }
-}
-
-void ValueSet::SetLineCount( sal_uInt16 nNewLines )
-{
- if ( mnUserVisLines != nNewLines )
- {
- mnUserVisLines = nNewLines;
- mbFormat = true;
- queue_resize();
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
- }
-}
-
-void ValueSet::SetItemWidth( long nNewItemWidth )
-{
- if ( mnUserItemWidth != nNewItemWidth )
- {
- mnUserItemWidth = nNewItemWidth;
- mbFormat = true;
- queue_resize();
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
- }
-}
-
-void ValueSet::SetItemHeight( long nNewItemHeight )
-{
- if ( mnUserItemHeight != nNewItemHeight )
- {
- mnUserItemHeight = nNewItemHeight;
- mbFormat = true;
- queue_resize();
- if ( IsReallyVisible() && IsUpdateMode() )
- Invalidate();
- }
-}
-
-void ValueSet::SelectItem( sal_uInt16 nItemId )
-{
- size_t nItemPos = 0;
-
- if ( nItemId )
- {
- nItemPos = GetItemPos( nItemId );
- if ( nItemPos == VALUESET_ITEM_NOTFOUND )
- return;
- }
-
- if ( !((mnSelItemId != nItemId) || mbNoSelection) )
- return;
-
- const sal_uInt16 nOldItem = mnSelItemId;
- mnSelItemId = nItemId;
- mbNoSelection = false;
-
- bool bNewOut = !mbFormat && IsReallyVisible() && IsUpdateMode();
- bool bNewLine = false;
-
- // if necessary scroll to the visible area
- if (mbScroll && mnCols)
- {
- sal_uInt16 nNewLine = static_cast<sal_uInt16>(nItemPos / mnCols);
- if ( nNewLine < mnFirstLine )
- {
- mnFirstLine = nNewLine;
- bNewLine = true;
- }
- else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) )
- {
- mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1);
- bNewLine = true;
- }
- }
-
- if ( bNewOut )
- {
- if ( bNewLine )
- {
- // redraw everything if the visible area has changed
- mbFormat = true;
- Invalidate();
- }
- else
- {
- // remove old selection and draw the new one
- Invalidate();
- }
- }
-
- if( ImplHasAccessibleListeners() )
- {
- // focus event (deselect)
- if( nOldItem )
- {
- const size_t nPos = GetItemPos( nItemId );
-
- if( nPos != VALUESET_ITEM_NOTFOUND )
- {
- ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation(
- mItemList[nPos]->GetAccessible( false/*bIsTransientChildrenDisabled*/ ) );
-
- if( pItemAcc )
- {
- Any aOldAny;
- Any aNewAny;
- aOldAny <<= Reference<XInterface>(static_cast<cppu::OWeakObject*>(pItemAcc));
- ImplFireAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
- }
- }
- }
-
- // focus event (select)
- const size_t nPos = GetItemPos( mnSelItemId );
-
- ValueSetItem* pItem;
- if( nPos != VALUESET_ITEM_NOTFOUND )
- pItem = mItemList[nPos].get();
- else
- pItem = mpNoneItem.get();
-
- ValueItemAcc* pItemAcc = nullptr;
- if (pItem != nullptr)
- pItemAcc = ValueItemAcc::getImplementation( pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ ) );
-
- if( pItemAcc )
- {
- Any aOldAny;
- Any aNewAny;
- aNewAny <<= Reference<XInterface>(static_cast<cppu::OWeakObject*>(pItemAcc));
- ImplFireAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny);
- }
-
- // selection event
- Any aOldAny;
- Any aNewAny;
- ImplFireAccessibleEvent(AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny);
- }
-}
-
-void ValueSet::SetNoSelection()
-{
- mbNoSelection = true;
- mbHighlight = false;
-
- if (IsReallyVisible() && IsUpdateMode())
- Invalidate();
-}
-
-Color ValueSet::GetItemColor( sal_uInt16 nItemId ) const
-{
- size_t nPos = GetItemPos( nItemId );
-
- if ( nPos != VALUESET_ITEM_NOTFOUND )
- return mItemList[nPos]->maColor;
- else
- return Color();
-}
-
-OUString ValueSet::GetItemText( sal_uInt16 nItemId ) const
-{
- size_t nPos = GetItemPos( nItemId );
-
- if ( nPos != VALUESET_ITEM_NOTFOUND )
- return mItemList[nPos]->maText;
-
- return OUString();
-}
-
-void ValueSet::EndSelection()
-{
- if ( mbHighlight )
- {
- if ( IsTracking() )
- EndTracking( TrackingEventFlags::Cancel );
-
- ImplHighlightItem( mnSelItemId );
- mbHighlight = false;
- }
-}
-
-Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCols,
- sal_uInt16 nDesireLines ) const
-{
- size_t nCalcCols = nDesireCols;
- size_t nCalcLines = nDesireLines;
-
- if ( !nCalcCols )
- {
- if ( mnUserCols )
- nCalcCols = mnUserCols;
- else
- nCalcCols = 1;
- }
-
- if ( !nCalcLines )
- {
- nCalcLines = mnVisLines;
-
- if ( mbFormat )
- {
- if ( mnUserVisLines )
- nCalcLines = mnUserVisLines;
- else
- {
- // Floor( (M+N-1)/N )==Ceiling( M/N )
- nCalcLines = (mItemList.size()+nCalcCols-1) / nCalcCols;
- if ( !nCalcLines )
- nCalcLines = 1;
- }
- }
- }
-
- Size aSize( rItemSize.Width() * nCalcCols, rItemSize.Height() * nCalcLines );
- WinBits nStyle = GetStyle();
- long nTxtHeight = GetTextHeight();
- long n;
-
- if ( nStyle & WB_ITEMBORDER )
- {
- if ( nStyle & WB_DOUBLEBORDER )
- n = ITEM_OFFSET_DOUBLE;
- else
- n = ITEM_OFFSET;
-
- aSize.AdjustWidth(n * nCalcCols );
- aSize.AdjustHeight(n * nCalcLines );
- }
- else
- n = 0;
-
- if ( nStyle & WB_NAMEFIELD )
- {
- aSize.AdjustHeight(nTxtHeight + NAME_OFFSET );
- if ( !(nStyle & WB_FLATVALUESET) )
- aSize.AdjustHeight(NAME_LINE_HEIGHT + NAME_LINE_OFF_Y );
- }
-
- if ( nStyle & WB_NONEFIELD )
- {
- aSize.AdjustHeight(nTxtHeight + n);
- }
-
- // sum possible ScrollBar width
- aSize.AdjustWidth(GetScrollWidth() );
-
- return aSize;
-}
-
-Size ValueSet::CalcItemSizePixel( const Size& rItemSize) const
-{
- Size aSize = rItemSize;
-
- WinBits nStyle = GetStyle();
- if ( nStyle & WB_ITEMBORDER )
- {
- long n;
-
- if ( nStyle & WB_DOUBLEBORDER )
- n = ITEM_OFFSET_DOUBLE;
- else
- n = ITEM_OFFSET;
-
- aSize.AdjustWidth(n );
- aSize.AdjustHeight(n );
- }
-
- return aSize;
-}
-
-long ValueSet::GetScrollWidth() const
-{
- if (GetStyle() & WB_VSCROLL)
- {
- ValueSet* pValueSet = const_cast<ValueSet*>(this);
- if (!mxScrollBar)
- {
- pValueSet->ImplInitScrollBar();
- }
- pValueSet->Invalidate();
- return mxScrollBar->GetSizePixel().Width() + SCRBAR_OFFSET;
- }
- else
- return 0;
-}
-
-Size ValueSet::GetLargestItemSize()
-{
- Size aLargestItem;
-
- for (const std::unique_ptr<ValueSetItem>& pItem : mItemList)
- {
- if (!pItem->mbVisible)
- continue;
-
- if (pItem->meType != VALUESETITEM_IMAGE &&
- pItem->meType != VALUESETITEM_IMAGE_AND_TEXT)
- {
- // handle determining an optimal size for this case
- continue;
- }
-
- Size aSize = pItem->maImage.GetSizePixel();
- if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT)
- {
- aSize.AdjustHeight(3 * NAME_LINE_HEIGHT + GetTextHeight());
- aSize.setWidth( std::max(aSize.Width(),
- GetTextWidth(pItem->maText) + NAME_OFFSET) );
- }
-
- aLargestItem.setWidth( std::max(aLargestItem.Width(), aSize.Width()) );
- aLargestItem.setHeight( std::max(aLargestItem.Height(), aSize.Height()) );
- }
-
- return aLargestItem;
-}
-
-Size ValueSet::GetOptimalSize() const
-{
- return CalcWindowSizePixel(
- const_cast<ValueSet *>(this)->GetLargestItemSize());
-}
-
-void ValueSet::SetEdgeBlending(bool bNew)
-{
- if(mbEdgeBlending != bNew)
- {
- mbEdgeBlending = bNew;
- mbFormat = true;
-
- if(IsReallyVisible() && IsUpdateMode())
- {
- Invalidate();
- }
- }
-}
-
SvtValueSet::SvtValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow)
: maVirDev( VclPtr<VirtualDevice>::Create())
, mxScrolledWindow(std::move(pScrolledWindow))
diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx
deleted file mode 100644
index 0e0df658f06a..000000000000
--- a/svtools/source/uitest/uiobject.cxx
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <memory>
-#include <uitest/uiobject.hxx>
-
-#include <svtools/valueset.hxx>
-
-ValueSetUIObject::ValueSetUIObject(const VclPtr<ValueSet>& xValueSet)
- : WindowUIObject(xValueSet)
- , mxValueSet(xValueSet)
-{
-}
-
-ValueSetUIObject::~ValueSetUIObject() {}
-
-void ValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters)
-{
- if (!mxValueSet->IsEnabled() || !mxValueSet->IsReallyVisible())
- return;
-
- if (rAction == "SELECT")
- {
- if (rParameters.find("POS") != rParameters.end())
- {
- auto aPos = rParameters.find("POS");
- OUString aVal = aPos->second;
- sal_Int32 nPos = aVal.toInt32();
- mxValueSet->SelectItem(nPos);
- mxValueSet->Select();
- }
- }
- else
- WindowUIObject::execute(rAction, rParameters);
-}
-
-StringMap ValueSetUIObject::get_state()
-{
- StringMap aMap = WindowUIObject::get_state();
- aMap["EntryCount"] = OUString::number(mxValueSet->GetItemCount());
-
- return aMap;
-}
-
-OUString ValueSetUIObject::get_name() const { return "ValueSetUIObject"; }
-
-OUString ValueSetUIObject::get_action(VclEventId /*nEvent*/) const
-{
- // No action for this control that trigger item selection after mouse tracking end
- return OUString();
-}
-
-std::unique_ptr<UIObject> ValueSetUIObject::create(vcl::Window* pWindow)
-{
- ValueSet* pValueSet = dynamic_cast<ValueSet*>(pWindow);
- assert(pValueSet);
- return std::unique_ptr<UIObject>(new ValueSetUIObject(pValueSet));
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */