1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: atkvalue.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include "atkwrapper.hxx"
36 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
41 using namespace ::com::sun::star
;
43 static accessibility::XAccessibleValue
*
44 getValue( AtkValue
*pValue
) throw (uno::RuntimeException
)
46 AtkObjectWrapper
*pWrap
= ATK_OBJECT_WRAPPER( pValue
);
49 if( !pWrap
->mpValue
&& pWrap
->mpContext
)
51 uno::Any any
= pWrap
->mpContext
->queryInterface( accessibility::XAccessibleValue::static_type(NULL
) );
52 pWrap
->mpValue
= reinterpret_cast< accessibility::XAccessibleValue
* > (any
.pReserved
);
53 pWrap
->mpValue
->acquire();
56 return pWrap
->mpValue
;
62 static void anyToGValue( uno::Any aAny
, GValue
*pValue
)
64 // FIXME: expand to lots of types etc.
68 memset( pValue
, 0, sizeof( GValue
) );
69 g_value_init( pValue
, G_TYPE_DOUBLE
);
70 g_value_set_double( pValue
, aDouble
);
76 value_wrapper_get_current_value( AtkValue
*value
,
80 accessibility::XAccessibleValue
* pValue
= getValue( value
);
82 anyToGValue( pValue
->getCurrentValue(), gval
);
84 catch(const uno::Exception
& e
) {
85 g_warning( "Exception in getCurrentValue()" );
90 value_wrapper_get_maximum_value( AtkValue
*value
,
94 accessibility::XAccessibleValue
* pValue
= getValue( value
);
96 anyToGValue( pValue
->getMaximumValue(), gval
);
98 catch(const uno::Exception
& e
) {
99 g_warning( "Exception in getCurrentValue()" );
104 value_wrapper_get_minimum_value( AtkValue
*value
,
108 accessibility::XAccessibleValue
* pValue
= getValue( value
);
110 anyToGValue( pValue
->getMinimumValue(), gval
);
112 catch(const uno::Exception
& e
) {
113 g_warning( "Exception in getCurrentValue()" );
118 value_wrapper_set_current_value( AtkValue
*value
,
122 accessibility::XAccessibleValue
* pValue
= getValue( value
);
125 // FIXME - this needs expanding
126 double aDouble
= g_value_get_double( gval
);
129 return pValue
->setCurrentValue( aAny
);
132 catch(const uno::Exception
& e
) {
133 g_warning( "Exception in getCurrentValue()" );
142 valueIfaceInit (AtkValueIface
*iface
)
144 g_return_if_fail (iface
!= NULL
);
146 iface
->get_current_value
= value_wrapper_get_current_value
;
147 iface
->get_maximum_value
= value_wrapper_get_maximum_value
;
148 iface
->get_minimum_value
= value_wrapper_get_minimum_value
;
149 iface
->set_current_value
= value_wrapper_set_current_value
;