update dev300-m58
[ooovba.git] / vcl / unx / gtk / a11y / atkimage.cxx
bloba58178502c592247eb2db7e4cbc155eb49c099ad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: atkimage.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include "atkwrapper.hxx"
36 #include <com/sun/star/accessibility/XAccessibleImage.hpp>
38 #include <stdio.h>
40 using namespace ::com::sun::star;
42 // FIXME
43 static G_CONST_RETURN gchar *
44 getAsConst( rtl::OUString rString )
46 static const int nMax = 10;
47 static rtl::OString aUgly[nMax];
48 static int nIdx = 0;
49 nIdx = (nIdx + 1) % nMax;
50 aUgly[nIdx] = rtl::OUStringToOString( rString, RTL_TEXTENCODING_UTF8 );
51 return aUgly[ nIdx ];
54 static accessibility::XAccessibleImage*
55 getImage( AtkImage *pImage ) throw (uno::RuntimeException)
57 AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pImage );
58 if( pWrap )
60 if( !pWrap->mpImage && pWrap->mpContext )
62 uno::Any any = pWrap->mpContext->queryInterface( accessibility::XAccessibleImage::static_type(NULL) );
63 pWrap->mpImage = reinterpret_cast< accessibility::XAccessibleImage * > (any.pReserved);
64 pWrap->mpImage->acquire();
67 return pWrap->mpImage;
70 return NULL;
73 extern "C" {
75 static G_CONST_RETURN gchar *
76 image_get_image_description( AtkImage *image )
78 try {
79 accessibility::XAccessibleImage* pImage = getImage( image );
80 if( pImage )
81 return getAsConst( pImage->getAccessibleImageDescription() );
83 catch(const uno::Exception& e) {
84 g_warning( "Exception in getAccessibleImageDescription()" );
87 return NULL;
90 static void
91 image_get_image_position( AtkImage *image,
92 gint *x,
93 gint *y,
94 AtkCoordType coord_type )
96 *x = *y = 0;
97 if( ATK_IS_COMPONENT( image ) )
98 atk_component_get_position( ATK_COMPONENT( image ), x, y, coord_type );
99 else
100 g_warning( "FIXME: no image position information" );
103 static void
104 image_get_image_size( AtkImage *image,
105 gint *width,
106 gint *height )
108 *width = 0;
109 *height = 0;
110 try {
111 accessibility::XAccessibleImage* pImage = getImage( image );
112 if( pImage )
114 *width = pImage->getAccessibleImageWidth();
115 *height = pImage->getAccessibleImageHeight();
118 catch(const uno::Exception& e) {
119 g_warning( "Exception in getAccessibleImageHeight() or Width" );
123 static gboolean
124 image_set_image_description( AtkImage *, const gchar * )
126 g_warning ("FIXME: no set image description");
127 return FALSE;
130 } // extern "C"
132 void
133 imageIfaceInit (AtkImageIface *iface)
135 g_return_if_fail (iface != NULL);
137 iface->set_image_description = image_set_image_description;
138 iface->get_image_description = image_get_image_description;
139 iface->get_image_position = image_get_image_position;
140 iface->get_image_size = image_get_image_size;