Update ooo320-m1
[ooovba.git] / forms / source / xforms / computedexpression.hxx
blob9e1a68e5e387b4dea22aaa208684084c82bec263
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: computedexpression.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _COMPUTEDEXPRESSION_HXX
32 #define _COMPUTEDEXPRESSION_HXX
35 // includes for member variables
36 #include <rtl/ustring.hxx>
37 #include <com/sun/star/uno/Reference.hxx>
39 // forward declaractions
40 namespace com { namespace sun { namespace star
42 namespace xml
44 namespace dom { class XNode; }
45 namespace dom { class XNodeset; }
46 namespace xpath { class XXPathAPI; }
47 namespace xpath { class XXPathObject; }
49 namespace container { class XNameContainer; }
50 } } }
51 namespace xforms { class EvaluationContext; }
55 namespace xforms
58 /** ComputedExpression represents an XPath Expression and caches results.
60 * As this class has no virtual methods, it should never be used
61 * polymorphically. */
62 class ComputedExpression
64 /// the expression string
65 rtl::OUString msExpression;
67 /// is msExpression empty?
68 bool mbIsEmpty;
70 protected:
71 /// is msExpression a simple expression?
72 bool mbIsSimple;
74 /// the result from the last bind
75 com::sun::star::uno::Reference<com::sun::star::xml::xpath::XXPathObject> mxResult;
78 /// implementation of isSimpleExpression
79 bool _checkExpression( const sal_Char* pExpression ) const;
81 /// allow manipulation of the expression before it is evaluated
82 const rtl::OUString _getExpressionForEvaluation() const;
84 /// obtain a (suitable) XPathAPI implementation
85 com::sun::star::uno::Reference<com::sun::star::xml::xpath::XXPathAPI> _getXPathAPI(const xforms::EvaluationContext& aContext);
87 /// evaluate the expression relative to the content node.
88 bool _evaluate( const xforms::EvaluationContext& rContext,
89 const rtl::OUString& sExpression );
92 public:
93 ComputedExpression();
94 ~ComputedExpression();
97 /// get the expression string
98 rtl::OUString getExpression() const;
100 /// set a new expression string
101 void setExpression( const rtl::OUString& rExpression );
103 /// get the namespaces that are used to interpret the expression string
104 com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> getNamespaces() const;
106 /// set the namespaces that are used to interpret the expression string
107 void setNamespaces( const com::sun::star::uno::Reference<com::sun::star::container::XNameContainer>& );
109 /// do we have an actual expression?
110 bool isEmptyExpression() const;
112 /// heuristically determine whether this expression is 'simple',
113 /// i.e. whether its value will change depending on the values
114 /// of other nodes
115 bool isSimpleExpression() const;
118 /// evaluate the expression relative to the content node.
119 bool evaluate( const xforms::EvaluationContext& rContext );
122 /// does this expression have a value?
123 bool hasValue() const;
126 /// remove value/evaluate results
127 void clear();
130 // get the result of this expression as string/bool/...
131 // (Results will be based on the last call of evaluate(..). The caller
132 // must call evaluate to ensure current results.)
133 com::sun::star::uno::Reference<com::sun::star::xml::xpath::XXPathObject> getXPath();
134 bool getBool( bool bDefault = false ) const;
135 rtl::OUString getString( const rtl::OUString& rDefault = rtl::OUString() ) const;
139 } // namespace xforms
141 #endif