xref: /trunk/main/connectivity/source/drivers/macab/MacabCatalog.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
31 #include "MacabCatalog.hxx"
32 #include "MacabConnection.hxx"
33 #include "MacabTables.hxx"
34 
35 using namespace connectivity::macab;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::beans;
38 using namespace ::com::sun::star::sdbcx;
39 using namespace ::com::sun::star::sdbc;
40 using namespace ::com::sun::star::container;
41 using namespace ::com::sun::star::lang;
42 using namespace ::cppu;
43 
44 // -------------------------------------------------------------------------
45 MacabCatalog::MacabCatalog(MacabConnection* _pCon)
46         : connectivity::sdbcx::OCatalog(_pCon),
47           m_pConnection(_pCon),
48           m_xMetaData(m_pConnection->getMetaData())
49 {
50 }
51 // -------------------------------------------------------------------------
52 void MacabCatalog::refreshTables()
53 {
54     TStringVector aVector;
55     Sequence< ::rtl::OUString > aTypes(1);
56     aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
57     Reference< XResultSet > xResult = m_xMetaData->getTables(
58         Any(),
59         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),
60         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),
61         aTypes);
62 
63     if (xResult.is())
64     {
65         Reference< XRow > xRow(xResult,UNO_QUERY);
66         ::rtl::OUString aName;
67         // const ::rtl::OUString& sDot = MacabCatalog::getDot();
68 
69         while (xResult->next())
70         {
71             // aName = xRow->getString(2);
72             // aName += sDot;
73             aName = xRow->getString(3);
74             aVector.push_back(aName);
75         }
76     }
77     if (m_pTables)
78         m_pTables->reFill(aVector);
79     else
80         m_pTables = new MacabTables(m_xMetaData,*this,m_aMutex,aVector);
81 }
82 // -------------------------------------------------------------------------
83 void MacabCatalog::refreshViews()
84 {
85 }
86 // -------------------------------------------------------------------------
87 void MacabCatalog::refreshGroups()
88 {
89 }
90 // -------------------------------------------------------------------------
91 void MacabCatalog::refreshUsers()
92 {
93 }
94 // -------------------------------------------------------------------------
95 const ::rtl::OUString& MacabCatalog::getDot()
96 {
97     static const ::rtl::OUString sDot = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("."));
98     return sDot;
99 }
100 // -----------------------------------------------------------------------------
101 
102 // XTablesSupplier
103 Reference< XNameAccess > SAL_CALL MacabCatalog::getTables(  ) throw(RuntimeException)
104 {
105     ::osl::MutexGuard aGuard(m_aMutex);
106     checkDisposed(rBHelper.bDisposed);
107 
108     try
109     {
110         if (!m_pTables)
111             refreshTables();
112     }
113     catch( const RuntimeException& )
114     {
115         // allowed to leave this method
116         throw;
117     }
118     catch( const Exception& )
119     {
120         // allowed
121     }
122 
123     return m_pTables;
124 }
125