Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / ATables.cxx
blobcdd7df2775c303cd5a0935ef06207ff9adc81878
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/ATables.hxx"
21 #include "ado/ATable.hxx"
22 #include <com/sun/star/sdbc/XRow.hpp>
23 #include <com/sun/star/sdbc/XResultSet.hpp>
24 #include <com/sun/star/sdbc/ColumnValue.hpp>
25 #include <com/sun/star/sdbc/KeyRule.hpp>
26 #include <com/sun/star/sdbcx/KeyType.hpp>
27 #include "ado/ACatalog.hxx"
28 #include "ado/AConnection.hxx"
29 #include "ado/Awrapado.hxx"
30 #include "TConnection.hxx"
31 #include <comphelper/types.hxx>
32 #include <cppuhelper/interfacecontainer.h>
33 #include <connectivity/dbexception.hxx>
34 #include "resource/ado_res.hrc"
36 using namespace ::cppu;
37 using namespace connectivity;
38 using namespace comphelper;
39 using namespace connectivity::ado;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::lang;
42 using namespace com::sun::star::beans;
43 using namespace com::sun::star::sdbc;
44 using namespace com::sun::star::container;
46 sdbcx::ObjectType OTables::createObject(const OUString& _rName)
48 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
49 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,m_aCollection.GetItem(_rName));
52 void OTables::impl_refresh( ) throw(RuntimeException)
54 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
55 m_aCollection.Refresh();
56 m_pCatalog->refreshTables();
59 Reference< XPropertySet > OTables::createDescriptor()
61 return new OAdoTable(this,isCaseSensitive(),m_pCatalog);
64 // XAppend
65 sdbcx::ObjectType OTables::appendObject( const OUString&, const Reference< XPropertySet >& descriptor )
67 OAdoTable* pTable = NULL;
68 if ( !getImplementation( pTable, descriptor ) || pTable == NULL )
69 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_TABLE_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
71 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
72 if(!m_aCollection.Append(pTable->getImpl()))
73 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
74 m_aCollection.Refresh();
76 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable->getImpl());
79 // XDrop
80 void OTables::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
82 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
83 if ( !m_aCollection.Delete(_sElementName) )
84 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
87 void OTables::appendNew(const OUString& _rsNewTable)
89 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
90 m_aCollection.Refresh();
92 insertElement(_rsNewTable,NULL);
94 // notify our container listeners
95 ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
96 OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
97 while (aListenerLoop.hasMoreElements())
98 static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */