LCOV - code coverage report
Current view: top level - connectivity/source/commontools - TKeyColumns.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 130 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 "connectivity/TKeyColumns.hxx"
      21                 :            : #include "connectivity/sdbcx/VKeyColumn.hxx"
      22                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      23                 :            : #include <com/sun/star/sdbc/XResultSet.hpp>
      24                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      25                 :            : #include <com/sun/star/sdbc/ColumnValue.hpp>
      26                 :            : #include <comphelper/extract.hxx>
      27                 :            : #include <comphelper/property.hxx>
      28                 :            : #include "TConnection.hxx"
      29                 :            : #include "connectivity/TTableHelper.hxx"
      30                 :            : 
      31                 :            : using namespace connectivity;
      32                 :            : using namespace connectivity::sdbcx;
      33                 :            : using namespace ::com::sun::star::uno;
      34                 :            : using namespace ::com::sun::star::beans;
      35                 :            : using namespace ::com::sun::star::sdbc;
      36                 :            : using namespace ::com::sun::star::container;
      37                 :            : using namespace ::com::sun::star::lang;
      38                 :            : 
      39                 :            : // -------------------------------------------------------------------------
      40                 :          0 : OKeyColumnsHelper::OKeyColumnsHelper(   OTableKeyHelper* _pKey,
      41                 :            :                 ::osl::Mutex& _rMutex,
      42                 :            :                 const ::std::vector< ::rtl::OUString> &_rVector)
      43                 :            :             : connectivity::sdbcx::OCollection(*_pKey,sal_True,_rMutex,_rVector)
      44                 :          0 :             ,m_pKey(_pKey)
      45                 :            : {
      46                 :          0 : }
      47                 :            : // -------------------------------------------------------------------------
      48                 :          0 : sdbcx::ObjectType OKeyColumnsHelper::createObject(const ::rtl::OUString& _rName)
      49                 :            : {
      50         [ #  # ]:          0 :     ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
      51                 :          0 :     ::rtl::OUString aSchema,aTable;
      52 [ #  # ][ #  # ]:          0 :     m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))   >>= aSchema;
      53 [ #  # ][ #  # ]:          0 :     m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))         >>= aTable;
      54                 :            : 
      55                 :            :     // frist get the related column to _rName
      56 [ #  # ][ #  # ]:          0 :     Reference< XResultSet > xResult = m_pKey->getTable()->getMetaData()->getImportedKeys(
      57 [ #  # ][ #  # ]:          0 :             m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable);
                 [ #  # ]
      58                 :            : 
      59                 :          0 :     ::rtl::OUString aRefColumnName;
      60         [ #  # ]:          0 :     if ( xResult.is() )
      61                 :            :     {
      62         [ #  # ]:          0 :         Reference< XRow > xRow(xResult,UNO_QUERY);
      63                 :          0 :         ::rtl::OUString aTemp;
      64 [ #  # ][ #  # ]:          0 :         while(xResult->next())
                 [ #  # ]
      65                 :            :         {
      66 [ #  # ][ #  # ]:          0 :             aTemp = xRow->getString(4);
      67 [ #  # ][ #  # ]:          0 :             if(xRow->getString(8) == _rName && m_pKey->getName() == xRow->getString(12))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
              # ][ #  # ]
      68                 :            :             {
      69                 :          0 :                 aRefColumnName = aTemp;
      70                 :          0 :                 break;
      71                 :            :             }
      72                 :          0 :         }
      73                 :            :     }
      74                 :            : 
      75                 :          0 :     sdbcx::ObjectType xRet;
      76                 :            : 
      77                 :            :     // now describe the column _rName and set his related column
      78   [ #  #  #  # ]:          0 :     xResult = m_pKey->getTable()->getMetaData()->getColumns(
                 [ #  # ]
      79 [ #  # ][ #  # ]:          0 :                 m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable,_rName);
         [ #  # ][ #  # ]
      80                 :            : 
      81         [ #  # ]:          0 :     if ( xResult.is() )
      82                 :            :     {
      83         [ #  # ]:          0 :         Reference< XRow > xRow(xResult,UNO_QUERY);
      84 [ #  # ][ #  # ]:          0 :         if ( xResult->next() )
                 [ #  # ]
      85                 :            :         {
      86 [ #  # ][ #  # ]:          0 :             if ( xRow->getString(4) == _rName )
                 [ #  # ]
      87                 :            :             {
      88 [ #  # ][ #  # ]:          0 :                 sal_Int32 nDataType = xRow->getInt(5);
      89 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aTypeName(xRow->getString(6));
      90 [ #  # ][ #  # ]:          0 :                 sal_Int32 nSize = xRow->getInt(7);
      91 [ #  # ][ #  # ]:          0 :                 sal_Int32 nDec  = xRow->getInt(9);
      92 [ #  # ][ #  # ]:          0 :                 sal_Int32 nNull = xRow->getInt(11);
      93                 :          0 :                 ::rtl::OUString sColumnDef;
      94                 :            :                 try
      95                 :            :                 {
      96 [ #  # ][ #  # ]:          0 :                     sColumnDef = xRow->getString(13);
      97                 :            :                 }
      98         [ #  # ]:          0 :                 catch(const SQLException&)
      99                 :            :                 {
     100                 :            :                     // somethimes we get an error when asking for this param
     101                 :            :                 }
     102                 :            : 
     103                 :            :                 OKeyColumn* pRet = new OKeyColumn(aRefColumnName,
     104                 :            :                                                     _rName,
     105                 :            :                                                     aTypeName,
     106                 :            :                                                     sColumnDef,
     107                 :            :                                                     nNull,
     108                 :            :                                                     nSize,
     109                 :            :                                                     nDec,
     110                 :            :                                                     nDataType,
     111                 :            :                                                     sal_False,
     112                 :            :                                                     sal_False,
     113                 :            :                                                     sal_False,
     114 [ #  # ][ #  # ]:          0 :                                                     isCaseSensitive());
     115 [ #  # ][ #  # ]:          0 :                 xRet = pRet;
     116                 :            :             }
     117                 :          0 :         }
     118                 :            :     }
     119                 :            : 
     120                 :          0 :     return xRet;
     121                 :            : }
     122                 :            : // -------------------------------------------------------------------------
     123                 :          0 : Reference< XPropertySet > OKeyColumnsHelper::createDescriptor()
     124                 :            : {
     125 [ #  # ][ #  # ]:          0 :     return new OKeyColumn(isCaseSensitive());
     126                 :            : }
     127                 :            : // -------------------------------------------------------------------------
     128                 :          0 : void OKeyColumnsHelper::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
     129                 :            : {
     130                 :          0 :     m_pKey->refreshColumns();
     131                 :          0 : }
     132                 :            : // -----------------------------------------------------------------------------
     133                 :            : 
     134                 :            : 
     135                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10