1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sal/config.h>
22 #include <dbase/DConnection.hxx>
23 #include <dbase/DTables.hxx>
24 #include <dbase/DTable.hxx>
25 #include <com/sun/star/sdbc/SQLException.hpp>
26 #include <file/FCatalog.hxx>
27 #include <file/FConnection.hxx>
28 #include <com/sun/star/lang/XUnoTunnel.hpp>
29 #include <dbase/DCatalog.hxx>
30 #include <comphelper/servicehelper.hxx>
31 #include <cppuhelper/exc_hlp.hxx>
32 #include <strings.hrc>
33 #include <connectivity/dbexception.hxx>
35 using namespace ::comphelper
;
36 using namespace connectivity
;
37 using namespace connectivity::dbase
;
38 using namespace connectivity::file
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::beans
;
41 using namespace ::com::sun::star::sdbcx
;
42 using namespace ::com::sun::star::sdbc
;
43 using namespace ::com::sun::star::lang
;
44 using namespace ::com::sun::star::container
;
46 sdbcx::ObjectType
ODbaseTables::createObject(const OUString
& _rName
)
48 ODbaseTable
* pRet
= new ODbaseTable(this, static_cast<ODbaseConnection
*>(static_cast<OFileCatalog
&>(m_rParent
).getConnection()),
51 sdbcx::ObjectType xRet
= pRet
;
56 void ODbaseTables::impl_refresh( )
58 static_cast<ODbaseCatalog
*>(&m_rParent
)->refreshTables();
61 Reference
< XPropertySet
> ODbaseTables::createDescriptor()
63 return new ODbaseTable(this, static_cast<ODbaseConnection
*>(static_cast<OFileCatalog
&>(m_rParent
).getConnection()));
67 sdbcx::ObjectType
ODbaseTables::appendObject( const OUString
& _rForName
, const Reference
< XPropertySet
>& descriptor
)
69 auto pTable
= comphelper::getUnoTunnelImplementation
<ODbaseTable
>(descriptor
);
72 pTable
->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME
),makeAny(_rForName
));
75 if(!pTable
->CreateImpl())
84 css::uno::Any anyEx
= cppu::getCaughtException();
85 throw SQLException( ex
.Message
, nullptr, "", 0, anyEx
);
88 return createObject( _rForName
);
92 void ODbaseTables::dropObject(sal_Int32 _nPos
, const OUString
& _sElementName
)
94 Reference
< XUnoTunnel
> xTunnel
;
97 xTunnel
.set(getObject(_nPos
),UNO_QUERY
);
99 catch(const Exception
&)
101 if(ODbaseTable::Drop_Static(ODbaseTable::getEntry(static_cast<OFileCatalog
&>(m_rParent
).getConnection(),_sElementName
),false,nullptr))
107 ODbaseTable
* pTable
= reinterpret_cast< ODbaseTable
* >( xTunnel
->getSomething(ODbaseTable::getUnoTunnelId()) );
113 const OUString
sError( static_cast<OFileCatalog
&>(m_rParent
).getConnection()->getResources().getResourceStringWithSubstitution(
115 "$tablename$", _sElementName
117 ::dbtools::throwGenericSQLException( sError
, nullptr );
121 Any SAL_CALL
ODbaseTables::queryInterface( const Type
& rType
)
123 typedef sdbcx::OCollection OTables_BASE
;
124 return OTables_BASE::queryInterface(rType
);
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */