LibreOffice Module connectivity (master) 1
ATables.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
32#include <comphelper/types.hxx>
35#include <strings.hrc>
36
37using namespace ::cppu;
38using namespace connectivity;
39using namespace comphelper;
40using namespace connectivity::ado;
41using namespace com::sun::star::uno;
42using namespace com::sun::star::lang;
43using namespace com::sun::star::beans;
44using namespace com::sun::star::sdbc;
45using namespace com::sun::star::container;
46
47sdbcx::ObjectType OTables::createObject(const OUString& _rName)
48{
49 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
50 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,m_aCollection.GetItem(_rName));
51}
52
54{
55 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
58}
59
61{
62 return new OAdoTable(this,isCaseSensitive(),m_pCatalog);
63}
64
65// XAppend
66sdbcx::ObjectType OTables::appendObject( const OUString&, const Reference< XPropertySet >& descriptor )
67{
68 OAdoTable* pTable = dynamic_cast<OAdoTable*>( descriptor.get() );
69 if ( pTable == nullptr )
70 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_TABLE_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
71
72 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
73 if(!m_aCollection.Append(pTable->getImpl()))
74 ADOS::ThrowException(m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
76
77 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable->getImpl());
78}
79
80// XDrop
81void OTables::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
82{
83 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
84 if ( !m_aCollection.Delete(_sElementName) )
85 ADOS::ThrowException(m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
86}
87
88void OTables::appendNew(const OUString& _rsNewTable)
89{
90 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
92
93 insertElement(_rsNewTable,nullptr);
94
95 // notify our container listeners
96 ContainerEvent aEvent(static_cast<XContainer*>(this), Any(_rsNewTable), Any(), Any());
98 while (aListenerLoop.hasMoreElements())
99 aListenerLoop.next()->elementInserted(aEvent);
100}
101
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
css::uno::Reference< ListenerT > const & next()
void throwGenericSQLException(TranslateId pErrorResourceId, const css::uno::Reference< css::uno::XInterface > &_xContext)
Definition: TConnection.cxx:74
static void ThrowException(ADOConnection *_pAdoCon, const css::uno::Reference< css::uno::XInterface > &_xInterface)
Definition: ADriver.cxx:207
WpADOTable getImpl() const
Definition: ATable.hxx:64
virtual void refreshTables() override
Definition: ACatalog.cxx:46
OConnection * getConnection() const
Definition: ACatalog.hxx:43
WpADOConnection & getConnection()
virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override
Definition: ATables.cxx:60
virtual sdbcx::ObjectType appendObject(const OUString &_rForName, const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
appends an object described by a descriptor, under a given name
virtual void impl_refresh() override
Definition: ATables.cxx:53
virtual void dropObject(sal_Int32 _nPos, const OUString &_sElementName) override
Definition: ATables.cxx:81
void appendNew(const OUString &_rsNewTable)
Definition: ATables.cxx:88
WpADOTables m_aCollection
Definition: ATables.hxx:30
bool Append(const WrapT &aWrapT)
Definition: Aolewrap.hxx:160
bool Delete(const OUString &sName)
Definition: Aolewrap.hxx:165
WrapT GetItem(sal_Int32 index) const
Definition: Aolewrap.hxx:102
void insertElement(const OUString &_sElementName, const ObjectType &_xElement)
insert a new element into the collection
::comphelper::OInterfaceContainerHelper3< css::container::XContainerListener > m_aContainerListeners
Definition: VCollection.hxx:93
css::uno::Reference< css::beans::XPropertySet > ObjectType
Definition: VCollection.hxx:59