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