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

Generated by: LCOV version 1.10