bump product version to 4.1.6.2
[LibreOffice.git] / forms / source / xforms / computedexpression.hxx
blob876ef3c25fb5217754c052ab5449e3c228cea7dd
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 _COMPUTEDEXPRESSION_HXX
21 #define _COMPUTEDEXPRESSION_HXX
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
26 // forward declaractions
27 namespace com { namespace sun { namespace star
29 namespace xml
31 namespace dom { class XNode; }
32 namespace dom { class XNodeset; }
33 namespace xpath { class XXPathAPI; }
34 namespace xpath { class XXPathObject; }
36 namespace container { class XNameContainer; }
37 } } }
38 namespace xforms { class EvaluationContext; }
42 namespace xforms
45 /** ComputedExpression represents an XPath Expression and caches results.
47 * As this class has no virtual methods, it should never be used
48 * polymorphically. */
49 class ComputedExpression
51 /// the expression string
52 OUString msExpression;
54 /// is msExpression empty?
55 bool mbIsEmpty;
57 protected:
58 /// is msExpression a simple expression?
59 bool mbIsSimple;
61 /// the result from the last bind
62 com::sun::star::uno::Reference<com::sun::star::xml::xpath::XXPathObject> mxResult;
65 /// implementation of isSimpleExpression
66 bool _checkExpression( const sal_Char* pExpression ) const;
68 /// allow manipulation of the expression before it is evaluated
69 const OUString _getExpressionForEvaluation() const;
71 /// obtain a (suitable) XPathAPI implementation
72 com::sun::star::uno::Reference<com::sun::star::xml::xpath::XXPathAPI> _getXPathAPI(const xforms::EvaluationContext& aContext);
74 /// evaluate the expression relative to the content node.
75 bool _evaluate( const xforms::EvaluationContext& rContext,
76 const OUString& sExpression );
79 public:
80 ComputedExpression();
81 ~ComputedExpression();
84 /// get the expression string
85 OUString getExpression() const;
87 /// set a new expression string
88 void setExpression( const OUString& rExpression );
90 /// get the namespaces that are used to interpret the expression string
91 com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> getNamespaces() const;
93 /// set the namespaces that are used to interpret the expression string
94 void setNamespaces( const com::sun::star::uno::Reference<com::sun::star::container::XNameContainer>& );
96 /// do we have an actual expression?
97 bool isEmptyExpression() const;
99 /// heuristically determine whether this expression is 'simple',
100 /// i.e. whether its value will change depending on the values
101 /// of other nodes
102 bool isSimpleExpression() const;
105 /// evaluate the expression relative to the content node.
106 bool evaluate( const xforms::EvaluationContext& rContext );
109 /// does this expression have a value?
110 bool hasValue() const;
113 /// remove value/evaluate results
114 void clear();
117 // get the result of this expression as string/bool/...
118 // (Results will be based on the last call of evaluate(..). The caller
119 // must call evaluate to ensure current results.)
120 com::sun::star::uno::Reference<com::sun::star::xml::xpath::XXPathObject> getXPath() const;
121 bool getBool( bool bDefault = false ) const;
122 OUString getString( const OUString& rDefault = OUString() ) const;
126 } // namespace xforms
128 #endif
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */