bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / inc / reportformula.hxx
blob506ec8f0d7c75e1777deef10b36192b367f09a1d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_REPORTDESIGN_INC_REPORTFORMULA_HXX
21 #define INCLUDED_REPORTDESIGN_INC_REPORTFORMULA_HXX
23 #include "dllapi.h"
25 #include <com/sun/star/uno/Any.hxx>
27 #include <osl/diagnose.h>
30 namespace rptui
35 //= ReportFormula
37 class REPORTDESIGN_DLLPUBLIC ReportFormula
39 public:
40 enum BindType
42 Expression,
43 Field,
45 Invalid
48 private:
49 BindType m_eType;
50 OUString m_sCompleteFormula;
51 OUString m_sUndecoratedContent;
53 public:
54 /// constructs a ReportFormula object from a string
55 ReportFormula( const OUString& _rFormula );
57 /// constructs a ReportFormula by BindType
58 ReportFormula( const BindType _eType, const OUString& _rFieldOrExpression );
59 ~ReportFormula();
61 ReportFormula& operator=(class ReportFormula const &);
63 /// returns whether the object denotes a valid formula
64 bool isValid() const;
66 /// returns the type of the binding represented by the formula
67 inline BindType getType() const { return m_eType; }
69 /// returns the complete formula represented by the object
70 const OUString&
71 getCompleteFormula() const { return m_sCompleteFormula; }
73 /** gets the <em>undecorated formula</em> content
75 If the formula denotes a field binding, the <em>undecorated content</em> is the
76 field name.
78 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
79 itself.
81 const OUString& getUndecoratedContent() const { return m_sUndecoratedContent; }
83 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on an expression
84 inline OUString getFieldName() const;
86 /**
87 @returns "=" + getFieldName()
89 OUString getEqualUndecoratedContent() const;
91 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on a field
92 inline OUString getExpression() const;
94 /** returns a bracketed field name of the formula denotes a field reference,
95 or the undecorated expression if the formula denotes an expression.
97 Effectively, this means the method returns the complete formular, stripped by the prefix
98 which indicates a field or a expression.
100 OUString getBracketedFieldOrExpression() const;
102 private:
103 void impl_construct( const OUString& _rFormula );
107 inline OUString ReportFormula::getFieldName() const
109 OSL_PRECOND( getType() == Field, "ReportFormula::getFieldName: not bound to a field!" );
110 return getUndecoratedContent();
114 inline OUString ReportFormula::getExpression() const
116 OSL_PRECOND( getType() == Expression, "ReportFormula::getExpression: not bound to an expression!" );
117 return getUndecoratedContent();
121 } // namespace rptui
124 #endif // INCLUDED_REPORTDESIGN_INC_REPORTFORMULA_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */