Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / AKey.cxx
blobd76bf93823b8cb02cbe0d8d1346dc05a0826e184
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ado/AKey.hxx"
21 #include <com/sun/star/sdbc/XRow.hpp>
22 #include <com/sun/star/sdbc/XResultSet.hpp>
23 #include <cppuhelper/typeprovider.hxx>
24 #include <comphelper/sequence.hxx>
25 #include "ado/AColumns.hxx"
26 #include "ado/AConnection.hxx"
28 using namespace connectivity::ado;
29 using namespace com::sun::star::uno;
30 using namespace com::sun::star::lang;
31 using namespace com::sun::star::beans;
32 using namespace com::sun::star::sdbc;
33 using namespace com::sun::star::sdbcx;
36 OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection, ADOKey* _pKey)
37 : OKey_ADO(_bCase)
38 ,m_pConnection(_pConnection)
40 construct();
41 m_aKey = WpADOKey(_pKey);
42 fillPropertyValues();
45 OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection)
46 : OKey_ADO(_bCase)
47 ,m_pConnection(_pConnection)
49 construct();
50 m_aKey.Create();
53 void OAdoKey::refreshColumns()
55 TStringVector aVector;
57 WpADOColumns aColumns;
58 if ( m_aKey.IsValid() )
60 aColumns = m_aKey.get_Columns();
61 aColumns.fillElementNames(aVector);
64 if(m_pColumns)
65 m_pColumns->reFill(aVector);
66 else
67 m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection);
70 Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId()
72 static ::cppu::OImplementationId * pId = 0;
73 if (! pId)
75 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
76 if (! pId)
78 static ::cppu::OImplementationId aId;
79 pId = &aId;
82 return pId->getImplementationId();
85 // com::sun::star::lang::XUnoTunnel
87 sal_Int64 OAdoKey::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
89 return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
90 ? reinterpret_cast< sal_Int64 >( this )
91 : OKey_ADO::getSomething(rId);
94 void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
96 if(m_aKey.IsValid())
98 switch(nHandle)
100 case PROPERTY_ID_NAME:
102 OUString aVal;
103 rValue >>= aVal;
104 m_aKey.put_Name(aVal);
105 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
107 break;
108 case PROPERTY_ID_TYPE:
110 sal_Int32 nVal=0;
111 rValue >>= nVal;
112 m_aKey.put_Type(Map2KeyRule(nVal));
113 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
115 break;
116 case PROPERTY_ID_REFERENCEDTABLE:
118 OUString aVal;
119 rValue >>= aVal;
120 m_aKey.put_RelatedTable(aVal);
121 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
123 break;
124 case PROPERTY_ID_UPDATERULE:
126 sal_Int32 nVal=0;
127 rValue >>= nVal;
128 m_aKey.put_UpdateRule(Map2Rule(nVal));
129 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
131 break;
132 case PROPERTY_ID_DELETERULE:
134 sal_Int32 nVal=0;
135 rValue >>= nVal;
136 m_aKey.put_DeleteRule(Map2Rule(nVal));
137 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
139 break;
142 OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
146 void SAL_CALL OAdoKey::acquire() throw()
148 OKey_ADO::acquire();
151 void SAL_CALL OAdoKey::release() throw()
153 OKey_ADO::release();
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */