Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / ado / AIndex.cxx
blob0e49c6e8e69af82c6618441bfc30ea27aa507c9a
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: AIndex.cxx,v $
10 * $Revision: 1.23 $
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 "ado/AIndex.hxx"
34 #include <com/sun/star/sdbc/XRow.hpp>
35 #include <com/sun/star/sdbc/XResultSet.hpp>
36 #include <cppuhelper/typeprovider.hxx>
37 #include <comphelper/sequence.hxx>
38 #include "ado/AColumns.hxx"
39 #include <comphelper/extract.hxx>
40 #include "TConnection.hxx"
41 #include <comphelper/types.hxx>
43 using namespace ::comphelper;
45 using namespace connectivity::ado;
46 using namespace com::sun::star::uno;
47 using namespace com::sun::star::lang;
48 using namespace com::sun::star::beans;
49 using namespace com::sun::star::sdbc;
51 // -------------------------------------------------------------------------
52 OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection,ADOIndex* _pIndex)
53 : OIndex_ADO(::rtl::OUString(),::rtl::OUString(),sal_False,sal_False,sal_False,_bCase)
54 ,m_pConnection(_pConnection)
56 construct();
57 m_aIndex = WpADOIndex(_pIndex);
58 fillPropertyValues();
60 // -------------------------------------------------------------------------
61 OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection)
62 : OIndex_ADO(_bCase)
63 ,m_pConnection(_pConnection)
65 construct();
66 m_aIndex.Create();
69 // -------------------------------------------------------------------------
71 void OAdoIndex::refreshColumns()
73 TStringVector aVector;
75 WpADOColumns aColumns;
76 if ( m_aIndex.IsValid() )
78 aColumns = m_aIndex.get_Columns();
79 aColumns.fillElementNames(aVector);
82 if ( m_pColumns )
83 m_pColumns->reFill(aVector);
84 else
85 m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection);
88 // -------------------------------------------------------------------------
89 Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId()
91 static ::cppu::OImplementationId * pId = 0;
92 if (! pId)
94 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
95 if (! pId)
97 static ::cppu::OImplementationId aId;
98 pId = &aId;
101 return pId->getImplementationId();
104 // com::sun::star::lang::XUnoTunnel
105 //------------------------------------------------------------------
106 sal_Int64 OAdoIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
108 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
109 ? reinterpret_cast< sal_Int64 >( this )
110 : OIndex_ADO::getSomething(rId);
112 // -------------------------------------------------------------------------
113 void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
115 if(m_aIndex.IsValid())
117 switch(nHandle)
119 case PROPERTY_ID_NAME:
121 ::rtl::OUString aVal;
122 rValue >>= aVal;
123 m_aIndex.put_Name(aVal);
125 break;
126 case PROPERTY_ID_CATALOG:
128 ::rtl::OUString aVal;
129 rValue >>= aVal;
130 m_aIndex.put_Name(aVal);
132 break;
133 case PROPERTY_ID_ISUNIQUE:
134 m_aIndex.put_Unique(getBOOL(rValue));
135 break;
136 case PROPERTY_ID_ISPRIMARYKEYINDEX:
137 m_aIndex.put_PrimaryKey(getBOOL(rValue));
138 break;
139 case PROPERTY_ID_ISCLUSTERED:
140 m_aIndex.put_Clustered(getBOOL(rValue));
141 break;
144 OIndex_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
146 // -----------------------------------------------------------------------------
147 void SAL_CALL OAdoIndex::acquire() throw()
149 OIndex_ADO::acquire();
151 // -----------------------------------------------------------------------------
152 void SAL_CALL OAdoIndex::release() throw()
154 OIndex_ADO::release();
156 // -----------------------------------------------------------------------------