LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - objectinspectormodel.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 64 0.0 %
Date: 2014-04-14 Functions: 0 17 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 "modulepcr.hxx"
      21             : #include "pcrcommon.hxx"
      22             : #include "inspectormodelbase.hxx"
      23             : 
      24             : #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
      25             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      26             : 
      27             : #include <cppuhelper/implbase3.hxx>
      28             : 
      29             : #include <comphelper/broadcasthelper.hxx>
      30             : #include <comphelper/uno3.hxx>
      31             : 
      32             : 
      33             : namespace pcr
      34             : {
      35             : 
      36             : 
      37             :     using ::com::sun::star::inspection::XObjectInspectorModel;
      38             :     using ::com::sun::star::lang::XInitialization;
      39             :     using ::com::sun::star::lang::XServiceInfo;
      40             :     using ::com::sun::star::uno::Reference;
      41             :     using ::com::sun::star::uno::XComponentContext;
      42             :     using ::com::sun::star::uno::RuntimeException;
      43             :     using ::com::sun::star::uno::Sequence;
      44             :     using ::com::sun::star::uno::Any;
      45             :     using ::com::sun::star::inspection::PropertyCategoryDescriptor;
      46             :     using ::com::sun::star::uno::Exception;
      47             :     using ::com::sun::star::uno::XInterface;
      48             :     using ::com::sun::star::lang::IllegalArgumentException;
      49             :     using ::com::sun::star::ucb::AlreadyInitializedException;
      50             :     using ::com::sun::star::beans::XPropertySetInfo;
      51             :     using ::com::sun::star::uno::makeAny;
      52             : 
      53             : 
      54             :     //= ObjectInspectorModel
      55             : 
      56           0 :     class ObjectInspectorModel : public ImplInspectorModel
      57             :     {
      58             :     private:
      59             :         Sequence< Any >             m_aFactories;
      60             : 
      61             :     public:
      62             :         ObjectInspectorModel();
      63             : 
      64             :         // XObjectInspectorModel
      65             :         virtual Sequence< Any > SAL_CALL getHandlerFactories() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      66             :         virtual Sequence< PropertyCategoryDescriptor > SAL_CALL describeCategories(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      67             :         virtual ::sal_Int32 SAL_CALL getPropertyOrderIndex( const OUString& PropertyName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      68             : 
      69             :         // XInitialization
      70             :         virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException, std::exception) SAL_OVERRIDE;
      71             : 
      72             :         // XServiceInfo
      73             :         virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      74             :         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      75             : 
      76             :         // XServiceInfo - static versions
      77             :         static OUString getImplementationName_static(  ) throw(RuntimeException);
      78             :         static Sequence< OUString > getSupportedServiceNames_static(  ) throw(RuntimeException);
      79             :         static Reference< XInterface > SAL_CALL
      80             :                         Create(const Reference< XComponentContext >&);
      81             : 
      82             :     protected:
      83             :         void    createDefault();
      84             :         void    createWithHandlerFactories( const Sequence< Any >& _rFactories );
      85             :         void    createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
      86             : 
      87             :     private:
      88             :         /** checks a given condition to be <TRUE/>, and throws an IllegalArgumentException if not
      89             :         */
      90             :         void    impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition );
      91             :     };
      92             : 
      93             : 
      94             :     //= ObjectInspectorModel
      95             : 
      96           0 :     ObjectInspectorModel::ObjectInspectorModel()
      97           0 :         :ImplInspectorModel()
      98             :     {
      99           0 :     }
     100             : 
     101             : 
     102           0 :     Sequence< Any > SAL_CALL ObjectInspectorModel::getHandlerFactories() throw (RuntimeException, std::exception)
     103             :     {
     104           0 :         return m_aFactories;
     105             :     }
     106             : 
     107             : 
     108           0 :     Sequence< PropertyCategoryDescriptor > SAL_CALL ObjectInspectorModel::describeCategories(  ) throw (RuntimeException, std::exception)
     109             :     {
     110             :         // no category info provided by this default implementation
     111           0 :         return Sequence< PropertyCategoryDescriptor >( );
     112             :     }
     113             : 
     114             : 
     115           0 :     ::sal_Int32 SAL_CALL ObjectInspectorModel::getPropertyOrderIndex( const OUString& /*PropertyName*/ ) throw (RuntimeException, std::exception)
     116             :     {
     117             :         // no ordering provided by this default implementation
     118           0 :         return 0;
     119             :     }
     120             : 
     121             : 
     122           0 :     void SAL_CALL ObjectInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException, std::exception)
     123             :     {
     124           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     125           0 :         if ( m_aFactories.getLength() )
     126           0 :             throw AlreadyInitializedException();
     127             : 
     128           0 :         StlSyntaxSequence< Any > arguments( _arguments );
     129           0 :         if ( arguments.empty() )
     130             :         {   // constructor: "createDefault()"
     131           0 :             createDefault();
     132           0 :             return;
     133             :         }
     134             : 
     135           0 :         Sequence< Any > factories;
     136           0 :         impl_verifyArgument_throw( arguments[0] >>= factories, 1 );
     137             : 
     138           0 :         if ( arguments.size() == 1 )
     139             :         {   // constructor: "createWithHandlerFactories( any[] )"
     140           0 :             createWithHandlerFactories( factories );
     141           0 :             return;
     142             :         }
     143             : 
     144           0 :         sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
     145           0 :         if ( arguments.size() == 3 )
     146             :         {   // constructor: "createWithHandlerFactoriesAndHelpSection( any[], long, long )"
     147           0 :             impl_verifyArgument_throw( arguments[1] >>= nMinHelpTextLines, 2 );
     148           0 :             impl_verifyArgument_throw( arguments[2] >>= nMaxHelpTextLines, 3 );
     149           0 :             createWithHandlerFactoriesAndHelpSection( factories, nMinHelpTextLines, nMaxHelpTextLines );
     150           0 :             return;
     151             :         }
     152             : 
     153           0 :         impl_verifyArgument_throw( false, 2 );
     154             :     }
     155             : 
     156             : 
     157           0 :     OUString SAL_CALL ObjectInspectorModel::getImplementationName(  ) throw (RuntimeException, std::exception)
     158             :     {
     159           0 :         return getImplementationName_static();
     160             :     }
     161             : 
     162             : 
     163           0 :     Sequence< OUString > SAL_CALL ObjectInspectorModel::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     164             :     {
     165           0 :         return getSupportedServiceNames_static();
     166             :     }
     167             : 
     168             : 
     169           0 :     OUString ObjectInspectorModel::getImplementationName_static(  ) throw(RuntimeException)
     170             :     {
     171           0 :         return OUString( "org.openoffice.comp.extensions.ObjectInspectorModel" );
     172             :     }
     173             : 
     174             : 
     175           0 :     Sequence< OUString > ObjectInspectorModel::getSupportedServiceNames_static(  ) throw(RuntimeException)
     176             :     {
     177           0 :         OUString sService( "com.sun.star.inspection.ObjectInspectorModel" );
     178           0 :         return Sequence< OUString >( &sService, 1 );
     179             :     }
     180             : 
     181             : 
     182           0 :     Reference< XInterface > SAL_CALL ObjectInspectorModel::Create(const Reference< XComponentContext >& /* _rxContext */ )
     183             :     {
     184           0 :         return *( new ObjectInspectorModel() );
     185             :     }
     186             : 
     187             : 
     188           0 :     void ObjectInspectorModel::createDefault()
     189             :     {
     190           0 :         m_aFactories.realloc( 1 );
     191           0 :         m_aFactories[0] <<= OUString( "com.sun.star.inspection.GenericPropertyHandler" );
     192           0 :     }
     193             : 
     194             : 
     195           0 :     void ObjectInspectorModel::createWithHandlerFactories( const Sequence< Any >& _rFactories )
     196             :     {
     197           0 :         impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
     198           0 :         m_aFactories = _rFactories;
     199           0 :     }
     200             : 
     201             : 
     202           0 :     void ObjectInspectorModel::createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
     203             :     {
     204           0 :         impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
     205           0 :         impl_verifyArgument_throw( _nMinHelpTextLines >= 1, 2 );
     206           0 :         impl_verifyArgument_throw( _nMaxHelpTextLines >= 1, 3 );
     207           0 :         impl_verifyArgument_throw( _nMinHelpTextLines <= _nMaxHelpTextLines, 2 );
     208             : 
     209           0 :         m_aFactories = _rFactories;
     210           0 :         enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
     211           0 :     }
     212             : 
     213             : 
     214           0 :     void ObjectInspectorModel::impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition )
     215             :     {
     216           0 :         if ( !_bCondition )
     217           0 :             throw IllegalArgumentException( OUString(), *this, _nArgumentPosition );
     218           0 :     }
     219             : 
     220             : 
     221             : } // namespace pcr
     222             : 
     223             : 
     224             : 
     225           0 : extern "C" void SAL_CALL createRegistryInfo_ObjectInspectorModel()
     226             : {
     227           0 :     ::pcr::OAutoRegistration< ::pcr::ObjectInspectorModel > aObjectInspectorModelRegistration;
     228           0 : }
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10