1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: defaultobjectnamecheck.hxx,v $
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 #ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
32 #define DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
34 #ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX
35 #include "objectnamecheck.hxx"
38 /** === begin UNO includes === **/
39 #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
40 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
42 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
43 #include <com/sun/star/container/XNameAccess.hpp>
45 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
46 #include <com/sun/star/sdbc/XConnection.hpp>
48 /** === end UNO includes === **/
51 #include <boost/noncopyable.hpp>
53 //........................................................................
56 //........................................................................
58 //====================================================================
59 //= HierarchicalNameCheck
60 //====================================================================
61 struct HierarchicalNameCheck_Impl
;
62 /** class implementing the IObjectNameCheck interface, and checking given object names
63 against a hierarchical name container
65 class HierarchicalNameCheck
:public ::boost::noncopyable
66 ,public IObjectNameCheck
69 std::auto_ptr
< HierarchicalNameCheck_Impl
> m_pImpl
;
72 /** constructs a HierarchicalNameCheck instance
74 the hierarchic container of named objects, against which given names should be
77 the root in the hierarchy against which given names should be checked
78 @throws ::com::sun::star::lang::IllegalArgumentException
79 if the given container is <NULL/>
81 HierarchicalNameCheck(
82 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>& _rxNames
,
83 const ::rtl::OUString
& _rRelativeRoot
86 ~HierarchicalNameCheck();
88 // IObjectNameCheck overridables
89 virtual bool isNameValid(
90 const ::rtl::OUString
& _rObjectName
,
91 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
95 HierarchicalNameCheck(); // never implemented
98 //====================================================================
99 //= DynamicTableOrQueryNameCheck
100 //====================================================================
101 struct DynamicTableOrQueryNameCheck_Impl
;
102 /** class implementing the IObjectNameCheck interface, and checking a given name
103 for being valid as either a query or a table name.
105 The class can be parametrized to act as either table name or query name validator.
107 For databases which support queries in queries, the name check is implicitly extended
108 to both queries and tables, no matter which category is checked. This prevents, for
109 such databases, that users can create a query with the name of an existing table,
112 @seealso dbtools::DatabaseMetaData::supportsSubqueriesInFrom
113 @seealso com::sun::star::sdb::tools::XObjectNames::checkNameForCreate
115 class DynamicTableOrQueryNameCheck
:public ::boost::noncopyable
116 ,public IObjectNameCheck
119 std::auto_ptr
< DynamicTableOrQueryNameCheck_Impl
> m_pImpl
;
122 /** constructs a DynamicTableOrQueryNameCheck instance
123 @param _rxSdbLevelConnection
124 a connection supporting the css.sdb.Connection service, in other word, it
125 does expose the XTablesSupplier and XQueriesSupplier interfaces.
127 specifies whether table names or query names should be checked. Only valid values
128 are CommandType::TABLE and CommandType::QUERY.
129 @throws ::com::sun::star::lang::IllegalArgumentException
130 if the given connection is <NULL/>, or the given command type is neither
131 CommandType::TABLE nor CommandType::QUERY.
133 DynamicTableOrQueryNameCheck(
134 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxSdbLevelConnection
,
135 sal_Int32 _nCommandType
138 ~DynamicTableOrQueryNameCheck();
140 // IObjectNameCheck overridables
141 virtual bool isNameValid(
142 const ::rtl::OUString
& _rObjectName
,
143 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
147 DynamicTableOrQueryNameCheck(); // never implemented
150 //........................................................................
152 //........................................................................
154 #endif // DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX