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>
26 using namespace ::com::sun::star
;
28 static accessibility::XAccessibleSelection
*
29 getSelection( AtkSelection
*pSelection
) throw (uno::RuntimeException
)
31 AtkObjectWrapper
*pWrap
= ATK_OBJECT_WRAPPER( pSelection
);
34 if( !pWrap
->mpSelection
&& pWrap
->mpContext
)
36 uno::Any any
= pWrap
->mpContext
->queryInterface( cppu::UnoType
<accessibility::XAccessibleSelection
>::get() );
37 pWrap
->mpSelection
= static_cast< accessibility::XAccessibleSelection
* > (any
.pReserved
);
38 pWrap
->mpSelection
->acquire();
41 return pWrap
->mpSelection
;
50 selection_add_selection( AtkSelection
*selection
,
54 accessibility::XAccessibleSelection
* pSelection
= getSelection( selection
);
57 pSelection
->selectAccessibleChild( i
);
61 catch(const uno::Exception
&) {
62 g_warning( "Exception in selectAccessibleChild()" );
69 selection_clear_selection( AtkSelection
*selection
)
72 accessibility::XAccessibleSelection
* pSelection
= getSelection( selection
);
75 pSelection
->clearAccessibleSelection();
79 catch(const uno::Exception
&) {
80 g_warning( "Exception in selectAccessibleChild()" );
87 selection_ref_selection( AtkSelection
*selection
,
91 accessibility::XAccessibleSelection
* pSelection
= 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 accessibility::XAccessibleSelection
* pSelection
= getSelection( selection
);
108 return pSelection
->getSelectedAccessibleChildCount();
110 catch(const uno::Exception
&) {
111 g_warning( "Exception in getSelectedAccessibleChildCount()" );
118 selection_is_child_selected( AtkSelection
*selection
,
122 accessibility::XAccessibleSelection
* pSelection
= getSelection( selection
);
124 return pSelection
->isAccessibleChildSelected( i
);
126 catch(const uno::Exception
&) {
127 g_warning( "Exception in getSelectedAccessibleChildCount()" );
134 selection_remove_selection( AtkSelection
*selection
,
138 accessibility::XAccessibleSelection
* pSelection
= getSelection( selection
);
141 pSelection
->deselectAccessibleChild( i
);
145 catch(const uno::Exception
&) {
146 g_warning( "Exception in getSelectedAccessibleChildCount()" );
153 selection_select_all_selection( AtkSelection
*selection
)
156 accessibility::XAccessibleSelection
* pSelection
= getSelection( selection
);
159 pSelection
->selectAllAccessibleChildren();
163 catch(const uno::Exception
&) {
164 g_warning( "Exception in getSelectedAccessibleChildCount()" );
173 selectionIfaceInit( AtkSelectionIface
*iface
)
175 g_return_if_fail (iface
!= NULL
);
177 iface
->add_selection
= selection_add_selection
;
178 iface
->clear_selection
= selection_clear_selection
;
179 iface
->ref_selection
= selection_ref_selection
;
180 iface
->get_selection_count
= selection_get_selection_count
;
181 iface
->is_child_selected
= selection_is_child_selected
;
182 iface
->remove_selection
= selection_remove_selection
;
183 iface
->select_all_selection
= selection_select_all_selection
;
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */