LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/propctrlr - eformspropertyhandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 250 0.0 %
Date: 2012-12-27 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "eformspropertyhandler.hxx"
      21             : #include "formstrings.hxx"
      22             : #include "formmetadata.hxx"
      23             : #include "propctrlr.hrc"
      24             : #include "formbrowsertools.hxx"
      25             : #include "eformshelper.hxx"
      26             : #include "handlerhelper.hxx"
      27             : 
      28             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      29             : #include <com/sun/star/inspection/PropertyControlType.hpp>
      30             : #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
      31             : #include <tools/debug.hxx>
      32             : 
      33             : #include <functional>
      34             : 
      35             : //------------------------------------------------------------------------
      36           0 : extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler()
      37             : {
      38           0 :     ::pcr::EFormsPropertyHandler::registerImplementation();
      39           0 : }
      40             : 
      41             : //........................................................................
      42             : namespace pcr
      43             : {
      44             : //........................................................................
      45             : 
      46             :     using namespace ::com::sun::star;
      47             :     using namespace ::com::sun::star::uno;
      48             :     using namespace ::com::sun::star::lang;
      49             :     using namespace ::com::sun::star::beans;
      50             :     using namespace ::com::sun::star::xforms;
      51             :     using namespace ::com::sun::star::script;
      52             :     using namespace ::com::sun::star::ui::dialogs;
      53             :     using namespace ::com::sun::star::form::binding;
      54             :     using namespace ::com::sun::star::inspection;
      55             : 
      56             :     //====================================================================
      57             :     //= EFormsPropertyHandler
      58             :     //====================================================================
      59             :     DBG_NAME( EFormsPropertyHandler )
      60             :     //--------------------------------------------------------------------
      61           0 :     EFormsPropertyHandler::EFormsPropertyHandler( const Reference< XComponentContext >& _rxContext )
      62             :         :EFormsPropertyHandler_Base( _rxContext )
      63           0 :         ,m_bSimulatingModelChange( false )
      64             :     {
      65             :         DBG_CTOR( EFormsPropertyHandler, NULL );
      66           0 :     }
      67             : 
      68             :     //--------------------------------------------------------------------
      69           0 :     EFormsPropertyHandler::~EFormsPropertyHandler( )
      70             :     {
      71             :         DBG_DTOR( EFormsPropertyHandler, NULL );
      72           0 :     }
      73             : 
      74             :     //--------------------------------------------------------------------
      75           0 :     ::rtl::OUString SAL_CALL EFormsPropertyHandler::getImplementationName_static(  ) throw (RuntimeException)
      76             :     {
      77           0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EFormsPropertyHandler" ) );
      78             :     }
      79             : 
      80             :     //--------------------------------------------------------------------
      81           0 :     Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupportedServiceNames_static(  ) throw (RuntimeException)
      82             :     {
      83           0 :         Sequence< ::rtl::OUString > aSupported( 1 );
      84           0 :         aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XMLFormsPropertyHandler" ) );
      85           0 :         return aSupported;
      86             :     }
      87             : 
      88             :     //--------------------------------------------------------------------
      89           0 :     ::rtl::OUString EFormsPropertyHandler::getModelNamePropertyValue() const
      90             :     {
      91           0 :         ::rtl::OUString sModelName = m_pHelper->getCurrentFormModelName();
      92           0 :         if ( sModelName.isEmpty() )
      93           0 :             sModelName = m_sBindingLessModelName;
      94           0 :         return sModelName;
      95             :     }
      96             : 
      97             :     //--------------------------------------------------------------------
      98           0 :     Any SAL_CALL EFormsPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
      99             :     {
     100           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     101           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     102             : 
     103             :         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::getPropertyValue: we don't have any SupportedProperties!" );
     104             :             // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
     105             : 
     106           0 :         Any aReturn;
     107             :         try
     108             :         {
     109           0 :             switch ( nPropId )
     110             :             {
     111             :             case PROPERTY_ID_LIST_BINDING:
     112           0 :                 aReturn <<= m_pHelper->getCurrentListSourceBinding();
     113           0 :                 break;
     114             : 
     115             :             case PROPERTY_ID_XML_DATA_MODEL:
     116           0 :                 aReturn <<= getModelNamePropertyValue();
     117           0 :                 break;
     118             : 
     119             :             case PROPERTY_ID_BINDING_NAME:
     120           0 :                 aReturn <<= m_pHelper->getCurrentBindingName();
     121           0 :                 break;
     122             : 
     123             :             case PROPERTY_ID_BIND_EXPRESSION:
     124             :             case PROPERTY_ID_XSD_CONSTRAINT:
     125             :             case PROPERTY_ID_XSD_CALCULATION:
     126             :             case PROPERTY_ID_XSD_REQUIRED:
     127             :             case PROPERTY_ID_XSD_RELEVANT:
     128             :             case PROPERTY_ID_XSD_READONLY:
     129             :             {
     130           0 :                 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
     131           0 :                 if ( xBindingProps.is() )
     132             :                 {
     133           0 :                     aReturn = xBindingProps->getPropertyValue( _rPropertyName );
     134             :                     DBG_ASSERT( aReturn.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
     135             :                         "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
     136             :                 }
     137             :                 else
     138           0 :                     aReturn <<= ::rtl::OUString();
     139             :             }
     140           0 :             break;
     141             : 
     142             :             default:
     143             :                 OSL_FAIL( "EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
     144           0 :                 break;
     145             :             }
     146             :         }
     147           0 :         catch( const Exception& )
     148             :         {
     149             : #if OSL_DEBUG_LEVEL > 0
     150             :             ::rtl::OString sMessage( "EFormsPropertyHandler::getPropertyValue: caught an exception!" );
     151             :             sMessage += "\n(have been asked for the \"";
     152             :             sMessage += ::rtl::OString( _rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
     153             :             sMessage += "\" property.)";
     154             :             OSL_FAIL( sMessage.getStr() );
     155             : #endif
     156             :         }
     157           0 :         return aReturn;
     158             :     }
     159             : 
     160             :     //--------------------------------------------------------------------
     161           0 :     void SAL_CALL EFormsPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
     162             :     {
     163           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     164           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     165             : 
     166             :         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::setPropertyValue: we don't have any SupportedProperties!" );
     167             :             // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
     168             : 
     169             :         try
     170             :         {
     171           0 :             Any aOldValue = getPropertyValue( _rPropertyName );
     172             : 
     173           0 :             switch ( nPropId )
     174             :             {
     175             :             case PROPERTY_ID_LIST_BINDING:
     176             :             {
     177           0 :                 Reference< XListEntrySource > xSource;
     178           0 :                 OSL_VERIFY( _rValue >>= xSource );
     179           0 :                 m_pHelper->setListSourceBinding( xSource );
     180             :             }
     181           0 :             break;
     182             : 
     183             :             case PROPERTY_ID_XML_DATA_MODEL:
     184             :             {
     185           0 :                 OSL_VERIFY( _rValue >>= m_sBindingLessModelName );
     186             : 
     187             :                 // if the model changed, reset the binding to NULL
     188           0 :                 if ( m_pHelper->getCurrentFormModelName() != m_sBindingLessModelName )
     189             :                 {
     190           0 :                     ::rtl::OUString sOldBindingName = m_pHelper->getCurrentBindingName();
     191           0 :                     m_pHelper->setBinding( NULL );
     192             :                     firePropertyChange( PROPERTY_BINDING_NAME, PROPERTY_ID_BINDING_NAME,
     193           0 :                         makeAny( sOldBindingName ), makeAny( ::rtl::OUString() ) );
     194             :                 }
     195             :             }
     196           0 :             break;
     197             : 
     198             :             case PROPERTY_ID_BINDING_NAME:
     199             :             {
     200           0 :                 ::rtl::OUString sNewBindingName;
     201           0 :                 OSL_VERIFY( _rValue >>= sNewBindingName );
     202             : 
     203           0 :                 bool bPreviouslyEmptyModel = !m_pHelper->getCurrentFormModel().is();
     204             : 
     205           0 :                 Reference< XPropertySet > xNewBinding;
     206           0 :                 if ( !sNewBindingName.isEmpty() )
     207             :                     // obtain the binding with this name, for the current model
     208           0 :                     xNewBinding = m_pHelper->getOrCreateBindingForModel( getModelNamePropertyValue(), sNewBindingName );
     209             : 
     210           0 :                 m_pHelper->setBinding( xNewBinding );
     211             : 
     212           0 :                 if ( bPreviouslyEmptyModel )
     213             :                 {   // simulate a property change for the model property
     214             :                     // This is because we "simulate" the Model property by remembering the
     215             :                     // value ourself. Other instances might, however, not know this value,
     216             :                     // but prefer to retrieve it somewhere else - e.g. from the EFormsHelper
     217             :                     //
     218             :                     // The really correct solution would be if *all* property handlers
     219             :                     // obtain a "current property value" for *all* properties from a central
     220             :                     // instance. Then, handler A could ask it for the value of property
     221             :                     // X, and this request would be re-routed to handler B, which ultimately
     222             :                     // knows the current value.
     223             :                     // However, there's no such mechanism in place currently.
     224           0 :                     m_bSimulatingModelChange = true;
     225             :                     firePropertyChange( PROPERTY_XML_DATA_MODEL, PROPERTY_ID_XML_DATA_MODEL,
     226           0 :                         makeAny( ::rtl::OUString() ), makeAny( getModelNamePropertyValue() ) );
     227           0 :                     m_bSimulatingModelChange = false;
     228           0 :                 }
     229             :             }
     230           0 :             break;
     231             : 
     232             :             case PROPERTY_ID_BIND_EXPRESSION:
     233             :             {
     234           0 :                 Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
     235             :                 OSL_ENSURE( xBinding.is(), "You should not reach this without an active binding!" );
     236           0 :                 if ( xBinding.is() )
     237           0 :                     xBinding->setPropertyValue( PROPERTY_BIND_EXPRESSION, _rValue );
     238             :             }
     239           0 :             break;
     240             : 
     241             :             case PROPERTY_ID_XSD_REQUIRED:
     242             :             case PROPERTY_ID_XSD_RELEVANT:
     243             :             case PROPERTY_ID_XSD_READONLY:
     244             :             case PROPERTY_ID_XSD_CONSTRAINT:
     245             :             case PROPERTY_ID_XSD_CALCULATION:
     246             :             {
     247           0 :                 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
     248             :                 DBG_ASSERT( xBindingProps.is(), "EFormsPropertyHandler::setPropertyValue: how can I set a property if there's no binding?" );
     249           0 :                 if ( xBindingProps.is() )
     250             :                 {
     251             :                     DBG_ASSERT( _rValue.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
     252             :                         "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
     253           0 :                     xBindingProps->setPropertyValue( _rPropertyName, _rValue );
     254           0 :                 }
     255             :             }
     256           0 :             break;
     257             : 
     258             :             default:
     259             :                 OSL_FAIL( "EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
     260           0 :                 break;
     261             :             }
     262             : 
     263           0 :             impl_setContextDocumentModified_nothrow();
     264             : 
     265           0 :             Any aNewValue( getPropertyValue( _rPropertyName ) );
     266           0 :             firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
     267             :         }
     268           0 :         catch( const Exception& )
     269             :         {
     270             :             OSL_FAIL( "EFormsPropertyHandler::setPropertyValue: caught an exception!" );
     271           0 :         }
     272           0 :     }
     273             : 
     274             :     //--------------------------------------------------------------------
     275           0 :     void EFormsPropertyHandler::onNewComponent()
     276             :     {
     277           0 :         EFormsPropertyHandler_Base::onNewComponent();
     278             : 
     279           0 :         Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
     280             :         DBG_ASSERT( xDocument.is(), "EFormsPropertyHandler::onNewComponent: no document!" );
     281           0 :         if ( EFormsHelper::isEForm( xDocument ) )
     282           0 :             m_pHelper.reset( new EFormsHelper( m_aMutex, m_xComponent, xDocument ) );
     283             :         else
     284           0 :             m_pHelper.reset( NULL );
     285           0 :     }
     286             : 
     287             :     //--------------------------------------------------------------------
     288           0 :     Sequence< Property > SAL_CALL EFormsPropertyHandler::doDescribeSupportedProperties() const
     289             :     {
     290           0 :         ::std::vector< Property > aProperties;
     291             : 
     292           0 :         if ( m_pHelper.get() )
     293             :         {
     294           0 :             if ( m_pHelper->canBindToAnyDataType() )
     295             :             {
     296           0 :                 aProperties.reserve( 7 );
     297           0 :                 addStringPropertyDescription( aProperties, PROPERTY_XML_DATA_MODEL );
     298           0 :                 addStringPropertyDescription( aProperties, PROPERTY_BINDING_NAME );
     299           0 :                 addStringPropertyDescription( aProperties, PROPERTY_BIND_EXPRESSION );
     300           0 :                 addStringPropertyDescription( aProperties, PROPERTY_XSD_REQUIRED );
     301           0 :                 addStringPropertyDescription( aProperties, PROPERTY_XSD_RELEVANT );
     302           0 :                 addStringPropertyDescription( aProperties, PROPERTY_XSD_READONLY );
     303           0 :                 addStringPropertyDescription( aProperties, PROPERTY_XSD_CONSTRAINT );
     304           0 :                 addStringPropertyDescription( aProperties, PROPERTY_XSD_CALCULATION );
     305             :             }
     306           0 :             if ( m_pHelper->isListEntrySink() )
     307             :             {
     308             :                 implAddPropertyDescription( aProperties, PROPERTY_LIST_BINDING,
     309           0 :                     ::getCppuType( static_cast< Reference< XListEntrySource > * >( NULL ) ) );
     310             :             }
     311             :         }
     312             : 
     313           0 :         if ( aProperties.empty() )
     314           0 :             return Sequence< Property >();
     315           0 :         return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
     316             :     }
     317             : 
     318             :     //--------------------------------------------------------------------
     319           0 :     Any SAL_CALL EFormsPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
     320             :     {
     321           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     322           0 :         Any aReturn;
     323             : 
     324             :         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
     325           0 :         if ( !m_pHelper.get() )
     326             :             return aReturn;
     327             : 
     328           0 :         PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
     329             : 
     330           0 :         ::rtl::OUString sControlValue;
     331           0 :         switch ( nPropId )
     332             :         {
     333             :         case PROPERTY_ID_LIST_BINDING:
     334             :         {
     335           0 :             OSL_VERIFY( _rControlValue >>= sControlValue );
     336           0 :             Reference< XListEntrySource > xListSource( m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ), UNO_QUERY );
     337             :             OSL_ENSURE( xListSource.is() || !m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ).is(),
     338             :                 "EFormsPropertyHandler::convertToPropertyValue: there's a binding which is no ListEntrySource!" );
     339           0 :             aReturn <<= xListSource;
     340             :         }
     341           0 :         break;
     342             : 
     343             :         default:
     344           0 :             aReturn = EFormsPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
     345           0 :             break;
     346             :         }
     347             : 
     348           0 :         return aReturn;
     349             :     }
     350             : 
     351             :     //--------------------------------------------------------------------
     352           0 :     Any SAL_CALL EFormsPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
     353             :     {
     354           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     355           0 :         Any aReturn;
     356             : 
     357             :         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
     358           0 :         if ( !m_pHelper.get() )
     359             :             return aReturn;
     360             : 
     361           0 :         PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
     362             : 
     363             :         OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
     364             :             "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
     365             : 
     366           0 :         switch ( nPropId )
     367             :         {
     368             :         case PROPERTY_ID_LIST_BINDING:
     369             :         {
     370           0 :             Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
     371           0 :             if ( xListSourceBinding.is() )
     372           0 :                 aReturn <<= m_pHelper->getModelElementUIName( EFormsHelper::Binding, xListSourceBinding );
     373             :         }
     374           0 :         break;
     375             : 
     376             :         default:
     377           0 :             aReturn = EFormsPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
     378           0 :             break;
     379             :         }
     380             : 
     381           0 :         return aReturn;
     382             :     }
     383             : 
     384             :     //--------------------------------------------------------------------
     385           0 :     Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
     386             :     {
     387           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     388           0 :         if ( !m_pHelper.get() )
     389           0 :             return Sequence< ::rtl::OUString >();
     390             : 
     391           0 :         ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
     392           0 :         aInterestedInActuations[ 0 ] = PROPERTY_XML_DATA_MODEL;
     393           0 :         aInterestedInActuations[ 1 ] = PROPERTY_BINDING_NAME;
     394           0 :         return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
     395             :     }
     396             : 
     397             :     //--------------------------------------------------------------------
     398           0 :     Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
     399             :     {
     400           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     401           0 :         if ( !m_pHelper.get() )
     402           0 :             return Sequence< ::rtl::OUString >();
     403             : 
     404           0 :         Sequence< ::rtl::OUString > aReturn( 1 );
     405           0 :         aReturn[ 0 ] = PROPERTY_INPUT_REQUIRED;
     406           0 :         return aReturn;
     407             :     }
     408             : 
     409             :     //--------------------------------------------------------------------
     410           0 :     LineDescriptor SAL_CALL EFormsPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
     411             :         const Reference< XPropertyControlFactory >& _rxControlFactory )
     412             :         throw (UnknownPropertyException, NullPointerException, RuntimeException)
     413             :     {
     414           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     415           0 :         if ( !_rxControlFactory.is() )
     416           0 :             throw NullPointerException();
     417           0 :         if ( !m_pHelper.get() )
     418           0 :             throw RuntimeException();
     419             : 
     420           0 :         LineDescriptor aDescriptor;
     421           0 :         sal_Int16 nControlType = PropertyControlType::TextField;
     422           0 :         ::std::vector< ::rtl::OUString > aListEntries;
     423           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     424           0 :         switch ( nPropId )
     425             :         {
     426             :         case PROPERTY_ID_LIST_BINDING:
     427           0 :             nControlType = PropertyControlType::ListBox;
     428           0 :             const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
     429           0 :             break;
     430             : 
     431             :         case PROPERTY_ID_XML_DATA_MODEL:
     432           0 :             nControlType = PropertyControlType::ListBox;
     433           0 :             m_pHelper->getFormModelNames( aListEntries );
     434           0 :             break;
     435             : 
     436             :         case PROPERTY_ID_BINDING_NAME:
     437             :         {
     438           0 :             nControlType = PropertyControlType::ComboBox;
     439           0 :             ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
     440           0 :             if ( !sCurrentModel.isEmpty() )
     441           0 :                 m_pHelper->getBindingNames( sCurrentModel, aListEntries );
     442             :         }
     443           0 :         break;
     444             : 
     445           0 :         case PROPERTY_ID_BIND_EXPRESSION:   aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BIND_EXPRESSION); break;
     446           0 :         case PROPERTY_ID_XSD_REQUIRED:      aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_REQUIRED);    break;
     447           0 :         case PROPERTY_ID_XSD_RELEVANT:      aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_RELEVANT);    break;
     448           0 :         case PROPERTY_ID_XSD_READONLY:      aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_READONLY);    break;
     449           0 :         case PROPERTY_ID_XSD_CONSTRAINT:    aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CONSTRAINT);  break;
     450           0 :         case PROPERTY_ID_XSD_CALCULATION:   aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CALCULATION); break;
     451             : 
     452             :         default:
     453             :             OSL_FAIL( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
     454           0 :             break;
     455             :         }
     456             : 
     457           0 :         switch ( nControlType )
     458             :         {
     459             :         case PropertyControlType::ListBox:
     460           0 :             aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
     461           0 :             break;
     462             :         case PropertyControlType::ComboBox:
     463           0 :             aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
     464           0 :             break;
     465             :         default:
     466           0 :             aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
     467           0 :             break;
     468             :         }
     469             : 
     470           0 :         aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
     471           0 :         aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
     472           0 :         aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
     473           0 :         return aDescriptor;
     474             :     }
     475             : 
     476             :     //--------------------------------------------------------------------
     477           0 :     InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
     478             :     {
     479           0 :         if ( !_rxInspectorUI.is() )
     480           0 :             throw NullPointerException();
     481             : 
     482           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     483             :         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::onInteractivePropertySelection: we do not have any SupportedProperties!" );
     484           0 :         if ( !m_pHelper.get() )
     485           0 :             return InteractiveSelectionResult_Cancelled;
     486             : 
     487           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     488             :         (void)nPropId;
     489             :         OSL_ENSURE( ( PROPERTY_ID_BINDING_NAME == nPropId )
     490             :                  || ( PROPERTY_ID_BIND_EXPRESSION == nPropId )
     491             :                  || ( PROPERTY_ID_XSD_REQUIRED == nPropId )
     492             :                  || ( PROPERTY_ID_XSD_RELEVANT == nPropId )
     493             :                  || ( PROPERTY_ID_XSD_READONLY == nPropId )
     494             :                  || ( PROPERTY_ID_XSD_CONSTRAINT == nPropId )
     495             :                  || ( PROPERTY_ID_XSD_CALCULATION == nPropId ), "EFormsPropertyHandler::onInteractivePropertySelection: unexpected!" );
     496             : 
     497             :         try
     498             :         {
     499           0 :             Reference< XExecutableDialog > xDialog;
     500           0 :             m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
     501           0 :             Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
     502             : 
     503             :             // the model for the dialog to work with
     504           0 :             Reference< xforms::XModel > xModel( m_pHelper->getCurrentFormModel() );
     505             :             // the binding for the dialog to work with
     506           0 :             Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
     507             :             // the aspect of the binding which the dialog should modify
     508           0 :             ::rtl::OUString sFacetName( _rPropertyName );
     509             : 
     510             :             OSL_ENSURE( xModel.is() && xBinding.is() && !sFacetName.isEmpty(),
     511             :                 "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
     512           0 :             if ( !( xModel.is() && xBinding.is() && !sFacetName.isEmpty() ) )
     513           0 :                 return InteractiveSelectionResult_Cancelled;
     514             : 
     515           0 :             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ), makeAny( xModel ) );
     516           0 :             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ), makeAny( xBinding ) );
     517           0 :             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ), makeAny( sFacetName ) );
     518             : 
     519           0 :             if ( !xDialog->execute() )
     520             :                 // cancelled
     521           0 :                 return InteractiveSelectionResult_Cancelled;
     522             : 
     523           0 :             _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
     524           0 :             return InteractiveSelectionResult_ObtainedValue;
     525             :         }
     526           0 :         catch( const Exception& )
     527             :         {
     528             :             OSL_FAIL( "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
     529             :         }
     530             : 
     531             :         // something went wrong here ...(but has been asserted already)
     532           0 :         return InteractiveSelectionResult_Cancelled;
     533             :     }
     534             : 
     535             :     //--------------------------------------------------------------------
     536           0 :     void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
     537             :     {
     538           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     539           0 :         EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
     540           0 :         if ( m_pHelper.get() )
     541           0 :             m_pHelper->registerBindingListener( _rxListener );
     542           0 :     }
     543             : 
     544             :     //--------------------------------------------------------------------
     545           0 :     void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
     546             :     {
     547           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     548           0 :         if ( m_pHelper.get() )
     549           0 :             m_pHelper->revokeBindingListener( _rxListener );
     550           0 :         EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
     551           0 :     }
     552             : 
     553             :     //--------------------------------------------------------------------
     554           0 :     void SAL_CALL EFormsPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
     555             :     {
     556           0 :         if ( !_rxInspectorUI.is() )
     557           0 :             throw NullPointerException();
     558             : 
     559           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     560           0 :         PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
     561             :         OSL_PRECOND( m_pHelper.get(), "EFormsPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
     562             :             // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
     563             : 
     564             :         DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
     565           0 :         if ( !_rxInspectorUI.is() )
     566           0 :             return;
     567             : 
     568           0 :         switch ( nActuatingPropId )
     569             :         {
     570             :         case PROPERTY_ID_XML_DATA_MODEL:
     571             :         {
     572           0 :             if ( m_bSimulatingModelChange )
     573             :                 break;
     574           0 :             ::rtl::OUString sDataModelName;
     575           0 :             OSL_VERIFY( _rNewValue >>= sDataModelName );
     576           0 :             sal_Bool bBoundToSomeModel = !sDataModelName.isEmpty();
     577           0 :             _rxInspectorUI->rebuildPropertyUI( PROPERTY_BINDING_NAME );
     578           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_BINDING_NAME, bBoundToSomeModel );
     579             :         }
     580             :         // NO break
     581             : 
     582             :         case PROPERTY_ID_BINDING_NAME:
     583             :         {
     584           0 :             sal_Bool bHaveABinding = !m_pHelper->getCurrentBindingName().isEmpty();
     585           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_BIND_EXPRESSION, bHaveABinding );
     586           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_REQUIRED, bHaveABinding );
     587           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_RELEVANT, bHaveABinding );
     588           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_READONLY, bHaveABinding );
     589           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CONSTRAINT, bHaveABinding );
     590           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CALCULATION, bHaveABinding );
     591           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_DATA_TYPE, bHaveABinding );
     592             :         }
     593           0 :         break;
     594             : 
     595             :         default:
     596             :             OSL_FAIL( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
     597           0 :             break;
     598           0 :         }
     599             :     }
     600             : 
     601             : //........................................................................
     602             : } // namespace pcr
     603             : //........................................................................
     604             : 
     605             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10