1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: atkimage.cxx,v $
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>
40 using namespace ::com::sun::star
;
43 static G_CONST_RETURN gchar
*
44 getAsConst( rtl::OUString rString
)
46 static const int nMax
= 10;
47 static rtl::OString aUgly
[nMax
];
49 nIdx
= (nIdx
+ 1) % nMax
;
50 aUgly
[nIdx
] = rtl::OUStringToOString( rString
, RTL_TEXTENCODING_UTF8
);
54 static accessibility::XAccessibleImage
*
55 getImage( AtkImage
*pImage
) throw (uno::RuntimeException
)
57 AtkObjectWrapper
*pWrap
= ATK_OBJECT_WRAPPER( pImage
);
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
;
75 static G_CONST_RETURN gchar
*
76 image_get_image_description( AtkImage
*image
)
79 accessibility::XAccessibleImage
* pImage
= getImage( image
);
81 return getAsConst( pImage
->getAccessibleImageDescription() );
83 catch(const uno::Exception
& e
) {
84 g_warning( "Exception in getAccessibleImageDescription()" );
91 image_get_image_position( AtkImage
*image
,
94 AtkCoordType coord_type
)
97 if( ATK_IS_COMPONENT( image
) )
98 atk_component_get_position( ATK_COMPONENT( image
), x
, y
, coord_type
);
100 g_warning( "FIXME: no image position information" );
104 image_get_image_size( AtkImage
*image
,
111 accessibility::XAccessibleImage
* pImage
= getImage( image
);
114 *width
= pImage
->getAccessibleImageWidth();
115 *height
= pImage
->getAccessibleImageHeight();
118 catch(const uno::Exception
& e
) {
119 g_warning( "Exception in getAccessibleImageHeight() or Width" );
124 image_set_image_description( AtkImage
*, const gchar
* )
126 g_warning ("FIXME: no set image description");
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
;