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

Generated by: LCOV version 1.10