1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef CONDITIONALEXPRESSION_HXX 29 #define CONDITIONALEXPRESSION_HXX 30 31 #include "dllapi.h" 32 33 /** === begin UNO includes === **/ 34 /** === end UNO includes === **/ 35 36 #include <rtl/ustring.hxx> 37 38 #include <boost/shared_ptr.hpp> 39 40 #include <map> 41 42 //........................................................................ 43 namespace rptui 44 { 45 //........................................................................ 46 47 // ============================================================================= 48 // = ConditionalExpression 49 // ============================================================================= 50 class REPORTDESIGN_DLLPUBLIC ConditionalExpression 51 { 52 private: 53 const ::rtl::OUString m_sPattern; 54 55 public: 56 ConditionalExpression( const sal_Char* _pAsciiPattern ); 57 58 /** assembles an expression string from a field data source, and one or two operands 59 */ 60 ::rtl::OUString assembleExpression( const ::rtl::OUString& _rFieldDataSource, const ::rtl::OUString& _rLHS, const ::rtl::OUString& _rRHS ) const; 61 62 /** matches the given expression string to the expression pattern represented by the object 63 @param _rExpression 64 the expression to match 65 @param _rFieldDataSource 66 the field data source 67 @param _out_rLHS 68 output parameter taking the left hand side operand, if successful 69 @param _out_rRHS 70 output parameter taking the right hand side operand, if successful 71 @return 72 <TRUE/> if and only if the expression string could be successfully matched to 73 the pattern. 74 */ 75 bool matchExpression( const ::rtl::OUString& _rExpression, const ::rtl::OUString& _rFieldDataSource, ::rtl::OUString& _out_rLHS, ::rtl::OUString& _out_rRHS ) const; 76 }; 77 78 //======================================================================== 79 //= ConditionType 80 //======================================================================== 81 enum ConditionType 82 { 83 eFieldValueComparison = 0, 84 eExpression = 1 85 }; 86 87 //======================================================================== 88 //= ComparisonOperation 89 //======================================================================== 90 enum ComparisonOperation 91 { 92 eBetween = 0, 93 eNotBetween = 1, 94 eEqualTo = 2, 95 eNotEqualTo = 3, 96 eGreaterThan = 4, 97 eLessThan = 5, 98 eGreaterOrEqual = 6, 99 eLessOrEqual = 7 100 }; 101 102 typedef ::boost::shared_ptr< ConditionalExpression > PConditionalExpression; 103 typedef ::std::map< ComparisonOperation, PConditionalExpression > ConditionalExpressions; 104 105 // ============================================================================= 106 // = ConditionalExpressionFactory 107 // ============================================================================= 108 class REPORTDESIGN_DLLPUBLIC ConditionalExpressionFactory 109 { 110 public: 111 /// fills the given map with all ConditionalExpressions which we know 112 static size_t getKnownConditionalExpressions( ConditionalExpressions& _out_rCondExp ); 113 114 private: 115 ConditionalExpressionFactory(); // never implemented 116 ConditionalExpressionFactory( const ConditionalExpressionFactory& ); // never implemented 117 ConditionalExpressionFactory& operator=( const ConditionalExpressionFactory& ); // never implemented 118 }; 119 //........................................................................ 120 } // namespace rptui 121 //........................................................................ 122 123 #endif // CONDITIONALEXPRESSION_HXX 124