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

Generated by: LCOV version 1.11