vcl/unx/gtk3/a11y/atkvalue.cxx |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit a0b7b47e3ec843d8012a7526c1e8e72d67cc41b1
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Oct 24 12:29:54 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Oct 24 14:55:55 2023 +0200

    gtk3 a11y: Take current type into account when setting new value
    
    This is the gtk3 variant of
    
        Change-Id I8674fc37798491fd0b57543acb491edbd4a5a056
        qt a11y: Take current type into account when setting new value
    
    See that change's commit message for more details.
    
    Change-Id: I597220253fa0ca61252706915ad009b8846bbd42
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158383
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk3/a11y/atkvalue.cxx b/vcl/unx/gtk3/a11y/atkvalue.cxx
index f5e45d3b2556..014164da2027 100644
--- a/vcl/unx/gtk3/a11y/atkvalue.cxx
+++ b/vcl/unx/gtk3/a11y/atkvalue.cxx
@@ -21,6 +21,7 @@
 
 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
 
+#include <cmath>
 #include <string.h>
 
 using namespace ::com::sun::star;
@@ -110,8 +111,23 @@ value_wrapper_set_current_value( AtkValue     *value,
             = getValue( value );
         if( pValue.is() )
         {
-            // FIXME - this needs expanding
             double aDouble = g_value_get_double( gval );
+
+            // Different types of numerical values for XAccessibleValue are 
possible.
+            // If current value has an integer type, also use that for the new 
value, to make
+            // sure underlying implementations expecting that can handle the 
value properly.
+            const css::uno::Any aCurrentValue = pValue->getCurrentValue();
+            if (aCurrentValue.getValueTypeClass() == 
css::uno::TypeClass::TypeClass_LONG)
+            {
+                const sal_Int32 nValue = std::round<sal_Int32>(aDouble);
+                return pValue->setCurrentValue(css::uno::Any(nValue));
+            }
+            else if (aCurrentValue.getValueTypeClass() == 
css::uno::TypeClass::TypeClass_HYPER)
+            {
+                const sal_Int64 nValue = std::round<sal_Int64>(aDouble);
+                return pValue->setCurrentValue(css::uno::Any(nValue));
+            }
+
             return pValue->setCurrentValue( uno::Any(aDouble) );
         }
     }

Reply via email to