LCOV - code coverage report
Current view: top level - sc/inc - miscuno.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 5 100.0 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 28 42.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SC_MISCUNO_HXX
      30                 :            : #define SC_MISCUNO_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      33                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      34                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      35                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      36                 :            : #include <com/sun/star/container/XEnumeration.hpp>
      37                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      38                 :            : #include <cppuhelper/implbase2.hxx>
      39                 :            : #include "scdllapi.h"
      40                 :            : 
      41                 :            : #define SC_SIMPLE_SERVICE_INFO( ClassName, ClassNameAscii, ServiceAscii )            \
      42                 :            : ::rtl::OUString SAL_CALL ClassName::getImplementationName()                      \
      43                 :            :     throw(::com::sun::star::uno::RuntimeException)                                   \
      44                 :            : {                                                                                    \
      45                 :            :     return ::rtl::OUString::createFromAscii(ClassNameAscii);                         \
      46                 :            : }                                                                                    \
      47                 :            : sal_Bool SAL_CALL ClassName::supportsService( const ::rtl::OUString& ServiceName ) \
      48                 :            :     throw(::com::sun::star::uno::RuntimeException)                                   \
      49                 :            : {                                                                                    \
      50                 :            :     return !ServiceName.compareToAscii(ServiceAscii);                                \
      51                 :            : }                                                                                    \
      52                 :            : ::com::sun::star::uno::Sequence< ::rtl::OUString >                                   \
      53                 :            :     SAL_CALL ClassName::getSupportedServiceNames(void)                           \
      54                 :            :     throw(::com::sun::star::uno::RuntimeException)                                   \
      55                 :            : {                                                                                    \
      56                 :            :     ::com::sun::star::uno::Sequence< ::rtl::OUString > aRet(1);                      \
      57                 :            :     ::rtl::OUString* pArray = aRet.getArray();                                       \
      58                 :            :     pArray[0] = ::rtl::OUString::createFromAscii(ServiceAscii);                  \
      59                 :            :     return aRet;                                                                     \
      60                 :            : }
      61                 :            : 
      62                 :            : #define SC_IMPL_DUMMY_PROPERTY_LISTENER( ClassName )                                \
      63                 :            :     void SAL_CALL ClassName::addPropertyChangeListener( const rtl::OUString&,       \
      64                 :            :                             const uno::Reference<beans::XPropertyChangeListener>&)  \
      65                 :            :                             throw(beans::UnknownPropertyException,                  \
      66                 :            :                             lang::WrappedTargetException, uno::RuntimeException)    \
      67                 :            :     { OSL_FAIL("not implemented"); }                                                \
      68                 :            :     void SAL_CALL ClassName::removePropertyChangeListener( const rtl::OUString&,    \
      69                 :            :                             const uno::Reference<beans::XPropertyChangeListener>&)  \
      70                 :            :                             throw(beans::UnknownPropertyException,                  \
      71                 :            :                             lang::WrappedTargetException, uno::RuntimeException)    \
      72                 :            :     { OSL_FAIL("not implemented"); }                                                \
      73                 :            :     void SAL_CALL ClassName::addVetoableChangeListener( const rtl::OUString&,       \
      74                 :            :                             const uno::Reference<beans::XVetoableChangeListener>&)  \
      75                 :            :                             throw(beans::UnknownPropertyException,                  \
      76                 :            :                             lang::WrappedTargetException, uno::RuntimeException)    \
      77                 :            :     { OSL_FAIL("not implemented"); }                                                \
      78                 :            :     void SAL_CALL ClassName::removeVetoableChangeListener( const rtl::OUString&,    \
      79                 :            :                             const uno::Reference<beans::XVetoableChangeListener>&)  \
      80                 :            :                             throw(beans::UnknownPropertyException,                  \
      81                 :            :                             lang::WrappedTargetException, uno::RuntimeException)    \
      82                 :            :     { OSL_FAIL("not implemented"); }
      83                 :            : 
      84                 :            : 
      85                 :            : #define SC_QUERYINTERFACE(x)    \
      86                 :            :     if (rType == getCppuType((const uno::Reference<x>*)0))  \
      87                 :            :     { return uno::makeAny(uno::Reference<x>(this)); }
      88                 :            : 
      89                 :            : // SC_QUERY_MULTIPLE( XElementAccess, XIndexAccess ):
      90                 :            : //  use if interface is used several times in one class
      91                 :            : 
      92                 :            : #define SC_QUERY_MULTIPLE(x,y)  \
      93                 :            :     if (rType == getCppuType((const uno::Reference<x>*)0))  \
      94                 :            :     { uno::Any aR; aR <<= uno::Reference<x>(static_cast<y*>(this)); return aR; }
      95                 :            : 
      96                 :            : 
      97                 :            : class ScIndexEnumeration : public cppu::WeakImplHelper2<
      98                 :            :                                 com::sun::star::container::XEnumeration,
      99                 :            :                                 com::sun::star::lang::XServiceInfo >
     100                 :            : {
     101                 :            : private:
     102                 :            :     com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> xIndex;
     103                 :            :     rtl::OUString           sServiceName;
     104                 :            :     sal_Int32               nPos;
     105                 :            : 
     106                 :            : public:
     107                 :            :                             ScIndexEnumeration(const com::sun::star::uno::Reference<
     108                 :            :                                 com::sun::star::container::XIndexAccess>& rInd, const rtl::OUString& rServiceName);
     109                 :            :     virtual                 ~ScIndexEnumeration();
     110                 :            : 
     111                 :            :                             // XEnumeration
     112                 :            :     virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException);
     113                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
     114                 :            :                                 throw(::com::sun::star::container::NoSuchElementException,
     115                 :            :                                         ::com::sun::star::lang::WrappedTargetException,
     116                 :            :                                         ::com::sun::star::uno::RuntimeException);
     117                 :            : 
     118                 :            :                             // XServiceInfo
     119                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName(  )
     120                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     121                 :            :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
     122                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     123                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
     124                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     125                 :            : };
     126                 :            : 
     127                 :            : //  new (uno 3) variant
     128                 :            : class ScNameToIndexAccess : public cppu::WeakImplHelper2<
     129                 :            :                                 com::sun::star::container::XIndexAccess,
     130                 :            :                                 com::sun::star::lang::XServiceInfo >
     131                 :            : {
     132                 :            : private:
     133                 :            :     com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xNameAccess;
     134                 :            :     com::sun::star::uno::Sequence<rtl::OUString> aNames;
     135                 :            : 
     136                 :            : public:
     137                 :            :                             ScNameToIndexAccess(
     138                 :            :                                 const com::sun::star::uno::Reference<
     139                 :            :                                     com::sun::star::container::XNameAccess>& rNameObj );
     140                 :            :     virtual                 ~ScNameToIndexAccess();
     141                 :            : 
     142                 :            :                             // XIndexAccess
     143                 :            :     virtual sal_Int32 SAL_CALL getCount(  ) throw(::com::sun::star::uno::RuntimeException);
     144                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
     145                 :            :                                 throw(::com::sun::star::lang::IndexOutOfBoundsException,
     146                 :            :                                         ::com::sun::star::lang::WrappedTargetException,
     147                 :            :                                         ::com::sun::star::uno::RuntimeException);
     148                 :            : 
     149                 :            :                             // XElementAccess
     150                 :            :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     151                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     152                 :            :     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
     153                 :            : 
     154                 :            :                             // XServiceInfo
     155                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName(  )
     156                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     157                 :            :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
     158                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     159                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
     160                 :            :                                 throw(::com::sun::star::uno::RuntimeException);
     161                 :            : };
     162                 :            : 
     163                 :            : class SC_DLLPUBLIC ScUnoHelpFunctions
     164                 :            : {
     165                 :            : public:
     166                 :            :     static com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
     167                 :            :                             AnyToInterface( const com::sun::star::uno::Any& rAny );
     168                 :            :     static sal_Bool         GetBoolProperty( const com::sun::star::uno::Reference<
     169                 :            :                                                 com::sun::star::beans::XPropertySet>& xProp,
     170                 :            :                                             const ::rtl::OUString& rName, sal_Bool bDefault = false );
     171                 :            :     static sal_Int32        GetLongProperty( const com::sun::star::uno::Reference<
     172                 :            :                                                 com::sun::star::beans::XPropertySet>& xProp,
     173                 :            :                                             const ::rtl::OUString& rName, long nDefault = 0 );
     174                 :            :     static sal_Int32        GetEnumProperty( const com::sun::star::uno::Reference<
     175                 :            :                                                 com::sun::star::beans::XPropertySet>& xProp,
     176                 :            :                                             const ::rtl::OUString& rName, long nDefault );
     177                 :            :     static ::rtl::OUString  GetStringProperty(
     178                 :            :         const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xProp,
     179                 :            :         const ::rtl::OUString& rName, const ::rtl::OUString& rDefault );
     180                 :            : 
     181                 :            :     static sal_Bool         GetBoolFromAny( const com::sun::star::uno::Any& aAny );
     182                 :            :     static sal_Int16        GetInt16FromAny( const com::sun::star::uno::Any& aAny );
     183                 :            :     static sal_Int32        GetInt32FromAny( const com::sun::star::uno::Any& aAny );
     184                 :            :     static sal_Int32        GetEnumFromAny( const com::sun::star::uno::Any& aAny );
     185                 :            :     static void             SetBoolInAny( com::sun::star::uno::Any& rAny, sal_Bool bValue );
     186                 :            : 
     187                 :            :     static void             SetOptionalPropertyValue(
     188                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
     189                 :            :         const sal_Char* pPropName, const ::com::sun::star::uno::Any& rVal );
     190                 :            : 
     191                 :            :     template<typename ValueType>
     192                 :       1645 :     static void             SetOptionalPropertyValue(
     193                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
     194                 :            :         const sal_Char* pPropName, const ValueType& rVal )
     195                 :            :     {
     196                 :       1645 :         ::com::sun::star::uno::Any any;
     197   [ +  -  +  -  :       1645 :         any <<= rVal;
          +  -  +  -  +  
             -  +  -  #  
                      # ]
     198 [ +  - ][ +  - ]:       1645 :         SetOptionalPropertyValue(rPropSet, pPropName, any);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ #  # ]
     199                 :       1645 :     }
     200                 :            : };
     201                 :            : 
     202                 :            : 
     203                 :            : 
     204                 :            : #endif
     205                 :            : 
     206                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10