LCOV - code coverage report
Current view: top level - connectivity/source/commontools - TIndex.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 36 80.6 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
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 <connectivity/TIndex.hxx>
      21             : #include <connectivity/TIndexColumns.hxx>
      22             : #include <com/sun/star/sdbc/XRow.hpp>
      23             : #include <com/sun/star/sdbc/XResultSet.hpp>
      24             : #include <connectivity/TTableHelper.hxx>
      25             : #include "TConnection.hxx"
      26             : 
      27             : using namespace connectivity;
      28             : using namespace connectivity::sdbcx;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::beans;
      31             : using namespace ::com::sun::star::sdbc;
      32             : using namespace ::com::sun::star::container;
      33             : using namespace ::com::sun::star::lang;
      34             : 
      35           0 : OIndexHelper::OIndexHelper( OTableHelper* _pTable) : connectivity::sdbcx::OIndex(true)
      36           0 :                  , m_pTable(_pTable)
      37             : {
      38           0 :     construct();
      39           0 :     ::std::vector< OUString> aVector;
      40           0 :     m_pColumns  = new OIndexColumns(this,m_aMutex,aVector);
      41           0 : }
      42             : 
      43           3 : OIndexHelper::OIndexHelper( OTableHelper* _pTable,
      44             :                 const OUString& _Name,
      45             :                 const OUString& _Catalog,
      46             :                 bool _isUnique,
      47             :                 bool _isPrimaryKeyIndex,
      48             :                 bool _isClustered
      49             :                 ) : connectivity::sdbcx::OIndex(_Name,
      50             :                                   _Catalog,
      51             :                                   _isUnique,
      52             :                                   _isPrimaryKeyIndex,
      53             :                                   _isClustered,true)
      54           3 :                 ,m_pTable(_pTable)
      55             : {
      56           3 :     construct();
      57           3 :     refreshColumns();
      58           3 : }
      59             : 
      60             : 
      61           3 : void OIndexHelper::refreshColumns()
      62             : {
      63           3 :     if ( !m_pTable )
      64           3 :         return;
      65             : 
      66           3 :     ::std::vector< OUString> aVector;
      67           3 :     if ( !isNew() )
      68             :     {
      69           3 :         ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
      70           6 :         OUString aSchema,aTable;
      71           3 :         m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
      72           3 :         m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))       >>= aTable;
      73             : 
      74           6 :         Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(
      75           3 :             m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
      76           9 :             aSchema,aTable,sal_False,sal_False);
      77             : 
      78           3 :         if ( xResult.is() )
      79             :         {
      80           3 :             Reference< XRow > xRow(xResult,UNO_QUERY);
      81           6 :             OUString aColName;
      82           9 :             while( xResult->next() )
      83             :             {
      84           3 :                 if ( xRow->getString(6) == m_Name )
      85             :                 {
      86           3 :                     aColName = xRow->getString(9);
      87           3 :                     if ( !xRow->wasNull() )
      88           3 :                         aVector.push_back(aColName);
      89             :                 }
      90           3 :             }
      91           3 :         }
      92             :     }
      93           3 :     if(m_pColumns)
      94           0 :         m_pColumns->reFill(aVector);
      95             :     else
      96           3 :         m_pColumns  = new OIndexColumns(this,m_aMutex,aVector);
      97             : }
      98             : 
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11