nss: upgrade to release 3.73
[LibreOffice.git] / vcl / unx / gtk3 / a11y / gtk3atkselection.cxx
blob91759e8d0b211e417c6a031b24f90add1a7a975e
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/XAccessibleSelection.hpp>
24 using namespace ::com::sun::star;
26 /// @throws uno::RuntimeException
27 static css::uno::Reference<css::accessibility::XAccessibleSelection>
28 getSelection( AtkSelection *pSelection )
30 AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection );
31 if( pWrap )
33 if( !pWrap->mpSelection.is() )
35 pWrap->mpSelection.set(pWrap->mpContext, css::uno::UNO_QUERY);
38 return pWrap->mpSelection;
41 return css::uno::Reference<css::accessibility::XAccessibleSelection>();
44 extern "C" {
46 static gboolean
47 selection_add_selection( AtkSelection *selection,
48 gint i )
50 try {
51 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
52 = getSelection( selection );
53 if( pSelection.is() )
55 pSelection->selectAccessibleChild( i );
56 return true;
59 catch(const uno::Exception&) {
60 g_warning( "Exception in selectAccessibleChild()" );
63 return FALSE;
66 static gboolean
67 selection_clear_selection( AtkSelection *selection )
69 try {
70 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
71 = getSelection( selection );
72 if( pSelection.is() )
74 pSelection->clearAccessibleSelection();
75 return true;
78 catch(const uno::Exception&) {
79 g_warning( "Exception in selectAccessibleChild()" );
82 return FALSE;
85 static AtkObject*
86 selection_ref_selection( AtkSelection *selection,
87 gint i )
89 try {
90 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
91 = getSelection( selection );
92 if( pSelection.is() )
93 return atk_object_wrapper_ref( pSelection->getSelectedAccessibleChild( i ) );
95 catch(const uno::Exception&) {
96 g_warning( "Exception in getSelectedAccessibleChild()" );
99 return nullptr;
102 static gint
103 selection_get_selection_count( AtkSelection *selection)
105 try {
106 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
107 = getSelection( selection );
108 if( pSelection.is() )
109 return pSelection->getSelectedAccessibleChildCount();
111 catch(const uno::Exception&) {
112 g_warning( "Exception in getSelectedAccessibleChildCount()" );
115 return -1;
118 static gboolean
119 selection_is_child_selected( AtkSelection *selection,
120 gint i)
122 try {
123 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
124 = getSelection( selection );
125 if( pSelection.is() )
126 return pSelection->isAccessibleChildSelected( i );
128 catch(const uno::Exception&) {
129 g_warning( "Exception in getSelectedAccessibleChildCount()" );
132 return FALSE;
135 static gboolean
136 selection_remove_selection( AtkSelection *selection,
137 gint i )
139 try {
140 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
141 = getSelection( selection );
142 if( pSelection.is() )
144 pSelection->deselectAccessibleChild( i );
145 return true;
148 catch(const uno::Exception&) {
149 g_warning( "Exception in getSelectedAccessibleChildCount()" );
152 return FALSE;
155 static gboolean
156 selection_select_all_selection( AtkSelection *selection)
158 try {
159 css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
160 = getSelection( selection );
161 if( pSelection.is() )
163 pSelection->selectAllAccessibleChildren();
164 return true;
167 catch(const uno::Exception&) {
168 g_warning( "Exception in getSelectedAccessibleChildCount()" );
171 return FALSE;
174 } // extern "C"
176 void
177 selectionIfaceInit( AtkSelectionIface *iface)
179 g_return_if_fail (iface != nullptr);
181 iface->add_selection = selection_add_selection;
182 iface->clear_selection = selection_clear_selection;
183 iface->ref_selection = selection_ref_selection;
184 iface->get_selection_count = selection_get_selection_count;
185 iface->is_child_selected = selection_is_child_selected;
186 iface->remove_selection = selection_remove_selection;
187 iface->select_all_selection = selection_select_all_selection;
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */