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 <ado/AView.hxx>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <ado/adoimp.hxx>
23 #include <cppuhelper/typeprovider.hxx>
24 #include <ado/Awrapado.hxx>
25 #include <comphelper/servicehelper.hxx>
26 #include <comphelper/types.hxx>
27 #include <TConnection.hxx>
28 
29 
30 using namespace comphelper;
31 using namespace connectivity::ado;
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::lang;
34 using namespace com::sun::star::beans;
35 using namespace com::sun::star::sdbc;
36 
37 //  IMPLEMENT_SERVICE_INFO(OAdoView,"com.sun.star.sdbcx.AView","com.sun.star.sdbcx.View");
38 
OAdoView(bool _bCase,ADOView * _pView)39 OAdoView::OAdoView(bool _bCase,ADOView* _pView) : OView_ADO(_bCase,nullptr)
40 ,m_aView(_pView)
41 {
42 }
43 
getUnoTunnelId()44 Sequence< sal_Int8 > OAdoView::getUnoTunnelId()
45 {
46     static ::cppu::OImplementationId implId;
47 
48     return implId.getImplementationId();
49 }
50 
51 // css::lang::XUnoTunnel
52 
getSomething(const Sequence<sal_Int8> & rId)53 sal_Int64 OAdoView::getSomething( const Sequence< sal_Int8 > & rId )
54 {
55     return isUnoTunnelId<OAdoView>(rId)
56                 ? reinterpret_cast< sal_Int64 >( this )
57                 : OView_ADO::getSomething(rId);
58 }
59 
60 
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const61 void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
62 {
63     if(m_aView.IsValid())
64     {
65         switch(nHandle)
66         {
67             case PROPERTY_ID_NAME:
68                 rValue <<= m_aView.get_Name();
69                 break;
70             case PROPERTY_ID_CATALOGNAME:
71                 break;
72             case PROPERTY_ID_SCHEMANAME:
73                 //  rValue <<= m_aView.get_Type();
74                 break;
75             case PROPERTY_ID_COMMAND:
76                 {
77                     OLEVariant aVar;
78                     m_aView.get_Command(aVar);
79                     if(!aVar.isNull() && !aVar.isEmpty())
80                     {
81                         ADOCommand* pCom = static_cast<ADOCommand*>(aVar.getIDispatch());
82                         OLEString aBSTR;
83                         pCom->get_CommandText(aBSTR.getAddress());
84                         rValue <<= aBSTR.asOUString();
85                     }
86                 }
87                 break;
88         }
89     }
90     else
91         OView_ADO::getFastPropertyValue(rValue,nHandle);
92 }
93 
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
95