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 : :
30 : : #include <vcl/svapp.hxx>
31 : : #include <vcl/window.hxx>
32 : : #include <vcl/wall.hxx>
33 : : #include <osl/mutex.hxx>
34 : : #include <toolkit/controls/dialogcontrol.hxx>
35 : : #include <toolkit/helper/property.hxx>
36 : : #include <toolkit/helper/unopropertyarrayhelper.hxx>
37 : : #include <toolkit/controls/stdtabcontroller.hxx>
38 : : #include <com/sun/star/awt/PosSize.hpp>
39 : : #include <com/sun/star/awt/WindowAttribute.hpp>
40 : : #include <com/sun/star/resource/XStringResourceResolver.hpp>
41 : : #include <com/sun/star/graphic/XGraphicProvider.hpp>
42 : : #include <cppuhelper/typeprovider.hxx>
43 : : #include <tools/debug.hxx>
44 : : #include <tools/diagnose_ex.h>
45 : : #include <comphelper/sequence.hxx>
46 : : #include <vcl/svapp.hxx>
47 : : #include <vcl/outdev.hxx>
48 : :
49 : : #include <toolkit/helper/vclunohelper.hxx>
50 : : #include <unotools/ucbstreamhelper.hxx>
51 : : #include <vcl/graph.hxx>
52 : : #include <vcl/image.hxx>
53 : : #include <map>
54 : : #include <boost/unordered_map.hpp>
55 : : #include <cppuhelper/implbase1.hxx>
56 : : #include <algorithm>
57 : : #include <functional>
58 : : #include "osl/file.hxx"
59 : :
60 : : #include <vcl/tabctrl.hxx>
61 : : #include <toolkit/awt/vclxwindows.hxx>
62 : : #include "toolkit/controls/unocontrols.hxx"
63 : :
64 : : using namespace ::com::sun::star;
65 : : using namespace ::com::sun::star::uno;
66 : : using namespace ::com::sun::star::awt;
67 : : using namespace ::com::sun::star::lang;
68 : : using namespace ::com::sun::star::container;
69 : : using namespace ::com::sun::star::beans;
70 : : using namespace ::com::sun::star::util;
71 : :
72 : : #define PROPERTY_DIALOGSOURCEURL ::rtl::OUString( "DialogSourceURL" )
73 : : #define PROPERTY_IMAGEURL ::rtl::OUString( "ImageURL" )
74 : : #define PROPERTY_GRAPHIC ::rtl::OUString( "Graphic" )
75 : : //
76 : :
77 : : // we probably will need both a hash of control models and hash of controls
78 : : // => use some template magic
79 : :
80 : : typedef ::cppu::WeakImplHelper1< container::XNameContainer > SimpleNameContainer_BASE;
81 : :
82 : : template< typename T >
83 [ + - ][ + - ]: 26 : class SimpleNamedThingContainer : public SimpleNameContainer_BASE
[ - + ][ + - ]
[ + - ]
84 : : {
85 : : typedef boost::unordered_map< rtl::OUString, Reference< T >, ::rtl::OUStringHash,
86 : : ::std::equal_to< ::rtl::OUString > > NamedThingsHash;
87 : : NamedThingsHash things;
88 : : ::osl::Mutex m_aMutex;
89 : : public:
90 : : // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess
91 : 0 : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
92 : : {
93 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
94 [ # # ][ # # ]: 0 : if ( !hasByName( aName ) )
95 [ # # ]: 0 : throw NoSuchElementException();
96 : 0 : Reference< T > xElement;
97 [ # # ][ # # ]: 0 : if ( ! ( aElement >>= xElement ) )
98 [ # # ]: 0 : throw IllegalArgumentException();
99 [ # # ][ # # ]: 0 : things[ aName ] = xElement;
[ # # ]
100 : 0 : }
101 : 18 : virtual Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
102 : : {
103 [ + - ]: 18 : ::osl::MutexGuard aGuard( m_aMutex );
104 [ + - ][ - + ]: 18 : if ( !hasByName( aName ) )
105 [ # # ]: 0 : throw NoSuchElementException();
106 [ + - ][ + - ]: 18 : return uno::makeAny( things[ aName ] );
[ + - ]
107 : : }
108 : 2 : virtual Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(RuntimeException)
109 : : {
110 [ + - ]: 2 : ::osl::MutexGuard aGuard( m_aMutex );
111 [ + - ]: 2 : Sequence< ::rtl::OUString > aResult( things.size() );
112 [ + - ]: 2 : typename NamedThingsHash::iterator it = things.begin();
113 [ + - ]: 2 : typename NamedThingsHash::iterator it_end = things.end();
114 [ + - ]: 2 : rtl::OUString* pName = aResult.getArray();
115 [ + + ]: 6 : for (; it != it_end; ++it, ++pName )
116 [ + - ]: 4 : *pName = it->first;
117 [ + - ]: 2 : return aResult;
118 : : }
119 : 66 : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(RuntimeException)
120 : : {
121 [ + - ]: 66 : ::osl::MutexGuard aGuard( m_aMutex );
122 [ + - ][ + - ]: 66 : return ( things.find( aName ) != things.end() );
[ + - ]
123 : : }
124 : 30 : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
125 : : {
126 [ + - ]: 30 : ::osl::MutexGuard aGuard( m_aMutex );
127 [ + - ][ - + ]: 30 : if ( hasByName( aName ) )
128 [ # # ]: 0 : throw ElementExistException();
129 : 30 : Reference< T > xElement;
130 [ - + ][ + - ]: 30 : if ( ! ( aElement >>= xElement ) )
131 [ # # ]: 0 : throw IllegalArgumentException();
132 [ + - ][ + - ]: 30 : things[ aName ] = xElement;
[ + - ]
133 : 30 : }
134 : 14 : virtual void SAL_CALL removeByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
135 : : {
136 [ + - ]: 14 : ::osl::MutexGuard aGuard( m_aMutex );
137 [ + - ][ - + ]: 14 : if ( !hasByName( aName ) )
138 [ # # ]: 0 : throw NoSuchElementException();
139 [ + - ][ + - ]: 14 : things.erase( things.find( aName ) );
[ + - ]
140 : 14 : }
141 : 0 : virtual Type SAL_CALL getElementType( ) throw (RuntimeException)
142 : : {
143 : 0 : return T::static_type( NULL );
144 : : }
145 : 0 : virtual ::sal_Bool SAL_CALL hasElements( ) throw (RuntimeException)
146 : : {
147 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
148 [ # # ]: 0 : return ( things.size() > 0 );
149 : : }
150 : : };
151 : :
152 : : ////HELPER
153 : : ::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl );
154 : :
155 : : // ----------------------------------------------------
156 : : // class UnoControlDialogModel
157 : : // ----------------------------------------------------
158 : 8 : UnoControlDialogModel::UnoControlDialogModel( const Reference< XMultiServiceFactory >& i_factory )
159 : 8 : :ControlModelContainerBase( i_factory )
160 : : {
161 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
162 : : // ImplRegisterProperty( BASEPROPERTY_BORDER );
163 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
164 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_ENABLED );
165 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
166 : : // ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
167 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
168 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_HELPURL );
169 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_TITLE );
170 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
171 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_DESKTOP_AS_PARENT );
172 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_DECORATION );
173 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
174 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_GRAPHIC );
175 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_IMAGEURL );
176 : :
177 : 8 : Any aBool;
178 [ + - ]: 8 : aBool <<= (sal_Bool) sal_True;
179 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
180 [ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
181 : : // #TODO separate class for 'UserForm' ( instead of re-using Dialog ? )
182 [ + - ][ + - ]: 8 : uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
[ + - ]
183 [ + - ][ + - ]: 8 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
184 : 8 : }
185 : :
186 : 2 : UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel& rModel )
187 : 2 : : ControlModelContainerBase( rModel )
188 : : {
189 : : // need to clone BASEPROPERTY_USERFORMCONTAINEES too
190 [ + - ][ + - ]: 2 : Reference< XNameContainer > xSrcNameCont( const_cast< UnoControlDialogModel& >(rModel).getPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ) ), UNO_QUERY );
[ + - ]
191 [ + - ][ + - ]: 2 : Reference<XNameContainer > xNameCont( new SimpleNamedThingContainer< XControlModel >() );
[ + - ]
192 : :
193 [ + - ][ + - ]: 2 : uno::Sequence< rtl::OUString > sNames = xSrcNameCont->getElementNames();
194 [ + - ]: 2 : rtl::OUString* pName = sNames.getArray();
195 : 2 : rtl::OUString* pNamesEnd = pName + sNames.getLength();
196 [ + + ]: 6 : for ( ; pName != pNamesEnd; ++pName )
197 : : {
198 [ + - ][ + - ]: 4 : if ( xSrcNameCont->hasByName( *pName ) )
[ + - ]
199 [ + - ][ + - ]: 4 : xNameCont->insertByName( *pName, xSrcNameCont->getByName( *pName ) );
[ + - ][ + - ]
200 : : }
201 [ + - ][ + - ]: 2 : setFastPropertyValue_NoBroadcast( BASEPROPERTY_USERFORMCONTAINEES, makeAny( xNameCont ) );
[ + - ]
202 : 2 : }
203 : :
204 : 2 : UnoControlDialogModel::~UnoControlDialogModel()
205 : : {
206 [ - + ]: 4 : }
207 : :
208 : 2 : UnoControlModel* UnoControlDialogModel::Clone() const
209 : : {
210 : : // clone the container itself
211 [ + - ]: 2 : UnoControlDialogModel* pClone = new UnoControlDialogModel( *this );
212 : :
213 : 2 : Clone_Impl(*pClone);
214 : :
215 : 2 : return pClone;
216 : : }
217 : :
218 : :
219 : 0 : ::rtl::OUString UnoControlDialogModel::getServiceName( ) throw(RuntimeException)
220 : : {
221 : 0 : return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialogModel );
222 : : }
223 : :
224 : 136 : Any UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
225 : : {
226 : 136 : Any aAny;
227 : :
228 [ + + ]: 136 : switch ( nPropId )
229 : : {
230 : : case BASEPROPERTY_DEFAULTCONTROL:
231 [ + - ]: 8 : aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialog );
232 : 8 : break;
233 : : default:
234 [ + - ]: 128 : aAny = UnoControlModel::ImplGetDefaultValue( nPropId );
235 : : }
236 : :
237 : 136 : return aAny;
238 : : }
239 : :
240 : 4324 : ::cppu::IPropertyArrayHelper& UnoControlDialogModel::getInfoHelper()
241 : : {
242 : : static UnoPropertyArrayHelper* pHelper = NULL;
243 [ + + ]: 4324 : if ( !pHelper )
244 : : {
245 [ + - ]: 2 : Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
246 [ + - ][ + - ]: 2 : pHelper = new UnoPropertyArrayHelper( aIDs );
247 : : }
248 : 4324 : return *pHelper;
249 : : }
250 : :
251 : : // XMultiPropertySet
252 : 2 : Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo( ) throw(RuntimeException)
253 : : {
254 [ + - ][ + - ]: 2 : static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ + - ][ + - ]
[ # # ]
255 : 2 : return xInfo;
256 : : }
257 : :
258 : 326 : void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
259 : : {
260 : 326 : ControlModelContainerBase::setFastPropertyValue_NoBroadcast( nHandle, rValue );
261 : : try
262 : : {
263 [ + - ][ + - ]: 326 : if ( nHandle == BASEPROPERTY_IMAGEURL && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
[ + + ][ + + ]
264 : : {
265 : 4 : ::rtl::OUString sImageURL;
266 : 4 : OSL_VERIFY( rValue >>= sImageURL );
267 [ + - ][ + - ]: 4 : setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj, sImageURL ) ) );
[ + - ][ # # ]
[ + - ]
268 : : }
269 : : }
270 : 0 : catch( const ::com::sun::star::uno::Exception& )
271 : : {
272 : : OSL_ENSURE( sal_False, "UnoControlDialogModel::setFastPropertyValue_NoBroadcast: caught an exception while setting ImageURL properties!" );
273 : : }
274 : 326 : }
275 : : // ============================================================================
276 : : // = class UnoDialogControl
277 : : // ============================================================================
278 : :
279 : 8 : UnoDialogControl::UnoDialogControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
280 : : :UnoDialogControl_Base( i_factory )
281 : : ,maTopWindowListeners( *this )
282 [ + - ]: 8 : ,mbWindowListener(false)
283 : : {
284 : 8 : maComponentInfos.nWidth = 300;
285 : 8 : maComponentInfos.nHeight = 450;
286 : 8 : }
287 : :
288 [ # # ]: 0 : UnoDialogControl::~UnoDialogControl()
289 : : {
290 [ # # ]: 0 : }
291 : :
292 : 2 : ::rtl::OUString UnoDialogControl::GetComponentServiceName()
293 : : {
294 : :
295 : 2 : sal_Bool bDecoration( sal_True );
296 [ + - ][ + - ]: 2 : ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
297 [ + - ]: 2 : if ( bDecoration )
298 : 2 : return ::rtl::OUString("Dialog");
299 : : else
300 : 2 : return ::rtl::OUString("TabPage");
301 : : }
302 : :
303 : 2 : void UnoDialogControl::dispose() throw(RuntimeException)
304 : : {
305 [ + - ]: 2 : SolarMutexGuard aGuard;
306 : :
307 [ + - ]: 2 : EventObject aEvt;
308 [ + - ]: 2 : aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
309 [ + - ]: 2 : maTopWindowListeners.disposeAndClear( aEvt );
310 [ + - ][ + - ]: 2 : ControlContainerBase::dispose();
[ + - ]
311 : 2 : }
312 : :
313 : 4 : void SAL_CALL UnoDialogControl::disposing(
314 : : const EventObject& Source )
315 : : throw(RuntimeException)
316 : : {
317 : 4 : ControlContainerBase::disposing( Source );
318 : 4 : }
319 : :
320 : 10 : sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
321 : : {
322 : : // #Can we move all the Resource stuff to the ControlContainerBase ?
323 [ + - ]: 10 : SolarMutexGuard aGuard;
324 [ + - ]: 10 : sal_Bool bRet = ControlContainerBase::setModel( rxModel );
325 [ + - ]: 10 : ImplStartListingForResourceEvents();
326 [ + - ]: 10 : return bRet;
327 : : }
328 : :
329 : 2 : void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
330 : : {
331 [ + - ]: 2 : SolarMutexGuard aGuard;
332 : :
333 [ + - ]: 2 : UnoControlContainer::createPeer( rxToolkit, rParentPeer );
334 : :
335 [ + - ][ + - ]: 2 : Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
336 [ + - ]: 2 : if ( xTW.is() )
337 : : {
338 [ + - ][ + - ]: 2 : xTW->setMenuBar( mxMenuBar );
339 : :
340 [ + - ]: 2 : if ( !mbWindowListener )
341 : : {
342 [ + - ]: 2 : Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
343 [ + - ]: 2 : addWindowListener( xWL );
344 : 2 : mbWindowListener = true;
345 : : }
346 : :
347 [ + - ][ - + ]: 2 : if ( maTopWindowListeners.getLength() )
348 [ # # ][ # # ]: 0 : xTW->addTopWindowListener( &maTopWindowListeners );
[ # # ]
349 [ + - ]: 2 : }
350 : 2 : }
351 : :
352 : 2 : void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc )
353 : : {
354 : 2 : sal_Bool bDecoration( sal_True );
355 [ + - ][ + - ]: 2 : ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
356 [ - + ]: 2 : if ( !bDecoration )
357 : : {
358 : : // Now we have to manipulate the WindowDescriptor
359 : 0 : rDesc.WindowAttributes = rDesc.WindowAttributes | ::com::sun::star::awt::WindowAttribute::NODECORATION;
360 : : }
361 : :
362 : : // We have to set the graphic property before the peer
363 : : // will be created. Otherwise the properties will be copied
364 : : // into the peer via propertiesChangeEvents. As the order of
365 : : // can lead to overwrites we have to set the graphic property
366 : : // before the propertiesChangeEvents are sent!
367 : 2 : ::rtl::OUString aImageURL;
368 : 2 : Reference< graphic::XGraphic > xGraphic;
369 [ + - - + ]: 4 : if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
[ + - ][ + - ]
[ + - ][ - +
# # # # #
# ][ + - ]
370 : 2 : ( !aImageURL.isEmpty() ))
371 : : {
372 : 0 : ::rtl::OUString absoluteUrl = aImageURL;
373 [ # # ]: 0 : if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
374 : : absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
375 [ # # ][ # # ]: 0 : uno::makeAny( aImageURL ) );
[ # # ]
376 : :
377 [ # # ][ # # ]: 0 : xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl );
378 [ # # ][ # # ]: 0 : ImplSetPropertyValue( PROPERTY_GRAPHIC, uno::makeAny( xGraphic ), sal_True );
379 : 2 : }
380 : 2 : }
381 : :
382 : 0 : void UnoDialogControl::addTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
383 : : {
384 : 0 : maTopWindowListeners.addInterface( rxListener );
385 [ # # ][ # # ]: 0 : if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
386 : : {
387 [ # # ][ # # ]: 0 : Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
388 [ # # ][ # # ]: 0 : xTW->addTopWindowListener( &maTopWindowListeners );
[ # # ]
389 : : }
390 : 0 : }
391 : :
392 : 0 : void UnoDialogControl::removeTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
393 : : {
394 [ # # ][ # # ]: 0 : if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
395 : : {
396 [ # # ][ # # ]: 0 : Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
397 [ # # ][ # # ]: 0 : xTW->removeTopWindowListener( &maTopWindowListeners );
[ # # ]
398 : : }
399 : 0 : maTopWindowListeners.removeInterface( rxListener );
400 : 0 : }
401 : :
402 : 0 : void UnoDialogControl::toFront( ) throw (RuntimeException)
403 : : {
404 [ # # ]: 0 : SolarMutexGuard aGuard;
405 [ # # ][ # # ]: 0 : if ( getPeer().is() )
406 : : {
407 [ # # ][ # # ]: 0 : Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
408 [ # # ]: 0 : if( xTW.is() )
409 [ # # ][ # # ]: 0 : xTW->toFront();
410 [ # # ]: 0 : }
411 : 0 : }
412 : :
413 : 0 : void UnoDialogControl::toBack( ) throw (RuntimeException)
414 : : {
415 [ # # ]: 0 : SolarMutexGuard aGuard;
416 [ # # ][ # # ]: 0 : if ( getPeer().is() )
417 : : {
418 [ # # ][ # # ]: 0 : Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
419 [ # # ]: 0 : if( xTW.is() )
420 [ # # ][ # # ]: 0 : xTW->toBack();
421 [ # # ]: 0 : }
422 : 0 : }
423 : :
424 : 0 : void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) throw (RuntimeException)
425 : : {
426 [ # # ]: 0 : SolarMutexGuard aGuard;
427 [ # # ]: 0 : mxMenuBar = rxMenuBar;
428 [ # # ][ # # ]: 0 : if ( getPeer().is() )
429 : : {
430 [ # # ][ # # ]: 0 : Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
431 [ # # ]: 0 : if( xTW.is() )
432 [ # # ][ # # ]: 0 : xTW->setMenuBar( mxMenuBar );
433 [ # # ]: 0 : }
434 : 0 : }
435 : 4 : static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize )
436 : : {
437 [ + - ]: 4 : ::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT );
438 : 4 : return aTmp;
439 : : }
440 : : // ::com::sun::star::awt::XWindowListener
441 : 4 : void SAL_CALL UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent& e )
442 : : throw (::com::sun::star::uno::RuntimeException)
443 : : {
444 : 4 : OutputDevice*pOutDev = Application::GetDefaultDevice();
445 : : DBG_ASSERT( pOutDev, "Missing Default Device!" );
446 [ + - ][ + - ]: 4 : if ( pOutDev && !mbSizeModified )
447 : : {
448 : : // Currentley we are simply using MAP_APPFONT
449 : 4 : ::Size aAppFontSize( e.Width, e.Height );
450 : :
451 [ + - ][ + - ]: 4 : Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
452 [ + - ][ + - ]: 4 : Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
[ + - ]
453 : : OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
454 : :
455 : : // #i87592 In design mode the drawing layer works with sizes with decoration.
456 : : // Therefore we have to substract them before writing back to the properties (model).
457 [ - + ][ - + ]: 4 : if ( xDialogDevice.is() && mbDesignMode )
[ + - ]
458 : : {
459 [ # # ][ # # ]: 0 : DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
460 : 0 : aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
461 : 0 : aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
462 : : }
463 : :
464 [ + - ]: 4 : aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
465 : :
466 : : // Remember that changes have been done by listener. No need to
467 : : // update the position because of property change event.
468 : 4 : mbSizeModified = true;
469 [ + - ]: 4 : Sequence< rtl::OUString > aProps( 2 );
470 [ + - ]: 4 : Sequence< Any > aValues( 2 );
471 : : // Properties in a sequence must be sorted!
472 [ + - ]: 4 : aProps[0] = rtl::OUString( "Height" );
473 [ + - ]: 4 : aProps[1] = rtl::OUString( "Width" );
474 [ + - ][ + - ]: 4 : aValues[0] <<= aAppFontSize.Height();
475 [ + - ][ + - ]: 4 : aValues[1] <<= aAppFontSize.Width();
476 : :
477 [ + - ]: 4 : ImplSetPropertyValues( aProps, aValues, true );
478 [ + - ][ + - ]: 4 : mbSizeModified = false;
479 : : }
480 : 4 : }
481 : :
482 : 0 : void SAL_CALL UnoDialogControl::windowMoved( const ::com::sun::star::awt::WindowEvent& e )
483 : : throw (::com::sun::star::uno::RuntimeException)
484 : : {
485 : 0 : OutputDevice*pOutDev = Application::GetDefaultDevice();
486 : : DBG_ASSERT( pOutDev, "Missing Default Device!" );
487 [ # # ][ # # ]: 0 : if ( pOutDev && !mbPosModified )
488 : : {
489 : : // Currentley we are simply using MAP_APPFONT
490 : 0 : Any aAny;
491 : 0 : ::Size aTmp( e.X, e.Y );
492 [ # # ]: 0 : aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
493 : :
494 : : // Remember that changes have been done by listener. No need to
495 : : // update the position because of property change event.
496 : 0 : mbPosModified = true;
497 [ # # ]: 0 : Sequence< rtl::OUString > aProps( 2 );
498 [ # # ]: 0 : Sequence< Any > aValues( 2 );
499 [ # # ]: 0 : aProps[0] = rtl::OUString( "PositionX" );
500 [ # # ]: 0 : aProps[1] = rtl::OUString( "PositionY" );
501 [ # # ][ # # ]: 0 : aValues[0] <<= aTmp.Width();
502 [ # # ][ # # ]: 0 : aValues[1] <<= aTmp.Height();
503 : :
504 [ # # ]: 0 : ImplSetPropertyValues( aProps, aValues, true );
505 [ # # ][ # # ]: 0 : mbPosModified = false;
506 : : }
507 : 0 : }
508 : :
509 : 0 : void SAL_CALL UnoDialogControl::windowShown( const EventObject& e ) throw (RuntimeException)
510 : : {
511 : : (void)e;
512 : 0 : }
513 : :
514 : 0 : void SAL_CALL UnoDialogControl::windowHidden( const EventObject& e ) throw (RuntimeException)
515 : : {
516 : : (void)e;
517 : 0 : }
518 : :
519 : 0 : void SAL_CALL UnoDialogControl::endDialog( ::sal_Int32 i_result ) throw (RuntimeException)
520 : : {
521 [ # # ][ # # ]: 0 : Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
522 [ # # ]: 0 : if ( xPeerDialog.is() )
523 [ # # ][ # # ]: 0 : xPeerDialog->endDialog( i_result );
524 : 0 : }
525 : :
526 : 0 : void SAL_CALL UnoDialogControl::setHelpId( const rtl::OUString& i_id ) throw (RuntimeException)
527 : : {
528 [ # # ][ # # ]: 0 : Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
529 [ # # ]: 0 : if ( xPeerDialog.is() )
530 [ # # ][ # # ]: 0 : xPeerDialog->setHelpId( i_id );
531 : 0 : }
532 : :
533 : 0 : void UnoDialogControl::setTitle( const ::rtl::OUString& Title ) throw(RuntimeException)
534 : : {
535 [ # # ]: 0 : SolarMutexGuard aGuard;
536 : 0 : Any aAny;
537 [ # # ]: 0 : aAny <<= Title;
538 [ # # ][ # # ]: 0 : ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ), aAny, sal_True );
[ # # ]
539 : 0 : }
540 : :
541 : 0 : ::rtl::OUString UnoDialogControl::getTitle() throw(RuntimeException)
542 : : {
543 [ # # ]: 0 : SolarMutexGuard aGuard;
544 [ # # ][ # # ]: 0 : return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE );
545 : : }
546 : :
547 : 0 : sal_Int16 UnoDialogControl::execute() throw(RuntimeException)
548 : : {
549 [ # # ]: 0 : SolarMutexGuard aGuard;
550 : 0 : sal_Int16 nDone = -1;
551 [ # # ][ # # ]: 0 : if ( getPeer().is() )
552 : : {
553 [ # # ][ # # ]: 0 : Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
554 [ # # ]: 0 : if( xDlg.is() )
555 : : {
556 : 0 : GetComponentInfos().bVisible = sal_True;
557 [ # # ][ # # ]: 0 : nDone = xDlg->execute();
558 : 0 : GetComponentInfos().bVisible = sal_False;
559 : 0 : }
560 : : }
561 [ # # ]: 0 : return nDone;
562 : : }
563 : :
564 : 0 : void UnoDialogControl::endExecute() throw(RuntimeException)
565 : : {
566 [ # # ]: 0 : SolarMutexGuard aGuard;
567 [ # # ][ # # ]: 0 : if ( getPeer().is() )
568 : : {
569 [ # # ][ # # ]: 0 : Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
570 [ # # ]: 0 : if( xDlg.is() )
571 : : {
572 [ # # ][ # # ]: 0 : xDlg->endExecute();
573 : 0 : GetComponentInfos().bVisible = sal_False;
574 : 0 : }
575 [ # # ]: 0 : }
576 : 0 : }
577 : :
578 : : // XModifyListener
579 : 0 : void SAL_CALL UnoDialogControl::modified(
580 : : const lang::EventObject& /*rEvent*/ )
581 : : throw (RuntimeException)
582 : : {
583 : 0 : ImplUpdateResourceResolver();
584 : 0 : }
585 : :
586 : 364 : void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
587 : : {
588 : 364 : sal_Int32 nLen = rEvents.getLength();
589 [ + + ]: 856 : for( sal_Int32 i = 0; i < nLen; i++ )
590 : : {
591 : 492 : const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
592 [ + - ]: 492 : Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
593 [ + - ][ + - ]: 492 : sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get();
[ + - ]
594 [ + + ][ + + ]: 492 : if ( bOwnModel && rEvt.PropertyName.equalsAsciiL( "ImageURL", 8 ))
[ + - ]
595 : : {
596 : 6 : ::rtl::OUString aImageURL;
597 : 6 : Reference< graphic::XGraphic > xGraphic;
598 [ + - ]: 12 : if (( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) ) >>= aImageURL ) &&
[ + - + + ]
[ + - ]
[ + + # # ]
[ + - ]
599 : 6 : ( !aImageURL.isEmpty() ))
600 : : {
601 : 4 : ::rtl::OUString absoluteUrl = aImageURL;
602 [ + - ]: 4 : if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
603 : :
604 [ + - ]: 4 : absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL )),
605 [ + - ][ + - ]: 8 : uno::makeAny(aImageURL));
[ + - ]
606 : :
607 [ + - ][ + - ]: 4 : xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl );
608 : : }
609 [ + - ][ + - ]: 6 : ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC), uno::makeAny( xGraphic ), sal_True );
[ + - ]
610 : 492 : break;
611 : : }
612 [ + + ]: 492 : }
613 : 364 : ControlContainerBase::ImplModelPropertiesChanged(rEvents);
614 : 364 : }
615 : :
616 : : // ----------------------------------------------------
617 : : // class MultiPageControl
618 : : // ----------------------------------------------------
619 [ # # ]: 0 : UnoMultiPageControl::UnoMultiPageControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory) : ControlContainerBase( i_factory ), maTabListeners( *this )
620 : : {
621 : 0 : maComponentInfos.nWidth = 280;
622 : 0 : maComponentInfos.nHeight = 400;
623 : 0 : }
624 : :
625 [ # # ]: 0 : UnoMultiPageControl::~UnoMultiPageControl()
626 : : {
627 [ # # ]: 0 : }
628 : : // XTabListener
629 : :
630 : 0 : void SAL_CALL UnoMultiPageControl::inserted( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
631 : : {
632 : 0 : }
633 : 0 : void SAL_CALL UnoMultiPageControl::removed( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
634 : : {
635 : 0 : }
636 : 0 : void SAL_CALL UnoMultiPageControl::changed( ::sal_Int32 /*ID*/, const Sequence< NamedValue >& /*Properties*/ ) throw (RuntimeException)
637 : : {
638 : 0 : }
639 : 0 : void SAL_CALL UnoMultiPageControl::activated( ::sal_Int32 ID ) throw (RuntimeException)
640 : : {
641 [ # # ][ # # ]: 0 : ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), sal_False );
642 : :
643 : 0 : }
644 : 0 : void SAL_CALL UnoMultiPageControl::deactivated( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
645 : : {
646 : 0 : }
647 : 0 : void SAL_CALL UnoMultiPageControl::disposing(const EventObject&) throw (RuntimeException)
648 : : {
649 : 0 : }
650 : :
651 : 0 : void SAL_CALL UnoMultiPageControl::dispose() throw (RuntimeException)
652 : : {
653 [ # # ]: 0 : lang::EventObject aEvt;
654 [ # # ]: 0 : aEvt.Source = (::cppu::OWeakObject*)this;
655 [ # # ]: 0 : maTabListeners.disposeAndClear( aEvt );
656 [ # # ][ # # ]: 0 : ControlContainerBase::dispose();
657 : 0 : }
658 : :
659 : : // com::sun::star::awt::XSimpleTabController
660 : 0 : ::sal_Int32 SAL_CALL UnoMultiPageControl::insertTab() throw (RuntimeException)
661 : : {
662 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
663 [ # # ]: 0 : if ( !xMultiPage.is() )
664 [ # # ]: 0 : throw RuntimeException();
665 [ # # ][ # # ]: 0 : return xMultiPage->insertTab();
666 : : }
667 : :
668 : 0 : void SAL_CALL UnoMultiPageControl::removeTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
669 : : {
670 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
671 [ # # ]: 0 : if ( !xMultiPage.is() )
672 [ # # ]: 0 : throw RuntimeException();
673 [ # # ][ # # ]: 0 : xMultiPage->removeTab( ID );
674 : 0 : }
675 : :
676 : 0 : void SAL_CALL UnoMultiPageControl::setTabProps( ::sal_Int32 ID, const Sequence< NamedValue >& Properties ) throw (IndexOutOfBoundsException, RuntimeException)
677 : : {
678 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
679 [ # # ]: 0 : if ( !xMultiPage.is() )
680 [ # # ]: 0 : throw RuntimeException();
681 [ # # ][ # # ]: 0 : xMultiPage->setTabProps( ID, Properties );
682 : 0 : }
683 : :
684 : 0 : Sequence< NamedValue > SAL_CALL UnoMultiPageControl::getTabProps( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
685 : : {
686 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
687 [ # # ]: 0 : if ( !xMultiPage.is() )
688 [ # # ]: 0 : throw RuntimeException();
689 [ # # ][ # # ]: 0 : return xMultiPage->getTabProps( ID );
690 : : }
691 : :
692 : 0 : void SAL_CALL UnoMultiPageControl::activateTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
693 : : {
694 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
695 [ # # ]: 0 : if ( !xMultiPage.is() )
696 [ # # ]: 0 : throw RuntimeException();
697 [ # # ][ # # ]: 0 : xMultiPage->activateTab( ID );
698 [ # # ][ # # ]: 0 : ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), sal_True );
[ # # ]
699 : :
700 : 0 : }
701 : :
702 : 0 : ::sal_Int32 SAL_CALL UnoMultiPageControl::getActiveTabID() throw (RuntimeException)
703 : : {
704 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
705 [ # # ]: 0 : if ( !xMultiPage.is() )
706 [ # # ]: 0 : throw RuntimeException();
707 [ # # ][ # # ]: 0 : return xMultiPage->getActiveTabID();
708 : : }
709 : :
710 : 0 : void SAL_CALL UnoMultiPageControl::addTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException)
711 : : {
712 [ # # ]: 0 : maTabListeners.addInterface( Listener );
713 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
714 [ # # ][ # # ]: 0 : if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
[ # # ][ # # ]
715 [ # # ][ # # ]: 0 : xMultiPage->addTabListener( &maTabListeners );
[ # # ]
716 : 0 : }
717 : :
718 : 0 : void SAL_CALL UnoMultiPageControl::removeTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException)
719 : : {
720 [ # # ][ # # ]: 0 : Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
721 [ # # ][ # # ]: 0 : if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
[ # # ][ # # ]
722 [ # # ][ # # ]: 0 : xMultiPage->removeTabListener( &maTabListeners );
[ # # ]
723 [ # # ]: 0 : maTabListeners.removeInterface( Listener );
724 : 0 : }
725 : :
726 : :
727 : : // lang::XTypeProvider
728 [ # # ][ # # ]: 0 : IMPL_XTYPEPROVIDER_START( UnoMultiPageControl )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
729 [ # # ]: 0 : getCppuType( ( uno::Reference< awt::XSimpleTabController>* ) NULL ),
730 [ # # ]: 0 : getCppuType( ( uno::Reference< awt::XTabListener>* ) NULL ),
731 : : ControlContainerBase::getTypes()
732 [ # # ][ # # ]: 0 : IMPL_XTYPEPROVIDER_END
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
733 : :
734 : : // uno::XInterface
735 : 0 : uno::Any UnoMultiPageControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
736 : : {
737 : : uno::Any aRet = ::cppu::queryInterface( rType,
738 [ # # ]: 0 : (static_cast< awt::XTabListener* >(this)), (static_cast< awt::XSimpleTabController* >(this)) );
739 [ # # ][ # # ]: 0 : return (aRet.hasValue() ? aRet : ControlContainerBase::queryAggregation( rType ));
740 : : }
741 : :
742 : 0 : ::rtl::OUString UnoMultiPageControl::GetComponentServiceName()
743 : : {
744 : 0 : sal_Bool bDecoration( sal_True );
745 [ # # ][ # # ]: 0 : ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
746 [ # # ]: 0 : if ( bDecoration )
747 : 0 : return ::rtl::OUString("tabcontrol");
748 : : // Hopefully we can tweak the tabcontrol to display without tabs
749 : 0 : return ::rtl::OUString("tabcontrolnotabs");
750 : : }
751 : :
752 : 0 : void UnoMultiPageControl::bindPage( const uno::Reference< awt::XControl >& _rxControl )
753 : : {
754 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindowPeer > xPage( _rxControl->getPeer() );
755 [ # # ][ # # ]: 0 : uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
756 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( _rxControl->getModel(), uno::UNO_QUERY );
[ # # ]
757 : :
758 [ # # ][ # # ]: 0 : VCLXTabPage* pXPage = dynamic_cast< VCLXTabPage* >( xPage.get() );
759 [ # # ][ # # ]: 0 : TabPage* pPage = pXPage ? pXPage->getTabPage() : NULL;
760 [ # # ][ # # ]: 0 : if ( xTabCntrl.is() && pPage )
[ # # ]
761 : : {
762 [ # # ][ # # ]: 0 : VCLXMultiPage* pXTab = dynamic_cast< VCLXMultiPage* >( xTabCntrl.get() );
763 [ # # ]: 0 : if ( pXTab )
764 : : {
765 : 0 : rtl::OUString sTitle;
766 [ # # ][ # # ]: 0 : xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
[ # # ]
767 [ # # ]: 0 : pXTab->insertTab( pPage, sTitle);
768 : : }
769 : 0 : }
770 : :
771 : 0 : }
772 : :
773 : 0 : void UnoMultiPageControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
774 : : {
775 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
776 : :
777 [ # # ]: 0 : UnoControlContainer::createPeer( rxToolkit, rParentPeer );
778 : :
779 [ # # ]: 0 : uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
780 : 0 : sal_uInt32 nCtrls = aCtrls.getLength();
781 [ # # ]: 0 : for( sal_uInt32 n = 0; n < nCtrls; n++ )
782 [ # # ][ # # ]: 0 : bindPage( aCtrls[ n ] );
783 : 0 : sal_Int32 nActiveTab(0);
784 [ # # ][ # # ]: 0 : Reference< XPropertySet > xMultiProps( getModel(), UNO_QUERY );
785 [ # # ][ # # ]: 0 : xMultiProps->getPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ) ) >>= nActiveTab;
[ # # ]
786 : :
787 [ # # ][ # # ]: 0 : uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
788 [ # # ]: 0 : if ( xTabCntrl.is() )
789 : : {
790 [ # # ][ # # ]: 0 : xTabCntrl->addTabListener( this );
[ # # ]
791 [ # # ][ # # ]: 0 : if ( nActiveTab && nCtrls ) // Ensure peer is initialise with correct activated tab
792 : : {
793 [ # # ][ # # ]: 0 : xTabCntrl->activateTab( nActiveTab );
794 [ # # ][ # # ]: 0 : ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( nActiveTab ), sal_True );
[ # # ]
795 : : }
796 [ # # ][ # # ]: 0 : }
797 : 0 : }
798 : :
799 : 0 : void UnoMultiPageControl::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl)
800 : : {
801 : : OSL_PRECOND( _rxControl.is(), "UnoMultiPageControl::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
802 : :
803 : : // if the container already has a peer, then also create a peer for the control
804 [ # # ]: 0 : uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
805 : :
806 [ # # ]: 0 : if( xMyPeer.is() )
807 : : {
808 [ # # ][ # # ]: 0 : _rxControl->createPeer( NULL, xMyPeer );
[ # # ]
809 [ # # ]: 0 : bindPage( _rxControl );
810 [ # # ]: 0 : ImplActivateTabControllers();
811 : 0 : }
812 : :
813 : 0 : }
814 : :
815 : : // ------------- UnoMultiPageModel -----------------
816 : :
817 : 2 : UnoMultiPageModel::UnoMultiPageModel( const Reference< XMultiServiceFactory >& i_factory ) : ControlModelContainerBase( i_factory )
818 : : {
819 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
820 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
821 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
822 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_ENABLED );
823 : :
824 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
825 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
826 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_HELPURL );
827 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
828 : : //ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
829 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_MULTIPAGEVALUE );
830 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
831 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
832 : :
833 : 2 : Any aBool;
834 [ + - ]: 2 : aBool <<= (sal_Bool) sal_True;
835 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
836 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
837 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_DECORATION, aBool );
838 : : // MultiPage Control has the tab stop property. And the default value is True.
839 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
840 : :
841 [ + - ][ + - ]: 2 : uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
[ + - ]
842 [ + - ][ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
843 : 2 : }
844 : :
845 : 0 : UnoMultiPageModel::UnoMultiPageModel( const UnoMultiPageModel& rModel )
846 : 0 : : ControlModelContainerBase( rModel )
847 : : {
848 : 0 : }
849 : :
850 : 2 : UnoMultiPageModel::~UnoMultiPageModel()
851 : : {
852 [ - + ]: 4 : }
853 : :
854 : : UnoControlModel*
855 : 0 : UnoMultiPageModel::Clone() const
856 : : {
857 : : // clone the container itself
858 [ # # ]: 0 : UnoMultiPageModel* pClone = new UnoMultiPageModel( *this );
859 : 0 : Clone_Impl( *pClone );
860 : 0 : return pClone;
861 : : }
862 : :
863 : 0 : ::rtl::OUString UnoMultiPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
864 : : {
865 : 0 : return ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
866 : : }
867 : :
868 : 30 : uno::Any UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
869 : : {
870 [ + + ]: 30 : if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
871 : : {
872 : 2 : uno::Any aAny;
873 [ + - ]: 2 : aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageControl );
874 : 2 : return aAny;
875 : : }
876 : 30 : return ControlModelContainerBase::ImplGetDefaultValue( nPropId );
877 : : }
878 : :
879 : 0 : ::cppu::IPropertyArrayHelper& UnoMultiPageModel::getInfoHelper()
880 : : {
881 : : static UnoPropertyArrayHelper* pHelper = NULL;
882 [ # # ]: 0 : if ( !pHelper )
883 : : {
884 [ # # ]: 0 : uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
885 [ # # ][ # # ]: 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
886 : : }
887 : 0 : return *pHelper;
888 : : }
889 : :
890 : : // beans::XMultiPropertySet
891 : 0 : uno::Reference< beans::XPropertySetInfo > UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
892 : : {
893 [ # # ][ # # ]: 0 : static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
894 : 0 : return xInfo;
895 : : }
896 : :
897 : 0 : void UnoMultiPageModel::insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
898 : : {
899 : 0 : Reference< XServiceInfo > xInfo;
900 [ # # ]: 0 : aElement >>= xInfo;
901 : :
902 [ # # ]: 0 : if ( !xInfo.is() )
903 [ # # ]: 0 : throw IllegalArgumentException();
904 : :
905 : : // Only a Page model can be inserted into the multipage
906 [ # # ][ # # ]: 0 : if ( !xInfo->supportsService( rtl::OUString::createFromAscii( szServiceName_UnoPageModel ) ) )
[ # # ]
907 [ # # ]: 0 : throw IllegalArgumentException();
908 : :
909 [ # # ]: 0 : return ControlModelContainerBase::insertByName( aName, aElement );
910 : : }
911 : :
912 : : // ----------------------------------------------------------------------------
913 : 0 : sal_Bool SAL_CALL UnoMultiPageModel::getGroupControl( ) throw (RuntimeException)
914 : : {
915 : 0 : return sal_True;
916 : : }
917 : :
918 : : // ----------------------------------------------------
919 : : // class UnoPageControl
920 : : // ----------------------------------------------------
921 : 0 : UnoPageControl::UnoPageControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) : ControlContainerBase( i_factory )
922 : : {
923 : 0 : maComponentInfos.nWidth = 280;
924 : 0 : maComponentInfos.nHeight = 400;
925 : 0 : }
926 : :
927 : 0 : UnoPageControl::~UnoPageControl()
928 : : {
929 [ # # ]: 0 : }
930 : :
931 : 0 : ::rtl::OUString UnoPageControl::GetComponentServiceName()
932 : : {
933 : 0 : return ::rtl::OUString("tabpage");
934 : : }
935 : :
936 : :
937 : : // ------------- UnoPageModel -----------------
938 : :
939 : 0 : UnoPageModel::UnoPageModel( const Reference< XMultiServiceFactory >& i_factory ) : ControlModelContainerBase( i_factory )
940 : : {
941 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
942 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
943 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_ENABLED );
944 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
945 : :
946 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
947 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
948 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_HELPURL );
949 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_TITLE );
950 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
951 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
952 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
953 : : // ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
954 : :
955 : 0 : Any aBool;
956 [ # # ]: 0 : aBool <<= (sal_Bool) sal_True;
957 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
958 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
959 : : //ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
960 : :
961 [ # # ][ # # ]: 0 : uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
[ # # ]
962 [ # # ][ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
963 : 0 : }
964 : :
965 : 0 : UnoPageModel::UnoPageModel( const UnoPageModel& rModel )
966 : 0 : : ControlModelContainerBase( rModel )
967 : : {
968 : 0 : }
969 : :
970 : 0 : UnoPageModel::~UnoPageModel()
971 : : {
972 [ # # ]: 0 : }
973 : :
974 : : UnoControlModel*
975 : 0 : UnoPageModel::Clone() const
976 : : {
977 : : // clone the container itself
978 [ # # ]: 0 : UnoPageModel* pClone = new UnoPageModel( *this );
979 : 0 : Clone_Impl( *pClone );
980 : 0 : return pClone;
981 : : }
982 : :
983 : 0 : ::rtl::OUString UnoPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
984 : : {
985 : 0 : return ::rtl::OUString::createFromAscii( szServiceName_UnoPageModel );
986 : : }
987 : :
988 : 0 : uno::Any UnoPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
989 : : {
990 [ # # ]: 0 : if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
991 : : {
992 : 0 : uno::Any aAny;
993 [ # # ]: 0 : aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoPageControl );
994 : 0 : return aAny;
995 : : }
996 : 0 : return ControlModelContainerBase::ImplGetDefaultValue( nPropId );
997 : : }
998 : :
999 : 0 : ::cppu::IPropertyArrayHelper& UnoPageModel::getInfoHelper()
1000 : : {
1001 : : static UnoPropertyArrayHelper* pHelper = NULL;
1002 [ # # ]: 0 : if ( !pHelper )
1003 : : {
1004 [ # # ]: 0 : uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1005 [ # # ][ # # ]: 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
1006 : : }
1007 : 0 : return *pHelper;
1008 : : }
1009 : :
1010 : : // beans::XMultiPropertySet
1011 : 0 : uno::Reference< beans::XPropertySetInfo > UnoPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1012 : : {
1013 [ # # ][ # # ]: 0 : static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
1014 : 0 : return xInfo;
1015 : : }
1016 : :
1017 : : // ----------------------------------------------------------------------------
1018 : 0 : sal_Bool SAL_CALL UnoPageModel::getGroupControl( ) throw (RuntimeException)
1019 : : {
1020 : 0 : return sal_False;
1021 : : }
1022 : :
1023 : : // Frame control
1024 : :
1025 : : // ----------------------------------------------------
1026 : : // class UnoFrameControl
1027 : : // ----------------------------------------------------
1028 : 0 : UnoFrameControl::UnoFrameControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) : ControlContainerBase( i_factory )
1029 : : {
1030 : 0 : maComponentInfos.nWidth = 280;
1031 : 0 : maComponentInfos.nHeight = 400;
1032 : 0 : }
1033 : :
1034 : 0 : UnoFrameControl::~UnoFrameControl()
1035 : : {
1036 [ # # ]: 0 : }
1037 : :
1038 : 0 : ::rtl::OUString UnoFrameControl::GetComponentServiceName()
1039 : : {
1040 : 0 : return ::rtl::OUString("frame");
1041 : : }
1042 : :
1043 : 0 : void UnoFrameControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
1044 : : {
1045 : 0 : bool bOwnCtrl = false;
1046 : 0 : rtl::OUString sTitle;
1047 [ # # ][ # # ]: 0 : if ( rxCtrl.get() == Reference<XControl>( this ).get() )
[ # # ][ # # ]
1048 : 0 : bOwnCtrl = true;
1049 [ # # ][ # # ]: 0 : Reference< XPropertySet > xProps( getModel(), UNO_QUERY );
1050 : : //xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
1051 [ # # ][ # # ]: 0 : xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ) ) >>= sTitle;
[ # # ]
1052 : :
1053 [ # # ]: 0 : ControlContainerBase::ImplSetPosSize( rxCtrl );
1054 [ # # ]: 0 : Reference < XWindow > xW( rxCtrl, UNO_QUERY );
1055 [ # # ][ # # ]: 0 : if ( !bOwnCtrl && xW.is() && !sTitle.isEmpty() )
[ # # ][ # # ]
1056 : : {
1057 [ # # ][ # # ]: 0 : awt::Rectangle aSizePos = xW->getPosSize();
1058 : :
1059 : 0 : sal_Int32 nX = aSizePos.X, nY = aSizePos.Y, nWidth = aSizePos.Width, nHeight = aSizePos.Height;
1060 : : // Retrieve the values set by the base class
1061 [ # # ]: 0 : OutputDevice*pOutDev = Application::GetDefaultDevice();
1062 [ # # ]: 0 : if ( pOutDev )
1063 : : {
1064 [ # # ][ # # ]: 0 : if ( !bOwnCtrl && !sTitle.isEmpty() )
[ # # ]
1065 : : {
1066 : : // Adjust Y based on height of Title
1067 [ # # ]: 0 : ::Rectangle aRect;
1068 [ # # ][ # # ]: 0 : aRect = pOutDev->GetTextRect( aRect, sTitle );
[ # # ]
1069 [ # # ]: 0 : nY = nY + ( aRect.GetHeight() / 2 );
1070 : : }
1071 : : }
1072 : : else
1073 : : {
1074 [ # # ]: 0 : Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True );
1075 [ # # ]: 0 : Reference< XDevice > xD( xPeer, UNO_QUERY );
1076 : :
1077 : 0 : SimpleFontMetric aFM;
1078 : 0 : FontDescriptor aFD;
1079 [ # # ][ # # ]: 0 : Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
1080 [ # # ]: 0 : aVal >>= aFD;
1081 [ # # ]: 0 : if ( !aFD.StyleName.isEmpty() )
1082 : : {
1083 [ # # ][ # # ]: 0 : Reference< XFont > xFont = xD->getFont( aFD );
1084 [ # # ][ # # ]: 0 : aFM = xFont->getFontMetric();
1085 : : }
1086 : : else
1087 : : {
1088 [ # # ][ # # ]: 0 : Reference< XGraphics > xG = xD->createGraphics();
1089 [ # # ][ # # ]: 0 : aFM = xG->getFontMetric();
1090 : : }
1091 : :
1092 : 0 : sal_Int16 nH = aFM.Ascent + aFM.Descent;
1093 [ # # ][ # # ]: 0 : if ( !bOwnCtrl && !sTitle.isEmpty() )
[ # # ]
1094 : : // offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
1095 : 0 : nY = nY + ( nH / 8); // how do I test this
1096 : : }
1097 [ # # ][ # # ]: 0 : xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
1098 : 0 : }
1099 : 0 : }
1100 : :
1101 : : // ------------- UnoFrameModel -----------------
1102 : :
1103 : 2 : UnoFrameModel::UnoFrameModel( const Reference< XMultiServiceFactory >& i_factory ) : ControlModelContainerBase( i_factory )
1104 : : {
1105 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
1106 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
1107 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_ENABLED );
1108 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
1109 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
1110 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
1111 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_HELPURL );
1112 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
1113 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_LABEL );
1114 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
1115 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
1116 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
1117 : :
1118 [ + - ][ + - ]: 2 : uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
[ + - ]
1119 [ + - ][ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
1120 : 2 : }
1121 : :
1122 : 0 : UnoFrameModel::UnoFrameModel( const UnoFrameModel& rModel )
1123 : 0 : : ControlModelContainerBase( rModel )
1124 : : {
1125 : 0 : }
1126 : :
1127 : 2 : UnoFrameModel::~UnoFrameModel()
1128 : : {
1129 [ - + ]: 4 : }
1130 : :
1131 : : UnoControlModel*
1132 : 0 : UnoFrameModel::Clone() const
1133 : : {
1134 : : // clone the container itself
1135 [ # # ]: 0 : UnoFrameModel* pClone = new UnoFrameModel( *this );
1136 : 0 : Clone_Impl( *pClone );
1137 : 0 : return pClone;
1138 : : }
1139 : :
1140 : 0 : ::rtl::OUString UnoFrameModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1141 : : {
1142 : 0 : return ::rtl::OUString::createFromAscii( szServiceName_UnoFrameModel );
1143 : : }
1144 : :
1145 : 32 : uno::Any UnoFrameModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1146 : : {
1147 [ + + ]: 32 : if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1148 : : {
1149 : 2 : uno::Any aAny;
1150 [ + - ]: 2 : aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoFrameControl );
1151 : 2 : return aAny;
1152 : : }
1153 : 32 : return ControlModelContainerBase::ImplGetDefaultValue( nPropId );
1154 : : }
1155 : :
1156 : 0 : ::cppu::IPropertyArrayHelper& UnoFrameModel::getInfoHelper()
1157 : : {
1158 : : static UnoPropertyArrayHelper* pHelper = NULL;
1159 [ # # ]: 0 : if ( !pHelper )
1160 : : {
1161 [ # # ]: 0 : uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1162 [ # # ][ # # ]: 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
1163 : : }
1164 : 0 : return *pHelper;
1165 : : }
1166 : :
1167 : : // beans::XMultiPropertySet
1168 : 0 : uno::Reference< beans::XPropertySetInfo > UnoFrameModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1169 : : {
1170 [ # # ][ # # ]: 0 : static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
1171 : 0 : return xInfo;
1172 : : }
1173 : :
1174 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|