merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / mozab / MCatalog.cxx
blob0ac15a904e4e0cc699b50ed946782b5a9a2cfcf8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MCatalog.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "MCatalog.hxx"
34 #ifndef _CONNECTIVITY_MOZAB_BCONNECTION_HXX_
35 #include "MConnection.hxx"
36 #endif
37 #include "MTables.hxx"
38 #include <com/sun/star/sdbc/XRow.hpp>
39 #include <com/sun/star/sdbc/XResultSet.hpp>
40 #include <cppuhelper/interfacecontainer.h>
42 // -------------------------------------------------------------------------
43 using namespace connectivity::mozab;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::sdbcx;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::container;
49 using namespace ::com::sun::star::lang;
50 using namespace ::cppu;
52 // -------------------------------------------------------------------------
53 OCatalog::OCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
54 ,m_pConnection(_pCon)
55 ,m_xMetaData(m_pConnection->getMetaData( ))
57 // osl_incrementInterlockedCount( &m_refCount );
58 // refreshTables();
59 // refreshViews();
60 // refreshGroups();
61 // refreshUsers();
62 // osl_decrementInterlockedCount( &m_refCount );
64 // -------------------------------------------------------------------------
65 void OCatalog::refreshTables()
67 TStringVector aVector;
68 Sequence< ::rtl::OUString > aTypes(1);
69 aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
70 Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
71 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),aTypes);
73 if(xResult.is())
75 Reference< XRow > xRow(xResult,UNO_QUERY);
76 ::rtl::OUString aName;
77 while(xResult->next())
79 aName = xRow->getString(3);
80 aVector.push_back(aName);
83 if(m_pTables)
84 m_pTables->reFill(aVector);
85 else
86 m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
88 // -------------------------------------------------------------------------
89 void OCatalog::refreshViews()
92 // -------------------------------------------------------------------------
93 void OCatalog::refreshGroups()
96 // -------------------------------------------------------------------------
97 void OCatalog::refreshUsers()
100 // -------------------------------------------------------------------------
101 const ::rtl::OUString& OCatalog::getDot()
103 static const ::rtl::OUString sDot = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("."));
104 return sDot;
106 // -----------------------------------------------------------------------------
108 // XTablesSupplier
109 Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException)
111 ::osl::MutexGuard aGuard(m_aMutex);
112 checkDisposed(rBHelper.bDisposed);
116 if(!m_pTables || m_pConnection->getForceLoadTables())
117 refreshTables();
119 catch( const RuntimeException& )
121 // allowed to leave this method
122 throw;
124 catch( const Exception& )
126 // allowed
129 return const_cast<OCatalog*>(this)->m_pTables;