1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <config_options.h>
26 #include <osl/diagnose.h>
27 #include <rtl/ustring.hxx>
36 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC
) ReportFormula
49 OUString m_sCompleteFormula
;
50 OUString m_sUndecoratedContent
;
53 /// constructs a ReportFormula object from a string
54 ReportFormula( const OUString
& _rFormula
);
56 /// constructs a ReportFormula by BindType
57 ReportFormula( const BindType _eType
, const OUString
& _rFieldOrExpression
);
60 /// returns whether the object denotes a valid formula
63 /// returns the type of the binding represented by the formula
64 BindType
getType() const { return m_eType
; }
66 /// returns the complete formula represented by the object
68 getCompleteFormula() const { return m_sCompleteFormula
; }
70 /** gets the <em>undecorated formula</em> content
72 If the formula denotes a field binding, the <em>undecorated content</em> is the
75 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
78 const OUString
& getUndecoratedContent() const { return m_sUndecoratedContent
; }
80 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on an expression
81 inline OUString
const & getFieldName() const;
84 @returns "=" + getFieldName()
86 OUString
getEqualUndecoratedContent() const;
88 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on a field
89 inline OUString
const & getExpression() const;
91 /** returns a bracketed field name of the formula denotes a field reference,
92 or the undecorated expression if the formula denotes an expression.
94 Effectively, this means the method returns the complete formula, stripped by the prefix
95 which indicates a field or an expression.
97 OUString
getBracketedFieldOrExpression() const;
101 inline OUString
const & ReportFormula::getFieldName() const
103 OSL_PRECOND( getType() == Field
, "ReportFormula::getFieldName: not bound to a field!" );
104 return getUndecoratedContent();
108 inline OUString
const & ReportFormula::getExpression() const
110 OSL_PRECOND( getType() == Expression
, "ReportFormula::getExpression: not bound to an expression!" );
111 return getUndecoratedContent();
118 #endif // INCLUDED_REPORTDESIGN_INC_REPORTFORMULA_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */