1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 
27 #include "MacabTable.hxx"
28 #include "MacabTables.hxx"
29 #include "MacabColumns.hxx"
30 #include "MacabCatalog.hxx"
31 
32 using namespace connectivity::macab;
33 using namespace connectivity;
34 using namespace ::comphelper;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::sdbc;
39 using namespace ::com::sun::star::container;
40 using namespace ::com::sun::star::lang;
41 
42 // -------------------------------------------------------------------------
43 MacabTable::MacabTable( sdbcx::OCollection* _pTables, MacabConnection* _pConnection)
44 	: MacabTable_TYPEDEF(_pTables, sal_True),
45 	m_pConnection(_pConnection)
46 {
47 	construct();
48 }
49 // -------------------------------------------------------------------------
50 MacabTable::MacabTable( sdbcx::OCollection* _pTables,
51 	            MacabConnection* _pConnection,
52 	            const ::rtl::OUString& _Name,
53 	            const ::rtl::OUString& _Type,
54 	            const ::rtl::OUString& _Description ,
55 	            const ::rtl::OUString& _SchemaName,
56 	            const ::rtl::OUString& _CatalogName
57 	            ) : MacabTable_TYPEDEF(_pTables,sal_True,
58 	                              _Name,
59 	                              _Type,
60 	                              _Description,
61 	                              _SchemaName,
62 	                              _CatalogName),
63 	                m_pConnection(_pConnection)
64 {
65 	construct();
66 }
67 // -------------------------------------------------------------------------
68 void MacabTable::refreshColumns()
69 {
70 	TStringVector aVector;
71 
72 	if (!isNew())
73 	{
74 	    Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(
75 				Any(),
76 				m_SchemaName,
77 				m_Name,
78 				::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
79 
80 	    if (xResult.is())
81 	    {
82 		Reference< XRow > xRow(xResult, UNO_QUERY);
83 		while (xResult->next())
84 				aVector.push_back(xRow->getString(4));
85 	    }
86 	}
87 
88 	if (m_pColumns)
89 	    m_pColumns->reFill(aVector);
90 	else
91 	    m_pColumns  = new MacabColumns(this,m_aMutex,aVector);
92 }
93