xref: /AOO41X/main/connectivity/source/drivers/macab/MacabColumns.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
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 "MacabColumns.hxx"
28 #include "MacabTable.hxx"
29 #include "MacabTables.hxx"
30 #include "MacabCatalog.hxx"
31 #include "connectivity/sdbcx/VColumn.hxx"
32 
33 using namespace connectivity::macab;
34 using namespace connectivity::sdbcx;
35 using namespace connectivity;
36 using namespace ::comphelper;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::sdbc;
40 using namespace ::com::sun::star::container;
41 using namespace ::com::sun::star::lang;
42 
43 // -------------------------------------------------------------------------
createObject(const::rtl::OUString & _rName)44 sdbcx::ObjectType MacabColumns::createObject(const ::rtl::OUString& _rName)
45 {
46     Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
47         Any(),
48         m_pTable->getSchema(),
49         m_pTable->getTableName(),
50         _rName);
51 
52     sdbcx::ObjectType xRet = NULL;
53     if (xResult.is())
54     {
55         Reference< XRow > xRow(xResult,UNO_QUERY);
56 
57         while (xResult->next())
58         {
59             if (xRow->getString(4) == _rName)
60             {
61                 OColumn* pRet = new OColumn(
62                         _rName,
63                         xRow->getString(6),
64                         xRow->getString(13),
65                         xRow->getString(12),
66                         xRow->getInt(11),
67                         xRow->getInt(7),
68                         xRow->getInt(9),
69                         xRow->getInt(5),
70                         sal_False,
71                         sal_False,
72                         sal_False,
73                         sal_True);
74                 xRet = pRet;
75                 break;
76             }
77         }
78     }
79 
80     return xRet;
81 }
82 // -------------------------------------------------------------------------
impl_refresh()83 void MacabColumns::impl_refresh() throw(RuntimeException)
84 {
85     m_pTable->refreshColumns();
86 }
87 // -------------------------------------------------------------------------
MacabColumns(MacabTable * _pTable,::osl::Mutex & _rMutex,const TStringVector & _rVector)88 MacabColumns::MacabColumns( MacabTable* _pTable,
89                         ::osl::Mutex& _rMutex,
90                         const TStringVector &_rVector)
91     : sdbcx::OCollection(*_pTable, sal_True, _rMutex, _rVector),
92       m_pTable(_pTable)
93 {
94 }
95