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 rtl::Reference
<ODbaseTable
> pRet
= new ODbaseTable(this, static_cast<ODbaseConnection
*>(static_cast<OFileCatalog
&>(m_rParent
).getConnection()),
55 void ODbaseTables::impl_refresh( )
57 static_cast<ODbaseCatalog
*>(&m_rParent
)->refreshTables();
60 Reference
< XPropertySet
> ODbaseTables::createDescriptor()
62 return new ODbaseTable(this, static_cast<ODbaseConnection
*>(static_cast<OFileCatalog
&>(m_rParent
).getConnection()));
66 sdbcx::ObjectType
ODbaseTables::appendObject( const OUString
& _rForName
, const Reference
< XPropertySet
>& descriptor
)
68 auto pTable
= comphelper::getUnoTunnelImplementation
<ODbaseTable
>(descriptor
);
71 pTable
->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME
),makeAny(_rForName
));
74 if(!pTable
->CreateImpl())
83 css::uno::Any anyEx
= cppu::getCaughtException();
84 throw SQLException( ex
.Message
, nullptr, "", 0, anyEx
);
87 return createObject( _rForName
);
91 void ODbaseTables::dropObject(sal_Int32 _nPos
, const OUString
& _sElementName
)
93 Reference
< XUnoTunnel
> xTunnel
;
96 xTunnel
.set(getObject(_nPos
),UNO_QUERY
);
98 catch(const Exception
&)
100 if(ODbaseTable::Drop_Static(ODbaseTable::getEntry(static_cast<OFileCatalog
&>(m_rParent
).getConnection(),_sElementName
),false,nullptr))
106 ODbaseTable
* pTable
= reinterpret_cast< ODbaseTable
* >( xTunnel
->getSomething(ODbaseTable::getUnoTunnelId()) );
112 const OUString
sError( static_cast<OFileCatalog
&>(m_rParent
).getConnection()->getResources().getResourceStringWithSubstitution(
114 "$tablename$", _sElementName
116 ::dbtools::throwGenericSQLException( sError
, nullptr );
120 Any SAL_CALL
ODbaseTables::queryInterface( const Type
& rType
)
122 typedef sdbcx::OCollection OTables_BASE
;
123 return OTables_BASE::queryInterface(rType
);
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */