1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: reportformula.hxx,v $
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
36 /** === begin UNO includes === **/
37 #include <com/sun/star/uno/Any.hxx>
38 /** === end UNO includes === **/
40 #include <osl/diagnose.h>
42 //........................................................................
45 //........................................................................
47 //====================================================================
49 //====================================================================
50 class REPORTDESIGN_DLLPUBLIC ReportFormula
63 ::rtl::OUString m_sCompleteFormula
;
64 ::rtl::OUString m_sUndecoratedContent
;
67 // constructs a ReportFormula instance which is initially invalid.
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
);
77 ReportFormula
& operator=(class ReportFormula
const &);
79 /// returns whether the object denotes a valid formula
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
94 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
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;
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 //........................................................................
138 //........................................................................
140 #endif // REPORTFORMULA_HXX