LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - inspectormodelbase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 71 0.0 %
Date: 2012-08-25 Functions: 0 29 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                 :            :  * 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 "inspectormodelbase.hxx"
      21                 :            : #include "pcrcommon.hxx"
      22                 :            : 
      23                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      24                 :            : 
      25                 :            : #include <comphelper/propertycontainerhelper.hxx>
      26                 :            : 
      27                 :            : //........................................................................
      28                 :            : namespace pcr
      29                 :            : {
      30                 :            : //........................................................................
      31                 :            : 
      32                 :            : #define MODEL_PROPERTY_ID_HAS_HELP_SECTION      2000
      33                 :            : #define MODEL_PROPERTY_ID_MIN_HELP_TEXT_LINES   2001
      34                 :            : #define MODEL_PROPERTY_ID_MAX_HELP_TEXT_LINES   2002
      35                 :            : #define MODEL_PROPERTY_ID_IS_READ_ONLY          2003
      36                 :            : 
      37                 :            :     /** === begin UNO using === **/
      38                 :            :     using ::com::sun::star::uno::Reference;
      39                 :            :     using ::com::sun::star::uno::XComponentContext;
      40                 :            :     using ::com::sun::star::beans::XPropertySetInfo;
      41                 :            :     using ::com::sun::star::uno::RuntimeException;
      42                 :            :     using ::com::sun::star::uno::Any;
      43                 :            :     using ::com::sun::star::lang::IllegalArgumentException;
      44                 :            :     using ::com::sun::star::uno::Exception;
      45                 :            :     using ::com::sun::star::uno::Sequence;
      46                 :            :     using ::com::sun::star::inspection::PropertyCategoryDescriptor;
      47                 :            :     using ::com::sun::star::uno::makeAny;
      48                 :            :     using ::com::sun::star::beans::Property;
      49                 :            :     /** === end UNO using === **/
      50                 :            :     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
      51                 :            : 
      52                 :            :     //====================================================================
      53                 :            :     //= InspectorModelProperties
      54                 :            :     //====================================================================
      55                 :            :     /** helper class for implementing the property set related functionality
      56                 :            :         of an ImplInspectorModel
      57                 :            :     */
      58                 :          0 :     class InspectorModelProperties : public ::comphelper::OPropertyContainerHelper
      59                 :            :     {
      60                 :            :     private:
      61                 :            :         ::osl::Mutex&           m_rMutex;
      62                 :            :         sal_Bool                m_bHasHelpSection;
      63                 :            :         sal_Int32               m_nMinHelpTextLines;
      64                 :            :         sal_Int32               m_nMaxHelpTextLines;
      65                 :            :         sal_Bool                m_bIsReadOnly;
      66                 :            :         ::std::auto_ptr< ::cppu::IPropertyArrayHelper >
      67                 :            :                                 m_pPropertyInfo;
      68                 :            : 
      69                 :            :     public:
      70                 :            :         InspectorModelProperties( ::osl::Mutex& _rMutex );
      71                 :            : 
      72                 :            :         using ::comphelper::OPropertyContainerHelper::convertFastPropertyValue;
      73                 :            :         using ::comphelper::OPropertyContainerHelper::setFastPropertyValue;
      74                 :            :         using ::comphelper::OPropertyContainerHelper::getFastPropertyValue;
      75                 :            : 
      76                 :            :     public:
      77                 :          0 :         inline  sal_Bool    hasHelpSection() const { return m_bHasHelpSection; }
      78                 :          0 :         inline  sal_Bool    isReadOnly() const { return m_bIsReadOnly; }
      79                 :          0 :         inline  sal_Int32   getMinHelpTextLines() const { return m_nMinHelpTextLines; }
      80                 :          0 :         inline  sal_Int32   getMaxHelpTextLines() const { return m_nMaxHelpTextLines; }
      81                 :            : 
      82                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
      83                 :            :                             getPropertySetInfo();
      84                 :            :         ::cppu::IPropertyArrayHelper&
      85                 :            :                             getInfoHelper();
      86                 :            : 
      87                 :            :         void    constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
      88                 :            :     };
      89                 :            : 
      90                 :            :     //====================================================================
      91                 :            :     //= InspectorModelProperties
      92                 :            :     //====================================================================
      93                 :            :     //--------------------------------------------------------------------
      94                 :          0 :     InspectorModelProperties::InspectorModelProperties( ::osl::Mutex& _rMutex )
      95                 :            :         :m_rMutex( _rMutex )
      96                 :            :         ,m_bHasHelpSection( sal_False )
      97                 :            :         ,m_nMinHelpTextLines( 3 )
      98                 :            :         ,m_nMaxHelpTextLines( 8 )
      99                 :          0 :         ,m_bIsReadOnly( sal_False )
     100                 :            :     {
     101                 :            :         registerProperty(
     102                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasHelpSection" ) ),
     103                 :            :             MODEL_PROPERTY_ID_HAS_HELP_SECTION,
     104                 :            :             PropertyAttribute::READONLY,
     105                 :          0 :             &m_bHasHelpSection, ::getCppuType( &m_bHasHelpSection )
     106                 :          0 :         );
     107                 :            :         registerProperty(
     108                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinHelpTextLines" ) ),
     109                 :            :             MODEL_PROPERTY_ID_MIN_HELP_TEXT_LINES,
     110                 :            :             PropertyAttribute::READONLY,
     111                 :          0 :             &m_nMinHelpTextLines, ::getCppuType( &m_nMinHelpTextLines )
     112                 :          0 :         );
     113                 :            :         registerProperty(
     114                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxHelpTextLines" ) ),
     115                 :            :             MODEL_PROPERTY_ID_MAX_HELP_TEXT_LINES,
     116                 :            :             PropertyAttribute::READONLY,
     117                 :          0 :             &m_nMaxHelpTextLines, ::getCppuType( &m_nMaxHelpTextLines )
     118                 :          0 :         );
     119                 :            :         registerProperty(
     120                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
     121                 :            :             MODEL_PROPERTY_ID_IS_READ_ONLY,
     122                 :            :             PropertyAttribute::BOUND,
     123                 :          0 :             &m_bIsReadOnly, ::getCppuType( &m_bIsReadOnly )
     124                 :          0 :         );
     125                 :          0 :     }
     126                 :            : 
     127                 :            :     //--------------------------------------------------------------------
     128                 :          0 :     void InspectorModelProperties::constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
     129                 :            :     {
     130                 :          0 :         m_bHasHelpSection = sal_True;
     131                 :          0 :         m_nMinHelpTextLines = _nMinHelpTextLines;
     132                 :          0 :         m_nMaxHelpTextLines = _nMaxHelpTextLines;
     133                 :            :         // no need to notify this, those properties are not bound. Also, the method should
     134                 :            :         // only be used during construction phase, where we don't expect to have any listeners.
     135                 :          0 :     }
     136                 :            : 
     137                 :            :     //--------------------------------------------------------------------
     138                 :          0 :     ::cppu::IPropertyArrayHelper& InspectorModelProperties::getInfoHelper()
     139                 :            :     {
     140                 :          0 :         ::osl::MutexGuard aGuard( m_rMutex );
     141                 :          0 :         if ( m_pPropertyInfo.get() == NULL )
     142                 :            :         {
     143                 :          0 :             Sequence< Property > aProperties;
     144                 :          0 :             describeProperties( aProperties );
     145                 :            : 
     146                 :          0 :             m_pPropertyInfo.reset( new ::cppu::OPropertyArrayHelper( aProperties ) );
     147                 :            :         }
     148                 :          0 :         return *m_pPropertyInfo;
     149                 :            :     }
     150                 :            : 
     151                 :            :     //--------------------------------------------------------------------
     152                 :          0 :     Reference< XPropertySetInfo > InspectorModelProperties::getPropertySetInfo()
     153                 :            :     {
     154                 :          0 :         return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
     155                 :            :     }
     156                 :            : 
     157                 :            :     //====================================================================
     158                 :            :     //= ImplInspectorModel
     159                 :            :     //====================================================================
     160                 :          0 :     ImplInspectorModel::ImplInspectorModel( const Reference< XComponentContext >& _rxContext )
     161                 :          0 :         :ImplInspectorModel_PBase( GetBroadcastHelper() )
     162                 :            :         ,m_aContext( _rxContext )
     163                 :          0 :         ,m_pProperties( new InspectorModelProperties( m_aMutex ) )
     164                 :            :     {
     165                 :          0 :     }
     166                 :            : 
     167                 :            :     //--------------------------------------------------------------------
     168                 :          0 :     ImplInspectorModel::~ImplInspectorModel()
     169                 :            :     {
     170                 :          0 :     }
     171                 :            : 
     172                 :            :     //--------------------------------------------------------------------
     173                 :          0 :     IMPLEMENT_FORWARD_XINTERFACE2( ImplInspectorModel, ImplInspectorModel_Base, ImplInspectorModel_PBase )
     174                 :            : 
     175                 :            :     //--------------------------------------------------------------------
     176                 :          0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( ImplInspectorModel, ImplInspectorModel_Base, ImplInspectorModel_PBase )
     177                 :            : 
     178                 :            :     //--------------------------------------------------------------------
     179                 :          0 :     Reference< XPropertySetInfo > SAL_CALL ImplInspectorModel::getPropertySetInfo(  ) throw (RuntimeException)
     180                 :            :     {
     181                 :          0 :         return m_pProperties->getPropertySetInfo();
     182                 :            :     }
     183                 :            : 
     184                 :            :     //--------------------------------------------------------------------
     185                 :          0 :     ::cppu::IPropertyArrayHelper& SAL_CALL ImplInspectorModel::getInfoHelper()
     186                 :            :     {
     187                 :          0 :         return m_pProperties->getInfoHelper();
     188                 :            :     }
     189                 :            : 
     190                 :            :     //--------------------------------------------------------------------
     191                 :          0 :     sal_Bool SAL_CALL ImplInspectorModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
     192                 :            :     {
     193                 :          0 :         return m_pProperties->convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
     194                 :            :     }
     195                 :            : 
     196                 :            :     //--------------------------------------------------------------------
     197                 :          0 :     void SAL_CALL ImplInspectorModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
     198                 :            :     {
     199                 :          0 :         m_pProperties->setFastPropertyValue( nHandle, rValue );
     200                 :          0 :     }
     201                 :            : 
     202                 :            :     //--------------------------------------------------------------------
     203                 :          0 :     void SAL_CALL ImplInspectorModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     204                 :            :     {
     205                 :          0 :         m_pProperties->getFastPropertyValue( rValue, nHandle );
     206                 :          0 :     }
     207                 :            : 
     208                 :            :     //--------------------------------------------------------------------
     209                 :          0 :     ::sal_Bool SAL_CALL ImplInspectorModel::getHasHelpSection() throw (RuntimeException)
     210                 :            :     {
     211                 :          0 :         return m_pProperties->hasHelpSection();
     212                 :            :     }
     213                 :            : 
     214                 :            :     //--------------------------------------------------------------------
     215                 :          0 :     ::sal_Int32 SAL_CALL ImplInspectorModel::getMinHelpTextLines() throw (RuntimeException)
     216                 :            :     {
     217                 :          0 :         return m_pProperties->getMinHelpTextLines();
     218                 :            :     }
     219                 :            : 
     220                 :            :     //--------------------------------------------------------------------
     221                 :          0 :     ::sal_Int32 SAL_CALL ImplInspectorModel::getMaxHelpTextLines() throw (RuntimeException)
     222                 :            :     {
     223                 :          0 :         return m_pProperties->getMaxHelpTextLines();
     224                 :            :     }
     225                 :            : 
     226                 :            :     //--------------------------------------------------------------------
     227                 :          0 :     ::sal_Bool SAL_CALL ImplInspectorModel::getIsReadOnly() throw (::com::sun::star::uno::RuntimeException)
     228                 :            :     {
     229                 :          0 :         return m_pProperties->isReadOnly();
     230                 :            :     }
     231                 :            : 
     232                 :            :     //--------------------------------------------------------------------
     233                 :          0 :     void SAL_CALL ImplInspectorModel::setIsReadOnly( ::sal_Bool _IsReadOnly ) throw (::com::sun::star::uno::RuntimeException)
     234                 :            :     {
     235                 :          0 :         setFastPropertyValue( MODEL_PROPERTY_ID_IS_READ_ONLY, makeAny( _IsReadOnly ) );
     236                 :          0 :     }
     237                 :            : 
     238                 :            :     //--------------------------------------------------------------------
     239                 :          0 :     ::sal_Bool SAL_CALL ImplInspectorModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
     240                 :            :     {
     241                 :          0 :         StlSyntaxSequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
     242                 :          0 :         for (   StlSyntaxSequence< ::rtl::OUString >::const_iterator check = aSupported.begin();
     243                 :          0 :                 check != aSupported.end();
     244                 :            :                 ++check
     245                 :            :             )
     246                 :          0 :             if ( check->equals( ServiceName ) )
     247                 :          0 :                 return sal_True;
     248                 :            : 
     249                 :          0 :         return sal_False;
     250                 :            :     }
     251                 :            : 
     252                 :            :     //--------------------------------------------------------------------
     253                 :          0 :     void ImplInspectorModel::enableHelpSectionProperties( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
     254                 :            :     {
     255                 :          0 :         m_pProperties->constructWithHelpSection( _nMinHelpTextLines, _nMaxHelpTextLines );
     256                 :          0 :     }
     257                 :            : 
     258                 :            : //........................................................................
     259                 :            : } // namespace pcr
     260                 :            : //........................................................................
     261                 :            : 
     262                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10