Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <tools/debug.hxx>
21 :
22 : #include <svdata.hxx>
23 :
24 : #include <dlgctrl.hxx>
25 : #include <vcl/event.hxx>
26 : #include <vcl/fixed.hxx>
27 : #include <vcl/layout.hxx>
28 : #include <vcl/svapp.hxx>
29 : #include <vcl/tabpage.hxx>
30 : #include <vcl/tabctrl.hxx>
31 : #include <vcl/tabdlg.hxx>
32 : #include <vcl/button.hxx>
33 : #include <vcl/settings.hxx>
34 : #include <vcl/unohelp.hxx>
35 :
36 : #include <com/sun/star/i18n/XCharacterClassification.hpp>
37 :
38 : using namespace ::com::sun::star;
39 :
40 :
41 2 : static vcl::Window* ImplGetLabelFor( vcl::Window* pFrameWindow, WindowType nMyType, vcl::Window* pLabel, sal_Unicode nAccel )
42 : {
43 2 : vcl::Window* pWindow = NULL;
44 :
45 2 : if( nMyType == WINDOW_FIXEDTEXT ||
46 0 : nMyType == WINDOW_FIXEDLINE ||
47 : nMyType == WINDOW_GROUPBOX )
48 : {
49 : // #i100833# MT 2010/02: Group box and fixed lines can also label a fixed text.
50 : // See tools/options/print for example.
51 2 : bool bThisIsAGroupControl = (nMyType == WINDOW_GROUPBOX) || (nMyType == WINDOW_FIXEDLINE);
52 : // get index, form start and form end
53 2 : sal_uInt16 nIndex=0, nFormStart=0, nFormEnd=0;
54 : ::ImplFindDlgCtrlWindow( pFrameWindow,
55 : pLabel,
56 : nIndex,
57 : nFormStart,
58 2 : nFormEnd );
59 2 : if( nAccel )
60 : {
61 : // find the accelerated window
62 : pWindow = ::ImplFindAccelWindow( pFrameWindow,
63 : nIndex,
64 : nAccel,
65 : nFormStart,
66 : nFormEnd,
67 0 : false );
68 : }
69 : else
70 : {
71 : // find the next control; if that is a fixed text
72 : // fixed line or group box, then return NULL
73 4 : while( nIndex < nFormEnd )
74 : {
75 0 : nIndex++;
76 : vcl::Window* pSWindow = ::ImplGetChildWindow( pFrameWindow,
77 : nIndex,
78 : nIndex,
79 0 : false );
80 0 : if( pSWindow && isVisibleInLayout(pSWindow) && ! (pSWindow->GetStyle() & WB_NOLABEL) )
81 : {
82 0 : WindowType nType = pSWindow->GetType();
83 0 : if( nType != WINDOW_FIXEDTEXT &&
84 0 : nType != WINDOW_FIXEDLINE &&
85 : nType != WINDOW_GROUPBOX )
86 : {
87 0 : pWindow = pSWindow;
88 : }
89 0 : else if( bThisIsAGroupControl && ( nType == WINDOW_FIXEDTEXT ) )
90 : {
91 0 : pWindow = pSWindow;
92 : }
93 0 : break;
94 : }
95 : }
96 : }
97 : }
98 :
99 2 : return pWindow;
100 : }
101 :
102 : namespace vcl {
103 :
104 11059 : Window* Window::getLegacyNonLayoutAccessibleRelationLabelFor() const
105 : {
106 11059 : Window* pWindow = NULL;
107 11059 : Window* pFrameWindow = ImplGetFrameWindow();
108 :
109 11059 : WinBits nFrameStyle = pFrameWindow->GetStyle();
110 11059 : if( ! ( nFrameStyle & WB_DIALOGCONTROL )
111 1 : || ( nFrameStyle & WB_NODIALOGCONTROL )
112 : )
113 11058 : return NULL;
114 :
115 1 : if ( mpWindowImpl->mpRealParent )
116 1 : pWindow = mpWindowImpl->mpRealParent->GetParentLabelFor( this );
117 :
118 1 : if( pWindow )
119 0 : return pWindow;
120 :
121 1 : sal_Unicode nAccel = getAccel( GetText() );
122 :
123 1 : pWindow = ImplGetLabelFor( pFrameWindow, GetType(), const_cast<Window*>(this), nAccel );
124 1 : if( ! pWindow && mpWindowImpl->mpRealParent )
125 1 : pWindow = ImplGetLabelFor( mpWindowImpl->mpRealParent, GetType(), const_cast<Window*>(this), nAccel );
126 1 : return pWindow;
127 : }
128 :
129 5394 : static Window* ImplGetLabeledBy( Window* pFrameWindow, WindowType nMyType, Window* pLabeled )
130 : {
131 5394 : Window* pWindow = NULL;
132 5394 : if ( (nMyType != WINDOW_GROUPBOX) && (nMyType != WINDOW_FIXEDLINE) )
133 : {
134 : // search for a control that labels this window
135 : // a label is considered the last fixed text, fixed line or group box
136 : // that comes before this control; with the exception of push buttons
137 : // which are labeled only if the fixed text, fixed line or group box
138 : // is directly before the control
139 :
140 : // get form start and form end and index of this control
141 : sal_uInt16 nIndex, nFormStart, nFormEnd;
142 : Window* pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow,
143 : pLabeled,
144 : nIndex,
145 : nFormStart,
146 5394 : nFormEnd );
147 5394 : if( pSWindow && nIndex != nFormStart )
148 : {
149 461 : if( nMyType == WINDOW_PUSHBUTTON ||
150 461 : nMyType == WINDOW_HELPBUTTON ||
151 461 : nMyType == WINDOW_OKBUTTON ||
152 : nMyType == WINDOW_CANCELBUTTON )
153 : {
154 0 : nFormStart = nIndex-1;
155 : }
156 940 : for( sal_uInt16 nSearchIndex = nIndex-1; nSearchIndex >= nFormStart; nSearchIndex-- )
157 : {
158 470 : sal_uInt16 nFoundIndex = 0;
159 : pSWindow = ::ImplGetChildWindow( pFrameWindow,
160 : nSearchIndex,
161 : nFoundIndex,
162 470 : false );
163 470 : if( pSWindow && isVisibleInLayout(pSWindow) && !(pSWindow->GetStyle() & WB_NOLABEL) )
164 : {
165 470 : WindowType nType = pSWindow->GetType();
166 470 : if ( ( nType == WINDOW_FIXEDTEXT ||
167 470 : nType == WINDOW_FIXEDLINE ||
168 : nType == WINDOW_GROUPBOX ) )
169 : {
170 : // a fixed text can't be labeld by a fixed text.
171 0 : if ( ( nMyType != WINDOW_FIXEDTEXT ) || ( nType != WINDOW_FIXEDTEXT ) )
172 0 : pWindow = pSWindow;
173 461 : break;
174 : }
175 : }
176 470 : if( nFoundIndex > nSearchIndex || nSearchIndex == 0 )
177 : break;
178 : }
179 : }
180 : }
181 5394 : return pWindow;
182 : }
183 :
184 2697 : Window* Window::getLegacyNonLayoutAccessibleRelationLabeledBy() const
185 : {
186 2697 : Window* pWindow = NULL;
187 2697 : Window* pFrameWindow = ImplGetFrameWindow();
188 :
189 2697 : if ( mpWindowImpl->mpRealParent )
190 : {
191 2697 : pWindow = mpWindowImpl->mpRealParent->GetParentLabeledBy( this );
192 :
193 2697 : if( pWindow )
194 0 : return pWindow;
195 : }
196 :
197 : // #i62723#, #104191# checkboxes and radiobuttons are not supposed to have labels
198 2697 : if( GetType() == WINDOW_CHECKBOX || GetType() == WINDOW_RADIOBUTTON )
199 0 : return NULL;
200 :
201 : // if( ! ( GetType() == WINDOW_FIXEDTEXT ||
202 : // GetType() == WINDOW_FIXEDLINE ||
203 : // GetType() == WINDOW_GROUPBOX ) )
204 : // #i100833# MT 2010/02: Group box and fixed lines can also label a fixed text.
205 : // See tools/options/print for example.
206 :
207 2697 : pWindow = ImplGetLabeledBy( pFrameWindow, GetType(), const_cast<Window*>(this) );
208 2697 : if( ! pWindow && mpWindowImpl->mpRealParent )
209 2697 : pWindow = ImplGetLabeledBy( mpWindowImpl->mpRealParent, GetType(), const_cast<Window*>(this) );
210 :
211 2697 : return pWindow;
212 : }
213 :
214 5 : Window* Window::getLegacyNonLayoutAccessibleRelationMemberOf() const
215 : {
216 5 : Window* pWindow = NULL;
217 5 : Window* pFrameWindow = GetParent();
218 5 : if ( !pFrameWindow )
219 : {
220 0 : pFrameWindow = ImplGetFrameWindow();
221 : }
222 : // if( ! ( GetType() == WINDOW_FIXEDTEXT ||
223 10 : if( !( GetType() == WINDOW_FIXEDLINE ||
224 5 : GetType() == WINDOW_GROUPBOX ) )
225 : {
226 : // search for a control that makes member of this window
227 : // it is considered the last fixed line or group box
228 : // that comes before this control; with the exception of push buttons
229 : // which are labeled only if the fixed line or group box
230 : // is directly before the control
231 : // get form start and form end and index of this control
232 : sal_uInt16 nIndex, nFormStart, nFormEnd;
233 : Window* pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow,
234 : const_cast<Window*>(this),
235 : nIndex,
236 : nFormStart,
237 5 : nFormEnd );
238 5 : if( pSWindow && nIndex != nFormStart )
239 : {
240 3 : if( GetType() == WINDOW_PUSHBUTTON ||
241 2 : GetType() == WINDOW_HELPBUTTON ||
242 3 : GetType() == WINDOW_OKBUTTON ||
243 1 : GetType() == WINDOW_CANCELBUTTON )
244 : {
245 0 : nFormStart = nIndex-1;
246 : }
247 4 : for( sal_uInt16 nSearchIndex = nIndex-1; nSearchIndex >= nFormStart; nSearchIndex-- )
248 : {
249 2 : sal_uInt16 nFoundIndex = 0;
250 : pSWindow = ::ImplGetChildWindow( pFrameWindow,
251 : nSearchIndex,
252 : nFoundIndex,
253 2 : false );
254 4 : if( pSWindow && pSWindow->IsVisible() &&
255 4 : ( pSWindow->GetType() == WINDOW_FIXEDLINE ||
256 2 : pSWindow->GetType() == WINDOW_GROUPBOX ) )
257 : {
258 0 : pWindow = pSWindow;
259 1 : break;
260 : }
261 2 : if( nFoundIndex > nSearchIndex || nSearchIndex == 0 )
262 : break;
263 : }
264 : }
265 : }
266 5 : return pWindow;
267 : }
268 :
269 801 : } /* namespace vcl */
270 :
271 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|