bump product version to 4.1.6.2
[LibreOffice.git] / include / connectivity / predicateinput.hxx
blob629419c9719dcd68902e241b35ca6250d955f1a3
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 CONNECTIVITY_PREDICATEINPUT_HXX
21 #define 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"
31 //.........................................................................
32 namespace dbtools
34 //.........................................................................
36 //=====================================================================
37 //= OPredicateInputController
38 //=====================================================================
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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
46 m_xConnection;
47 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
48 m_xFormatter;
49 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData4 >
50 m_xLocaleData;
52 ::connectivity::OSQLParser
53 m_aParser;
55 public:
56 OPredicateInputController(
57 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
58 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
59 const ::connectivity::IParseContext* _pParseContext = NULL
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 sal_Bool normalizePredicateString(
72 OUString& _rPredicateValue,
73 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
74 OUString* _pErrorMessage = NULL
75 ) const;
77 /** get's a value of the predicate which can 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 @param _bForStatementUse
83 If <TRUE/>, the returned value can be used in an SQL statement. If <FALSE/>, it can be used
84 for instance for setting parameter values.
85 @param _pErrorMessage
86 If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
87 points to.
88 @see normalizePredicateString
90 OUString getPredicateValue(
91 const OUString& _rPredicateValue,
92 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField,
93 sal_Bool _bForStatementUse,
94 OUString* _pErrorMessage = NULL
95 ) const;
97 OUString getPredicateValue(
98 const OUString& _sField
99 , const OUString& _rPredicateValue
100 , sal_Bool _bForStatementUse
101 , OUString* _pErrorMessage = NULL) const;
103 private:
104 ::connectivity::OSQLParseNode* implPredicateTree(
105 OUString& _rErrorMessage,
106 const OUString& _rStatement,
107 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField
108 ) const;
110 sal_Bool getSeparatorChars(
111 const ::com::sun::star::lang::Locale& _rLocale,
112 sal_Unicode& _rDecSep,
113 sal_Unicode& _rThdSep
114 ) const;
116 OUString implParseNode(::connectivity::OSQLParseNode* pParseNode,sal_Bool _bForStatementUse) const;
119 //.........................................................................
120 } // namespace dbtools
121 //.........................................................................
123 #endif // CONNECTIVITY_PREDICATEINPUT_HXX
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */