accessibility/source/standard/vclxaccessiblecheckbox.cxx |   40 +++++----------
 1 file changed, 14 insertions(+), 26 deletions(-)

New commits:
commit e3c9a06b7056e2b99628aef8005329c328bcab91
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Dec 4 16:39:30 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Dec 4 20:47:51 2024 +0100

    a11y: Use vcl CheckBox directly in VCLXAccessibleCheckBox
    
    ... instead of using the toolkit/UNO wrapper class
    VCLXCheckBox.
    
    Change-Id: I271535f3e2e46202e2ca3d2e3f9a1d05ac380c41
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177815
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/accessibility/source/standard/vclxaccessiblecheckbox.cxx 
b/accessibility/source/standard/vclxaccessiblecheckbox.cxx
index 46c3e8749e92..debdb086df1e 100644
--- a/accessibility/source/standard/vclxaccessiblecheckbox.cxx
+++ b/accessibility/source/standard/vclxaccessiblecheckbox.cxx
@@ -19,7 +19,6 @@
 
 #include <standard/vclxaccessiblecheckbox.hxx>
 
-#include <toolkit/awt/vclxwindows.hxx>
 #include <helper/accresmgr.hxx>
 #include <strings.hrc>
 
@@ -54,25 +53,15 @@ VCLXAccessibleCheckBox::VCLXAccessibleCheckBox( VCLXWindow* 
pVCLWindow )
 
 bool VCLXAccessibleCheckBox::IsChecked() const
 {
-    bool bChecked = false;
-
-    VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( 
GetVCLXWindow() );
-    if ( pVCLXCheckBox && pVCLXCheckBox->getState() == sal_Int16(1) )
-        bChecked = true;
-
-    return bChecked;
+    VclPtr<CheckBox> pCheckBox = GetAs<CheckBox>();
+    return pCheckBox && pCheckBox->IsChecked();
 }
 
 
 bool VCLXAccessibleCheckBox::IsIndeterminate() const
 {
-    bool bIndeterminate = false;
-
-    VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( 
GetVCLXWindow() );
-    if ( pVCLXCheckBox && pVCLXCheckBox->getState() == sal_Int16(2) )
-        bIndeterminate = true;
-
-    return bIndeterminate;
+    VclPtr<CheckBox> pCheckBox = GetAs<CheckBox>();
+    return pCheckBox && pCheckBox->GetState() == TRISTATE_INDET;
 }
 
 
@@ -176,23 +165,22 @@ sal_Bool VCLXAccessibleCheckBox::doAccessibleAction ( 
sal_Int32 nIndex )
     if ( nIndex != 0 )
         throw IndexOutOfBoundsException();
 
-    VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
-    VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( 
GetVCLXWindow() );
-    if ( pCheckBox && pVCLXCheckBox )
+    VclPtr<CheckBox> pCheckBox = GetAs<CheckBox>();
+    if (pCheckBox)
     {
         sal_Int32 nValueMax = sal_Int32(1);
 
         if ( pCheckBox->IsTriStateEnabled() )
             nValueMax = sal_Int32(2);
 
-        sal_Int32 nValue = static_cast<sal_Int32>(pVCLXCheckBox->getState());
+        sal_Int32 nValue = static_cast<sal_Int32>(pCheckBox->GetState());
 
         ++nValue;
 
         if ( nValue > nValueMax )
             nValue = 0;
 
-        pVCLXCheckBox->setState( static_cast<sal_Int16>(nValue) );
+        pCheckBox->SetState(static_cast<TriState>(nValue));
     }
 
     return true;
@@ -259,9 +247,9 @@ Any VCLXAccessibleCheckBox::getCurrentValue(  )
 
     Any aValue;
 
-    VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( 
GetVCLXWindow() );
-    if ( pVCLXCheckBox )
-        aValue <<= static_cast<sal_Int32>(pVCLXCheckBox->getState());
+    VclPtr<CheckBox> pCheckBox = GetAs<CheckBox>();
+    if (pCheckBox)
+        aValue <<= static_cast<sal_Int32>(pCheckBox->GetState());
 
     return aValue;
 }
@@ -273,8 +261,8 @@ sal_Bool VCLXAccessibleCheckBox::setCurrentValue( const 
Any& aNumber )
 
     bool bReturn = false;
 
-    VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( 
GetVCLXWindow() );
-    if ( pVCLXCheckBox )
+    VclPtr<CheckBox> pCheckBox = GetAs<CheckBox>();
+    if (pCheckBox)
     {
         sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
         OSL_VERIFY( aNumber >>= nValue );
@@ -285,7 +273,7 @@ sal_Bool VCLXAccessibleCheckBox::setCurrentValue( const 
Any& aNumber )
         else if ( nValue > nValueMax )
             nValue = nValueMax;
 
-        pVCLXCheckBox->setState( static_cast<sal_Int16>(nValue) );
+        pCheckBox->SetState(static_cast<TriState>(nValue));
         bReturn = true;
     }
 

Reply via email to