Branch libreoffice-5-0-4
[LibreOffice.git] / include / connectivity / predicateinput.hxx
blob54dbaea9dc73bb30acce589bb89db3f7f7a590bb
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
38 //= OPredicateInputController
40 /** A class which allows input of an SQL predicate for a row set column
41 into a edit field.
43 class OOO_DLLPUBLIC_DBTOOLS OPredicateInputController
45 private:
46 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
47 m_xConnection;
48 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
49 m_xFormatter;
50 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData4 >
51 m_xLocaleData;
53 ::connectivity::OSQLParser
54 m_aParser;
56 public:
57 OPredicateInputController(
58 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
59 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
60 const ::connectivity::IParseContext* _pParseContext = NULL
63 /** transforms a "raw" predicate value (usually obtained from a user input) into a valid predicate for the given column
64 @param _rPredicateValue
65 The text to normalize.
66 @param _rxField
67 The field for which the text should be a predicate value.
68 @param _pErrorMessage
69 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
70 points to.
72 bool normalizePredicateString(
73 OUString& _rPredicateValue,
74 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
75 OUString* _pErrorMessage = NULL
76 ) const;
78 /** get the value of the predicate, as a string to be used in a WHERE clause
79 @param _rPredicateValue
80 the value which has been normalized using normalizePredicateString
81 @param _rxField
82 is the field for which a predicate is to be entered
83 @param _pErrorMessage
84 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
85 points to.
86 @see normalizePredicateString
88 OUString getPredicateValueStr(
89 const OUString& _rPredicateValue,
90 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField,
91 OUString* _pErrorMessage = NULL
92 ) const;
94 OUString getPredicateValueStr(
95 const OUString& _sField
96 , const OUString& _rPredicateValue
97 , OUString* _pErrorMessage = NULL) const;
99 /** get the value of the predicate, either as an empty or as a string
100 @param _rPredicateValue
101 the value which has been normalized using normalizePredicateString
102 @param _rxField
103 is the field for which a predicate is to be entered
104 @param _pErrorMessage
105 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
106 points to.
107 @see normalizePredicateString
109 ::com::sun::star::uno::Any getPredicateValue(
110 const OUString& _rPredicateValue,
111 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField,
112 OUString* _pErrorMessage = NULL
113 ) const;
115 private:
116 ::connectivity::OSQLParseNode* implPredicateTree(
117 OUString& _rErrorMessage,
118 const OUString& _rStatement,
119 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField
120 ) const;
122 bool getSeparatorChars(
123 const ::com::sun::star::lang::Locale& _rLocale,
124 sal_Unicode& _rDecSep,
125 sal_Unicode& _rThdSep
126 ) const;
128 ::com::sun::star::uno::Any implParseNode(::connectivity::OSQLParseNode* pParseNode, bool _bForStatementUse) const;
132 } // namespace dbtools
135 #endif // INCLUDED_CONNECTIVITY_PREDICATEINPUT_HXX
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */