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>
34 // HierarchicalNameCheck
35 struct HierarchicalNameCheck_Impl
;
36 /** class implementing the IObjectNameCheck interface, and checking given object names
37 against a hierarchical name container
39 class HierarchicalNameCheck
:public IObjectNameCheck
42 std::unique_ptr
< HierarchicalNameCheck_Impl
> m_pImpl
;
45 /** constructs a HierarchicalNameCheck instance
47 the hierarchic container of named objects, against which given names should be
50 the root in the hierarchy against which given names should be checked
51 @throws css::lang::IllegalArgumentException
52 if the given container is <NULL/>
54 HierarchicalNameCheck(
55 const css::uno::Reference
< css::container::XHierarchicalNameAccess
>& _rxNames
,
56 const OUString
& _rRelativeRoot
59 virtual ~HierarchicalNameCheck();
61 HierarchicalNameCheck(const HierarchicalNameCheck
&) = delete;
62 const HierarchicalNameCheck
& operator=(const HierarchicalNameCheck
&) = delete;
64 // IObjectNameCheck overridables
65 virtual bool isNameValid(
66 const OUString
& _rObjectName
,
67 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
71 // DynamicTableOrQueryNameCheck
72 struct DynamicTableOrQueryNameCheck_Impl
;
73 /** class implementing the IObjectNameCheck interface, and checking a given name
74 for being valid as either a query or a table name.
76 The class can be parametrized to act as either table name or query name validator.
78 For databases which support queries in queries, the name check is implicitly extended
79 to both queries and tables, no matter which category is checked. This prevents, for
80 such databases, that users can create a query with the name of an existing table,
83 @seealso dbtools::DatabaseMetaData::supportsSubqueriesInFrom
84 @seealso css::sdb::tools::XObjectNames::checkNameForCreate
86 class DynamicTableOrQueryNameCheck
:public IObjectNameCheck
89 std::unique_ptr
< DynamicTableOrQueryNameCheck_Impl
> m_pImpl
;
92 /** constructs a DynamicTableOrQueryNameCheck instance
93 @param _rxSdbLevelConnection
94 a connection supporting the css.sdb.Connection service, in other word, it
95 does expose the XTablesSupplier and XQueriesSupplier interfaces.
97 specifies whether table names or query names should be checked. Only valid values
98 are CommandType::TABLE and CommandType::QUERY.
99 @throws css::lang::IllegalArgumentException
100 if the given connection is <NULL/>, or the given command type is neither
101 CommandType::TABLE nor CommandType::QUERY.
103 DynamicTableOrQueryNameCheck(
104 const css::uno::Reference
< css::sdbc::XConnection
>& _rxSdbLevelConnection
,
105 sal_Int32 _nCommandType
108 virtual ~DynamicTableOrQueryNameCheck();
110 DynamicTableOrQueryNameCheck(const DynamicTableOrQueryNameCheck
&) = delete;
111 const DynamicTableOrQueryNameCheck
& operator=(const DynamicTableOrQueryNameCheck
&) = delete;
113 // IObjectNameCheck overridables
114 virtual bool isNameValid(
115 const OUString
& _rObjectName
,
116 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
122 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */