LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/commontools - TPrivilegesResultSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 70 0.0 %
Date: 2012-12-27 Functions: 0 4 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 "TPrivilegesResultSet.hxx"
      21             : 
      22             : using namespace connectivity;
      23             : //------------------------------------------------------------------------------
      24             : using namespace ::com::sun::star::beans;
      25             : using namespace ::com::sun::star::uno;
      26             : using namespace ::com::sun::star::sdbcx;
      27             : using namespace ::com::sun::star::sdbc;
      28             : using namespace ::com::sun::star::container;
      29             : using namespace ::com::sun::star::lang;
      30             : //------------------------------------------------------------------------------
      31           0 : OResultSetPrivileges::OResultSetPrivileges( const Reference< XDatabaseMetaData>& _rxMeta
      32             :                                            , const Any& catalog
      33             :                                            , const ::rtl::OUString& schemaPattern
      34             :                                            , const ::rtl::OUString& tableNamePattern)
      35             :                                            : ODatabaseMetaDataResultSet(eTablePrivileges)
      36           0 :                                            , m_bResetValues(sal_True)
      37             : {
      38           0 :     osl_atomic_increment( &m_refCount );
      39             :     {
      40           0 :         ::rtl::OUString sUserWorkingFor;
      41           0 :         Sequence< ::rtl::OUString > sTableTypes(3);
      42             :         // we want all catalogues, all schemas, all tables
      43           0 :         sTableTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
      44           0 :         sTableTypes[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
      45           0 :         sTableTypes[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")); // just to be sure to include anything else ....
      46             :         try
      47             :         {
      48           0 :             m_xTables = _rxMeta->getTables(catalog,schemaPattern,tableNamePattern,sTableTypes);
      49           0 :             m_xRow = Reference< XRow>(m_xTables,UNO_QUERY);
      50             : 
      51           0 :             sUserWorkingFor = _rxMeta->getUserName();
      52             :         }
      53           0 :         catch(Exception&)
      54             :         {
      55             :         }
      56             : 
      57           0 :         ODatabaseMetaDataResultSet::ORows aRows;
      58           0 :         static ODatabaseMetaDataResultSet::ORow aRow(8);
      59           0 :         aRow[5] = new ORowSetValueDecorator(sUserWorkingFor);
      60           0 :         aRow[6] = ODatabaseMetaDataResultSet::getSelectValue();
      61           0 :         aRow[7] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YES")));
      62           0 :         aRows.push_back(aRow);
      63           0 :         aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
      64           0 :         aRows.push_back(aRow);
      65           0 :         aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue();
      66           0 :         aRows.push_back(aRow);
      67           0 :         aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue();
      68           0 :         aRows.push_back(aRow);
      69           0 :         aRow[6] = ODatabaseMetaDataResultSet::getCreateValue();
      70           0 :         aRows.push_back(aRow);
      71           0 :         aRow[6] = ODatabaseMetaDataResultSet::getReadValue();
      72           0 :         aRows.push_back(aRow);
      73           0 :         aRow[6] = ODatabaseMetaDataResultSet::getAlterValue();
      74           0 :         aRows.push_back(aRow);
      75           0 :         aRow[6] = ODatabaseMetaDataResultSet::getDropValue();
      76           0 :         aRows.push_back(aRow);
      77           0 :         aRow[6] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REFERENCE")));
      78           0 :         aRows.push_back(aRow);
      79             : 
      80           0 :         setRows(aRows);
      81             :     }
      82           0 :     osl_atomic_decrement( &m_refCount );
      83           0 : }
      84             : //------------------------------------------------------------------------------
      85           0 : const ORowSetValue& OResultSetPrivileges::getValue(sal_Int32 columnIndex)
      86             : {
      87           0 :     switch(columnIndex)
      88             :     {
      89             :         case 1:
      90             :         case 2:
      91             :         case 3:
      92           0 :             if ( m_xRow.is() && m_bResetValues )
      93             :             {
      94           0 :                 (*m_aRowsIter)[1] = new ORowSetValueDecorator(m_xRow->getString(1));
      95           0 :                 if ( m_xRow->wasNull() )
      96           0 :                     (*m_aRowsIter)[1]->setNull();
      97           0 :                 (*m_aRowsIter)[2] = new ORowSetValueDecorator(m_xRow->getString(2));
      98           0 :                 if ( m_xRow->wasNull() )
      99           0 :                     (*m_aRowsIter)[2]->setNull();
     100           0 :                 (*m_aRowsIter)[3] = new ORowSetValueDecorator(m_xRow->getString(3));
     101           0 :                 if ( m_xRow->wasNull() )
     102           0 :                     (*m_aRowsIter)[3]->setNull();
     103             : 
     104           0 :                 m_bResetValues = sal_False;
     105             :             }
     106             :     }
     107           0 :     return ODatabaseMetaDataResultSet::getValue(columnIndex);
     108             : }
     109             : // -----------------------------------------------------------------------------
     110           0 : void SAL_CALL OResultSetPrivileges::disposing(void)
     111             : {
     112           0 :     ODatabaseMetaDataResultSet::disposing();
     113           0 : m_xTables.clear();
     114           0 : m_xRow.clear();
     115           0 : }
     116             : // -----------------------------------------------------------------------------
     117           0 : sal_Bool SAL_CALL OResultSetPrivileges::next(  ) throw(SQLException, RuntimeException)
     118             : {
     119           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     120           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     121             : 
     122           0 :     sal_Bool bReturn = sal_False;
     123           0 :     if ( m_xTables.is() )
     124             :     {
     125           0 :         if ( m_bBOF )
     126             :         {
     127           0 :             m_bResetValues = sal_True;
     128           0 :             if ( !m_xTables->next() )
     129           0 :                 return sal_False;
     130             :         }
     131             : 
     132           0 :         bReturn = ODatabaseMetaDataResultSet::next();
     133           0 :         if ( !bReturn )
     134             :         {
     135           0 :             m_bBOF = sal_False;
     136           0 :             m_bResetValues = bReturn = m_xTables->next();
     137             :         }
     138             :     }
     139           0 :     return bReturn;
     140             : }
     141             : // -----------------------------------------------------------------------------
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10