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

Generated by: LCOV version 1.10