LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableFieldDescription.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 103 0.0 %
Date: 2014-04-14 Functions: 0 12 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             : #include "TableFieldDescription.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include <com/sun/star/sdbc/DataType.hpp>
      23             : #include <comphelper/namedvaluecollection.hxx>
      24             : 
      25             : #include <functional>
      26             : 
      27             : using namespace ::com::sun::star::sdbc;
      28             : using namespace ::com::sun::star::uno;
      29             : using namespace ::com::sun::star::beans;
      30             : using namespace comphelper;
      31             : using namespace dbaui;
      32             : 
      33           0 : OTableFieldDesc::OTableFieldDesc()
      34             :     :m_pTabWindow(0)
      35             :     ,m_eDataType(1000)
      36             :     ,m_eFunctionType( FKT_NONE )
      37             :     ,m_eFieldType(TAB_NORMAL_FIELD)
      38             :     ,m_eOrderDir( ORDER_NONE )
      39             :     ,m_nIndex(0)
      40             :     ,m_nColWidth(0)
      41             :     ,m_nColumnId((sal_uInt16)-1)
      42             :     ,m_bGroupBy(sal_False)
      43           0 :     ,m_bVisible(sal_False)
      44             : {
      45           0 : }
      46             : 
      47           0 : OTableFieldDesc::OTableFieldDesc(const OTableFieldDesc& rRS)
      48           0 :     : ::salhelper::SimpleReferenceObject()
      49             : 
      50             : {
      51           0 :     *this = rRS;
      52           0 : }
      53             : 
      54           0 : OTableFieldDesc::OTableFieldDesc(const OUString& rT, const OUString& rF )
      55             :     :m_pTabWindow(0)
      56             :     ,m_eDataType(1000)
      57             :     ,m_eFunctionType( FKT_NONE )
      58             :     ,m_eFieldType(TAB_NORMAL_FIELD)
      59             :     ,m_eOrderDir( ORDER_NONE )
      60             :     ,m_nIndex(0)
      61             :     ,m_nColWidth(0)
      62             :     ,m_nColumnId((sal_uInt16)-1)
      63             :     ,m_bGroupBy(sal_False)
      64           0 :     ,m_bVisible(sal_False)
      65             : {
      66           0 :     SetField( rF ); SetTable( rT );
      67           0 : }
      68             : 
      69           0 : OTableFieldDesc::~OTableFieldDesc()
      70             : {
      71           0 : }
      72             : 
      73           0 : OTableFieldDesc& OTableFieldDesc::operator=( const OTableFieldDesc& rRS )
      74             : {
      75           0 :     if (&rRS == this)
      76           0 :         return *this;
      77             : 
      78           0 :     m_aCriteria = rRS.GetCriteria();
      79           0 :     m_aTableName = rRS.GetTable();
      80           0 :     m_aAliasName = rRS.GetAlias();      // table range
      81           0 :     m_aFieldName = rRS.GetField();      // column
      82           0 :     m_aFieldAlias = rRS.GetFieldAlias();    // column alias
      83           0 :     m_aFunctionName = rRS.GetFunction();    // Funktionsname
      84           0 :     m_pTabWindow = rRS.GetTabWindow();
      85           0 :     m_eDataType = rRS.GetDataType();
      86           0 :     m_eFunctionType = rRS.GetFunctionType();
      87           0 :     m_eFieldType = rRS.GetFieldType();
      88           0 :     m_eOrderDir = rRS.GetOrderDir();
      89           0 :     m_nIndex = rRS.GetFieldIndex();
      90           0 :     m_nColWidth = rRS.GetColWidth();
      91           0 :     m_nColumnId = rRS.m_nColumnId;
      92           0 :     m_bGroupBy = rRS.IsGroupBy();
      93           0 :     m_bVisible = rRS.IsVisible();
      94             : 
      95           0 :     return *this;
      96             : }
      97             : 
      98           0 : sal_Bool OTableFieldDesc::operator==( const OTableFieldDesc& rDesc )
      99             : {
     100             : 
     101           0 :     return (    m_eOrderDir != rDesc.GetOrderDir()      ||
     102           0 :                 m_eDataType != rDesc.GetDataType()      ||
     103           0 :                 m_aAliasName != rDesc.GetAlias()        ||
     104           0 :                 m_aFunctionName != rDesc.GetFunction()  ||
     105           0 :                 m_aFieldName != rDesc.GetField()        ||
     106           0 :                 m_aTableName != rDesc.GetTable()        ||
     107           0 :                 m_bGroupBy != rDesc.IsGroupBy()         ||
     108           0 :                 m_aCriteria != rDesc.GetCriteria()  ||
     109           0 :                 m_bVisible != rDesc.IsVisible() );
     110             : 
     111             : }
     112             : 
     113           0 : void OTableFieldDesc::SetCriteria( sal_uInt16 nIdx, const OUString& rCrit)
     114             : {
     115           0 :     if (nIdx < m_aCriteria.size())
     116           0 :         m_aCriteria[nIdx] = rCrit;
     117             :     else
     118             :     {
     119           0 :         for(sal_Int32 i=m_aCriteria.size();i<nIdx;++i)
     120           0 :             m_aCriteria.push_back( OUString());
     121           0 :         m_aCriteria.push_back(rCrit);
     122             :     }
     123           0 : }
     124             : 
     125           0 : OUString OTableFieldDesc::GetCriteria( sal_uInt16 nIdx ) const
     126             : {
     127           0 :     OUString aRetStr;
     128           0 :     if( nIdx < m_aCriteria.size())
     129           0 :         aRetStr = m_aCriteria[nIdx];
     130             : 
     131           0 :     return aRetStr;
     132             : }
     133             : 
     134             : namespace
     135             : {
     136             :     struct SelectPropertyValueAsString : public ::std::unary_function< PropertyValue, OUString >
     137             :     {
     138           0 :         OUString operator()( const PropertyValue& i_rPropValue ) const
     139             :         {
     140           0 :             OUString sValue;
     141           0 :             OSL_VERIFY( i_rPropValue.Value >>= sValue );
     142           0 :             return sValue;
     143             :         }
     144             :     };
     145             : }
     146             : 
     147           0 : void OTableFieldDesc::Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria )
     148             : {
     149             : 
     150           0 :     ::comphelper::NamedValueCollection aFieldDesc( i_rSettings.Value );
     151           0 :     m_aAliasName = aFieldDesc.getOrDefault( "AliasName", m_aAliasName );
     152           0 :     m_aTableName = aFieldDesc.getOrDefault( "TableName", m_aTableName );
     153           0 :     m_aFieldName = aFieldDesc.getOrDefault( "FieldName", m_aFieldName );
     154           0 :     m_aFieldAlias = aFieldDesc.getOrDefault( "FieldAlias", m_aFieldAlias );
     155           0 :     m_aFunctionName = aFieldDesc.getOrDefault( "FunctionName", m_aFunctionName );
     156           0 :     m_eDataType = aFieldDesc.getOrDefault( "DataType", m_eDataType );
     157           0 :     m_eFunctionType = aFieldDesc.getOrDefault( "FunctionType", m_eFunctionType );
     158           0 :     m_nColWidth = aFieldDesc.getOrDefault( "ColWidth", m_nColWidth );
     159           0 :     m_bGroupBy = aFieldDesc.getOrDefault( "GroupBy", m_bGroupBy );
     160           0 :     m_bVisible = aFieldDesc.getOrDefault( "Visible", m_bVisible );
     161             : 
     162           0 :     m_eFieldType = static_cast< ETableFieldType >( aFieldDesc.getOrDefault( "FieldType", static_cast< sal_Int32 >( m_eFieldType ) ) );
     163           0 :     m_eOrderDir = static_cast< EOrderDir >( aFieldDesc.getOrDefault( "OrderDir", static_cast< sal_Int32 >( m_eOrderDir ) ) );
     164             : 
     165           0 :     if ( i_bIncludingCriteria )
     166             :     {
     167           0 :         const Sequence< PropertyValue > aCriteria( aFieldDesc.getOrDefault( "Criteria", Sequence< PropertyValue >() ) );
     168           0 :         m_aCriteria.resize( aCriteria.getLength() );
     169             :         ::std::transform(
     170             :             aCriteria.getConstArray(),
     171           0 :             aCriteria.getConstArray() + aCriteria.getLength(),
     172             :             m_aCriteria.begin(),
     173             :             SelectPropertyValueAsString()
     174           0 :         );
     175           0 :     }
     176           0 : }
     177             : 
     178           0 : void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria )
     179             : {
     180             : 
     181           0 :     o_rSettings.put( "AliasName", m_aAliasName );
     182           0 :     o_rSettings.put( "TableName", m_aTableName );
     183           0 :     o_rSettings.put( "FieldName", m_aFieldName );
     184           0 :     o_rSettings.put( "FieldAlias", m_aFieldAlias );
     185           0 :     o_rSettings.put( "FunctionName", m_aFunctionName );
     186           0 :     o_rSettings.put( "DataType", m_eDataType );
     187           0 :     o_rSettings.put( "FunctionType", (sal_Int32)m_eFunctionType );
     188           0 :     o_rSettings.put( "FieldType", (sal_Int32)m_eFieldType );
     189           0 :     o_rSettings.put( "OrderDir", (sal_Int32)m_eOrderDir );
     190           0 :     o_rSettings.put( "ColWidth", m_nColWidth );
     191           0 :     o_rSettings.put( "GroupBy", m_bGroupBy );
     192           0 :     o_rSettings.put( "Visible", m_bVisible );
     193             : 
     194           0 :     if ( i_bIncludingCriteria )
     195             :     {
     196           0 :         if ( !m_aCriteria.empty() )
     197             :         {
     198           0 :             sal_Int32 c = 0;
     199           0 :             Sequence< PropertyValue > aCriteria( m_aCriteria.size() );
     200           0 :             for (   ::std::vector< OUString >::const_iterator crit = m_aCriteria.begin();
     201           0 :                     crit != m_aCriteria.end();
     202             :                     ++crit, ++c
     203             :                 )
     204             :             {
     205           0 :                 aCriteria[c].Name = "Criterion_" + OUString::number( c );
     206           0 :                 aCriteria[c].Value <<= *crit;
     207             :             }
     208             : 
     209           0 :             o_rSettings.put( "Criteria", aCriteria );
     210             :         }
     211             :     }
     212           0 : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10