build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / include / connectivity / predicateinput.hxx
blob16ace17d910813c42e3ca1a4e8bbd37f162383e5
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 <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/sdbc/XConnection.hpp>
26 #include <com/sun/star/util/XNumberFormatter.hpp>
27 #include <com/sun/star/i18n/XLocaleData4.hpp>
28 #include <connectivity/sqlparse.hxx>
29 #include <connectivity/dbtoolsdllapi.hxx>
30 #include <com/sun/star/uno/Any.hxx>
33 namespace dbtools
37 //= OPredicateInputController
39 /** A class which allows input of an SQL predicate for a row set column
40 into a edit field.
42 class OOO_DLLPUBLIC_DBTOOLS OPredicateInputController
44 private:
45 css::uno::Reference< css::sdbc::XConnection >
46 m_xConnection;
47 css::uno::Reference< css::util::XNumberFormatter >
48 m_xFormatter;
49 css::uno::Reference< css::i18n::XLocaleData4 >
50 m_xLocaleData;
52 ::connectivity::OSQLParser
53 m_aParser;
55 public:
56 OPredicateInputController(
57 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
58 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
59 const ::connectivity::IParseContext* _pParseContext = nullptr
62 /** transforms a "raw" predicate value (usually obtained from a user input) into a valid predicate for the given column
63 @param _rPredicateValue
64 The text to normalize.
65 @param _rxField
66 The field for which the text should be a predicate value.
67 @param _pErrorMessage
68 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
69 points to.
71 bool normalizePredicateString(
72 OUString& _rPredicateValue,
73 const css::uno::Reference< css::beans::XPropertySet >& _rxField,
74 OUString* _pErrorMessage = nullptr
75 ) const;
77 /** get the value of the predicate, as a string to be used in a WHERE clause
78 @param _rPredicateValue
79 the value which has been normalized using normalizePredicateString
80 @param _rxField
81 is the field for which a predicate is to be entered
82 @see normalizePredicateString
84 OUString getPredicateValueStr(
85 const OUString& _rPredicateValue,
86 const css::uno::Reference< css::beans::XPropertySet > & _rxField
87 ) const;
89 OUString getPredicateValueStr(
90 const OUString& _sField
91 , const OUString& _rPredicateValue) const;
93 /** get the value of the predicate, either as an empty or as a string
94 @param _rPredicateValue
95 the value which has been normalized using normalizePredicateString
96 @param _rxField
97 is the field for which a predicate is to be entered
98 @see normalizePredicateString
100 css::uno::Any getPredicateValue(
101 const OUString& _rPredicateValue,
102 const css::uno::Reference< css::beans::XPropertySet > & _rxField
103 ) const;
105 private:
106 ::connectivity::OSQLParseNode* implPredicateTree(
107 OUString& _rErrorMessage,
108 const OUString& _rStatement,
109 const css::uno::Reference< css::beans::XPropertySet > & _rxField
110 ) const;
112 bool getSeparatorChars(
113 const css::lang::Locale& _rLocale,
114 sal_Unicode& _rDecSep,
115 sal_Unicode& _rThdSep
116 ) const;
118 css::uno::Any implParseNode(::connectivity::OSQLParseNode* pParseNode, bool _bForStatementUse) const;
122 } // namespace dbtools
125 #endif // INCLUDED_CONNECTIVITY_PREDICATEINPUT_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */