summaryrefslogtreecommitdiff
path: root/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/source/standard/vclxaccessibletoolboxitem.cxx')
-rw-r--r--accessibility/source/standard/vclxaccessibletoolboxitem.cxx146
1 files changed, 70 insertions, 76 deletions
diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
index 64a08300ce59..b8e489c9f610 100644
--- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
@@ -29,13 +29,13 @@
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <comphelper/accessiblecontexthelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/unohelp2.hxx>
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <strings.hxx>
#include <sal/log.hxx>
@@ -67,9 +67,9 @@ VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_In
m_bIndeterminate( false )
{
- OSL_ENSURE( m_pToolBox, "invalid toolbox" );
+ assert( m_pToolBox );
m_nItemId = m_pToolBox->GetItemId( m_nIndexInParent );
- m_sOldName = GetText();
+ m_sOldName = implGetAccessibleName();
m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId );
m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == TRISTATE_INDET );
ToolBoxItemType eType = m_pToolBox->GetItemType( m_nIndexInParent );
@@ -114,33 +114,6 @@ VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem()
{
}
-OUString VCLXAccessibleToolBoxItem::GetText()
-{
- OUString sRet;
- // no text for separators and spaces
- if ( m_pToolBox && m_nItemId > 0 )
- {
- sRet = m_pToolBox->GetItemText( m_nItemId );
- if (sRet.isEmpty())
- {
- sRet = m_pToolBox->GetQuickHelpText( m_nItemId );
- if (sRet.isEmpty())
- {
- vcl::Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId );
- if ( m_nRole == AccessibleRole::PANEL && pItemWindow && pItemWindow->GetAccessible().is() &&
- pItemWindow->GetAccessible()->getAccessibleContext().is() )
- {
- OUString sWinText = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName();
- if (!sWinText.isEmpty())
- sRet = sWinText;
- }
- }
- }
-
- }
- return sRet;
-}
-
void VCLXAccessibleToolBoxItem::SetFocus( bool _bFocus )
{
if ( m_bHasFocus != _bFocus )
@@ -189,7 +162,7 @@ void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate )
void VCLXAccessibleToolBoxItem::NameChanged()
{
- OUString sNewName = implGetText();
+ OUString sNewName = implGetAccessibleName();
if ( sNewName != m_sOldName )
{
Any aOldValue, aNewValue;
@@ -242,7 +215,11 @@ awt::Rectangle VCLXAccessibleToolBoxItem::implGetBounds( )
OUString VCLXAccessibleToolBoxItem::implGetText()
{
- return GetText();
+ // no text for separators and spaces
+ if (!m_pToolBox || m_nItemId <= ToolBoxItemId(0))
+ return OUString();
+
+ return m_pToolBox->GetItemText(m_nItemId);
}
Locale VCLXAccessibleToolBoxItem::implGetLocale()
@@ -258,7 +235,6 @@ void VCLXAccessibleToolBoxItem::implGetSelection( sal_Int32& nStartIndex, sal_In
// XInterface
-IMPLEMENT_FORWARD_REFCOUNT( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE )
Any SAL_CALL VCLXAccessibleToolBoxItem::queryInterface( const Type& _rType )
{
// #i33611# - toolbox buttons without text don't support XAccessibleText
@@ -266,21 +242,14 @@ Any SAL_CALL VCLXAccessibleToolBoxItem::queryInterface( const Type& _rType )
&& ( !m_pToolBox || m_pToolBox->GetButtonType() == ButtonType::SYMBOLONLY ) )
return Any();
- css::uno::Any aReturn = AccessibleTextHelper_BASE::queryInterface( _rType );
- if ( !aReturn.hasValue() )
- aReturn = VCLXAccessibleToolBoxItem_BASE::queryInterface( _rType );
- return aReturn;
+ return ImplInheritanceHelper::queryInterface( _rType );
}
-// XTypeProvider
-
-IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE, VCLXAccessibleToolBoxItem_BASE )
-
// XComponent
void SAL_CALL VCLXAccessibleToolBoxItem::disposing()
{
- AccessibleTextHelper_BASE::disposing();
+ comphelper::OAccessibleTextHelper::disposing();
m_pToolBox = nullptr;
}
@@ -288,7 +257,7 @@ void SAL_CALL VCLXAccessibleToolBoxItem::disposing()
OUString VCLXAccessibleToolBoxItem::getImplementationName()
{
- return "com.sun.star.comp.toolkit.AccessibleToolBoxItem";
+ return u"com.sun.star.comp.toolkit.AccessibleToolBoxItem"_ustr;
}
sal_Bool VCLXAccessibleToolBoxItem::supportsService( const OUString& rServiceName )
@@ -298,10 +267,10 @@ sal_Bool VCLXAccessibleToolBoxItem::supportsService( const OUString& rServiceNam
Sequence< OUString > VCLXAccessibleToolBoxItem::getSupportedServiceNames()
{
- return {"com.sun.star.accessibility.AccessibleContext",
- "com.sun.star.accessibility.AccessibleComponent",
- "com.sun.star.accessibility.AccessibleExtendedComponent",
- "com.sun.star.accessibility.AccessibleToolBoxItem"};
+ return {u"com.sun.star.accessibility.AccessibleContext"_ustr,
+ u"com.sun.star.accessibility.AccessibleComponent"_ustr,
+ u"com.sun.star.accessibility.AccessibleExtendedComponent"_ustr,
+ u"com.sun.star.accessibility.AccessibleToolBoxItem"_ustr};
}
// XAccessible
@@ -313,14 +282,14 @@ Reference< XAccessibleContext > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibl
// XAccessibleContext
-sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChildCount( )
+sal_Int64 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChildCount( )
{
OContextEntryGuard aGuard( this );
return m_xChild.is() ? 1 : 0;
}
-Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int32 i )
+Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int64 i )
{
OContextEntryGuard aGuard( this );
@@ -338,7 +307,7 @@ Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleParent
return m_pToolBox->GetAccessible();
}
-sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleIndexInParent( )
+sal_Int64 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleIndexInParent( )
{
OContextEntryGuard aGuard( this );
@@ -369,53 +338,73 @@ OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription( )
}
}
+OUString VCLXAccessibleToolBoxItem::implGetAccessibleName()
+{
+ OUString sRet = m_pToolBox->GetAccessibleName(m_nItemId);
+ if (!sRet.isEmpty())
+ return sRet;
+
+ sRet = implGetText();
+ if (!sRet.isEmpty())
+ return sRet;
+
+ sRet = m_pToolBox->GetQuickHelpText( m_nItemId );
+ if (!sRet.isEmpty())
+ return sRet;
+
+ vcl::Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId );
+ if ( m_nRole == AccessibleRole::PANEL && pItemWindow && pItemWindow->GetAccessible().is() &&
+ pItemWindow->GetAccessible()->getAccessibleContext().is() )
+ {
+ sRet = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName();
+ }
+ return sRet;
+}
+
OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleName( )
{
OExternalLockGuard aGuard( this );
-
- // entry text == accessible name
- return GetText();
+ return implGetAccessibleName();
}
Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRelationSet( )
{
OContextEntryGuard aGuard( this );
- utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
- Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
- return xSet;
+ return new utl::AccessibleRelationSetHelper;
}
-Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleStateSet( )
+sal_Int64 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleStateSet( )
{
OExternalLockGuard aGuard( this );
- utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
- Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
+ sal_Int64 nStateSet = 0;
if ( m_pToolBox && !rBHelper.bDisposed && !rBHelper.bInDispose )
{
- pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
+ nStateSet |= AccessibleStateType::FOCUSABLE;
+ if (m_pToolBox->GetItemBits(m_nItemId) & ToolBoxItemBits::CHECKABLE)
+ nStateSet |= AccessibleStateType::CHECKABLE;
if ( m_bIsChecked && m_nRole != AccessibleRole::PANEL )
- pStateSetHelper->AddState( AccessibleStateType::CHECKED );
+ nStateSet |= AccessibleStateType::CHECKED;
if ( m_bIndeterminate )
- pStateSetHelper->AddState( AccessibleStateType::INDETERMINATE );
+ nStateSet |= AccessibleStateType::INDETERMINATE;
if ( m_pToolBox->IsEnabled() && m_pToolBox->IsItemEnabled( m_nItemId ) )
{
- pStateSetHelper->AddState( AccessibleStateType::ENABLED );
- pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
+ nStateSet |= AccessibleStateType::ENABLED;
+ nStateSet |= AccessibleStateType::SENSITIVE;
}
if ( m_pToolBox->IsItemVisible( m_nItemId ) )
- pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
+ nStateSet |= AccessibleStateType::VISIBLE;
if ( m_pToolBox->IsItemReallyVisible( m_nItemId ) )
- pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ nStateSet |= AccessibleStateType::SHOWING;
if ( m_bHasFocus )
- pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
+ nStateSet |= AccessibleStateType::FOCUSED;
}
else
- pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ nStateSet |= AccessibleStateType::DEFUNC;
- return xStateSet;
+ return nStateSet;
}
// XAccessibleText
@@ -424,26 +413,26 @@ OUString VCLXAccessibleToolBoxItem::getText()
{
OExternalLockGuard aGuard( this );
- return GetText();
+ return implGetText();
}
sal_Int32 VCLXAccessibleToolBoxItem::getCharacterCount()
{
- return GetText().getLength();
+ return implGetText().getLength();
}
sal_Unicode VCLXAccessibleToolBoxItem::getCharacter( sal_Int32 nIndex )
{
OExternalLockGuard aGuard( this );
- return OCommonAccessibleText::implGetCharacter( GetText(), nIndex );
+ return OCommonAccessibleText::implGetCharacter(implGetText(), nIndex);
}
OUString VCLXAccessibleToolBoxItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
{
OExternalLockGuard aGuard( this );
- return OCommonAccessibleText::implGetTextRange( GetText(), nStartIndex, nEndIndex );
+ return OCommonAccessibleText::implGetTextRange(implGetText(), nStartIndex, nEndIndex);
}
sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getCaretPosition()
@@ -455,7 +444,7 @@ sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setCaretPosition( sal_Int32 nIndex
{
OExternalLockGuard aGuard( this );
- if ( !implIsValidRange( nIndex, nIndex, GetText().getLength() ) )
+ if (!implIsValidRange(nIndex, nIndex, implGetText().getLength()))
throw IndexOutOfBoundsException();
return false;
@@ -501,7 +490,7 @@ sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getIndexAtPoint( const awt::Point&
sal_Int32 nIndex = -1;
if ( m_pToolBox && m_pToolBox->GetButtonType() != ButtonType::SYMBOLONLY ) // symbol buttons have no character bounds
{
- sal_uInt16 nItemId = 0;
+ ToolBoxItemId nItemId;
tools::Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
Point aPnt( VCLPoint( aPoint ) );
aPnt += aItemRect.TopLeft();
@@ -539,7 +528,7 @@ sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sa
{
OUString sText( OCommonAccessibleText::implGetTextRange( implGetText(), nStartIndex, nEndIndex ) );
- vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( sText );
+ rtl::Reference<vcl::unohelper::TextDataObject> pDataObj = new vcl::unohelper::TextDataObject( sText );
SolarMutexReleaser aReleaser;
xClipboard->setContents( pDataObj, nullptr );
@@ -728,5 +717,10 @@ Any VCLXAccessibleToolBoxItem::getMinimumValue( )
return Any(sal_Int32(0));
}
+Any VCLXAccessibleToolBoxItem::getMinimumIncrement( )
+{
+ return Any(sal_Int32(1));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */