1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include "NCatalog.hxx" 31 #include "NConnection.hxx" 32 #include "NTables.hxx" 33 #include <com/sun/star/sdbc/XRow.hpp> 34 #include <com/sun/star/sdbc/XResultSet.hpp> 35 #include "NDebug.hxx" 36 37 38 // ------------------------------------------------------------------------- 39 using namespace connectivity::evoab; 40 using namespace ::com::sun::star::uno; 41 using namespace ::com::sun::star::beans; 42 using namespace ::com::sun::star::sdbcx; 43 using namespace ::com::sun::star::sdbc; 44 using namespace ::com::sun::star::container; 45 using namespace ::com::sun::star::lang; 46 // ------------------------------------------------------------------------- 47 OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) : 48 connectivity::sdbcx::OCatalog(_pCon) 49 ,m_pConnection(_pCon) 50 ,m_xMetaData(m_pConnection->getMetaData()) 51 { 52 } 53 void OEvoabCatalog::refreshTables() 54 { 55 TStringVector aVector; 56 Sequence< ::rtl::OUString > aTypes(1); 57 aTypes[0] = ::rtl::OUString::createFromAscii("TABLE"); 58 Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), 59 ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); 60 61 if(xResult.is()) 62 { 63 Reference< XRow > xRow(xResult,UNO_QUERY); 64 ::rtl::OUString aName; 65 66 while(xResult->next()) 67 { 68 aName = xRow->getString(3); 69 aVector.push_back(aName); 70 } 71 } 72 if(m_pTables) 73 m_pTables->reFill(aVector); 74 else 75 m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector); 76 } 77 // XTablesSupplier 78 Reference< XNameAccess > SAL_CALL OEvoabCatalog::getTables( ) throw(RuntimeException) 79 { 80 ::osl::MutexGuard aGuard(m_aMutex); 81 82 try 83 { 84 if (!m_pTables) { 85 refreshTables(); 86 } 87 } 88 catch( const RuntimeException& ) 89 { 90 // allowed to leave this method 91 throw; 92 } 93 catch( const Exception& ) 94 { 95 // allowed 96 } 97 98 return m_pTables; 99 } 100 101