LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - formcontroller.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 98 0.0 %
Date: 2014-04-14 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "formcontroller.hxx"
      21             : #include "pcrcommon.hxx"
      22             : #include "formstrings.hxx"
      23             : #include "defaultforminspection.hxx"
      24             : #include "propctrlr.hrc"
      25             : 
      26             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      27             : #include <com/sun/star/form/XGridColumnFactory.hpp>
      28             : #include <com/sun/star/form/XForm.hpp>
      29             : #include <com/sun/star/container/XChild.hpp>
      30             : #include <cppuhelper/typeprovider.hxx>
      31             : #include <toolkit/helper/vclunohelper.hxx>
      32             : 
      33             : 
      34           0 : extern "C" void SAL_CALL createRegistryInfo_FormController()
      35             : {
      36           0 :     ::pcr::OAutoRegistration< ::pcr::FormController > aFormControllerRegistration;
      37           0 :     ::pcr::OAutoRegistration< ::pcr::DialogController > aDialogControllerRegistration;
      38           0 : }
      39             : 
      40             : 
      41             : namespace pcr
      42             : {
      43             : 
      44             : 
      45             :     using ::com::sun::star::uno::Reference;
      46             :     using ::com::sun::star::uno::TypeClass_INTERFACE;
      47             :     using ::com::sun::star::uno::TypeClass_STRING;
      48             :     using ::com::sun::star::uno::XComponentContext;
      49             :     using ::com::sun::star::inspection::XObjectInspectorModel;
      50             :     using ::com::sun::star::uno::RuntimeException;
      51             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      52             :     using ::com::sun::star::uno::Sequence;
      53             :     using ::com::sun::star::uno::XInterface;
      54             :     using ::com::sun::star::beans::XPropertySetInfo;
      55             :     using ::com::sun::star::beans::XPropertySet;
      56             :     using ::com::sun::star::beans::Property;
      57             :     using ::com::sun::star::uno::Any;
      58             :     using ::com::sun::star::lang::IllegalArgumentException;
      59             :     using ::com::sun::star::uno::Exception;
      60             :     using ::com::sun::star::uno::Type;
      61             :     using ::com::sun::star::util::VetoException;
      62             :     using ::com::sun::star::beans::PropertyVetoException;
      63             :     using ::com::sun::star::uno::UNO_QUERY;
      64             :     using ::com::sun::star::form::XGridColumnFactory;
      65             :     using ::com::sun::star::form::XForm;
      66             :     using ::com::sun::star::container::XChild;
      67             :     using ::com::sun::star::frame::XFrame;
      68             :     using ::com::sun::star::awt::XWindow;
      69             : 
      70             :     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
      71             : 
      72             : 
      73             :     //= FormController
      74             : 
      75             : 
      76           0 :     FormController::FormController( const Reference< XComponentContext >& _rxContext, ServiceDescriptor _aServiceDescriptor,
      77             :             bool _bUseFormFormComponentHandlers )
      78             :         :OPropertyBrowserController( _rxContext )
      79             :         ,FormController_PropertyBase1( m_aBHelper )
      80           0 :         ,m_aServiceDescriptor( _aServiceDescriptor )
      81             :     {
      82           0 :         osl_atomic_increment( &m_refCount );
      83             :         {
      84             :             Reference< XObjectInspectorModel > xModel(
      85           0 :                 *(new DefaultFormComponentInspectorModel( _bUseFormFormComponentHandlers )),
      86             :                 UNO_QUERY_THROW
      87           0 :             );
      88           0 :             setInspectorModel( xModel );
      89             :         }
      90           0 :         osl_atomic_decrement( &m_refCount );
      91           0 :     }
      92             : 
      93             : 
      94           0 :     FormController::~FormController()
      95             :     {
      96           0 :     }
      97             : 
      98             : 
      99           0 :     IMPLEMENT_FORWARD_XINTERFACE2( FormController, OPropertyBrowserController, FormController_PropertyBase1 )
     100             : 
     101             : 
     102           0 :     Sequence< Type > SAL_CALL FormController::getTypes(  ) throw(RuntimeException, std::exception)
     103             :     {
     104             :         ::cppu::OTypeCollection aTypes(
     105           0 :             ::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ),
     106           0 :             ::getCppuType( static_cast< Reference< XMultiPropertySet >* >(NULL) ),
     107           0 :             ::getCppuType( static_cast< Reference< XFastPropertySet >* >(NULL) ),
     108           0 :             OPropertyBrowserController::getTypes());
     109           0 :         return aTypes.getTypes();
     110             :     }
     111             : 
     112             : 
     113           0 :     IMPLEMENT_GET_IMPLEMENTATION_ID( FormController )
     114             : 
     115             : 
     116           0 :     OUString SAL_CALL FormController::getImplementationName(  ) throw(RuntimeException, std::exception)
     117             :     {
     118           0 :         return m_aServiceDescriptor.GetImplementationName();
     119             :     }
     120             : 
     121             : 
     122           0 :     Sequence< OUString > SAL_CALL FormController::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
     123             :     {
     124           0 :         Sequence< OUString > aSupported( m_aServiceDescriptor.GetSupportedServiceNames() );
     125           0 :         aSupported.realloc( aSupported.getLength() + 1 );
     126           0 :         aSupported[ aSupported.getLength() - 1 ] = "com.sun.star.inspection.ObjectInspector";
     127           0 :         return aSupported;
     128             :     }
     129             : 
     130             : 
     131           0 :     OUString FormController::getImplementationName_static(  ) throw(RuntimeException)
     132             :     {
     133           0 :         return OUString("org.openoffice.comp.extensions.FormController");
     134             :     }
     135             : 
     136             : 
     137           0 :     Sequence< OUString > FormController::getSupportedServiceNames_static(  ) throw(RuntimeException)
     138             :     {
     139           0 :         Sequence< OUString > aSupported(1);
     140           0 :         aSupported[0] = "com.sun.star.form.PropertyBrowserController";
     141           0 :         return aSupported;
     142             :     }
     143             : 
     144             : 
     145           0 :     Reference< XInterface > SAL_CALL FormController::Create(const Reference< XComponentContext >& _rxContext )
     146             :     {
     147             :         ServiceDescriptor aService;
     148           0 :         aService.GetImplementationName = &FormController::getImplementationName_static;
     149           0 :         aService.GetSupportedServiceNames = &FormController::getSupportedServiceNames_static;
     150           0 :         return *(new FormController( _rxContext, aService, true ) );
     151             :     }
     152             : 
     153             : 
     154           0 :     Reference< XPropertySetInfo > SAL_CALL FormController::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     155             :     {
     156           0 :         return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     157             :     }
     158             : 
     159             : 
     160           0 :     ::cppu::IPropertyArrayHelper& SAL_CALL FormController::getInfoHelper()
     161             :     {
     162           0 :         return *getArrayHelper();
     163             :     }
     164             : 
     165             : 
     166           0 :     ::cppu::IPropertyArrayHelper* FormController::createArrayHelper( ) const
     167             :     {
     168           0 :         Sequence< Property > aProps( 2 );
     169           0 :         aProps[0] = Property(
     170             :             PROPERTY_CURRENTPAGE,
     171             :             OWN_PROPERTY_ID_CURRENTPAGE,
     172           0 :             ::getCppuType( static_cast< OUString* >( NULL ) ),
     173             :             PropertyAttribute::TRANSIENT
     174           0 :         );
     175           0 :         aProps[1] = Property(
     176             :             PROPERTY_INTROSPECTEDOBJECT,
     177             :             OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
     178           0 :             cppu::UnoType<XPropertySet>::get(),
     179             :             PropertyAttribute::TRANSIENT | PropertyAttribute::CONSTRAINED
     180           0 :         );
     181           0 :         return new ::cppu::OPropertyArrayHelper( aProps );
     182             :     }
     183             : 
     184             : 
     185           0 :     sal_Bool SAL_CALL FormController::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
     186             :     {
     187           0 :         switch ( nHandle )
     188             :         {
     189             :         case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
     190           0 :             if ( rValue.getValueTypeClass() != TypeClass_INTERFACE )
     191           0 :                 throw IllegalArgumentException();
     192           0 :             break;
     193             :         case OWN_PROPERTY_ID_CURRENTPAGE:
     194           0 :             if ( rValue.getValueTypeClass() != TypeClass_STRING )
     195           0 :                 throw IllegalArgumentException();
     196           0 :             break;
     197             :         }
     198             : 
     199           0 :         getFastPropertyValue( rOldValue, nHandle );
     200           0 :         rConvertedValue = rValue;
     201           0 :         return sal_True;
     202             :     }
     203             : 
     204             : 
     205           0 :     void SAL_CALL FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception, std::exception)
     206             :     {
     207           0 :         switch ( _nHandle )
     208             :         {
     209             :         case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
     210             :         {
     211           0 :             Reference< XObjectInspectorModel > xModel( getInspectorModel() );
     212           0 :             if ( xModel.is() )
     213             :             {
     214             :                 try
     215             :                 {
     216           0 :                     m_xCurrentInspectee.set( _rValue, UNO_QUERY );
     217           0 :                     Sequence< Reference< XInterface > > aObjects;
     218           0 :                     if ( m_xCurrentInspectee.is() )
     219             :                     {
     220           0 :                         aObjects.realloc( 1 );
     221           0 :                         aObjects[0] = m_xCurrentInspectee;
     222             :                     }
     223             : 
     224           0 :                     Reference< XObjectInspector > xInspector( *this, UNO_QUERY_THROW );
     225           0 :                     xInspector->inspect( aObjects );
     226             :                 }
     227           0 :                 catch( const VetoException& e )
     228             :                 {
     229           0 :                     throw PropertyVetoException( e.Message, e.Context );
     230             :                 }
     231           0 :             }
     232             :         }
     233           0 :         break;
     234             :         case OWN_PROPERTY_ID_CURRENTPAGE:
     235           0 :             restoreViewData( _rValue );
     236           0 :             break;
     237             :         }
     238           0 :     }
     239             : 
     240             : 
     241           0 :     void SAL_CALL FormController::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const
     242             :     {
     243           0 :         switch ( nHandle )
     244             :         {
     245             :         case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
     246           0 :             rValue <<= m_xCurrentInspectee;
     247           0 :             break;
     248             : 
     249             :         case OWN_PROPERTY_ID_CURRENTPAGE:
     250           0 :             rValue = const_cast< FormController* >( this )->getViewData();
     251           0 :             break;
     252             :         }
     253           0 :     }
     254             : 
     255             : 
     256             :     //= DialogController
     257             : 
     258             : 
     259           0 :     OUString DialogController::getImplementationName_static(  ) throw(RuntimeException)
     260             :     {
     261           0 :         return OUString("org.openoffice.comp.extensions.DialogController");
     262             :     }
     263             : 
     264             : 
     265           0 :     Sequence< OUString > DialogController::getSupportedServiceNames_static(  ) throw(RuntimeException)
     266             :     {
     267           0 :         Sequence< OUString > aSupported(1);
     268           0 :         aSupported[0] = "com.sun.star.awt.PropertyBrowserController";
     269           0 :         return aSupported;
     270             :     }
     271             : 
     272             : 
     273           0 :     Reference< XInterface > SAL_CALL DialogController::Create(const Reference< XComponentContext >& _rxContext)
     274             :     {
     275             :         ServiceDescriptor aService;
     276           0 :         aService.GetImplementationName = &DialogController::getImplementationName_static;
     277           0 :         aService.GetSupportedServiceNames = &DialogController::getSupportedServiceNames_static;
     278           0 :         return *(new FormController( _rxContext, aService, false ) );
     279             :     }
     280             : 
     281             : 
     282             : } // namespace pcr
     283             : 
     284             : 
     285             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10