LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - eformspropertyhandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 250 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10