LibreOffice Module connectivity (master) 1
View.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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#include "View.hxx"
10
11#include <propertyids.hxx>
12
13#include <com/sun/star/sdbc/XRow.hpp>
14
16{
17View::View(const css::uno::Reference<css::sdbc::XConnection>& _rxConnection, bool _bCaseSensitive,
18 const OUString& _rSchemaName, const OUString& _rName)
19 : View_Base(_bCaseSensitive, _rName, _rxConnection->getMetaData(), OUString(), _rSchemaName,
20 OUString())
21 , m_xConnection(_rxConnection)
22{
23}
24
26
27void SAL_CALL View::acquire() noexcept { View_Base::acquire(); };
28void SAL_CALL View::release() noexcept { View_Base::release(); };
29css::uno::Any SAL_CALL View::queryInterface(const css::uno::Type& _rType)
30{
31 css::uno::Any aReturn = View_Base::queryInterface(_rType);
32 if (!aReturn.hasValue())
33 aReturn = View_IBASE::queryInterface(_rType);
34 return aReturn;
35}
36
37css::uno::Sequence<css::uno::Type> SAL_CALL View::getTypes()
38{
39 return ::comphelper::concatSequences(View_Base::getTypes(), View_IBASE::getTypes());
40}
41
42css::uno::Sequence<sal_Int8> SAL_CALL View::getImplementationId()
43{
44 return css::uno::Sequence<sal_Int8>();
45}
46
47void SAL_CALL View::alterCommand(const OUString& _rNewCommand)
48{
49 OUString aCommand = "ALTER VIEW \"" + m_Name + "\" AS " + _rNewCommand;
50 m_xMetaData->getConnection()->createStatement()->execute(aCommand);
51}
52
53void SAL_CALL View::getFastPropertyValue(css::uno::Any& _rValue, sal_Int32 _nHandle) const
54{
55 if (_nHandle == PROPERTY_ID_COMMAND)
56 {
57 // retrieve the very current command, don't rely on the base classes cached value
58 // (which we initialized empty, anyway)
59 _rValue <<= impl_getCommand();
60 return;
61 }
62
63 View_Base::getFastPropertyValue(_rValue, _nHandle);
64}
65
66OUString View::impl_getCommand() const
67{
68 OUString aCommand("SELECT RDB$VIEW_SOURCE FROM RDB$RELATIONS WHERE RDB$RELATION_NAME = '"
69 + m_Name + "'");
70 css::uno::Reference<css::sdbc::XStatement> statement = m_xConnection->createStatement();
71 css::uno::Reference<css::sdbc::XResultSet> xResult = statement->executeQuery(aCommand);
72
73 css::uno::Reference<css::sdbc::XRow> xRow(xResult, css::uno::UNO_QUERY_THROW);
74 if (!xResult->next())
75 {
76 // hmm. There is no view the name as we know it. Can only mean some other instance
77 // dropped this view meanwhile...
78 std::abort();
79 }
80
81 return xRow->getString(1);
82}
83
84} // namespace connectivity::firebird
85/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: View.cxx:42
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &_rValue, sal_Int32 _nHandle) const override
Definition: View.cxx:53
View(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, bool _bCaseSensitive, const OUString &_rSchemaName, const OUString &_rName)
Definition: View.cxx:17
virtual void SAL_CALL alterCommand(const OUString &NewCommand) override
Definition: View.cxx:47
virtual ~View() override
Definition: View.cxx:25
css::uno::Reference< css::sdbc::XConnection > m_xConnection
Definition: View.hxx:54
OUString impl_getCommand() const
retrieves the current command of the View
Definition: View.cxx:66
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: View.cxx:37
virtual void SAL_CALL acquire() noexcept override
Definition: View.cxx:27
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: View.cxx:29
virtual void SAL_CALL release() noexcept override
Definition: View.cxx:28
virtual void SAL_CALL release() noexcept override
Definition: VView.cxx:127
virtual void SAL_CALL acquire() noexcept override
Definition: VView.cxx:122
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
Definition: VView.hxx:54
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: VView.cxx:83
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: VView.cxx:78
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
Reference< XConnection > m_xConnection
#define PROPERTY_ID_COMMAND
Definition: propertyids.hxx:72
OUString aCommand