1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "connectivity/sdbcx/VView.hxx"
27cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
28cdf0e10cSrcweir #include <comphelper/sequence.hxx>
29cdf0e10cSrcweir #include "connectivity/dbtools.hxx"
30cdf0e10cSrcweir #include "TConnection.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir // -------------------------------------------------------------------------
33cdf0e10cSrcweir using namespace connectivity;
34cdf0e10cSrcweir using namespace connectivity::sdbcx;
35cdf0e10cSrcweir using namespace ::com::sun::star::beans;
36cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
38cdf0e10cSrcweir using namespace ::com::sun::star::container;
39cdf0e10cSrcweir using namespace ::com::sun::star::lang;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OView,"com.sun.star.sdbcx.VView","com.sun.star.sdbcx.View");
42cdf0e10cSrcweir // -------------------------------------------------------------------------
43cdf0e10cSrcweir OView::OView(sal_Bool _bCase,
44cdf0e10cSrcweir 			const ::rtl::OUString& _Name,
45cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
46cdf0e10cSrcweir 			sal_Int32 _CheckOption,
47cdf0e10cSrcweir 			const ::rtl::OUString& _Command,
48cdf0e10cSrcweir 			const ::rtl::OUString& _SchemaName,
49cdf0e10cSrcweir 			const ::rtl::OUString& _CatalogName) : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase)
50cdf0e10cSrcweir 			,m_CatalogName(_CatalogName)
51cdf0e10cSrcweir 			,m_SchemaName(_SchemaName)
52cdf0e10cSrcweir 			,m_Command(_Command)
53cdf0e10cSrcweir 			,m_CheckOption(_CheckOption)
54cdf0e10cSrcweir 			,m_xMetaData(_xMetaData)
55cdf0e10cSrcweir 
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	m_Name = _Name;
58cdf0e10cSrcweir 	construct();
59cdf0e10cSrcweir }
60cdf0e10cSrcweir // -------------------------------------------------------------------------
61cdf0e10cSrcweir OView::OView(sal_Bool _bCase,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData)
62cdf0e10cSrcweir 	: ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase,sal_True)
63cdf0e10cSrcweir 	,m_xMetaData(_xMetaData)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	construct();
66cdf0e10cSrcweir }
67cdf0e10cSrcweir // -------------------------------------------------------------------------
68cdf0e10cSrcweir OView::~OView()
69cdf0e10cSrcweir {
70cdf0e10cSrcweir }
71cdf0e10cSrcweir // -------------------------------------------------------------------------
72cdf0e10cSrcweir void OView::construct()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	ODescriptor::construct();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME),		PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
79cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),		PROPERTY_ID_SCHEMANAME,	nAttrib,&m_SchemaName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
80cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND),			PROPERTY_ID_COMMAND,	nAttrib,&m_Command,		::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
81cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CHECKOPTION),		PROPERTY_ID_CHECKOPTION,nAttrib,&m_CheckOption,	::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
82cdf0e10cSrcweir }
83cdf0e10cSrcweir // -------------------------------------------------------------------------
84cdf0e10cSrcweir void OView::disposing(void)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	OPropertySetHelper::disposing();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
89cdf0e10cSrcweir }
90cdf0e10cSrcweir // -------------------------------------------------------------------------
91cdf0e10cSrcweir Sequence< Type > SAL_CALL OView::getTypes(  ) throw(RuntimeException)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     return ::comphelper::concatSequences(ODescriptor::getTypes(),OView_BASE::getTypes());
94cdf0e10cSrcweir }
95cdf0e10cSrcweir // -------------------------------------------------------------------------
96cdf0e10cSrcweir Any SAL_CALL OView::queryInterface( const Type & rType ) throw(RuntimeException)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     Any aRet = OView_BASE::queryInterface( rType);
99cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : ODescriptor::queryInterface( rType);
100cdf0e10cSrcweir }
101cdf0e10cSrcweir // -------------------------------------------------------------------------
102cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OView::createArrayHelper( sal_Int32 /*_nId*/ ) const
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     return doCreateArrayHelper();
105cdf0e10cSrcweir }
106cdf0e10cSrcweir // -------------------------------------------------------------------------
107cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & OView::getInfoHelper()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	return *const_cast<OView*>(this)->getArrayHelper(isNew() ? 1 : 0);
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // -----------------------------------------------------------------------------
112cdf0e10cSrcweir ::rtl::OUString SAL_CALL OView::getName() throw(::com::sun::star::uno::RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	::rtl::OUString sComposedName;
115cdf0e10cSrcweir 	if(m_xMetaData.is())
116cdf0e10cSrcweir 		sComposedName = ::dbtools::composeTableName( m_xMetaData, m_CatalogName, m_SchemaName, m_Name, sal_False, ::dbtools::eInDataManipulation );
117cdf0e10cSrcweir 	else
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 		Any aValue;
120cdf0e10cSrcweir 		getFastPropertyValue(aValue,PROPERTY_ID_NAME);
121cdf0e10cSrcweir 		aValue >>= sComposedName;
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir 	return sComposedName;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir // -----------------------------------------------------------------------------
126cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OView::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
129cdf0e10cSrcweir }
130cdf0e10cSrcweir // -----------------------------------------------------------------------------
131cdf0e10cSrcweir void SAL_CALL OView::setName( const ::rtl::OUString& ) throw(::com::sun::star::uno::RuntimeException)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir }
134cdf0e10cSrcweir // -----------------------------------------------------------------------------
135cdf0e10cSrcweir void SAL_CALL OView::acquire() throw()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	OView_BASE::acquire();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
140cdf0e10cSrcweir void SAL_CALL OView::release() throw()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	OView_BASE::release();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir // -----------------------------------------------------------------------------
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147