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

Generated by: LCOV version 1.10