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

Generated by: LCOV version 1.11