merge the formfield patch from ooo-build
[ooovba.git] / accessibility / source / standard / vclxaccessibledropdowncombobox.cxx
blobb222fce840a54ea581adc5b054ff43e76394a07a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vclxaccessibledropdowncombobox.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
33 #include <accessibility/standard/vclxaccessibledropdowncombobox.hxx>
34 #include <accessibility/standard/vclxaccessiblecombobox.hxx>
35 #include <accessibility/standard/vclxaccessibletextfield.hxx>
36 #include <accessibility/standard/vclxaccessiblelist.hxx>
37 #include <accessibility/helper/accresmgr.hxx>
38 #include <accessibility/helper/accessiblestrings.hrc>
40 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
41 #include <com/sun/star/accessibility/AccessibleRole.hpp>
42 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
43 #include <tools/debug.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vcl/combobox.hxx>
46 #include <vcl/unohelp.hxx>
48 #include <toolkit/awt/vclxwindow.hxx>
49 #include <toolkit/helper/convert.hxx>
51 #include <comphelper/sequence.hxx>
52 #include <cppuhelper/typeprovider.hxx>
53 #include <unotools/accessiblestatesethelper.hxx>
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::lang;
58 using namespace ::com::sun::star::uno;
59 using namespace ::com::sun::star::accessibility;
62 VCLXAccessibleDropDownComboBox::VCLXAccessibleDropDownComboBox (VCLXWindow* pVCLWindow)
63 : VCLXAccessibleBox (pVCLWindow, VCLXAccessibleBox::COMBOBOX, true)
70 VCLXAccessibleDropDownComboBox::~VCLXAccessibleDropDownComboBox (void)
76 bool VCLXAccessibleDropDownComboBox::IsValid (void) const
78 return static_cast<ComboBox*>(GetWindow()) != NULL;
85 void VCLXAccessibleDropDownComboBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
87 switch ( rVclWindowEvent.GetId() )
89 case VCLEVENT_DROPDOWN_OPEN:
90 case VCLEVENT_DROPDOWN_CLOSE:
92 /* // child count changed
93 Any aOldValue, aNewValue;
94 // get the listbox child
95 Reference< XAccessible > xChild;
96 if ( !xChild.is() )
98 try
100 // the listbox is the second child
101 xChild = getAccessibleChild(1);
103 catch ( IndexOutOfBoundsException& ) {}
104 catch ( RuntimeException& ) {}
106 if ( rVclWindowEvent.GetId() == VCLEVENT_DROPDOWN_OPEN )
107 aNewValue <<= xChild;
108 else
109 aOldValue <<= xChild;
110 NotifyAccessibleEvent(
111 AccessibleEventId::CHILD, aOldValue, aNewValue
114 break;
117 default:
118 VCLXAccessibleBox::ProcessWindowEvent( rVclWindowEvent );
125 //===== XServiceInfo ========================================================
127 ::rtl::OUString VCLXAccessibleDropDownComboBox::getImplementationName()
128 throw (RuntimeException)
130 return ::rtl::OUString::createFromAscii("com.sun.star.comp.toolkit.AccessibleDropDownComboBox");
136 Sequence< ::rtl::OUString > VCLXAccessibleDropDownComboBox::getSupportedServiceNames (void)
137 throw (RuntimeException)
139 Sequence< ::rtl::OUString > aNames = VCLXAccessibleBox::getSupportedServiceNames();
140 sal_Int32 nLength = aNames.getLength();
141 aNames.realloc( nLength + 1 );
142 aNames[nLength] = ::rtl::OUString::createFromAscii(
143 "com.sun.star.accessibility.AccessibleDropDownComboBox" );
144 return aNames;