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_CONNECTIVITY_PREDICATEINPUT_HXX
21 #define INCLUDED_CONNECTIVITY_PREDICATEINPUT_HXX
23 #include <connectivity/sqlparse.hxx>
24 #include <connectivity/dbtoolsdllapi.hxx>
25 #include <com/sun/star/uno/Any.hxx>
27 namespace com::sun::star::beans
{ class XPropertySet
; }
28 namespace com::sun::star::i18n
{ class XLocaleData4
; }
29 namespace com::sun::star::sdbc
{ class XConnection
; }
30 namespace com::sun::star::uno
{ class XComponentContext
; }
31 namespace com::sun::star::util
{ class XNumberFormatter
; }
39 //= OPredicateInputController
41 /** A class which allows input of an SQL predicate for a row set column
44 class OOO_DLLPUBLIC_DBTOOLS OPredicateInputController
47 css::uno::Reference
< css::sdbc::XConnection
>
49 css::uno::Reference
< css::util::XNumberFormatter
>
51 css::uno::Reference
< css::i18n::XLocaleData4
>
54 ::connectivity::OSQLParser
58 OPredicateInputController(
59 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
60 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
,
61 const ::connectivity::IParseContext
* _pParseContext
= nullptr
64 /** transforms a "raw" predicate value (usually obtained from a user input) into a valid predicate for the given column
65 @param _rPredicateValue
66 The text to normalize.
68 The field for which the text should be a predicate value.
70 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
73 bool normalizePredicateString(
74 OUString
& _rPredicateValue
,
75 const css::uno::Reference
< css::beans::XPropertySet
>& _rxField
,
76 OUString
* _pErrorMessage
= nullptr
79 /** get the value of the predicate, as a string to be used in a WHERE clause
80 @param _rPredicateValue
81 the value which has been normalized using normalizePredicateString
83 is the field for which a predicate is to be entered
84 @see normalizePredicateString
86 OUString
getPredicateValueStr(
87 const OUString
& _rPredicateValue
,
88 const css::uno::Reference
< css::beans::XPropertySet
> & _rxField
91 OUString
getPredicateValueStr(
92 const OUString
& _sField
93 , const OUString
& _rPredicateValue
) const;
95 /** get the value of the predicate, either as an empty or as a string
96 @param _rPredicateValue
97 the value which has been normalized using normalizePredicateString
99 is the field for which a predicate is to be entered
100 @see normalizePredicateString
102 css::uno::Any
getPredicateValue(
103 const OUString
& _rPredicateValue
,
104 const css::uno::Reference
< css::beans::XPropertySet
> & _rxField
108 std::unique_ptr
<::connectivity::OSQLParseNode
> implPredicateTree(
109 OUString
& _rErrorMessage
,
110 const OUString
& _rStatement
,
111 const css::uno::Reference
< css::beans::XPropertySet
> & _rxField
114 bool getSeparatorChars(
115 const css::lang::Locale
& _rLocale
,
116 sal_Unicode
& _rDecSep
,
117 sal_Unicode
& _rThdSep
120 css::uno::Any
implParseNode(std::unique_ptr
<::connectivity::OSQLParseNode
> pParseNode
, bool _bForStatementUse
) const;
124 } // namespace dbtools
127 #endif // INCLUDED_CONNECTIVITY_PREDICATEINPUT_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */