LCOV - code coverage report
Current view: top level - libreoffice/toolkit/source/controls - dialogcontrol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 654 0.0 %
Date: 2012-12-17 Functions: 0 112 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10