tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / drivers / evoab2 / NConnection.cxx
blob4c4d46e63fd8f082544f43b41a1f9eb897f0e7f2
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 "NConnection.hxx"
21 #include "NDatabaseMetaData.hxx"
22 #include "NCatalog.hxx"
23 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
24 #include "NPreparedStatement.hxx"
25 #include "NStatement.hxx"
26 #include <connectivity/dbexception.hxx>
27 #include <rtl/ref.hxx>
28 #include <rtl/ustring.hxx>
29 #include <sal/log.hxx>
31 using namespace connectivity::evoab;
32 using namespace dbtools;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::sdbc;
40 OEvoabConnection::OEvoabConnection(OEvoabDriver const & _rDriver)
41 : m_rDriver(_rDriver)
42 , m_eSDBCAddressType(SDBCAddress::EVO_LOCAL)
46 OEvoabConnection::~OEvoabConnection()
48 ::osl::MutexGuard aGuard( m_aMutex );
50 if(!isClosed()) {
51 acquire();
52 close();
57 // XServiceInfo
59 IMPLEMENT_SERVICE_INFO(OEvoabConnection, u"com.sun.star.sdbc.drivers.evoab.Connection"_ustr, u"com.sun.star.sdbc.Connection"_ustr)
62 void OEvoabConnection::construct(const OUString& url, const Sequence< PropertyValue >& info)
64 osl_atomic_increment( &m_refCount );
65 SAL_INFO("connectivity.evoab2", "OEvoabConnection::construct()::url = " << url );
67 OUString sPassword;
68 const char pPwd[] = "password";
70 const PropertyValue *pIter = info.getConstArray();
71 const PropertyValue *pEnd = pIter + info.getLength();
72 for(;pIter != pEnd;++pIter)
74 if(pIter->Name == pPwd)
76 pIter->Value >>= sPassword;
77 break;
81 if ( url == "sdbc:address:evolution:groupwise" )
82 setSDBCAddressType(SDBCAddress::EVO_GWISE);
83 else if ( url == "sdbc:address:evolution:ldap" )
84 setSDBCAddressType(SDBCAddress::EVO_LDAP);
85 else
86 setSDBCAddressType(SDBCAddress::EVO_LOCAL);
87 setURL(url);
88 setPassword(OUStringToOString(sPassword,RTL_TEXTENCODING_UTF8));
89 osl_atomic_decrement( &m_refCount );
93 OUString SAL_CALL OEvoabConnection::nativeSQL( const OUString& _sSql )
95 // when you need to transform SQL92 to you driver specific you can do it here
96 return _sSql;
99 Reference< XDatabaseMetaData > SAL_CALL OEvoabConnection::getMetaData( )
101 ::osl::MutexGuard aGuard( m_aMutex );
102 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
104 Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
105 if(!xMetaData.is())
107 xMetaData = new OEvoabDatabaseMetaData(this);
108 m_xMetaData = xMetaData;
111 return xMetaData;
114 css::uno::Reference< XTablesSupplier > OEvoabConnection::createCatalog()
116 ::osl::MutexGuard aGuard( m_aMutex );
117 Reference< XTablesSupplier > xTab = m_xCatalog;
118 if(!xTab.is())
120 xTab = new OEvoabCatalog(this);
121 m_xCatalog = xTab;
123 return xTab;
126 Reference< XStatement > SAL_CALL OEvoabConnection::createStatement( )
128 ::osl::MutexGuard aGuard( m_aMutex );
129 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
131 Reference< XStatement > xStmt = new OStatement(this);
132 m_aStatements.push_back(WeakReferenceHelper(xStmt));
133 return xStmt;
136 Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( const OUString& sql )
138 ::osl::MutexGuard aGuard( m_aMutex );
139 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
141 rtl::Reference<OEvoabPreparedStatement> pStmt = new OEvoabPreparedStatement( this );
142 pStmt->construct( sql );
144 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
145 return pStmt;
148 Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareCall( const OUString& /*sql*/ )
150 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::prepareCall"_ustr, *this );
151 return nullptr;
153 sal_Bool SAL_CALL OEvoabConnection::isClosed( )
155 ::osl::MutexGuard aGuard( m_aMutex );
156 return OConnection_BASE::rBHelper.bDisposed;
160 // XCloseable
161 void SAL_CALL OEvoabConnection::close( )
163 { // we just dispose us
164 ::osl::MutexGuard aGuard( m_aMutex );
165 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
167 dispose();
171 // XWarningsSupplier
172 Any SAL_CALL OEvoabConnection::getWarnings( )
174 return m_aWarnings.getWarnings();
176 void SAL_CALL OEvoabConnection::clearWarnings( )
178 m_aWarnings.clearWarnings();
182 void OEvoabConnection::disposing()
184 // we noticed that we should be destroyed in near future so we have to dispose our statements
185 ::osl::MutexGuard aGuard(m_aMutex);
186 OConnection_BASE::disposing();
189 // -------------------------------- stubbed methods ------------------------------------------------
190 void SAL_CALL OEvoabConnection::setAutoCommit( sal_Bool /*autoCommit*/ )
192 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::setAutoCommit"_ustr, *this );
194 sal_Bool SAL_CALL OEvoabConnection::getAutoCommit( )
196 return true;
198 void SAL_CALL OEvoabConnection::commit( )
201 void SAL_CALL OEvoabConnection::rollback( )
204 void SAL_CALL OEvoabConnection::setReadOnly( sal_Bool /*readOnly*/ )
206 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::setReadOnly"_ustr, *this );
208 sal_Bool SAL_CALL OEvoabConnection::isReadOnly( )
210 return false;
212 void SAL_CALL OEvoabConnection::setCatalog( const OUString& /*catalog*/ )
214 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::setCatalog"_ustr, *this );
217 OUString SAL_CALL OEvoabConnection::getCatalog( )
219 return OUString();
221 void SAL_CALL OEvoabConnection::setTransactionIsolation( sal_Int32 /*level*/ )
223 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::setTransactionIsolation"_ustr, *this );
226 sal_Int32 SAL_CALL OEvoabConnection::getTransactionIsolation( )
228 return TransactionIsolation::NONE;
231 Reference< css::container::XNameAccess > SAL_CALL OEvoabConnection::getTypeMap( )
233 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::getTypeMap"_ustr, *this );
234 return nullptr;
236 void SAL_CALL OEvoabConnection::setTypeMap( const Reference< css::container::XNameAccess >& /*typeMap*/ )
238 ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::setTypeMap"_ustr, *this );
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */