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

Generated by: LCOV version 1.10