LibreOffice Module forms (master) 1
extension.cxx
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
21#include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
22#include <com/sun/star/beans/NamedValue.hpp>
23#include "extension.hxx"
24#include "xpathlib.hxx"
25
26namespace com::sun::star::uno {
27 class XComponentContext;
28}
29
30using namespace com::sun::star::uno;
31using namespace com::sun::star::lang;
32using namespace com::sun::star::xforms;
33using namespace com::sun::star::xml::xpath;
34using namespace com::sun::star::beans;
35
37{
38 Libxml2ExtensionHandle aHandle;
39 aHandle.functionLookupFunction = reinterpret_cast< sal_Int64 >( &xforms_lookupFunc );
40 aHandle.functionData = reinterpret_cast< sal_Int64 >( this );
41 aHandle.variableLookupFunction = sal_Int64(0);
42 aHandle.variableData = sal_Int64(0);
43 return aHandle;
44}
45
47{
48 if (aSequence.getLength() == 2
49 && (aSequence[0] >>= m_aModel)
50 && (aSequence[1] >>= m_aContextNode))
51 {
52 return;
53 }
54
55 NamedValue aValue;
56 for (const Any& rArg : aSequence)
57 {
58 if (! (rArg >>= aValue))
59 throw RuntimeException();
60 if ( aValue.Name == "Model" )
61 aValue.Value >>= m_aModel;
62 else if ( aValue.Name == "ContextNode" )
63 aValue.Value >>= m_aContextNode;
64 }
65}
66
67
68extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
70 css::uno::Sequence<css::uno::Any> const &)
71{
72 return cppu::acquire(new CLibxml2XFormsExtension());
73}
74/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::xml::xpath::Libxml2ExtensionHandle SAL_CALL getLibxml2ExtensionHandle() override
Definition: extension.cxx:36
css::uno::Reference< css::xml::dom::XNode > m_aContextNode
Definition: extension.hxx:37
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aSequence) override
Definition: extension.cxx:46
css::uno::Reference< css::xforms::XModel > m_aModel
Definition: extension.hxx:36
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_xml_xpath_XFormsExtension_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: extension.cxx:69
xmlXPathFunction xforms_lookupFunc(void *, const xmlChar *xname, const xmlChar *)
Definition: xpathlib.cxx:53