nss: upgrade to release 3.73
[LibreOffice.git] / connectivity / source / drivers / dbase / DTables.cxx
blob1d922969493f7aab79d530a943a659afccf1e057
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 <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()),
49 _rName,"TABLE");
51 sdbcx::ObjectType xRet = pRet;
52 pRet->construct();
53 return xRet;
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()));
66 // XAppend
67 sdbcx::ObjectType ODbaseTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
69 auto pTable = comphelper::getUnoTunnelImplementation<ODbaseTable>(descriptor);
70 if(pTable)
72 pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName));
73 try
75 if(!pTable->CreateImpl())
76 throw SQLException();
78 catch(SQLException&)
80 throw;
82 catch(Exception& ex)
84 css::uno::Any anyEx = cppu::getCaughtException();
85 throw SQLException( ex.Message, nullptr, "", 0, anyEx );
88 return createObject( _rForName );
91 // XDrop
92 void ODbaseTables::dropObject(sal_Int32 _nPos, const OUString& _sElementName)
94 Reference< XUnoTunnel> xTunnel;
95 try
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))
102 return;
105 if ( xTunnel.is() )
107 ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelId()) );
108 if(pTable)
109 pTable->DropImpl();
111 else
113 const OUString sError( static_cast<OFileCatalog&>(m_rParent).getConnection()->getResources().getResourceStringWithSubstitution(
114 STR_TABLE_NOT_DROP,
115 "$tablename$", _sElementName
116 ) );
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: */