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 .
23 #include "dlgctrl.hxx"
25 using namespace ::com::sun::star
;
28 static vcl::Window
* ImplGetLabelFor( vcl::Window
* pFrameWindow
, WindowType nMyType
, vcl::Window
* pLabel
, sal_Unicode nAccel
)
30 vcl::Window
* pWindow
= nullptr;
32 if( nMyType
== WindowType::FIXEDTEXT
||
33 nMyType
== WindowType::FIXEDLINE
||
34 nMyType
== WindowType::GROUPBOX
)
36 // #i100833# MT 2010/02: Group box and fixed lines can also label a fixed text.
37 // See tools/options/print for example.
38 bool bThisIsAGroupControl
= (nMyType
== WindowType::GROUPBOX
) || (nMyType
== WindowType::FIXEDLINE
);
39 // get index, form start and form end
40 sal_uInt16 nIndex
=0, nFormStart
=0, nFormEnd
=0;
41 ::ImplFindDlgCtrlWindow( pFrameWindow
,
48 // find the accelerated window
49 pWindow
= ::ImplFindAccelWindow( pFrameWindow
,
58 // find the next control; if that is a fixed text
59 // fixed line or group box, then return NULL
60 while( nIndex
< nFormEnd
)
63 vcl::Window
* pSWindow
= ::ImplGetChildWindow( pFrameWindow
,
67 if( pSWindow
&& isVisibleInLayout(pSWindow
) && ! (pSWindow
->GetStyle() & WB_NOLABEL
) )
69 WindowType nType
= pSWindow
->GetType();
70 if( nType
!= WindowType::FIXEDTEXT
&&
71 nType
!= WindowType::FIXEDLINE
&&
72 nType
!= WindowType::GROUPBOX
)
76 else if( bThisIsAGroupControl
&& ( nType
== WindowType::FIXEDTEXT
) )
91 Window
* Window::getLegacyNonLayoutAccessibleRelationLabelFor() const
93 Window
* pFrameWindow
= ImplGetFrameWindow();
95 WinBits nFrameStyle
= pFrameWindow
->GetStyle();
96 if( ! ( nFrameStyle
& WB_DIALOGCONTROL
)
97 || ( nFrameStyle
& WB_NODIALOGCONTROL
)
101 sal_Unicode nAccel
= getAccel( GetText() );
103 Window
* pWindow
= ImplGetLabelFor( pFrameWindow
, GetType(), const_cast<Window
*>(this), nAccel
);
104 if( ! pWindow
&& mpWindowImpl
->mpRealParent
)
105 pWindow
= ImplGetLabelFor( mpWindowImpl
->mpRealParent
, GetType(), const_cast<Window
*>(this), nAccel
);
109 static Window
* ImplGetLabeledBy( Window
* pFrameWindow
, WindowType nMyType
, Window
* pLabeled
)
111 Window
* pWindow
= nullptr;
112 if ( (nMyType
!= WindowType::GROUPBOX
) && (nMyType
!= WindowType::FIXEDLINE
) )
114 // search for a control that labels this window
115 // a label is considered the last fixed text, fixed line or group box
116 // that comes before this control; with the exception of push buttons
117 // which are labeled only if the fixed text, fixed line or group box
118 // is directly before the control
120 // get form start and form end and index of this control
121 sal_uInt16 nIndex
, nFormStart
, nFormEnd
;
122 Window
* pSWindow
= ::ImplFindDlgCtrlWindow( pFrameWindow
,
127 if( pSWindow
&& nIndex
!= nFormStart
)
129 if( nMyType
== WindowType::PUSHBUTTON
||
130 nMyType
== WindowType::HELPBUTTON
||
131 nMyType
== WindowType::OKBUTTON
||
132 nMyType
== WindowType::CANCELBUTTON
)
134 nFormStart
= nIndex
-1;
136 for( sal_uInt16 nSearchIndex
= nIndex
-1; nSearchIndex
>= nFormStart
; nSearchIndex
-- )
138 sal_uInt16 nFoundIndex
= 0;
139 pSWindow
= ::ImplGetChildWindow( pFrameWindow
,
143 if( pSWindow
&& isVisibleInLayout(pSWindow
) && !(pSWindow
->GetStyle() & WB_NOLABEL
) )
145 WindowType nType
= pSWindow
->GetType();
146 if ( nType
== WindowType::FIXEDTEXT
||
147 nType
== WindowType::FIXEDLINE
||
148 nType
== WindowType::GROUPBOX
)
150 // a fixed text can't be labelled by a fixed text.
151 if ( ( nMyType
!= WindowType::FIXEDTEXT
) || ( nType
!= WindowType::FIXEDTEXT
) )
156 if( nFoundIndex
> nSearchIndex
|| nSearchIndex
== 0 )
164 Window
* Window::getLegacyNonLayoutAccessibleRelationLabeledBy() const
166 Window
* pFrameWindow
= ImplGetFrameWindow();
168 // #i62723#, #104191# checkboxes and radiobuttons are not supposed to have labels
169 if( GetType() == WindowType::CHECKBOX
|| GetType() == WindowType::RADIOBUTTON
)
172 // if( ! ( GetType() == WindowType::FIXEDTEXT ||
173 // GetType() == WindowType::FIXEDLINE ||
174 // GetType() == WindowType::GROUPBOX ) )
175 // #i100833# MT 2010/02: Group box and fixed lines can also label a fixed text.
176 // See tools/options/print for example.
178 Window
* pWindow
= ImplGetLabeledBy( pFrameWindow
, GetType(), const_cast<Window
*>(this) );
179 if( ! pWindow
&& mpWindowImpl
->mpRealParent
)
180 pWindow
= ImplGetLabeledBy( mpWindowImpl
->mpRealParent
, GetType(), const_cast<Window
*>(this) );
185 Window
* Window::getLegacyNonLayoutAccessibleRelationMemberOf() const
187 Window
* pWindow
= nullptr;
188 Window
* pFrameWindow
= GetParent();
191 pFrameWindow
= ImplGetFrameWindow();
193 // if( ! ( GetType() == WindowType::FIXEDTEXT ||
194 if( GetType() != WindowType::FIXEDLINE
&& GetType() != WindowType::GROUPBOX
)
196 // search for a control that makes member of this window
197 // it is considered the last fixed line or group box
198 // that comes before this control; with the exception of push buttons
199 // which are labeled only if the fixed line or group box
200 // is directly before the control
201 // get form start and form end and index of this control
202 sal_uInt16 nIndex
, nFormStart
, nFormEnd
;
203 Window
* pSWindow
= ::ImplFindDlgCtrlWindow( pFrameWindow
,
204 const_cast<Window
*>(this),
208 if( pSWindow
&& nIndex
!= nFormStart
)
210 if( GetType() == WindowType::PUSHBUTTON
||
211 GetType() == WindowType::HELPBUTTON
||
212 GetType() == WindowType::OKBUTTON
||
213 GetType() == WindowType::CANCELBUTTON
)
215 nFormStart
= nIndex
-1;
217 for( sal_uInt16 nSearchIndex
= nIndex
-1; nSearchIndex
>= nFormStart
; nSearchIndex
-- )
219 sal_uInt16 nFoundIndex
= 0;
220 pSWindow
= ::ImplGetChildWindow( pFrameWindow
,
224 if( pSWindow
&& pSWindow
->IsVisible() &&
225 ( pSWindow
->GetType() == WindowType::FIXEDLINE
||
226 pSWindow
->GetType() == WindowType::GROUPBOX
) )
231 if( nFoundIndex
> nSearchIndex
|| nSearchIndex
== 0 )
239 } /* namespace vcl */
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */