LibreOffice Module toolkit (master) 1
vclxcontainer.cxx
Go to the documentation of this file.
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 <awt/vclxcontainer.hxx>
23
24#include <vcl/svapp.hxx>
25#include <vcl/window.hxx>
26#include <vcl/tabpage.hxx>
27#include <tools/debug.hxx>
29#include <helper/property.hxx>
30
31void VCLXContainer::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
32{
34}
35
37{
38}
39
41{
42}
43
44
45// css::awt::XVclContainer
46void VCLXContainer::addVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener )
47{
48 SolarMutexGuard aGuard;
49
50 if (!IsDisposed())
51 GetContainerListeners().addInterface( rxListener );
52}
53
54void VCLXContainer::removeVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener )
55{
56 SolarMutexGuard aGuard;
57
58 if (!IsDisposed())
59 GetContainerListeners().removeInterface( rxListener );
60}
61
62css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > VCLXContainer::getWindows( )
63{
64 SolarMutexGuard aGuard;
65
66 // Request container interface from all children
67 css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > aSeq;
68 VclPtr<vcl::Window> pWindow = GetWindow();
69 if ( pWindow )
70 {
71 sal_uInt16 nChildren = pWindow->GetChildCount();
72 if ( nChildren )
73 {
74 aSeq = css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >( nChildren );
75 css::uno::Reference< css::awt::XWindow > * pChildRefs = aSeq.getArray();
76 for ( sal_uInt16 n = 0; n < nChildren; n++ )
77 {
78 vcl::Window* pChild = pWindow->GetChild( n );
79 css::uno::Reference< css::awt::XWindowPeer > xWP = pChild->GetComponentInterface();
80 css::uno::Reference< css::awt::XWindow > xW( xWP, css::uno::UNO_QUERY );
81 pChildRefs[n] = xW;
82 }
83 }
84 }
85 return aSeq;
86}
87
88
89// css::awt::XVclContainerPeer
91{
92 SolarMutexGuard aGuard;
93
94 VclPtr<vcl::Window> pWindow = GetWindow();
95 if ( pWindow )
96 {
97 WinBits nStyle = pWindow->GetStyle();
98 if ( bEnable )
99 nStyle |= WB_DIALOGCONTROL;
100 else
101 nStyle &= (~WB_DIALOGCONTROL);
102 pWindow->SetStyle( nStyle );
103 }
104}
105
106void VCLXContainer::setTabOrder( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components, const css::uno::Sequence< css::uno::Any >& Tabs, sal_Bool bGroupControl )
107{
108 SolarMutexGuard aGuard;
109
110 sal_uInt32 nCount = Components.getLength();
111 DBG_ASSERT( nCount == static_cast<sal_uInt32>(Tabs.getLength()), "setTabOrder: TabCount != ComponentCount" );
112 const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray();
113 const css::uno::Any* pTabs = Tabs.getConstArray();
114
115 vcl::Window* pPrevWin = nullptr;
116 for ( sal_uInt32 n = 0; n < nCount; n++ )
117 {
118 // css::style::TabStop
120 // May be NULL if a css::uno::Sequence is originated from TabController and is missing a peer!
121 if ( pWin )
122 {
123 // Order windows before manipulating their style, because elements such as the
124 // RadioButton considers the PREV-window in StateChanged.
125 if ( pPrevWin )
126 pWin->SetZOrder( pPrevWin, ZOrderFlags::Behind );
127
128 WinBits nStyle = pWin->GetStyle();
129 nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP);
130 if ( pTabs[n].getValueType().getTypeClass() == css::uno::TypeClass_BOOLEAN )
131 {
132 bool bTab = false;
133 pTabs[n] >>= bTab;
134 nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP );
135 }
136 pWin->SetStyle( nStyle );
137
138 if ( bGroupControl )
139 {
140 if ( n == 0 )
141 pWin->SetDialogControlStart( true );
142 else
143 pWin->SetDialogControlStart( false );
144 }
145
146 pPrevWin = pWin;
147 }
148 }
149}
150
151void VCLXContainer::setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components )
152{
153 SolarMutexGuard aGuard;
154
155 sal_uInt32 nCount = Components.getLength();
156 const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray();
157
158 vcl::Window* pPrevWin = nullptr;
159 vcl::Window* pPrevRadio = nullptr;
160 for ( sal_uInt32 n = 0; n < nCount; n++ )
161 {
163 if ( pWin )
164 {
165 vcl::Window* pSortBehind = pPrevWin;
166 // #57096# Sort all radios consecutively
167 bool bNewPrevWin = true;
168 if ( pWin->GetType() == WindowType::RADIOBUTTON )
169 {
170 if ( pPrevRadio )
171 {
172 // This RadioButton was sorted before PrevWin
173 bNewPrevWin = ( pPrevWin == pPrevRadio );
174 pSortBehind = pPrevRadio;
175 }
176 pPrevRadio = pWin;
177 }
178
179 // Z-Order
180 if ( pSortBehind )
181 pWin->SetZOrder( pSortBehind, ZOrderFlags::Behind );
182
183 WinBits nStyle = pWin->GetStyle();
184 if ( n == 0 )
185 nStyle |= WB_GROUP;
186 else
187 nStyle &= (~WB_GROUP);
188 pWin->SetStyle( nStyle );
189
190 // Add WB_GROUP after the last group
191 if ( n == ( nCount - 1 ) )
192 {
193 vcl::Window* pBehindLast = pWin->GetWindow( GetWindowType::Next );
194 if ( pBehindLast )
195 {
196 WinBits nLastStyle = pBehindLast->GetStyle();
197 nLastStyle |= WB_GROUP;
198 pBehindLast->SetStyle( nLastStyle );
199 }
200 }
201
202 if ( bNewPrevWin )
203 pPrevWin = pWin;
204 }
205 }
206}
207
209 const OUString& PropertyName,
210 const css::uno::Any& Value )
211{
212 SolarMutexGuard aGuard;
213
214 sal_uInt16 nPropType = GetPropertyId( PropertyName );
215 switch ( nPropType )
216 {
221 {
222 sal_Int32 nVal =0;
223 Value >>= nVal;
224 Size aSize( nVal, nVal );
225 VclPtr<vcl::Window> pWindow = GetWindow();
226 MapMode aMode( MapUnit::MapAppFont );
227 toolkit::ScrollableDialog* pScrollable = dynamic_cast< toolkit::ScrollableDialog* >( pWindow.get() );
228 TabPage* pScrollTabPage = dynamic_cast< TabPage* >( pWindow.get() );
229 if ( pWindow && (pScrollable || pScrollTabPage) )
230 {
231 aSize = pWindow->LogicToPixel( aSize, aMode );
232 switch ( nPropType )
233 {
235 pScrollable ? pScrollable->SetScrollHeight( aSize.Height() ) : (void)0;
236 pScrollTabPage ? pScrollTabPage->SetScrollHeight( aSize.Height() ) : (void)0;
237 break;
239 pScrollable ? pScrollable->SetScrollWidth( aSize.Width() ) : (void)0;
240 pScrollTabPage ? pScrollTabPage->SetScrollWidth( aSize.Width() ) : (void)0;
241 break;
243 pScrollable ? pScrollable->SetScrollTop( aSize.Height() ) : (void)0;
244 pScrollTabPage ? pScrollTabPage->SetScrollTop( aSize.Height() ) : (void)0;
245 break;
247 pScrollable ? pScrollable->SetScrollLeft( aSize.Width() ) : (void)0;
248 pScrollTabPage ? pScrollTabPage->SetScrollLeft( aSize.Width() ) : (void)0;
249 break;
250 default:
251 break;
252 }
253 break;
254 }
255 break;
256 }
257
258 default:
259 {
260 VCLXWindow::setProperty( PropertyName, Value );
261 }
262 }
263}
264/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetScrollLeft(tools::Long nLeft)
void SetScrollTop(tools::Long Top)
void SetScrollWidth(tools::Long nWidth)
void SetScrollHeight(tools::Long nHeight)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
void SAL_CALL addVclContainerListener(const css::uno::Reference< css::awt::XVclContainerListener > &l) override
void SAL_CALL enableDialogControl(sal_Bool bEnable) override
void SAL_CALL setTabOrder(const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > &WindowOrder, const css::uno::Sequence< css::uno::Any > &Tabs, sal_Bool GroupControl) override
void SAL_CALL setProperty(const OUString &PropertyName, const css::uno::Any &Value) override
static void ImplGetPropertyIds(std::vector< sal_uInt16 > &aIds)
virtual ~VCLXContainer() override
void SAL_CALL setGroup(const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > &Windows) override
void SAL_CALL removeVclContainerListener(const css::uno::Reference< css::awt::XVclContainerListener > &l) override
css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > SAL_CALL getWindows() override
static void ImplGetPropertyIds(std::vector< sal_uInt16 > &aIds, bool bWithDefaults=false)
void SAL_CALL setProperty(const OUString &PropertyName, const css::uno::Any &Value) override
reference_type * get() const
void SetScrollLeft(tools::Long nLeft)
void SetScrollWidth(tools::Long nWidth)
void SetScrollTop(tools::Long Top)
void SetScrollHeight(tools::Long nHeight)
void SetStyle(WinBits nStyle)
WinBits GetStyle() const
virtual css::uno::Reference< css::awt::XVclWindowPeer > GetComponentInterface(bool bCreate=true)
int nCount
#define DBG_ASSERT(sCon, aError)
sal_Int64 n
Sequence< sal_Int8 > aSeq
Value
sal_uInt16 GetPropertyId(const OUString &rPropertyName)
Definition: property.cxx:278
#define BASEPROPERTY_SCROLLWIDTH
Definition: property.hxx:197
#define BASEPROPERTY_SCROLLLEFT
Definition: property.hxx:200
#define BASEPROPERTY_SCROLLHEIGHT
Definition: property.hxx:198
#define BASEPROPERTY_SCROLLTOP
Definition: property.hxx:199
unsigned char sal_Bool
std::vector< uno::Reference< sheet::XSpreadsheetDocument > > Components
sal_Int64 WinBits
WinBits const WB_DIALOGCONTROL
WinBits const WB_NOTABSTOP
WinBits const WB_GROUP
WinBits const WB_TABSTOP