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 <tools/debug.hxx>
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>
36 #include <com/sun/star/i18n/XCharacterClassification.hpp>
38 using namespace ::com::sun::star
;
41 static vcl::Window
* ImplGetLabelFor( vcl::Window
* pFrameWindow
, WindowType nMyType
, vcl::Window
* pLabel
, sal_Unicode nAccel
)
43 vcl::Window
* pWindow
= nullptr;
45 if( nMyType
== WINDOW_FIXEDTEXT
||
46 nMyType
== WINDOW_FIXEDLINE
||
47 nMyType
== WINDOW_GROUPBOX
)
49 // #i100833# MT 2010/02: Group box and fixed lines can also label a fixed text.
50 // See tools/options/print for example.
51 bool bThisIsAGroupControl
= (nMyType
== WINDOW_GROUPBOX
) || (nMyType
== WINDOW_FIXEDLINE
);
52 // get index, form start and form end
53 sal_uInt16 nIndex
=0, nFormStart
=0, nFormEnd
=0;
54 ::ImplFindDlgCtrlWindow( pFrameWindow
,
61 // find the accelerated window
62 pWindow
= ::ImplFindAccelWindow( pFrameWindow
,
71 // find the next control; if that is a fixed text
72 // fixed line or group box, then return NULL
73 while( nIndex
< nFormEnd
)
76 vcl::Window
* pSWindow
= ::ImplGetChildWindow( pFrameWindow
,
80 if( pSWindow
&& isVisibleInLayout(pSWindow
) && ! (pSWindow
->GetStyle() & WB_NOLABEL
) )
82 WindowType nType
= pSWindow
->GetType();
83 if( nType
!= WINDOW_FIXEDTEXT
&&
84 nType
!= WINDOW_FIXEDLINE
&&
85 nType
!= WINDOW_GROUPBOX
)
89 else if( bThisIsAGroupControl
&& ( nType
== WINDOW_FIXEDTEXT
) )
104 Window
* Window::getLegacyNonLayoutAccessibleRelationLabelFor() const
106 Window
* pWindow
= nullptr;
107 Window
* pFrameWindow
= ImplGetFrameWindow();
109 WinBits nFrameStyle
= pFrameWindow
->GetStyle();
110 if( ! ( nFrameStyle
& WB_DIALOGCONTROL
)
111 || ( nFrameStyle
& WB_NODIALOGCONTROL
)
115 if ( mpWindowImpl
->mpRealParent
)
116 pWindow
= mpWindowImpl
->mpRealParent
->GetParentLabelFor( this );
121 sal_Unicode nAccel
= getAccel( GetText() );
123 pWindow
= ImplGetLabelFor( pFrameWindow
, GetType(), const_cast<Window
*>(this), nAccel
);
124 if( ! pWindow
&& mpWindowImpl
->mpRealParent
)
125 pWindow
= ImplGetLabelFor( mpWindowImpl
->mpRealParent
, GetType(), const_cast<Window
*>(this), nAccel
);
129 static Window
* ImplGetLabeledBy( Window
* pFrameWindow
, WindowType nMyType
, Window
* pLabeled
)
131 Window
* pWindow
= nullptr;
132 if ( (nMyType
!= WINDOW_GROUPBOX
) && (nMyType
!= WINDOW_FIXEDLINE
) )
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
140 // get form start and form end and index of this control
141 sal_uInt16 nIndex
, nFormStart
, nFormEnd
;
142 Window
* pSWindow
= ::ImplFindDlgCtrlWindow( pFrameWindow
,
147 if( pSWindow
&& nIndex
!= nFormStart
)
149 if( nMyType
== WINDOW_PUSHBUTTON
||
150 nMyType
== WINDOW_HELPBUTTON
||
151 nMyType
== WINDOW_OKBUTTON
||
152 nMyType
== WINDOW_CANCELBUTTON
)
154 nFormStart
= nIndex
-1;
156 for( sal_uInt16 nSearchIndex
= nIndex
-1; nSearchIndex
>= nFormStart
; nSearchIndex
-- )
158 sal_uInt16 nFoundIndex
= 0;
159 pSWindow
= ::ImplGetChildWindow( pFrameWindow
,
163 if( pSWindow
&& isVisibleInLayout(pSWindow
) && !(pSWindow
->GetStyle() & WB_NOLABEL
) )
165 WindowType nType
= pSWindow
->GetType();
166 if ( ( nType
== WINDOW_FIXEDTEXT
||
167 nType
== WINDOW_FIXEDLINE
||
168 nType
== WINDOW_GROUPBOX
) )
170 // a fixed text can't be labeld by a fixed text.
171 if ( ( nMyType
!= WINDOW_FIXEDTEXT
) || ( nType
!= WINDOW_FIXEDTEXT
) )
176 if( nFoundIndex
> nSearchIndex
|| nSearchIndex
== 0 )
184 Window
* Window::getLegacyNonLayoutAccessibleRelationLabeledBy() const
186 Window
* pWindow
= nullptr;
187 Window
* pFrameWindow
= ImplGetFrameWindow();
189 if ( mpWindowImpl
->mpRealParent
)
191 pWindow
= mpWindowImpl
->mpRealParent
->GetParentLabeledBy( this );
197 // #i62723#, #104191# checkboxes and radiobuttons are not supposed to have labels
198 if( GetType() == WINDOW_CHECKBOX
|| GetType() == WINDOW_RADIOBUTTON
)
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.
207 pWindow
= ImplGetLabeledBy( pFrameWindow
, GetType(), const_cast<Window
*>(this) );
208 if( ! pWindow
&& mpWindowImpl
->mpRealParent
)
209 pWindow
= ImplGetLabeledBy( mpWindowImpl
->mpRealParent
, GetType(), const_cast<Window
*>(this) );
214 Window
* Window::getLegacyNonLayoutAccessibleRelationMemberOf() const
216 Window
* pWindow
= nullptr;
217 Window
* pFrameWindow
= GetParent();
220 pFrameWindow
= ImplGetFrameWindow();
222 // if( ! ( GetType() == WINDOW_FIXEDTEXT ||
223 if( !( GetType() == WINDOW_FIXEDLINE
||
224 GetType() == WINDOW_GROUPBOX
) )
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),
238 if( pSWindow
&& nIndex
!= nFormStart
)
240 if( GetType() == WINDOW_PUSHBUTTON
||
241 GetType() == WINDOW_HELPBUTTON
||
242 GetType() == WINDOW_OKBUTTON
||
243 GetType() == WINDOW_CANCELBUTTON
)
245 nFormStart
= nIndex
-1;
247 for( sal_uInt16 nSearchIndex
= nIndex
-1; nSearchIndex
>= nFormStart
; nSearchIndex
-- )
249 sal_uInt16 nFoundIndex
= 0;
250 pSWindow
= ::ImplGetChildWindow( pFrameWindow
,
254 if( pSWindow
&& pSWindow
->IsVisible() &&
255 ( pSWindow
->GetType() == WINDOW_FIXEDLINE
||
256 pSWindow
->GetType() == WINDOW_GROUPBOX
) )
261 if( nFoundIndex
> nSearchIndex
|| nSearchIndex
== 0 )
269 } /* namespace vcl */
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */