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 
28 #include "calc/CCatalog.hxx"
29 #include "calc/CConnection.hxx"
30 #include "calc/CTables.hxx"
31 #include <com/sun/star/sdbc/XRow.hpp>
32 #include <com/sun/star/sdbc/XResultSet.hpp>
33 #include <rtl/logfile.hxx>
34 
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 
41 // -------------------------------------------------------------------------
42 using namespace connectivity::calc;
43 // -------------------------------------------------------------------------
OCalcCatalog(OCalcConnection * _pCon)44 OCalcCatalog::OCalcCatalog(OCalcConnection* _pCon) : file::OFileCatalog(_pCon)
45 {
46     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcCatalog::OCalcCatalog" );
47 }
48 // -------------------------------------------------------------------------
refreshTables()49 void OCalcCatalog::refreshTables()
50 {
51     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcCatalog::refreshTables" );
52 	TStringVector aVector;
53 	Sequence< ::rtl::OUString > aTypes;
54 	OCalcConnection::ODocHolder aDocHodler(((OCalcConnection*)m_pConnection));
55 	Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
56 		::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
57 
58 	if(xResult.is())
59 	{
60 		Reference< XRow > xRow(xResult,UNO_QUERY);
61 		while(xResult->next())
62 			aVector.push_back(xRow->getString(3));
63 	}
64 	if(m_pTables)
65 		m_pTables->reFill(aVector);
66 	else
67 		m_pTables = new OCalcTables(m_xMetaData,*this,m_aMutex,aVector);
68 
69 	// this avoids that the document will be loaded a 2nd time when one table will be accessed.
70     //if ( m_pTables && m_pTables->hasElements() )
71     //    m_pTables->getByIndex(0);
72 }
73 // -----------------------------------------------------------------------------
74 
75 
76 
77