Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / mozab / MTables.cxx
blobc6bac0f566d073200ea252be6daf813487a2422c
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: MTables.cxx,v $
10 * $Revision: 1.9 $
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 "MTables.hxx"
34 #include "MTable.hxx"
35 #include <com/sun/star/sdbc/XRow.hpp>
36 #include <com/sun/star/sdbc/XResultSet.hpp>
37 #include <com/sun/star/sdbc/ColumnValue.hpp>
38 #include <com/sun/star/sdbc/KeyRule.hpp>
39 #include <com/sun/star/sdbcx/KeyType.hpp>
40 #include "MCatalog.hxx"
41 #ifndef _CONNECTIVITY_MOZAB_BCONNECTION_HXX_
42 #include "MConnection.hxx"
43 #endif
44 #include <comphelper/extract.hxx>
45 #include "connectivity/dbtools.hxx"
46 #include "connectivity/dbexception.hxx"
47 #include <cppuhelper/interfacecontainer.h>
48 #include <comphelper/types.hxx>
50 using namespace ::comphelper;
51 using namespace connectivity;
52 using namespace ::cppu;
53 using namespace connectivity::mozab;
54 using namespace ::com::sun::star::uno;
55 using namespace ::com::sun::star::beans;
56 using namespace ::com::sun::star::sdbcx;
57 using namespace ::com::sun::star::sdbc;
58 using namespace ::com::sun::star::container;
59 using namespace ::com::sun::star::lang;
60 using namespace dbtools;
61 typedef connectivity::sdbcx::OCollection OCollection_TYPE;
63 sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
65 ::rtl::OUString aName,aSchema;
66 // sal_Int32 nLen = _rName.indexOf('.');
67 // aSchema = _rName.copy(0,nLen);
68 // aName = _rName.copy(nLen+1);
69 aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
70 aName = _rName;
72 Sequence< ::rtl::OUString > aTypes(1);
73 aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
74 // aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE"));
75 // aTypes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEMTABLE"));
76 ::rtl::OUString sEmpty;
78 Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
80 sdbcx::ObjectType xRet = NULL;
81 if(xResult.is())
83 Reference< XRow > xRow(xResult,UNO_QUERY);
84 if(xResult->next()) // there can be only one table with this name
86 OTable* pRet = new OTable( this, static_cast<OCatalog&>(m_rParent).getConnection(),
87 aName,xRow->getString(4),xRow->getString(5));
88 xRet = pRet;
91 ::comphelper::disposeComponent(xResult);
93 return xRet;
95 // -------------------------------------------------------------------------
96 void OTables::impl_refresh( ) throw(RuntimeException)
98 static_cast<OCatalog&>(m_rParent).refreshTables();
100 // -------------------------------------------------------------------------
101 void OTables::disposing(void)
103 m_xMetaData.clear();
104 OCollection::disposing();
106 // -----------------------------------------------------------------------------