1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AIndex.cxx,v $
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
)
57 m_aIndex
= WpADOIndex(_pIndex
);
60 // -------------------------------------------------------------------------
61 OAdoIndex::OAdoIndex(sal_Bool _bCase
,OConnection
* _pConnection
)
63 ,m_pConnection(_pConnection
)
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
);
83 m_pColumns
->reFill(aVector
);
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;
94 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
97 static ::cppu::OImplementationId 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())
119 case PROPERTY_ID_NAME
:
121 ::rtl::OUString aVal
;
123 m_aIndex
.put_Name(aVal
);
126 case PROPERTY_ID_CATALOG
:
128 ::rtl::OUString aVal
;
130 m_aIndex
.put_Name(aVal
);
133 case PROPERTY_ID_ISUNIQUE
:
134 m_aIndex
.put_Unique(getBOOL(rValue
));
136 case PROPERTY_ID_ISPRIMARYKEYINDEX
:
137 m_aIndex
.put_PrimaryKey(getBOOL(rValue
));
139 case PROPERTY_ID_ISCLUSTERED
:
140 m_aIndex
.put_Clustered(getBOOL(rValue
));
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 // -----------------------------------------------------------------------------