merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / adabas / BGroup.cxx
blob8dc7c2f1e3bec5cd5f2ddf74b80144bdf87f526c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BGroup.cxx,v $
10 * $Revision: 1.9 $
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_ADABAS_GROUP_HXX_
35 #include "adabas/BGroup.hxx"
36 #endif
37 #include "adabas/BUsers.hxx"
38 #include <com/sun/star/sdbc/XRow.hpp>
39 #include <com/sun/star/sdbc/XResultSet.hpp>
40 #include "adabas/BConnection.hxx"
41 #include <comphelper/types.hxx>
43 using namespace connectivity::adabas;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::beans;
46 // using namespace ::com::sun::star::sdbcx;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::container;
49 using namespace ::com::sun::star::lang;
51 // -------------------------------------------------------------------------
52 OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True)
53 ,m_pConnection(_pConnection)
55 construct();
56 TStringVector aVector;
57 m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
59 // -------------------------------------------------------------------------
60 OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection,
61 const ::rtl::OUString& _Name
62 ) : connectivity::sdbcx::OGroup(_Name,sal_True)
63 ,m_pConnection(_pConnection)
65 construct();
66 refreshUsers();
68 // -------------------------------------------------------------------------
69 void OAdabasGroup::refreshUsers()
71 if(!m_pConnection)
72 return;
74 TStringVector aVector;
75 Reference< XStatement > xStmt = m_pConnection->createStatement( );
77 ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '");
78 aSql += getName( );
79 aSql += ::rtl::OUString::createFromAscii("'");
81 Reference< XResultSet > xResult = xStmt->executeQuery(aSql);
82 if(xResult.is())
84 Reference< XRow > xRow(xResult,UNO_QUERY);
85 while(xResult->next())
86 aVector.push_back(xRow->getString(1));
87 ::comphelper::disposeComponent(xResult);
89 ::comphelper::disposeComponent(xStmt);
91 if(m_pUsers)
92 m_pUsers->reFill(aVector);
93 else
94 m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);