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/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
);
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
>();
47 selection_add_selection( AtkSelection
*selection
,
51 css::uno::Reference
<css::accessibility::XAccessibleSelection
> pSelection
52 = getSelection( selection
);
55 pSelection
->selectAccessibleChild( i
);
59 catch(const uno::Exception
&) {
60 g_warning( "Exception in selectAccessibleChild()" );
67 selection_clear_selection( AtkSelection
*selection
)
70 css::uno::Reference
<css::accessibility::XAccessibleSelection
> pSelection
71 = getSelection( selection
);
74 pSelection
->clearAccessibleSelection();
78 catch(const uno::Exception
&) {
79 g_warning( "Exception in selectAccessibleChild()" );
86 selection_ref_selection( AtkSelection
*selection
,
90 css::uno::Reference
<css::accessibility::XAccessibleSelection
> pSelection
91 = getSelection( selection
);
93 return atk_object_wrapper_ref( pSelection
->getSelectedAccessibleChild( i
) );
95 catch(const uno::Exception
&) {
96 g_warning( "Exception in getSelectedAccessibleChild()" );
103 selection_get_selection_count( AtkSelection
*selection
)
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()" );
119 selection_is_child_selected( AtkSelection
*selection
,
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()" );
136 selection_remove_selection( AtkSelection
*selection
,
140 css::uno::Reference
<css::accessibility::XAccessibleSelection
> pSelection
141 = getSelection( selection
);
142 if( pSelection
.is() )
144 pSelection
->deselectAccessibleChild( i
);
148 catch(const uno::Exception
&) {
149 g_warning( "Exception in getSelectedAccessibleChildCount()" );
156 selection_select_all_selection( AtkSelection
*selection
)
159 css::uno::Reference
<css::accessibility::XAccessibleSelection
> pSelection
160 = getSelection( selection
);
161 if( pSelection
.is() )
163 pSelection
->selectAllAccessibleChildren();
167 catch(const uno::Exception
&) {
168 g_warning( "Exception in getSelectedAccessibleChildCount()" );
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: */