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
25 #include <osl/diagnose.h>
26 #include <rtl/ustring.hxx>
35 class REPORTDESIGN_DLLPUBLIC ReportFormula
48 OUString m_sCompleteFormula
;
49 OUString m_sUndecoratedContent
;
52 /// constructs a ReportFormula object from a string
53 ReportFormula( const OUString
& _rFormula
);
55 /// constructs a ReportFormula by BindType
56 ReportFormula( const BindType _eType
, const OUString
& _rFieldOrExpression
);
59 /// returns whether the object denotes a valid formula
62 /// returns the type of the binding represented by the formula
63 BindType
getType() const { return m_eType
; }
65 /// returns the complete formula represented by the object
67 getCompleteFormula() const { return m_sCompleteFormula
; }
69 /** gets the <em>undecorated formula</em> content
71 If the formula denotes a field binding, the <em>undecorated content</em> is the
74 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
77 const OUString
& getUndecoratedContent() const { return m_sUndecoratedContent
; }
79 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on an expression
80 inline OUString
getFieldName() const;
83 @returns "=" + getFieldName()
85 OUString
getEqualUndecoratedContent() const;
87 /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on a field
88 inline OUString
getExpression() const;
90 /** returns a bracketed field name of the formula denotes a field reference,
91 or the undecorated expression if the formula denotes an expression.
93 Effectively, this means the method returns the complete formular, stripped by the prefix
94 which indicates a field or a expression.
96 OUString
getBracketedFieldOrExpression() const;
99 void impl_construct( const OUString
& _rFormula
);
103 inline OUString
ReportFormula::getFieldName() const
105 OSL_PRECOND( getType() == Field
, "ReportFormula::getFieldName: not bound to a field!" );
106 return getUndecoratedContent();
110 inline OUString
ReportFormula::getExpression() const
112 OSL_PRECOND( getType() == Expression
, "ReportFormula::getExpression: not bound to an expression!" );
113 return getUndecoratedContent();
120 #endif // INCLUDED_REPORTDESIGN_INC_REPORTFORMULA_HXX
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */