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

Generated by: LCOV version 1.10