tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / extended / accessibleeditbrowseboxcell.cxx
bloba61e86a4e2d75b55d9e26974bf572a1859e811d7
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 <helper/accresmgr.hxx>
21 #include <strings.hrc>
23 #include <extended/accessibleeditbrowseboxcell.hxx>
24 #include <comphelper/processfactory.hxx>
25 #include <utility>
26 #include <comphelper/diagnose_ex.hxx>
28 namespace accessibility
30 using namespace com::sun::star::accessibility;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::awt;
34 using namespace ::comphelper;
36 EditBrowseBoxTableCell::EditBrowseBoxTableCell(
37 const css::uno::Reference< css::accessibility::XAccessible >& _rxParent,
38 const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
39 const css::uno::Reference< css::accessibility::XAccessibleContext >& _xControlChild,
40 ::vcl::IAccessibleTableProvider& _rBrowseBox,
41 const css::uno::Reference< css::awt::XWindow >& _xFocusWindow,
42 sal_Int32 _nRowPos,
43 sal_uInt16 _nColPos)
44 :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
45 ,OAccessibleContextWrapperHelper( ::comphelper::getProcessComponentContext(), rBHelper, _xControlChild, _rxOwningAccessible, _rxParent )
47 aggregateProxy( m_refCount, *this );
50 EditBrowseBoxTableCell::~EditBrowseBoxTableCell()
52 if ( !rBHelper.bDisposed )
54 acquire(); // to prevent duplicate dtor calls
55 dispose();
59 OUString SAL_CALL EditBrowseBoxTableCell::getImplementationName()
61 return u"com.sun.star.comp.svtools.TableCellProxy"_ustr;
64 IMPLEMENT_FORWARD_XINTERFACE2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
66 IMPLEMENT_FORWARD_XTYPEPROVIDER2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
68 void EditBrowseBoxTableCell::notifyTranslatedEvent( const AccessibleEventObject& _rEvent )
70 commitEvent( _rEvent.EventId, _rEvent.NewValue, _rEvent.OldValue );
73 // css::accessibility::XAccessibleComponent
74 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getForeground( )
76 SolarMethodGuard aGuard(getMutex());
77 ensureIsAlive();
79 css::uno::Reference< css::accessibility::XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
80 if ( xAccComp.is() )
81 return xAccComp->getForeground();
82 return 0;
85 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getBackground( )
87 SolarMethodGuard aGuard(getMutex());
88 ensureIsAlive();
90 css::uno::Reference< css::accessibility::XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
91 if ( xAccComp.is() )
92 return xAccComp->getBackground();
93 return 0;
96 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleParent( )
98 return m_xParentAccessible;
101 OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleDescription()
103 SolarMethodGuard aGuard(getMutex());
104 ensureIsAlive();
106 return m_xInnerContext->getAccessibleDescription();
109 OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleName()
111 SolarMethodGuard aGuard(getMutex());
112 ensureIsAlive();
114 return AccResId(RID_STR_ACC_COLUMN_NUM).replaceAll("%COLUMNNUMBER", OUString::number(getColumnPos()-1)) + ", "
115 + AccResId(RID_STR_ACC_ROW_NUM).replaceAll("%ROWNUMBER", OUString::number(getRowPos()));
118 css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleRelationSet()
120 SolarMethodGuard aGuard(getMutex());
121 ensureIsAlive();
123 return baseGetAccessibleRelationSet( );
126 sal_Int64 SAL_CALL EditBrowseBoxTableCell::getAccessibleStateSet()
128 SolarMethodGuard aGuard(getMutex());
129 ensureIsAlive();
131 return m_xInnerContext->getAccessibleStateSet();
132 // TODO: shouldn't we add an ACTIVE here? Isn't the EditBrowseBoxTableCell always ACTIVE?
135 sal_Int64 SAL_CALL EditBrowseBoxTableCell::getAccessibleChildCount( )
137 SolarMethodGuard aGuard(getMutex());
138 ensureIsAlive();
140 return baseGetAccessibleChildCount();
143 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleChild( sal_Int64 i )
145 SolarMethodGuard aGuard(getMutex());
146 ensureIsAlive();
148 return baseGetAccessibleChild( i );
151 sal_Int16 SAL_CALL EditBrowseBoxTableCell::getAccessibleRole()
153 SolarMethodGuard aGuard(getMutex());
154 ensureIsAlive();
156 return m_xInnerContext->getAccessibleRole( );
159 void SAL_CALL EditBrowseBoxTableCell::dispose()
161 // simply disambiguate. Note that the OComponentHelper base in AccessibleBrowseBoxCell
162 // will call our "disposing()", which will call "dispose()" on the OAccessibleContextWrapperHelper
163 // so there is no need to do this here.
164 AccessibleBrowseBoxCell::dispose();
167 void SAL_CALL EditBrowseBoxTableCell::disposing( const css::lang::EventObject& _rSource )
169 AccessibleBrowseBoxCell::disposing( _rSource );
170 OAccessibleContextWrapperHelper::disposing( _rSource );
173 void SAL_CALL EditBrowseBoxTableCell::disposing()
175 SolarMethodGuard aGuard(getMutex());
177 OAccessibleContextWrapperHelper::dispose();
178 // TODO: do we need to dispose our inner object? The base class does this, but is it a good idea?
179 AccessibleBrowseBoxCell::disposing();
182 // EditBrowseBoxTableCell
183 EditBrowseBoxTableCellAccess::EditBrowseBoxTableCellAccess(
184 css::uno::Reference< css::accessibility::XAccessible > _xParent, css::uno::Reference< css::accessibility::XAccessible > _xControlAccessible,
185 css::uno::Reference< css::awt::XWindow > _xFocusWindow,
186 ::vcl::IAccessibleTableProvider& _rBrowseBox, sal_Int32 _nRowPos, sal_uInt16 _nColPos )
187 :m_xParent(std::move( _xParent ))
188 ,m_xControlAccessible(std::move( _xControlAccessible ))
189 ,m_xFocusWindow(std::move( _xFocusWindow ))
190 ,m_pBrowseBox( &_rBrowseBox )
191 ,m_nRowPos( _nRowPos )
192 ,m_nColPos( _nColPos )
196 EditBrowseBoxTableCellAccess::~EditBrowseBoxTableCellAccess( )
200 css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL EditBrowseBoxTableCellAccess::getAccessibleContext( )
202 if ( !m_pBrowseBox || !m_xControlAccessible.is() )
203 throw DisposedException();
204 css::uno::Reference< css::accessibility::XAccessibleContext > xMyContext( m_aContext );
205 if ( !xMyContext.is() )
207 css::uno::Reference< css::accessibility::XAccessibleContext > xInnerContext = m_xControlAccessible->getAccessibleContext();
208 css::uno::Reference< css::accessibility::XAccessible > xMe( this );
210 xMyContext = new EditBrowseBoxTableCell( xMe, m_xParent, xInnerContext, *m_pBrowseBox, m_xFocusWindow, m_nRowPos, m_nColPos );
211 m_aContext = xMyContext;
213 return xMyContext;
216 void EditBrowseBoxTableCellAccess::disposing(std::unique_lock<std::mutex>&)
218 // dispose our context, if it still alive
219 css::uno::Reference< XComponent > xMyContext( m_aContext.get(), UNO_QUERY );
220 if ( xMyContext.is() )
224 xMyContext->dispose();
226 catch( const Exception& )
228 TOOLS_WARN_EXCEPTION( "accessibility", "EditBrowseBoxTableCellAccess::disposing: caught an exception while disposing the context!" );
232 m_pBrowseBox = nullptr;
233 m_xControlAccessible.clear();
234 m_aContext.clear();
235 // NO dispose of the inner object there: it is the css::accessibility::XAccessible of a window, and disposing
236 // it would delete the respective VCL window
238 } // namespace accessibility
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */