update dev300-m58
[ooovba.git] / connectivity / source / drivers / ado / AKey.cxx
blob129705426f6ce45da65e45a936a03041055790ad
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: AKey.cxx,v $
10 * $Revision: 1.22 $
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/AKey.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 "ado/AConnection.hxx"
41 using namespace connectivity::ado;
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star::lang;
44 using namespace com::sun::star::beans;
45 using namespace com::sun::star::sdbc;
46 using namespace com::sun::star::sdbcx;
48 // -------------------------------------------------------------------------
49 OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection, ADOKey* _pKey)
50 : OKey_ADO(_bCase)
51 ,m_pConnection(_pConnection)
53 construct();
54 m_aKey = WpADOKey(_pKey);
55 fillPropertyValues();
57 // -------------------------------------------------------------------------
58 OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection)
59 : OKey_ADO(_bCase)
60 ,m_pConnection(_pConnection)
62 construct();
63 m_aKey.Create();
65 // -------------------------------------------------------------------------
66 void OAdoKey::refreshColumns()
68 TStringVector aVector;
70 WpADOColumns aColumns;
71 if ( m_aKey.IsValid() )
73 aColumns = m_aKey.get_Columns();
74 aColumns.fillElementNames(aVector);
77 if(m_pColumns)
78 m_pColumns->reFill(aVector);
79 else
80 m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection);
82 // -------------------------------------------------------------------------
83 Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId()
85 static ::cppu::OImplementationId * pId = 0;
86 if (! pId)
88 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
89 if (! pId)
91 static ::cppu::OImplementationId aId;
92 pId = &aId;
95 return pId->getImplementationId();
98 // com::sun::star::lang::XUnoTunnel
99 //------------------------------------------------------------------
100 sal_Int64 OAdoKey::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
102 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
103 ? reinterpret_cast< sal_Int64 >( this )
104 : OKey_ADO::getSomething(rId);
106 // -------------------------------------------------------------------------
107 void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
109 if(m_aKey.IsValid())
111 switch(nHandle)
113 case PROPERTY_ID_NAME:
115 ::rtl::OUString aVal;
116 rValue >>= aVal;
117 m_aKey.put_Name(aVal);
118 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
120 break;
121 case PROPERTY_ID_TYPE:
123 sal_Int32 nVal=0;
124 rValue >>= nVal;
125 m_aKey.put_Type(Map2KeyRule(nVal));
126 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
128 break;
129 case PROPERTY_ID_REFERENCEDTABLE:
131 ::rtl::OUString aVal;
132 rValue >>= aVal;
133 m_aKey.put_RelatedTable(aVal);
134 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
136 break;
137 case PROPERTY_ID_UPDATERULE:
139 sal_Int32 nVal=0;
140 rValue >>= nVal;
141 m_aKey.put_UpdateRule(Map2Rule(nVal));
142 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
144 break;
145 case PROPERTY_ID_DELETERULE:
147 sal_Int32 nVal=0;
148 rValue >>= nVal;
149 m_aKey.put_DeleteRule(Map2Rule(nVal));
150 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
152 break;
155 OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
157 // -------------------------------------------------------------------------
158 // -----------------------------------------------------------------------------
159 void SAL_CALL OAdoKey::acquire() throw()
161 OKey_ADO::acquire();
163 // -----------------------------------------------------------------------------
164 void SAL_CALL OAdoKey::release() throw()
166 OKey_ADO::release();
168 // -----------------------------------------------------------------------------