tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / reportdesign / inc / reportformula.hxx
blobafb123b297c6c83893721063b93c8439c6cd27ec
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 <config_options.h>
24 #include "dllapi.h"
26 #include <osl/diagnose.h>
27 #include <rtl/ustring.hxx>
30 namespace rptui
34 //= ReportFormula
36 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC) ReportFormula
38 public:
39 enum BindType
41 Expression,
42 Field,
44 Invalid
47 private:
48 BindType m_eType;
49 OUString m_sCompleteFormula;
50 OUString m_sUndecoratedContent;
52 public:
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 );
58 ~ReportFormula();
60 /// returns whether the object denotes a valid formula
61 bool isValid() const;
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
67 const OUString&
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
73 field name.
75 If the formula denotes an expression, then the <em>undecorated content</em> is the expression
76 itself.
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;
83 /**
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();
115 } // namespace rptui
118 #endif // INCLUDED_REPORTDESIGN_INC_REPORTFORMULA_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */