xref: /trunk/main/connectivity/source/drivers/ado/AIndex.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "ado/AIndex.hxx"
27cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
29cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
30cdf0e10cSrcweir #include <comphelper/sequence.hxx>
31cdf0e10cSrcweir #include "ado/AColumns.hxx"
32cdf0e10cSrcweir #include <comphelper/extract.hxx>
33cdf0e10cSrcweir #include "TConnection.hxx"
34cdf0e10cSrcweir #include <comphelper/types.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace ::comphelper;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace connectivity::ado;
39cdf0e10cSrcweir using namespace com::sun::star::uno;
40cdf0e10cSrcweir using namespace com::sun::star::lang;
41cdf0e10cSrcweir using namespace com::sun::star::beans;
42cdf0e10cSrcweir using namespace com::sun::star::sdbc;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // -------------------------------------------------------------------------
OAdoIndex(sal_Bool _bCase,OConnection * _pConnection,ADOIndex * _pIndex)45cdf0e10cSrcweir OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection,ADOIndex* _pIndex)
46cdf0e10cSrcweir     : OIndex_ADO(::rtl::OUString(),::rtl::OUString(),sal_False,sal_False,sal_False,_bCase)
47cdf0e10cSrcweir     ,m_pConnection(_pConnection)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     construct();
50cdf0e10cSrcweir     m_aIndex = WpADOIndex(_pIndex);
51cdf0e10cSrcweir     fillPropertyValues();
52cdf0e10cSrcweir }
53cdf0e10cSrcweir // -------------------------------------------------------------------------
OAdoIndex(sal_Bool _bCase,OConnection * _pConnection)54cdf0e10cSrcweir OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection)
55cdf0e10cSrcweir     : OIndex_ADO(_bCase)
56cdf0e10cSrcweir     ,m_pConnection(_pConnection)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     construct();
59cdf0e10cSrcweir     m_aIndex.Create();
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // -------------------------------------------------------------------------
63cdf0e10cSrcweir 
refreshColumns()64cdf0e10cSrcweir void OAdoIndex::refreshColumns()
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     TStringVector aVector;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     WpADOColumns aColumns;
69cdf0e10cSrcweir     if ( m_aIndex.IsValid() )
70cdf0e10cSrcweir     {
71cdf0e10cSrcweir         aColumns = m_aIndex.get_Columns();
72cdf0e10cSrcweir         aColumns.fillElementNames(aVector);
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     if ( m_pColumns )
76cdf0e10cSrcweir         m_pColumns->reFill(aVector);
77cdf0e10cSrcweir     else
78cdf0e10cSrcweir         m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // -------------------------------------------------------------------------
getUnoTunnelImplementationId()82cdf0e10cSrcweir Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     static ::cppu::OImplementationId * pId = 0;
85cdf0e10cSrcweir     if (! pId)
86cdf0e10cSrcweir     {
87cdf0e10cSrcweir         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
88cdf0e10cSrcweir         if (! pId)
89cdf0e10cSrcweir         {
90cdf0e10cSrcweir             static ::cppu::OImplementationId aId;
91cdf0e10cSrcweir             pId = &aId;
92cdf0e10cSrcweir         }
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir     return pId->getImplementationId();
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel
98cdf0e10cSrcweir //------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & rId)99cdf0e10cSrcweir sal_Int64 OAdoIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
102cdf0e10cSrcweir                 ? reinterpret_cast< sal_Int64 >( this )
103cdf0e10cSrcweir                 : OIndex_ADO::getSomething(rId);
104cdf0e10cSrcweir }
105cdf0e10cSrcweir // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)106cdf0e10cSrcweir void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     if(m_aIndex.IsValid())
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         switch(nHandle)
111cdf0e10cSrcweir         {
112cdf0e10cSrcweir             case PROPERTY_ID_NAME:
113cdf0e10cSrcweir                 {
114cdf0e10cSrcweir                     ::rtl::OUString aVal;
115cdf0e10cSrcweir                     rValue >>= aVal;
116cdf0e10cSrcweir                     m_aIndex.put_Name(aVal);
117cdf0e10cSrcweir                 }
118cdf0e10cSrcweir                 break;
119cdf0e10cSrcweir             case PROPERTY_ID_CATALOG:
120cdf0e10cSrcweir                 {
121cdf0e10cSrcweir                     ::rtl::OUString aVal;
122cdf0e10cSrcweir                     rValue >>= aVal;
123cdf0e10cSrcweir                     m_aIndex.put_Name(aVal);
124cdf0e10cSrcweir                 }
125cdf0e10cSrcweir                 break;
126cdf0e10cSrcweir             case PROPERTY_ID_ISUNIQUE:
127cdf0e10cSrcweir                 m_aIndex.put_Unique(getBOOL(rValue));
128cdf0e10cSrcweir                 break;
129cdf0e10cSrcweir             case PROPERTY_ID_ISPRIMARYKEYINDEX:
130cdf0e10cSrcweir                 m_aIndex.put_PrimaryKey(getBOOL(rValue));
131cdf0e10cSrcweir                 break;
132cdf0e10cSrcweir             case PROPERTY_ID_ISCLUSTERED:
133cdf0e10cSrcweir                 m_aIndex.put_Clustered(getBOOL(rValue));
134cdf0e10cSrcweir                 break;
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir     OIndex_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()140cdf0e10cSrcweir void SAL_CALL OAdoIndex::acquire() throw()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     OIndex_ADO::acquire();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()145cdf0e10cSrcweir void SAL_CALL OAdoIndex::release() throw()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     OIndex_ADO::release();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir // -----------------------------------------------------------------------------
150