LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkvalue.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 53 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "atkwrapper.hxx"
      21             : 
      22             : #include <com/sun/star/accessibility/XAccessibleValue.hpp>
      23             : 
      24             : #include <string.h>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : static accessibility::XAccessibleValue*
      29           0 :     getValue( AtkValue *pValue ) throw (uno::RuntimeException)
      30             : {
      31           0 :     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue );
      32           0 :     if( pWrap )
      33             :     {
      34           0 :         if( !pWrap->mpValue && pWrap->mpContext )
      35             :         {
      36           0 :             uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleValue>::get() );
      37           0 :             pWrap->mpValue = static_cast< accessibility::XAccessibleValue * > (any.pReserved);
      38           0 :             pWrap->mpValue->acquire();
      39             :         }
      40             : 
      41           0 :         return pWrap->mpValue;
      42             :     }
      43             : 
      44           0 :     return NULL;
      45             : }
      46             : 
      47           0 : static void anyToGValue( uno::Any aAny, GValue *pValue )
      48             : {
      49             :     // FIXME: expand to lots of types etc.
      50           0 :     double aDouble=0;
      51           0 :     aAny >>= aDouble;
      52             : 
      53           0 :     memset( pValue,  0, sizeof( GValue ) );
      54           0 :     g_value_init( pValue, G_TYPE_DOUBLE );
      55           0 :     g_value_set_double( pValue, aDouble );
      56           0 : }
      57             : 
      58             : extern "C" {
      59             : 
      60             : static void
      61           0 : value_wrapper_get_current_value( AtkValue *value,
      62             :                                  GValue   *gval )
      63             : {
      64             :     try {
      65           0 :         accessibility::XAccessibleValue* pValue = getValue( value );
      66           0 :         if( pValue )
      67           0 :             anyToGValue( pValue->getCurrentValue(), gval );
      68             :     }
      69           0 :     catch(const uno::Exception&) {
      70           0 :         g_warning( "Exception in getCurrentValue()" );
      71             :     }
      72           0 : }
      73             : 
      74             : static void
      75           0 : value_wrapper_get_maximum_value( AtkValue *value,
      76             :                                  GValue   *gval )
      77             : {
      78             :     try {
      79           0 :         accessibility::XAccessibleValue* pValue = getValue( value );
      80           0 :         if( pValue )
      81           0 :             anyToGValue( pValue->getMaximumValue(), gval );
      82             :     }
      83           0 :     catch(const uno::Exception&) {
      84           0 :         g_warning( "Exception in getCurrentValue()" );
      85             :     }
      86           0 : }
      87             : 
      88             : static void
      89           0 : value_wrapper_get_minimum_value( AtkValue *value,
      90             :                                  GValue   *gval )
      91             : {
      92             :     try {
      93           0 :         accessibility::XAccessibleValue* pValue = getValue( value );
      94           0 :         if( pValue )
      95           0 :             anyToGValue( pValue->getMinimumValue(), gval );
      96             :     }
      97           0 :     catch(const uno::Exception&) {
      98           0 :         g_warning( "Exception in getCurrentValue()" );
      99             :     }
     100           0 : }
     101             : 
     102             : static gboolean
     103           0 : value_wrapper_set_current_value( AtkValue     *value,
     104             :                                  const GValue *gval )
     105             : {
     106             :     try {
     107           0 :         accessibility::XAccessibleValue* pValue = getValue( value );
     108           0 :         if( pValue )
     109             :         {
     110             :             // FIXME - this needs expanding
     111           0 :             double aDouble = g_value_get_double( gval );
     112           0 :             uno::Any aAny;
     113           0 :             aAny <<= aDouble;
     114           0 :             return pValue->setCurrentValue( aAny );
     115             :         }
     116             :     }
     117           0 :     catch(const uno::Exception&) {
     118           0 :         g_warning( "Exception in getCurrentValue()" );
     119             :     }
     120             : 
     121           0 :     return FALSE;
     122             : }
     123             : 
     124             : } // extern "C"
     125             : 
     126             : void
     127           0 : valueIfaceInit (AtkValueIface *iface)
     128             : {
     129           0 :   g_return_if_fail (iface != NULL);
     130             : 
     131           0 :   iface->get_current_value = value_wrapper_get_current_value;
     132           0 :   iface->get_maximum_value = value_wrapper_get_maximum_value;
     133           0 :   iface->get_minimum_value = value_wrapper_get_minimum_value;
     134           0 :   iface->set_current_value = value_wrapper_set_current_value;
     135             : }
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11