Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef REPORTFORMULA_HXX
30 : : #define REPORTFORMULA_HXX
31 : :
32 : : #include "dllapi.h"
33 : :
34 : : #include <com/sun/star/uno/Any.hxx>
35 : :
36 : : #include <osl/diagnose.h>
37 : :
38 : : //........................................................................
39 : : namespace rptui
40 : : {
41 : : //........................................................................
42 : :
43 : : //====================================================================
44 : : //= ReportFormula
45 : : //====================================================================
46 : : class REPORTDESIGN_DLLPUBLIC ReportFormula
47 : : {
48 : : public:
49 : : enum BindType
50 : : {
51 : : Expression,
52 : : Field,
53 : :
54 : : Invalid
55 : : };
56 : :
57 : : private:
58 : : BindType m_eType;
59 : : ::rtl::OUString m_sCompleteFormula;
60 : : ::rtl::OUString m_sUndecoratedContent;
61 : :
62 : : public:
63 : : /// constructs a ReportFormula object from a string
64 : : ReportFormula( const ::rtl::OUString& _rFormula );
65 : :
66 : : /// constructs a ReportFormula by BindType
67 : : ReportFormula( const BindType _eType, const ::rtl::OUString& _rFieldOrExpression );
68 : : ~ReportFormula();
69 : :
70 : : ReportFormula& operator=(class ReportFormula const &);
71 : :
72 : : /// returns whether the object denotes a valid formula
73 : : bool isValid() const;
74 : :
75 : : /// returns the type of the binding represented by the formula
76 : 0 : inline BindType getType() const { return m_eType; }
77 : :
78 : : /// returns the complete formula represented by the object
79 : : const ::rtl::OUString&
80 : : getCompleteFormula() const;
81 : :
82 : : /** gets the <em>undecorated formula</em> content
83 : :
84 : : If the formula denotes a field binding, the <em>undecorated content</em> is the
85 : : field name.
86 : :
87 : : If the formula denotes an expression, then the <em>undecorated content</em> is the expression
88 : : itself.
89 : : */
90 : : const ::rtl::OUString& getUndecoratedContent() const;
91 : :
92 : : /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on an expression
93 : : inline ::rtl::OUString getFieldName() const;
94 : :
95 : : /**
96 : : @returns "=" + getFieldName()
97 : : */
98 : : ::rtl::OUString getEqualUndecoratedContent() const;
99 : :
100 : : /// convenience alias for <code>getUndecoratedContent</code>, which asserts (in a non-product build) when used on a field
101 : : inline ::rtl::OUString getExpression() const;
102 : :
103 : : /** returns a bracketed field name of the formula denotes a field reference,
104 : : or the undecorated expression if the formula denotes an expression.
105 : :
106 : : Effectively, this means the method returns the complete formular, stripped by the prefix
107 : : which indicates a field or a expression.
108 : : */
109 : : ::rtl::OUString getBracketedFieldOrExpression() const;
110 : :
111 : : private:
112 : : void impl_construct( const ::rtl::OUString& _rFormula );
113 : : };
114 : :
115 : : //--------------------------------------------------------------------
116 : 0 : inline ::rtl::OUString ReportFormula::getFieldName() const
117 : : {
118 : : OSL_PRECOND( getType() == Field, "ReportFormula::getFieldName: not bound to a field!" );
119 : 0 : return getUndecoratedContent();
120 : : }
121 : :
122 : : //--------------------------------------------------------------------
123 : 0 : inline ::rtl::OUString ReportFormula::getExpression() const
124 : : {
125 : : OSL_PRECOND( getType() == Expression, "ReportFormula::getExpression: not bound to an expression!" );
126 : 0 : return getUndecoratedContent();
127 : : }
128 : :
129 : : //........................................................................
130 : : } // namespace rptui
131 : : //........................................................................
132 : :
133 : : #endif // REPORTFORMULA_HXX
134 : :
135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|