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 .
21 #include "ado/AGroup.hxx"
22 #include "ado/AUsers.hxx"
23 #include <cppuhelper/typeprovider.hxx>
24 #include <comphelper/sequence.hxx>
25 #include <com/sun/star/sdbc/XRow.hpp>
26 #include <com/sun/star/sdbc/XResultSet.hpp>
27 #include "ado/AConnection.hxx"
28 #include "TConnection.hxx"
30 using namespace connectivity::ado
;
31 using namespace com::sun::star::uno
;
32 using namespace com::sun::star::lang
;
33 using namespace com::sun::star::beans
;
34 using namespace com::sun::star::sdbc
;
35 using namespace com::sun::star::sdbcx
;
37 // -------------------------------------------------------------------------
38 void WpADOGroup::Create()
40 ADOGroup
* pGroup
= NULL
;
41 HRESULT hr
= CoCreateInstance(ADOS::CLSID_ADOGROUP_25
,
44 ADOS::IID_ADOGROUP_25
,
54 // -------------------------------------------------------------------------
55 OAdoGroup::OAdoGroup(OCatalog
* _pParent
,sal_Bool _bCase
, ADOGroup
* _pGroup
) : OGroup_ADO(_bCase
),m_pCatalog(_pParent
)
59 m_aGroup
= WpADOGroup(_pGroup
);
64 // -------------------------------------------------------------------------
65 OAdoGroup::OAdoGroup(OCatalog
* _pParent
,sal_Bool _bCase
, const OUString
& _Name
) : OGroup_ADO(_Name
,_bCase
),m_pCatalog(_pParent
)
69 m_aGroup
.put_Name(_Name
);
71 // -------------------------------------------------------------------------
72 void OAdoGroup::refreshUsers()
74 TStringVector aVector
;
76 WpADOUsers aUsers
= m_aGroup
.get_Users();
77 aUsers
.fillElementNames(aVector
);
80 m_pUsers
->reFill(aVector
);
82 m_pUsers
= new OUsers(m_pCatalog
,m_aMutex
,aVector
,aUsers
,isCaseSensitive());
84 //--------------------------------------------------------------------------
85 Sequence
< sal_Int8
> OAdoGroup::getUnoTunnelImplementationId()
87 static ::cppu::OImplementationId
* pId
= 0;
90 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
93 static ::cppu::OImplementationId aId
;
97 return pId
->getImplementationId();
100 // com::sun::star::lang::XUnoTunnel
101 //------------------------------------------------------------------
102 sal_Int64
OAdoGroup::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
104 return (rId
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
105 ? reinterpret_cast< sal_Int64
>( this )
106 : OGroup_ADO::getSomething(rId
);
109 // -------------------------------------------------------------------------
110 void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
,const Any
& rValue
)throw (Exception
)
112 if(m_aGroup
.IsValid())
117 case PROPERTY_ID_NAME
:
121 m_aGroup
.put_Name(aVal
);
127 // -------------------------------------------------------------------------
128 void OAdoGroup::getFastPropertyValue(Any
& rValue
,sal_Int32 nHandle
) const
130 if(m_aGroup
.IsValid())
134 case PROPERTY_ID_NAME
:
135 rValue
<<= m_aGroup
.get_Name();
140 // -------------------------------------------------------------------------
142 sal_Int32 SAL_CALL
OAdoGroup::getPrivileges( const OUString
& objName
, sal_Int32 objType
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
144 return MapRight(m_aGroup
.GetPermissions(objName
,MapObjectType(objType
)));
146 // -------------------------------------------------------------------------
147 sal_Int32 SAL_CALL
OAdoGroup::getGrantablePrivileges( const OUString
& objName
, sal_Int32 objType
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
149 RightsEnum eNum
= m_aGroup
.GetPermissions(objName
,MapObjectType(objType
));
150 if(eNum
& adRightWithGrant
)
151 return MapRight(eNum
);
154 // -------------------------------------------------------------------------
155 void SAL_CALL
OAdoGroup::grantPrivileges( const OUString
& objName
, sal_Int32 objType
, sal_Int32 objPrivileges
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
157 m_aGroup
.SetPermissions(objName
,MapObjectType(objType
),adAccessGrant
,Map2Right(objPrivileges
));
159 // -------------------------------------------------------------------------
160 void SAL_CALL
OAdoGroup::revokePrivileges( const OUString
& objName
, sal_Int32 objType
, sal_Int32 objPrivileges
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
162 m_aGroup
.SetPermissions(objName
,MapObjectType(objType
),adAccessDeny
,Map2Right(objPrivileges
));
165 // -----------------------------------------------------------------------------
166 void SAL_CALL
OAdoGroup::acquire() throw()
168 OGroup_ADO::acquire();
170 // -----------------------------------------------------------------------------
171 void SAL_CALL
OAdoGroup::release() throw()
173 OGroup_ADO::release();
175 // -----------------------------------------------------------------------------
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */