update dev300-m58
[ooovba.git] / dbaccess / source / core / misc / objectnameapproval.cxx
blob3c9f77a9ca1b92e1986ca174dde38f4c886ae2fa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objectnameapproval.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX
35 #include "objectnameapproval.hxx"
36 #endif
38 /** === begin UNO includes === **/
39 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
40 #include <com/sun/star/lang/DisposedException.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
43 #include <com/sun/star/sdb/tools/XConnectionTools.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
46 #include <com/sun/star/sdb/CommandType.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
49 #include <com/sun/star/sdbc/SQLException.hpp>
50 #endif
51 /** === end UNO includes === **/
53 #ifndef _CPPUHELPER_WEAKREF_HXX_
54 #include <cppuhelper/weakref.hxx>
55 #endif
56 #ifndef _CPPUHELPER_EXC_HLP_HXX_
57 #include <cppuhelper/exc_hlp.hxx>
58 #endif
60 //........................................................................
61 namespace dbaccess
63 //........................................................................
65 /** === begin UNO using === **/
66 using ::com::sun::star::sdbc::XConnection;
67 using ::com::sun::star::uno::WeakReference;
68 using ::com::sun::star::uno::Reference;
69 using ::com::sun::star::lang::DisposedException;
70 using ::com::sun::star::sdb::tools::XConnectionTools;
71 using ::com::sun::star::uno::UNO_QUERY_THROW;
72 using ::com::sun::star::sdb::tools::XObjectNames;
73 using ::com::sun::star::uno::XInterface;
74 using ::com::sun::star::sdbc::SQLException;
75 /** === end UNO using === **/
77 namespace CommandType = com::sun::star::sdb::CommandType;
79 //====================================================================
80 //= ObjectNameApproval_Impl
81 //====================================================================
82 struct ObjectNameApproval_Impl
84 WeakReference< XConnection > aConnection;
85 sal_Int32 nCommandType;
88 //====================================================================
89 //= ObjectNameApproval
90 //====================================================================
91 //--------------------------------------------------------------------
92 ObjectNameApproval::ObjectNameApproval( const Reference< XConnection >& _rxConnection, ObjectType _eType )
93 :m_pImpl( new ObjectNameApproval_Impl )
95 m_pImpl->aConnection = _rxConnection;
96 m_pImpl->nCommandType = _eType == TypeQuery ? CommandType::QUERY : CommandType::TABLE;
99 //--------------------------------------------------------------------
100 ObjectNameApproval::~ObjectNameApproval()
104 //--------------------------------------------------------------------
105 void SAL_CALL ObjectNameApproval::approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& /*_rxElement*/ )
107 Reference< XConnection > xConnection( m_pImpl->aConnection );
108 if ( !xConnection.is() )
109 throw DisposedException();
111 Reference< XConnectionTools > xConnectionTools( xConnection, UNO_QUERY_THROW );
112 Reference< XObjectNames > xObjectNames( xConnectionTools->getObjectNames(), UNO_QUERY_THROW );
113 xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rName );
116 //........................................................................
117 } // namespace dbaccess
118 //........................................................................