1*b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b0724fc6SAndrew Rist * distributed with this work for additional information 6*b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9*b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15*b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17*b0724fc6SAndrew Rist * specific language governing permissions and limitations 18*b0724fc6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b0724fc6SAndrew Rist *************************************************************/ 21*b0724fc6SAndrew Rist 22*b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_toolkit.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/svapp.hxx> 28cdf0e10cSrcweir #include <vcl/window.hxx> 29cdf0e10cSrcweir #include <vcl/wall.hxx> 30cdf0e10cSrcweir #include <vos/mutex.hxx> 31cdf0e10cSrcweir #include <toolkit/controls/dialogcontrol.hxx> 32cdf0e10cSrcweir #include <toolkit/helper/property.hxx> 33cdf0e10cSrcweir #include <toolkit/helper/unopropertyarrayhelper.hxx> 34cdf0e10cSrcweir #include <toolkit/controls/stdtabcontroller.hxx> 35cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 36cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 37cdf0e10cSrcweir #include <com/sun/star/resource/XStringResourceResolver.hpp> 38cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 39cdf0e10cSrcweir #include <tools/list.hxx> 40cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 41cdf0e10cSrcweir #include <tools/debug.hxx> 42cdf0e10cSrcweir #include <tools/diagnose_ex.h> 43cdf0e10cSrcweir #include <comphelper/sequence.hxx> 44cdf0e10cSrcweir #include <vcl/svapp.hxx> 45cdf0e10cSrcweir #include <vcl/outdev.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 48cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 49cdf0e10cSrcweir #include <vcl/graph.hxx> 50cdf0e10cSrcweir #include <vcl/image.hxx> 51cdf0e10cSrcweir #include <map> 52cdf0e10cSrcweir #include <algorithm> 53cdf0e10cSrcweir #include <functional> 54cdf0e10cSrcweir #include "tools/urlobj.hxx" 55cdf0e10cSrcweir #include "osl/file.hxx" 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace ::com::sun::star; 58cdf0e10cSrcweir using namespace ::com::sun::star::uno; 59cdf0e10cSrcweir using namespace ::com::sun::star::awt; 60cdf0e10cSrcweir using namespace ::com::sun::star::lang; 61cdf0e10cSrcweir using namespace ::com::sun::star::container; 62cdf0e10cSrcweir using namespace ::com::sun::star::beans; 63cdf0e10cSrcweir using namespace ::com::sun::star::util; 64cdf0e10cSrcweir 65cdf0e10cSrcweir #define PROPERTY_DIALOGSOURCEURL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" )) 66cdf0e10cSrcweir #define PROPERTY_IMAGEURL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ImageURL" )) 67cdf0e10cSrcweir #define PROPERTY_GRAPHIC ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Graphic" )) 68cdf0e10cSrcweir // 69cdf0e10cSrcweir ////HELPER 70cdf0e10cSrcweir ::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir // ---------------------------------------------------- 73cdf0e10cSrcweir // class UnoControlDialogModel 74cdf0e10cSrcweir // ---------------------------------------------------- 75cdf0e10cSrcweir UnoControlDialogModel::UnoControlDialogModel( const Reference< XMultiServiceFactory >& i_factory ) 76cdf0e10cSrcweir :ControlModelContainerBase( i_factory ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); 79cdf0e10cSrcweir // ImplRegisterProperty( BASEPROPERTY_BORDER ); 80cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); 81cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLED ); 82cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); 83cdf0e10cSrcweir // ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); 84cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); 85cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPURL ); 86cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_TITLE ); 87cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_SIZEABLE ); 88cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DESKTOP_AS_PARENT ); 89cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DECORATION ); 90cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL ); 91cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_GRAPHIC ); 92cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_IMAGEURL ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir Any aBool; 95cdf0e10cSrcweir aBool <<= (sal_Bool) sal_True; 96cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool ); 97cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel& rModel ) 101cdf0e10cSrcweir : ControlModelContainerBase( rModel ) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir UnoControlDialogModel::~UnoControlDialogModel() 106cdf0e10cSrcweir { 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir UnoControlModel* UnoControlDialogModel::Clone() const 110cdf0e10cSrcweir { 111cdf0e10cSrcweir // clone the container itself 112cdf0e10cSrcweir UnoControlDialogModel* pClone = new UnoControlDialogModel( *this ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir Clone_Impl(*pClone); 115cdf0e10cSrcweir 116cdf0e10cSrcweir return pClone; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir 120cdf0e10cSrcweir ::rtl::OUString UnoControlDialogModel::getServiceName( ) throw(RuntimeException) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialogModel ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir Any UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 126cdf0e10cSrcweir { 127cdf0e10cSrcweir Any aAny; 128cdf0e10cSrcweir 129cdf0e10cSrcweir switch ( nPropId ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir case BASEPROPERTY_DEFAULTCONTROL: 132cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialog ); 133cdf0e10cSrcweir break; 134cdf0e10cSrcweir default: 135cdf0e10cSrcweir aAny = UnoControlModel::ImplGetDefaultValue( nPropId ); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir return aAny; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlDialogModel::getInfoHelper() 142cdf0e10cSrcweir { 143cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 144cdf0e10cSrcweir if ( !pHelper ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 147cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir return *pHelper; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir // XMultiPropertySet 153cdf0e10cSrcweir Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo( ) throw(RuntimeException) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 156cdf0e10cSrcweir return xInfo; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir // ============================================================================ 160cdf0e10cSrcweir // = class UnoDialogControl 161cdf0e10cSrcweir // ============================================================================ 162cdf0e10cSrcweir 163cdf0e10cSrcweir UnoDialogControl::UnoDialogControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) 164cdf0e10cSrcweir :UnoDialogControl_Base( i_factory ) 165cdf0e10cSrcweir ,maTopWindowListeners( *this ) 166cdf0e10cSrcweir ,mbWindowListener(false) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir maComponentInfos.nWidth = 300; 169cdf0e10cSrcweir maComponentInfos.nHeight = 450; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir UnoDialogControl::~UnoDialogControl() 173cdf0e10cSrcweir { 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir ::rtl::OUString UnoDialogControl::GetComponentServiceName() 177cdf0e10cSrcweir { 178cdf0e10cSrcweir 179cdf0e10cSrcweir sal_Bool bDecoration( sal_True ); 180cdf0e10cSrcweir ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration; 181cdf0e10cSrcweir if ( bDecoration ) 182cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "Dialog" ); 183cdf0e10cSrcweir else 184cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "TabPage" ); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir void UnoDialogControl::dispose() throw(RuntimeException) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir EventObject aEvt; 192cdf0e10cSrcweir aEvt.Source = static_cast< ::cppu::OWeakObject* >( this ); 193cdf0e10cSrcweir maTopWindowListeners.disposeAndClear( aEvt ); 194cdf0e10cSrcweir ControlContainerBase::dispose(); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir void SAL_CALL UnoDialogControl::disposing( 198cdf0e10cSrcweir const EventObject& Source ) 199cdf0e10cSrcweir throw(RuntimeException) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir ControlContainerBase::disposing( Source ); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir // #Can we move all the Resource stuff to the ControlContainerBase ? 207cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 208cdf0e10cSrcweir sal_Bool bRet = ControlContainerBase::setModel( rxModel ); 209cdf0e10cSrcweir ImplStartListingForResourceEvents(); 210cdf0e10cSrcweir return bRet; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 216cdf0e10cSrcweir 217cdf0e10cSrcweir UnoControlContainer::createPeer( rxToolkit, rParentPeer ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir Reference < XTopWindow > xTW( getPeer(), UNO_QUERY ); 220cdf0e10cSrcweir if ( xTW.is() ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir xTW->setMenuBar( mxMenuBar ); 223cdf0e10cSrcweir 224cdf0e10cSrcweir if ( !mbWindowListener ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY ); 227cdf0e10cSrcweir addWindowListener( xWL ); 228cdf0e10cSrcweir mbWindowListener = true; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir if ( maTopWindowListeners.getLength() ) 232cdf0e10cSrcweir xTW->addTopWindowListener( &maTopWindowListeners ); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir sal_Bool bDecoration( sal_True ); 239cdf0e10cSrcweir ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration; 240cdf0e10cSrcweir if ( !bDecoration ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir // Now we have to manipulate the WindowDescriptor 243cdf0e10cSrcweir rDesc.WindowAttributes = rDesc.WindowAttributes | ::com::sun::star::awt::WindowAttribute::NODECORATION; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir // We have to set the graphic property before the peer 247cdf0e10cSrcweir // will be created. Otherwise the properties will be copied 248cdf0e10cSrcweir // into the peer via propertiesChangeEvents. As the order of 249cdf0e10cSrcweir // can lead to overwrites we have to set the graphic property 250cdf0e10cSrcweir // before the propertiesChangeEvents are sent! 251cdf0e10cSrcweir ::rtl::OUString aImageURL; 252cdf0e10cSrcweir Reference< graphic::XGraphic > xGraphic; 253cdf0e10cSrcweir if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) && 254cdf0e10cSrcweir ( aImageURL.getLength() > 0 )) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir ::rtl::OUString absoluteUrl = 257cdf0e10cSrcweir getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ), 258cdf0e10cSrcweir ImplGetPropertyValue( PROPERTY_IMAGEURL )); 259cdf0e10cSrcweir 260cdf0e10cSrcweir xGraphic = ControlContainerBase::Impl_getGraphicFromURL_nothrow( absoluteUrl ); 261cdf0e10cSrcweir ImplSetPropertyValue( PROPERTY_GRAPHIC, uno::makeAny( xGraphic ), sal_True ); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir void UnoDialogControl::addTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir maTopWindowListeners.addInterface( rxListener ); 268cdf0e10cSrcweir if( getPeer().is() && maTopWindowListeners.getLength() == 1 ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir Reference < XTopWindow > xTW( getPeer(), UNO_QUERY ); 271cdf0e10cSrcweir xTW->addTopWindowListener( &maTopWindowListeners ); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir void UnoDialogControl::removeTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir if( getPeer().is() && maTopWindowListeners.getLength() == 1 ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir Reference < XTopWindow > xTW( getPeer(), UNO_QUERY ); 280cdf0e10cSrcweir xTW->removeTopWindowListener( &maTopWindowListeners ); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir maTopWindowListeners.removeInterface( rxListener ); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir void UnoDialogControl::toFront( ) throw (RuntimeException) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 288cdf0e10cSrcweir if ( getPeer().is() ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir Reference< XTopWindow > xTW( getPeer(), UNO_QUERY ); 291cdf0e10cSrcweir if( xTW.is() ) 292cdf0e10cSrcweir xTW->toFront(); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir void UnoDialogControl::toBack( ) throw (RuntimeException) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 299cdf0e10cSrcweir if ( getPeer().is() ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir Reference< XTopWindow > xTW( getPeer(), UNO_QUERY ); 302cdf0e10cSrcweir if( xTW.is() ) 303cdf0e10cSrcweir xTW->toBack(); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) throw (RuntimeException) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 310cdf0e10cSrcweir mxMenuBar = rxMenuBar; 311cdf0e10cSrcweir if ( getPeer().is() ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir Reference< XTopWindow > xTW( getPeer(), UNO_QUERY ); 314cdf0e10cSrcweir if( xTW.is() ) 315cdf0e10cSrcweir xTW->setMenuBar( mxMenuBar ); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir } 318cdf0e10cSrcweir static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize ) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir ::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT ); 321cdf0e10cSrcweir return aTmp; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir // ::com::sun::star::awt::XWindowListener 324cdf0e10cSrcweir void SAL_CALL UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent& e ) 325cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir OutputDevice*pOutDev = Application::GetDefaultDevice(); 328cdf0e10cSrcweir DBG_ASSERT( pOutDev, "Missing Default Device!" ); 329cdf0e10cSrcweir if ( pOutDev && !mbSizeModified ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir // Currentley we are simply using MAP_APPFONT 332cdf0e10cSrcweir ::Size aAppFontSize( e.Width, e.Height ); 333cdf0e10cSrcweir 334cdf0e10cSrcweir Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); 335cdf0e10cSrcweir Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); 336cdf0e10cSrcweir OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" ); 337cdf0e10cSrcweir 338cdf0e10cSrcweir // #i87592 In design mode the drawing layer works with sizes with decoration. 339cdf0e10cSrcweir // Therefore we have to substract them before writing back to the properties (model). 340cdf0e10cSrcweir if ( xDialogDevice.is() && mbDesignMode ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir DeviceInfo aDeviceInfo( xDialogDevice->getInfo() ); 343cdf0e10cSrcweir aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; 344cdf0e10cSrcweir aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); 348cdf0e10cSrcweir 349cdf0e10cSrcweir // Remember that changes have been done by listener. No need to 350cdf0e10cSrcweir // update the position because of property change event. 351cdf0e10cSrcweir mbSizeModified = true; 352cdf0e10cSrcweir Sequence< rtl::OUString > aProps( 2 ); 353cdf0e10cSrcweir Sequence< Any > aValues( 2 ); 354cdf0e10cSrcweir // Properties in a sequence must be sorted! 355cdf0e10cSrcweir aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" )); 356cdf0e10cSrcweir aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" )); 357cdf0e10cSrcweir aValues[0] <<= aAppFontSize.Height(); 358cdf0e10cSrcweir aValues[1] <<= aAppFontSize.Width(); 359cdf0e10cSrcweir 360cdf0e10cSrcweir ImplSetPropertyValues( aProps, aValues, true ); 361cdf0e10cSrcweir mbSizeModified = false; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir void SAL_CALL UnoDialogControl::windowMoved( const ::com::sun::star::awt::WindowEvent& e ) 366cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir OutputDevice*pOutDev = Application::GetDefaultDevice(); 369cdf0e10cSrcweir DBG_ASSERT( pOutDev, "Missing Default Device!" ); 370cdf0e10cSrcweir if ( pOutDev && !mbPosModified ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir // Currentley we are simply using MAP_APPFONT 373cdf0e10cSrcweir Any aAny; 374cdf0e10cSrcweir ::Size aTmp( e.X, e.Y ); 375cdf0e10cSrcweir aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); 376cdf0e10cSrcweir 377cdf0e10cSrcweir // Remember that changes have been done by listener. No need to 378cdf0e10cSrcweir // update the position because of property change event. 379cdf0e10cSrcweir mbPosModified = true; 380cdf0e10cSrcweir Sequence< rtl::OUString > aProps( 2 ); 381cdf0e10cSrcweir Sequence< Any > aValues( 2 ); 382cdf0e10cSrcweir aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" )); 383cdf0e10cSrcweir aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" )); 384cdf0e10cSrcweir aValues[0] <<= aTmp.Width(); 385cdf0e10cSrcweir aValues[1] <<= aTmp.Height(); 386cdf0e10cSrcweir 387cdf0e10cSrcweir ImplSetPropertyValues( aProps, aValues, true ); 388cdf0e10cSrcweir mbPosModified = false; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir void SAL_CALL UnoDialogControl::windowShown( const EventObject& e ) throw (RuntimeException) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir (void)e; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir void SAL_CALL UnoDialogControl::windowHidden( const EventObject& e ) throw (RuntimeException) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir (void)e; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir void SAL_CALL UnoDialogControl::endDialog( ::sal_Int32 i_result ) throw (RuntimeException) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY ); 405cdf0e10cSrcweir if ( xPeerDialog.is() ) 406cdf0e10cSrcweir xPeerDialog->endDialog( i_result ); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir void SAL_CALL UnoDialogControl::setHelpId( const rtl::OUString& i_id ) throw (RuntimeException) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY ); 412cdf0e10cSrcweir if ( xPeerDialog.is() ) 413cdf0e10cSrcweir xPeerDialog->setHelpId( i_id ); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir void UnoDialogControl::setTitle( const ::rtl::OUString& Title ) throw(RuntimeException) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 419cdf0e10cSrcweir Any aAny; 420cdf0e10cSrcweir aAny <<= Title; 421cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ), aAny, sal_True ); 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir ::rtl::OUString UnoDialogControl::getTitle() throw(RuntimeException) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 427cdf0e10cSrcweir return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE ); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir sal_Int16 UnoDialogControl::execute() throw(RuntimeException) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 433cdf0e10cSrcweir sal_Int16 nDone = -1; 434cdf0e10cSrcweir if ( getPeer().is() ) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir Reference< XDialog > xDlg( getPeer(), UNO_QUERY ); 437cdf0e10cSrcweir if( xDlg.is() ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir GetComponentInfos().bVisible = sal_True; 440cdf0e10cSrcweir nDone = xDlg->execute(); 441cdf0e10cSrcweir GetComponentInfos().bVisible = sal_False; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir } 444cdf0e10cSrcweir return nDone; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir void UnoDialogControl::endExecute() throw(RuntimeException) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 450cdf0e10cSrcweir if ( getPeer().is() ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir Reference< XDialog > xDlg( getPeer(), UNO_QUERY ); 453cdf0e10cSrcweir if( xDlg.is() ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir xDlg->endExecute(); 456cdf0e10cSrcweir GetComponentInfos().bVisible = sal_False; 457cdf0e10cSrcweir } 458cdf0e10cSrcweir } 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir // XModifyListener 462cdf0e10cSrcweir void SAL_CALL UnoDialogControl::modified( 463cdf0e10cSrcweir const lang::EventObject& /*rEvent*/ ) 464cdf0e10cSrcweir throw (RuntimeException) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir ImplUpdateResourceResolver(); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir 469cdf0e10cSrcweir void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir sal_Int32 nLen = rEvents.getLength(); 472cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; i++ ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i]; 475cdf0e10cSrcweir Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY ); 476cdf0e10cSrcweir sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get(); 477cdf0e10cSrcweir if ( bOwnModel && rEvt.PropertyName.equalsAsciiL( "ImageURL", 8 )) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir ::rtl::OUString aImageURL; 480cdf0e10cSrcweir Reference< graphic::XGraphic > xGraphic; 481cdf0e10cSrcweir if (( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) ) >>= aImageURL ) && 482cdf0e10cSrcweir ( aImageURL.getLength() > 0 )) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir ::rtl::OUString absoluteUrl = 485cdf0e10cSrcweir getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL )), 486cdf0e10cSrcweir uno::makeAny(aImageURL)); 487cdf0e10cSrcweir 488cdf0e10cSrcweir xGraphic = Impl_getGraphicFromURL_nothrow( absoluteUrl ); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC), uno::makeAny( xGraphic ), sal_True ); 491cdf0e10cSrcweir break; 492cdf0e10cSrcweir } 493cdf0e10cSrcweir } 494cdf0e10cSrcweir ControlContainerBase::ImplModelPropertiesChanged(rEvents); 495cdf0e10cSrcweir } 496