1*9ee13d13SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9ee13d13SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9ee13d13SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9ee13d13SAndrew Rist  * distributed with this work for additional information
6*9ee13d13SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9ee13d13SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9ee13d13SAndrew Rist  * "License"); you may not use this file except in compliance
9*9ee13d13SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9ee13d13SAndrew Rist  *
11*9ee13d13SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9ee13d13SAndrew Rist  *
13*9ee13d13SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9ee13d13SAndrew Rist  * software distributed under the License is distributed on an
15*9ee13d13SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9ee13d13SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9ee13d13SAndrew Rist  * specific language governing permissions and limitations
18*9ee13d13SAndrew Rist  * under the License.
19*9ee13d13SAndrew Rist  *
20*9ee13d13SAndrew Rist  *************************************************************/
21*9ee13d13SAndrew Rist 
22*9ee13d13SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef CONDITIONALEXPRESSION_HXX
25cdf0e10cSrcweir #define CONDITIONALEXPRESSION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "dllapi.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir /** === begin UNO includes === **/
30cdf0e10cSrcweir /** === end UNO includes === **/
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <rtl/ustring.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <map>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //........................................................................
39cdf0e10cSrcweir namespace rptui
40cdf0e10cSrcweir {
41cdf0e10cSrcweir //........................................................................
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     // =============================================================================
44cdf0e10cSrcweir     // = ConditionalExpression
45cdf0e10cSrcweir     // =============================================================================
46cdf0e10cSrcweir     class REPORTDESIGN_DLLPUBLIC ConditionalExpression
47cdf0e10cSrcweir     {
48cdf0e10cSrcweir     private:
49cdf0e10cSrcweir         const ::rtl::OUString       m_sPattern;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     public:
52cdf0e10cSrcweir         ConditionalExpression( const sal_Char* _pAsciiPattern );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir         /** assembles an expression string from a field data source, and one or two operands
55cdf0e10cSrcweir         */
56cdf0e10cSrcweir         ::rtl::OUString     assembleExpression( const ::rtl::OUString& _rFieldDataSource, const ::rtl::OUString& _rLHS, const ::rtl::OUString& _rRHS ) const;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir         /** matches the given expression string to the expression pattern represented by the object
59cdf0e10cSrcweir             @param  _rExpression
60cdf0e10cSrcweir                 the expression to match
61cdf0e10cSrcweir             @param  _rFieldDataSource
62cdf0e10cSrcweir                 the field data source
63cdf0e10cSrcweir             @param  _out_rLHS
64cdf0e10cSrcweir                 output parameter taking the left hand side operand, if successful
65cdf0e10cSrcweir             @param  _out_rRHS
66cdf0e10cSrcweir                 output parameter taking the right hand side operand, if successful
67cdf0e10cSrcweir             @return
68cdf0e10cSrcweir                 <TRUE/> if and only if the expression string could be successfully matched to
69cdf0e10cSrcweir                 the pattern.
70cdf0e10cSrcweir         */
71cdf0e10cSrcweir         bool                matchExpression( const ::rtl::OUString& _rExpression, const ::rtl::OUString& _rFieldDataSource, ::rtl::OUString& _out_rLHS, ::rtl::OUString& _out_rRHS ) const;
72cdf0e10cSrcweir     };
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     //========================================================================
75cdf0e10cSrcweir     //= ConditionType
76cdf0e10cSrcweir     //========================================================================
77cdf0e10cSrcweir     enum ConditionType
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         eFieldValueComparison   = 0,
80cdf0e10cSrcweir         eExpression             = 1
81cdf0e10cSrcweir     };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     //========================================================================
84cdf0e10cSrcweir     //= ComparisonOperation
85cdf0e10cSrcweir     //========================================================================
86cdf0e10cSrcweir     enum ComparisonOperation
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         eBetween        = 0,
89cdf0e10cSrcweir         eNotBetween     = 1,
90cdf0e10cSrcweir         eEqualTo        = 2,
91cdf0e10cSrcweir         eNotEqualTo     = 3,
92cdf0e10cSrcweir         eGreaterThan    = 4,
93cdf0e10cSrcweir         eLessThan       = 5,
94cdf0e10cSrcweir         eGreaterOrEqual = 6,
95cdf0e10cSrcweir         eLessOrEqual    = 7
96cdf0e10cSrcweir     };
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     typedef ::boost::shared_ptr< ConditionalExpression >                PConditionalExpression;
99cdf0e10cSrcweir     typedef ::std::map< ComparisonOperation, PConditionalExpression >   ConditionalExpressions;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     // =============================================================================
102cdf0e10cSrcweir     // = ConditionalExpressionFactory
103cdf0e10cSrcweir     // =============================================================================
104cdf0e10cSrcweir     class REPORTDESIGN_DLLPUBLIC ConditionalExpressionFactory
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir     public:
107cdf0e10cSrcweir         /// fills the given map with all ConditionalExpressions which we know
108cdf0e10cSrcweir         static size_t  getKnownConditionalExpressions( ConditionalExpressions& _out_rCondExp );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     private:
111cdf0e10cSrcweir         ConditionalExpressionFactory();                                                 // never implemented
112cdf0e10cSrcweir         ConditionalExpressionFactory( const ConditionalExpressionFactory& );            // never implemented
113cdf0e10cSrcweir         ConditionalExpressionFactory& operator=( const ConditionalExpressionFactory& ); // never implemented
114cdf0e10cSrcweir     };
115cdf0e10cSrcweir //........................................................................
116cdf0e10cSrcweir } // namespace rptui
117cdf0e10cSrcweir //........................................................................
118cdf0e10cSrcweir 
119cdf0e10cSrcweir #endif // CONDITIONALEXPRESSION_HXX
120