LibreOffice Module dbaccess (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 -*- */
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 <View.hxx>
21#include <strings.hxx>
22
24
25#include <com/sun/star/lang/XMultiServiceFactory.hpp>
26
28
29namespace dbaccess
30{
31
32 using namespace ::com::sun::star::uno;
33 using ::com::sun::star::sdbc::XConnection;
34 using ::com::sun::star::lang::XMultiServiceFactory;
35
36 static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection >& _xConnection,const OUString& i_sSetting)
37 {
38 OUString sSupportService;
39 Any aValue;
40 if ( dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) )
41 {
42 aValue >>= sSupportService;
43 }
44 return sSupportService;
45 }
46 // View
47 View::View( const Reference< XConnection >& _rxConnection, bool _bCaseSensitive,
48 const OUString& _rCatalogName,const OUString& _rSchemaName, const OUString& _rName )
49 :View_Base( _bCaseSensitive, _rName, _rxConnection->getMetaData(), OUString(), _rSchemaName, _rCatalogName )
50 {
51 m_nCommandHandle = getProperty(PROPERTY_COMMAND).Handle;
52 try
53 {
54 Reference<XMultiServiceFactory> xFac(_rxConnection,UNO_QUERY_THROW);
55 m_xViewAccess.set(xFac->createInstance(lcl_getServiceNameForSetting(_rxConnection,"ViewAccessServiceName")),UNO_QUERY);
56 }
57 catch(const Exception& )
58 {
59 DBG_UNHANDLED_EXCEPTION("dbaccess");
60 }
61 }
62
63 View::~View()
64 {
65 }
66
69
70 Any SAL_CALL View::queryInterface( const Type & _rType )
71 {
72 if(_rType == cppu::UnoType<XAlterView>::get()&& !m_xViewAccess.is() )
73 return Any();
74 Any aReturn = View_Base::queryInterface( _rType );
75 if ( !aReturn.hasValue() )
76 aReturn = View_IBASE::queryInterface( _rType );
77 return aReturn;
78 }
79
80 Sequence< Type > SAL_CALL View::getTypes( )
81 {
83
84 Sequence< Type > aTypes( ::comphelper::concatSequences(View_Base::getTypes(),View_IBASE::getTypes()) );
85 std::vector<Type> aOwnTypes;
86 aOwnTypes.reserve(aTypes.getLength());
87
88 const Type* pIter = aTypes.getConstArray();
89 const Type* pEnd = pIter + aTypes.getLength();
90 for(;pIter != pEnd ;++pIter)
91 {
92 if( *pIter != aAlterType || m_xViewAccess.is() )
93 aOwnTypes.push_back(*pIter);
94 }
95
96 return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size());
97 }
98
99 void SAL_CALL View::alterCommand( const OUString& _rNewCommand )
100 {
101 OSL_ENSURE(m_xViewAccess.is(),"Illegal call to AlterView!");
102 m_xViewAccess->alterCommand(this,_rNewCommand);
103 }
104
105 void SAL_CALL View::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
106 {
107 if ( _nHandle == m_nCommandHandle && m_xViewAccess.is() )
108 {
109 // retrieve the very current command, don't rely on the base classes cached value
110 // (which we initialized empty, anyway)
111 _rValue <<= m_xViewAccess->getCommand(const_cast<View*>(this));
112 return;
113 }
114
115 View_Base::getFastPropertyValue( _rValue, _nHandle );
116 }
117
118} // namespace dbaccess
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
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
css::uno::Type const & get()
View(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, bool _bCaseSensitive, const OUString &_rCatalogName, const OUString &_rSchemaName, const OUString &_rName)
#define DBG_UNHANDLED_EXCEPTION(...)
Type
static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection > &_xConnection, const OUString &i_sSetting)
Definition: View.cxx:36
bool getDataSourceSetting(const Reference< XInterface > &_xChild, const OUString &_sAsciiSettingsName, Any &_rSettingsValue)
IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController)
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
#define IMPLEMENT_FORWARD_REFCOUNT(classname, refcountbase)
const SvXMLTokenMapEntry aTypes[]