LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - columnsettings.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 41 46.3 %
Date: 2012-08-25 Functions: 3 8 37.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 98 9.2 %

           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                 :            : 
      21                 :            : #include "columnsettings.hxx"
      22                 :            : #include "dbastrings.hrc"
      23                 :            : 
      24                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      25                 :            : 
      26                 :            : #include <cppuhelper/typeprovider.hxx>
      27                 :            : #include <comphelper/property.hxx>
      28                 :            : #include <tools/debug.hxx>
      29                 :            : #include <tools/diagnose_ex.h>
      30                 :            : 
      31                 :            : //........................................................................
      32                 :            : namespace dbaccess
      33                 :            : {
      34                 :            : //........................................................................
      35                 :            : 
      36                 :            :     /** === begin UNO using === **/
      37                 :            :     using ::com::sun::star::uno::Reference;
      38                 :            :     using ::com::sun::star::uno::XInterface;
      39                 :            :     using ::com::sun::star::uno::UNO_QUERY;
      40                 :            :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      41                 :            :     using ::com::sun::star::uno::UNO_SET_THROW;
      42                 :            :     using ::com::sun::star::uno::Exception;
      43                 :            :     using ::com::sun::star::uno::RuntimeException;
      44                 :            :     using ::com::sun::star::uno::Any;
      45                 :            :     using ::com::sun::star::uno::makeAny;
      46                 :            :     using ::com::sun::star::uno::Sequence;
      47                 :            :     using ::com::sun::star::uno::Type;
      48                 :            :     using ::com::sun::star::lang::IllegalArgumentException;
      49                 :            :     using ::com::sun::star::beans::XPropertySet;
      50                 :            :     using ::com::sun::star::beans::XPropertySetInfo;
      51                 :            :     /** === end UNO using === **/
      52                 :            :     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
      53                 :            : 
      54                 :            :     //==============================================================================
      55                 :            :     //= OColumnSettings
      56                 :            :     //==============================================================================
      57                 :            :     DBG_NAME( OColumnSettings )
      58                 :            : 
      59                 :       2880 :     OColumnSettings::OColumnSettings()
      60                 :       2880 :         :m_bHidden(sal_False)
      61                 :            :     {
      62                 :            :         DBG_CTOR( OColumnSettings, NULL );
      63                 :       2880 :     }
      64                 :            : 
      65                 :       2880 :     OColumnSettings::~OColumnSettings()
      66                 :            :     {
      67                 :            :         DBG_DTOR( OColumnSettings, NULL );
      68         [ -  + ]:       2880 :     }
      69                 :            : 
      70                 :       2880 :     void OColumnSettings::registerProperties( IPropertyContainer& _rPropertyContainer )
      71                 :            :     {
      72                 :       2880 :         const sal_Int32 nBoundAttr = PropertyAttribute::BOUND;
      73                 :       2880 :         const sal_Int32 nMayBeVoidAttr = PropertyAttribute::MAYBEVOID | nBoundAttr;
      74                 :            : 
      75                 :       2880 :         const Type& rSalInt32Type = ::getCppuType( static_cast< sal_Int32* >( NULL ) );
      76                 :       2880 :         const Type& rStringType = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
      77                 :            : 
      78         [ +  - ]:       2880 :         _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_ALIGN, PROPERTY_ID_ALIGN, nMayBeVoidAttr, &m_aAlignment, rSalInt32Type );
      79         [ +  - ]:       2880 :         _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT, nMayBeVoidAttr, &m_aFormatKey, rSalInt32Type );
      80         [ +  - ]:       2880 :         _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION, nMayBeVoidAttr, &m_aRelativePosition, rSalInt32Type );
      81         [ +  - ]:       2880 :         _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_WIDTH, PROPERTY_ID_WIDTH, nMayBeVoidAttr, &m_aWidth, rSalInt32Type );
      82         [ +  - ]:       2880 :         _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT, nMayBeVoidAttr, &m_aHelpText, rStringType );
      83         [ +  - ]:       2880 :         _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT, nMayBeVoidAttr, &m_aControlDefault, rStringType );
      84         [ +  - ]:       2880 :         _rPropertyContainer.registerProperty( PROPERTY_CONTROLMODEL, PROPERTY_ID_CONTROLMODEL, nBoundAttr, &m_xControlModel, ::getCppuType( &m_xControlModel ) );
      85         [ +  - ]:       2880 :         _rPropertyContainer.registerProperty( PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN, nBoundAttr, &m_bHidden, ::getCppuType( &m_bHidden ) );
      86                 :       2880 :     }
      87                 :            : 
      88                 :          0 :     bool OColumnSettings::isColumnSettingProperty( const sal_Int32 _nPropertyHandle )
      89                 :            :     {
      90                 :            :         return  ( _nPropertyHandle == PROPERTY_ID_ALIGN )
      91                 :            :             ||  ( _nPropertyHandle == PROPERTY_ID_NUMBERFORMAT )
      92                 :            :             ||  ( _nPropertyHandle == PROPERTY_ID_RELATIVEPOSITION )
      93                 :            :             ||  ( _nPropertyHandle == PROPERTY_ID_WIDTH )
      94                 :            :             ||  ( _nPropertyHandle == PROPERTY_ID_HELPTEXT )
      95                 :            :             ||  ( _nPropertyHandle == PROPERTY_ID_CONTROLDEFAULT )
      96                 :            :             ||  ( _nPropertyHandle == PROPERTY_ID_CONTROLMODEL )
      97 [ #  # ][ #  # ]:          0 :             ||  ( _nPropertyHandle == PROPERTY_ID_HIDDEN );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      98                 :            :     }
      99                 :            : 
     100                 :          0 :     bool OColumnSettings::isDefaulted( const sal_Int32 _nPropertyHandle, const Any& _rPropertyValue )
     101                 :            :     {
     102   [ #  #  #  # ]:          0 :         switch ( _nPropertyHandle )
     103                 :            :         {
     104                 :            :         case PROPERTY_ID_ALIGN:
     105                 :            :         case PROPERTY_ID_NUMBERFORMAT:
     106                 :            :         case PROPERTY_ID_RELATIVEPOSITION:
     107                 :            :         case PROPERTY_ID_WIDTH:
     108                 :            :         case PROPERTY_ID_HELPTEXT:
     109                 :            :         case PROPERTY_ID_CONTROLDEFAULT:
     110                 :          0 :             return !_rPropertyValue.hasValue();
     111                 :            : 
     112                 :            :         case PROPERTY_ID_CONTROLMODEL:
     113                 :          0 :             return !Reference< XPropertySet >( _rPropertyValue, UNO_QUERY ).is();
     114                 :            : 
     115                 :            :         case PROPERTY_ID_HIDDEN:
     116                 :            :             {
     117                 :          0 :                 sal_Bool bHidden = sal_False;
     118                 :          0 :                 OSL_VERIFY( _rPropertyValue >>= bHidden );
     119                 :          0 :                 return !bHidden;
     120                 :            :             }
     121                 :            :         }
     122                 :            :         OSL_FAIL( "OColumnSettings::isDefaulted: illegal property handle!" );
     123                 :          0 :         return sal_False;
     124                 :            :     }
     125                 :            : 
     126                 :          0 :     bool OColumnSettings::hasDefaultSettings( const Reference< XPropertySet >& _rxColumn )
     127                 :            :     {
     128 [ #  # ][ #  # ]:          0 :         ENSURE_OR_THROW( _rxColumn.is(), "illegal column" );
         [ #  # ][ #  # ]
     129                 :            :         try
     130                 :            :         {
     131 [ #  # ][ #  # ]:          0 :             Reference< XPropertySetInfo > xPSI( _rxColumn->getPropertySetInfo(), UNO_SET_THROW );
                 [ #  # ]
     132                 :            : 
     133                 :          0 :             struct PropertyDescriptor
     134                 :            :             {
     135                 :            :                 ::rtl::OUString sName;
     136                 :            :                 sal_Int32       nHandle;
     137                 :            :             };
     138                 :            :             PropertyDescriptor aProps[] =
     139                 :            :             {
     140                 :            :                 { PROPERTY_ALIGN,            PROPERTY_ID_ALIGN },
     141                 :            :                 { PROPERTY_NUMBERFORMAT,     PROPERTY_ID_NUMBERFORMAT },
     142                 :            :                 { PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION },
     143                 :            :                 { PROPERTY_WIDTH,            PROPERTY_ID_WIDTH },
     144                 :            :                 { PROPERTY_HELPTEXT,         PROPERTY_ID_HELPTEXT },
     145                 :            :                 { PROPERTY_CONTROLDEFAULT,   PROPERTY_ID_CONTROLDEFAULT },
     146                 :            :                 { PROPERTY_CONTROLMODEL,     PROPERTY_ID_CONTROLMODEL },
     147                 :            :                 { PROPERTY_HIDDEN,           PROPERTY_ID_HIDDEN }
     148 [ #  # ][ #  # ]:          0 :             };
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     149                 :            : 
     150         [ #  # ]:          0 :             for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
     151                 :            :             {
     152 [ #  # ][ #  # ]:          0 :                 if ( xPSI->hasPropertyByName( aProps[i].sName ) )
                 [ #  # ]
     153 [ #  # ][ #  # ]:          0 :                     if ( !isDefaulted( aProps[i].nHandle, _rxColumn->getPropertyValue( aProps[i].sName ) ) )
         [ #  # ][ #  # ]
     154                 :          0 :                         return false;
     155 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
           [ #  #  #  # ]
     156                 :            :         }
     157                 :          0 :         catch( const Exception& )
     158                 :            :         {
     159                 :            :             DBG_UNHANDLED_EXCEPTION();
     160                 :            :         }
     161                 :          0 :         return true;
     162                 :            :     }
     163                 :            : 
     164                 :            : //........................................................................
     165                 :            : } // namespace dbaccess
     166                 :            : //........................................................................
     167                 :            : 
     168                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10