LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableConnectionData.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 74 0.0 %
Date: 2014-04-14 Functions: 0 15 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 "TableConnectionData.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include <osl/diagnose.h>
      23             : 
      24             : using namespace dbaui;
      25             : 
      26             : // class OTableConnectionData
      27           0 : OTableConnectionData::OTableConnectionData()
      28             : {
      29           0 :     Init();
      30           0 : }
      31             : 
      32           0 : OTableConnectionData::OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable
      33             :                                           ,const TTableWindowData::value_type& _pReferencedTable
      34             :                                           ,const OUString& rConnName )
      35             :  :m_pReferencingTable(_pReferencingTable)
      36             :  ,m_pReferencedTable(_pReferencedTable)
      37           0 :  ,m_aConnName( rConnName )
      38             : {
      39           0 :     Init();
      40           0 : }
      41             : 
      42           0 : void OTableConnectionData::Init()
      43             : {
      44             :     // initialise linedatalist with defaults
      45             :     OSL_ENSURE(m_vConnLineData.empty(), "OTableConnectionData::Init() : nur mit leere Linienliste aufzurufen !");
      46           0 :     ResetConnLines();
      47             :         // this creates the defaults
      48           0 : }
      49             : 
      50           0 : OTableConnectionData::OTableConnectionData( const OTableConnectionData& rConnData )
      51             : {
      52           0 :     *this = rConnData;
      53           0 : }
      54             : 
      55           0 : void OTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
      56             : {
      57           0 :     *this = rSource;
      58             :     // here I revert to the (non-virtual) operator =, which only copies my members
      59           0 : }
      60             : 
      61           0 : OTableConnectionData::~OTableConnectionData()
      62             : {
      63             :     // delete LineDataList
      64           0 :     OConnectionLineDataVec().swap(m_vConnLineData);
      65           0 : }
      66             : 
      67           0 : OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionData& rConnData )
      68             : {
      69           0 :     if (&rConnData == this)
      70           0 :         return *this;
      71             : 
      72           0 :     m_pReferencingTable = rConnData.m_pReferencingTable;
      73           0 :     m_pReferencedTable = rConnData.m_pReferencedTable;
      74           0 :     m_aConnName = rConnData.GetConnName();
      75             : 
      76             :     // clear line list
      77           0 :     ResetConnLines();
      78             : 
      79             :     // and copy
      80           0 :     OConnectionLineDataVec* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList();
      81             : 
      82           0 :     OConnectionLineDataVec::const_iterator aIter = pLineData->begin();
      83           0 :     OConnectionLineDataVec::const_iterator aEnd = pLineData->end();
      84           0 :     for(;aIter != aEnd;++aIter)
      85           0 :         m_vConnLineData.push_back(new OConnectionLineData(**aIter));
      86             : 
      87           0 :     return *this;
      88             : }
      89             : 
      90           0 : sal_Bool OTableConnectionData::SetConnLine( sal_uInt16 nIndex, const OUString& rSourceFieldName, const OUString& rDestFieldName )
      91             : {
      92           0 :     if (sal_uInt16(m_vConnLineData.size()) < nIndex)
      93           0 :         return sal_False;
      94             : 
      95             :         // == still allowed, this correponds to a Append
      96             : 
      97           0 :     if (m_vConnLineData.size() == nIndex)
      98           0 :         return AppendConnLine(rSourceFieldName, rDestFieldName);
      99             : 
     100           0 :     OConnectionLineDataRef pConnLineData = m_vConnLineData[nIndex];
     101             :     OSL_ENSURE(pConnLineData != NULL, "OTableConnectionData::SetConnLine : habe ungueltiges LineData-Objekt");
     102             : 
     103           0 :     pConnLineData->SetSourceFieldName( rSourceFieldName );
     104           0 :     pConnLineData->SetDestFieldName( rDestFieldName );
     105             : 
     106           0 :     return sal_True;
     107             : }
     108             : 
     109           0 : sal_Bool OTableConnectionData::AppendConnLine( const OUString& rSourceFieldName, const OUString& rDestFieldName )
     110             : {
     111           0 :     OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
     112           0 :     OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
     113           0 :     for(;aIter != aEnd;++aIter)
     114             :     {
     115           0 :         if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName)
     116           0 :             break;
     117             :     }
     118           0 :     if(aIter == aEnd)
     119             :     {
     120           0 :         OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName);
     121           0 :         if (!pNew.is())
     122           0 :             return sal_False;
     123             : 
     124           0 :         m_vConnLineData.push_back(pNew);
     125             :     }
     126           0 :     return sal_True;
     127             : }
     128             : 
     129           0 : void OTableConnectionData::ResetConnLines()
     130             : {
     131           0 :     OConnectionLineDataVec().swap(m_vConnLineData);
     132           0 : }
     133             : 
     134           0 : OConnectionLineDataRef OTableConnectionData::CreateLineDataObj()
     135             : {
     136           0 :     return new OConnectionLineData();
     137             : }
     138             : 
     139           0 : OConnectionLineDataRef OTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
     140             : {
     141           0 :     return new OConnectionLineData( rConnLineData );
     142             : }
     143             : 
     144           0 : OTableConnectionData* OTableConnectionData::NewInstance() const
     145             : {
     146           0 :     return new OTableConnectionData();
     147             : }
     148             : 
     149           0 : OConnectionLineDataVec::size_type OTableConnectionData::normalizeLines()
     150             : {
     151             :     // remove empty lines
     152           0 :     OConnectionLineDataVec::size_type nCount = m_vConnLineData.size();
     153           0 :     OConnectionLineDataVec::size_type nRet = nCount;
     154           0 :     for(OConnectionLineDataVec::size_type i = 0; i < nCount;)
     155             :     {
     156           0 :         if(m_vConnLineData[i]->GetSourceFieldName().isEmpty() && m_vConnLineData[i]->GetDestFieldName().isEmpty())
     157             :         {
     158           0 :             OConnectionLineDataRef pData = m_vConnLineData[i];
     159           0 :             m_vConnLineData.erase(m_vConnLineData.begin()+i);
     160           0 :             --nCount;
     161           0 :             if (i < nRet)
     162           0 :                 nRet=i;
     163             :         }
     164             :         else
     165           0 :             ++i;
     166             :     }
     167           0 :     return nRet;
     168             : }
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10