1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef DBAUI_TABLEGRANTCONTROL_HXX 24 #define DBAUI_TABLEGRANTCONTROL_HXX 25 26 #ifndef _SVTOOLS_EDITBROWSEBOX_HXX_ 27 #include <svtools/editbrowsebox.hxx> 28 #endif 29 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 30 #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 31 #endif 32 #ifndef _COM_SUN_STAR_SDBCX_XAUTHORIZABLE_HPP_ 33 #include <com/sun/star/sdbcx/XAuthorizable.hpp> 34 #endif 35 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ 36 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37 #endif 38 #ifndef _COMPHELPER_STLTYPES_HXX_ 39 #include <comphelper/stl_types.hxx> 40 #endif 41 #ifndef _DBAUI_MODULE_DBU_HXX_ 42 #include "moduledbu.hxx" 43 #endif 44 45 class Edit; 46 namespace dbaui 47 { 48 49 class OTableGrantControl : public ::svt::EditBrowseBox 50 { 51 typedef struct 52 { 53 sal_Int32 nRights; 54 sal_Int32 nWithGrant; 55 } TPrivileges; 56 57 DECLARE_STL_USTRINGACCESS_MAP(TPrivileges,TTablePrivilegeMap); 58 59 OModuleClient m_aModuleClient; 60 61 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers; 62 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xTables; 63 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB; 64 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable> m_xGrantUser; 65 ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aTableNames; 66 67 mutable TTablePrivilegeMap m_aPrivMap; 68 ::rtl::OUString m_sUserName; 69 ::svt::CheckBoxControl* m_pCheckCell; 70 Edit* m_pEdit; 71 long m_nDataPos; 72 sal_Bool m_bEnable; 73 sal_uLong m_nDeactivateEvent; 74 75 public: 76 OTableGrantControl( Window* pParent,const ResId& _RsId); 77 virtual ~OTableGrantControl(); 78 void UpdateTables(); 79 void setUserName(const ::rtl::OUString _sUserName); 80 void setGrantUser(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable>& _xGrantUser); 81 82 void setTablesSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >& _xTablesSup); 83 void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB); 84 85 virtual void Init(); 86 87 // IAccessibleTableProvider 88 /** Creates the accessible object of a data table cell. 89 @param nRow The row index of the cell. 90 @param nColumnId The column ID of the cell. 91 @return The XAccessible interface of the specified cell. */ 92 virtual ::com::sun::star::uno::Reference< 93 ::com::sun::star::accessibility::XAccessible > 94 CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId ); 95 96 protected: 97 virtual void Resize(); 98 99 virtual long PreNotify(NotifyEvent& rNEvt ); 100 101 virtual sal_Bool IsTabAllowed(sal_Bool bForward) const; 102 virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ); 103 virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol ); 104 virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const; 105 virtual sal_Bool SeekRow( long nRow ); 106 virtual sal_Bool SaveModified(); 107 virtual String GetCellText( long nRow, sal_uInt16 nColId ) const; 108 109 virtual void CellModified(); 110 111 private: 112 DECL_LINK( AsynchActivate, void* ); 113 DECL_LINK( AsynchDeactivate, void* ); 114 115 sal_Bool isAllowed(sal_uInt16 _nColumnId,sal_Int32 _nPrivilege) const; 116 void fillPrivilege(sal_Int32 _nRow) const; 117 TTablePrivilegeMap::const_iterator findPrivilege(sal_Int32 _nRow) const; 118 }; 119 120 } 121 122 #endif // DBAUI_TABLEGRANTCONTROL_HXX 123