LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableConnectionData.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 72 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 142 0.0 %

           Branch data     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                 :            :     // LineDataList mit Defaults initialisieren
      53                 :            :     OSL_ENSURE(m_vConnLineData.empty(), "OTableConnectionData::Init() : nur mit leere Linienliste aufzurufen !");
      54                 :          0 :     ResetConnLines(sal_True);
      55                 :            :         // das legt Defaults an
      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                 :            :     // hier ziehe ich mich auf das (nicht-virtuelle) operator= zurueck, das nur meine Members kopiert
      68                 :          0 : }
      69                 :            : 
      70                 :            : //------------------------------------------------------------------------
      71 [ #  # ][ #  # ]:          0 : OTableConnectionData::~OTableConnectionData()
      72                 :            : {
      73                 :            :     DBG_DTOR(OTableConnectionData,NULL);
      74                 :            :     // LineDataList loeschen
      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(sal_False);
      90                 :            : 
      91                 :            :     // und kopieren
      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                 :            :         // == ist noch erlaubt, das entspricht einem Append
     108                 :            : 
     109         [ #  # ]:          0 :     if (m_vConnLineData.size() == nIndex)
     110 [ #  # ][ #  # ]:          0 :         return AppendConnLine(rSourceFieldName, rDestFieldName);
                 [ #  # ]
     111                 :            : 
     112         [ #  # ]:          0 :     OConnectionLineDataRef pConnLineData = m_vConnLineData[nIndex];
     113                 :            :     OSL_ENSURE(pConnLineData != NULL, "OTableConnectionData::SetConnLine : habe ungueltiges LineData-Objekt");
     114                 :            : 
     115         [ #  # ]:          0 :     pConnLineData->SetSourceFieldName( rSourceFieldName );
     116         [ #  # ]:          0 :     pConnLineData->SetDestFieldName( rDestFieldName );
     117                 :            : 
     118         [ #  # ]:          0 :     return sal_True;
     119                 :            : }
     120                 :            : 
     121                 :            : //------------------------------------------------------------------------
     122                 :          0 : sal_Bool OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName )
     123                 :            : {
     124                 :          0 :     OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
     125                 :          0 :     OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
     126 [ #  # ][ #  # ]:          0 :     for(;aIter != aEnd;++aIter)
     127                 :            :     {
     128 [ #  # ][ #  # ]:          0 :         if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName)
         [ #  # ][ #  # ]
                 [ #  # ]
     129                 :          0 :             break;
     130                 :            :     }
     131 [ #  # ][ #  # ]:          0 :     if(aIter == aEnd)
     132                 :            :     {
     133 [ #  # ][ #  # ]:          0 :         OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName);
                 [ #  # ]
     134         [ #  # ]:          0 :         if (!pNew.is())
     135                 :          0 :             return sal_False;
     136                 :            : 
     137 [ #  # ][ #  # ]:          0 :         m_vConnLineData.push_back(pNew);
                 [ #  # ]
     138                 :            :     }
     139                 :          0 :     return sal_True;
     140                 :            : }
     141                 :            : 
     142                 :            : //------------------------------------------------------------------------
     143                 :          0 : void OTableConnectionData::ResetConnLines( sal_Bool /*bUseDefaults*/ )
     144                 :            : {
     145                 :          0 :     OConnectionLineDataVec().swap(m_vConnLineData);
     146                 :          0 : }
     147                 :            : 
     148                 :            : //------------------------------------------------------------------------
     149                 :          0 : OConnectionLineDataRef OTableConnectionData::CreateLineDataObj()
     150                 :            : {
     151         [ #  # ]:          0 :     return new OConnectionLineData();
     152                 :            : }
     153                 :            : 
     154                 :            : //------------------------------------------------------------------------
     155                 :          0 : OConnectionLineDataRef OTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
     156                 :            : {
     157         [ #  # ]:          0 :     return new OConnectionLineData( rConnLineData );
     158                 :            : }
     159                 :            : // -----------------------------------------------------------------------------
     160                 :          0 : OTableConnectionData* OTableConnectionData::NewInstance() const
     161                 :            : {
     162         [ #  # ]:          0 :     return new OTableConnectionData();
     163                 :            : }
     164                 :            : // -----------------------------------------------------------------------------
     165                 :          0 : void OTableConnectionData::normalizeLines()
     166                 :            : {
     167                 :            :     // noch ein wenig Normalisierung auf den LineDatas : leere Lines vom Anfang an das Ende verschieben
     168                 :          0 :     sal_Int32 nCount = m_vConnLineData.size();
     169         [ #  # ]:          0 :     for(sal_Int32 i=0;i<nCount;)
     170                 :            :     {
     171 [ #  # ][ #  # ]:          0 :         if(m_vConnLineData[i]->GetSourceFieldName().isEmpty() || m_vConnLineData[i]->GetDestFieldName().isEmpty())
         [ #  # ][ #  # ]
                 [ #  # ]
     172                 :            :         {
     173         [ #  # ]:          0 :             OConnectionLineDataRef pData = m_vConnLineData[i];
     174 [ #  # ][ #  # ]:          0 :             m_vConnLineData.erase(m_vConnLineData.begin()+i);
     175         [ #  # ]:          0 :             m_vConnLineData.push_back(pData);
     176         [ #  # ]:          0 :             --nCount;
     177                 :            :         }
     178                 :            :         else
     179                 :          0 :             ++i;
     180                 :            :     }
     181                 :          0 : }
     182                 :            : // -----------------------------------------------------------------------------
     183                 :            : 
     184                 :            : 
     185                 :            : 
     186                 :            : 
     187                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10