LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TableRow.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 102 0.0 %
Date: 2014-11-03 Functions: 0 9 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 "TableRow.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include "FieldDescriptions.hxx"
      23             : #include <algorithm>
      24             : #include <comphelper/types.hxx>
      25             : 
      26             : using namespace dbaui;
      27             : using namespace ::com::sun::star::sdbc;
      28             : using namespace ::com::sun::star::uno;
      29             : using namespace ::com::sun::star::beans;
      30             : 
      31             : // class OTableRow
      32           0 : OTableRow::OTableRow()
      33             :     :m_pActFieldDescr( NULL )
      34             :     ,m_nPos( -1 )
      35             :     ,m_bReadOnly( false )
      36           0 :     ,m_bOwnsDescriptions(false)
      37             : {
      38           0 : }
      39             : 
      40           0 : OTableRow::OTableRow(const Reference< XPropertySet >& xAffectedCol)
      41             :     :m_pActFieldDescr( NULL )
      42             :     ,m_nPos( -1 )
      43             :     ,m_bReadOnly( false )
      44           0 :     ,m_bOwnsDescriptions(true)
      45             : {
      46           0 :     m_pActFieldDescr = new OFieldDescription(xAffectedCol);
      47           0 : }
      48             : 
      49           0 : OTableRow::OTableRow( const OTableRow& rRow, long nPosition )
      50             :     :m_pActFieldDescr(NULL)
      51             :     ,m_nPos( nPosition )
      52           0 :     ,m_bReadOnly(rRow.IsReadOnly())
      53           0 :     ,m_bOwnsDescriptions(false)
      54             : {
      55             : 
      56           0 :     OFieldDescription* pSrcField = rRow.GetActFieldDescr();
      57           0 :     if(pSrcField)
      58             :     {
      59           0 :         m_pActFieldDescr = new OFieldDescription(*pSrcField);
      60           0 :         m_bOwnsDescriptions = true;
      61             :     }
      62           0 : }
      63             : 
      64           0 : OTableRow::~OTableRow()
      65             : {
      66           0 :     if(m_bOwnsDescriptions)
      67           0 :         delete m_pActFieldDescr;
      68           0 : }
      69             : 
      70           0 : void OTableRow::SetPrimaryKey( bool bSet )
      71             : {
      72           0 :     if(m_pActFieldDescr)
      73           0 :         m_pActFieldDescr->SetPrimaryKey(bSet);
      74           0 : }
      75             : 
      76           0 : bool OTableRow::IsPrimaryKey() const
      77             : {
      78           0 :     return m_pActFieldDescr && m_pActFieldDescr->IsPrimaryKey();
      79             : }
      80             : 
      81           0 : void OTableRow::SetFieldType( const TOTypeInfoSP& _pType, bool _bForce )
      82             : {
      83           0 :     if ( _pType.get() )
      84             :     {
      85           0 :         if( !m_pActFieldDescr )
      86             :         {
      87           0 :             m_pActFieldDescr = new OFieldDescription();
      88           0 :             m_bOwnsDescriptions = true;
      89             :         }
      90           0 :         m_pActFieldDescr->FillFromTypeInfo(_pType,_bForce,true);
      91             :     }
      92             :     else
      93             :     {
      94           0 :         delete m_pActFieldDescr;
      95           0 :         m_pActFieldDescr = NULL;
      96             :     }
      97           0 : }
      98             : 
      99             : namespace dbaui
     100             : {
     101           0 :     SvStream& WriteOTableRow( SvStream& _rStr, const OTableRow& _rRow )
     102             :     {
     103           0 :         _rStr.WriteInt32( _rRow.m_nPos );
     104           0 :         OFieldDescription* pFieldDesc = _rRow.GetActFieldDescr();
     105           0 :         if(pFieldDesc)
     106             :         {
     107           0 :             _rStr.WriteInt32( 1 );
     108           0 :             _rStr.WriteUniOrByteString(pFieldDesc->GetName(), _rStr.GetStreamCharSet());
     109           0 :             _rStr.WriteUniOrByteString(pFieldDesc->GetDescription(), _rStr.GetStreamCharSet());
     110           0 :             _rStr.WriteUniOrByteString(pFieldDesc->GetHelpText(), _rStr.GetStreamCharSet());
     111           0 :             double nValue = 0.0;
     112           0 :             Any aValue = pFieldDesc->GetControlDefault();
     113           0 :             if ( aValue >>= nValue )
     114             :             {
     115           0 :                 _rStr.WriteInt32( 1 );
     116           0 :                 _rStr.WriteDouble( nValue );
     117             :             }
     118             :             else
     119             :             {
     120           0 :                 _rStr.WriteInt32( 2 );
     121           0 :                 _rStr.WriteUniOrByteString(::comphelper::getString(aValue), _rStr.GetStreamCharSet());
     122             :             }
     123             : 
     124           0 :             _rStr.WriteInt32( pFieldDesc->GetType() );
     125             : 
     126           0 :             _rStr.WriteInt32( pFieldDesc->GetPrecision() );
     127           0 :             _rStr.WriteInt32( pFieldDesc->GetScale() );
     128           0 :             _rStr.WriteInt32( pFieldDesc->GetIsNullable() );
     129           0 :             _rStr.WriteInt32( pFieldDesc->GetFormatKey() );
     130           0 :             _rStr.WriteInt32( pFieldDesc->GetHorJustify() );
     131           0 :             _rStr.WriteInt32( pFieldDesc->IsAutoIncrement() ? 1 : 0 );
     132           0 :             _rStr.WriteInt32( pFieldDesc->IsPrimaryKey() ? 1 : 0 );
     133           0 :             _rStr.WriteInt32( pFieldDesc->IsCurrency() ? 1 : 0 );
     134             :         }
     135             :         else
     136           0 :             _rStr.WriteInt32( 0 );
     137           0 :         return _rStr;
     138             :     }
     139           0 :     SvStream& ReadOTableRow( SvStream& _rStr, OTableRow& _rRow )
     140             :     {
     141           0 :         _rStr.ReadInt32( _rRow.m_nPos );
     142           0 :         sal_Int32 nValue = 0;
     143           0 :         _rStr.ReadInt32( nValue );
     144           0 :         if ( nValue )
     145             :         {
     146           0 :             OFieldDescription* pFieldDesc = new OFieldDescription();
     147           0 :             _rRow.m_pActFieldDescr = pFieldDesc;
     148           0 :             OUString sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet());
     149           0 :             pFieldDesc->SetName(sValue);
     150             : 
     151           0 :             sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet());
     152           0 :             pFieldDesc->SetDescription(sValue);
     153           0 :             sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet());
     154           0 :             pFieldDesc->SetHelpText(sValue);
     155             : 
     156           0 :             _rStr.ReadInt32( nValue );
     157           0 :             Any aControlDefault;
     158           0 :             switch ( nValue )
     159             :             {
     160             :                 case 1:
     161             :                 {
     162             :                     double nControlDefault;
     163           0 :                     _rStr.ReadDouble( nControlDefault );
     164           0 :                     aControlDefault <<= nControlDefault;
     165           0 :                     break;
     166             :                 }
     167             :                 case 2:
     168           0 :                     sValue = _rStr.ReadUniOrByteString(_rStr.GetStreamCharSet());
     169           0 :                     aControlDefault <<= OUString(sValue);
     170           0 :                     break;
     171             :             }
     172             : 
     173           0 :             pFieldDesc->SetControlDefault(aControlDefault);
     174             : 
     175           0 :             _rStr.ReadInt32( nValue );
     176           0 :             pFieldDesc->SetTypeValue(nValue);
     177             : 
     178           0 :             _rStr.ReadInt32( nValue );
     179           0 :             pFieldDesc->SetPrecision(nValue);
     180           0 :             _rStr.ReadInt32( nValue );
     181           0 :             pFieldDesc->SetScale(nValue);
     182           0 :             _rStr.ReadInt32( nValue );
     183           0 :             pFieldDesc->SetIsNullable(nValue);
     184           0 :             _rStr.ReadInt32( nValue );
     185           0 :             pFieldDesc->SetFormatKey(nValue);
     186           0 :             _rStr.ReadInt32( nValue );
     187           0 :             pFieldDesc->SetHorJustify((SvxCellHorJustify)nValue);
     188             : 
     189           0 :             _rStr.ReadInt32( nValue );
     190           0 :             pFieldDesc->SetAutoIncrement(nValue != 0);
     191           0 :             _rStr.ReadInt32( nValue );
     192           0 :             pFieldDesc->SetPrimaryKey(nValue != 0);
     193           0 :             _rStr.ReadInt32( nValue );
     194           0 :             pFieldDesc->SetCurrency(nValue != 0);
     195             :         }
     196           0 :         return _rStr;
     197             :     }
     198             : }
     199             : 
     200             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10