LibreOffice Module connectivity (master) 1
AGroup.cxx
Go to the documentation of this file.
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
21#include <ado/AGroup.hxx>
22#include <ado/AUsers.hxx>
24#include <com/sun/star/sdbc/XRow.hpp>
25#include <com/sun/star/sdbc/XResultSet.hpp>
26#include <ado/AConnection.hxx>
27#include <TConnection.hxx>
28
29using namespace connectivity::ado;
30using namespace com::sun::star::uno;
31using namespace com::sun::star::lang;
32using namespace com::sun::star::beans;
33using namespace com::sun::star::sdbc;
34using namespace com::sun::star::sdbcx;
35
36
37void WpADOGroup::Create()
38{
39 pInterface.CoCreateInstance(ADOS::CLSID_ADOGROUP_25, nullptr, CLSCTX_INPROC_SERVER);
40}
41
42OAdoGroup::OAdoGroup(OCatalog* _pParent,bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent)
43{
44 construct();
45 if(_pGroup)
46 m_aGroup.set(_pGroup);
47 else
49
50}
51
52OAdoGroup::OAdoGroup(OCatalog* _pParent,bool _bCase, const OUString& Name) : OGroup_ADO(Name,_bCase),m_pCatalog(_pParent)
53{
54 construct();
57}
58
60{
61 ::std::vector< OUString> aVector;
62
63 WpADOUsers aUsers = m_aGroup.get_Users();
64 aUsers.fillElementNames(aVector);
65
66 if(m_pUsers)
67 m_pUsers->reFill(aVector);
68 else
69 m_pUsers.reset(new OUsers(m_pCatalog, m_aMutex, aVector, aUsers, isCaseSensitive()));
70}
71
72void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
73{
74 if(m_aGroup.IsValid())
75 {
76
77 switch(nHandle)
78 {
80 {
81 OUString aVal;
82 rValue >>= aVal;
83 m_aGroup.put_Name(aVal);
84 }
85 break;
86 }
87 }
88}
89
90void OAdoGroup::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
91{
92 if(m_aGroup.IsValid())
93 {
94 switch(nHandle)
95 {
97 rValue <<= m_aGroup.get_Name();
98 break;
99 }
100 }
101}
102
103
104sal_Int32 SAL_CALL OAdoGroup::getPrivileges( const OUString& objName, sal_Int32 objType )
105{
106 return MapRight(m_aGroup.GetPermissions(objName,MapObjectType(objType)));
107}
108
109sal_Int32 SAL_CALL OAdoGroup::getGrantablePrivileges( const OUString& objName, sal_Int32 objType )
110{
111 RightsEnum eNum = m_aGroup.GetPermissions(objName,MapObjectType(objType));
112 if(eNum & adRightWithGrant)
113 return MapRight(eNum);
114 return 0;
115}
116
117void SAL_CALL OAdoGroup::grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
118{
119 m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessGrant,Map2Right(objPrivileges));
120}
121
122void SAL_CALL OAdoGroup::revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
123{
124 m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessDeny,Map2Right(objPrivileges));
125}
126
127/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const CLSID CLSID_ADOGROUP_25
Definition: adoimp.hxx:63
OAdoGroup(OCatalog *_pParent, bool _bCase, ADOGroup *_pGroup=nullptr)
Definition: AGroup.cxx:42
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: AGroup.cxx:72
static RightsEnum Map2Right(sal_Int32 _eNum)
virtual void SAL_CALL grantPrivileges(const OUString &objName, sal_Int32 objType, sal_Int32 objPrivileges) override
Definition: AGroup.cxx:117
static sal_Int32 MapRight(RightsEnum _eNum)
virtual sal_Int32 SAL_CALL getGrantablePrivileges(const OUString &objName, sal_Int32 objType) override
Definition: AGroup.cxx:109
virtual void SAL_CALL revokePrivileges(const OUString &objName, sal_Int32 objType, sal_Int32 objPrivileges) override
Definition: AGroup.cxx:122
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: AGroup.cxx:90
virtual sal_Int32 SAL_CALL getPrivileges(const OUString &objName, sal_Int32 objType) override
Definition: AGroup.cxx:104
static ObjectTypeEnum MapObjectType(sal_Int32 ObjType)
virtual void refreshUsers() override
Definition: AGroup.cxx:59
void put_Name(std::u16string_view _rName)
Definition: Awrapado.cxx:1373
RightsEnum GetPermissions(const OLEVariant &Name, ObjectTypeEnum ObjectType)
Definition: Awrapado.cxx:1379
bool SetPermissions(const OLEVariant &Name, ObjectTypeEnum ObjectType, ActionEnum Action, RightsEnum Rights)
Definition: Awrapado.cxx:1390
sal::systools::COMReference< ADOGroup > pInterface
Definition: Aolewrap.hxx:44
void fillElementNames(::std::vector< OUString > &_rVector)
Definition: Aolewrap.hxx:129
std::unique_ptr< OUsers > m_pUsers
Definition: VGroup.hxx:52
mutable::osl::Mutex m_aMutex
OCollection OUsers
Definition: VGroup.hxx:36
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
sal_Int32 nHandle
OUString Name