LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - formcontroller.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 98 0.0 %
Date: 2012-08-25 Functions: 0 23 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 "formcontroller.hxx"
      30                 :            : #include "pcrcommon.hxx"
      31                 :            : #include "formstrings.hxx"
      32                 :            : #include "defaultforminspection.hxx"
      33                 :            : #include "propctrlr.hrc"
      34                 :            : 
      35                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      36                 :            : #include <com/sun/star/form/XGridColumnFactory.hpp>
      37                 :            : #include <com/sun/star/form/XForm.hpp>
      38                 :            : #include <com/sun/star/container/XChild.hpp>
      39                 :            : #include <cppuhelper/typeprovider.hxx>
      40                 :            : #include <toolkit/helper/vclunohelper.hxx>
      41                 :            : 
      42                 :            : //------------------------------------------------------------------------
      43                 :          0 : extern "C" void SAL_CALL createRegistryInfo_FormController()
      44                 :            : {
      45                 :          0 :     ::pcr::OAutoRegistration< ::pcr::FormController > aFormControllerRegistration;
      46                 :          0 :     ::pcr::OAutoRegistration< ::pcr::DialogController > aDialogControllerRegistration;
      47                 :          0 : }
      48                 :            : 
      49                 :            : //........................................................................
      50                 :            : namespace pcr
      51                 :            : {
      52                 :            : //........................................................................
      53                 :            : 
      54                 :            :     /** === begin UNO using === **/
      55                 :            :     using ::com::sun::star::uno::Reference;
      56                 :            :     using ::com::sun::star::uno::TypeClass_INTERFACE;
      57                 :            :     using ::com::sun::star::uno::TypeClass_STRING;
      58                 :            :     using ::com::sun::star::uno::XComponentContext;
      59                 :            :     using ::com::sun::star::inspection::XObjectInspectorModel;
      60                 :            :     using ::com::sun::star::uno::RuntimeException;
      61                 :            :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      62                 :            :     using ::com::sun::star::uno::Sequence;
      63                 :            :     using ::com::sun::star::uno::XInterface;
      64                 :            :     using ::com::sun::star::beans::XPropertySetInfo;
      65                 :            :     using ::com::sun::star::beans::XPropertySet;
      66                 :            :     using ::com::sun::star::beans::Property;
      67                 :            :     using ::com::sun::star::uno::Any;
      68                 :            :     using ::com::sun::star::lang::IllegalArgumentException;
      69                 :            :     using ::com::sun::star::uno::Exception;
      70                 :            :     using ::com::sun::star::uno::Type;
      71                 :            :     using ::com::sun::star::util::VetoException;
      72                 :            :     using ::com::sun::star::beans::PropertyVetoException;
      73                 :            :     using ::com::sun::star::uno::UNO_QUERY;
      74                 :            :     using ::com::sun::star::form::XGridColumnFactory;
      75                 :            :     using ::com::sun::star::form::XForm;
      76                 :            :     using ::com::sun::star::container::XChild;
      77                 :            :     using ::com::sun::star::frame::XFrame;
      78                 :            :     using ::com::sun::star::awt::XWindow;
      79                 :            :     /** === end UNO using === **/
      80                 :            : 
      81                 :            :     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
      82                 :            : 
      83                 :            :     //====================================================================
      84                 :            :     //= FormController
      85                 :            :     //====================================================================
      86                 :            :     //--------------------------------------------------------------------
      87                 :          0 :     FormController::FormController( const Reference< XComponentContext >& _rxContext, ServiceDescriptor _aServiceDescriptor,
      88                 :            :             bool _bUseFormFormComponentHandlers )
      89                 :            :         :OPropertyBrowserController( _rxContext )
      90                 :            :         ,FormController_PropertyBase1( m_aBHelper )
      91                 :          0 :         ,m_aServiceDescriptor( _aServiceDescriptor )
      92                 :            :     {
      93                 :          0 :         osl_incrementInterlockedCount( &m_refCount );
      94                 :            :         {
      95                 :            :             Reference< XObjectInspectorModel > xModel(
      96                 :          0 :                 *(new DefaultFormComponentInspectorModel( _rxContext, _bUseFormFormComponentHandlers )),
      97                 :            :                 UNO_QUERY_THROW
      98                 :          0 :             );
      99                 :          0 :             setInspectorModel( xModel );
     100                 :            :         }
     101                 :          0 :         osl_decrementInterlockedCount( &m_refCount );
     102                 :          0 :     }
     103                 :            : 
     104                 :            :     //------------------------------------------------------------------------
     105                 :          0 :     FormController::~FormController()
     106                 :            :     {
     107                 :          0 :     }
     108                 :            : 
     109                 :            :     //------------------------------------------------------------------------
     110                 :          0 :     IMPLEMENT_FORWARD_XINTERFACE2( FormController, OPropertyBrowserController, FormController_PropertyBase1 )
     111                 :            : 
     112                 :            :     //------------------------------------------------------------------------
     113                 :          0 :     Sequence< Type > SAL_CALL FormController::getTypes(  ) throw(RuntimeException)
     114                 :            :     {
     115                 :            :         ::cppu::OTypeCollection aTypes(
     116                 :          0 :             ::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ),
     117                 :          0 :             ::getCppuType( static_cast< Reference< XMultiPropertySet >* >(NULL) ),
     118                 :          0 :             ::getCppuType( static_cast< Reference< XFastPropertySet >* >(NULL) ),
     119                 :          0 :             OPropertyBrowserController::getTypes());
     120                 :          0 :         return aTypes.getTypes();
     121                 :            :     }
     122                 :            : 
     123                 :            :     //------------------------------------------------------------------------
     124                 :          0 :     IMPLEMENT_GET_IMPLEMENTATION_ID( FormController )
     125                 :            : 
     126                 :            :     //------------------------------------------------------------------------
     127                 :          0 :     ::rtl::OUString SAL_CALL FormController::getImplementationName(  ) throw(RuntimeException)
     128                 :            :     {
     129                 :          0 :         return m_aServiceDescriptor.GetImplementationName();
     130                 :            :     }
     131                 :            : 
     132                 :            :     //------------------------------------------------------------------------
     133                 :          0 :     Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedServiceNames(  ) throw(RuntimeException)
     134                 :            :     {
     135                 :          0 :         Sequence< ::rtl::OUString > aSupported( m_aServiceDescriptor.GetSupportedServiceNames() );
     136                 :          0 :         aSupported.realloc( aSupported.getLength() + 1 );
     137                 :          0 :         aSupported[ aSupported.getLength() - 1 ] = ::rtl::OUString(  "com.sun.star.inspection.ObjectInspector"  );
     138                 :          0 :         return aSupported;
     139                 :            :     }
     140                 :            : 
     141                 :            :     //------------------------------------------------------------------------
     142                 :          0 :     ::rtl::OUString FormController::getImplementationName_static(  ) throw(RuntimeException)
     143                 :            :     {
     144                 :          0 :         return ::rtl::OUString("org.openoffice.comp.extensions.FormController");
     145                 :            :     }
     146                 :            : 
     147                 :            :     //------------------------------------------------------------------------
     148                 :          0 :     Sequence< ::rtl::OUString > FormController::getSupportedServiceNames_static(  ) throw(RuntimeException)
     149                 :            :     {
     150                 :          0 :         Sequence< ::rtl::OUString > aSupported(1);
     151                 :          0 :         aSupported[0] = ::rtl::OUString("com.sun.star.form.PropertyBrowserController");
     152                 :          0 :         return aSupported;
     153                 :            :     }
     154                 :            : 
     155                 :            :     //------------------------------------------------------------------------
     156                 :          0 :     Reference< XInterface > SAL_CALL FormController::Create(const Reference< XComponentContext >& _rxContext )
     157                 :            :     {
     158                 :            :         ServiceDescriptor aService;
     159                 :          0 :         aService.GetImplementationName = &FormController::getImplementationName_static;
     160                 :          0 :         aService.GetSupportedServiceNames = &FormController::getSupportedServiceNames_static;
     161                 :          0 :         return *(new FormController( _rxContext, aService, true ) );
     162                 :            :     }
     163                 :            : 
     164                 :            :     //------------------------------------------------------------------------
     165                 :          0 :     Reference< XPropertySetInfo > SAL_CALL FormController::getPropertySetInfo(  ) throw(RuntimeException)
     166                 :            :     {
     167                 :          0 :         return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     168                 :            :     }
     169                 :            : 
     170                 :            :     //------------------------------------------------------------------------
     171                 :          0 :     ::cppu::IPropertyArrayHelper& SAL_CALL FormController::getInfoHelper()
     172                 :            :     {
     173                 :          0 :         return *getArrayHelper();
     174                 :            :     }
     175                 :            : 
     176                 :            :     //------------------------------------------------------------------------
     177                 :          0 :     ::cppu::IPropertyArrayHelper* FormController::createArrayHelper( ) const
     178                 :            :     {
     179                 :          0 :         Sequence< Property > aProps( 2 );
     180                 :          0 :         aProps[0] = Property(
     181                 :            :             PROPERTY_CURRENTPAGE,
     182                 :            :             OWN_PROPERTY_ID_CURRENTPAGE,
     183                 :          0 :             ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ),
     184                 :            :             PropertyAttribute::TRANSIENT
     185                 :          0 :         );
     186                 :          0 :         aProps[1] = Property(
     187                 :            :             PROPERTY_INTROSPECTEDOBJECT,
     188                 :            :             OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
     189                 :          0 :             XPropertySet::static_type(),
     190                 :            :             PropertyAttribute::TRANSIENT | PropertyAttribute::CONSTRAINED
     191                 :          0 :         );
     192                 :          0 :         return new ::cppu::OPropertyArrayHelper( aProps );
     193                 :            :     }
     194                 :            : 
     195                 :            :     //------------------------------------------------------------------------
     196                 :          0 :     sal_Bool SAL_CALL FormController::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
     197                 :            :     {
     198                 :          0 :         switch ( nHandle )
     199                 :            :         {
     200                 :            :         case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
     201                 :          0 :             if ( rValue.getValueTypeClass() != TypeClass_INTERFACE )
     202                 :          0 :                 throw IllegalArgumentException();
     203                 :          0 :             break;
     204                 :            :         case OWN_PROPERTY_ID_CURRENTPAGE:
     205                 :          0 :             if ( rValue.getValueTypeClass() != TypeClass_STRING )
     206                 :          0 :                 throw IllegalArgumentException();
     207                 :          0 :             break;
     208                 :            :         }
     209                 :            : 
     210                 :          0 :         getFastPropertyValue( rOldValue, nHandle );
     211                 :          0 :         rConvertedValue = rValue;
     212                 :          0 :         return sal_True;
     213                 :            :     }
     214                 :            : 
     215                 :            :     //------------------------------------------------------------------------
     216                 :          0 :     void SAL_CALL FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
     217                 :            :     {
     218                 :          0 :         switch ( _nHandle )
     219                 :            :         {
     220                 :            :         case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
     221                 :            :         {
     222                 :          0 :             Reference< XObjectInspectorModel > xModel( getInspectorModel() );
     223                 :          0 :             if ( xModel.is() )
     224                 :            :             {
     225                 :            :                 try
     226                 :            :                 {
     227                 :          0 :                     m_xCurrentInspectee.set( _rValue, UNO_QUERY );
     228                 :          0 :                     Sequence< Reference< XInterface > > aObjects;
     229                 :          0 :                     if ( m_xCurrentInspectee.is() )
     230                 :            :                     {
     231                 :          0 :                         aObjects.realloc( 1 );
     232                 :          0 :                         aObjects[0] = m_xCurrentInspectee;
     233                 :            :                     }
     234                 :            : 
     235                 :          0 :                     Reference< XObjectInspector > xInspector( *this, UNO_QUERY_THROW );
     236                 :          0 :                     xInspector->inspect( aObjects );
     237                 :            :                 }
     238                 :          0 :                 catch( const VetoException& e )
     239                 :            :                 {
     240                 :          0 :                     throw PropertyVetoException( e.Message, e.Context );
     241                 :            :                 }
     242                 :          0 :             }
     243                 :            :         }
     244                 :          0 :         break;
     245                 :            :         case OWN_PROPERTY_ID_CURRENTPAGE:
     246                 :          0 :             restoreViewData( _rValue );
     247                 :          0 :             break;
     248                 :            :         }
     249                 :          0 :     }
     250                 :            : 
     251                 :            :     //------------------------------------------------------------------------
     252                 :          0 :     void SAL_CALL FormController::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const
     253                 :            :     {
     254                 :          0 :         switch ( nHandle )
     255                 :            :         {
     256                 :            :         case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
     257                 :          0 :             rValue <<= m_xCurrentInspectee;
     258                 :          0 :             break;
     259                 :            : 
     260                 :            :         case OWN_PROPERTY_ID_CURRENTPAGE:
     261                 :          0 :             rValue = const_cast< FormController* >( this )->getViewData();
     262                 :          0 :             break;
     263                 :            :         }
     264                 :          0 :     }
     265                 :            : 
     266                 :            :     //====================================================================
     267                 :            :     //= DialogController
     268                 :            :     //====================================================================
     269                 :            :     //------------------------------------------------------------------------
     270                 :          0 :     ::rtl::OUString DialogController::getImplementationName_static(  ) throw(RuntimeException)
     271                 :            :     {
     272                 :          0 :         return ::rtl::OUString("org.openoffice.comp.extensions.DialogController");
     273                 :            :     }
     274                 :            : 
     275                 :            :     //------------------------------------------------------------------------
     276                 :          0 :     Sequence< ::rtl::OUString > DialogController::getSupportedServiceNames_static(  ) throw(RuntimeException)
     277                 :            :     {
     278                 :          0 :         Sequence< ::rtl::OUString > aSupported(1);
     279                 :          0 :         aSupported[0] = ::rtl::OUString("com.sun.star.awt.PropertyBrowserController");
     280                 :          0 :         return aSupported;
     281                 :            :     }
     282                 :            : 
     283                 :            :     //------------------------------------------------------------------------
     284                 :          0 :     Reference< XInterface > SAL_CALL DialogController::Create(const Reference< XComponentContext >& _rxContext)
     285                 :            :     {
     286                 :            :         ServiceDescriptor aService;
     287                 :          0 :         aService.GetImplementationName = &DialogController::getImplementationName_static;
     288                 :          0 :         aService.GetSupportedServiceNames = &DialogController::getSupportedServiceNames_static;
     289                 :          0 :         return *(new FormController( _rxContext, aService, false ) );
     290                 :            :     }
     291                 :            : 
     292                 :            : //........................................................................
     293                 :            : } // namespace pcr
     294                 :            : //........................................................................
     295                 :            : 
     296                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10