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 REPORTFORMULA_HXX 29 #define REPORTFORMULA_HXX 30 31 #include "dllapi.h" 32 33 /** === begin UNO includes === **/ 34 #include <com/sun/star/uno/Any.hxx> 35 /** === end UNO includes === **/ 36 37 #include <osl/diagnose.h> 38 39 //........................................................................ 40 namespace rptui 41 { 42 //........................................................................ 43 44 //==================================================================== 45 //= ReportFormula 46 //==================================================================== 47 class REPORTDESIGN_DLLPUBLIC ReportFormula 48 { 49 public: 50 enum BindType 51 { 52 Expression, 53 Field, 54 55 Invalid 56 }; 57 58 private: 59 BindType m_eType; 60 ::rtl::OUString m_sCompleteFormula; 61 ::rtl::OUString m_sUndecoratedContent; 62 63 public: 64 /// constructs a ReportFormula object from a string 65 ReportFormula( const ::rtl::OUString& _rFormula ); 66 67 /// constructs a ReportFormula by BindType 68 ReportFormula( const BindType _eType, const ::rtl::OUString& _rFieldOrExpression ); 69 ~ReportFormula(); 70 71 ReportFormula& operator=(class ReportFormula const &); 72 73 /// returns whether the object denotes a valid formula 74 bool isValid() const; 75 76 /// returns the type of the binding represented by the formula 77 inline BindType getType() const { return m_eType; } 78 79 /// returns the complete formula represented by the object 80 const ::rtl::OUString& 81 getCompleteFormula() const; 82 83 /** gets the <em>undecorated formula</em> content 84 85 If the formula denotes a field binding, the <em>undecorated content</em> is the 86 field name. 87 88 If the formula denotes an expression, then the <em>undecorated content</em> is the expression 89 itself. 90 */ 91 const ::rtl::OUString& getUndecoratedContent() const;// { return m_sUndecoratedContent; } 92 93 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on an expression 94 inline ::rtl::OUString getFieldName() const; 95 96 /** 97 @returns "=" + getFieldName() 98 */ 99 ::rtl::OUString getEqualUndecoratedContent() const; 100 101 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on a field 102 inline ::rtl::OUString getExpression() const; 103 104 /** returns a bracketed field name of the formula denotes a field reference, 105 or the undecorated expression if the formula denotes an expression. 106 107 Effectively, this means the method returns the complete formular, stripped by the prefix 108 which indicates a field or a expression. 109 */ 110 ::rtl::OUString getBracketedFieldOrExpression() const; 111 112 private: 113 void impl_construct( const ::rtl::OUString& _rFormula ); 114 }; 115 116 //-------------------------------------------------------------------- 117 inline ::rtl::OUString ReportFormula::getFieldName() const 118 { 119 OSL_PRECOND( getType() == Field, "ReportFormula::getFieldName: not bound to a field!" ); 120 return getUndecoratedContent(); 121 } 122 123 //-------------------------------------------------------------------- 124 inline ::rtl::OUString ReportFormula::getExpression() const 125 { 126 OSL_PRECOND( getType() == Expression, "ReportFormula::getExpression: not bound to an expression!" ); 127 return getUndecoratedContent(); 128 } 129 130 //........................................................................ 131 } // namespace rptui 132 //........................................................................ 133 134 #endif // REPORTFORMULA_HXX 135