Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <toolkit/awt/vclxcontainer.hxx>
30 : : #include <toolkit/helper/macros.hxx>
31 : : #include <toolkit/helper/vclunohelper.hxx>
32 : : #include <cppuhelper/typeprovider.hxx>
33 : : #include <rtl/memory.h>
34 : : #include <rtl/uuid.h>
35 : :
36 : : #include <vcl/svapp.hxx>
37 : : #include <vcl/window.hxx>
38 : : #include <tools/debug.hxx>
39 : :
40 : : // ----------------------------------------------------
41 : : // class VCLXContainer
42 : : // ----------------------------------------------------
43 : :
44 : 0 : void VCLXContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
45 : : {
46 : 0 : VCLXWindow::ImplGetPropertyIds( rIds );
47 : 0 : }
48 : :
49 [ + - ]: 8524 : VCLXContainer::VCLXContainer()
50 : : {
51 : 8524 : }
52 : :
53 [ + - ]: 8113 : VCLXContainer::~VCLXContainer()
54 : : {
55 [ - + ]: 10813 : }
56 : :
57 : : // ::com::sun::star::uno::XInterface
58 : 310290 : ::com::sun::star::uno::Any VCLXContainer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
59 : : {
60 : : ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
61 : : (static_cast< ::com::sun::star::awt::XVclContainer* >(this)),
62 [ + - ]: 310290 : (static_cast< ::com::sun::star::awt::XVclContainerPeer* >(this)) );
63 [ + + ][ + - ]: 310290 : return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
64 : : }
65 : :
66 : : // ::com::sun::star::lang::XTypeProvider
67 [ # # ][ # # ]: 0 : IMPL_XTYPEPROVIDER_START( VCLXContainer )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
68 [ # # ]: 0 : getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainer>* ) NULL ),
69 [ # # ]: 0 : getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerPeer>* ) NULL ),
70 : : VCLXWindow::getTypes()
71 [ # # ][ # # ]: 0 : IMPL_XTYPEPROVIDER_END
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
72 : :
73 : :
74 : : // ::com::sun::star::awt::XVclContainer
75 : 0 : void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
76 : : {
77 [ # # ]: 0 : SolarMutexGuard aGuard;
78 : :
79 [ # # ][ # # ]: 0 : GetContainerListeners().addInterface( rxListener );
[ # # ]
80 : 0 : }
81 : :
82 : 0 : void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
83 : : {
84 [ # # ]: 0 : SolarMutexGuard aGuard;
85 : :
86 [ # # ][ # # ]: 0 : GetContainerListeners().removeInterface( rxListener );
[ # # ]
87 : 0 : }
88 : :
89 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException)
90 : : {
91 [ # # ]: 0 : SolarMutexGuard aGuard;
92 : :
93 : : // Request container interface from all children
94 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > aSeq;
95 : 0 : Window* pWindow = GetWindow();
96 [ # # ]: 0 : if ( pWindow )
97 : : {
98 [ # # ]: 0 : sal_uInt16 nChildren = pWindow->GetChildCount();
99 [ # # ]: 0 : if ( nChildren )
100 : : {
101 [ # # ][ # # ]: 0 : aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >( nChildren );
[ # # ]
102 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pChildRefs = aSeq.getArray();
103 [ # # ]: 0 : for ( sal_uInt16 n = 0; n < nChildren; n++ )
104 : : {
105 [ # # ]: 0 : Window* pChild = pWindow->GetChild( n );
106 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xWP = pChild->GetComponentInterface( sal_True );
107 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xW( xWP, ::com::sun::star::uno::UNO_QUERY );
108 [ # # ]: 0 : pChildRefs[n] = xW;
109 : 0 : }
110 : : }
111 : : }
112 [ # # ]: 0 : return aSeq;
113 : : }
114 : :
115 : :
116 : : // ::com::sun::star::awt::XVclContainerPeer
117 : 2 : void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException)
118 : : {
119 [ + - ]: 2 : SolarMutexGuard aGuard;
120 : :
121 : 2 : Window* pWindow = GetWindow();
122 [ + - ]: 2 : if ( pWindow )
123 : : {
124 [ + - ]: 2 : WinBits nStyle = pWindow->GetStyle();
125 [ + - ]: 2 : if ( bEnable )
126 : 2 : nStyle |= WB_DIALOGCONTROL;
127 : : else
128 : 0 : nStyle &= (~WB_DIALOGCONTROL);
129 [ + - ]: 2 : pWindow->SetStyle( nStyle );
130 [ + - ]: 2 : }
131 : 2 : }
132 : :
133 : 42 : void VCLXContainer::setTabOrder( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Tabs, sal_Bool bGroupControl ) throw(::com::sun::star::uno::RuntimeException)
134 : : {
135 [ + - ]: 42 : SolarMutexGuard aGuard;
136 : :
137 : 42 : sal_uInt32 nCount = Components.getLength();
138 : : DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" );
139 : 42 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
140 : 42 : const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray();
141 : :
142 : 42 : Window* pPrevWin = NULL;
143 [ + + ]: 88 : for ( sal_uInt32 n = 0; n < nCount; n++ )
144 : : {
145 : : // ::com::sun::star::style::TabStop
146 [ + - ]: 46 : Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
147 : : // May be NULL if a ::com::sun::star::uno::Sequence is originated from TabController and is missing a peer!
148 [ + - ]: 46 : if ( pWin )
149 : : {
150 : : // Order windows before manipulating their style, because elements such as the
151 : : // RadioButton considers the PREV-window in StateChanged.
152 [ + + ]: 46 : if ( pPrevWin )
153 [ + - ]: 22 : pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND );
154 : :
155 [ + - ]: 46 : WinBits nStyle = pWin->GetStyle();
156 : 46 : nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP);
157 [ - + ]: 46 : if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN )
158 : : {
159 : 0 : sal_Bool bTab = false;
160 : 0 : pTabs[n] >>= bTab;
161 [ # # ]: 0 : nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP );
162 : : }
163 [ + - ]: 46 : pWin->SetStyle( nStyle );
164 : :
165 [ - + ]: 46 : if ( bGroupControl )
166 : : {
167 [ # # ]: 0 : if ( n == 0 )
168 [ # # ]: 0 : pWin->SetDialogControlStart( sal_True );
169 : : else
170 [ # # ]: 0 : pWin->SetDialogControlStart( sal_False );
171 : : }
172 : :
173 : 46 : pPrevWin = pWin;
174 : : }
175 [ + - ]: 42 : }
176 : 42 : }
177 : :
178 : 6 : void VCLXContainer::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components ) throw(::com::sun::star::uno::RuntimeException)
179 : : {
180 [ + - ]: 6 : SolarMutexGuard aGuard;
181 : :
182 : 6 : sal_uInt32 nCount = Components.getLength();
183 : 6 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
184 : :
185 : 6 : Window* pPrevWin = NULL;
186 : 6 : Window* pPrevRadio = NULL;
187 [ + + ]: 22 : for ( sal_uInt32 n = 0; n < nCount; n++ )
188 : : {
189 [ + - ]: 16 : Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
190 [ + - ]: 16 : if ( pWin )
191 : : {
192 : 16 : Window* pSortBehind = pPrevWin;
193 : : // #57096# Sort all radios consecutively
194 : 16 : sal_Bool bNewPrevWin = sal_True;
195 [ + - ][ - + ]: 16 : if ( pWin->GetType() == WINDOW_RADIOBUTTON )
196 : : {
197 [ # # ]: 0 : if ( pPrevRadio )
198 : : {
199 : : // This RadioButton was sorted before PrevWin
200 : 0 : bNewPrevWin = ( pPrevWin == pPrevRadio );
201 : 0 : pSortBehind = pPrevRadio;
202 : : }
203 : 0 : pPrevRadio = pWin;
204 : : }
205 : :
206 : : // Z-Order
207 [ + + ]: 16 : if ( pSortBehind )
208 [ + - ]: 12 : pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND );
209 : :
210 [ + - ]: 16 : WinBits nStyle = pWin->GetStyle();
211 [ + + ]: 16 : if ( n == 0 )
212 : 4 : nStyle |= WB_GROUP;
213 : : else
214 : 12 : nStyle &= (~WB_GROUP);
215 [ + - ]: 16 : pWin->SetStyle( nStyle );
216 : :
217 : : // Add WB_GROUP after the last group
218 [ + + ]: 16 : if ( n == ( nCount - 1 ) )
219 : : {
220 [ + - ]: 4 : Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT );
221 [ - + ]: 4 : if ( pBehindLast )
222 : : {
223 [ # # ]: 0 : WinBits nLastStyle = pBehindLast->GetStyle();
224 : 0 : nLastStyle |= WB_GROUP;
225 [ # # ]: 0 : pBehindLast->SetStyle( nLastStyle );
226 : : }
227 : : }
228 : :
229 [ + - ]: 16 : if ( bNewPrevWin )
230 : 16 : pPrevWin = pWin;
231 : : }
232 [ + - ]: 6 : }
233 : 6 : }
234 : :
235 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|