1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
31 #include <toolkit/awt/vclxcontainer.hxx>
32 #include <toolkit/helper/macros.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <cppuhelper/typeprovider.hxx>
35 #include <rtl/memory.h>
38 #include <vcl/svapp.hxx>
39 #include <vcl/window.hxx>
40 #include <tools/debug.hxx>
42 // ----------------------------------------------------
43 // class VCLXContainer
44 // ----------------------------------------------------
46 void VCLXContainer::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
48 VCLXWindow::ImplGetPropertyIds( rIds
);
51 VCLXContainer::VCLXContainer()
55 VCLXContainer::~VCLXContainer()
59 // ::com::sun::star::uno::XInterface
60 ::com::sun::star::uno::Any
VCLXContainer::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
62 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
63 (static_cast< ::com::sun::star::awt::XVclContainer
* >(this)),
64 (static_cast< ::com::sun::star::awt::XVclContainerPeer
* >(this)) );
65 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
68 // ::com::sun::star::lang::XTypeProvider
69 IMPL_XTYPEPROVIDER_START( VCLXContainer
)
70 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainer
>* ) NULL
),
71 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainerPeer
>* ) NULL
),
72 VCLXWindow::getTypes()
73 IMPL_XTYPEPROVIDER_END
76 // ::com::sun::star::awt::XVclContainer
77 void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainerListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
)
79 SolarMutexGuard aGuard
;
81 GetContainerListeners().addInterface( rxListener
);
84 void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XVclContainerListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
)
86 SolarMutexGuard aGuard
;
88 GetContainerListeners().removeInterface( rxListener
);
91 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> > VCLXContainer::getWindows( ) throw(::com::sun::star::uno::RuntimeException
)
93 SolarMutexGuard aGuard
;
95 // Bei allen Children das Container-Interface abfragen...
96 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> > aSeq
;
97 Window
* pWindow
= GetWindow();
100 sal_uInt16 nChildren
= pWindow
->GetChildCount();
103 aSeq
= ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> >( nChildren
);
104 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> * pChildRefs
= aSeq
.getArray();
105 for ( sal_uInt16 n
= 0; n
< nChildren
; n
++ )
107 Window
* pChild
= pWindow
->GetChild( n
);
108 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> xWP
= pChild
->GetComponentInterface( sal_True
);
109 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xW( xWP
, ::com::sun::star::uno::UNO_QUERY
);
118 // ::com::sun::star::awt::XVclContainerPeer
119 void VCLXContainer::enableDialogControl( sal_Bool bEnable
) throw(::com::sun::star::uno::RuntimeException
)
121 SolarMutexGuard aGuard
;
123 Window
* pWindow
= GetWindow();
126 WinBits nStyle
= pWindow
->GetStyle();
128 nStyle
|= WB_DIALOGCONTROL
;
130 nStyle
&= (~WB_DIALOGCONTROL
);
131 pWindow
->SetStyle( nStyle
);
135 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
)
137 SolarMutexGuard aGuard
;
139 sal_uInt32 nCount
= Components
.getLength();
140 DBG_ASSERT( nCount
== (sal_uInt32
)Tabs
.getLength(), "setTabOrder: TabCount != ComponentCount" );
141 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> * pComps
= Components
.getConstArray();
142 const ::com::sun::star::uno::Any
* pTabs
= Tabs
.getConstArray();
144 Window
* pPrevWin
= NULL
;
145 for ( sal_uInt32 n
= 0; n
< nCount
; n
++ )
147 // ::com::sun::star::style::TabStop
148 Window
* pWin
= VCLUnoHelper::GetWindow( pComps
[n
] );
149 // NULL kann vorkommen, wenn die ::com::sun::star::uno::Sequence vom TabController kommt und eine Peer fehlt!
152 // Reihenfolge der Fenster vor der Manipulation des Styles,
153 // weil z.B. der RadioButton in StateChanged das PREV-Window beruecksichtigt.
155 pWin
->SetZOrder( pPrevWin
, WINDOW_ZORDER_BEHIND
);
157 WinBits nStyle
= pWin
->GetStyle();
158 nStyle
&= ~(WB_TABSTOP
|WB_NOTABSTOP
|WB_GROUP
);
159 if ( pTabs
[n
].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN
)
161 sal_Bool bTab
= false;
163 nStyle
|= ( bTab
? WB_TABSTOP
: WB_NOTABSTOP
);
165 pWin
->SetStyle( nStyle
);
170 pWin
->SetDialogControlStart( sal_True
);
172 pWin
->SetDialogControlStart( sal_False
);
180 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
)
182 SolarMutexGuard aGuard
;
184 sal_uInt32 nCount
= Components
.getLength();
185 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> * pComps
= Components
.getConstArray();
187 Window
* pPrevWin
= NULL
;
188 Window
* pPrevRadio
= NULL
;
189 for ( sal_uInt32 n
= 0; n
< nCount
; n
++ )
191 Window
* pWin
= VCLUnoHelper::GetWindow( pComps
[n
] );
194 Window
* pSortBehind
= pPrevWin
;
195 // #57096# Alle Radios hintereinander sortieren...
196 sal_Bool bNewPrevWin
= sal_True
;
197 if ( pWin
->GetType() == WINDOW_RADIOBUTTON
)
201 bNewPrevWin
= ( pPrevWin
== pPrevRadio
); // Radio-Button wurde vor das PreWin sortiert....
202 pSortBehind
= pPrevRadio
;
209 pWin
->SetZOrder( pSortBehind
, WINDOW_ZORDER_BEHIND
);
211 WinBits nStyle
= pWin
->GetStyle();
215 nStyle
&= (~WB_GROUP
);
216 pWin
->SetStyle( nStyle
);
218 // Ein WB_GROUP hinter die Gruppe, falls keine Gruppe mehr folgt.
219 if ( n
== ( nCount
- 1 ) )
221 Window
* pBehindLast
= pWin
->GetWindow( WINDOW_NEXT
);
224 WinBits nLastStyle
= pBehindLast
->GetStyle();
225 nLastStyle
|= WB_GROUP
;
226 pBehindLast
->SetStyle( nLastStyle
);
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */