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: AKey.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/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
)
51 ,m_pConnection(_pConnection
)
54 m_aKey
= WpADOKey(_pKey
);
57 // -------------------------------------------------------------------------
58 OAdoKey::OAdoKey(sal_Bool _bCase
,OConnection
* _pConnection
)
60 ,m_pConnection(_pConnection
)
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
);
78 m_pColumns
->reFill(aVector
);
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;
88 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
91 static ::cppu::OImplementationId 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
)
113 case PROPERTY_ID_NAME
:
115 ::rtl::OUString aVal
;
117 m_aKey
.put_Name(aVal
);
118 ADOS::ThrowException(*m_pConnection
->getConnection(),*this);
121 case PROPERTY_ID_TYPE
:
125 m_aKey
.put_Type(Map2KeyRule(nVal
));
126 ADOS::ThrowException(*m_pConnection
->getConnection(),*this);
129 case PROPERTY_ID_REFERENCEDTABLE
:
131 ::rtl::OUString aVal
;
133 m_aKey
.put_RelatedTable(aVal
);
134 ADOS::ThrowException(*m_pConnection
->getConnection(),*this);
137 case PROPERTY_ID_UPDATERULE
:
141 m_aKey
.put_UpdateRule(Map2Rule(nVal
));
142 ADOS::ThrowException(*m_pConnection
->getConnection(),*this);
145 case PROPERTY_ID_DELETERULE
:
149 m_aKey
.put_DeleteRule(Map2Rule(nVal
));
150 ADOS::ThrowException(*m_pConnection
->getConnection(),*this);
155 OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle
,rValue
);
157 // -------------------------------------------------------------------------
158 // -----------------------------------------------------------------------------
159 void SAL_CALL
OAdoKey::acquire() throw()
163 // -----------------------------------------------------------------------------
164 void SAL_CALL
OAdoKey::release() throw()
168 // -----------------------------------------------------------------------------