LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkeditabletext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 72 0.0 %
Date: 2014-11-03 Functions: 0 9 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             : #include "atktextattributes.hxx"
      22             : 
      23             : #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
      24             : #include <com/sun/star/accessibility/TextSegment.hpp>
      25             : 
      26             : #include <stdio.h>
      27             : #include <string.h>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31             : static accessibility::XAccessibleEditableText*
      32           0 :     getEditableText( AtkEditableText *pEditableText ) throw (uno::RuntimeException)
      33             : {
      34           0 :     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pEditableText );
      35           0 :     if( pWrap )
      36             :     {
      37           0 :         if( !pWrap->mpEditableText && pWrap->mpContext )
      38             :         {
      39           0 :             uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleEditableText>::get() );
      40           0 :             pWrap->mpEditableText = reinterpret_cast< accessibility::XAccessibleEditableText * > (any.pReserved);
      41           0 :             pWrap->mpEditableText->acquire();
      42             :         }
      43             : 
      44           0 :         return pWrap->mpEditableText;
      45             :     }
      46             : 
      47           0 :     return NULL;
      48             : }
      49             : 
      50             : /*****************************************************************************/
      51             : 
      52             : extern "C" {
      53             : 
      54             : static gboolean
      55           0 : editable_text_wrapper_set_run_attributes( AtkEditableText  *text,
      56             :                                           AtkAttributeSet  *attribute_set,
      57             :                                           gint              nStartOffset,
      58             :                                           gint              nEndOffset)
      59             : {
      60             :     try {
      61           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
      62           0 :         if( pEditableText )
      63             :         {
      64           0 :             uno::Sequence< beans::PropertyValue > aAttributeList;
      65             : 
      66           0 :             if( attribute_set_map_to_property_values( attribute_set, aAttributeList ) )
      67           0 :                 return pEditableText->setAttributes(nStartOffset, nEndOffset, aAttributeList);
      68             :         }
      69             :     }
      70           0 :     catch(const uno::Exception&) {
      71           0 :         g_warning( "Exception in setAttributes()" );
      72             :     }
      73             : 
      74           0 :     return FALSE;
      75             : }
      76             : 
      77             : static void
      78           0 : editable_text_wrapper_set_text_contents( AtkEditableText  *text,
      79             :                                          const gchar      *string )
      80             : {
      81             :     try {
      82           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
      83           0 :         if( pEditableText )
      84             :         {
      85           0 :             OUString aString ( string, strlen(string), RTL_TEXTENCODING_UTF8 );
      86           0 :             pEditableText->setText( aString );
      87             :         }
      88             :     }
      89           0 :     catch(const uno::Exception&) {
      90           0 :         g_warning( "Exception in setText()" );
      91             :     }
      92           0 : }
      93             : 
      94             : static void
      95           0 : editable_text_wrapper_insert_text( AtkEditableText  *text,
      96             :                                    const gchar      *string,
      97             :                                    gint             length,
      98             :                                    gint             *pos )
      99             : {
     100             :     try {
     101           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
     102           0 :         if( pEditableText )
     103             :         {
     104           0 :             OUString aString ( string, length, RTL_TEXTENCODING_UTF8 );
     105           0 :             if( pEditableText->insertText( aString, *pos ) )
     106           0 :                 *pos += length;
     107             :         }
     108             :     }
     109           0 :     catch(const uno::Exception&) {
     110           0 :         g_warning( "Exception in insertText()" );
     111             :     }
     112           0 : }
     113             : 
     114             : static void
     115           0 : editable_text_wrapper_cut_text( AtkEditableText  *text,
     116             :                                 gint             start,
     117             :                                 gint             end )
     118             : {
     119             :     try {
     120           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
     121           0 :         if( pEditableText )
     122           0 :             pEditableText->cutText( start, end );
     123             :     }
     124           0 :     catch(const uno::Exception&) {
     125           0 :         g_warning( "Exception in cutText()" );
     126             :     }
     127           0 : }
     128             : 
     129             : static void
     130           0 : editable_text_wrapper_delete_text( AtkEditableText  *text,
     131             :                                    gint             start,
     132             :                                    gint             end )
     133             : {
     134             :     try {
     135           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
     136           0 :         if( pEditableText )
     137           0 :             pEditableText->deleteText( start, end );
     138             :     }
     139           0 :     catch(const uno::Exception&) {
     140           0 :         g_warning( "Exception in deleteText()" );
     141             :     }
     142           0 : }
     143             : 
     144             : static void
     145           0 : editable_text_wrapper_paste_text( AtkEditableText  *text,
     146             :                                   gint             pos )
     147             : {
     148             :     try {
     149           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
     150           0 :         if( pEditableText )
     151           0 :             pEditableText->pasteText( pos );
     152             :     }
     153           0 :     catch(const uno::Exception&) {
     154           0 :         g_warning( "Exception in pasteText()" );
     155             :     }
     156           0 : }
     157             : 
     158             : static void
     159           0 : editable_text_wrapper_copy_text( AtkEditableText  *text,
     160             :                                  gint             start,
     161             :                                  gint             end )
     162             : {
     163             :     try {
     164           0 :         accessibility::XAccessibleEditableText* pEditableText = getEditableText( text );
     165           0 :         if( pEditableText )
     166           0 :             pEditableText->copyText( start, end );
     167             :     }
     168           0 :     catch(const uno::Exception&) {
     169           0 :         g_warning( "Exception in copyText()" );
     170             :     }
     171           0 : }
     172             : 
     173             : } // extern "C"
     174             : 
     175             : void
     176           0 : editableTextIfaceInit (AtkEditableTextIface *iface)
     177             : {
     178           0 :   g_return_if_fail (iface != NULL);
     179             : 
     180           0 :   iface->set_text_contents = editable_text_wrapper_set_text_contents;
     181           0 :   iface->insert_text = editable_text_wrapper_insert_text;
     182           0 :   iface->copy_text = editable_text_wrapper_copy_text;
     183           0 :   iface->cut_text = editable_text_wrapper_cut_text;
     184           0 :   iface->delete_text = editable_text_wrapper_delete_text;
     185           0 :   iface->paste_text = editable_text_wrapper_paste_text;
     186           0 :   iface->set_run_attributes = editable_text_wrapper_set_run_attributes;
     187             : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10