merge the formfield patch from ooo-build
[ooovba.git] / reportdesign / inc / reportformula.hxx
blob2f73fd7e420277f61baef141db61472434de395f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: reportformula.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef REPORTFORMULA_HXX
32 #define REPORTFORMULA_HXX
34 #include "dllapi.h"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/uno/Any.hxx>
38 /** === end UNO includes === **/
40 #include <osl/diagnose.h>
42 //........................................................................
43 namespace rptui
45 //........................................................................
47 //====================================================================
48 //= ReportFormula
49 //====================================================================
50 class REPORTDESIGN_DLLPUBLIC ReportFormula
52 public:
53 enum BindType
55 Expression,
56 Field,
58 Invalid
61 private:
62 BindType m_eType;
63 ::rtl::OUString m_sCompleteFormula;
64 ::rtl::OUString m_sUndecoratedContent;
66 public:
67 // constructs a ReportFormula instance which is initially invalid.
68 ReportFormula();
70 /// constructs a ReportFormula object from a string
71 ReportFormula( const ::rtl::OUString& _rFormula );
73 /// constructs a ReportFormula by BindType
74 ReportFormula( const BindType _eType, const ::rtl::OUString& _rFieldOrExpression );
75 ~ReportFormula();
77 ReportFormula& operator=(class ReportFormula const &);
79 /// returns whether the object denotes a valid formula
80 bool isValid() const;
82 /// returns the type of the binding represented by the formula
83 inline BindType getType() const { return m_eType; }
85 /// returns the complete formula represented by the object
86 const ::rtl::OUString&
87 getCompleteFormula() const;
89 /** gets the <em>undecorated formula</em> content
91 If the formula denotes a field binding, the <em>undecorated content</em> is the
92 field name.
94 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
95 itself.
97 const ::rtl::OUString& getUndecoratedContent() const;// { return m_sUndecoratedContent; }
99 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on an expression
100 inline ::rtl::OUString getFieldName() const;
103 @returns "=" + getFieldName()
105 ::rtl::OUString getEqualUndecoratedContent() const;
107 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on a field
108 inline ::rtl::OUString getExpression() const;
110 /** returns a bracketed field name of the formula denotes a field reference,
111 or the undecorated expression if the formula denotes an expression.
113 Effectively, this means the method returns the complete formular, stripped by the prefix
114 which indicates a field or a expression.
116 ::rtl::OUString getBracketedFieldOrExpression() const;
118 private:
119 void impl_construct( const ::rtl::OUString& _rFormula );
122 //--------------------------------------------------------------------
123 inline ::rtl::OUString ReportFormula::getFieldName() const
125 OSL_PRECOND( getType() == Field, "ReportFormula::getFieldName: not bound to a field!" );
126 return getUndecoratedContent();
129 //--------------------------------------------------------------------
130 inline ::rtl::OUString ReportFormula::getExpression() const
132 OSL_PRECOND( getType() == Expression, "ReportFormula::getExpression: not bound to an expression!" );
133 return getUndecoratedContent();
136 //........................................................................
137 } // namespace rptui
138 //........................................................................
140 #endif // REPORTFORMULA_HXX