1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "atkwrapper.hxx"
22 #include <com/sun/star/accessibility/XAccessibleImage.hpp>
24 using namespace ::com::sun::star
;
28 getAsConst( const OUString
& rString
)
30 static const int nMax
= 10;
31 static OString aUgly
[nMax
];
33 nIdx
= (nIdx
+ 1) % nMax
;
34 aUgly
[nIdx
] = OUStringToOString( rString
, RTL_TEXTENCODING_UTF8
);
35 return aUgly
[ nIdx
].getStr();
38 /// @throws uno::RuntimeException
39 static css::uno::Reference
<css::accessibility::XAccessibleImage
>
40 getImage( AtkImage
*pImage
)
42 AtkObjectWrapper
*pWrap
= ATK_OBJECT_WRAPPER( pImage
);
45 if( !pWrap
->mpImage
.is() )
47 pWrap
->mpImage
.set(pWrap
->mpContext
, css::uno::UNO_QUERY
);
50 return pWrap
->mpImage
;
53 return css::uno::Reference
<css::accessibility::XAccessibleImage
>();
59 image_get_image_description( AtkImage
*image
)
62 css::uno::Reference
<css::accessibility::XAccessibleImage
> pImage
65 return getAsConst( pImage
->getAccessibleImageDescription() );
67 catch(const uno::Exception
&) {
68 g_warning( "Exception in getAccessibleImageDescription()" );
75 image_get_image_position( AtkImage
*image
,
78 AtkCoordType coord_type
)
81 if( ATK_IS_COMPONENT( image
) )
83 SAL_WNODEPRECATED_DECLARATIONS_PUSH
84 atk_component_get_position( ATK_COMPONENT( image
), x
, y
, coord_type
);
85 SAL_WNODEPRECATED_DECLARATIONS_POP
88 g_warning( "FIXME: no image position information" );
92 image_get_image_size( AtkImage
*image
,
96 *width
= *height
= -1;
98 css::uno::Reference
<css::accessibility::XAccessibleImage
> pImage
102 *width
= pImage
->getAccessibleImageWidth();
103 *height
= pImage
->getAccessibleImageHeight();
106 catch(const uno::Exception
&) {
107 g_warning( "Exception in getAccessibleImageHeight() or Width" );
112 image_set_image_description( AtkImage
*, const gchar
* )
114 g_warning ("FIXME: no set image description");
121 imageIfaceInit (AtkImageIface
*iface
)
123 g_return_if_fail (iface
!= nullptr);
125 iface
->set_image_description
= image_set_image_description
;
126 iface
->get_image_description
= image_get_image_description
;
127 iface
->get_image_position
= image_get_image_position
;
128 iface
->get_image_size
= image_get_image_size
;
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */