nss: upgrade to release 3.73
[LibreOffice.git] / vcl / unx / gtk3 / a11y / gtk3atkimage.cxx
blobacd43f46769087347740c3853b46f089a5af7254
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
26 // FIXME
27 static const gchar *
28 getAsConst( const OUString& rString )
30 static const int nMax = 10;
31 static OString aUgly[nMax];
32 static int nIdx = 0;
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 );
43 if( pWrap )
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>();
56 extern "C" {
58 static const gchar *
59 image_get_image_description( AtkImage *image )
61 try {
62 css::uno::Reference<css::accessibility::XAccessibleImage> pImage
63 = getImage( image );
64 if( pImage.is() )
65 return getAsConst( pImage->getAccessibleImageDescription() );
67 catch(const uno::Exception&) {
68 g_warning( "Exception in getAccessibleImageDescription()" );
71 return nullptr;
74 static void
75 image_get_image_position( AtkImage *image,
76 gint *x,
77 gint *y,
78 AtkCoordType coord_type )
80 *x = *y = -1;
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
87 else
88 g_warning( "FIXME: no image position information" );
91 static void
92 image_get_image_size( AtkImage *image,
93 gint *width,
94 gint *height )
96 *width = *height = -1;
97 try {
98 css::uno::Reference<css::accessibility::XAccessibleImage> pImage
99 = getImage( image );
100 if( pImage.is() )
102 *width = pImage->getAccessibleImageWidth();
103 *height = pImage->getAccessibleImageHeight();
106 catch(const uno::Exception&) {
107 g_warning( "Exception in getAccessibleImageHeight() or Width" );
111 static gboolean
112 image_set_image_description( AtkImage *, const gchar * )
114 g_warning ("FIXME: no set image description");
115 return FALSE;
118 } // extern "C"
120 void
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: */