xref: /trunk/main/dbaccess/source/ui/inc/TableGrantCtrl.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_TABLEGRANTCONTROL_HXX
28 #define DBAUI_TABLEGRANTCONTROL_HXX
29 
30 #ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
31 #include <svtools/editbrowsebox.hxx>
32 #endif
33 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
34 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBCX_XAUTHORIZABLE_HPP_
37 #include <com/sun/star/sdbcx/XAuthorizable.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #endif
42 #ifndef _COMPHELPER_STLTYPES_HXX_
43 #include <comphelper/stl_types.hxx>
44 #endif
45 #ifndef _DBAUI_MODULE_DBU_HXX_
46 #include "moduledbu.hxx"
47 #endif
48 
49 class Edit;
50 namespace dbaui
51 {
52 
53 class OTableGrantControl : public ::svt::EditBrowseBox
54 {
55     typedef struct
56     {
57         sal_Int32 nRights;
58         sal_Int32 nWithGrant;
59     } TPrivileges;
60 
61     DECLARE_STL_USTRINGACCESS_MAP(TPrivileges,TTablePrivilegeMap);
62 
63     OModuleClient        m_aModuleClient;
64 
65     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xUsers;
66     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xTables;
67     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB;
68     ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable>       m_xGrantUser;
69     ::com::sun::star::uno::Sequence< ::rtl::OUString>                               m_aTableNames;
70 
71     mutable TTablePrivilegeMap  m_aPrivMap;
72     ::rtl::OUString             m_sUserName;
73     ::svt::CheckBoxControl*     m_pCheckCell;
74     Edit*                       m_pEdit;
75     long                        m_nDataPos;
76     sal_Bool                        m_bEnable;
77     sal_uLong                       m_nDeactivateEvent;
78 
79 public:
80     OTableGrantControl( Window* pParent,const ResId& _RsId);
81     virtual ~OTableGrantControl();
82     void UpdateTables();
83     void setUserName(const ::rtl::OUString _sUserName);
84     void setGrantUser(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable>& _xGrantUser);
85 
86     void setTablesSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >& _xTablesSup);
87     void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB);
88 
89     virtual void Init();
90 
91     // IAccessibleTableProvider
92     /** Creates the accessible object of a data table cell.
93         @param nRow  The row index of the cell.
94         @param nColumnId  The column ID of the cell.
95         @return  The XAccessible interface of the specified cell. */
96     virtual ::com::sun::star::uno::Reference<
97         ::com::sun::star::accessibility::XAccessible >
98     CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId );
99 
100 protected:
101     virtual void Resize();
102 
103     virtual long PreNotify(NotifyEvent& rNEvt );
104 
105     virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
106     virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
107     virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
108     virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const;
109     virtual sal_Bool SeekRow( long nRow );
110     virtual sal_Bool SaveModified();
111     virtual String GetCellText( long nRow, sal_uInt16 nColId ) const;
112 
113     virtual void CellModified();
114 
115 private:
116     DECL_LINK( AsynchActivate, void* );
117     DECL_LINK( AsynchDeactivate, void* );
118 
119     sal_Bool    isAllowed(sal_uInt16 _nColumnId,sal_Int32 _nPrivilege) const;
120     void        fillPrivilege(sal_Int32 _nRow) const;
121     TTablePrivilegeMap::const_iterator findPrivilege(sal_Int32 _nRow) const;
122 };
123 
124 }
125 
126 #endif // DBAUI_TABLEGRANTCONTROL_HXX
127