merged tag ooo/OOO330_m14
[LibreOffice.git] / reportdesign / inc / reportformula.hxx
blobfa809d237c7581065ae5053dfccd89560c18e3e3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef REPORTFORMULA_HXX
29 #define REPORTFORMULA_HXX
31 #include "dllapi.h"
33 /** === begin UNO includes === **/
34 #include <com/sun/star/uno/Any.hxx>
35 /** === end UNO includes === **/
37 #include <osl/diagnose.h>
39 //........................................................................
40 namespace rptui
42 //........................................................................
44 //====================================================================
45 //= ReportFormula
46 //====================================================================
47 class REPORTDESIGN_DLLPUBLIC ReportFormula
49 public:
50 enum BindType
52 Expression,
53 Field,
55 Invalid
58 private:
59 BindType m_eType;
60 ::rtl::OUString m_sCompleteFormula;
61 ::rtl::OUString m_sUndecoratedContent;
63 public:
64 /// constructs a ReportFormula object from a string
65 ReportFormula( const ::rtl::OUString& _rFormula );
67 /// constructs a ReportFormula by BindType
68 ReportFormula( const BindType _eType, const ::rtl::OUString& _rFieldOrExpression );
69 ~ReportFormula();
71 ReportFormula& operator=(class ReportFormula const &);
73 /// returns whether the object denotes a valid formula
74 bool isValid() const;
76 /// returns the type of the binding represented by the formula
77 inline BindType getType() const { return m_eType; }
79 /// returns the complete formula represented by the object
80 const ::rtl::OUString&
81 getCompleteFormula() const;
83 /** gets the <em>undecorated formula</em> content
85 If the formula denotes a field binding, the <em>undecorated content</em> is the
86 field name.
88 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
89 itself.
91 const ::rtl::OUString& getUndecoratedContent() const;// { return m_sUndecoratedContent; }
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;
96 /**
97 @returns "=" + getFieldName()
99 ::rtl::OUString getEqualUndecoratedContent() const;
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;
104 /** returns a bracketed field name of the formula denotes a field reference,
105 or the undecorated expression if the formula denotes an expression.
107 Effectively, this means the method returns the complete formular, stripped by the prefix
108 which indicates a field or a expression.
110 ::rtl::OUString getBracketedFieldOrExpression() const;
112 private:
113 void impl_construct( const ::rtl::OUString& _rFormula );
116 //--------------------------------------------------------------------
117 inline ::rtl::OUString ReportFormula::getFieldName() const
119 OSL_PRECOND( getType() == Field, "ReportFormula::getFieldName: not bound to a field!" );
120 return getUndecoratedContent();
123 //--------------------------------------------------------------------
124 inline ::rtl::OUString ReportFormula::getExpression() const
126 OSL_PRECOND( getType() == Expression, "ReportFormula::getExpression: not bound to an expression!" );
127 return getUndecoratedContent();
130 //........................................................................
131 } // namespace rptui
132 //........................................................................
134 #endif // REPORTFORMULA_HXX