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 "ado/ACatalog.hxx" 31 #ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ 32 #include "ado/AConnection.hxx" 33 #endif 34 #include "ado/AGroups.hxx" 35 #include "ado/AUsers.hxx" 36 #include "ado/ATables.hxx" 37 #include "ado/AViews.hxx" 38 #include <com/sun/star/sdbc/XRow.hpp> 39 #include <com/sun/star/sdbc/XResultSet.hpp> 40 41 42 // ------------------------------------------------------------------------- 43 using namespace connectivity; 44 using namespace connectivity::ado; 45 // ------------------------------------------------------------------------- 46 OCatalog::OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) 47 ,m_pConnection(_pCon) 48 ,m_aCatalog(_pCatalog) 49 { 50 } 51 // ----------------------------------------------------------------------------- 52 OCatalog::~OCatalog() 53 { 54 if(m_aCatalog.IsValid()) 55 m_aCatalog.putref_ActiveConnection(NULL); 56 m_aCatalog.clear(); 57 } 58 // ----------------------------------------------------------------------------- 59 void OCatalog::refreshTables() 60 { 61 TStringVector aVector; 62 63 WpADOTables aTables(m_aCatalog.get_Tables()); 64 if ( aTables.IsValid() ) 65 { 66 aTables.Refresh(); 67 sal_Int32 nCount = aTables.GetItemCount(); 68 aVector.reserve(nCount); 69 for(sal_Int32 i=0;i< nCount;++i) 70 { 71 WpADOTable aElement = aTables.GetItem(i); 72 if ( aElement.IsValid() ) 73 { 74 ::rtl::OUString sTypeName = aElement.get_Type(); 75 if ( !sTypeName.equalsIgnoreAsciiCaseAscii("SYSTEM TABLE") && !sTypeName.equalsIgnoreAsciiCaseAscii("ACCESS TABLE") ) 76 aVector.push_back(aElement.get_Name()); 77 } 78 } 79 } 80 81 if(m_pTables) 82 m_pTables->reFill(aVector); 83 else 84 m_pTables = new OTables(this,m_aMutex,aVector,aTables,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); 85 } 86 // ------------------------------------------------------------------------- 87 void OCatalog::refreshViews() 88 { 89 TStringVector aVector; 90 91 WpADOViews aViews = m_aCatalog.get_Views(); 92 aViews.fillElementNames(aVector); 93 94 if(m_pViews) 95 m_pViews->reFill(aVector); 96 else 97 m_pViews = new OViews(this,m_aMutex,aVector,aViews,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); 98 } 99 // ------------------------------------------------------------------------- 100 void OCatalog::refreshGroups() 101 { 102 TStringVector aVector; 103 104 WpADOGroups aGroups = m_aCatalog.get_Groups(); 105 aGroups.fillElementNames(aVector); 106 107 if(m_pGroups) 108 m_pGroups->reFill(aVector); 109 else 110 m_pGroups = new OGroups(this,m_aMutex,aVector,aGroups,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); 111 } 112 // ------------------------------------------------------------------------- 113 void OCatalog::refreshUsers() 114 { 115 TStringVector aVector; 116 117 WpADOUsers aUsers = m_aCatalog.get_Users(); 118 aUsers.fillElementNames(aVector); 119 120 if(m_pUsers) 121 m_pUsers->reFill(aVector); 122 else 123 m_pUsers = new OUsers(this,m_aMutex,aVector,aUsers,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); 124 } 125 // ------------------------------------------------------------------------- 126 127 128