Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / dbaccess / source / ui / inc / TableGrantCtrl.hxx
blob74a9fd8b5875e531809d4a520f04b9b664a83e5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #pragma once
21 #include <sal/config.h>
23 #include <map>
25 #include <svtools/editbrowsebox.hxx>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
28 #include <com/sun/star/sdbcx/XAuthorizable.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 class Edit;
32 namespace dbaui
35 class OTableGrantControl : public ::svt::EditBrowseBox
37 typedef struct
39 sal_Int32 nRights;
40 sal_Int32 nWithGrant;
41 } TPrivileges;
43 typedef std::map<OUString, TPrivileges> TTablePrivilegeMap;
45 css::uno::Reference< css::container::XNameAccess > m_xUsers;
46 css::uno::Reference< css::container::XNameAccess > m_xTables;
47 css::uno::Reference< css::uno::XComponentContext> m_xContext;
48 css::uno::Reference< css::sdbcx::XAuthorizable> m_xGrantUser;
49 css::uno::Sequence< OUString> m_aTableNames;
51 mutable TTablePrivilegeMap m_aPrivMap;
52 OUString m_sUserName;
53 VclPtr<::svt::CheckBoxControl> m_pCheckCell;
54 VclPtr<::svt::EditControl> m_pEdit;
55 tools::Long m_nDataPos;
56 ImplSVEvent * m_nDeactivateEvent;
58 public:
59 OTableGrantControl(const css::uno::Reference<css::awt::XWindow> &rParent);
60 virtual ~OTableGrantControl() override;
61 virtual void dispose() override;
62 void UpdateTables();
63 void setUserName(const OUString& _sUserName);
64 void setGrantUser(const css::uno::Reference< css::sdbcx::XAuthorizable>& _xGrantUser);
66 void setTablesSupplier(const css::uno::Reference< css::sdbcx::XTablesSupplier >& _xTablesSup);
67 void setComponentContext(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
69 virtual void Init() override;
71 // IAccessibleTableProvider
72 /** Creates the accessible object of a data table cell.
73 @param nRow The row index of the cell.
74 @param nColumnId The column ID of the cell.
75 @return The XAccessible interface of the specified cell. */
76 virtual css::uno::Reference<
77 css::accessibility::XAccessible >
78 CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId ) override;
80 protected:
81 virtual bool PreNotify(NotifyEvent& rNEvt ) override;
83 virtual bool IsTabAllowed(bool bForward) const override;
84 virtual void InitController( ::svt::CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol ) override;
85 virtual ::svt::CellController* GetController( sal_Int32 nRow, sal_uInt16 nCol ) override;
86 virtual void PaintCell( OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColId ) const override;
87 virtual bool SeekRow( sal_Int32 nRow ) override;
88 virtual bool SaveModified() override;
89 virtual OUString GetCellText( sal_Int32 nRow, sal_uInt16 nColId ) const override;
91 virtual void CellModified() override;
93 private:
94 DECL_LINK( AsynchActivate, void*, void );
95 DECL_LINK( AsynchDeactivate, void*, void );
97 static bool isAllowed(sal_uInt16 _nColumnId,sal_Int32 _nPrivilege);
98 void fillPrivilege(sal_Int32 _nRow) const;
99 TTablePrivilegeMap::const_iterator findPrivilege(sal_Int32 _nRow) const;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */