summaryrefslogtreecommitdiffstats
path: root/accessibility/source/standard/vclxaccessibleedit.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/source/standard/vclxaccessibleedit.cxx')
-rw-r--r--accessibility/source/standard/vclxaccessibleedit.cxx87
1 files changed, 44 insertions, 43 deletions
diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx
index 87cfcdb62f30..5943b4c8c745 100644
--- a/accessibility/source/standard/vclxaccessibleedit.cxx
+++ b/accessibility/source/standard/vclxaccessibleedit.cxx
@@ -22,16 +22,17 @@
#include <toolkit/awt/vclxwindows.hxx>
#include <toolkit/helper/convert.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <com/sun/star/accessibility/AccessibleTextType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <comphelper/accessiblecontexthelper.hxx>
#include <comphelper/string.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <vcl/toolkit/edit.hxx>
#include <vcl/toolkit/vclmedit.hxx>
@@ -55,7 +56,7 @@ using namespace ::comphelper;
VCLXAccessibleEdit::VCLXAccessibleEdit( VCLXWindow* pVCLWindow )
- :VCLXAccessibleTextComponent( pVCLWindow )
+ :ImplInheritanceHelper( pVCLWindow )
{
m_nCaretPosition = getCaretPosition();
}
@@ -103,17 +104,22 @@ void VCLXAccessibleEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEve
}
-void VCLXAccessibleEdit::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+void VCLXAccessibleEdit::FillAccessibleStateSet( sal_Int64& rStateSet )
{
VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
- VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
- if ( pVCLXEdit )
+ VCLXWindow* pVCLXWindow = GetVCLXWindow();
+ if (pVCLXWindow)
{
- rStateSet.AddState( AccessibleStateType::FOCUSABLE );
- rStateSet.AddState( AccessibleStateType::SINGLE_LINE );
- if ( pVCLXEdit->isEditable() )
- rStateSet.AddState( AccessibleStateType::EDITABLE );
+ rStateSet |= AccessibleStateType::FOCUSABLE;
+
+ if (GetWindow() && GetWindow()->GetType() == WindowType::MULTILINEEDIT)
+ rStateSet |= AccessibleStateType::MULTI_LINE;
+ else
+ rStateSet |= AccessibleStateType::SINGLE_LINE;
+
+ if (isEditable())
+ rStateSet |= AccessibleStateType::EDITABLE;
}
}
@@ -128,14 +134,14 @@ OUString VCLXAccessibleEdit::implGetText()
VclPtr< Edit > pEdit = GetAs< Edit >();
if ( pEdit )
{
- aText = OutputDevice::GetNonMnemonicString( pEdit->GetText() );
+ aText = removeMnemonicFromString( pEdit->GetText() );
if ( implGetAccessibleRole() == AccessibleRole::PASSWORD_TEXT )
{
sal_Unicode cEchoChar = pEdit->GetEchoChar();
if ( !cEchoChar )
cEchoChar = '*';
- OUStringBuffer sTmp;
+ OUStringBuffer sTmp(aText.getLength());
aText = comphelper::string::padToLength(sTmp, aText.getLength(),
cEchoChar).makeStringAndClear();
}
@@ -147,47 +153,35 @@ OUString VCLXAccessibleEdit::implGetText()
void VCLXAccessibleEdit::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
{
- awt::Selection aSelection;
- VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
- if ( pVCLXEdit )
- aSelection = pVCLXEdit->getSelection();
+ Selection aSelection;
+ VclPtr<Edit> pEdit = GetAs<Edit>();
+ if (pEdit)
+ aSelection = pEdit->GetSelection();
- nStartIndex = aSelection.Min;
- nEndIndex = aSelection.Max;
+ nStartIndex = aSelection.Min();
+ nEndIndex = aSelection.Max();
}
-// XInterface
-
-
-IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleEdit, VCLXAccessibleTextComponent, VCLXAccessibleEdit_BASE )
-
-
-// XTypeProvider
-
-
-IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleEdit, VCLXAccessibleTextComponent, VCLXAccessibleEdit_BASE )
-
-
// XServiceInfo
OUString VCLXAccessibleEdit::getImplementationName()
{
- return "com.sun.star.comp.toolkit.AccessibleEdit";
+ return u"com.sun.star.comp.toolkit.AccessibleEdit"_ustr;
}
Sequence< OUString > VCLXAccessibleEdit::getSupportedServiceNames()
{
- return { "com.sun.star.awt.AccessibleEdit" };
+ return { u"com.sun.star.awt.AccessibleEdit"_ustr };
}
// XAccessibleContext
-sal_Int32 VCLXAccessibleEdit::getAccessibleChildCount()
+sal_Int64 VCLXAccessibleEdit::getAccessibleChildCount()
{
OExternalLockGuard aGuard( this );
@@ -195,7 +189,7 @@ sal_Int32 VCLXAccessibleEdit::getAccessibleChildCount()
}
-Reference< XAccessible > VCLXAccessibleEdit::getAccessibleChild( sal_Int32 )
+Reference< XAccessible > VCLXAccessibleEdit::getAccessibleChild( sal_Int64 )
{
throw IndexOutOfBoundsException();
}
@@ -426,11 +420,10 @@ sal_Bool VCLXAccessibleEdit::setSelection( sal_Int32 nStartIndex, sal_Int32 nEnd
if ( !implIsValidRange( nStartIndex, nEndIndex, sText.getLength() ) )
throw IndexOutOfBoundsException();
- VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
VclPtr< Edit > pEdit = GetAs< Edit >();
- if ( pVCLXEdit && pEdit && pEdit->IsEnabled() )
+ if (pEdit && pEdit->IsEnabled())
{
- pVCLXEdit->setSelection( awt::Selection( nStartIndex, nEndIndex ) );
+ pEdit->SetSelection(Selection(nStartIndex, nEndIndex));
bReturn = true;
}
@@ -562,10 +555,12 @@ sal_Bool VCLXAccessibleEdit::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndI
sal_Int32 nMinIndex = std::min( nStartIndex, nEndIndex );
sal_Int32 nMaxIndex = std::max( nStartIndex, nEndIndex );
- VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
- if ( pVCLXEdit && pVCLXEdit->isEditable() )
+
+ if (isEditable())
{
- pVCLXEdit->setText( sText.replaceAt( nMinIndex, nMaxIndex - nMinIndex, sReplacement ) );
+ VclPtr<Edit> pEdit = GetAs<Edit>();
+ assert(pEdit);
+ pEdit->SetText(sText.replaceAt(nMinIndex, nMaxIndex - nMinIndex, sReplacement));
sal_Int32 nIndex = nMinIndex + sReplacement.getLength();
setSelection( nIndex, nIndex );
bReturn = true;
@@ -592,17 +587,23 @@ sal_Bool VCLXAccessibleEdit::setText( const OUString& sText )
bool bReturn = false;
- VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
- if ( pVCLXEdit && pVCLXEdit->isEditable() )
+ if (isEditable())
{
- pVCLXEdit->setText( sText );
+ VclPtr<Edit> pEdit = GetAs<Edit>();
+ assert(pEdit);
+ pEdit->SetText(sText);
sal_Int32 nSize = sText.getLength();
- pVCLXEdit->setSelection( awt::Selection( nSize, nSize ) );
+ pEdit->SetSelection(Selection(nSize, nSize) );
bReturn = true;
}
return bReturn;
}
+bool VCLXAccessibleEdit::isEditable()
+{
+ VclPtr<Edit> pEdit = GetAs<Edit>();
+ return pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled();
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */