LibreOffice Module forms (master) 1
computedexpression.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <rtl/ustring.hxx>
23#include <com/sun/star/uno/Reference.hxx>
24
25// forward declaractions
26namespace com::sun::star
27{
28 namespace xml
29 {
30 namespace dom { class XNode; }
31 namespace dom { class XNodeset; }
32 namespace xpath { class XXPathAPI; }
33 namespace xpath { class XXPathObject; }
34 }
35 namespace container { class XNameContainer; }
36}
37namespace xforms { class EvaluationContext; }
38
39
40namespace xforms
41{
42
48{
50 OUString msExpression;
51
54
55protected:
58
60 css::uno::Reference<css::xml::xpath::XXPathObject> mxResult;
61
62
64 bool _checkExpression( const char* pExpression ) const;
65
67 // the default implementation is to do nothing...
68 const OUString& _getExpressionForEvaluation() const { return msExpression; }
69
71 static css::uno::Reference<css::xml::xpath::XXPathAPI> _getXPathAPI(const xforms::EvaluationContext& aContext);
72
74 bool _evaluate( const xforms::EvaluationContext& rContext,
75 const OUString& sExpression );
76
77
78public:
81
82
84 const OUString& getExpression() const { return msExpression;}
85
87 void setExpression( const OUString& rExpression );
88
90 bool isEmptyExpression() const { return mbIsEmpty;}
91
95 bool isSimpleExpression() const;
96
97
99 bool evaluate( const xforms::EvaluationContext& rContext );
100
101
103 bool hasValue() const;
104
105
107 void clear();
108
109
110 // get the result of this expression as string/bool/...
111 // (Results will be based on the last call of evaluate(..). The caller
112 // must call evaluate to ensure current results.)
113 css::uno::Reference<css::xml::xpath::XXPathObject> const & getXPath() const { return mxResult;}
114 bool getBool( bool bDefault = false ) const;
115 OUString getString() const;
116
117};
118
119} // namespace xforms
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ComputedExpression represents an XPath Expression and caches results.
bool isSimpleExpression() const
heuristically determine whether this expression is 'simple', i.e.
css::uno::Reference< css::xml::xpath::XXPathObject > const & getXPath() const
const OUString & getExpression() const
get the expression string
css::uno::Reference< css::xml::xpath::XXPathObject > mxResult
the result from the last bind
bool isEmptyExpression() const
do we have an actual expression?
OUString msExpression
the expression string
bool getBool(bool bDefault=false) const
bool mbIsEmpty
is msExpression empty?
static css::uno::Reference< css::xml::xpath::XXPathAPI > _getXPathAPI(const xforms::EvaluationContext &aContext)
obtain a (suitable) XPathAPI implementation
const OUString & _getExpressionForEvaluation() const
allow manipulation of the expression before it is evaluated
bool hasValue() const
does this expression have a value?
bool _checkExpression(const char *pExpression) const
implementation of isSimpleExpression
bool mbIsSimple
is msExpression a simple expression?
void clear()
remove value/evaluate results
bool evaluate(const xforms::EvaluationContext &rContext)
evaluate the expression relative to the content node.
bool _evaluate(const xforms::EvaluationContext &rContext, const OUString &sExpression)
evaluate the expression relative to the content node.
void setExpression(const OUString &rExpression)
set a new expression string
define the context for the evaluation of an XPath expression