1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_accessibility.hxx"
26 #include <accessibility/standard/vclxaccessibletextfield.hxx>
27 #include <vcl/lstbox.hxx>
28 #include <accessibility/helper/listboxhelper.hxx>
29 
30 #include <unotools/accessiblestatesethelper.hxx>
31 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <vcl/svapp.hxx>
35 #include <vcl/combobox.hxx>
36 
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::beans;
41 using namespace ::com::sun::star::accessibility;
42 
43 
44 
45 
VCLXAccessibleTextField(VCLXWindow * pVCLWindow,const Reference<XAccessible> & _xParent)46 VCLXAccessibleTextField::VCLXAccessibleTextField (VCLXWindow* pVCLWindow, const Reference< XAccessible >& _xParent) :
47 
48 	VCLXAccessibleTextComponent (pVCLWindow),
49 
50 	m_xParent( _xParent )
51 
52 {
53 }
54 
55 
56 
57 
~VCLXAccessibleTextField(void)58 VCLXAccessibleTextField::~VCLXAccessibleTextField (void)
59 {
60 }
61 
62 
63 
64 
implGetText(void)65 ::rtl::OUString VCLXAccessibleTextField::implGetText (void)
66 {
67     ::rtl::OUString aText;
68     ListBox* pListBox = static_cast<ListBox*>(GetWindow());
69     if (pListBox!=NULL && !pListBox->IsInDropDown())
70 		aText = pListBox->GetSelectEntry();
71 
72     return aText;
73 }
74 
75 
76 
77 
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField,VCLXAccessibleTextComponent,VCLXAccessible_BASE)78 IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
79 IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
80 
81 
82 //=====  XAccessible  =========================================================
83 
84 Reference<XAccessibleContext> SAL_CALL
85     VCLXAccessibleTextField::getAccessibleContext (void)
86     throw (RuntimeException)
87 {
88 	return this;
89 }
90 
91 
92 //=====  XAccessibleContext  ==================================================
93 
getAccessibleChildCount(void)94 sal_Int32 SAL_CALL VCLXAccessibleTextField::getAccessibleChildCount (void)
95     throw (RuntimeException)
96 {
97     return 0;
98 }
99 
100 
101 
102 
getAccessibleChild(sal_Int32)103 Reference<XAccessible> SAL_CALL VCLXAccessibleTextField::getAccessibleChild (sal_Int32)
104     throw (IndexOutOfBoundsException, RuntimeException)
105 {
106     throw IndexOutOfBoundsException();
107 }
108 
109 
110 
111 
getAccessibleRole(void)112 sal_Int16 SAL_CALL VCLXAccessibleTextField::getAccessibleRole (void)
113     throw (RuntimeException)
114 {
115 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
116 
117     return AccessibleRole::TEXT;
118 }
119 
getAccessibleParent()120 Reference< XAccessible > SAL_CALL VCLXAccessibleTextField::getAccessibleParent(  )
121 	throw (RuntimeException)
122 {
123 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
124 
125 	return m_xParent;
126 }
127 
128 
129 
130 //===== XServiceInfo ==========================================================
131 
getImplementationName(void)132 ::rtl::OUString VCLXAccessibleTextField::getImplementationName (void)
133     throw (RuntimeException)
134 {
135 	return ::rtl::OUString::createFromAscii ("com.sun.star.comp.toolkit.AccessibleTextField");
136 }
137 
138 
139 
140 
getSupportedServiceNames(void)141 Sequence< ::rtl::OUString > VCLXAccessibleTextField::getSupportedServiceNames (void)
142     throw (RuntimeException)
143 {
144 	Sequence< ::rtl::OUString > aNames = VCLXAccessibleTextComponent::getSupportedServiceNames();
145 	sal_Int32 nLength = aNames.getLength();
146 	aNames.realloc( nLength + 1 );
147 	aNames[nLength] = ::rtl::OUString::createFromAscii(
148         "com.sun.star.accessibility.AccessibleTextField");
149 	return aNames;
150 }
151