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 <sal/config.h>
22 #include <string_view>
24 #include "atkwrapper.hxx"
26 #include <com/sun/star/accessibility/XAccessibleImage.hpp>
28 using namespace ::com::sun::star
;
32 getAsConst( std::u16string_view rString
)
34 static const int nMax
= 10;
35 static OString aUgly
[nMax
];
37 nIdx
= (nIdx
+ 1) % nMax
;
38 aUgly
[nIdx
] = OUStringToOString( rString
, RTL_TEXTENCODING_UTF8
);
39 return aUgly
[ nIdx
].getStr();
42 /// @throws uno::RuntimeException
43 static css::uno::Reference
<css::accessibility::XAccessibleImage
>
44 getImage( AtkImage
*pImage
)
46 AtkObjectWrapper
*pWrap
= ATK_OBJECT_WRAPPER( pImage
);
49 if( !pWrap
->mpImage
.is() )
51 pWrap
->mpImage
.set(pWrap
->mpContext
, css::uno::UNO_QUERY
);
54 return pWrap
->mpImage
;
57 return css::uno::Reference
<css::accessibility::XAccessibleImage
>();
63 image_get_image_description( AtkImage
*image
)
66 css::uno::Reference
<css::accessibility::XAccessibleImage
> pImage
69 return getAsConst( pImage
->getAccessibleImageDescription() );
71 catch(const uno::Exception
&) {
72 g_warning( "Exception in getAccessibleImageDescription()" );
79 image_get_image_position( AtkImage
*image
,
82 AtkCoordType coord_type
)
85 if( ATK_IS_COMPONENT( image
) )
89 atk_component_get_extents(ATK_COMPONENT(image
), x
, y
, &nWidth
, &nHeight
, coord_type
);
92 g_warning( "FIXME: no image position information" );
96 image_get_image_size( AtkImage
*image
,
100 *width
= *height
= -1;
102 css::uno::Reference
<css::accessibility::XAccessibleImage
> pImage
106 *width
= pImage
->getAccessibleImageWidth();
107 *height
= pImage
->getAccessibleImageHeight();
110 catch(const uno::Exception
&) {
111 g_warning( "Exception in getAccessibleImageHeight() or Width" );
116 image_set_image_description( AtkImage
*, const gchar
* )
118 g_warning ("FIXME: no set image description");
125 imageIfaceInit (gpointer iface_
, gpointer
)
127 auto const iface
= static_cast<AtkImageIface
*>(iface_
);
128 g_return_if_fail (iface
!= nullptr);
130 iface
->set_image_description
= image_set_image_description
;
131 iface
->get_image_description
= image_get_image_description
;
132 iface
->get_image_position
= image_get_image_position
;
133 iface
->get_image_size
= image_get_image_size
;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */