1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
23 #include "objectnamecheck.hxx"
25 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
26 #include <com/sun/star/container/XNameAccess.hpp>
27 #include <com/sun/star/sdbc/XConnection.hpp>
30 #include <boost/noncopyable.hpp>
35 // HierarchicalNameCheck
36 struct HierarchicalNameCheck_Impl
;
37 /** class implementing the IObjectNameCheck interface, and checking given object names
38 against a hierarchical name container
40 class HierarchicalNameCheck
:public ::boost::noncopyable
41 ,public IObjectNameCheck
44 std::unique_ptr
< HierarchicalNameCheck_Impl
> m_pImpl
;
47 /** constructs a HierarchicalNameCheck instance
49 the hierarchic container of named objects, against which given names should be
52 the root in the hierarchy against which given names should be checked
53 @throws ::com::sun::star::lang::IllegalArgumentException
54 if the given container is <NULL/>
56 HierarchicalNameCheck(
57 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>& _rxNames
,
58 const OUString
& _rRelativeRoot
61 virtual ~HierarchicalNameCheck();
63 // IObjectNameCheck overridables
64 virtual bool isNameValid(
65 const OUString
& _rObjectName
,
66 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
70 HierarchicalNameCheck(); // never implemented
73 // DynamicTableOrQueryNameCheck
74 struct DynamicTableOrQueryNameCheck_Impl
;
75 /** class implementing the IObjectNameCheck interface, and checking a given name
76 for being valid as either a query or a table name.
78 The class can be parametrized to act as either table name or query name validator.
80 For databases which support queries in queries, the name check is implicitly extended
81 to both queries and tables, no matter which category is checked. This prevents, for
82 such databases, that users can create a query with the name of an existing table,
85 @seealso dbtools::DatabaseMetaData::supportsSubqueriesInFrom
86 @seealso com::sun::star::sdb::tools::XObjectNames::checkNameForCreate
88 class DynamicTableOrQueryNameCheck
:public ::boost::noncopyable
89 ,public IObjectNameCheck
92 std::unique_ptr
< DynamicTableOrQueryNameCheck_Impl
> m_pImpl
;
95 /** constructs a DynamicTableOrQueryNameCheck instance
96 @param _rxSdbLevelConnection
97 a connection supporting the css.sdb.Connection service, in other word, it
98 does expose the XTablesSupplier and XQueriesSupplier interfaces.
100 specifies whether table names or query names should be checked. Only valid values
101 are CommandType::TABLE and CommandType::QUERY.
102 @throws ::com::sun::star::lang::IllegalArgumentException
103 if the given connection is <NULL/>, or the given command type is neither
104 CommandType::TABLE nor CommandType::QUERY.
106 DynamicTableOrQueryNameCheck(
107 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxSdbLevelConnection
,
108 sal_Int32 _nCommandType
111 virtual ~DynamicTableOrQueryNameCheck();
113 // IObjectNameCheck overridables
114 virtual bool isNameValid(
115 const OUString
& _rObjectName
,
116 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
117 ) const SAL_OVERRIDE
;
120 DynamicTableOrQueryNameCheck(); // never implemented
125 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */