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 #ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX 29 #define DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX 30 31 #ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX 32 #include "objectnamecheck.hxx" 33 #endif 34 35 /** === begin UNO includes === **/ 36 #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_ 37 #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 38 #endif 39 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 40 #include <com/sun/star/container/XNameAccess.hpp> 41 #endif 42 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 43 #include <com/sun/star/sdbc/XConnection.hpp> 44 #endif 45 /** === end UNO includes === **/ 46 47 #include <memory> 48 #include <boost/noncopyable.hpp> 49 50 //........................................................................ 51 namespace dbaui 52 { 53 //........................................................................ 54 55 //==================================================================== 56 //= HierarchicalNameCheck 57 //==================================================================== 58 struct HierarchicalNameCheck_Impl; 59 /** class implementing the IObjectNameCheck interface, and checking given object names 60 against a hierarchical name container 61 */ 62 class HierarchicalNameCheck :public ::boost::noncopyable 63 ,public IObjectNameCheck 64 { 65 private: 66 std::auto_ptr< HierarchicalNameCheck_Impl > m_pImpl; 67 68 public: 69 /** constructs a HierarchicalNameCheck instance 70 @param _rxNames 71 the hierarchic container of named objects, against which given names should be 72 checked 73 @param _rRelativeRoot 74 the root in the hierarchy against which given names should be checked 75 @throws ::com::sun::star::lang::IllegalArgumentException 76 if the given container is <NULL/> 77 */ 78 HierarchicalNameCheck( 79 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& _rxNames, 80 const ::rtl::OUString& _rRelativeRoot 81 ); 82 83 ~HierarchicalNameCheck(); 84 85 // IObjectNameCheck overridables 86 virtual bool isNameValid( 87 const ::rtl::OUString& _rObjectName, 88 ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay 89 ) const; 90 91 private: 92 HierarchicalNameCheck(); // never implemented 93 }; 94 95 //==================================================================== 96 //= DynamicTableOrQueryNameCheck 97 //==================================================================== 98 struct DynamicTableOrQueryNameCheck_Impl; 99 /** class implementing the IObjectNameCheck interface, and checking a given name 100 for being valid as either a query or a table name. 101 102 The class can be parametrized to act as either table name or query name validator. 103 104 For databases which support queries in queries, the name check is implicitly extended 105 to both queries and tables, no matter which category is checked. This prevents, for 106 such databases, that users can create a query with the name of an existing table, 107 or vice versa. 108 109 @seealso dbtools::DatabaseMetaData::supportsSubqueriesInFrom 110 @seealso com::sun::star::sdb::tools::XObjectNames::checkNameForCreate 111 */ 112 class DynamicTableOrQueryNameCheck :public ::boost::noncopyable 113 ,public IObjectNameCheck 114 { 115 private: 116 std::auto_ptr< DynamicTableOrQueryNameCheck_Impl > m_pImpl; 117 118 public: 119 /** constructs a DynamicTableOrQueryNameCheck instance 120 @param _rxSdbLevelConnection 121 a connection supporting the css.sdb.Connection service, in other word, it 122 does expose the XTablesSupplier and XQueriesSupplier interfaces. 123 @param _nCommandType 124 specifies whether table names or query names should be checked. Only valid values 125 are CommandType::TABLE and CommandType::QUERY. 126 @throws ::com::sun::star::lang::IllegalArgumentException 127 if the given connection is <NULL/>, or the given command type is neither 128 CommandType::TABLE nor CommandType::QUERY. 129 */ 130 DynamicTableOrQueryNameCheck( 131 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxSdbLevelConnection, 132 sal_Int32 _nCommandType 133 ); 134 135 ~DynamicTableOrQueryNameCheck(); 136 137 // IObjectNameCheck overridables 138 virtual bool isNameValid( 139 const ::rtl::OUString& _rObjectName, 140 ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay 141 ) const; 142 143 private: 144 DynamicTableOrQueryNameCheck(); // never implemented 145 }; 146 147 //........................................................................ 148 } // namespace dbaui 149 //........................................................................ 150 151 #endif // DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX 152 153