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

Generated by: LCOV version 1.11