1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 #include "ado/AView.hxx"
31 #include <com/sun/star/lang/DisposedException.hpp>
32 #include "ado/adoimp.hxx"
33 #include <cppuhelper/typeprovider.hxx>
34 #include "ado/Awrapado.hxx"
35 #include <comphelper/sequence.hxx>
36 #include <comphelper/types.hxx>
37 #include "TConnection.hxx"
38 
39 // -------------------------------------------------------------------------
40 using namespace comphelper;
41 using namespace connectivity::ado;
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star::lang;
44 using namespace com::sun::star::beans;
45 using namespace com::sun::star::sdbc;
46 
47 //	IMPLEMENT_SERVICE_INFO(OAdoView,"com.sun.star.sdbcx.AView","com.sun.star.sdbcx.View");
48 // -------------------------------------------------------------------------
49 OAdoView::OAdoView(sal_Bool _bCase,ADOView* _pView) : OView_ADO(_bCase,NULL)
50 ,m_aView(_pView)
51 {
52 }
53 //--------------------------------------------------------------------------
54 Sequence< sal_Int8 > OAdoView::getUnoTunnelImplementationId()
55 {
56 	static ::cppu::OImplementationId * pId = 0;
57 	if (! pId)
58 	{
59 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
60 		if (! pId)
61 		{
62 			static ::cppu::OImplementationId aId;
63 			pId = &aId;
64 		}
65 	}
66 	return pId->getImplementationId();
67 }
68 
69 // com::sun::star::lang::XUnoTunnel
70 //------------------------------------------------------------------
71 sal_Int64 OAdoView::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
72 {
73 	return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
74 				? reinterpret_cast< sal_Int64 >( this )
75 				: OView_ADO::getSomething(rId);
76 }
77 
78 // -------------------------------------------------------------------------
79 void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
80 {
81 	if(m_aView.IsValid())
82 	{
83 		switch(nHandle)
84 		{
85 			case PROPERTY_ID_NAME:
86 				rValue <<= m_aView.get_Name();
87 				break;
88 			case PROPERTY_ID_CATALOGNAME:
89 				break;
90 			case PROPERTY_ID_SCHEMANAME:
91 				//	rValue <<= m_aView.get_Type();
92 				break;
93 			case PROPERTY_ID_COMMAND:
94 				{
95 					OLEVariant aVar;
96 					m_aView.get_Command(aVar);
97 					if(!aVar.isNull() && !aVar.isEmpty())
98 					{
99 						ADOCommand* pCom = (ADOCommand*)aVar.getIDispatch();
100 						OLEString aBSTR;
101 						pCom->get_CommandText(&aBSTR);
102 						rValue <<= (::rtl::OUString) aBSTR;
103 					}
104 				}
105 				break;
106 		}
107 	}
108 	else
109 		OView_ADO::getFastPropertyValue(rValue,nHandle);
110 }
111 // -----------------------------------------------------------------------------
112 void SAL_CALL OAdoView::acquire() throw()
113 {
114 	OView_ADO::acquire();
115 }
116 // -----------------------------------------------------------------------------
117 void SAL_CALL OAdoView::release() throw()
118 {
119 	OView_ADO::release();
120 }
121 // -----------------------------------------------------------------------------
122 
123 
124