Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / vcl / unx / gtk3 / a11y / atkimage.cxx
bloba9af56f9cdc94e23165e70bb10213c331107c94d
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 <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;
30 // FIXME
31 static const gchar *
32 getAsConst( std::u16string_view rString )
34 static const int nMax = 10;
35 static OString aUgly[nMax];
36 static int nIdx = 0;
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 );
47 if( pWrap )
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>();
60 extern "C" {
62 static const gchar *
63 image_get_image_description( AtkImage *image )
65 try {
66 css::uno::Reference<css::accessibility::XAccessibleImage> pImage
67 = getImage( image );
68 if( pImage.is() )
69 return getAsConst( pImage->getAccessibleImageDescription() );
71 catch(const uno::Exception&) {
72 g_warning( "Exception in getAccessibleImageDescription()" );
75 return nullptr;
78 static void
79 image_get_image_position( AtkImage *image,
80 gint *x,
81 gint *y,
82 AtkCoordType coord_type )
84 *x = *y = -1;
85 if( ATK_IS_COMPONENT( image ) )
87 gint nWidth = -1;
88 gint nHeight = -1;
89 atk_component_get_extents(ATK_COMPONENT(image), x, y, &nWidth, &nHeight, coord_type);
91 else
92 g_warning( "FIXME: no image position information" );
95 static void
96 image_get_image_size( AtkImage *image,
97 gint *width,
98 gint *height )
100 *width = *height = -1;
101 try {
102 css::uno::Reference<css::accessibility::XAccessibleImage> pImage
103 = getImage( image );
104 if( pImage.is() )
106 *width = pImage->getAccessibleImageWidth();
107 *height = pImage->getAccessibleImageHeight();
110 catch(const uno::Exception&) {
111 g_warning( "Exception in getAccessibleImageHeight() or Width" );
115 static gboolean
116 image_set_image_description( AtkImage *, const gchar * )
118 g_warning ("FIXME: no set image description");
119 return FALSE;
122 } // extern "C"
124 void
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: */