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