1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "ado/AGroup.hxx"
31 #include "ado/AUsers.hxx"
32 #include <cppuhelper/typeprovider.hxx>
33 #include <comphelper/sequence.hxx>
34 #include <com/sun/star/sdbc/XRow.hpp>
35 #include <com/sun/star/sdbc/XResultSet.hpp>
36 #include "ado/AConnection.hxx"
37 #include "TConnection.hxx"
39 using namespace connectivity::ado
;
40 using namespace com::sun::star::uno
;
41 using namespace com::sun::star::lang
;
42 using namespace com::sun::star::beans
;
43 using namespace com::sun::star::sdbc
;
44 using namespace com::sun::star::sdbcx
;
46 // -------------------------------------------------------------------------
47 void WpADOGroup::Create()
50 ADOGroup
* pGroup
= NULL
;
51 hr
= CoCreateInstance(ADOS::CLSID_ADOGROUP_25
,
54 ADOS::IID_ADOGROUP_25
,
64 // -------------------------------------------------------------------------
65 OAdoGroup::OAdoGroup(OCatalog
* _pParent
,sal_Bool _bCase
, ADOGroup
* _pGroup
) : OGroup_ADO(_bCase
),m_pCatalog(_pParent
)
69 m_aGroup
= WpADOGroup(_pGroup
);
74 // -------------------------------------------------------------------------
75 OAdoGroup::OAdoGroup(OCatalog
* _pParent
,sal_Bool _bCase
, const ::rtl::OUString
& _Name
) : OGroup_ADO(_Name
,_bCase
),m_pCatalog(_pParent
)
79 m_aGroup
.put_Name(_Name
);
81 // -------------------------------------------------------------------------
82 void OAdoGroup::refreshUsers()
84 TStringVector aVector
;
86 WpADOUsers aUsers
= m_aGroup
.get_Users();
87 aUsers
.fillElementNames(aVector
);
90 m_pUsers
->reFill(aVector
);
92 m_pUsers
= new OUsers(m_pCatalog
,m_aMutex
,aVector
,aUsers
,isCaseSensitive());
94 //--------------------------------------------------------------------------
95 Sequence
< sal_Int8
> OAdoGroup::getUnoTunnelImplementationId()
97 static ::cppu::OImplementationId
* pId
= 0;
100 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
103 static ::cppu::OImplementationId aId
;
107 return pId
->getImplementationId();
110 // com::sun::star::lang::XUnoTunnel
111 //------------------------------------------------------------------
112 sal_Int64
OAdoGroup::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
114 return (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
115 ? reinterpret_cast< sal_Int64
>( this )
116 : OGroup_ADO::getSomething(rId
);
119 // -------------------------------------------------------------------------
120 void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
,const Any
& rValue
)throw (Exception
)
122 if(m_aGroup
.IsValid())
127 case PROPERTY_ID_NAME
:
129 ::rtl::OUString aVal
;
131 m_aGroup
.put_Name(aVal
);
137 // -------------------------------------------------------------------------
138 void OAdoGroup::getFastPropertyValue(Any
& rValue
,sal_Int32 nHandle
) const
140 if(m_aGroup
.IsValid())
144 case PROPERTY_ID_NAME
:
145 rValue
<<= m_aGroup
.get_Name();
150 // -------------------------------------------------------------------------
152 sal_Int32 SAL_CALL
OAdoGroup::getPrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
154 return MapRight(m_aGroup
.GetPermissions(objName
,MapObjectType(objType
)));
156 // -------------------------------------------------------------------------
157 sal_Int32 SAL_CALL
OAdoGroup::getGrantablePrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
159 RightsEnum eNum
= m_aGroup
.GetPermissions(objName
,MapObjectType(objType
));
160 if(eNum
& adRightWithGrant
)
161 return MapRight(eNum
);
164 // -------------------------------------------------------------------------
165 void SAL_CALL
OAdoGroup::grantPrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
, sal_Int32 objPrivileges
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
167 m_aGroup
.SetPermissions(objName
,MapObjectType(objType
),adAccessGrant
,Map2Right(objPrivileges
));
169 // -------------------------------------------------------------------------
170 void SAL_CALL
OAdoGroup::revokePrivileges( const ::rtl::OUString
& objName
, sal_Int32 objType
, sal_Int32 objPrivileges
) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
172 m_aGroup
.SetPermissions(objName
,MapObjectType(objType
),adAccessDeny
,Map2Right(objPrivileges
));
175 // -----------------------------------------------------------------------------
176 void SAL_CALL
OAdoGroup::acquire() throw()
178 OGroup_ADO::acquire();
180 // -----------------------------------------------------------------------------
181 void SAL_CALL
OAdoGroup::release() throw()
183 OGroup_ADO::release();
185 // -----------------------------------------------------------------------------
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */