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 .
21 #include <vcl/svapp.hxx>
22 #include <vcl/window.hxx>
23 #include <vcl/wall.hxx>
24 #include <osl/mutex.hxx>
25 #include <toolkit/controls/dialogcontrol.hxx>
26 #include <toolkit/controls/geometrycontrolmodel.hxx>
27 #include <toolkit/helper/property.hxx>
28 #include <toolkit/controls/stdtabcontroller.hxx>
29 #include <com/sun/star/awt/PosSize.hpp>
30 #include <com/sun/star/awt/WindowAttribute.hpp>
31 #include <com/sun/star/resource/XStringResourceResolver.hpp>
32 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <com/sun/star/graphic/XGraphicProvider.hpp>
34 #include <cppuhelper/supportsservice.hxx>
35 #include <cppuhelper/typeprovider.hxx>
36 #include <cppuhelper/queryinterface.hxx>
37 #include <tools/debug.hxx>
38 #include <tools/diagnose_ex.h>
39 #include <comphelper/sequence.hxx>
40 #include <vcl/outdev.hxx>
42 #include <toolkit/helper/vclunohelper.hxx>
43 #include <unotools/ucbstreamhelper.hxx>
44 #include <vcl/graph.hxx>
45 #include <vcl/image.hxx>
46 #include <cppuhelper/implbase1.hxx>
50 #include <unordered_map>
51 #include "osl/file.hxx"
53 #include <vcl/tabctrl.hxx>
54 #include <toolkit/awt/vclxwindows.hxx>
55 #include "toolkit/controls/unocontrols.hxx"
57 #include "helper/unopropertyarrayhelper.hxx"
58 #include "controlmodelcontainerbase_internal.hxx"
60 using namespace ::com::sun::star
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::awt
;
63 using namespace ::com::sun::star::lang
;
64 using namespace ::com::sun::star::container
;
65 using namespace ::com::sun::star::beans
;
66 using namespace ::com::sun::star::util
;
68 #define PROPERTY_DIALOGSOURCEURL OUString( "DialogSourceURL" )
69 #define PROPERTY_IMAGEURL OUString( "ImageURL" )
70 #define PROPERTY_GRAPHIC OUString( "Graphic" )
73 // we probably will need both a hash of control models and hash of controls
74 // => use some template magic
76 typedef ::cppu::WeakImplHelper1
< container::XNameContainer
> SimpleNameContainer_BASE
;
78 template< typename T
>
79 class SimpleNamedThingContainer
: public SimpleNameContainer_BASE
81 typedef std::unordered_map
< OUString
, Reference
< T
>, OUStringHash
,
82 std::equal_to
< OUString
> > NamedThingsHash
;
83 NamedThingsHash things
;
84 ::osl::Mutex m_aMutex
;
86 // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess
87 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
) SAL_OVERRIDE
89 ::osl::MutexGuard
aGuard( m_aMutex
);
90 if ( !hasByName( aName
) )
91 throw NoSuchElementException();
92 Reference
< T
> xElement
;
93 if ( ! ( aElement
>>= xElement
) )
94 throw IllegalArgumentException();
95 things
[ aName
] = xElement
;
97 virtual Any SAL_CALL
getByName( const OUString
& aName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
) SAL_OVERRIDE
99 ::osl::MutexGuard
aGuard( m_aMutex
);
100 if ( !hasByName( aName
) )
101 throw NoSuchElementException();
102 return uno::makeAny( things
[ aName
] );
104 virtual Sequence
< OUString
> SAL_CALL
getElementNames( ) throw(RuntimeException
, std::exception
) SAL_OVERRIDE
106 ::osl::MutexGuard
aGuard( m_aMutex
);
107 Sequence
< OUString
> aResult( things
.size() );
108 typename
NamedThingsHash::iterator it
= things
.begin();
109 typename
NamedThingsHash::iterator it_end
= things
.end();
110 OUString
* pName
= aResult
.getArray();
111 for (; it
!= it_end
; ++it
, ++pName
)
115 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) throw(RuntimeException
, std::exception
) SAL_OVERRIDE
117 ::osl::MutexGuard
aGuard( m_aMutex
);
118 return ( things
.find( aName
) != things
.end() );
120 virtual void SAL_CALL
insertByName( const OUString
& aName
, const Any
& aElement
) throw(IllegalArgumentException
, ElementExistException
, WrappedTargetException
, RuntimeException
, std::exception
) SAL_OVERRIDE
122 ::osl::MutexGuard
aGuard( m_aMutex
);
123 if ( hasByName( aName
) )
124 throw ElementExistException();
125 Reference
< T
> xElement
;
126 if ( ! ( aElement
>>= xElement
) )
127 throw IllegalArgumentException();
128 things
[ aName
] = xElement
;
130 virtual void SAL_CALL
removeByName( const OUString
& aName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
) SAL_OVERRIDE
132 ::osl::MutexGuard
aGuard( m_aMutex
);
133 if ( !hasByName( aName
) )
134 throw NoSuchElementException();
135 things
.erase( things
.find( aName
) );
137 virtual Type SAL_CALL
getElementType( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
139 return cppu::UnoType
<T
>::get();
141 virtual sal_Bool SAL_CALL
hasElements( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
143 ::osl::MutexGuard
aGuard( m_aMutex
);
144 return ( !things
.empty() );
150 class UnoControlDialogModel
: public ControlModelContainerBase
153 css::uno::Reference
< css::graphic::XGraphicObject
> mxGrfObj
;
154 css::uno::Any
ImplGetDefaultValue( sal_uInt16 nPropId
) const SAL_OVERRIDE
;
155 ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
156 // ::cppu::OPropertySetHelper
157 void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
) throw (css::uno::Exception
, std::exception
) SAL_OVERRIDE
;
159 UnoControlDialogModel( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
160 UnoControlDialogModel( const UnoControlDialogModel
& rModel
);
161 virtual ~UnoControlDialogModel();
163 UnoControlModel
* Clone() const SAL_OVERRIDE
;
164 // css::beans::XMultiPropertySet
165 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
167 // css::io::XPersistObject
168 OUString SAL_CALL
getServiceName() throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
171 OUString SAL_CALL
getImplementationName()
172 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
173 { return OUString("stardiv.Toolkit.UnoControlDialogModel"); }
175 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
176 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
178 auto s(ControlModelContainerBase::getSupportedServiceNames());
179 s
.realloc(s
.getLength() + 2);
180 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDialogModel";
181 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.Dialog";
186 UnoControlDialogModel::UnoControlDialogModel( const Reference
< XComponentContext
>& rxContext
)
187 :ControlModelContainerBase( rxContext
)
189 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
190 // ImplRegisterProperty( BASEPROPERTY_BORDER );
191 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
192 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
193 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
194 // ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
195 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
196 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
197 ImplRegisterProperty( BASEPROPERTY_TITLE
);
198 ImplRegisterProperty( BASEPROPERTY_SIZEABLE
);
199 ImplRegisterProperty( BASEPROPERTY_DESKTOP_AS_PARENT
);
200 ImplRegisterProperty( BASEPROPERTY_DECORATION
);
201 ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL
);
202 ImplRegisterProperty( BASEPROPERTY_GRAPHIC
);
203 ImplRegisterProperty( BASEPROPERTY_IMAGEURL
);
204 ImplRegisterProperty( BASEPROPERTY_HSCROLL
);
205 ImplRegisterProperty( BASEPROPERTY_VSCROLL
);
206 ImplRegisterProperty( BASEPROPERTY_SCROLLWIDTH
);
207 ImplRegisterProperty( BASEPROPERTY_SCROLLHEIGHT
);
208 ImplRegisterProperty( BASEPROPERTY_SCROLLTOP
);
209 ImplRegisterProperty( BASEPROPERTY_SCROLLLEFT
);
213 ImplRegisterProperty( BASEPROPERTY_MOVEABLE
, aBool
);
214 ImplRegisterProperty( BASEPROPERTY_CLOSEABLE
, aBool
);
215 // #TODO separate class for 'UserForm' ( instead of re-using Dialog ? )
216 uno::Reference
< XNameContainer
> xNameCont
= new SimpleNamedThingContainer
< XControlModel
>();
217 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
, uno::makeAny( xNameCont
) );
220 UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel
& rModel
)
221 : ControlModelContainerBase( rModel
)
223 // need to clone BASEPROPERTY_USERFORMCONTAINEES too
224 Reference
< XNameContainer
> xSrcNameCont( const_cast< UnoControlDialogModel
& >(rModel
).getPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES
) ), UNO_QUERY
);
225 Reference
<XNameContainer
> xNameCont( new SimpleNamedThingContainer
< XControlModel
>() );
227 uno::Sequence
< OUString
> sNames
= xSrcNameCont
->getElementNames();
228 OUString
* pName
= sNames
.getArray();
229 OUString
* pNamesEnd
= pName
+ sNames
.getLength();
230 for ( ; pName
!= pNamesEnd
; ++pName
)
232 if ( xSrcNameCont
->hasByName( *pName
) )
233 xNameCont
->insertByName( *pName
, xSrcNameCont
->getByName( *pName
) );
235 setFastPropertyValue_NoBroadcast( BASEPROPERTY_USERFORMCONTAINEES
, makeAny( xNameCont
) );
238 UnoControlDialogModel::~UnoControlDialogModel()
242 UnoControlModel
* UnoControlDialogModel::Clone() const
244 // clone the container itself
245 UnoControlDialogModel
* pClone
= new UnoControlDialogModel( *this );
253 OUString
UnoControlDialogModel::getServiceName( ) throw(RuntimeException
, std::exception
)
255 return OUString("stardiv.vcl.controlmodel.Dialog");
258 Any
UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
264 case BASEPROPERTY_DEFAULTCONTROL
:
265 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlDialog
);
267 case BASEPROPERTY_SCROLLWIDTH
:
268 case BASEPROPERTY_SCROLLHEIGHT
:
269 case BASEPROPERTY_SCROLLTOP
:
270 case BASEPROPERTY_SCROLLLEFT
:
271 aAny
<<= sal_Int32(0);
274 aAny
= UnoControlModel::ImplGetDefaultValue( nPropId
);
280 ::cppu::IPropertyArrayHelper
& UnoControlDialogModel::getInfoHelper()
282 static UnoPropertyArrayHelper
* pHelper
= NULL
;
285 Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
286 pHelper
= new UnoPropertyArrayHelper( aIDs
);
292 Reference
< XPropertySetInfo
> UnoControlDialogModel::getPropertySetInfo( ) throw(RuntimeException
, std::exception
)
294 static Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
298 void SAL_CALL
UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
, std::exception
)
300 ControlModelContainerBase::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
303 if ( nHandle
== BASEPROPERTY_IMAGEURL
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
306 OSL_VERIFY( rValue
>>= sImageURL
);
307 setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC
), uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj
, sImageURL
) ) );
310 catch( const ::com::sun::star::uno::Exception
& )
312 OSL_ENSURE( false, "UnoControlDialogModel::setFastPropertyValue_NoBroadcast: caught an exception while setting ImageURL properties!" );
319 // = class UnoDialogControl
322 UnoDialogControl::UnoDialogControl( const uno::Reference
< uno::XComponentContext
>& rxContext
)
323 :UnoDialogControl_Base( rxContext
)
324 ,maTopWindowListeners( *this )
325 ,mbWindowListener(false)
327 maComponentInfos
.nWidth
= 300;
328 maComponentInfos
.nHeight
= 450;
331 UnoDialogControl::~UnoDialogControl()
335 OUString
UnoDialogControl::GetComponentServiceName()
338 bool bDecoration( true );
339 ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION
)) >>= bDecoration
;
341 return OUString("Dialog");
343 return OUString("TabPage");
346 void UnoDialogControl::dispose() throw(RuntimeException
, std::exception
)
348 SolarMutexGuard aGuard
;
351 aEvt
.Source
= static_cast< ::cppu::OWeakObject
* >( this );
352 maTopWindowListeners
.disposeAndClear( aEvt
);
353 ControlContainerBase::dispose();
356 void SAL_CALL
UnoDialogControl::disposing(
357 const EventObject
& Source
)
358 throw(RuntimeException
, std::exception
)
360 ControlContainerBase::disposing( Source
);
363 sal_Bool
UnoDialogControl::setModel( const Reference
< XControlModel
>& rxModel
) throw(RuntimeException
, std::exception
)
365 // #Can we move all the Resource stuff to the ControlContainerBase ?
366 SolarMutexGuard aGuard
;
367 bool bRet
= ControlContainerBase::setModel( rxModel
);
368 ImplStartListingForResourceEvents();
372 void UnoDialogControl::createPeer( const Reference
< XToolkit
> & rxToolkit
, const Reference
< XWindowPeer
> & rParentPeer
) throw(RuntimeException
, std::exception
)
374 SolarMutexGuard aGuard
;
376 UnoControlContainer::createPeer( rxToolkit
, rParentPeer
);
378 Reference
< XTopWindow
> xTW( getPeer(), UNO_QUERY
);
381 xTW
->setMenuBar( mxMenuBar
);
383 if ( !mbWindowListener
)
385 Reference
< XWindowListener
> xWL( static_cast< cppu::OWeakObject
*>( this ), UNO_QUERY
);
386 addWindowListener( xWL
);
387 mbWindowListener
= true;
390 if ( maTopWindowListeners
.getLength() )
391 xTW
->addTopWindowListener( &maTopWindowListeners
);
392 // there must be a better way than doing this, we can't
393 // process the scrolltop & scrollleft in XDialog because
394 // the children haven't been added when those props are applied
395 ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLTOP
), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLTOP
) ) );
396 ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLLEFT
), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLLEFT
) ) );
401 OUString
UnoDialogControl::getImplementationName()
402 throw (css::uno::RuntimeException
, std::exception
)
404 return OUString("stardiv.Toolkit.UnoDialogControl");
407 sal_Bool
UnoDialogControl::supportsService(OUString
const & ServiceName
)
408 throw (css::uno::RuntimeException
, std::exception
)
410 return cppu::supportsService(this, ServiceName
);
413 css::uno::Sequence
<OUString
> UnoDialogControl::getSupportedServiceNames()
414 throw (css::uno::RuntimeException
, std::exception
)
416 return css::uno::Sequence
<OUString
>{
417 OUString::createFromAscii(szServiceName2_UnoControlDialog
),
418 "stardiv.vcl.control.Dialog"};
421 void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor
& rDesc
)
423 UnoControlContainer::PrepareWindowDescriptor( rDesc
);
424 bool bDecoration( true );
425 ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION
)) >>= bDecoration
;
428 // Now we have to manipulate the WindowDescriptor
429 rDesc
.WindowAttributes
= rDesc
.WindowAttributes
| ::com::sun::star::awt::WindowAttribute::NODECORATION
;
432 // We have to set the graphic property before the peer
433 // will be created. Otherwise the properties will be copied
434 // into the peer via propertiesChangeEvents. As the order of
435 // can lead to overwrites we have to set the graphic property
436 // before the propertiesChangeEvents are sent!
438 Reference
< graphic::XGraphic
> xGraphic
;
439 if (( ImplGetPropertyValue( PROPERTY_IMAGEURL
) >>= aImageURL
) &&
440 ( !aImageURL
.isEmpty() ))
442 OUString absoluteUrl
= aImageURL
;
443 if ( !aImageURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX
) )
444 absoluteUrl
= getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL
),
445 uno::makeAny( aImageURL
) );
447 xGraphic
= ImageHelper::getGraphicFromURL_nothrow( absoluteUrl
);
448 ImplSetPropertyValue( PROPERTY_GRAPHIC
, uno::makeAny( xGraphic
), true );
452 void UnoDialogControl::addTopWindowListener( const Reference
< XTopWindowListener
>& rxListener
) throw (RuntimeException
, std::exception
)
454 maTopWindowListeners
.addInterface( rxListener
);
455 if( getPeer().is() && maTopWindowListeners
.getLength() == 1 )
457 Reference
< XTopWindow
> xTW( getPeer(), UNO_QUERY
);
458 xTW
->addTopWindowListener( &maTopWindowListeners
);
462 void UnoDialogControl::removeTopWindowListener( const Reference
< XTopWindowListener
>& rxListener
) throw (RuntimeException
, std::exception
)
464 if( getPeer().is() && maTopWindowListeners
.getLength() == 1 )
466 Reference
< XTopWindow
> xTW( getPeer(), UNO_QUERY
);
467 xTW
->removeTopWindowListener( &maTopWindowListeners
);
469 maTopWindowListeners
.removeInterface( rxListener
);
472 void UnoDialogControl::toFront( ) throw (RuntimeException
, std::exception
)
474 SolarMutexGuard aGuard
;
475 if ( getPeer().is() )
477 Reference
< XTopWindow
> xTW( getPeer(), UNO_QUERY
);
483 void UnoDialogControl::toBack( ) throw (RuntimeException
, std::exception
)
485 SolarMutexGuard aGuard
;
486 if ( getPeer().is() )
488 Reference
< XTopWindow
> xTW( getPeer(), UNO_QUERY
);
494 void UnoDialogControl::setMenuBar( const Reference
< XMenuBar
>& rxMenuBar
) throw (RuntimeException
, std::exception
)
496 SolarMutexGuard aGuard
;
497 mxMenuBar
= rxMenuBar
;
498 if ( getPeer().is() )
500 Reference
< XTopWindow
> xTW( getPeer(), UNO_QUERY
);
502 xTW
->setMenuBar( mxMenuBar
);
505 static ::Size
ImplMapPixelToAppFont( OutputDevice
* pOutDev
, const ::Size
& aSize
)
507 ::Size aTmp
= pOutDev
->PixelToLogic( aSize
, MAP_APPFONT
);
510 // ::com::sun::star::awt::XWindowListener
511 void SAL_CALL
UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent
& e
)
512 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
514 OutputDevice
*pOutDev
= Application::GetDefaultDevice();
515 DBG_ASSERT( pOutDev
, "Missing Default Device!" );
516 if ( pOutDev
&& !mbSizeModified
)
518 // Currentley we are simply using MAP_APPFONT
519 ::Size
aAppFontSize( e
.Width
, e
.Height
);
521 Reference
< XControl
> xDialogControl( *this, UNO_QUERY_THROW
);
522 Reference
< XDevice
> xDialogDevice( xDialogControl
->getPeer(), UNO_QUERY
);
523 OSL_ENSURE( xDialogDevice
.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
525 // #i87592 In design mode the drawing layer works with sizes with decoration.
526 // Therefore we have to subtract them before writing back to the properties (model).
527 if ( xDialogDevice
.is() && mbDesignMode
)
529 DeviceInfo
aDeviceInfo( xDialogDevice
->getInfo() );
530 aAppFontSize
.Width() -= aDeviceInfo
.LeftInset
+ aDeviceInfo
.RightInset
;
531 aAppFontSize
.Height() -= aDeviceInfo
.TopInset
+ aDeviceInfo
.BottomInset
;
534 aAppFontSize
= ImplMapPixelToAppFont( pOutDev
, aAppFontSize
);
536 // Remember that changes have been done by listener. No need to
537 // update the position because of property change event.
538 mbSizeModified
= true;
539 Sequence
< OUString
> aProps( 2 );
540 Sequence
< Any
> aValues( 2 );
541 // Properties in a sequence must be sorted!
542 aProps
[0] = "Height";
544 aValues
[0] <<= aAppFontSize
.Height();
545 aValues
[1] <<= aAppFontSize
.Width();
547 ImplSetPropertyValues( aProps
, aValues
, true );
548 mbSizeModified
= false;
552 void SAL_CALL
UnoDialogControl::windowMoved( const ::com::sun::star::awt::WindowEvent
& e
)
553 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
555 OutputDevice
*pOutDev
= Application::GetDefaultDevice();
556 DBG_ASSERT( pOutDev
, "Missing Default Device!" );
557 if ( pOutDev
&& !mbPosModified
)
559 // Currentley we are simply using MAP_APPFONT
560 ::Size
aTmp( e
.X
, e
.Y
);
561 aTmp
= ImplMapPixelToAppFont( pOutDev
, aTmp
);
563 // Remember that changes have been done by listener. No need to
564 // update the position because of property change event.
565 mbPosModified
= true;
566 Sequence
< OUString
> aProps( 2 );
567 Sequence
< Any
> aValues( 2 );
568 aProps
[0] = "PositionX";
569 aProps
[1] = "PositionY";
570 aValues
[0] <<= aTmp
.Width();
571 aValues
[1] <<= aTmp
.Height();
573 ImplSetPropertyValues( aProps
, aValues
, true );
574 mbPosModified
= false;
578 void SAL_CALL
UnoDialogControl::windowShown( const EventObject
& e
) throw (RuntimeException
, std::exception
)
583 void SAL_CALL
UnoDialogControl::windowHidden( const EventObject
& e
) throw (RuntimeException
, std::exception
)
588 void SAL_CALL
UnoDialogControl::endDialog( ::sal_Int32 i_result
) throw (RuntimeException
, std::exception
)
590 Reference
< XDialog2
> xPeerDialog( getPeer(), UNO_QUERY
);
591 if ( xPeerDialog
.is() )
592 xPeerDialog
->endDialog( i_result
);
595 void SAL_CALL
UnoDialogControl::setHelpId( const OUString
& i_id
) throw (RuntimeException
, std::exception
)
597 Reference
< XDialog2
> xPeerDialog( getPeer(), UNO_QUERY
);
598 if ( xPeerDialog
.is() )
599 xPeerDialog
->setHelpId( i_id
);
602 void UnoDialogControl::setTitle( const OUString
& Title
) throw(RuntimeException
, std::exception
)
604 SolarMutexGuard aGuard
;
607 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE
), aAny
, true );
610 OUString
UnoDialogControl::getTitle() throw(RuntimeException
, std::exception
)
612 SolarMutexGuard aGuard
;
613 return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE
);
616 sal_Int16
UnoDialogControl::execute() throw(RuntimeException
, std::exception
)
618 SolarMutexGuard aGuard
;
619 sal_Int16 nDone
= -1;
620 if ( getPeer().is() )
622 Reference
< XDialog
> xDlg( getPeer(), UNO_QUERY
);
625 GetComponentInfos().bVisible
= true;
626 nDone
= xDlg
->execute();
627 GetComponentInfos().bVisible
= false;
633 void UnoDialogControl::endExecute() throw(RuntimeException
, std::exception
)
635 SolarMutexGuard aGuard
;
636 if ( getPeer().is() )
638 Reference
< XDialog
> xDlg( getPeer(), UNO_QUERY
);
642 GetComponentInfos().bVisible
= false;
648 void SAL_CALL
UnoDialogControl::modified(
649 const lang::EventObject
& /*rEvent*/ )
650 throw (RuntimeException
, std::exception
)
652 ImplUpdateResourceResolver();
655 void UnoDialogControl::ImplModelPropertiesChanged( const Sequence
< PropertyChangeEvent
>& rEvents
) throw(RuntimeException
)
657 sal_Int32 nLen
= rEvents
.getLength();
658 for( sal_Int32 i
= 0; i
< nLen
; i
++ )
660 const PropertyChangeEvent
& rEvt
= rEvents
.getConstArray()[i
];
661 Reference
< XControlModel
> xModel( rEvt
.Source
, UNO_QUERY
);
662 bool bOwnModel
= (XControlModel
*)xModel
.get() == (XControlModel
*)getModel().get();
663 if ( bOwnModel
&& rEvt
.PropertyName
== "ImageURL" )
666 Reference
< graphic::XGraphic
> xGraphic
;
667 if (( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL
) ) >>= aImageURL
) &&
668 ( !aImageURL
.isEmpty() ))
670 OUString absoluteUrl
= aImageURL
;
671 if ( !aImageURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX
) )
673 absoluteUrl
= getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL
)),
674 uno::makeAny(aImageURL
));
676 xGraphic
= ImageHelper::getGraphicFromURL_nothrow( absoluteUrl
);
678 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC
), uno::makeAny( xGraphic
), true );
682 ControlContainerBase::ImplModelPropertiesChanged(rEvents
);
686 // class MultiPageControl
688 UnoMultiPageControl::UnoMultiPageControl( const uno::Reference
< uno::XComponentContext
>& rxContext
) : ControlContainerBase(rxContext
), maTabListeners( *this )
690 maComponentInfos
.nWidth
= 280;
691 maComponentInfos
.nHeight
= 400;
694 UnoMultiPageControl::~UnoMultiPageControl()
699 void SAL_CALL
UnoMultiPageControl::inserted( SAL_UNUSED_PARAMETER ::sal_Int32
) throw (RuntimeException
, std::exception
)
702 void SAL_CALL
UnoMultiPageControl::removed( SAL_UNUSED_PARAMETER ::sal_Int32
) throw (RuntimeException
, std::exception
)
705 void SAL_CALL
UnoMultiPageControl::changed( SAL_UNUSED_PARAMETER ::sal_Int32
,
706 SAL_UNUSED_PARAMETER
const Sequence
< NamedValue
>& ) throw (RuntimeException
, std::exception
)
709 void SAL_CALL
UnoMultiPageControl::activated( ::sal_Int32 ID
) throw (RuntimeException
, std::exception
)
711 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE
), uno::makeAny( ID
), false );
714 void SAL_CALL
UnoMultiPageControl::deactivated( SAL_UNUSED_PARAMETER ::sal_Int32
) throw (RuntimeException
, std::exception
)
717 void SAL_CALL
UnoMultiPageControl::disposing(const EventObject
&) throw (RuntimeException
, std::exception
)
721 void SAL_CALL
UnoMultiPageControl::dispose() throw (RuntimeException
, std::exception
)
723 lang::EventObject aEvt
;
724 aEvt
.Source
= (::cppu::OWeakObject
*)this;
725 maTabListeners
.disposeAndClear( aEvt
);
726 ControlContainerBase::dispose();
729 // com::sun::star::awt::XSimpleTabController
730 ::sal_Int32 SAL_CALL
UnoMultiPageControl::insertTab() throw (RuntimeException
, std::exception
)
732 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
733 if ( !xMultiPage
.is() )
734 throw RuntimeException();
735 return xMultiPage
->insertTab();
738 void SAL_CALL
UnoMultiPageControl::removeTab( ::sal_Int32 ID
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
740 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
741 if ( !xMultiPage
.is() )
742 throw RuntimeException();
743 xMultiPage
->removeTab( ID
);
746 void SAL_CALL
UnoMultiPageControl::setTabProps( ::sal_Int32 ID
, const Sequence
< NamedValue
>& Properties
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
748 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
749 if ( !xMultiPage
.is() )
750 throw RuntimeException();
751 xMultiPage
->setTabProps( ID
, Properties
);
754 Sequence
< NamedValue
> SAL_CALL
UnoMultiPageControl::getTabProps( ::sal_Int32 ID
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
756 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
757 if ( !xMultiPage
.is() )
758 throw RuntimeException();
759 return xMultiPage
->getTabProps( ID
);
762 void SAL_CALL
UnoMultiPageControl::activateTab( ::sal_Int32 ID
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
764 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
765 if ( !xMultiPage
.is() )
766 throw RuntimeException();
767 xMultiPage
->activateTab( ID
);
768 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE
), uno::makeAny( ID
), true );
772 ::sal_Int32 SAL_CALL
UnoMultiPageControl::getActiveTabID() throw (RuntimeException
, std::exception
)
774 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
775 if ( !xMultiPage
.is() )
776 throw RuntimeException();
777 return xMultiPage
->getActiveTabID();
780 void SAL_CALL
UnoMultiPageControl::addTabListener( const Reference
< XTabListener
>& Listener
) throw (RuntimeException
, std::exception
)
782 maTabListeners
.addInterface( Listener
);
783 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
784 if ( xMultiPage
.is() && maTabListeners
.getLength() == 1 )
785 xMultiPage
->addTabListener( &maTabListeners
);
788 void SAL_CALL
UnoMultiPageControl::removeTabListener( const Reference
< XTabListener
>& Listener
) throw (RuntimeException
, std::exception
)
790 Reference
< XSimpleTabController
> xMultiPage( getPeer(), UNO_QUERY
);
791 if ( xMultiPage
.is() && maTabListeners
.getLength() == 1 )
792 xMultiPage
->removeTabListener( &maTabListeners
);
793 maTabListeners
.removeInterface( Listener
);
797 // lang::XTypeProvider
798 IMPL_XTYPEPROVIDER_START( UnoMultiPageControl
)
799 cppu::UnoType
<awt::XSimpleTabController
>::get(),
800 cppu::UnoType
<awt::XTabListener
>::get(),
801 ControlContainerBase::getTypes()
802 IMPL_XTYPEPROVIDER_END
805 uno::Any
UnoMultiPageControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
807 uno::Any aRet
= ::cppu::queryInterface( rType
,
808 (static_cast< awt::XTabListener
* >(this)), (static_cast< awt::XSimpleTabController
* >(this)) );
809 return (aRet
.hasValue() ? aRet
: ControlContainerBase::queryAggregation( rType
));
812 OUString
UnoMultiPageControl::GetComponentServiceName()
814 bool bDecoration( true );
815 ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION
)) >>= bDecoration
;
817 return OUString("tabcontrol");
818 // Hopefully we can tweak the tabcontrol to display without tabs
819 return OUString("tabcontrolnotabs");
822 void UnoMultiPageControl::bindPage( const uno::Reference
< awt::XControl
>& _rxControl
)
824 uno::Reference
< awt::XWindowPeer
> xPage( _rxControl
->getPeer() );
825 uno::Reference
< awt::XSimpleTabController
> xTabCntrl( getPeer(), uno::UNO_QUERY
);
826 uno::Reference
< beans::XPropertySet
> xProps( _rxControl
->getModel(), uno::UNO_QUERY
);
828 VCLXTabPage
* pXPage
= dynamic_cast< VCLXTabPage
* >( xPage
.get() );
829 TabPage
* pPage
= pXPage
? pXPage
->getTabPage() : NULL
;
830 if ( xTabCntrl
.is() && pPage
)
832 VCLXMultiPage
* pXTab
= dynamic_cast< VCLXMultiPage
* >( xTabCntrl
.get() );
836 xProps
->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE
) ) >>= sTitle
;
837 pXTab
->insertTab( pPage
, sTitle
);
843 void UnoMultiPageControl::createPeer( const Reference
< XToolkit
> & rxToolkit
, const Reference
< XWindowPeer
> & rParentPeer
) throw(RuntimeException
, std::exception
)
845 SolarMutexGuard aSolarGuard
;
847 UnoControlContainer::createPeer( rxToolkit
, rParentPeer
);
849 uno::Sequence
< uno::Reference
< awt::XControl
> > aCtrls
= getControls();
850 sal_uInt32 nCtrls
= aCtrls
.getLength();
851 for( sal_uInt32 n
= 0; n
< nCtrls
; n
++ )
852 bindPage( aCtrls
[ n
] );
853 sal_Int32
nActiveTab(0);
854 Reference
< XPropertySet
> xMultiProps( getModel(), UNO_QUERY
);
855 xMultiProps
->getPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE
) ) >>= nActiveTab
;
857 uno::Reference
< awt::XSimpleTabController
> xTabCntrl( getPeer(), uno::UNO_QUERY
);
858 if ( xTabCntrl
.is() )
860 xTabCntrl
->addTabListener( this );
861 if ( nActiveTab
&& nCtrls
) // Ensure peer is initialise with correct activated tab
863 xTabCntrl
->activateTab( nActiveTab
);
864 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE
), uno::makeAny( nActiveTab
), true );
869 void UnoMultiPageControl::impl_createControlPeerIfNecessary( const uno::Reference
< awt::XControl
>& _rxControl
)
871 OSL_PRECOND( _rxControl
.is(), "UnoMultiPageControl::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
873 // if the container already has a peer, then also create a peer for the control
874 uno::Reference
< awt::XWindowPeer
> xMyPeer( getPeer() );
878 _rxControl
->createPeer( NULL
, xMyPeer
);
879 bindPage( _rxControl
);
880 ImplActivateTabControllers();
885 // ------------- UnoMultiPageModel -----------------
887 UnoMultiPageModel::UnoMultiPageModel( const Reference
< XComponentContext
>& rxContext
) : ControlModelContainerBase( rxContext
)
889 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
890 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
891 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
892 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
894 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
895 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
896 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
897 ImplRegisterProperty( BASEPROPERTY_SIZEABLE
);
898 //ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
899 ImplRegisterProperty( BASEPROPERTY_MULTIPAGEVALUE
);
900 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
901 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
);
905 ImplRegisterProperty( BASEPROPERTY_MOVEABLE
, aBool
);
906 ImplRegisterProperty( BASEPROPERTY_CLOSEABLE
, aBool
);
907 ImplRegisterProperty( BASEPROPERTY_DECORATION
, aBool
);
908 // MultiPage Control has the tab stop property. And the default value is True.
909 ImplRegisterProperty( BASEPROPERTY_TABSTOP
, aBool
);
911 uno::Reference
< XNameContainer
> xNameCont
= new SimpleNamedThingContainer
< XControlModel
>();
912 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
, uno::makeAny( xNameCont
) );
915 UnoMultiPageModel::UnoMultiPageModel( const UnoMultiPageModel
& rModel
)
916 : ControlModelContainerBase( rModel
)
920 UnoMultiPageModel::~UnoMultiPageModel()
925 UnoMultiPageModel::Clone() const
927 // clone the container itself
928 UnoMultiPageModel
* pClone
= new UnoMultiPageModel( *this );
929 Clone_Impl( *pClone
);
933 OUString
UnoMultiPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
935 return OUString( "com.sun.star.awt.UnoMultiPageModel" );
938 uno::Any
UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
940 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
943 aAny
<<= OUString( "com.sun.star.awt.UnoControlMultiPage" );
946 return ControlModelContainerBase::ImplGetDefaultValue( nPropId
);
949 ::cppu::IPropertyArrayHelper
& UnoMultiPageModel::getInfoHelper()
951 static UnoPropertyArrayHelper
* pHelper
= NULL
;
954 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
955 pHelper
= new UnoPropertyArrayHelper( aIDs
);
960 // beans::XMultiPropertySet
961 uno::Reference
< beans::XPropertySetInfo
> UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
963 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
967 void UnoMultiPageModel::insertByName( const OUString
& aName
, const Any
& aElement
) throw(IllegalArgumentException
, ElementExistException
, WrappedTargetException
, RuntimeException
, std::exception
)
969 Reference
< XServiceInfo
> xInfo
;
973 throw IllegalArgumentException();
975 // Only a Page model can be inserted into the multipage
976 if ( !xInfo
->supportsService( "com.sun.star.awt.UnoPageModel" ) )
977 throw IllegalArgumentException();
979 return ControlModelContainerBase::insertByName( aName
, aElement
);
983 sal_Bool SAL_CALL
UnoMultiPageModel::getGroupControl( ) throw (RuntimeException
, std::exception
)
989 // class UnoPageControl
991 UnoPageControl::UnoPageControl( const uno::Reference
< uno::XComponentContext
>& rxContext
) : ControlContainerBase(rxContext
)
993 maComponentInfos
.nWidth
= 280;
994 maComponentInfos
.nHeight
= 400;
997 UnoPageControl::~UnoPageControl()
1001 OUString
UnoPageControl::GetComponentServiceName()
1003 return OUString("tabpage");
1007 // ------------- UnoPageModel -----------------
1009 UnoPageModel::UnoPageModel( const Reference
< XComponentContext
>& rxContext
) : ControlModelContainerBase( rxContext
)
1011 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1012 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
1013 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1014 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1016 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1017 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1018 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1019 ImplRegisterProperty( BASEPROPERTY_TITLE
);
1020 ImplRegisterProperty( BASEPROPERTY_SIZEABLE
);
1021 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1022 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
);
1023 // ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
1027 ImplRegisterProperty( BASEPROPERTY_MOVEABLE
, aBool
);
1028 ImplRegisterProperty( BASEPROPERTY_CLOSEABLE
, aBool
);
1029 //ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
1031 uno::Reference
< XNameContainer
> xNameCont
= new SimpleNamedThingContainer
< XControlModel
>();
1032 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
, uno::makeAny( xNameCont
) );
1035 UnoPageModel::UnoPageModel( const UnoPageModel
& rModel
)
1036 : ControlModelContainerBase( rModel
)
1040 UnoPageModel::~UnoPageModel()
1045 UnoPageModel::Clone() const
1047 // clone the container itself
1048 UnoPageModel
* pClone
= new UnoPageModel( *this );
1049 Clone_Impl( *pClone
);
1053 OUString
UnoPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1055 return OUString( "com.sun.star.awt.UnoPageModel" );
1058 uno::Any
UnoPageModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1060 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1063 aAny
<<= OUString( "com.sun.star.awt.UnoControlPage" );
1066 return ControlModelContainerBase::ImplGetDefaultValue( nPropId
);
1069 ::cppu::IPropertyArrayHelper
& UnoPageModel::getInfoHelper()
1071 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1074 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1075 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1080 // beans::XMultiPropertySet
1081 uno::Reference
< beans::XPropertySetInfo
> UnoPageModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
1083 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1088 sal_Bool SAL_CALL
UnoPageModel::getGroupControl( ) throw (RuntimeException
, std::exception
)
1096 // class UnoFrameControl
1098 UnoFrameControl::UnoFrameControl( const uno::Reference
< uno::XComponentContext
>& rxContext
) : ControlContainerBase(rxContext
)
1100 maComponentInfos
.nWidth
= 280;
1101 maComponentInfos
.nHeight
= 400;
1104 UnoFrameControl::~UnoFrameControl()
1108 OUString
UnoFrameControl::GetComponentServiceName()
1110 return OUString("frame");
1113 void UnoFrameControl::ImplSetPosSize( Reference
< XControl
>& rxCtrl
)
1115 bool bOwnCtrl
= false;
1117 if ( rxCtrl
.get() == Reference
<XControl
>( this ).get() )
1119 Reference
< XPropertySet
> xProps( getModel(), UNO_QUERY
);
1120 //xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
1121 xProps
->getPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
) ) >>= sTitle
;
1123 ControlContainerBase::ImplSetPosSize( rxCtrl
);
1124 Reference
< XWindow
> xW( rxCtrl
, UNO_QUERY
);
1125 if ( !bOwnCtrl
&& xW
.is() && !sTitle
.isEmpty() )
1127 awt::Rectangle aSizePos
= xW
->getPosSize();
1129 sal_Int32 nX
= aSizePos
.X
, nY
= aSizePos
.Y
, nWidth
= aSizePos
.Width
, nHeight
= aSizePos
.Height
;
1130 // Retrieve the values set by the base class
1131 OutputDevice
*pOutDev
= Application::GetDefaultDevice();
1134 if ( !bOwnCtrl
&& !sTitle
.isEmpty() )
1136 // Adjust Y based on height of Title
1138 aRect
= pOutDev
->GetTextRect( aRect
, sTitle
);
1139 nY
= nY
+ ( aRect
.GetHeight() / 2 );
1144 Reference
< XWindowPeer
> xPeer
= ImplGetCompatiblePeer( true );
1145 Reference
< XDevice
> xD( xPeer
, UNO_QUERY
);
1147 SimpleFontMetric aFM
;
1149 Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR
) );
1152 if ( !aFD
.StyleName
.isEmpty() )
1154 Reference
< XFont
> xFont
= xD
->getFont( aFD
);
1155 aFM
= xFont
->getFontMetric();
1159 Reference
< XGraphics
> xG
= xD
->createGraphics();
1160 aFM
= xG
->getFontMetric();
1163 sal_Int16 nH
= aFM
.Ascent
+ aFM
.Descent
;
1164 if ( !bOwnCtrl
&& !sTitle
.isEmpty() )
1165 // offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
1166 nY
= nY
+ ( nH
/ 8); // how do I test this
1168 xW
->setPosSize( nX
, nY
, nWidth
, nHeight
, PosSize::POSSIZE
);
1172 // ------------- UnoFrameModel -----------------
1174 UnoFrameModel::UnoFrameModel( const Reference
< XComponentContext
>& rxContext
) : ControlModelContainerBase( rxContext
)
1176 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1177 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
1178 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1179 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1180 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1181 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1182 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1183 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1184 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1185 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1186 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1187 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
);
1188 ImplRegisterProperty( BASEPROPERTY_HSCROLL
);
1189 ImplRegisterProperty( BASEPROPERTY_VSCROLL
);
1190 ImplRegisterProperty( BASEPROPERTY_SCROLLWIDTH
);
1191 ImplRegisterProperty( BASEPROPERTY_SCROLLHEIGHT
);
1192 ImplRegisterProperty( BASEPROPERTY_SCROLLTOP
);
1193 ImplRegisterProperty( BASEPROPERTY_SCROLLLEFT
);
1196 uno::Reference
< XNameContainer
> xNameCont
= new SimpleNamedThingContainer
< XControlModel
>();
1197 ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES
, uno::makeAny( xNameCont
) );
1200 UnoFrameModel::UnoFrameModel( const UnoFrameModel
& rModel
)
1201 : ControlModelContainerBase( rModel
)
1205 UnoFrameModel::~UnoFrameModel()
1210 UnoFrameModel::Clone() const
1212 // clone the container itself
1213 UnoFrameModel
* pClone
= new UnoFrameModel( *this );
1214 Clone_Impl( *pClone
);
1218 OUString
UnoFrameModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1220 return OUString( "com.sun.star.awt.UnoFrameModel" );
1223 uno::Any
UnoFrameModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1228 case BASEPROPERTY_DEFAULTCONTROL
:
1230 aAny
<<= OUString( "com.sun.star.awt.UnoControlFrame" );
1233 case BASEPROPERTY_SCROLLWIDTH
:
1234 case BASEPROPERTY_SCROLLHEIGHT
:
1235 case BASEPROPERTY_SCROLLTOP
:
1236 case BASEPROPERTY_SCROLLLEFT
:
1237 aAny
<<= sal_Int32(0);
1239 case BASEPROPERTY_USERFORMCONTAINEES
:
1241 uno::Reference
< XNameContainer
> xNameCont
= new SimpleNamedThingContainer
< XControlModel
>();
1242 return makeAny( xNameCont
);
1245 return ControlModelContainerBase::ImplGetDefaultValue( nPropId
);
1248 ::cppu::IPropertyArrayHelper
& UnoFrameModel::getInfoHelper()
1250 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1253 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1254 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1259 // beans::XMultiPropertySet
1260 uno::Reference
< beans::XPropertySetInfo
> UnoFrameModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
1262 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1266 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1267 stardiv_Toolkit_UnoControlDialogModel_get_implementation(
1268 css::uno::XComponentContext
*context
,
1269 css::uno::Sequence
<css::uno::Any
> const &)
1271 return cppu::acquire(new OGeometryControlModel
<UnoControlDialogModel
>(context
));
1274 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1275 stardiv_Toolkit_UnoDialogControl_get_implementation(
1276 css::uno::XComponentContext
*context
,
1277 css::uno::Sequence
<css::uno::Any
> const &)
1279 return cppu::acquire(new UnoDialogControl(context
));
1282 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1283 stardiv_Toolkit_UnoMultiPageControl_get_implementation(
1284 css::uno::XComponentContext
*context
,
1285 css::uno::Sequence
<css::uno::Any
> const &)
1287 return cppu::acquire(new UnoMultiPageControl(context
));
1290 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1291 stardiv_Toolkit_UnoMultiPageModel_get_implementation(
1292 css::uno::XComponentContext
*context
,
1293 css::uno::Sequence
<css::uno::Any
> const &)
1295 return cppu::acquire(new UnoMultiPageModel(context
));
1298 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1299 stardiv_Toolkit_UnoPageControl_get_implementation(
1300 css::uno::XComponentContext
*context
,
1301 css::uno::Sequence
<css::uno::Any
> const &)
1303 return cppu::acquire(new UnoPageControl(context
));
1306 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1307 stardiv_Toolkit_UnoPageModel_get_implementation(
1308 css::uno::XComponentContext
*context
,
1309 css::uno::Sequence
<css::uno::Any
> const &)
1311 return cppu::acquire(new UnoPageModel(context
));
1314 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1315 stardiv_Toolkit_UnoFrameControl_get_implementation(
1316 css::uno::XComponentContext
*context
,
1317 css::uno::Sequence
<css::uno::Any
> const &)
1319 return cppu::acquire(new UnoFrameControl(context
));
1322 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1323 stardiv_Toolkit_UnoFrameModel_get_implementation(
1324 css::uno::XComponentContext
*context
,
1325 css::uno::Sequence
<css::uno::Any
> const &)
1327 return cppu::acquire(new UnoFrameModel(context
));
1330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */