LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MDatabaseMetaDataHelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 35 37 94.6 %
Date: 2014-11-03 Functions: 6 6 100.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           2 : 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           6 : MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()
      41             : {
      42             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" );
      43           6 : }
      44             : 
      45             : 
      46           6 : MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
      47             : {
      48           6 : }
      49             : 
      50         162 : bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
      51             :                                                    ::std::vector< OUString >& _rStrings)
      52             : {
      53             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTableStrings()");
      54             : 
      55             :     /* add default tables */
      56         162 :     _rStrings.push_back("AddressBook");
      57         162 :     _rStrings.push_back("CollectedAddressBook");
      58             : 
      59             :     /* retrieve list table names (not from collected ab) */
      60         162 :     std::set<std::string> lists;
      61         162 :     _pCon->getMorkParser("AddressBook")->retrieveLists(lists);
      62         486 :     for (::std::set<std::string>::iterator iter = lists.begin(); iter != lists.end(); ++iter) {
      63         324 :         OUString groupTableName = OStringToOUString((*iter).c_str(), RTL_TEXTENCODING_UTF8);
      64             :         SAL_INFO("connectivity.mork", "add Table " << groupTableName);
      65             : 
      66         324 :         _rStrings.push_back(groupTableName);
      67         324 :     }
      68             : 
      69         162 :     return true;
      70             : }
      71             : 
      72          10 : bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon,
      73             :                                              const OUString& tableNamePattern,
      74             :                                              ODatabaseMetaDataResultSet::ORows& _rRows)
      75             : {
      76             : 
      77             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()");
      78             : 
      79          10 :     static ODatabaseMetaDataResultSet::ORows    aRows;
      80             : 
      81             :     SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()" );
      82             :     SAL_INFO("connectivity.mork", "tableNamePattern : " << tableNamePattern);
      83          10 :     ::osl::MutexGuard aGuard( m_aMetaMutex );
      84             : 
      85          10 :     ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well
      86          10 :     aRows.clear();
      87             : 
      88          20 :     ::std::vector< OUString > tables;
      89             : 
      90          10 :     if ( !getTableStrings( _pCon, tables ) )
      91           0 :         return false;
      92             : 
      93          50 :     for ( size_t i = 0; i < tables.size(); i++ ) {
      94          40 :         ODatabaseMetaDataResultSet::ORow aRow(3);
      95             : 
      96          80 :         OUString aTableName  = tables[i];
      97             :         SAL_INFO("connectivity.mork", "TableName: " << aTableName );
      98             : 
      99             : 
     100             :         // return tables to caller
     101          40 :         if (match( tableNamePattern, aTableName, '\0' ))
     102             :         {
     103          28 :             if ( aTableName.isEmpty() ) {
     104           0 :                 aTableName = "AddressBook";
     105             :             }
     106             : 
     107             :             SAL_INFO("connectivity.mork", "TableName: " << aTableName);
     108             : 
     109          28 :             aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
     110          28 :             aRow.push_back( new ORowSetValueDecorator( OUString("TABLE") ) ); // Table type
     111          28 :             aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
     112          28 :             aRows.push_back(aRow);
     113             :         }
     114          40 :     }
     115             : 
     116          10 :     _rRows = aRows;
     117          20 :     return true;
     118           6 : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10