1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "ado/AView.hxx"
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include "ado/adoimp.hxx"
29 #include <cppuhelper/typeprovider.hxx>
30 #include "ado/Awrapado.hxx"
31 #include <comphelper/sequence.hxx>
32 #include <comphelper/types.hxx>
33 #include "TConnection.hxx"
34 
35 // -------------------------------------------------------------------------
36 using namespace comphelper;
37 using namespace connectivity::ado;
38 using namespace com::sun::star::uno;
39 using namespace com::sun::star::lang;
40 using namespace com::sun::star::beans;
41 using namespace com::sun::star::sdbc;
42 
43 //	IMPLEMENT_SERVICE_INFO(OAdoView,"com.sun.star.sdbcx.AView","com.sun.star.sdbcx.View");
44 // -------------------------------------------------------------------------
OAdoView(sal_Bool _bCase,ADOView * _pView)45 OAdoView::OAdoView(sal_Bool _bCase,ADOView* _pView) : OView_ADO(_bCase,NULL)
46 ,m_aView(_pView)
47 {
48 }
49 //--------------------------------------------------------------------------
getUnoTunnelImplementationId()50 Sequence< sal_Int8 > OAdoView::getUnoTunnelImplementationId()
51 {
52 	static ::cppu::OImplementationId * pId = 0;
53 	if (! pId)
54 	{
55 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
56 		if (! pId)
57 		{
58 			static ::cppu::OImplementationId aId;
59 			pId = &aId;
60 		}
61 	}
62 	return pId->getImplementationId();
63 }
64 
65 // com::sun::star::lang::XUnoTunnel
66 //------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & rId)67 sal_Int64 OAdoView::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
68 {
69 	return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
70 				? reinterpret_cast< sal_Int64 >( this )
71 				: OView_ADO::getSomething(rId);
72 }
73 
74 // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const75 void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
76 {
77 	if(m_aView.IsValid())
78 	{
79 		switch(nHandle)
80 		{
81 			case PROPERTY_ID_NAME:
82 				rValue <<= m_aView.get_Name();
83 				break;
84 			case PROPERTY_ID_CATALOGNAME:
85 				break;
86 			case PROPERTY_ID_SCHEMANAME:
87 				//	rValue <<= m_aView.get_Type();
88 				break;
89 			case PROPERTY_ID_COMMAND:
90 				{
91 					OLEVariant aVar;
92 					m_aView.get_Command(aVar);
93 					if(!aVar.isNull() && !aVar.isEmpty())
94 					{
95 						ADOCommand* pCom = (ADOCommand*)aVar.getIDispatch();
96 						OLEString aBSTR;
97 						pCom->get_CommandText(&aBSTR);
98 						rValue <<= (::rtl::OUString) aBSTR;
99 					}
100 				}
101 				break;
102 		}
103 	}
104 	else
105 		OView_ADO::getFastPropertyValue(rValue,nHandle);
106 }
107 // -----------------------------------------------------------------------------
acquire()108 void SAL_CALL OAdoView::acquire() throw()
109 {
110 	OView_ADO::acquire();
111 }
112 // -----------------------------------------------------------------------------
release()113 void SAL_CALL OAdoView::release() throw()
114 {
115 	OView_ADO::release();
116 }
117 // -----------------------------------------------------------------------------
118 
119 
120