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/AUsers.hxx>
21 #include <ado/AUser.hxx>
22 #include <ado/ATable.hxx>
23 #include <ado/AConnection.hxx>
24 #include <com/sun/star/sdbc/XRow.hpp>
25 #include <com/sun/star/sdbc/XResultSet.hpp>
26 #include <connectivity/sdbcx/IRefreshable.hxx>
27 #include <comphelper/servicehelper.hxx>
28 #include <comphelper/types.hxx>
29 #include <connectivity/dbexception.hxx>
30 #include <strings.hrc>
31
32 using namespace comphelper;
33 using namespace connectivity;
34 using namespace connectivity::ado;
35 using namespace com::sun::star::uno;
36 using namespace com::sun::star::lang;
37 using namespace com::sun::star::beans;
38 using namespace com::sun::star::sdbc;
39 using namespace com::sun::star::container;
40
createObject(const OUString & _rName)41 sdbcx::ObjectType OUsers::createObject(const OUString& _rName)
42 {
43 return new OAdoUser(m_pCatalog,isCaseSensitive(),_rName);
44 }
45
impl_refresh()46 void OUsers::impl_refresh()
47 {
48 m_aCollection.Refresh();
49 }
50
createDescriptor()51 Reference< XPropertySet > OUsers::createDescriptor()
52 {
53 return new OUserExtend(m_pCatalog,isCaseSensitive());
54 }
55
56 // XAppend
appendObject(const OUString & _rForName,const Reference<XPropertySet> & descriptor)57 sdbcx::ObjectType OUsers::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
58 {
59 OUserExtend* pUser = getUnoTunnelImplementation<OUserExtend>( descriptor );
60 if ( pUser == nullptr )
61 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_USER_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
62
63 ADOUsers* pUsers = m_aCollection;
64 pUsers->Append(OLEVariant(pUser->getImpl()),OLEString(pUser->getPassword()).asBSTR());
65
66 return createObject( _rForName );
67 }
68
69 // XDrop
dropObject(sal_Int32,const OUString & _sElementName)70 void OUsers::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
71 {
72 m_aCollection.Delete(_sElementName);
73 }
74
75
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
77