LibreOffice Module connectivity (master) 1
TPrivilegesResultSet.cxx
Go to the documentation of this file.
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
21
22using namespace connectivity;
23
24using namespace ::com::sun::star::beans;
25using namespace ::com::sun::star::uno;
26using namespace ::com::sun::star::sdbcx;
27using namespace ::com::sun::star::sdbc;
28using namespace ::com::sun::star::container;
29using namespace ::com::sun::star::lang;
30
31OResultSetPrivileges::OResultSetPrivileges( const Reference< XDatabaseMetaData>& _rxMeta
32 , const Any& catalog
33 , const OUString& schemaPattern
34 , const OUString& tableNamePattern)
35 : ODatabaseMetaDataResultSet(eTablePrivileges)
36 , m_bResetValues(true)
37{
38 osl_atomic_increment( &m_refCount );
39 {
40 OUString sUserWorkingFor;
41 // we want all catalogues, all schemas, all tables
42 Sequence< OUString > sTableTypes {"VIEW", "TABLE", "%"}; // this last one is just to be sure to include anything else...
43 try
44 {
45 m_xTables = _rxMeta->getTables(catalog,schemaPattern,tableNamePattern,sTableTypes);
46 m_xRow.set(m_xTables,UNO_QUERY);
47
48 sUserWorkingFor = _rxMeta->getUserName();
49 }
50 catch(Exception&)
51 {
52 }
53
56 aRow[5] = new ORowSetValueDecorator(sUserWorkingFor);
58 aRow[7] = new ORowSetValueDecorator(OUString("YES"));
59 aRows.push_back(aRow);
61 aRows.push_back(aRow);
63 aRows.push_back(aRow);
65 aRows.push_back(aRow);
67 aRows.push_back(aRow);
69 aRows.push_back(aRow);
71 aRows.push_back(aRow);
73 aRows.push_back(aRow);
74 aRow[6] = new ORowSetValueDecorator(OUString("REFERENCE"));
75 aRows.push_back(aRow);
76
77 setRows(std::move(aRows));
78 }
79 osl_atomic_decrement( &m_refCount );
80}
81
82const ORowSetValue& OResultSetPrivileges::getValue(sal_Int32 columnIndex)
83{
84 switch(columnIndex)
85 {
86 case 1:
87 case 2:
88 case 3:
89 if ( m_xRow.is() && m_bResetValues )
90 {
91 (*m_aRowsIter)[1] = new ORowSetValueDecorator(m_xRow->getString(1));
92 if ( m_xRow->wasNull() )
93 (*m_aRowsIter)[1]->setNull();
94 (*m_aRowsIter)[2] = new ORowSetValueDecorator(m_xRow->getString(2));
95 if ( m_xRow->wasNull() )
96 (*m_aRowsIter)[2]->setNull();
97 (*m_aRowsIter)[3] = new ORowSetValueDecorator(m_xRow->getString(3));
98 if ( m_xRow->wasNull() )
99 (*m_aRowsIter)[3]->setNull();
100
101 m_bResetValues = false;
102 }
103 }
104 return ODatabaseMetaDataResultSet::getValue(columnIndex);
105}
106
108{
110 m_xTables.clear();
111 m_xRow.clear();
112}
113
115{
116 ::osl::MutexGuard aGuard( m_aMutex );
117 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
118
119 bool bReturn = false;
120 if ( m_xTables.is() )
121 {
122 if ( m_bBOF )
123 {
124 m_bResetValues = true;
125 if ( !m_xTables->next() )
126 return false;
127 }
128
130 if ( !bReturn )
131 {
132 m_bBOF = false;
133 m_bResetValues = bReturn = m_xTables->next();
134 }
135 }
136 return bReturn;
137}
138
139
140/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ORowSetValueDecoratorRef const & getAlterValue()
return an ORowSetValueDecorator with string ALTER as value
std::vector< ORowSetValueDecoratorRef > ORow
static ORowSetValueDecoratorRef const & getDeleteValue()
return an ORowSetValueDecorator with string DELETE as value
static ORowSetValueDecoratorRef const & getDropValue()
return an ORowSetValueDecorator with string DROP as value
static ORowSetValueDecoratorRef const & getInsertValue()
return an ORowSetValueDecorator with string INSERT as value
static ORowSetValueDecoratorRef const & getReadValue()
return an ORowSetValueDecorator with string READ as value
static ORowSetValueDecoratorRef const & getUpdateValue()
return an ORowSetValueDecorator with string UPDATE as value
static ORowSetValueDecoratorRef const & getCreateValue()
return an ORowSetValueDecorator with string CREATE as value
virtual const ORowSetValue & getValue(sal_Int32 columnIndex)
static ORowSetValueDecoratorRef const & getSelectValue()
return an ORowSetValueDecorator with string SELECT as value
css::uno::Reference< css::sdbc::XResultSet > m_xTables
virtual const ORowSetValue & getValue(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XRow > m_xRow
virtual sal_Bool SAL_CALL next() override
virtual void SAL_CALL disposing() override
ORowSetValueDecorator decorates an ORowSetValue so the value is "refcounted".
Definition: FValue.hxx:402
mutable::osl::Mutex m_aMutex
ULONG m_refCount
@ Exception
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
unsigned char sal_Bool