bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / connectivity / predicateinput.hxx
blob3c54284700f4ebc94a53550a61f444e756eb472a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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; }
35 namespace dbtools
39 //= OPredicateInputController
41 /** A class which allows input of an SQL predicate for a row set column
42 into a edit field.
44 class OOO_DLLPUBLIC_DBTOOLS OPredicateInputController
46 private:
47 css::uno::Reference< css::sdbc::XConnection >
48 m_xConnection;
49 css::uno::Reference< css::util::XNumberFormatter >
50 m_xFormatter;
51 css::uno::Reference< css::i18n::XLocaleData4 >
52 m_xLocaleData;
54 ::connectivity::OSQLParser
55 m_aParser;
57 public:
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.
67 @param _rxField
68 The field for which the text should be a predicate value.
69 @param _pErrorMessage
70 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
71 points to.
73 bool normalizePredicateString(
74 OUString& _rPredicateValue,
75 const css::uno::Reference< css::beans::XPropertySet >& _rxField,
76 OUString* _pErrorMessage = nullptr
77 ) const;
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
82 @param _rxField
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
89 ) const;
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
98 @param _rxField
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
105 ) const;
107 private:
108 std::unique_ptr<::connectivity::OSQLParseNode> implPredicateTree(
109 OUString& _rErrorMessage,
110 const OUString& _rStatement,
111 const css::uno::Reference< css::beans::XPropertySet > & _rxField
112 ) const;
114 bool getSeparatorChars(
115 const css::lang::Locale& _rLocale,
116 sal_Unicode& _rDecSep,
117 sal_Unicode& _rThdSep
118 ) const;
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: */