LCOV - code coverage report
Current view: top level - include/ucbhelper - propertyvalueset.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 15 18 83.3 %
Date: 2014-11-03 Functions: 5 6 83.3 %
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 INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
      21             : #define INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
      22             : 
      23             : #include <com/sun/star/lang/XTypeProvider.hpp>
      24             : #include <com/sun/star/sdbc/XColumnLocate.hpp>
      25             : #include <com/sun/star/sdbc/XRow.hpp>
      26             : #include <com/sun/star/beans/Property.hpp>
      27             : #include <cppuhelper/weak.hxx>
      28             : 
      29             : #include <osl/mutex.hxx>
      30             : #include <ucbhelper/macros.hxx>
      31             : #include <ucbhelper/ucbhelperdllapi.h>
      32             : 
      33             : namespace com { namespace sun { namespace star { namespace script {
      34             :     class XTypeConverter;
      35             : } } } }
      36             : 
      37             : namespace com { namespace sun { namespace star { namespace beans {
      38             :     struct PropertyValue;
      39             :     class XPropertySet;
      40             : } } } }
      41             : 
      42             : namespace ucbhelper {
      43             : 
      44             : class PropertyValues;
      45             : 
      46             : 
      47             : 
      48             : /**
      49             :   * This class implements the interface XRow. After construction of a valueset
      50             :   * the user can append properties ( incl. its values ) to the set. This class
      51             :   * is useful when implementing the command "getPropertyValues", because the
      52             :   * values to return can easily appended to a valueset object. That object can
      53             :   * directly be returned by the implementation of the command.
      54             :   */
      55             : class UCBHELPER_DLLPUBLIC PropertyValueSet :
      56             :                 public cppu::OWeakObject,
      57             :                 public com::sun::star::lang::XTypeProvider,
      58             :                 public com::sun::star::sdbc::XRow,
      59             :                 public com::sun::star::sdbc::XColumnLocate
      60             : {
      61             :     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
      62             :                                      m_xContext;
      63             :     com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter >
      64             :                                      m_xTypeConverter;
      65             :     osl::Mutex      m_aMutex;
      66             :     PropertyValues* m_pValues;
      67             :     bool        m_bWasNull;
      68             :     bool        m_bTriedToGetTypeConverter;
      69             : 
      70             : private:
      71             :     UCBHELPER_DLLPRIVATE const com::sun::star::uno::Reference<
      72             :             com::sun::star::script::XTypeConverter >&
      73             :     getTypeConverter();
      74             : 
      75             : public:
      76             :     PropertyValueSet(
      77             :             const com::sun::star::uno::Reference<
      78             :                 com::sun::star::uno::XComponentContext >& rxContext );
      79             :     virtual ~PropertyValueSet();
      80             : 
      81             :     // XInterface
      82             :     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
      83             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      84             :     virtual void SAL_CALL acquire()
      85             :         throw() SAL_OVERRIDE;
      86             :     virtual void SAL_CALL release()
      87             :         throw() SAL_OVERRIDE;
      88             : 
      89             :     // XTypeProvider
      90             :     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
      91             :     getImplementationId()
      92             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      93             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
      94             :     getTypes()
      95             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      96             : 
      97             :     // XRow
      98             :     virtual sal_Bool SAL_CALL
      99             :     wasNull()
     100             :         throw( ::com::sun::star::sdbc::SQLException,
     101             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     102             :     virtual OUString SAL_CALL
     103             :     getString( sal_Int32 columnIndex )
     104             :         throw( ::com::sun::star::sdbc::SQLException,
     105             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     106             :     virtual sal_Bool SAL_CALL
     107             :     getBoolean( sal_Int32 columnIndex )
     108             :         throw( ::com::sun::star::sdbc::SQLException,
     109             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     110             :     virtual sal_Int8 SAL_CALL
     111             :     getByte( sal_Int32 columnIndex )
     112             :         throw( ::com::sun::star::sdbc::SQLException,
     113             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     114             :     virtual sal_Int16 SAL_CALL
     115             :     getShort( sal_Int32 columnIndex )
     116             :         throw( ::com::sun::star::sdbc::SQLException,
     117             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     118             :     virtual sal_Int32 SAL_CALL
     119             :     getInt( sal_Int32 columnIndex )
     120             :         throw( ::com::sun::star::sdbc::SQLException,
     121             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     122             :     virtual sal_Int64 SAL_CALL
     123             :     getLong( sal_Int32 columnIndex )
     124             :         throw( ::com::sun::star::sdbc::SQLException,
     125             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     126             :     virtual float SAL_CALL
     127             :     getFloat( sal_Int32 columnIndex )
     128             :         throw( ::com::sun::star::sdbc::SQLException,
     129             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     130             :     virtual double SAL_CALL
     131             :     getDouble( sal_Int32 columnIndex )
     132             :         throw( ::com::sun::star::sdbc::SQLException,
     133             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     134             :     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
     135             :     getBytes( sal_Int32 columnIndex )
     136             :         throw( ::com::sun::star::sdbc::SQLException,
     137             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     138             :     virtual ::com::sun::star::util::Date SAL_CALL
     139             :     getDate( sal_Int32 columnIndex )
     140             :         throw( ::com::sun::star::sdbc::SQLException,
     141             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     142             :     virtual ::com::sun::star::util::Time SAL_CALL
     143             :     getTime( sal_Int32 columnIndex )
     144             :         throw( ::com::sun::star::sdbc::SQLException,
     145             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     146             :     virtual ::com::sun::star::util::DateTime SAL_CALL
     147             :     getTimestamp( sal_Int32 columnIndex )
     148             :         throw( ::com::sun::star::sdbc::SQLException,
     149             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     150             :     virtual ::com::sun::star::uno::Reference<
     151             :                 ::com::sun::star::io::XInputStream > SAL_CALL
     152             :     getBinaryStream( sal_Int32 columnIndex )
     153             :         throw( ::com::sun::star::sdbc::SQLException,
     154             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     155             :     virtual ::com::sun::star::uno::Reference<
     156             :                 ::com::sun::star::io::XInputStream > SAL_CALL
     157             :     getCharacterStream( sal_Int32 columnIndex )
     158             :         throw( ::com::sun::star::sdbc::SQLException,
     159             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     160             :     virtual ::com::sun::star::uno::Any SAL_CALL
     161             :     getObject( sal_Int32 columnIndex,
     162             :                const ::com::sun::star::uno::Reference<
     163             :                    ::com::sun::star::container::XNameAccess >& typeMap )
     164             :         throw( ::com::sun::star::sdbc::SQLException,
     165             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     166             :     virtual ::com::sun::star::uno::Reference<
     167             :                 ::com::sun::star::sdbc::XRef > SAL_CALL
     168             :     getRef( sal_Int32 columnIndex )
     169             :         throw( ::com::sun::star::sdbc::SQLException,
     170             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     171             :     virtual ::com::sun::star::uno::Reference<
     172             :                 ::com::sun::star::sdbc::XBlob > SAL_CALL
     173             :     getBlob( sal_Int32 columnIndex )
     174             :         throw( ::com::sun::star::sdbc::SQLException,
     175             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     176             :     virtual ::com::sun::star::uno::Reference<
     177             :                 ::com::sun::star::sdbc::XClob > SAL_CALL
     178             :     getClob( sal_Int32 columnIndex )
     179             :         throw( ::com::sun::star::sdbc::SQLException,
     180             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     181             :     virtual ::com::sun::star::uno::Reference<
     182             :                 ::com::sun::star::sdbc::XArray > SAL_CALL
     183             :     getArray( sal_Int32 columnIndex )
     184             :         throw( ::com::sun::star::sdbc::SQLException,
     185             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     186             : 
     187             :     // XColumnLocate
     188             :     virtual sal_Int32 SAL_CALL
     189             :     findColumn( const OUString& columnName )
     190             :         throw( ::com::sun::star::sdbc::SQLException,
     191             :                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     192             : 
     193             : 
     194             :     // Non-interface methods
     195             : 
     196             : 
     197             :     void appendString( const OUString& rPropName, const OUString& rValue );
     198             :     void appendString( const sal_Char* pAsciiPropName, const OUString& rValue )
     199             :     {
     200             :         appendString( OUString::createFromAscii( pAsciiPropName ), rValue );
     201             :     }
     202        2344 :     void appendString( const ::com::sun::star::beans::Property& rProp, const OUString& rValue )
     203             :     {
     204        2344 :         appendString( rProp.Name, rValue );
     205        2344 :     }
     206             : 
     207             :     void appendBoolean( const OUString& rPropName, bool bValue );
     208             :     void appendBoolean( const sal_Char* pAsciiPropName, bool bValue )
     209             :     {
     210             :         appendBoolean( OUString::createFromAscii( pAsciiPropName ), bValue );
     211             :     }
     212        3020 :     void appendBoolean( const ::com::sun::star::beans::Property& rProp, bool bValue )
     213             :     {
     214        3020 :         appendBoolean( rProp.Name, bValue );
     215        3020 :     }
     216             : 
     217             :     void appendLong( const OUString& rPropName, sal_Int64 nValue );
     218             :     void appendLong( const sal_Char* pAsciiPropName, sal_Int64 nValue )
     219             :     {
     220             :         appendLong( OUString::createFromAscii( pAsciiPropName ), nValue );
     221             :     }
     222          12 :     void appendLong( const ::com::sun::star::beans::Property& rProp, sal_Int64 nValue )
     223             :     {
     224          12 :         appendLong( rProp.Name, nValue );
     225          12 :     }
     226             : 
     227             :     void appendTimestamp( const OUString& rPropName, const ::com::sun::star::util::DateTime& rValue );
     228             :     void appendTimestamp( const sal_Char* pAsciiPropName, const ::com::sun::star::util::DateTime& rValue )
     229             :     {
     230             :         appendTimestamp( OUString::createFromAscii( pAsciiPropName ), rValue );
     231             :     }
     232           0 :     void appendTimestamp( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::DateTime& rValue )
     233             :     {
     234           0 :         appendTimestamp( rProp.Name, rValue );
     235           0 :     }
     236             : 
     237             :     void appendObject( const OUString& rPropName, const ::com::sun::star::uno::Any& rValue );
     238             :     void appendObject( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Any& rValue )
     239             :     {
     240             :         appendObject( OUString::createFromAscii( pAsciiPropName ), rValue );
     241             :     }
     242         348 :     void appendObject( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Any& rValue )
     243             :     {
     244         348 :         appendObject( rProp.Name, rValue );
     245         348 :     }
     246             : 
     247             :     void appendVoid( const OUString& rPropName );
     248             :     void appendVoid( const sal_Char* pAsciiPropName)
     249             :     {
     250             :         appendVoid( OUString::createFromAscii( pAsciiPropName ) );
     251             :     }
     252          28 :     void appendVoid( const ::com::sun::star::beans::Property& rProp )
     253             :     {
     254          28 :         appendVoid( rProp.Name );
     255          28 :     }
     256             : 
     257             :     /**
     258             :       * This method tries to append all property values contained in a
     259             :       * property set to the value set.
     260             :       *
     261             :        *    @param  rSet is a property set containing the property values.
     262             :       */
     263             :     void appendPropertySet( const ::com::sun::star::uno::Reference<
     264             :                                 ::com::sun::star::beans::XPropertySet >& rSet );
     265             : 
     266             :     /** This method tries to append a single property value contained in a
     267             :       * property set to the value set.
     268             :       *
     269             :        *    @param  rSet is a property set containing the property values.
     270             :        *    @param  rProperty is the property for that the value shall be obtained
     271             :       *         from the given property set.
     272             :        *    @return False, if the property value cannot be obtained from the
     273             :       *         given property pet. True, otherwise.
     274             :        */
     275             :     bool appendPropertySetValue(
     276             :                         const ::com::sun::star::uno::Reference<
     277             :                             ::com::sun::star::beans::XPropertySet >& rSet,
     278             :                         const ::com::sun::star::beans::Property& rProperty );
     279             : };
     280             : 
     281             : }
     282             : 
     283             : #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
     284             : 
     285             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10