1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX
28cdf0e10cSrcweir #include "objectnameapproval.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir /** === begin UNO includes === **/
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
33cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
36cdf0e10cSrcweir #include <com/sun/star/sdb/tools/XConnectionTools.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
39cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
42cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLException.hpp>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir /** === end UNO includes === **/
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #ifndef _CPPUHELPER_WEAKREF_HXX_
47cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _CPPUHELPER_EXC_HLP_HXX_
50cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //........................................................................
54cdf0e10cSrcweir namespace dbaccess
55cdf0e10cSrcweir {
56cdf0e10cSrcweir //........................................................................
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	/** === begin UNO using === **/
59cdf0e10cSrcweir     using ::com::sun::star::sdbc::XConnection;
60cdf0e10cSrcweir     using ::com::sun::star::uno::WeakReference;
61cdf0e10cSrcweir     using ::com::sun::star::uno::Reference;
62cdf0e10cSrcweir     using ::com::sun::star::lang::DisposedException;
63cdf0e10cSrcweir     using ::com::sun::star::sdb::tools::XConnectionTools;
64cdf0e10cSrcweir     using ::com::sun::star::uno::UNO_QUERY_THROW;
65cdf0e10cSrcweir     using ::com::sun::star::sdb::tools::XObjectNames;
66cdf0e10cSrcweir     using ::com::sun::star::uno::XInterface;
67cdf0e10cSrcweir     using ::com::sun::star::sdbc::SQLException;
68cdf0e10cSrcweir 	/** === end UNO using === **/
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     namespace CommandType = com::sun::star::sdb::CommandType;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	//====================================================================
73cdf0e10cSrcweir 	//= ObjectNameApproval_Impl
74cdf0e10cSrcweir 	//====================================================================
75cdf0e10cSrcweir     struct ObjectNameApproval_Impl
76cdf0e10cSrcweir     {
77cdf0e10cSrcweir         WeakReference< XConnection >        aConnection;
78cdf0e10cSrcweir         sal_Int32                           nCommandType;
79cdf0e10cSrcweir     };
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	//====================================================================
82cdf0e10cSrcweir 	//= ObjectNameApproval
83cdf0e10cSrcweir 	//====================================================================
84cdf0e10cSrcweir 	//--------------------------------------------------------------------
ObjectNameApproval(const Reference<XConnection> & _rxConnection,ObjectType _eType)85cdf0e10cSrcweir     ObjectNameApproval::ObjectNameApproval( const Reference< XConnection >& _rxConnection, ObjectType _eType )
86cdf0e10cSrcweir         :m_pImpl( new ObjectNameApproval_Impl )
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         m_pImpl->aConnection = _rxConnection;
89cdf0e10cSrcweir         m_pImpl->nCommandType = _eType == TypeQuery ? CommandType::QUERY : CommandType::TABLE;
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	//--------------------------------------------------------------------
~ObjectNameApproval()93cdf0e10cSrcweir     ObjectNameApproval::~ObjectNameApproval()
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     //--------------------------------------------------------------------
approveElement(const::rtl::OUString & _rName,const Reference<XInterface> &)98cdf0e10cSrcweir     void SAL_CALL ObjectNameApproval::approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& /*_rxElement*/ )
99cdf0e10cSrcweir     {
100cdf0e10cSrcweir         Reference< XConnection > xConnection( m_pImpl->aConnection );
101cdf0e10cSrcweir         if ( !xConnection.is() )
102cdf0e10cSrcweir             throw DisposedException();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         Reference< XConnectionTools > xConnectionTools( xConnection, UNO_QUERY_THROW );
105cdf0e10cSrcweir         Reference< XObjectNames > xObjectNames( xConnectionTools->getObjectNames(), UNO_QUERY_THROW );
106cdf0e10cSrcweir         xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rName );
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //........................................................................
110cdf0e10cSrcweir } // namespace dbaccess
111cdf0e10cSrcweir //........................................................................
112cdf0e10cSrcweir 
113