Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "TableGrantCtrl.hxx"
21 : : #include <tools/debug.hxx>
22 : : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
23 : : #include <com/sun/star/sdbcx/Privilege.hpp>
24 : : #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
25 : : #include <com/sun/star/sdbcx/XUsersSupplier.hpp>
26 : : #include <com/sun/star/sdbcx/XAuthorizable.hpp>
27 : : #include "dbu_control.hrc"
28 : : #include "UITools.hxx"
29 : :
30 : : using namespace ::com::sun::star::accessibility;
31 : : using namespace ::com::sun::star::container;
32 : : using namespace ::com::sun::star::sdbcx;
33 : : using namespace ::com::sun::star::sdbc;
34 : : using namespace ::com::sun::star::uno;
35 : : using namespace ::dbaui;
36 : : using namespace ::svt;
37 : :
38 : : const sal_uInt16 COL_TABLE_NAME = 1;
39 : : const sal_uInt16 COL_SELECT = 2;
40 : : const sal_uInt16 COL_INSERT = 3;
41 : : const sal_uInt16 COL_DELETE = 4;
42 : : const sal_uInt16 COL_UPDATE = 5;
43 : : const sal_uInt16 COL_ALTER = 6;
44 : : const sal_uInt16 COL_REF = 7;
45 : : const sal_uInt16 COL_DROP = 8;
46 : :
47 : : DBG_NAME(OTableGrantControl)
48 : :
49 : : //================================================================================
50 : : // OTableGrantControl
51 : : //================================================================================
52 : 0 : OTableGrantControl::OTableGrantControl( Window* pParent,const ResId& _RsId)
53 : : :EditBrowseBox( pParent,_RsId, EBBF_SMART_TAB_TRAVEL | EBBF_NOROWPICTURE )
54 : : ,m_pCheckCell( NULL )
55 : : ,m_pEdit( NULL )
56 : : ,m_nDataPos( 0 )
57 : : ,m_bEnable(sal_True)
58 [ # # ][ # # ]: 0 : ,m_nDeactivateEvent(0)
[ # # ]
59 : : {
60 : : DBG_CTOR(OTableGrantControl,NULL);
61 : : //////////////////////////////////////////////////////////////////////
62 : : // Spalten einfuegen
63 : 0 : sal_uInt16 i=1;
64 [ # # ][ # # ]: 0 : InsertDataColumn( i, String(ModuleRes(STR_TABLE_PRIV_NAME) ), 75);
[ # # ][ # # ]
65 [ # # ]: 0 : FreezeColumn(i++);
66 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_SELECT)), 75);
[ # # ][ # # ]
67 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_INSERT)), 75);
[ # # ][ # # ]
68 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_DELETE)), 75);
[ # # ][ # # ]
69 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_UPDATE)), 75);
[ # # ][ # # ]
70 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_ALTER)), 75);
[ # # ][ # # ]
71 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_REFERENCE)), 75);
[ # # ][ # # ]
72 [ # # ][ # # ]: 0 : InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_DROP)), 75);
[ # # ][ # # ]
73 : :
74 [ # # ]: 0 : while(--i)
75 [ # # ][ # # ]: 0 : SetColumnWidth(i,GetAutoColumnWidth(i));
76 : 0 : }
77 : :
78 : : //------------------------------------------------------------------------
79 [ # # ][ # # ]: 0 : OTableGrantControl::~OTableGrantControl()
80 : : {
81 : : DBG_DTOR(OTableGrantControl,NULL);
82 [ # # ]: 0 : if (m_nDeactivateEvent)
83 : : {
84 [ # # ]: 0 : Application::RemoveUserEvent(m_nDeactivateEvent);
85 : 0 : m_nDeactivateEvent = 0;
86 : : }
87 : :
88 [ # # ][ # # ]: 0 : delete m_pCheckCell;
89 [ # # ][ # # ]: 0 : delete m_pEdit;
90 : :
91 [ # # ]: 0 : m_xTables = NULL;
92 [ # # ]: 0 : }
93 : : // -----------------------------------------------------------------------------
94 : 0 : void OTableGrantControl::setTablesSupplier(const Reference< XTablesSupplier >& _xTablesSup)
95 : : {
96 : : // first we need the users
97 [ # # ]: 0 : Reference< XUsersSupplier> xUserSup(_xTablesSup,UNO_QUERY);
98 [ # # ]: 0 : if(xUserSup.is())
99 [ # # ][ # # ]: 0 : m_xUsers = xUserSup->getUsers();
[ # # ]
100 : :
101 : : // second we need the tables to determine which privileges the user has
102 [ # # ]: 0 : if(_xTablesSup.is())
103 [ # # ][ # # ]: 0 : m_xTables = _xTablesSup->getTables();
[ # # ]
104 : :
105 [ # # ]: 0 : if(m_xTables.is())
106 [ # # ][ # # ]: 0 : m_aTableNames = m_xTables->getElementNames();
[ # # ][ # # ]
107 : :
108 : : OSL_ENSURE(m_xUsers.is(),"No user access supported!");
109 : 0 : OSL_ENSURE(m_xTables.is(),"No tables supported!");
110 : 0 : }
111 : : // -----------------------------------------------------------------------------
112 : 0 : void OTableGrantControl::setORB(const Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB)
113 : : {
114 : 0 : m_xORB = _xORB;
115 : 0 : }
116 : : //------------------------------------------------------------------------
117 : 0 : void OTableGrantControl::UpdateTables()
118 : : {
119 : 0 : RemoveRows();
120 : :
121 [ # # ]: 0 : if(m_xTables.is())
122 : 0 : RowInserted(0, m_aTableNames.getLength());
123 : : // m_bEnable = m_xDb->GetUser() != ((OUserAdmin*)GetParent())->GetUser();
124 : 0 : }
125 : : //------------------------------------------------------------------------
126 : 0 : void OTableGrantControl::Init()
127 : : {
128 : : DBG_CHKTHIS(OTableGrantControl,NULL);
129 : 0 : EditBrowseBox::Init();
130 : :
131 : : //////////////////////////////////////////////////////////////////////
132 : : // ComboBox instanzieren
133 [ # # ]: 0 : if(!m_pCheckCell)
134 : : {
135 [ # # ]: 0 : m_pCheckCell = new CheckBoxControl( &GetDataWindow() );
136 : 0 : m_pCheckCell->GetBox().EnableTriState(sal_False);
137 : :
138 [ # # ]: 0 : m_pEdit = new Edit( &GetDataWindow() );
139 : 0 : m_pEdit->SetReadOnly();
140 : 0 : m_pEdit->Enable(sal_False);
141 : : }
142 : :
143 : 0 : UpdateTables();
144 : : //////////////////////////////////////////////////////////////////////
145 : : // Browser Mode setzen
146 : : BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL |
147 : 0 : BROWSER_HIDECURSOR | BROWSER_HIDESELECT;
148 : :
149 : 0 : SetMode(nMode);
150 : 0 : }
151 : :
152 : : //------------------------------------------------------------------------------
153 : 0 : void OTableGrantControl::Resize()
154 : : {
155 : : DBG_CHKTHIS(OTableGrantControl,NULL);
156 : 0 : EditBrowseBox::Resize();
157 : 0 : }
158 : :
159 : : //------------------------------------------------------------------------------
160 : 0 : long OTableGrantControl::PreNotify(NotifyEvent& rNEvt)
161 : : {
162 : : DBG_CHKTHIS(OTableGrantControl,NULL);
163 [ # # ]: 0 : if (rNEvt.GetType() == EVENT_LOSEFOCUS)
164 [ # # ]: 0 : if (!HasChildPathFocus())
165 : : {
166 [ # # ]: 0 : if (m_nDeactivateEvent)
167 : 0 : Application::RemoveUserEvent(m_nDeactivateEvent);
168 [ # # ]: 0 : m_nDeactivateEvent = Application::PostUserEvent(LINK(this, OTableGrantControl, AsynchDeactivate));
169 : : }
170 [ # # ]: 0 : if (rNEvt.GetType() == EVENT_GETFOCUS)
171 : : {
172 [ # # ]: 0 : if (m_nDeactivateEvent)
173 : 0 : Application::RemoveUserEvent(m_nDeactivateEvent);
174 [ # # ]: 0 : m_nDeactivateEvent = Application::PostUserEvent(LINK(this, OTableGrantControl, AsynchActivate));
175 : : }
176 : 0 : return EditBrowseBox::PreNotify(rNEvt);
177 : : }
178 : :
179 : : //------------------------------------------------------------------------------
180 : 0 : IMPL_LINK_NOARG(OTableGrantControl, AsynchActivate)
181 : : {
182 : 0 : m_nDeactivateEvent = 0;
183 : 0 : ActivateCell();
184 : 0 : return 0L;
185 : : }
186 : :
187 : : //------------------------------------------------------------------------------
188 : 0 : IMPL_LINK_NOARG(OTableGrantControl, AsynchDeactivate)
189 : : {
190 : 0 : m_nDeactivateEvent = 0;
191 : 0 : DeactivateCell();
192 : 0 : return 0L;
193 : : }
194 : :
195 : : //------------------------------------------------------------------------------
196 : 0 : sal_Bool OTableGrantControl::IsTabAllowed(sal_Bool bForward) const
197 : : {
198 : : DBG_CHKTHIS(OTableGrantControl,NULL);
199 : 0 : long nRow = GetCurRow();
200 : 0 : sal_uInt16 nCol = GetCurColumnId();
201 : :
202 [ # # ][ # # ]: 0 : if (bForward && (nCol == 2) && (nRow == GetRowCount() - 1))
[ # # ][ # # ]
203 : 0 : return sal_False;
204 : :
205 [ # # ][ # # ]: 0 : if (!bForward && (nCol == 1) && (nRow == 0))
[ # # ]
206 : 0 : return sal_False;
207 : :
208 : 0 : return EditBrowseBox::IsTabAllowed(bForward);
209 : : }
210 : : //------------------------------------------------------------------------------
211 : : #define GRANT_REVOKE_RIGHT(what) \
212 : : if(m_pCheckCell->GetBox().IsChecked()) \
213 : : xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,what);\
214 : : else \
215 : : xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,what)
216 : :
217 : : //------------------------------------------------------------------------------
218 : 0 : sal_Bool OTableGrantControl::SaveModified()
219 : : {
220 : : DBG_CHKTHIS(OTableGrantControl,NULL);
221 : :
222 : 0 : sal_Int32 nRow = GetCurRow();
223 [ # # ][ # # ]: 0 : if(nRow == -1 || nRow >= m_aTableNames.getLength())
[ # # ]
224 : 0 : return sal_False;
225 : :
226 [ # # ]: 0 : ::rtl::OUString sTableName = m_aTableNames[nRow];
227 : 0 : sal_Bool bErg = sal_True;
228 : : try
229 : : {
230 : :
231 [ # # ][ # # ]: 0 : if ( m_xUsers->hasByName(m_sUserName) )
[ # # ]
232 : : {
233 [ # # ][ # # ]: 0 : Reference<XAuthorizable> xAuth(m_xUsers->getByName(m_sUserName),UNO_QUERY);
[ # # ]
234 [ # # ]: 0 : if ( xAuth.is() )
235 : : {
236 [ # # # # : 0 : switch( GetCurColumnId() )
# # # # ]
237 : : {
238 : : case COL_INSERT:
239 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::INSERT);
[ # # ][ # # ]
[ # # ][ # # ]
240 : 0 : break;
241 : : case COL_DELETE:
242 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::DELETE);
[ # # ][ # # ]
[ # # ][ # # ]
243 : 0 : break;
244 : : case COL_UPDATE:
245 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::UPDATE);
[ # # ][ # # ]
[ # # ][ # # ]
246 : 0 : break;
247 : : case COL_ALTER:
248 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::ALTER);
[ # # ][ # # ]
[ # # ][ # # ]
249 : 0 : break;
250 : : case COL_SELECT:
251 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::SELECT);
[ # # ][ # # ]
[ # # ][ # # ]
252 : 0 : break;
253 : : case COL_REF:
254 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::REFERENCE);
[ # # ][ # # ]
[ # # ][ # # ]
255 : 0 : break;
256 : : case COL_DROP:
257 [ # # ][ # # ]: 0 : GRANT_REVOKE_RIGHT(Privilege::DROP);
[ # # ][ # # ]
[ # # ][ # # ]
258 : 0 : break;
259 : : }
260 [ # # ]: 0 : fillPrivilege(nRow);
261 : 0 : }
262 : : }
263 : : }
264 [ # # # # ]: 0 : catch(SQLException& e)
265 : : {
266 : 0 : bErg = sal_False;
267 [ # # # # : 0 : ::dbaui::showError(::dbtools::SQLExceptionInfo(e),GetParent(),m_xORB);
# # # # ]
268 : : }
269 [ # # ][ # # ]: 0 : if(bErg && Controller().Is())
[ # # ][ # # ]
[ # # ]
[ # # # # ]
270 [ # # ][ # # ]: 0 : Controller()->ClearModified();
[ # # ]
271 [ # # ]: 0 : if(!bErg)
272 [ # # ]: 0 : UpdateTables();
273 : :
274 : 0 : return bErg;
275 : : }
276 : :
277 : : //------------------------------------------------------------------------------
278 : 0 : String OTableGrantControl::GetCellText( long nRow, sal_uInt16 nColId ) const
279 : : {
280 : : DBG_CHKTHIS(OTableGrantControl,NULL);
281 [ # # ]: 0 : if(COL_TABLE_NAME == nColId)
282 [ # # ]: 0 : return m_aTableNames[nRow];
283 : :
284 : 0 : sal_Int32 nPriv = 0;
285 [ # # ]: 0 : TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
286 [ # # ]: 0 : if(aFind != m_aPrivMap.end())
287 : 0 : nPriv = aFind->second.nRights;
288 : :
289 [ # # ][ # # ]: 0 : return String::CreateFromInt32(isAllowed(nColId,nPriv) ? 1 :0);
290 : : }
291 : :
292 : : //------------------------------------------------------------------------------
293 : 0 : void OTableGrantControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
294 : : {
295 : : DBG_CHKTHIS(OTableGrantControl,NULL);
296 [ # # ][ # # ]: 0 : String sTablename = m_aTableNames[nRow];
297 : : // special case for tablename
298 [ # # ]: 0 : if(nColumnId == COL_TABLE_NAME)
299 [ # # ]: 0 : m_pEdit->SetText(sTablename);
300 : : else
301 : : {
302 : : // get the privileges from the user
303 [ # # ]: 0 : TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
304 [ # # ][ # # ]: 0 : m_pCheckCell->GetBox().Check(aFind != m_aPrivMap.end() ? isAllowed(nColumnId,aFind->second.nRights) : sal_False);
305 [ # # ]: 0 : }
306 : 0 : }
307 : : // -----------------------------------------------------------------------------
308 : 0 : void OTableGrantControl::fillPrivilege(sal_Int32 _nRow) const
309 : : {
310 : :
311 [ # # ]: 0 : if ( m_xUsers->hasByName(m_sUserName) )
312 : : {
313 : : try
314 : : {
315 [ # # ][ # # ]: 0 : Reference<XAuthorizable> xAuth(m_xUsers->getByName(m_sUserName),UNO_QUERY);
[ # # ]
316 [ # # ]: 0 : if ( xAuth.is() )
317 : : {
318 : : // get the privileges
319 : : TPrivileges nRights;
320 [ # # ][ # # ]: 0 : nRights.nRights = xAuth->getPrivileges(m_aTableNames[_nRow],PrivilegeObject::TABLE);
321 [ # # ]: 0 : if(m_xGrantUser.is())
322 [ # # ][ # # ]: 0 : nRights.nWithGrant = m_xGrantUser->getGrantablePrivileges(m_aTableNames[_nRow],PrivilegeObject::TABLE);
323 : : else
324 : 0 : nRights.nWithGrant = 0;
325 : :
326 [ # # ]: 0 : m_aPrivMap[m_aTableNames[_nRow]] = nRights;
327 : 0 : }
328 : : }
329 [ # # # ]: 0 : catch(SQLException& e)
330 : : {
331 [ # # # # : 0 : ::dbaui::showError(::dbtools::SQLExceptionInfo(e),GetParent(),m_xORB);
# # # # ]
332 : : }
333 : 0 : catch(Exception& )
334 : : {
335 : : }
336 : : }
337 : 0 : }
338 : : // -----------------------------------------------------------------------------
339 : 0 : sal_Bool OTableGrantControl::isAllowed(sal_uInt16 _nColumnId,sal_Int32 _nPrivilege) const
340 : : {
341 : 0 : sal_Bool bAllowed = sal_False;
342 [ # # # # : 0 : switch (_nColumnId)
# # # # ]
343 : : {
344 : : case COL_INSERT:
345 : 0 : bAllowed = (Privilege::INSERT & _nPrivilege) == Privilege::INSERT;
346 : 0 : break;
347 : : case COL_DELETE:
348 : 0 : bAllowed = (Privilege::DELETE & _nPrivilege) == Privilege::DELETE;
349 : 0 : break;
350 : : case COL_UPDATE:
351 : 0 : bAllowed = (Privilege::UPDATE & _nPrivilege) == Privilege::UPDATE;
352 : 0 : break;
353 : : case COL_ALTER:
354 : 0 : bAllowed = (Privilege::ALTER & _nPrivilege) == Privilege::ALTER;
355 : 0 : break;
356 : : case COL_SELECT:
357 : 0 : bAllowed = (Privilege::SELECT & _nPrivilege) == Privilege::SELECT;
358 : 0 : break;
359 : : case COL_REF:
360 : 0 : bAllowed = (Privilege::REFERENCE & _nPrivilege) == Privilege::REFERENCE;
361 : 0 : break;
362 : : case COL_DROP:
363 : 0 : bAllowed = (Privilege::DROP & _nPrivilege) == Privilege::DROP;
364 : 0 : break;
365 : : }
366 : 0 : return bAllowed;
367 : : }
368 : : // -----------------------------------------------------------------------------
369 : 0 : void OTableGrantControl::setUserName(const ::rtl::OUString _sUserName)
370 : : {
371 : 0 : m_sUserName = _sUserName;
372 [ # # ]: 0 : m_aPrivMap = TTablePrivilegeMap();
373 : 0 : }
374 : : // -----------------------------------------------------------------------------
375 : 0 : void OTableGrantControl::setGrantUser(const Reference< XAuthorizable>& _xGrantUser)
376 : : {
377 : : OSL_ENSURE(_xGrantUser.is(),"OTableGrantControl::setGrantUser: GrantUser is null!");
378 : 0 : m_xGrantUser = _xGrantUser;
379 : 0 : }
380 : : //------------------------------------------------------------------------------
381 : 0 : CellController* OTableGrantControl::GetController( long nRow, sal_uInt16 nColumnId )
382 : : {
383 : : DBG_CHKTHIS(OTableGrantControl,NULL);
384 : :
385 : 0 : CellController* pController = NULL;
386 [ # # # ]: 0 : switch( nColumnId )
387 : : {
388 : : case COL_TABLE_NAME:
389 : 0 : break;
390 : : case COL_INSERT:
391 : : case COL_DELETE:
392 : : case COL_UPDATE:
393 : : case COL_ALTER:
394 : : case COL_SELECT:
395 : : case COL_REF:
396 : : case COL_DROP:
397 : : {
398 [ # # ]: 0 : TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
399 [ # # ][ # # ]: 0 : if(aFind != m_aPrivMap.end() && isAllowed(nColumnId,aFind->second.nWithGrant))
[ # # ][ # # ]
[ # # ]
400 [ # # ][ # # ]: 0 : pController = new CheckBoxCellController( m_pCheckCell );
401 : : }
402 : 0 : break;
403 : : default:
404 : : ;
405 : : }
406 : 0 : return pController;
407 : : }
408 : : //------------------------------------------------------------------------------
409 : 0 : sal_Bool OTableGrantControl::SeekRow( long nRow )
410 : : {
411 : : DBG_CHKTHIS(OTableGrantControl,NULL);
412 : 0 : m_nDataPos = nRow;
413 : :
414 : 0 : return (nRow <= m_aTableNames.getLength());
415 : : }
416 : :
417 : : //------------------------------------------------------------------------------
418 : 0 : void OTableGrantControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
419 : : {
420 : : DBG_CHKTHIS(OTableGrantControl,NULL);
421 : :
422 [ # # ]: 0 : if(nColumnId != COL_TABLE_NAME)
423 : : {
424 [ # # ]: 0 : TTablePrivilegeMap::const_iterator aFind = findPrivilege(m_nDataPos);
425 [ # # ]: 0 : if(aFind != m_aPrivMap.end())
426 [ # # ][ # # ]: 0 : PaintTristate(rDev, rRect, isAllowed(nColumnId,aFind->second.nRights) ? STATE_CHECK : STATE_NOCHECK,isAllowed(nColumnId,aFind->second.nWithGrant));
427 : : else
428 [ # # ]: 0 : PaintTristate(rDev, rRect, STATE_NOCHECK,sal_False);
429 : : }
430 : : else
431 : : {
432 [ # # ]: 0 : String aText(((OTableGrantControl*)this)->GetCellText( m_nDataPos, nColumnId ));
433 : 0 : Point aPos( rRect.TopLeft() );
434 [ # # ]: 0 : sal_Int32 nWidth = GetDataWindow().GetTextWidth( aText );
435 [ # # ]: 0 : sal_Int32 nHeight = GetDataWindow().GetTextHeight();
436 : :
437 [ # # ][ # # : 0 : if( aPos.X() < rRect.Right() || aPos.X() + nWidth > rRect.Right() ||
# # # # ]
[ # # ]
438 : 0 : aPos.Y() < rRect.Top() || aPos.Y() + nHeight > rRect.Bottom() )
439 [ # # ][ # # ]: 0 : rDev.SetClipRegion( rRect );
[ # # ]
440 : :
441 [ # # ][ # # ]: 0 : rDev.DrawText( aPos, aText );
442 : : }
443 : :
444 [ # # ]: 0 : if( rDev.IsClipRegion() )
445 : 0 : rDev.SetClipRegion();
446 : 0 : }
447 : :
448 : : //------------------------------------------------------------------------
449 : 0 : void OTableGrantControl::CellModified()
450 : : {
451 : : DBG_CHKTHIS(OTableGrantControl,NULL);
452 : 0 : EditBrowseBox::CellModified();
453 : 0 : SaveModified();
454 : 0 : }
455 : : // -----------------------------------------------------------------------------
456 : 0 : OTableGrantControl::TTablePrivilegeMap::const_iterator OTableGrantControl::findPrivilege(sal_Int32 _nRow) const
457 : : {
458 : 0 : TTablePrivilegeMap::const_iterator aFind = m_aPrivMap.find(m_aTableNames[_nRow]);
459 [ # # ]: 0 : if(aFind == m_aPrivMap.end())
460 : : {
461 : 0 : fillPrivilege(_nRow);
462 : 0 : aFind = m_aPrivMap.find(m_aTableNames[_nRow]);
463 : : }
464 : 0 : return aFind;
465 : : }
466 : : // -----------------------------------------------------------------------------
467 : 0 : Reference< XAccessible > OTableGrantControl::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
468 : : {
469 : 0 : sal_uInt16 nColumnId = GetColumnId( _nColumnPos );
470 [ # # ]: 0 : if(nColumnId != COL_TABLE_NAME)
471 : : {
472 : 0 : TriState eState = STATE_NOCHECK;
473 : 0 : sal_Bool bEnable = sal_False;
474 [ # # ]: 0 : TTablePrivilegeMap::const_iterator aFind = findPrivilege(_nRow);
475 [ # # ]: 0 : if(aFind != m_aPrivMap.end())
476 : : {
477 [ # # ]: 0 : eState = isAllowed(nColumnId,aFind->second.nRights) ? STATE_CHECK : STATE_NOCHECK;
478 : 0 : bEnable = isAllowed(nColumnId,aFind->second.nWithGrant);
479 : : }
480 : : else
481 : 0 : eState = STATE_NOCHECK;
482 : :
483 [ # # ]: 0 : return EditBrowseBox::CreateAccessibleCheckBoxCell( _nRow, _nColumnPos,eState,bEnable );
484 : : }
485 : 0 : return EditBrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
486 : : }
487 : : // -----------------------------------------------------------------------------
488 : :
489 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|