tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / dbaccess / source / core / api / View.cxx
blobefbbd8b412df47c8c33678003555dc879c2452de
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 .
20 #include <View.hxx>
21 #include <strings.hxx>
23 #include <connectivity/dbtools.hxx>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <comphelper/diagnose_ex.hxx>
29 namespace dbaccess
32 using namespace ::com::sun::star::uno;
33 using ::com::sun::star::sdbc::XConnection;
34 using ::com::sun::star::lang::XMultiServiceFactory;
36 static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection >& _xConnection,const OUString& i_sSetting)
38 OUString sSupportService;
39 Any aValue;
40 if ( dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) )
42 aValue >>= sSupportService;
44 return sSupportService;
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 )
51 m_nCommandHandle = getProperty(PROPERTY_COMMAND).Handle;
52 try
54 Reference<XMultiServiceFactory> xFac(_rxConnection,UNO_QUERY_THROW);
55 m_xViewAccess.set(xFac->createInstance(lcl_getServiceNameForSetting(_rxConnection,u"ViewAccessServiceName"_ustr)),UNO_QUERY);
57 catch(const Exception& )
59 DBG_UNHANDLED_EXCEPTION("dbaccess");
63 View::~View()
67 IMPLEMENT_FORWARD_REFCOUNT( View, View_Base )
68 IMPLEMENT_GET_IMPLEMENTATION_ID( View )
70 Any SAL_CALL View::queryInterface( const Type & _rType )
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;
80 Sequence< Type > SAL_CALL View::getTypes( )
82 Type aAlterType = cppu::UnoType<XAlterView>::get();
84 Sequence< Type > aTypes( ::comphelper::concatSequences(View_Base::getTypes(),View_IBASE::getTypes()) );
85 std::vector<Type> aOwnTypes;
86 aOwnTypes.reserve(aTypes.getLength());
88 for (auto& type : aTypes)
89 if (m_xViewAccess || type != aAlterType)
90 aOwnTypes.push_back(type);
92 return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size());
95 void SAL_CALL View::alterCommand( const OUString& _rNewCommand )
97 OSL_ENSURE(m_xViewAccess.is(),"Illegal call to AlterView!");
98 m_xViewAccess->alterCommand(this,_rNewCommand);
101 void SAL_CALL View::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
103 if ( _nHandle == m_nCommandHandle && m_xViewAccess.is() )
105 // retrieve the very current command, don't rely on the base classes cached value
106 // (which we initialized empty, anyway)
107 _rValue <<= m_xViewAccess->getCommand(const_cast<View*>(this));
108 return;
111 View_Base::getFastPropertyValue( _rValue, _nHandle );
114 } // namespace dbaccess
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */