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 DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
21 #define 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>
32 //........................................................................
35 //........................................................................
37 //====================================================================
38 //= HierarchicalNameCheck
39 //====================================================================
40 struct HierarchicalNameCheck_Impl
;
41 /** class implementing the IObjectNameCheck interface, and checking given object names
42 against a hierarchical name container
44 class HierarchicalNameCheck
:public ::boost::noncopyable
45 ,public IObjectNameCheck
48 std::auto_ptr
< HierarchicalNameCheck_Impl
> m_pImpl
;
51 /** constructs a HierarchicalNameCheck instance
53 the hierarchic container of named objects, against which given names should be
56 the root in the hierarchy against which given names should be checked
57 @throws ::com::sun::star::lang::IllegalArgumentException
58 if the given container is <NULL/>
60 HierarchicalNameCheck(
61 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>& _rxNames
,
62 const OUString
& _rRelativeRoot
65 ~HierarchicalNameCheck();
67 // IObjectNameCheck overridables
68 virtual bool isNameValid(
69 const OUString
& _rObjectName
,
70 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
74 HierarchicalNameCheck(); // never implemented
77 //====================================================================
78 //= DynamicTableOrQueryNameCheck
79 //====================================================================
80 struct DynamicTableOrQueryNameCheck_Impl
;
81 /** class implementing the IObjectNameCheck interface, and checking a given name
82 for being valid as either a query or a table name.
84 The class can be parametrized to act as either table name or query name validator.
86 For databases which support queries in queries, the name check is implicitly extended
87 to both queries and tables, no matter which category is checked. This prevents, for
88 such databases, that users can create a query with the name of an existing table,
91 @seealso dbtools::DatabaseMetaData::supportsSubqueriesInFrom
92 @seealso com::sun::star::sdb::tools::XObjectNames::checkNameForCreate
94 class DynamicTableOrQueryNameCheck
:public ::boost::noncopyable
95 ,public IObjectNameCheck
98 std::auto_ptr
< DynamicTableOrQueryNameCheck_Impl
> m_pImpl
;
101 /** constructs a DynamicTableOrQueryNameCheck instance
102 @param _rxSdbLevelConnection
103 a connection supporting the css.sdb.Connection service, in other word, it
104 does expose the XTablesSupplier and XQueriesSupplier interfaces.
106 specifies whether table names or query names should be checked. Only valid values
107 are CommandType::TABLE and CommandType::QUERY.
108 @throws ::com::sun::star::lang::IllegalArgumentException
109 if the given connection is <NULL/>, or the given command type is neither
110 CommandType::TABLE nor CommandType::QUERY.
112 DynamicTableOrQueryNameCheck(
113 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxSdbLevelConnection
,
114 sal_Int32 _nCommandType
117 ~DynamicTableOrQueryNameCheck();
119 // IObjectNameCheck overridables
120 virtual bool isNameValid(
121 const OUString
& _rObjectName
,
122 ::dbtools::SQLExceptionInfo
& _out_rErrorToDisplay
126 DynamicTableOrQueryNameCheck(); // never implemented
129 //........................................................................
131 //........................................................................
133 #endif // DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */