xref: /trunk/main/connectivity/source/sdbcx/VView.cxx (revision cdf0e10c)
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 "connectivity/sdbcx/VView.hxx"
31 #include <com/sun/star/lang/DisposedException.hpp>
32 #include <comphelper/sequence.hxx>
33 #include "connectivity/dbtools.hxx"
34 #include "TConnection.hxx"
35 
36 // -------------------------------------------------------------------------
37 using namespace connectivity;
38 using namespace connectivity::sdbcx;
39 using namespace ::com::sun::star::beans;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::sdbcx;
42 using namespace ::com::sun::star::container;
43 using namespace ::com::sun::star::lang;
44 
45 IMPLEMENT_SERVICE_INFO(OView,"com.sun.star.sdbcx.VView","com.sun.star.sdbcx.View");
46 // -------------------------------------------------------------------------
47 OView::OView(sal_Bool _bCase,
48 			const ::rtl::OUString& _Name,
49 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
50 			sal_Int32 _CheckOption,
51 			const ::rtl::OUString& _Command,
52 			const ::rtl::OUString& _SchemaName,
53 			const ::rtl::OUString& _CatalogName) : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase)
54 			,m_CatalogName(_CatalogName)
55 			,m_SchemaName(_SchemaName)
56 			,m_Command(_Command)
57 			,m_CheckOption(_CheckOption)
58 			,m_xMetaData(_xMetaData)
59 
60 {
61 	m_Name = _Name;
62 	construct();
63 }
64 // -------------------------------------------------------------------------
65 OView::OView(sal_Bool _bCase,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData)
66 	: ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase,sal_True)
67 	,m_xMetaData(_xMetaData)
68 {
69 	construct();
70 }
71 // -------------------------------------------------------------------------
72 OView::~OView()
73 {
74 }
75 // -------------------------------------------------------------------------
76 void OView::construct()
77 {
78 	ODescriptor::construct();
79 
80 	sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
81 
82 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME),		PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
83 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),		PROPERTY_ID_SCHEMANAME,	nAttrib,&m_SchemaName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
84 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND),			PROPERTY_ID_COMMAND,	nAttrib,&m_Command,		::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
85 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CHECKOPTION),		PROPERTY_ID_CHECKOPTION,nAttrib,&m_CheckOption,	::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
86 }
87 // -------------------------------------------------------------------------
88 void OView::disposing(void)
89 {
90 	OPropertySetHelper::disposing();
91 
92 	::osl::MutexGuard aGuard(m_aMutex);
93 }
94 // -------------------------------------------------------------------------
95 Sequence< Type > SAL_CALL OView::getTypes(  ) throw(RuntimeException)
96 {
97     return ::comphelper::concatSequences(ODescriptor::getTypes(),OView_BASE::getTypes());
98 }
99 // -------------------------------------------------------------------------
100 Any SAL_CALL OView::queryInterface( const Type & rType ) throw(RuntimeException)
101 {
102     Any aRet = OView_BASE::queryInterface( rType);
103 	return aRet.hasValue() ? aRet : ODescriptor::queryInterface( rType);
104 }
105 // -------------------------------------------------------------------------
106 ::cppu::IPropertyArrayHelper* OView::createArrayHelper( sal_Int32 /*_nId*/ ) const
107 {
108     return doCreateArrayHelper();
109 }
110 // -------------------------------------------------------------------------
111 ::cppu::IPropertyArrayHelper & OView::getInfoHelper()
112 {
113 	return *const_cast<OView*>(this)->getArrayHelper(isNew() ? 1 : 0);
114 }
115 // -----------------------------------------------------------------------------
116 ::rtl::OUString SAL_CALL OView::getName() throw(::com::sun::star::uno::RuntimeException)
117 {
118 	::rtl::OUString sComposedName;
119 	if(m_xMetaData.is())
120 		sComposedName = ::dbtools::composeTableName( m_xMetaData, m_CatalogName, m_SchemaName, m_Name, sal_False, ::dbtools::eInDataManipulation );
121 	else
122 	{
123 		Any aValue;
124 		getFastPropertyValue(aValue,PROPERTY_ID_NAME);
125 		aValue >>= sComposedName;
126 	}
127 	return sComposedName;
128 }
129 // -----------------------------------------------------------------------------
130 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OView::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
131 {
132 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
133 }
134 // -----------------------------------------------------------------------------
135 void SAL_CALL OView::setName( const ::rtl::OUString& ) throw(::com::sun::star::uno::RuntimeException)
136 {
137 }
138 // -----------------------------------------------------------------------------
139 void SAL_CALL OView::acquire() throw()
140 {
141 	OView_BASE::acquire();
142 }
143 // -----------------------------------------------------------------------------
144 void SAL_CALL OView::release() throw()
145 {
146 	OView_BASE::release();
147 }
148 // -----------------------------------------------------------------------------
149 
150 
151