summaryrefslogtreecommitdiff
path: root/toolkit/source/controls/dialogcontrol.cxx
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-11-03 23:10:43 +0000
committerNoel Power <noel.power@novell.com>2010-11-03 23:10:43 +0000
commit3ba9edf4164eb231a3f4208c0b234456a2e34e58 (patch)
tree6306af95841957acda7eebbcf80ee97f199dcbeb /toolkit/source/controls/dialogcontrol.cxx
parentfebd9e0c181be958688b4b04313b4a2d75fb5b29 (diff)
separation of new container controls and existing Dialog control & model
Diffstat (limited to 'toolkit/source/controls/dialogcontrol.cxx')
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx1923
1 files changed, 1089 insertions, 834 deletions
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index 031a4931f9c7..f1d720b91db1 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -326,8 +326,9 @@ UnoControlDialogModel::UnoControlDialogModel( bool regProps )
,maChangeListeners ( GetMutex() )
,mbGroupsUpToDate( sal_False ), mbAdjustingGraphic( false )
{
- if ( regProps )
- {
+ if ( !regProps ) // Register properties elsewhere ( probably in class derived from this )
+ return;
+
ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
// ImplRegisterProperty( BASEPROPERTY_BORDER );
ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
@@ -348,9 +349,9 @@ UnoControlDialogModel::UnoControlDialogModel( bool regProps )
aBool <<= (sal_Bool) sal_True;
ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
- uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
- ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
- }
+ // #TODO separate class for 'UserForm' ( instead of re-using Dialog ? )
+ uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
+ ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );
}
UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel& rModel )
@@ -391,7 +392,7 @@ Sequence< Type > UnoControlDialogModel::getTypes() throw(RuntimeException)
void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
{
- UnoControlDialogModel_Base::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+ UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
try
{
switch ( nHandle )
@@ -407,7 +408,7 @@ void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32
}
break;
- case BASEPROPERTY_GRAPHIC:
+ case BASEPROPERTY_GRAPHIC:
if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
{
mbAdjustingGraphic = true;
@@ -415,15 +416,14 @@ void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32
mbAdjustingGraphic = false;
}
break;
- }
+ }
}
catch( const ::com::sun::star::uno::Exception& )
{
- OSL_ENSURE( sal_False, "UnoControlDialogModel::setFastPropertyValue_NoBroadcast: caught an exception while setting ImageURL properties!" );
+ OSL_ENSURE( sal_False, "UnoControlDialogModel::setFastPropertyValue_NoBroadcast: caught an exception while setting Graphic/ImageURL properties!" );
}
}
-
Any UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{
Any aAny;
@@ -613,7 +613,7 @@ Sequence< ::rtl::OUString > UnoControlDialogModel::getAvailableServiceNames() th
static Sequence< ::rtl::OUString >* pNamesSeq = NULL;
if ( !pNamesSeq )
{
- pNamesSeq = new Sequence< ::rtl::OUString >( 25 );
+ pNamesSeq = new Sequence< ::rtl::OUString >( 26 );
::rtl::OUString* pNames = pNamesSeq->getArray();
pNames[0] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlEditModel );
pNames[1] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFormattedFieldModel );
@@ -636,11 +636,11 @@ Sequence< ::rtl::OUString > UnoControlDialogModel::getAvailableServiceNames() th
pNames[18] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedLineModel );
pNames[19] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRoadmapModel );
pNames[20] = ::rtl::OUString::createFromAscii( szServiceName_TreeControlModel );
-
pNames[21] = ::rtl::OUString::createFromAscii( szServiceName_GridControlModel );
pNames[22] = ::rtl::OUString::createFromAscii( szServiceName2_UnoSimpleAnimationControlModel );
pNames[23] = ::rtl::OUString::createFromAscii( szServiceName2_UnoThrobberControlModel );
pNames[24] = ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
+ pNames[25] = ::rtl::OUString::createFromAscii( szServiceName_UnoFrameModel );
}
return *pNamesSeq;
}
@@ -730,7 +730,6 @@ void UnoControlDialogModel::replaceByName( const ::rtl::OUString& aName, const A
UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName );
if ( maModels.end() == aElementPos )
lcl_throwNoSuchElementException();
-
// Dialog behaviour is to have all containee names unique ( MSO Userform is the same )
// With container controls you could have constructed an existing hierachy and are now
// add this to an existing container, in this case a name nested in the containment
@@ -752,7 +751,6 @@ void UnoControlDialogModel::replaceByName( const ::rtl::OUString& aName, const A
aElementPos->first = xNewModel;
startControlListening( xNewModel );
-
ContainerEvent aEvent;
aEvent.Source = *this;
aEvent.Element = aElement;
@@ -809,7 +807,7 @@ void UnoControlDialogModel::insertByName( const ::rtl::OUString& aName, const An
Reference< beans::XPropertySetInfo > xPropInfo = xProps.get()->getPropertySetInfo();
::rtl::OUString sImageSourceProperty = GetPropertyName( BASEPROPERTY_IMAGEURL );
- if ( xPropInfo.get()->hasPropertyByName( sImageSourceProperty ))
+ if ( xPropInfo.get()->hasPropertyByName( sImageSourceProperty ))
{
Any aUrl = xProps.get()->getPropertyValue( sImageSourceProperty );
@@ -835,7 +833,6 @@ void UnoControlDialogModel::insertByName( const ::rtl::OUString& aName, const An
lcl_throwIllegalArgumentException();
UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName );
-
if ( maModels.end() != aElementPos )
lcl_throwElementExistException();
@@ -850,10 +847,8 @@ void UnoControlDialogModel::insertByName( const ::rtl::OUString& aName, const An
if ( xAllChildren.is() )
updateUserFormChildren( xAllChildren, aName, Insert, xM );
-
maModels.push_back( UnoControlModelHolder( xM, aName ) );
-
mbGroupsUpToDate = sal_False;
startControlListening( xM );
@@ -893,7 +888,6 @@ void UnoControlDialogModel::removeByName( const ::rtl::OUString& aName ) throw(N
stopControlListening( aElementPos->first );
Reference< XPropertySet > xPS( aElementPos->first, UNO_QUERY );
maModels.erase( aElementPos );
-
mbGroupsUpToDate = sal_False;
if ( xPS.is() )
@@ -1552,620 +1546,855 @@ throw ( RuntimeException )
}
}
-static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize )
-{
- ::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT );
- return aTmp;
-}
+// ============================================================================
+// = class UnoDialogControl
+// ============================================================================
-// ----------------------------------------------------
-// class MultiPageControl
-// ----------------------------------------------------
-UnoMultiPageControl::UnoMultiPageControl() : maTabListeners( *this )
+UnoDialogControl::UnoDialogControl() :
+ maTopWindowListeners( *this ),
+ mbWindowListener(false),
+ mbSizeModified(false),
+ mbPosModified(false)
{
- maComponentInfos.nWidth = 280;
- maComponentInfos.nHeight = 400;
+ maComponentInfos.nWidth = 300;
+ maComponentInfos.nHeight = 450;
+ mxListener = new ResourceListener( Reference< util::XModifyListener >(
+ static_cast< OWeakObject* >( this ), UNO_QUERY ));
}
-UnoMultiPageControl::~UnoMultiPageControl()
+::rtl::OUString UnoDialogControl::GetComponentServiceName()
{
-}
-// XTabListener
-void SAL_CALL UnoMultiPageControl::inserted( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
-{
-}
-void SAL_CALL UnoMultiPageControl::removed( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
-{
-}
-void SAL_CALL UnoMultiPageControl::changed( ::sal_Int32 /*ID*/, const Sequence< NamedValue >& /*Properties*/ ) throw (RuntimeException)
-{
+ sal_Bool bDecoration( sal_True );
+ ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
+ if ( bDecoration )
+ return ::rtl::OUString::createFromAscii( "Dialog" );
+ else
+ return ::rtl::OUString::createFromAscii( "TabPage" );
}
-void SAL_CALL UnoMultiPageControl::activated( ::sal_Int32 ID ) throw (RuntimeException)
-{
- ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), sal_False );
-}
-void SAL_CALL UnoMultiPageControl::deactivated( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
-{
-}
-void SAL_CALL UnoMultiPageControl::disposing(const EventObject&) throw (RuntimeException)
+// XInterface
+Any UnoDialogControl::queryAggregation( const Type & rType ) throw(RuntimeException)
{
+ Any aRet( UnoDialogControl_IBase::queryInterface( rType ) );
+ return (aRet.hasValue() ? aRet : UnoControlContainer::queryAggregation( rType ));
}
-void SAL_CALL UnoMultiPageControl::dispose() throw (RuntimeException)
+// XTypeProvider
+IMPL_IMPLEMENTATION_ID( UnoDialogControl )
+Sequence< Type > UnoDialogControl::getTypes() throw(RuntimeException)
{
- lang::EventObject aEvt;
- aEvt.Source = (::cppu::OWeakObject*)this;
- maTabListeners.disposeAndClear( aEvt );
- UnoDialogContainerControl::dispose();
+ return ::comphelper::concatSequences(
+ UnoDialogControl_IBase::getTypes(),
+ UnoControlContainer::getTypes()
+ );
}
-// com::sun::star::awt::XSimpleTabController
-::sal_Int32 SAL_CALL UnoMultiPageControl::insertTab() throw (RuntimeException)
+void UnoDialogControl::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName )
{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( !xMultiPage.is() )
- throw RuntimeException();
- return xMultiPage->insertTab();
-}
+ Reference< XPropertySet > xP( rxModel, UNO_QUERY );
-void SAL_CALL UnoMultiPageControl::removeTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
-{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( !xMultiPage.is() )
- throw RuntimeException();
- xMultiPage->removeTab( ID );
-}
+ ::rtl::OUString aDefCtrl;
+ xP->getPropertyValue( GetPropertyName( BASEPROPERTY_DEFAULTCONTROL ) ) >>= aDefCtrl;
-void SAL_CALL UnoMultiPageControl::setTabProps( ::sal_Int32 ID, const Sequence< NamedValue >& Properties ) throw (IndexOutOfBoundsException, RuntimeException)
-{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( !xMultiPage.is() )
- throw RuntimeException();
- xMultiPage->setTabProps( ID, Properties );
-}
+ // Add our own resource resolver to a newly created control
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
+ rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
-Sequence< NamedValue > SAL_CALL UnoMultiPageControl::getTabProps( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
-{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( !xMultiPage.is() )
- throw RuntimeException();
- return xMultiPage->getTabProps( ID );
-}
+ Any aAny;
+ ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
-void SAL_CALL UnoMultiPageControl::activateTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
-{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( !xMultiPage.is() )
- throw RuntimeException();
- xMultiPage->activateTab( ID );
- ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), sal_True );
+ aAny <<= xStringResourceResolver;
+ xP->setPropertyValue( aPropName, aAny );
+
+ Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference < XControl > xCtrl( xMSF->createInstance( aDefCtrl ), UNO_QUERY );
+
+ DBG_ASSERT( xCtrl.is(), "UnoDialogControl::ImplInsertControl: could not create the control!" );
+ if ( xCtrl.is() )
+ {
+ xCtrl->setModel( rxModel );
+ addControl( rName, xCtrl );
+ // will implicitly call addingControl, where we can add the PropertiesChangeListener to the model
+ // (which we formerly did herein)
+ // 08.01.2001 - 96008 - fs@openoffice.org
+ ImplSetPosSize( xCtrl );
+ }
}
-::sal_Int32 SAL_CALL UnoMultiPageControl::getActiveTabID() throw (RuntimeException)
+void UnoDialogControl::ImplRemoveControl( Reference< XControlModel >& rxModel )
{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( !xMultiPage.is() )
- throw RuntimeException();
- return xMultiPage->getActiveTabID();
+ Sequence< Reference< XControl > > aControls = getControls();
+ Reference< XControl > xCtrl = StdTabController::FindControl( aControls, rxModel );
+ if ( xCtrl.is() )
+ removeControl( xCtrl );
}
-void SAL_CALL UnoMultiPageControl::addTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException)
+void UnoDialogControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
{
- maTabListeners.addInterface( Listener );
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
- xMultiPage->addTabListener( &maTabListeners );
+ Reference< XPropertySet > xP( rxCtrl->getModel(), UNO_QUERY );
+
+ sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) ) >>= nX;
+ xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ) ) >>= nY;
+ xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) >>= nWidth;
+ xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) >>= nHeight;
+
+ // Currentley we are simply using MAP_APPFONT
+ OutputDevice*pOutDev = Application::GetDefaultDevice();
+ DBG_ASSERT( pOutDev, "Missing Default Device!" );
+ if ( pOutDev )
+ {
+ ::Size aTmp( nX, nY );
+ aTmp = pOutDev->LogicToPixel( aTmp, MAP_APPFONT );
+ nX = aTmp.Width();
+ nY = aTmp.Height();
+ aTmp = ::Size( nWidth, nHeight );
+ aTmp = pOutDev->LogicToPixel( aTmp, MAP_APPFONT );
+ nWidth = aTmp.Width();
+ nHeight = aTmp.Height();
+ }
+ else
+ {
+ Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True );
+ Reference< XDevice > xD( xPeer, UNO_QUERY );
+
+ SimpleFontMetric aFM;
+ FontDescriptor aFD;
+ Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
+ aVal >>= aFD;
+ if ( aFD.StyleName.getLength() )
+ {
+ Reference< XFont > xFont = xD->getFont( aFD );
+ aFM = xFont->getFontMetric();
+ }
+ else
+ {
+ Reference< XGraphics > xG = xD->createGraphics();
+ aFM = xG->getFontMetric();
+ }
+
+ sal_Int16 nH = aFM.Ascent + aFM.Descent;
+ sal_Int16 nW = nH/2; // calculate avarage width?!
+
+ nX *= nW;
+ nX /= 4;
+ nWidth *= nW;
+ nWidth /= 4;
+ nY *= nH;
+ nY /= 8;
+ nHeight *= nH;
+ nHeight /= 8;
+ }
+ Reference < XWindow > xW( rxCtrl, UNO_QUERY );
+ xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
}
-void SAL_CALL UnoMultiPageControl::removeTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException)
+void UnoDialogControl::dispose() throw(RuntimeException)
{
- Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
- if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
- xMultiPage->removeTabListener( &maTabListeners );
- maTabListeners.removeInterface( Listener );
-}
+ SolarMutexGuard aSolarGuard;
+ EventObject aEvt;
+ aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
+ maTopWindowListeners.disposeAndClear( aEvt );
-// lang::XTypeProvider
-IMPL_XTYPEPROVIDER_START( UnoMultiPageControl )
- getCppuType( ( uno::Reference< awt::XSimpleTabController>* ) NULL ),
- getCppuType( ( uno::Reference< awt::XTabListener>* ) NULL ),
- UnoDialogContainerControl::getTypes()
-IMPL_XTYPEPROVIDER_END
+ // Notify our listener helper about dispose
+ // --- SAFE ---
+ ::osl::ResettableGuard< ::osl::Mutex > aGuard( GetMutex() );
+ Reference< XEventListener > xListener( mxListener, UNO_QUERY );
+ mxListener.clear();
+ aGuard.clear();
+ // --- SAFE ---
-// uno::XInterface
-uno::Any UnoMultiPageControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
-{
- uno::Any aRet = ::cppu::queryInterface( rType,
- SAL_STATIC_CAST( awt::XTabListener*, this ), SAL_STATIC_CAST( awt::XSimpleTabController*, this ) );
- return (aRet.hasValue() ? aRet : UnoDialogContainerControl::queryAggregation( rType ));
+ if ( xListener.is() )
+ xListener->disposing( aEvt );
+
+ UnoControlContainer::dispose();
}
-::rtl::OUString UnoMultiPageControl::GetComponentServiceName()
+void SAL_CALL UnoDialogControl::disposing(
+ const EventObject& Source )
+throw(RuntimeException)
{
- sal_Bool bDecoration( sal_True );
- ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
- if ( bDecoration )
- return ::rtl::OUString::createFromAscii( "tabcontrol" );
- // Hopefully we can tweak the tabcontrol to display without tabs
- return ::rtl::OUString::createFromAscii( "tabcontrolnotabs" );
+ rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
+
+ ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
+ Reference< XInterface > xIfac( xStringResourceResolver, UNO_QUERY );
+
+ if ( Source.Source == xIfac )
+ {
+ Any aAny;
+
+ // Reset resource resolver reference
+ ImplSetPropertyValue( aPropName, aAny, sal_True );
+ ImplUpdateResourceResolver();
+ }
+ else
+ {
+ UnoControlContainer::disposing( Source );
+ }
}
-void UnoMultiPageControl::bindPage( const uno::Reference< awt::XControl >& _rxControl )
+sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
{
- uno::Reference< awt::XWindowPeer > xPage( _rxControl->getPeer() );
- uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
- uno::Reference< beans::XPropertySet > xProps( _rxControl->getModel(), uno::UNO_QUERY );
+ SolarMutexGuard aSolarGuard;
- VCLXTabPage* pXPage = dynamic_cast< VCLXTabPage* >( xPage.get() );
- TabPage* pPage = pXPage ? pXPage->getTabPage() : NULL;
- if ( xTabCntrl.is() && pPage )
+ // destroy the old tab controller, if existent
+ if ( mxTabController.is() )
{
- VCLXMultiPage* pXTab = dynamic_cast< VCLXMultiPage* >( xTabCntrl.get() );
- if ( pXTab )
+ mxTabController->setModel( NULL ); // just to be sure, should not be necessary
+ removeTabController( mxTabController );
+ ::comphelper::disposeComponent( mxTabController ); // just to be sure, should not be necessary
+ mxTabController.clear();
+ }
+
+ if ( getModel().is() )
+ {
+ Sequence< Reference< XControl > > aControls = getControls();
+ const Reference< XControl >* pCtrls = aControls.getConstArray();
+ const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength();
+
+ for ( ; pCtrls < pCtrlsEnd; ++pCtrls )
+ removeControl( *pCtrls );
+ // will implicitly call removingControl, which will remove the PropertyChangeListener
+ // (which we formerly did herein)
+ // 08.01.2001 - 96008 - fs@openoffice.org
+
+ Reference< XContainer > xC( getModel(), UNO_QUERY );
+ if ( xC.is() )
+ xC->removeContainerListener( this );
+
+ Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY );
+ if ( xChangeNotifier.is() )
+ xChangeNotifier->removeChangesListener( this );
+ }
+
+ sal_Bool bRet = UnoControl::setModel( rxModel );
+
+ if ( getModel().is() )
+ {
+ Reference< XNameAccess > xNA( getModel(), UNO_QUERY );
+ if ( xNA.is() )
{
- rtl::OUString sTitle;
- xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
- pXTab->insertTab( pPage, sTitle);
+ Sequence< ::rtl::OUString > aNames = xNA->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_uInt32 nCtrls = aNames.getLength();
+
+ Reference< XControlModel > xCtrlModel;
+ for( sal_uInt32 n = 0; n < nCtrls; ++n, ++pNames )
+ {
+ xNA->getByName( *pNames ) >>= xCtrlModel;
+ ImplInsertControl( xCtrlModel, *pNames );
+ }
}
+
+ Reference< XContainer > xC( getModel(), UNO_QUERY );
+ if ( xC.is() )
+ xC->addContainerListener( this );
+
+ Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY );
+ if ( xChangeNotifier.is() )
+ xChangeNotifier->addChangesListener( this );
+ }
+
+ Reference< XTabControllerModel > xTabbing( getModel(), UNO_QUERY );
+ if ( xTabbing.is() )
+ {
+ mxTabController = new StdTabController;
+ mxTabController->setModel( xTabbing );
+ addTabController( mxTabController );
}
+ ImplStartListingForResourceEvents();
+ return bRet;
}
-void UnoMultiPageControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
+void UnoDialogControl::setDesignMode( sal_Bool bOn ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- UnoControlContainer::createPeer( rxToolkit, rParentPeer );
+ UnoControl::setDesignMode( bOn );
- uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
- sal_uInt32 nCtrls = aCtrls.getLength();
- for( sal_uInt32 n = 0; n < nCtrls; n++ )
- bindPage( aCtrls[ n ] );
- sal_Int32 nActiveTab(0);
- Reference< XPropertySet > xMultiProps( getModel(), UNO_QUERY );
- xMultiProps->getPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ) ) >>= nActiveTab;
+ Sequence< Reference< XControl > > xCtrls = getControls();
+ sal_Int32 nControls = xCtrls.getLength();
+ Reference< XControl >* pControls = xCtrls.getArray();
+ for ( sal_Int32 n = 0; n < nControls; n++ )
+ pControls[n]->setDesignMode( bOn );
- uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
- if ( xTabCntrl.is() )
+ // #109067# in design mode the tab controller is not notified about
+ // tab index changes, therefore the tab order must be activated
+ // when switching from design mode to live mode
+ if ( mxTabController.is() && !bOn )
+ mxTabController->activateTabOrder();
+}
+
+void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ UnoControlContainer::createPeer( rxToolkit, rParentPeer );
+
+ Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
+ if ( xTW.is() )
{
- xTabCntrl->addTabListener( this );
- if ( nActiveTab && nCtrls ) // Ensure peer is initialise with correct activated tab
+ xTW->setMenuBar( mxMenuBar );
+
+ if ( !mbWindowListener )
{
- xTabCntrl->activateTab( nActiveTab );
- ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( nActiveTab ), sal_True );
+ Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
+ addWindowListener( xWL );
+ mbWindowListener = true;
}
+
+ if ( maTopWindowListeners.getLength() )
+ xTW->addTopWindowListener( &maTopWindowListeners );
}
}
-void UnoMultiPageControl::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl)
+void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc )
{
- OSL_PRECOND( _rxControl.is(), "UnoMultiPageControl::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
-
- // if the container already has a peer, then also create a peer for the control
- uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
-
- if( xMyPeer.is() )
+ sal_Bool bDecoration( sal_True );
+ ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
+ if ( !bDecoration )
{
- _rxControl->createPeer( NULL, xMyPeer );
- bindPage( _rxControl );
- ImplActivateTabControllers();
+ // Now we have to manipulate the WindowDescriptor
+ rDesc.WindowAttributes = rDesc.WindowAttributes | ::com::sun::star::awt::WindowAttribute::NODECORATION;
}
-}
+ // We have to set the graphic property before the peer
+ // will be created. Otherwise the properties will be copied
+ // into the peer via propertiesChangeEvents. As the order of
+ // can lead to overwrites we have to set the graphic property
+ // before the propertiesChangeEvents are sent!
+ ::rtl::OUString aImageURL;
+ if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
+ ( aImageURL.getLength() > 0 ))
+ {
+ aImageURL =
+ getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
+ ImplGetPropertyValue( PROPERTY_IMAGEURL ));
-// ------------- UnoMultiPageModel -----------------
+ }
+ if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
+ ImplSetPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( aImageURL ), sal_True );
+}
-UnoMultiPageModel::UnoMultiPageModel() : UnoControlDialogModel( false )
+void UnoDialogControl::elementInserted( const ContainerEvent& Event ) throw(RuntimeException)
{
- ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
- ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
- ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
- ImplRegisterProperty( BASEPROPERTY_ENABLED );
+ SolarMutexGuard aSolarGuard;
- ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
- ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
- ImplRegisterProperty( BASEPROPERTY_HELPURL );
- ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
- //ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
- ImplRegisterProperty( BASEPROPERTY_MULTIPAGEVALUE );
- ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
- ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
+ Reference< XControlModel > xModel;
+ ::rtl::OUString aName;
- Any aBool;
- aBool <<= (sal_Bool) sal_True;
- ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
- ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
- ImplRegisterProperty( BASEPROPERTY_DECORATION, aBool );
- // MultiPage Control has the tab stop property. And the default value is True.
- ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
+ Event.Accessor >>= aName;
+ Event.Element >>= xModel;
+ ImplInsertControl( xModel, aName );
}
-UnoMultiPageModel::UnoMultiPageModel( const UnoMultiPageModel& rModel )
- : UnoControlDialogModel( rModel )
+void UnoDialogControl::elementRemoved( const ContainerEvent& Event ) throw(RuntimeException)
{
-}
+ SolarMutexGuard aSolarGuard;
-UnoMultiPageModel::~UnoMultiPageModel()
-{
+ Reference< XControlModel > xModel;
+ Event.Element >>= xModel;
+ if ( xModel.is() )
+ ImplRemoveControl( xModel );
}
-UnoControlModel*
-UnoMultiPageModel::Clone() const
+void UnoDialogControl::elementReplaced( const ContainerEvent& Event ) throw(RuntimeException)
{
- // clone the container itself
- UnoMultiPageModel* pClone = new UnoMultiPageModel( *this );
+ SolarMutexGuard aSolarGuard;
- // clone all children
- ::std::for_each(
- maModels.begin(), maModels.end(),
- CloneControlModel( pClone->maModels )
- );
+ Reference< XControlModel > xModel;
+ Event.ReplacedElement >>= xModel;
+ if ( xModel.is() )
+ ImplRemoveControl( xModel );
- return pClone;
+ ::rtl::OUString aName;
+ Event.Accessor >>= aName;
+ Event.Element >>= xModel;
+ ImplInsertControl( xModel, aName );
}
-::rtl::OUString UnoMultiPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
+void UnoDialogControl::addTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
{
- return ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
+ maTopWindowListeners.addInterface( rxListener );
+ if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
+ {
+ Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
+ xTW->addTopWindowListener( &maTopWindowListeners );
+ }
}
-uno::Any UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
+void UnoDialogControl::removeTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
{
- if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
+ if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
{
- uno::Any aAny;
- aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageControl );
- return aAny;
+ Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
+ xTW->removeTopWindowListener( &maTopWindowListeners );
}
- return UnoControlDialogModel::ImplGetDefaultValue( nPropId );
+ maTopWindowListeners.removeInterface( rxListener );
}
-::cppu::IPropertyArrayHelper& UnoMultiPageModel::getInfoHelper()
+void UnoDialogControl::toFront( ) throw (RuntimeException)
{
- static UnoPropertyArrayHelper* pHelper = NULL;
- if ( !pHelper )
+ SolarMutexGuard aSolarGuard;
+ if ( getPeer().is() )
{
- uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
- pHelper = new UnoPropertyArrayHelper( aIDs );
+ Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
+ if( xTW.is() )
+ xTW->toFront();
}
- return *pHelper;
}
-// beans::XMultiPropertySet
-uno::Reference< beans::XPropertySetInfo > UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
+void UnoDialogControl::toBack( ) throw (RuntimeException)
{
- static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
- return xInfo;
+ SolarMutexGuard aSolarGuard;
+ if ( getPeer().is() )
+ {
+ Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
+ if( xTW.is() )
+ xTW->toBack();
+ }
}
-void UnoMultiPageModel::insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) throw (RuntimeException)
{
- Reference< XServiceInfo > xInfo;
- aElement >>= xInfo;
-
- if ( !xInfo.is() )
- throw IllegalArgumentException();
-
- // Only a Page model can be inserted into the multipage
- if ( !xInfo->supportsService( rtl::OUString::createFromAscii( szServiceName_UnoPageModel ) ) )
- throw IllegalArgumentException();
-
- return UnoControlDialogModel::insertByName( aName, aElement );
+ SolarMutexGuard aSolarGuard;
+ mxMenuBar = rxMenuBar;
+ if ( getPeer().is() )
+ {
+ Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
+ if( xTW.is() )
+ xTW->setMenuBar( mxMenuBar );
+ }
}
-// ----------------------------------------------------------------------------
-sal_Bool SAL_CALL UnoMultiPageModel::getGroupControl( ) throw (RuntimeException)
+static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize )
{
- return sal_True;
+ ::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT );
+ return aTmp;
}
-// ----------------------------------------------------
-// class UnoPageControl
-// ----------------------------------------------------
-UnoPageControl::UnoPageControl()
+// ::com::sun::star::awt::XWindowListener
+void SAL_CALL UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent& e )
+throw (::com::sun::star::uno::RuntimeException)
{
- maComponentInfos.nWidth = 280;
- maComponentInfos.nHeight = 400;
-}
+ OutputDevice*pOutDev = Application::GetDefaultDevice();
+ DBG_ASSERT( pOutDev, "Missing Default Device!" );
+ if ( pOutDev && !mbSizeModified )
+ {
+ // Currentley we are simply using MAP_APPFONT
+ ::Size aAppFontSize( e.Width, e.Height );
-UnoPageControl::~UnoPageControl()
-{
-}
+ Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
+ Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
+ OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
+ if ( xDialogDevice.is() )
+ {
+ DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
+ aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
+ aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
+ }
-::rtl::OUString UnoPageControl::GetComponentServiceName()
-{
- return ::rtl::OUString::createFromAscii( "tabpage" );
-}
+ aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
+ // Remember that changes have been done by listener. No need to
+ // update the position because of property change event.
+ mbSizeModified = true;
+ Sequence< rtl::OUString > aProps( 2 );
+ Sequence< Any > aValues( 2 );
+ // Properties in a sequence must be sorted!
+ aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ));
+ aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ));
+ aValues[0] <<= aAppFontSize.Height();
+ aValues[1] <<= aAppFontSize.Width();
-// ------------- UnoPageModel -----------------
+ ImplSetPropertyValues( aProps, aValues, true );
+ mbSizeModified = false;
+ }
+}
-UnoPageModel::UnoPageModel() : UnoControlDialogModel( false )
+void SAL_CALL UnoDialogControl::windowMoved( const ::com::sun::star::awt::WindowEvent& e )
+throw (::com::sun::star::uno::RuntimeException)
{
- ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
- ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
- ImplRegisterProperty( BASEPROPERTY_ENABLED );
- ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
+ OutputDevice*pOutDev = Application::GetDefaultDevice();
+ DBG_ASSERT( pOutDev, "Missing Default Device!" );
+ if ( pOutDev && !mbPosModified )
+ {
+ // Currentley we are simply using MAP_APPFONT
+ Any aAny;
+ ::Size aTmp( e.X, e.Y );
+ aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
- ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
- ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
- ImplRegisterProperty( BASEPROPERTY_HELPURL );
- ImplRegisterProperty( BASEPROPERTY_TITLE );
- ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
- ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
- ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
-// ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
+ // Remember that changes have been done by listener. No need to
+ // update the position because of property change event.
+ mbPosModified = true;
+ Sequence< rtl::OUString > aProps( 2 );
+ Sequence< Any > aValues( 2 );
+ aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ));
+ aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ));
+ aValues[0] <<= aTmp.Width();
+ aValues[1] <<= aTmp.Height();
- Any aBool;
- aBool <<= (sal_Bool) sal_True;
- ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
- ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
- //ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
+ ImplSetPropertyValues( aProps, aValues, true );
+ mbPosModified = false;
+ }
}
-UnoPageModel::UnoPageModel( const UnoPageModel& rModel )
- : UnoControlDialogModel( rModel )
+void SAL_CALL UnoDialogControl::windowShown( const ::com::sun::star::lang::EventObject& e )
+throw (::com::sun::star::uno::RuntimeException)
{
+ (void)e;
}
-UnoPageModel::~UnoPageModel()
+void SAL_CALL UnoDialogControl::windowHidden( const ::com::sun::star::lang::EventObject& e )
+throw (::com::sun::star::uno::RuntimeException)
{
+ (void)e;
}
-UnoControlModel*
-UnoPageModel::Clone() const
+// XPropertiesChangeListener
+void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
{
- // clone the container itself
- UnoPageModel* pClone = new UnoPageModel( *this );
+ if( !isDesignMode() && !mbCreatingCompatiblePeer )
+ {
+ ::rtl::OUString s1( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) );
+ ::rtl::OUString s2( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) );
+ ::rtl::OUString s3( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
+ ::rtl::OUString s4( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
- // clone all children
- ::std::for_each(
- maModels.begin(), maModels.end(),
- CloneControlModel( pClone->maModels )
- );
+ sal_Int32 nLen = rEvents.getLength();
+ for( sal_Int32 i = 0; i < nLen; i++ )
+ {
+ const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
+ Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
+ sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get();
+ if ( ( rEvt.PropertyName == s1 ) ||
+ ( rEvt.PropertyName == s2 ) ||
+ ( rEvt.PropertyName == s3 ) ||
+ ( rEvt.PropertyName == s4 ) )
+ {
+ if ( bOwnModel )
+ {
+ if ( !mbPosModified && !mbSizeModified )
+ {
+ // Don't set new pos/size if we get new values from window listener
+ Reference< XControl > xThis( (XAggregation*)(::cppu::OWeakAggObject*)this, UNO_QUERY );
+ ImplSetPosSize( xThis );
+ }
+ }
+ else
+ {
+ Sequence<Reference<XControl> > aControlSequence(getControls());
+ Reference<XControl> aControlRef( StdTabController::FindControl( aControlSequence, xModel ) );
+ ImplSetPosSize( aControlRef );
+ }
+ break;
+ }
+ else if ( bOwnModel && rEvt.PropertyName.equalsAsciiL( "ResourceResolver", 16 ))
+ {
+ ImplStartListingForResourceEvents();
+ }
+ }
+ }
- return pClone;
-}
+ sal_Int32 nLen = rEvents.getLength();
+ for( sal_Int32 i = 0; i < nLen; i++ )
+ {
+ const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
+ Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
+ sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get();
+ if ( bOwnModel && rEvt.PropertyName.equalsAsciiL( "ImageURL", 8 ))
+ {
+ ::rtl::OUString aImageURL;
+ if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
+ ( aImageURL.getLength() > 0 ))
+ {
+ aImageURL =
+ getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
+ ImplGetPropertyValue( PROPERTY_IMAGEURL ));
-::rtl::OUString UnoPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
-{
- return ::rtl::OUString::createFromAscii( szServiceName_UnoPageModel );
-}
+ }
-uno::Any UnoPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
-{
- if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
- {
- uno::Any aAny;
- aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoPageControl );
- return aAny;
+ ImplSetPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( aImageURL ), sal_True );
+ break;
+ }
}
- return UnoControlDialogModel::ImplGetDefaultValue( nPropId );
-}
-::cppu::IPropertyArrayHelper& UnoPageModel::getInfoHelper()
-{
- static UnoPropertyArrayHelper* pHelper = NULL;
- if ( !pHelper )
- {
- uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
- pHelper = new UnoPropertyArrayHelper( aIDs );
- }
- return *pHelper;
+ UnoControlContainer::ImplModelPropertiesChanged( rEvents );
}
-// beans::XMultiPropertySet
-uno::Reference< beans::XPropertySetInfo > UnoPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
+void UnoDialogControl::ImplStartListingForResourceEvents()
{
- static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
- return xInfo;
-}
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
-// ----------------------------------------------------------------------------
-sal_Bool SAL_CALL UnoPageModel::getGroupControl( ) throw (RuntimeException)
-{
- return sal_False;
-}
+ ImplGetPropertyValue( PROPERTY_RESOURCERESOLVER ) >>= xStringResourceResolver;
-// Frame control
+ // Add our helper as listener to retrieve notifications about changes
+ Reference< util::XModifyListener > rListener( mxListener );
+ ResourceListener* pResourceListener = static_cast< ResourceListener* >( rListener.get() );
-// ----------------------------------------------------
-// class UnoFrameControl
-// ----------------------------------------------------
-UnoFrameControl::UnoFrameControl()
-{
- maComponentInfos.nWidth = 280;
- maComponentInfos.nHeight = 400;
+ // resource listener will stop listening if resolver reference is empty
+ if ( pResourceListener )
+ pResourceListener->startListening( xStringResourceResolver );
+ ImplUpdateResourceResolver();
}
-UnoFrameControl::~UnoFrameControl()
+void UnoDialogControl::ImplUpdateResourceResolver()
{
-}
+ rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
-::rtl::OUString UnoFrameControl::GetComponentServiceName()
-{
- return ::rtl::OUString::createFromAscii( "frame" );
-}
+ ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
+ if ( !xStringResourceResolver.is() )
+ return;
-void UnoFrameControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
-{
- bool bOwnCtrl = false;
- rtl::OUString sTitle;
- if ( rxCtrl.get() == Reference<XControl>( this ).get() )
- bOwnCtrl = true;
- Reference< XPropertySet > xProps( getModel(), UNO_QUERY );
- //xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
- xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ) ) >>= sTitle;
+ Any xNewStringResourceResolver; xNewStringResourceResolver <<= xStringResourceResolver;
- UnoDialogContainerControl::ImplSetPosSize( rxCtrl );
- Reference < XWindow > xW( rxCtrl, UNO_QUERY );
- if ( !bOwnCtrl && xW.is() && sTitle.getLength() )
+ Sequence< rtl::OUString > aPropNames(1);
+ aPropNames[0] = aPropName;
+
+ const Sequence< Reference< awt::XControl > > aSeq = getControls();
+ for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
{
- awt::Rectangle aSizePos = xW->getPosSize();
+ Reference< XControl > xControl( aSeq[i] );
+ Reference< XPropertySet > xPropertySet;
- sal_Int32 nX = aSizePos.X, nY = aSizePos.Y, nWidth = aSizePos.Width, nHeight = aSizePos.Height;
- // Retrieve the values set by the base class
- OutputDevice*pOutDev = Application::GetDefaultDevice();
- if ( pOutDev )
+ if ( xControl.is() )
+ xPropertySet = Reference< XPropertySet >( xControl->getModel(), UNO_QUERY );
+
+ if ( !xPropertySet.is() )
+ continue;
+
+ try
{
- if ( !bOwnCtrl && sTitle.getLength() )
+ Reference< resource::XStringResourceResolver > xCurrStringResourceResolver;
+ Any aOldValue = xPropertySet->getPropertyValue( aPropName );
+ if ( ( aOldValue >>= xCurrStringResourceResolver )
+ && ( xStringResourceResolver == xCurrStringResourceResolver )
+ )
{
- // Adjust Y based on height of Title
- ::Rectangle aRect = pOutDev->GetTextRect( aRect, sTitle );
- nY = nY + ( aRect.GetHeight() / 2 );
+ Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY );
+ Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY );
+ xMultiPropSet->firePropertiesChangeEvent( aPropNames, xListener );
}
+ else
+ xPropertySet->setPropertyValue( aPropName, xNewStringResourceResolver );
}
- else
+ /*catch ( NoSuchElementException& )*/ // that's nonsense, this is never thrown above ...
+ catch ( const Exception& )
{
- Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True );
- Reference< XDevice > xD( xPeer, UNO_QUERY );
-
- SimpleFontMetric aFM;
- FontDescriptor aFD;
- Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
- aVal >>= aFD;
- if ( aFD.StyleName.getLength() )
- {
- Reference< XFont > xFont = xD->getFont( aFD );
- aFM = xFont->getFontMetric();
- }
- else
- {
- Reference< XGraphics > xG = xD->createGraphics();
- aFM = xG->getFontMetric();
- }
-
- sal_Int16 nH = aFM.Ascent + aFM.Descent;
- if ( !bOwnCtrl && sTitle.getLength() )
- // offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
- nY = nY + ( nH / 8); // how do I test this
}
- xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
}
-}
-// ------------- UnoFrameModel -----------------
+ // propagate resource resolver changes to language dependent props of the dialog
+ Reference< XPropertySet > xPropertySet( getModel(), UNO_QUERY );
+ if ( xPropertySet.is() )
+ {
+ Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY );
+ Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY );
+ xMultiPropSet->firePropertiesChangeEvent( lcl_getLanguageDependentProperties(), xListener );
+ }
+}
-UnoFrameModel::UnoFrameModel() : UnoControlDialogModel( false )
+void SAL_CALL UnoDialogControl::endDialog( ::sal_Int32 i_result ) throw (RuntimeException)
{
- ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
- ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
- ImplRegisterProperty( BASEPROPERTY_ENABLED );
- ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
- ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
- ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
- ImplRegisterProperty( BASEPROPERTY_HELPURL );
- ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
- ImplRegisterProperty( BASEPROPERTY_LABEL );
- ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
- ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
- ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
+ Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
+ if ( xPeerDialog.is() )
+ xPeerDialog->endDialog( i_result );
}
-UnoFrameModel::UnoFrameModel( const UnoFrameModel& rModel )
- : UnoControlDialogModel( rModel )
+void SAL_CALL UnoDialogControl::setHelpId( ::sal_Int32 i_id ) throw (RuntimeException)
{
+ Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
+ if ( xPeerDialog.is() )
+ xPeerDialog->setHelpId( i_id );
}
-UnoFrameModel::~UnoFrameModel()
+void UnoDialogControl::setTitle( const ::rtl::OUString& Title ) throw(RuntimeException)
{
+ SolarMutexGuard aSolarGuard;
+ Any aAny;
+ aAny <<= Title;
+ ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ), aAny, sal_True );
}
-UnoControlModel*
-UnoFrameModel::Clone() const
+::rtl::OUString UnoDialogControl::getTitle() throw(RuntimeException)
{
- // clone the container itself
- UnoFrameModel* pClone = new UnoFrameModel( *this );
-
- // clone all children
- ::std::for_each(
- maModels.begin(), maModels.end(),
- CloneControlModel( pClone->maModels )
- );
+ SolarMutexGuard aSolarGuard;
+ return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE );
+}
- return pClone;
+sal_Int16 UnoDialogControl::execute() throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ sal_Int16 nDone = -1;
+ if ( getPeer().is() )
+ {
+ Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
+ if( xDlg.is() )
+ {
+ GetComponentInfos().bVisible = sal_True;
+ nDone = xDlg->execute();
+ GetComponentInfos().bVisible = sal_False;
+ }
+ }
+ return nDone;
}
-::rtl::OUString UnoFrameModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
+void UnoDialogControl::endExecute() throw(RuntimeException)
{
- return ::rtl::OUString::createFromAscii( szServiceName_UnoFrameModel );
+ SolarMutexGuard aSolarGuard;
+ if ( getPeer().is() )
+ {
+ Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
+ if( xDlg.is() )
+ {
+ xDlg->endExecute();
+ GetComponentInfos().bVisible = sal_False;
+ }
+ }
}
-uno::Any UnoFrameModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
+void UnoDialogControl::addingControl( const Reference< XControl >& _rxControl )
{
- if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
+ SolarMutexGuard aSolarGuard;
+ UnoControlContainer::addingControl( _rxControl );
+
+ if ( _rxControl.is() )
{
- uno::Any aAny;
- aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoFrameControl );
- return aAny;
+ Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY );
+ if ( xProps.is() )
+ {
+ Sequence< ::rtl::OUString > aNames( 4 );
+ ::rtl::OUString* pNames = aNames.getArray();
+ *pNames++ = ::rtl::OUString::createFromAscii( "PositionX" );
+ *pNames++ = ::rtl::OUString::createFromAscii( "PositionY" );
+ *pNames++ = ::rtl::OUString::createFromAscii( "Width" );
+ *pNames++ = ::rtl::OUString::createFromAscii( "Height" );
+
+ xProps->addPropertiesChangeListener( aNames, this );
+ }
}
- return UnoControlDialogModel::ImplGetDefaultValue( nPropId );
}
-::cppu::IPropertyArrayHelper& UnoFrameModel::getInfoHelper()
+void UnoDialogControl::removingControl( const Reference< XControl >& _rxControl )
{
- static UnoPropertyArrayHelper* pHelper = NULL;
- if ( !pHelper )
+ SolarMutexGuard aSolarGuard;
+ UnoControlContainer::removingControl( _rxControl );
+
+ if ( _rxControl.is() )
{
- uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
- pHelper = new UnoPropertyArrayHelper( aIDs );
+ Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY );
+ if ( xProps.is() )
+ xProps->removePropertiesChangeListener( this );
}
- return *pHelper;
+
}
-// beans::XMultiPropertySet
-uno::Reference< beans::XPropertySetInfo > UnoFrameModel::getPropertySetInfo( ) throw(uno::RuntimeException)
+void SAL_CALL UnoDialogControl::changesOccurred( const ChangesEvent& ) throw (RuntimeException)
{
- static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
- return xInfo;
+ SolarMutexGuard aSolarGuard;
+ // a tab controller model may have changed
+
+ // #109067# in design mode don't notify the tab controller
+ // about tab index changes
+ if ( mxTabController.is() && !mbDesignMode )
+ mxTabController->activateTabOrder();
}
+// XModifyListener
+void SAL_CALL UnoDialogControl::modified(
+ const lang::EventObject& /*rEvent*/ )
+throw (RuntimeException)
+{
+ ImplUpdateResourceResolver();
+}
-//===============================================================
// ----------------------------------------------------
-// class DialogContainerControl
+// Helper Method to convert relative url to physical location
// ----------------------------------------------------
-UnoDialogContainerControl::UnoDialogContainerControl() :
+
+::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl )
+{
+
+ ::rtl::OUString ret;
+
+ ::rtl::OUString baseLocation;
+ ::rtl::OUString url;
+
+ rbase >>= baseLocation;
+ rUrl >>= url;
+
+ ::rtl::OUString absoluteURL( url );
+ if ( url.getLength() > 0 )
+ {
+ // Don't adjust GraphicObject url(s)
+ if ( url.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
+ {
+ INetURLObject urlObj(baseLocation);
+ urlObj.removeSegment();
+ baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE );
+ ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, ret );
+ }
+ else
+ ret = url;
+
+ const INetURLObject protocolCheck( url );
+ const INetProtocol protocol = protocolCheck.GetProtocol();
+ if ( protocol == INET_PROT_NOT_VALID )
+ {
+ ::rtl::OUString testAbsoluteURL;
+ if ( ::osl::FileBase::E_None == ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, testAbsoluteURL ) )
+ absoluteURL = testAbsoluteURL;
+ }
+ }
+
+ return absoluteURL;
+}
+
+UnoParentControl::UnoParentControl() :
mbSizeModified(false),
mbPosModified(false)
{
maComponentInfos.nWidth = 280;
maComponentInfos.nHeight = 400;
+ // #TODO Do we need the ResourceListener foo ?
}
-UnoDialogContainerControl::~UnoDialogContainerControl()
+UnoParentControl::~UnoParentControl()
{
}
// XInterface
-Any UnoDialogContainerControl::queryAggregation( const Type & rType ) throw(RuntimeException)
+Any UnoParentControl::queryAggregation( const Type & rType ) throw(RuntimeException)
{
- Any aRet( UnoDialogContainerControl_IBase::queryInterface( rType ) );
+ Any aRet( UnoParentControl_IBase::queryInterface( rType ) );
return (aRet.hasValue() ? aRet : UnoControlContainer::queryAggregation( rType ));
}
// XTypeProvider
-IMPL_IMPLEMENTATION_ID( UnoDialogContainerControl )
+IMPL_IMPLEMENTATION_ID( UnoParentControl )
Sequence< Type >
-UnoDialogContainerControl::getTypes() throw(RuntimeException)
+UnoParentControl::getTypes() throw(RuntimeException)
{
return ::comphelper::concatSequences(
- UnoDialogContainerControl_IBase::getTypes(),
+ UnoParentControl_IBase::getTypes(),
UnoControlContainer::getTypes()
);
}
-void UnoDialogContainerControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
+void UnoParentControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
UnoControlContainer::createPeer( rxToolkit, rParentPeer );
}
-void UnoDialogContainerControl::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName )
+void UnoParentControl::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName )
{
Reference< XPropertySet > xP( rxModel, UNO_QUERY );
@@ -2187,7 +2416,7 @@ void UnoDialogContainerControl::ImplInsertControl( Reference< XControlModel >& r
}
}
-void UnoDialogContainerControl::ImplRemoveControl( Reference< XControlModel >& rxModel )
+void UnoParentControl::ImplRemoveControl( Reference< XControlModel >& rxModel )
{
Sequence< Reference< XControl > > aControls = getControls();
Reference< XControl > xCtrl = StdTabController::FindControl( aControls, rxModel );
@@ -2195,7 +2424,7 @@ void UnoDialogContainerControl::ImplRemoveControl( Reference< XControlModel >& r
removeControl( xCtrl );
}
-void UnoDialogContainerControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
+void UnoParentControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
{
Reference< XPropertySet > xP( rxCtrl->getModel(), UNO_QUERY );
@@ -2253,19 +2482,19 @@ void UnoDialogContainerControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
}
-void UnoDialogContainerControl::dispose() throw(RuntimeException)
+void UnoParentControl::dispose() throw(RuntimeException)
{
UnoControlContainer::dispose();
}
-void SAL_CALL UnoDialogContainerControl::disposing(
+void SAL_CALL UnoParentControl::disposing(
const EventObject& Source )
throw(RuntimeException)
{
UnoControlContainer::disposing( Source );
}
-sal_Bool UnoDialogContainerControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
+sal_Bool UnoParentControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
@@ -2338,7 +2567,7 @@ sal_Bool UnoDialogContainerControl::setModel( const Reference< XControlModel >&
return bRet;
}
-void UnoDialogContainerControl::setDesignMode( sal_Bool bOn ) throw(RuntimeException)
+void UnoParentControl::setDesignMode( sal_Bool bOn ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
@@ -2357,7 +2586,7 @@ void UnoDialogContainerControl::setDesignMode( sal_Bool bOn ) throw(RuntimeExcep
mxTabController->activateTabOrder();
}
-void UnoDialogContainerControl::elementInserted( const ContainerEvent& Event ) throw(RuntimeException)
+void UnoParentControl::elementInserted( const ContainerEvent& Event ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
Reference< XControlModel > xModel;
@@ -2368,7 +2597,7 @@ void UnoDialogContainerControl::elementInserted( const ContainerEvent& Event ) t
ImplInsertControl( xModel, aName );
}
-void UnoDialogContainerControl::elementRemoved( const ContainerEvent& Event ) throw(RuntimeException)
+void UnoParentControl::elementRemoved( const ContainerEvent& Event ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
@@ -2378,7 +2607,7 @@ void UnoDialogContainerControl::elementRemoved( const ContainerEvent& Event ) th
ImplRemoveControl( xModel );
}
-void UnoDialogContainerControl::elementReplaced( const ContainerEvent& Event ) throw(RuntimeException)
+void UnoParentControl::elementReplaced( const ContainerEvent& Event ) throw(RuntimeException)
{
SolarMutexGuard aSolarGuard;
@@ -2394,7 +2623,7 @@ void UnoDialogContainerControl::elementReplaced( const ContainerEvent& Event ) t
}
// XPropertiesChangeListener
-void UnoDialogContainerControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
+void UnoParentControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
{
if( !isDesignMode() && !mbCreatingCompatiblePeer )
{
@@ -2436,7 +2665,7 @@ void UnoDialogContainerControl::ImplModelPropertiesChanged( const Sequence< Prop
UnoControlContainer::ImplModelPropertiesChanged( rEvents );
}
-void UnoDialogContainerControl::addingControl( const Reference< XControl >& _rxControl )
+void UnoParentControl::addingControl( const Reference< XControl >& _rxControl )
{
SolarMutexGuard aSolarGuard;
UnoControlContainer::addingControl( _rxControl );
@@ -2458,7 +2687,7 @@ void UnoDialogContainerControl::addingControl( const Reference< XControl >& _rxC
}
}
-void UnoDialogContainerControl::removingControl( const Reference< XControl >& _rxControl )
+void UnoParentControl::removingControl( const Reference< XControl >& _rxControl )
{
SolarMutexGuard aSolarGuard;
UnoControlContainer::removingControl( _rxControl );
@@ -2472,7 +2701,7 @@ void UnoDialogContainerControl::removingControl( const Reference< XControl >& _r
}
-void SAL_CALL UnoDialogContainerControl::changesOccurred( const ChangesEvent& ) throw (RuntimeException)
+void SAL_CALL UnoParentControl::changesOccurred( const ChangesEvent& ) throw (RuntimeException)
{
SolarMutexGuard aSolarGuard;
// a tab controller model may have changed
@@ -2483,544 +2712,570 @@ void SAL_CALL UnoDialogContainerControl::changesOccurred( const ChangesEvent& )
mxTabController->activateTabOrder();
}
-// ============================================================================
-// = class UnoDialogControl
-// ============================================================================
-
-UnoDialogControl::UnoDialogControl() :
- maTopWindowListeners( *this ),
- mbWindowListener(false)
+// ----------------------------------------------------
+// class MultiPageControl
+// ----------------------------------------------------
+UnoMultiPageControl::UnoMultiPageControl() : maTabListeners( *this )
{
- maComponentInfos.nWidth = 300;
- maComponentInfos.nHeight = 450;
- mxListener = new ResourceListener( Reference< util::XModifyListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ maComponentInfos.nWidth = 280;
+ maComponentInfos.nHeight = 400;
}
-UnoDialogControl::~UnoDialogControl()
+UnoMultiPageControl::~UnoMultiPageControl()
{
}
+// XTabListener
-::rtl::OUString UnoDialogControl::GetComponentServiceName()
+void SAL_CALL UnoMultiPageControl::inserted( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
+{
+}
+void SAL_CALL UnoMultiPageControl::removed( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
+{
+}
+void SAL_CALL UnoMultiPageControl::changed( ::sal_Int32 /*ID*/, const Sequence< NamedValue >& /*Properties*/ ) throw (RuntimeException)
+{
+}
+void SAL_CALL UnoMultiPageControl::activated( ::sal_Int32 ID ) throw (RuntimeException)
{
+ ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), sal_False );
- sal_Bool bDecoration( sal_True );
- ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
- if ( bDecoration )
- return ::rtl::OUString::createFromAscii( "Dialog" );
- else
- return ::rtl::OUString::createFromAscii( "TabPage" );
+}
+void SAL_CALL UnoMultiPageControl::deactivated( ::sal_Int32 /*ID*/ ) throw (RuntimeException)
+{
+}
+void SAL_CALL UnoMultiPageControl::disposing(const EventObject&) throw (RuntimeException)
+{
}
-// XInterface
-Any UnoDialogControl::queryAggregation( const Type & rType ) throw(RuntimeException)
+void SAL_CALL UnoMultiPageControl::dispose() throw (RuntimeException)
{
- uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XTopWindow*, this ) );
- if ( !aRet.hasValue() )
- aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XDialog*, this ) );
- if ( !aRet.hasValue() )
- aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XWindowListener*, this ) );
- return (aRet.hasValue() ? aRet : UnoDialogContainerControl::queryAggregation( rType ));
-}
-//lang::XTypeProvider
-IMPL_XTYPEPROVIDER_START( UnoDialogControl)
- getCppuType( ( uno::Reference< awt::XTopWindow>* ) NULL ),
- getCppuType( ( uno::Reference< awt::XDialog>* ) NULL ),
- getCppuType( ( uno::Reference< awt::XWindowListener>* ) NULL ),
- UnoDialogContainerControl::getTypes()
-IMPL_XTYPEPROVIDER_END
+ lang::EventObject aEvt;
+ aEvt.Source = (::cppu::OWeakObject*)this;
+ maTabListeners.disposeAndClear( aEvt );
+ UnoParentControl::dispose();
+}
-void UnoDialogControl::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName )
+// com::sun::star::awt::XSimpleTabController
+::sal_Int32 SAL_CALL UnoMultiPageControl::insertTab() throw (RuntimeException)
{
- // maybe this should be in the UnoDialogContainerControl, lets see
- Reference< XPropertySet > xP( rxModel, UNO_QUERY );
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( !xMultiPage.is() )
+ throw RuntimeException();
+ return xMultiPage->insertTab();
+}
- // Add our own resource resolver to a newly created control
- Reference< resource::XStringResourceResolver > xStringResourceResolver;
- rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
+void SAL_CALL UnoMultiPageControl::removeTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( !xMultiPage.is() )
+ throw RuntimeException();
+ xMultiPage->removeTab( ID );
+}
- Any aAny;
- ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
+void SAL_CALL UnoMultiPageControl::setTabProps( ::sal_Int32 ID, const Sequence< NamedValue >& Properties ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( !xMultiPage.is() )
+ throw RuntimeException();
+ xMultiPage->setTabProps( ID, Properties );
+}
- aAny <<= xStringResourceResolver;
- xP->setPropertyValue( aPropName, aAny );
+Sequence< NamedValue > SAL_CALL UnoMultiPageControl::getTabProps( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( !xMultiPage.is() )
+ throw RuntimeException();
+ return xMultiPage->getTabProps( ID );
+}
- UnoDialogContainerControl::ImplInsertControl( rxModel, rName );
+void SAL_CALL UnoMultiPageControl::activateTab( ::sal_Int32 ID ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( !xMultiPage.is() )
+ throw RuntimeException();
+ xMultiPage->activateTab( ID );
+ ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( ID ), sal_True );
}
-void UnoDialogControl::dispose() throw(RuntimeException)
+::sal_Int32 SAL_CALL UnoMultiPageControl::getActiveTabID() throw (RuntimeException)
{
- SolarMutexGuard aSolarGuard;
-
- EventObject aEvt;
- aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
- maTopWindowListeners.disposeAndClear( aEvt );
- // Notify our listener helper about dispose
- // --- SAFE ---
- ::osl::ResettableGuard< ::osl::Mutex > aGuard( GetMutex() );
- Reference< XEventListener > xListener( mxListener, UNO_QUERY );
- mxListener.clear();
- aGuard.clear();
- // --- SAFE ---
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( !xMultiPage.is() )
+ throw RuntimeException();
+ return xMultiPage->getActiveTabID();
+}
- if ( xListener.is() )
- xListener->disposing( aEvt );
- UnoDialogContainerControl::dispose();
+void SAL_CALL UnoMultiPageControl::addTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException)
+{
+ maTabListeners.addInterface( Listener );
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
+ xMultiPage->addTabListener( &maTabListeners );
}
-void SAL_CALL UnoDialogControl::disposing(
- const EventObject& Source )
-throw(RuntimeException)
+void SAL_CALL UnoMultiPageControl::removeTabListener( const Reference< XTabListener >& Listener ) throw (RuntimeException)
{
- // #FIXME see what can be moved to UnoDialogControlContainer
- rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
- Reference< resource::XStringResourceResolver > xStringResourceResolver;
+ Reference< XSimpleTabController > xMultiPage( getPeer(), UNO_QUERY );
+ if ( xMultiPage.is() && maTabListeners.getLength() == 1 )
+ xMultiPage->removeTabListener( &maTabListeners );
+ maTabListeners.removeInterface( Listener );
+}
- ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
- Reference< XInterface > xIfac( xStringResourceResolver, UNO_QUERY );
- if ( Source.Source == xIfac )
- {
- Any aAny;
+// lang::XTypeProvider
+IMPL_XTYPEPROVIDER_START( UnoMultiPageControl )
+ getCppuType( ( uno::Reference< awt::XSimpleTabController>* ) NULL ),
+ getCppuType( ( uno::Reference< awt::XTabListener>* ) NULL ),
+ UnoParentControl::getTypes()
+IMPL_XTYPEPROVIDER_END
- // Reset resource resolver reference
- ImplSetPropertyValue( aPropName, aAny, sal_True );
- ImplUpdateResourceResolver();
- }
- else
- {
- UnoDialogContainerControl::disposing( Source );
- }
+// uno::XInterface
+uno::Any UnoMultiPageControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ uno::Any aRet = ::cppu::queryInterface( rType,
+ SAL_STATIC_CAST( awt::XTabListener*, this ), SAL_STATIC_CAST( awt::XSimpleTabController*, this ) );
+ return (aRet.hasValue() ? aRet : UnoParentControl::queryAggregation( rType ));
}
-sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
+::rtl::OUString UnoMultiPageControl::GetComponentServiceName()
{
- // #Can we move all the Resource stuff to the UnoDialogContainerControl ?
- SolarMutexGuard aSolarGuard;
- sal_Bool bRet = UnoDialogContainerControl::setModel( rxModel );
- ImplStartListingForResourceEvents();
- return bRet;
+ sal_Bool bDecoration( sal_True );
+ ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
+ if ( bDecoration )
+ return ::rtl::OUString::createFromAscii( "tabcontrol" );
+ // Hopefully we can tweak the tabcontrol to display without tabs
+ return ::rtl::OUString::createFromAscii( "tabcontrolnotabs" );
}
-void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
+void UnoMultiPageControl::bindPage( const uno::Reference< awt::XControl >& _rxControl )
{
- SolarMutexGuard aSolarGuard;
-
- UnoControlContainer::createPeer( rxToolkit, rParentPeer );
+ uno::Reference< awt::XWindowPeer > xPage( _rxControl->getPeer() );
+ uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProps( _rxControl->getModel(), uno::UNO_QUERY );
- Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
- if ( xTW.is() )
+ VCLXTabPage* pXPage = dynamic_cast< VCLXTabPage* >( xPage.get() );
+ TabPage* pPage = pXPage ? pXPage->getTabPage() : NULL;
+ if ( xTabCntrl.is() && pPage )
{
- xTW->setMenuBar( mxMenuBar );
-
- if ( !mbWindowListener )
+ VCLXMultiPage* pXTab = dynamic_cast< VCLXMultiPage* >( xTabCntrl.get() );
+ if ( pXTab )
{
- Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
- addWindowListener( xWL );
- mbWindowListener = true;
+ rtl::OUString sTitle;
+ xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
+ pXTab->insertTab( pPage, sTitle);
}
-
- if ( maTopWindowListeners.getLength() )
- xTW->addTopWindowListener( &maTopWindowListeners );
}
+
}
-void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc )
+void UnoMultiPageControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
{
- sal_Bool bDecoration( sal_True );
- ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DECORATION )) >>= bDecoration;
- if ( !bDecoration )
- {
- // Now we have to manipulate the WindowDescriptor
- rDesc.WindowAttributes = rDesc.WindowAttributes | ::com::sun::star::awt::WindowAttribute::NODECORATION;
- }
+ SolarMutexGuard aSolarGuard;
- // We have to set the graphic property before the peer
- // will be created. Otherwise the properties will be copied
- // into the peer via propertiesChangeEvents. As the order of
- // can lead to overwrites we have to set the graphic property
- // before the propertiesChangeEvents are sent!
- ::rtl::OUString aImageURL;
- if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
- ( aImageURL.getLength() > 0 ))
+ UnoControlContainer::createPeer( rxToolkit, rParentPeer );
+
+ uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
+ sal_uInt32 nCtrls = aCtrls.getLength();
+ for( sal_uInt32 n = 0; n < nCtrls; n++ )
+ bindPage( aCtrls[ n ] );
+ sal_Int32 nActiveTab(0);
+ Reference< XPropertySet > xMultiProps( getModel(), UNO_QUERY );
+ xMultiProps->getPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ) ) >>= nActiveTab;
+
+ uno::Reference< awt::XSimpleTabController > xTabCntrl( getPeer(), uno::UNO_QUERY );
+ if ( xTabCntrl.is() )
{
- ::rtl::OUString absoluteUrl = aImageURL;
- if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
+ xTabCntrl->addTabListener( this );
+ if ( nActiveTab && nCtrls ) // Ensure peer is initialise with correct activated tab
{
- absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
- ImplGetPropertyValue( PROPERTY_IMAGEURL ));
+ xTabCntrl->activateTab( nActiveTab );
+ ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( nActiveTab ), sal_True );
}
- // not understanding the code above, but it surely setting the URL is just as
- // effective ( and prevents ambiguity with embedded images )
- ImplSetPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( absoluteUrl ), sal_True );
}
- if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
- ImplSetPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( aImageURL ), sal_True );
}
-void UnoDialogControl::addTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
+void UnoMultiPageControl::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl)
{
- maTopWindowListeners.addInterface( rxListener );
- if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
- {
- Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
- xTW->addTopWindowListener( &maTopWindowListeners );
- }
-}
+ OSL_PRECOND( _rxControl.is(), "UnoMultiPageControl::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
-void UnoDialogControl::removeTopWindowListener( const Reference< XTopWindowListener >& rxListener ) throw (RuntimeException)
-{
- if( getPeer().is() && maTopWindowListeners.getLength() == 1 )
+ // if the container already has a peer, then also create a peer for the control
+ uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
+
+ if( xMyPeer.is() )
{
- Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
- xTW->removeTopWindowListener( &maTopWindowListeners );
+ _rxControl->createPeer( NULL, xMyPeer );
+ bindPage( _rxControl );
+ ImplActivateTabControllers();
}
- maTopWindowListeners.removeInterface( rxListener );
+
}
-void UnoDialogControl::toFront( ) throw (RuntimeException)
+// ------------- UnoMultiPageModel -----------------
+
+UnoMultiPageModel::UnoMultiPageModel() : UnoControlDialogModel( false )
{
- SolarMutexGuard aSolarGuard;
- if ( getPeer().is() )
- {
- Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
- if( xTW.is() )
- xTW->toFront();
- }
+ ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
+ ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
+ ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
+ ImplRegisterProperty( BASEPROPERTY_ENABLED );
+
+ ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
+ ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
+ ImplRegisterProperty( BASEPROPERTY_HELPURL );
+ ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
+ //ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
+ ImplRegisterProperty( BASEPROPERTY_MULTIPAGEVALUE );
+ ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
+ ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
+
+ Any aBool;
+ aBool <<= (sal_Bool) sal_True;
+ ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
+ ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
+ ImplRegisterProperty( BASEPROPERTY_DECORATION, aBool );
+ // MultiPage Control has the tab stop property. And the default value is True.
+ ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
}
-void UnoDialogControl::toBack( ) throw (RuntimeException)
+UnoMultiPageModel::UnoMultiPageModel( const UnoMultiPageModel& rModel )
+ : UnoControlDialogModel( rModel )
{
- SolarMutexGuard aSolarGuard;
- if ( getPeer().is() )
- {
- Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
- if( xTW.is() )
- xTW->toBack();
- }
}
-void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) throw (RuntimeException)
+UnoMultiPageModel::~UnoMultiPageModel()
{
- SolarMutexGuard aSolarGuard;
- mxMenuBar = rxMenuBar;
- if ( getPeer().is() )
- {
- Reference< XTopWindow > xTW( getPeer(), UNO_QUERY );
- if( xTW.is() )
- xTW->setMenuBar( mxMenuBar );
- }
}
-// ::com::sun::star::awt::XWindowListener
-void SAL_CALL UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent& e )
-throw (::com::sun::star::uno::RuntimeException)
+UnoControlModel*
+UnoMultiPageModel::Clone() const
{
- OutputDevice*pOutDev = Application::GetDefaultDevice();
- DBG_ASSERT( pOutDev, "Missing Default Device!" );
- if ( pOutDev && !mbSizeModified )
- {
- // Currentley we are simply using MAP_APPFONT
- ::Size aAppFontSize( e.Width, e.Height );
-
- Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
- Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
- OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
- if ( xDialogDevice.is() )
- {
- DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
- aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
- aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
- }
+ // clone the container itself
+ UnoMultiPageModel* pClone = new UnoMultiPageModel( *this );
- aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
+ // clone all children
+ ::std::for_each(
+ maModels.begin(), maModels.end(),
+ CloneControlModel( pClone->maModels )
+ );
- // Remember that changes have been done by listener. No need to
- // update the position because of property change event.
- mbSizeModified = true;
- Sequence< rtl::OUString > aProps( 2 );
- Sequence< Any > aValues( 2 );
- // Properties in a sequence must be sorted!
- aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ));
- aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ));
- aValues[0] <<= aAppFontSize.Height();
- aValues[1] <<= aAppFontSize.Width();
+ return pClone;
+}
- ImplSetPropertyValues( aProps, aValues, true );
- mbSizeModified = false;
- }
+::rtl::OUString UnoMultiPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
}
-void SAL_CALL UnoDialogControl::windowMoved( const ::com::sun::star::awt::WindowEvent& e )
-throw (::com::sun::star::uno::RuntimeException)
+uno::Any UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{
- OutputDevice*pOutDev = Application::GetDefaultDevice();
- DBG_ASSERT( pOutDev, "Missing Default Device!" );
- if ( pOutDev && !mbPosModified )
+ if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
{
- // Currentley we are simply using MAP_APPFONT
- Any aAny;
- ::Size aTmp( e.X, e.Y );
- aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
-
- // Remember that changes have been done by listener. No need to
- // update the position because of property change event.
- mbPosModified = true;
- Sequence< rtl::OUString > aProps( 2 );
- Sequence< Any > aValues( 2 );
- aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ));
- aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ));
- aValues[0] <<= aTmp.Width();
- aValues[1] <<= aTmp.Height();
-
- ImplSetPropertyValues( aProps, aValues, true );
- mbPosModified = false;
+ uno::Any aAny;
+ aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageControl );
+ return aAny;
}
+ return UnoControlDialogModel::ImplGetDefaultValue( nPropId );
}
-void SAL_CALL UnoDialogControl::windowShown( const ::com::sun::star::lang::EventObject& e )
-throw (::com::sun::star::uno::RuntimeException)
+::cppu::IPropertyArrayHelper& UnoMultiPageModel::getInfoHelper()
{
- (void)e;
+ static UnoPropertyArrayHelper* pHelper = NULL;
+ if ( !pHelper )
+ {
+ uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
+ pHelper = new UnoPropertyArrayHelper( aIDs );
+ }
+ return *pHelper;
}
-void SAL_CALL UnoDialogControl::windowHidden( const ::com::sun::star::lang::EventObject& e )
-throw (::com::sun::star::uno::RuntimeException)
+// beans::XMultiPropertySet
+uno::Reference< beans::XPropertySetInfo > UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
{
- (void)e;
+ static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
}
-// XPropertiesChangeListener
-void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
+void UnoMultiPageModel::insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
{
- sal_Int32 nLen = rEvents.getLength();
- for( sal_Int32 i = 0; i < nLen; i++ )
- {
- const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
- Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
- sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get();
- if( !isDesignMode() && !mbCreatingCompatiblePeer && bOwnModel )
- {
- if ( rEvt.PropertyName.equalsAsciiL( "ResourceResolver", 16 ) )
- ImplStartListingForResourceEvents();
- }
+ Reference< XServiceInfo > xInfo;
+ aElement >>= xInfo;
- else if ( bOwnModel && rEvt.PropertyName.equalsAsciiL( "ImageURL", 8 ))
- {
- ::rtl::OUString aImageURL;
- Reference< graphic::XGraphic > xGraphic;
- // Ignore GraphicObject urls
- if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
- ( aImageURL.getLength() > 0 ))
- {
- ::rtl::OUString absoluteUrl = aImageURL;
- if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
- {
- absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
- ImplGetPropertyValue( PROPERTY_IMAGEURL ));
- }
- ImplSetPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( absoluteUrl ), sal_True );
- }
- }
- }
- UnoDialogContainerControl::ImplModelPropertiesChanged( rEvents );
+ if ( !xInfo.is() )
+ throw IllegalArgumentException();
+
+ // Only a Page model can be inserted into the multipage
+ if ( !xInfo->supportsService( rtl::OUString::createFromAscii( szServiceName_UnoPageModel ) ) )
+ throw IllegalArgumentException();
+
+ return UnoControlDialogModel::insertByName( aName, aElement );
}
-void UnoDialogControl::ImplStartListingForResourceEvents()
+// ----------------------------------------------------------------------------
+sal_Bool SAL_CALL UnoMultiPageModel::getGroupControl( ) throw (RuntimeException)
{
- // #FIXME can we move this to base class
- Reference< resource::XStringResourceResolver > xStringResourceResolver;
-
- ImplGetPropertyValue( PROPERTY_RESOURCERESOLVER ) >>= xStringResourceResolver;
+ return sal_True;
+}
- // Add our helper as listener to retrieve notifications about changes
- Reference< util::XModifyListener > rListener( mxListener );
- ResourceListener* pResourceListener = static_cast< ResourceListener* >( rListener.get() );
+// ----------------------------------------------------
+// class UnoPageControl
+// ----------------------------------------------------
+UnoPageControl::UnoPageControl()
+{
+ maComponentInfos.nWidth = 280;
+ maComponentInfos.nHeight = 400;
+}
- // resource listener will stop listening if resolver reference is empty
- if ( pResourceListener )
- pResourceListener->startListening( xStringResourceResolver );
- ImplUpdateResourceResolver();
+UnoPageControl::~UnoPageControl()
+{
}
-void lcl_ApplyResolverToNestedContainees( const Reference< resource::XStringResourceResolver >& xStringResourceResolver, const Reference< XControlContainer >& xContainer )
+::rtl::OUString UnoPageControl::GetComponentServiceName()
{
- rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
+ return ::rtl::OUString::createFromAscii( "tabpage" );
+}
- Any xNewStringResourceResolver; xNewStringResourceResolver <<= xStringResourceResolver;
- Sequence< rtl::OUString > aPropNames(1);
- aPropNames[0] = aPropName;
+// ------------- UnoPageModel -----------------
- const Sequence< Reference< awt::XControl > > aSeq = xContainer->getControls();
- for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
- {
- Reference< XControl > xControl( aSeq[i] );
- Reference< XPropertySet > xPropertySet;
+UnoPageModel::UnoPageModel() : UnoControlDialogModel( false )
+{
+ ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
+ ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
+ ImplRegisterProperty( BASEPROPERTY_ENABLED );
+ ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
- if ( xControl.is() )
- xPropertySet = Reference< XPropertySet >( xControl->getModel(), UNO_QUERY );
+ ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
+ ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
+ ImplRegisterProperty( BASEPROPERTY_HELPURL );
+ ImplRegisterProperty( BASEPROPERTY_TITLE );
+ ImplRegisterProperty( BASEPROPERTY_SIZEABLE );
+ ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
+ ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
+// ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
- if ( !xPropertySet.is() )
- continue;
+ Any aBool;
+ aBool <<= (sal_Bool) sal_True;
+ ImplRegisterProperty( BASEPROPERTY_MOVEABLE, aBool );
+ ImplRegisterProperty( BASEPROPERTY_CLOSEABLE, aBool );
+ //ImplRegisterProperty( BASEPROPERTY_TABSTOP, aBool );
+}
- try
- {
- Reference< resource::XStringResourceResolver > xCurrStringResourceResolver;
- Any aOldValue = xPropertySet->getPropertyValue( aPropName );
- if ( ( aOldValue >>= xCurrStringResourceResolver )
- && ( xStringResourceResolver == xCurrStringResourceResolver )
- )
- {
- Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY );
- Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY );
- xMultiPropSet->firePropertiesChangeEvent( aPropNames, xListener );
- }
- else
- xPropertySet->setPropertyValue( aPropName, xNewStringResourceResolver );
- }
- /*catch ( NoSuchElementException& )*/ // that's nonsense, this is never thrown above ...
- catch ( const Exception& )
- {
- }
+UnoPageModel::UnoPageModel( const UnoPageModel& rModel )
+ : UnoControlDialogModel( rModel )
+{
+}
- uno::Reference< XControlContainer > xNestedContainer( xControl, uno::UNO_QUERY );
- if ( xNestedContainer.is() )
- lcl_ApplyResolverToNestedContainees( xStringResourceResolver, xNestedContainer );
+UnoPageModel::~UnoPageModel()
+{
+}
- }
+UnoControlModel*
+UnoPageModel::Clone() const
+{
+ // clone the container itself
+ UnoPageModel* pClone = new UnoPageModel( *this );
+
+ // clone all children
+ ::std::for_each(
+ maModels.begin(), maModels.end(),
+ CloneControlModel( pClone->maModels )
+ );
+ return pClone;
}
-void UnoDialogControl::ImplUpdateResourceResolver()
+::rtl::OUString UnoPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
{
- rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
- Reference< resource::XStringResourceResolver > xStringResourceResolver;
-
- ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
- if ( !xStringResourceResolver.is() )
- return;
+ return ::rtl::OUString::createFromAscii( szServiceName_UnoPageModel );
+}
- lcl_ApplyResolverToNestedContainees( xStringResourceResolver, this );
+uno::Any UnoPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
+{
+ if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
+ {
+ uno::Any aAny;
+ aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoPageControl );
+ return aAny;
+ }
+ return UnoControlDialogModel::ImplGetDefaultValue( nPropId );
+}
- // propagate resource resolver changes to language dependent props of the dialog
- Reference< XPropertySet > xPropertySet( getModel(), UNO_QUERY );
- if ( xPropertySet.is() )
+::cppu::IPropertyArrayHelper& UnoPageModel::getInfoHelper()
+{
+ static UnoPropertyArrayHelper* pHelper = NULL;
+ if ( !pHelper )
{
- Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY );
- Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY );
- xMultiPropSet->firePropertiesChangeEvent( lcl_getLanguageDependentProperties(), xListener );
+ uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
+ pHelper = new UnoPropertyArrayHelper( aIDs );
}
+ return *pHelper;
}
-void SAL_CALL UnoDialogControl::endDialog( ::sal_Int32 i_result ) throw (RuntimeException)
+// beans::XMultiPropertySet
+uno::Reference< beans::XPropertySetInfo > UnoPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
{
- Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
- if ( xPeerDialog.is() )
- xPeerDialog->endDialog( i_result );
+ static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
}
-void SAL_CALL UnoDialogControl::setHelpId( ::sal_Int32 i_id ) throw (RuntimeException)
+// ----------------------------------------------------------------------------
+sal_Bool SAL_CALL UnoPageModel::getGroupControl( ) throw (RuntimeException)
{
- Reference< XDialog2 > xPeerDialog( getPeer(), UNO_QUERY );
- if ( xPeerDialog.is() )
- xPeerDialog->setHelpId( i_id );
+ return sal_False;
}
-void UnoDialogControl::setTitle( const ::rtl::OUString& Title ) throw(RuntimeException)
+// Frame control
+
+// ----------------------------------------------------
+// class UnoFrameControl
+// ----------------------------------------------------
+UnoFrameControl::UnoFrameControl()
{
- SolarMutexGuard aSolarGuard;
- Any aAny;
- aAny <<= Title;
- ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ), aAny, sal_True );
+ maComponentInfos.nWidth = 280;
+ maComponentInfos.nHeight = 400;
}
-::rtl::OUString UnoDialogControl::getTitle() throw(RuntimeException)
+UnoFrameControl::~UnoFrameControl()
{
- SolarMutexGuard aSolarGuard;
- return ImplGetPropertyValue_UString( BASEPROPERTY_TITLE );
}
-sal_Int16 UnoDialogControl::execute() throw(RuntimeException)
+::rtl::OUString UnoFrameControl::GetComponentServiceName()
{
- SolarMutexGuard aSolarGuard;
- sal_Int16 nDone = -1;
- if ( getPeer().is() )
- {
- Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
- if( xDlg.is() )
- {
- GetComponentInfos().bVisible = sal_True;
- nDone = xDlg->execute();
- GetComponentInfos().bVisible = sal_False;
- }
- }
- return nDone;
+ return ::rtl::OUString::createFromAscii( "frame" );
}
-void UnoDialogControl::endExecute() throw(RuntimeException)
+void UnoFrameControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
{
- SolarMutexGuard aSolarGuard;
- if ( getPeer().is() )
+ bool bOwnCtrl = false;
+ rtl::OUString sTitle;
+ if ( rxCtrl.get() == Reference<XControl>( this ).get() )
+ bOwnCtrl = true;
+ Reference< XPropertySet > xProps( getModel(), UNO_QUERY );
+ //xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_TITLE ) ) >>= sTitle;
+ xProps->getPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ) ) >>= sTitle;
+
+ UnoParentControl::ImplSetPosSize( rxCtrl );
+ Reference < XWindow > xW( rxCtrl, UNO_QUERY );
+ if ( !bOwnCtrl && xW.is() && sTitle.getLength() )
{
- Reference< XDialog > xDlg( getPeer(), UNO_QUERY );
- if( xDlg.is() )
+ awt::Rectangle aSizePos = xW->getPosSize();
+
+ sal_Int32 nX = aSizePos.X, nY = aSizePos.Y, nWidth = aSizePos.Width, nHeight = aSizePos.Height;
+ // Retrieve the values set by the base class
+ OutputDevice*pOutDev = Application::GetDefaultDevice();
+ if ( pOutDev )
{
- xDlg->endExecute();
- GetComponentInfos().bVisible = sal_False;
+ if ( !bOwnCtrl && sTitle.getLength() )
+ {
+ // Adjust Y based on height of Title
+ ::Rectangle aRect = pOutDev->GetTextRect( aRect, sTitle );
+ nY = nY + ( aRect.GetHeight() / 2 );
+ }
}
+ else
+ {
+ Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True );
+ Reference< XDevice > xD( xPeer, UNO_QUERY );
+
+ SimpleFontMetric aFM;
+ FontDescriptor aFD;
+ Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
+ aVal >>= aFD;
+ if ( aFD.StyleName.getLength() )
+ {
+ Reference< XFont > xFont = xD->getFont( aFD );
+ aFM = xFont->getFontMetric();
+ }
+ else
+ {
+ Reference< XGraphics > xG = xD->createGraphics();
+ aFM = xG->getFontMetric();
+ }
+
+ sal_Int16 nH = aFM.Ascent + aFM.Descent;
+ if ( !bOwnCtrl && sTitle.getLength() )
+ // offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
+ nY = nY + ( nH / 8); // how do I test this
+ }
+ xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
}
}
-// XModifyListener
-void SAL_CALL UnoDialogControl::modified(
- const lang::EventObject& /*rEvent*/ )
-throw (RuntimeException)
+// ------------- UnoFrameModel -----------------
+
+UnoFrameModel::UnoFrameModel() : UnoControlDialogModel( false )
{
- ImplUpdateResourceResolver();
+ ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
+ ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
+ ImplRegisterProperty( BASEPROPERTY_ENABLED );
+ ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
+ ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
+ ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
+ ImplRegisterProperty( BASEPROPERTY_HELPURL );
+ ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
+ ImplRegisterProperty( BASEPROPERTY_LABEL );
+ ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
+ ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
+ ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
}
-// ----------------------------------------------------
-// Helper Method to convert relative url to physical location
-// ----------------------------------------------------
+UnoFrameModel::UnoFrameModel( const UnoFrameModel& rModel )
+ : UnoControlDialogModel( rModel )
+{
+}
-::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl )
+UnoFrameModel::~UnoFrameModel()
{
+}
- ::rtl::OUString ret;
+UnoControlModel*
+UnoFrameModel::Clone() const
+{
+ // clone the container itself
+ UnoFrameModel* pClone = new UnoFrameModel( *this );
- ::rtl::OUString baseLocation;
- ::rtl::OUString url;
+ // clone all children
+ ::std::for_each(
+ maModels.begin(), maModels.end(),
+ CloneControlModel( pClone->maModels )
+ );
- rbase >>= baseLocation;
- rUrl >>= url;
+ return pClone;
+}
- ::rtl::OUString absoluteURL( url );
- if ( url.getLength() > 0 )
+::rtl::OUString UnoFrameModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( szServiceName_UnoFrameModel );
+}
+
+uno::Any UnoFrameModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
+{
+ if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
{
- // Don't adjust GraphicObject url(s)
- if ( url.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
- {
- INetURLObject urlObj(baseLocation);
- urlObj.removeSegment();
- baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE );
- ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, ret );
- }
- else
- ret = url;
+ uno::Any aAny;
+ aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoFrameControl );
+ return aAny;
+ }
+ return UnoControlDialogModel::ImplGetDefaultValue( nPropId );
+}
- const INetURLObject protocolCheck( url );
- const INetProtocol protocol = protocolCheck.GetProtocol();
- if ( protocol == INET_PROT_NOT_VALID )
- {
- ::rtl::OUString testAbsoluteURL;
- if ( ::osl::FileBase::E_None == ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, testAbsoluteURL ) )
- absoluteURL = testAbsoluteURL;
- }
+::cppu::IPropertyArrayHelper& UnoFrameModel::getInfoHelper()
+{
+ static UnoPropertyArrayHelper* pHelper = NULL;
+ if ( !pHelper )
+ {
+ uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
+ pHelper = new UnoPropertyArrayHelper( aIDs );
}
+ return *pHelper;
+}
- return absoluteURL;
+// beans::XMultiPropertySet
+uno::Reference< beans::XPropertySetInfo > UnoFrameModel::getPropertySetInfo( ) throw(uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */