LCOV - code coverage report
Current view: top level - sc/inc - miscuno.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 9 0.0 %
Date: 2014-04-14 Functions: 0 7 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             : #ifndef SC_MISCUNO_HXX
      21             : #define SC_MISCUNO_HXX
      22             : 
      23             : #include <com/sun/star/lang/XServiceInfo.hpp>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      26             : #include <com/sun/star/container/XNameAccess.hpp>
      27             : #include <com/sun/star/container/XEnumeration.hpp>
      28             : #include <com/sun/star/container/XIndexAccess.hpp>
      29             : #include <cppuhelper/implbase2.hxx>
      30             : #include <cppuhelper/supportsservice.hxx>
      31             : #include "scdllapi.h"
      32             : 
      33             : #define SC_SIMPLE_SERVICE_INFO( ClassName, ClassNameAscii, ServiceAscii )            \
      34             : OUString SAL_CALL ClassName::getImplementationName()                      \
      35             :     throw(::com::sun::star::uno::RuntimeException, std::exception)                                   \
      36             : {                                                                                    \
      37             :     return OUString::createFromAscii(ClassNameAscii);                         \
      38             : }                                                                                    \
      39             : sal_Bool SAL_CALL ClassName::supportsService( const OUString& ServiceName ) \
      40             :     throw(::com::sun::star::uno::RuntimeException, std::exception)                                   \
      41             : {                                                                                    \
      42             :     return cppu::supportsService(this, ServiceName);                                \
      43             : }                                                                                    \
      44             : ::com::sun::star::uno::Sequence< OUString >                                   \
      45             :     SAL_CALL ClassName::getSupportedServiceNames(void)                           \
      46             :     throw(::com::sun::star::uno::RuntimeException, std::exception)                                   \
      47             : {                                                                                    \
      48             :     ::com::sun::star::uno::Sequence< OUString > aRet(1);                      \
      49             :     OUString* pArray = aRet.getArray();                                       \
      50             :     pArray[0] = OUString::createFromAscii(ServiceAscii);                  \
      51             :     return aRet;                                                                     \
      52             : }
      53             : 
      54             : #define SC_IMPL_DUMMY_PROPERTY_LISTENER( ClassName )                                \
      55             :     void SAL_CALL ClassName::addPropertyChangeListener( const OUString&,       \
      56             :                             const uno::Reference<beans::XPropertyChangeListener>&)  \
      57             :                             throw(beans::UnknownPropertyException,                  \
      58             :                             lang::WrappedTargetException, uno::RuntimeException, std::exception)    \
      59             :     { OSL_FAIL("not implemented"); }                                                \
      60             :     void SAL_CALL ClassName::removePropertyChangeListener( const OUString&,    \
      61             :                             const uno::Reference<beans::XPropertyChangeListener>&)  \
      62             :                             throw(beans::UnknownPropertyException,                  \
      63             :                             lang::WrappedTargetException, uno::RuntimeException, std::exception)    \
      64             :     { OSL_FAIL("not implemented"); }                                                \
      65             :     void SAL_CALL ClassName::addVetoableChangeListener( const OUString&,       \
      66             :                             const uno::Reference<beans::XVetoableChangeListener>&)  \
      67             :                             throw(beans::UnknownPropertyException,                  \
      68             :                             lang::WrappedTargetException, uno::RuntimeException, std::exception)    \
      69             :     { OSL_FAIL("not implemented"); }                                                \
      70             :     void SAL_CALL ClassName::removeVetoableChangeListener( const OUString&,    \
      71             :                             const uno::Reference<beans::XVetoableChangeListener>&)  \
      72             :                             throw(beans::UnknownPropertyException,                  \
      73             :                             lang::WrappedTargetException, uno::RuntimeException, std::exception)    \
      74             :     { OSL_FAIL("not implemented"); }
      75             : 
      76             : 
      77             : #define SC_QUERYINTERFACE(x)    \
      78             :     if (rType == getCppuType((const uno::Reference<x>*)0))  \
      79             :     { return uno::makeAny(uno::Reference<x>(this)); }
      80             : 
      81             : // SC_QUERY_MULTIPLE( XElementAccess, XIndexAccess ):
      82             : //  use if interface is used several times in one class
      83             : 
      84             : #define SC_QUERY_MULTIPLE(x,y)  \
      85             :     if (rType == getCppuType((const uno::Reference<x>*)0))  \
      86             :     { uno::Any aR; aR <<= uno::Reference<x>(static_cast<y*>(this)); return aR; }
      87             : 
      88             : 
      89             : class ScIndexEnumeration : public cppu::WeakImplHelper2<
      90             :                                 com::sun::star::container::XEnumeration,
      91             :                                 com::sun::star::lang::XServiceInfo >
      92             : {
      93             : private:
      94             :     com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> xIndex;
      95             :     OUString           sServiceName;
      96             :     sal_Int32               nPos;
      97             : 
      98             : public:
      99             :                             ScIndexEnumeration(const com::sun::star::uno::Reference<
     100             :                                 com::sun::star::container::XIndexAccess>& rInd, const OUString& rServiceName);
     101             :     virtual                 ~ScIndexEnumeration();
     102             : 
     103             :                             // XEnumeration
     104             :     virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             :     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
     106             :                                 throw(::com::sun::star::container::NoSuchElementException,
     107             :                                         ::com::sun::star::lang::WrappedTargetException,
     108             :                                         ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             : 
     110             :                             // XServiceInfo
     111             :     virtual OUString SAL_CALL getImplementationName(  )
     112             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     114             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  )
     116             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     117             : };
     118             : 
     119             : //  new (uno 3) variant
     120             : class ScNameToIndexAccess : public cppu::WeakImplHelper2<
     121             :                                 com::sun::star::container::XIndexAccess,
     122             :                                 com::sun::star::lang::XServiceInfo >
     123             : {
     124             : private:
     125             :     com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xNameAccess;
     126             :     com::sun::star::uno::Sequence<OUString> aNames;
     127             : 
     128             : public:
     129             :                             ScNameToIndexAccess(
     130             :                                 const com::sun::star::uno::Reference<
     131             :                                     com::sun::star::container::XNameAccess>& rNameObj );
     132             :     virtual                 ~ScNameToIndexAccess();
     133             : 
     134             :                             // XIndexAccess
     135             :     virtual sal_Int32 SAL_CALL getCount(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     136             :     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
     137             :                                 throw(::com::sun::star::lang::IndexOutOfBoundsException,
     138             :                                         ::com::sun::star::lang::WrappedTargetException,
     139             :                                         ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     140             : 
     141             :                             // XElementAccess
     142             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     143             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             :     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             : 
     146             :                             // XServiceInfo
     147             :     virtual OUString SAL_CALL getImplementationName(  )
     148             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     150             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     151             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  )
     152             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     153             : };
     154             : 
     155             : class SC_DLLPUBLIC ScUnoHelpFunctions
     156             : {
     157             : public:
     158             :     static com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
     159             :                             AnyToInterface( const com::sun::star::uno::Any& rAny );
     160             :     static bool             GetBoolProperty( const com::sun::star::uno::Reference<
     161             :                                                 com::sun::star::beans::XPropertySet>& xProp,
     162             :                                             const OUString& rName, bool bDefault = false );
     163             :     static sal_Int32        GetLongProperty( const com::sun::star::uno::Reference<
     164             :                                                 com::sun::star::beans::XPropertySet>& xProp,
     165             :                                             const OUString& rName, long nDefault = 0 );
     166             :     static sal_Int32        GetEnumProperty( const com::sun::star::uno::Reference<
     167             :                                                 com::sun::star::beans::XPropertySet>& xProp,
     168             :                                             const OUString& rName, long nDefault );
     169             :     static OUString  GetStringProperty(
     170             :         const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xProp,
     171             :         const OUString& rName, const OUString& rDefault );
     172             : 
     173             :     static bool             GetBoolFromAny( const com::sun::star::uno::Any& aAny );
     174             :     static sal_Int16        GetInt16FromAny( const com::sun::star::uno::Any& aAny );
     175             :     static sal_Int32        GetInt32FromAny( const com::sun::star::uno::Any& aAny );
     176             :     static sal_Int32        GetEnumFromAny( const com::sun::star::uno::Any& aAny );
     177             :     static void             SetBoolInAny( com::sun::star::uno::Any& rAny, bool bValue );
     178             : 
     179             :     static void             SetOptionalPropertyValue(
     180             :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
     181             :         const sal_Char* pPropName, const ::com::sun::star::uno::Any& rVal );
     182             : 
     183             :     template<typename ValueType>
     184           0 :     static void             SetOptionalPropertyValue(
     185             :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
     186             :         const sal_Char* pPropName, const ValueType& rVal )
     187             :     {
     188           0 :         ::com::sun::star::uno::Any any;
     189           0 :         any <<= rVal;
     190           0 :         SetOptionalPropertyValue(rPropSet, pPropName, any);
     191           0 :     }
     192             : 
     193             :     template<typename ValueType>
     194           0 :     static com::sun::star::uno::Sequence<ValueType> VectorToSequence( const std::vector<ValueType>& rVector )
     195             :     {
     196           0 :         if (rVector.empty())
     197           0 :             return com::sun::star::uno::Sequence<ValueType>();
     198             : 
     199           0 :         return com::sun::star::uno::Sequence<ValueType>(&rVector[0], static_cast<sal_Int32>(rVector.size()));
     200             :     }
     201             : };
     202             : 
     203             : #endif
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10