1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AGroup.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #ifndef _CONNECTIVITY_ADO_GROUP_HXX_
35 #include "ado/AGroup.hxx"
37 #include "ado/AUsers.hxx"
38 #include <cppuhelper/typeprovider.hxx>
39 #include <comphelper/sequence.hxx>
40 #include <com/sun/star/sdbc/XRow.hpp>
41 #include <com/sun/star/sdbc/XResultSet.hpp>
42 #ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_
43 #include "ado/AConnection.hxx"
45 #include "TConnection.hxx"
47 using namespace connectivity::ado
;
48 using namespace com::sun::star::uno
;
49 using namespace com::sun::star::lang
;
50 using namespace com::sun::star::beans
;
51 using namespace com::sun::star::sdbc
;
52 using namespace com::sun::star::sdbcx
;
54 // -------------------------------------------------------------------------
55 void WpADOGroup::Create()
58 ADOGroup
* pGroup
= NULL
;
59 hr
= CoCreateInstance(ADOS::CLSID_ADOGROUP_25
,
62 ADOS::IID_ADOGROUP_25
,
72 // -------------------------------------------------------------------------
73 OAdoGroup::OAdoGroup(OCatalog
* _pParent
,sal_Bool _bCase
, ADOGroup
* _pGroup
) : OGroup_ADO(_bCase
),m_pCatalog(_pParent
)
77 m_aGroup
= WpADOGroup(_pGroup
);
82 // -------------------------------------------------------------------------
83 OAdoGroup::OAdoGroup(OCatalog
* _pParent
,sal_Bool _bCase
, const ::rtl::OUString
& _Name
) : OGroup_ADO(_Name
,_bCase
),m_pCatalog(_pParent
)
87 m_aGroup
.put_Name(_Name
);
89 // -------------------------------------------------------------------------
90 void OAdoGroup::refreshUsers()
92 TStringVector aVector
;
94 WpADOUsers aUsers
= m_aGroup
.get_Users();
95 aUsers
.fillElementNames(aVector
);
98 m_pUsers
->reFill(aVector
);
100 m_pUsers
= new OUsers(m_pCatalog
,m_aMutex
,aVector
,aUsers
,isCaseSensitive());
102 //--------------------------------------------------------------------------
103 Sequence
< sal_Int8
> OAdoGroup::getUnoTunnelImplementationId()
105 static ::cppu::OImplementationId
* pId
= 0;
108 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
111 static ::cppu::OImplementationId aId
;
115 return pId
->getImplementationId();
118 // com::sun::star::lang::XUnoTunnel
119 //------------------------------------------------------------------
120 sal_Int64
OAdoGroup::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
122 return (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
123 ? reinterpret_cast< sal_Int64
>( this )
124 : OGroup_ADO::getSomething(rId
);
127 // -------------------------------------------------------------------------
128 void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
,const Any
& rValue
)throw (Exception
)
130 if(m_aGroup
.IsValid())
135 case PROPERTY_ID_NAME
:
137 ::rtl::OUString aVal
;
139 m_aGroup
.put_Name(aVal
);
145 // -------------------------------------------------------------------------
146 void OAdoGroup::getFastPropertyValue(Any
& rValue
,sal_Int32 nHandle
) const
148 if(m_aGroup
.IsValid())
152 case PROPERTY_ID_NAME
:
153 rValue
<<= m_aGroup
.get_Name();
158 // -------------------------------------------------------------------------
160 sal_Int32 SAL_CALL
OAdoGroup::getPrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
162 return MapRight(m_aGroup
.GetPermissions(objName
,MapObjectType(objType
)));
164 // -------------------------------------------------------------------------
165 sal_Int32 SAL_CALL
OAdoGroup::getGrantablePrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
167 RightsEnum eNum
= m_aGroup
.GetPermissions(objName
,MapObjectType(objType
));
168 if(eNum
& adRightWithGrant
)
169 return MapRight(eNum
);
172 // -------------------------------------------------------------------------
173 void SAL_CALL
OAdoGroup::grantPrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
, sal_Int32 objPrivileges
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
175 m_aGroup
.SetPermissions(objName
,MapObjectType(objType
),adAccessGrant
,Map2Right(objPrivileges
));
177 // -------------------------------------------------------------------------
178 void SAL_CALL
OAdoGroup::revokePrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
, sal_Int32 objPrivileges
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
180 m_aGroup
.SetPermissions(objName
,MapObjectType(objType
),adAccessDeny
,Map2Right(objPrivileges
));
183 // -----------------------------------------------------------------------------
184 void SAL_CALL
OAdoGroup::acquire() throw()
186 OGroup_ADO::acquire();
188 // -----------------------------------------------------------------------------
189 void SAL_CALL
OAdoGroup::release() throw()
191 OGroup_ADO::release();
193 // -----------------------------------------------------------------------------