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

Generated by: LCOV version 1.10