LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MDatabaseMetaDataHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 6 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             : 
      10             : #include "MDatabaseMetaDataHelper.hxx"
      11             : #include "FDatabaseMetaDataResultSet.hxx"
      12             : #include <connectivity/dbexception.hxx>
      13             : #include <comphelper/uno3.hxx>
      14             : #include <comphelper/sequence.hxx>
      15             : #include <osl/mutex.hxx>
      16             : #include <osl/conditn.hxx>
      17             : 
      18             : // do we need it?
      19           0 : static ::osl::Mutex m_aMetaMutex;
      20             : 
      21             : #include <osl/diagnose.h>
      22             : #include <com/sun/star/uno/Reference.hxx>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/uno/XInterface.hpp>
      25             : #include <com/sun/star/uno/Exception.hpp>
      26             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27             : #include <com/sun/star/beans/Property.hpp>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      30             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31             : #include <com/sun/star/sdb/ErrorCondition.hpp>
      32             : #include <comphelper/processfactory.hxx>
      33             : 
      34             : #include "MorkParser.hxx"
      35             : 
      36             : using namespace connectivity;
      37             : using namespace connectivity::mork;
      38             : 
      39             : 
      40           0 : MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()
      41             : {
      42             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" );
      43           0 : }
      44             : 
      45             : 
      46           0 : MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
      47             : {
      48           0 : }
      49             : 
      50           0 : sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
      51             :                                                    ::std::vector< OUString >& _rStrings)
      52             : {
      53             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTableStrings()");
      54             : 
      55             :     /* add default tables */
      56           0 :     _rStrings.push_back("AddressBook");
      57           0 :     _rStrings.push_back("CollectedAddressBook");
      58             : 
      59             :     /* retrieve list table names (not from collected ab) */
      60           0 :     std::set<std::string> lists;
      61           0 :     _pCon->getMorkParser("AddressBook")->retrieveLists(lists);
      62           0 :     for (::std::set<std::string>::iterator iter = lists.begin(); iter != lists.end(); ++iter) {
      63           0 :         OUString groupTableName = OStringToOUString((*iter).c_str(), RTL_TEXTENCODING_UTF8);
      64             :         SAL_INFO("connectivity.mork", "add Table " << groupTableName);
      65             : 
      66           0 :         _rStrings.push_back(groupTableName);
      67           0 :     }
      68             : 
      69           0 :     return( sal_True );
      70             : }
      71             : 
      72           0 : sal_Bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon,
      73             :                                              const OUString& tableNamePattern,
      74             :                                              ODatabaseMetaDataResultSet::ORows& _rRows)
      75             : {
      76             : 
      77             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()");
      78             : 
      79           0 :     static ODatabaseMetaDataResultSet::ORows    aRows;
      80             : 
      81             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()" );
      82             :     SAL_INFO("connectivity.mork", "tableNamePattern : " << tableNamePattern);
      83           0 :     ::osl::MutexGuard aGuard( m_aMetaMutex );
      84             : 
      85           0 :     ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well
      86           0 :     aRows.clear();
      87             : 
      88           0 :     ::std::vector< OUString > tables;
      89             : 
      90           0 :     if ( !getTableStrings( _pCon, tables ) )
      91           0 :         return sal_False;
      92             : 
      93           0 :     for ( size_t i = 0; i < tables.size(); i++ ) {
      94           0 :         ODatabaseMetaDataResultSet::ORow aRow(3);
      95             : 
      96           0 :         OUString aTableName  = tables[i];
      97             :         SAL_INFO("connectivity.mork", "TableName: " << aTableName );
      98             : 
      99             : 
     100             :         // return tables to caller
     101           0 :         if (match( tableNamePattern, aTableName, '\0' ))
     102             :         {
     103           0 :             if ( aTableName.isEmpty() ) {
     104           0 :                 aTableName = "AddressBook";
     105             :             }
     106             : 
     107             :             SAL_INFO("connectivity.mork", "TableName: " << aTableName);
     108             : 
     109           0 :             aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
     110           0 :             aRow.push_back( new ORowSetValueDecorator( OUString("TABLE") ) ); // Table type
     111           0 :             aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
     112           0 :             aRows.push_back(aRow);
     113             :         }
     114           0 :     }
     115             : 
     116           0 :     _rRows = aRows;
     117           0 :     return(sal_True);
     118           0 : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10