LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkvalue.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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                 :            : 
      21                 :            : #include "atkwrapper.hxx"
      22                 :            : 
      23                 :            : #include <com/sun/star/accessibility/XAccessibleValue.hpp>
      24                 :            : 
      25                 :            : #include <stdio.h>
      26                 :            : #include <string.h>
      27                 :            : 
      28                 :            : using namespace ::com::sun::star;
      29                 :            : 
      30                 :            : static accessibility::XAccessibleValue*
      31                 :          0 :     getValue( AtkValue *pValue ) throw (uno::RuntimeException)
      32                 :            : {
      33                 :          0 :     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue );
      34                 :          0 :     if( pWrap )
      35                 :            :     {
      36                 :          0 :         if( !pWrap->mpValue && pWrap->mpContext )
      37                 :            :         {
      38                 :          0 :             uno::Any any = pWrap->mpContext->queryInterface( accessibility::XAccessibleValue::static_type(NULL) );
      39                 :          0 :             pWrap->mpValue = reinterpret_cast< accessibility::XAccessibleValue * > (any.pReserved);
      40                 :          0 :             pWrap->mpValue->acquire();
      41                 :            :         }
      42                 :            : 
      43                 :          0 :         return pWrap->mpValue;
      44                 :            :     }
      45                 :            : 
      46                 :          0 :     return NULL;
      47                 :            : }
      48                 :            : 
      49                 :          0 : static void anyToGValue( uno::Any aAny, GValue *pValue )
      50                 :            : {
      51                 :            :     // FIXME: expand to lots of types etc.
      52                 :          0 :     double aDouble=0;
      53                 :          0 :     aAny >>= aDouble;
      54                 :            : 
      55                 :          0 :     memset( pValue,  0, sizeof( GValue ) );
      56                 :          0 :     g_value_init( pValue, G_TYPE_DOUBLE );
      57                 :          0 :     g_value_set_double( pValue, aDouble );
      58                 :          0 : }
      59                 :            : 
      60                 :            : extern "C" {
      61                 :            : 
      62                 :            : static void
      63                 :          0 : value_wrapper_get_current_value( AtkValue *value,
      64                 :            :                                  GValue   *gval )
      65                 :            : {
      66                 :            :     try {
      67                 :          0 :         accessibility::XAccessibleValue* pValue = getValue( value );
      68                 :          0 :         if( pValue )
      69                 :          0 :             anyToGValue( pValue->getCurrentValue(), gval );
      70                 :            :     }
      71                 :          0 :     catch(const uno::Exception& e) {
      72                 :          0 :         g_warning( "Exception in getCurrentValue()" );
      73                 :            :     }
      74                 :          0 : }
      75                 :            : 
      76                 :            : static void
      77                 :          0 : value_wrapper_get_maximum_value( AtkValue *value,
      78                 :            :                                  GValue   *gval )
      79                 :            : {
      80                 :            :     try {
      81                 :          0 :         accessibility::XAccessibleValue* pValue = getValue( value );
      82                 :          0 :         if( pValue )
      83                 :          0 :             anyToGValue( pValue->getMaximumValue(), gval );
      84                 :            :     }
      85                 :          0 :     catch(const uno::Exception& e) {
      86                 :          0 :         g_warning( "Exception in getCurrentValue()" );
      87                 :            :     }
      88                 :          0 : }
      89                 :            : 
      90                 :            : static void
      91                 :          0 : value_wrapper_get_minimum_value( AtkValue *value,
      92                 :            :                                  GValue   *gval )
      93                 :            : {
      94                 :            :     try {
      95                 :          0 :         accessibility::XAccessibleValue* pValue = getValue( value );
      96                 :          0 :         if( pValue )
      97                 :          0 :             anyToGValue( pValue->getMinimumValue(), gval );
      98                 :            :     }
      99                 :          0 :     catch(const uno::Exception& e) {
     100                 :          0 :         g_warning( "Exception in getCurrentValue()" );
     101                 :            :     }
     102                 :          0 : }
     103                 :            : 
     104                 :            : static gboolean
     105                 :          0 : value_wrapper_set_current_value( AtkValue     *value,
     106                 :            :                                  const GValue *gval )
     107                 :            : {
     108                 :            :     try {
     109                 :          0 :         accessibility::XAccessibleValue* pValue = getValue( value );
     110                 :          0 :         if( pValue )
     111                 :            :         {
     112                 :            :             // FIXME - this needs expanding
     113                 :          0 :             double aDouble = g_value_get_double( gval );
     114                 :          0 :             uno::Any aAny;
     115                 :          0 :             aAny <<= aDouble;
     116                 :          0 :             return pValue->setCurrentValue( aAny );
     117                 :            :         }
     118                 :            :     }
     119                 :          0 :     catch(const uno::Exception& e) {
     120                 :          0 :         g_warning( "Exception in getCurrentValue()" );
     121                 :            :     }
     122                 :            : 
     123                 :          0 :     return FALSE;
     124                 :            : }
     125                 :            : 
     126                 :            : } // extern "C"
     127                 :            : 
     128                 :            : void
     129                 :          0 : valueIfaceInit (AtkValueIface *iface)
     130                 :            : {
     131                 :          0 :   g_return_if_fail (iface != NULL);
     132                 :            : 
     133                 :          0 :   iface->get_current_value = value_wrapper_get_current_value;
     134                 :          0 :   iface->get_maximum_value = value_wrapper_get_maximum_value;
     135                 :          0 :   iface->get_minimum_value = value_wrapper_get_minimum_value;
     136                 :          0 :   iface->set_current_value = value_wrapper_set_current_value;
     137                 :            : }
     138                 :            : 
     139                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10