1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
23 #include <com/sun/star/beans/NamedValue.hpp>
24 #include "extension.hxx"
25 #include "xpathlib.hxx"
26 #include "frm_module.hxx"
28 using namespace com::sun::star::uno
;
29 using namespace com::sun::star::lang
;
30 using namespace com::sun::star::xforms
;
31 using namespace com::sun::star::xml::xpath
;
32 using namespace com::sun::star::beans
;
33 using com::sun::star::xml::dom::XNode
;
35 Reference
< XInterface
> SAL_CALL
CLibxml2XFormsExtension::Create(
36 const Reference
< XMultiServiceFactory
>& /*aFactory*/)
38 Reference
< XInterface
> aInstance(static_cast< XXPathExtension
* >(new CLibxml2XFormsExtension(/*aFactory*/)));
42 OUString SAL_CALL
CLibxml2XFormsExtension::getImplementationName_Static()
44 return OUString("com.sun.star.comp.xml.xpath.XFormsExtension");
47 Sequence
< OUString
> SAL_CALL
CLibxml2XFormsExtension::getSupportedServiceNames_Static()
49 Sequence
< OUString
> aSequence(1);
50 aSequence
[0] = OUString("com.sun.star.xml.xpath.XPathExtension");
54 Libxml2ExtensionHandle SAL_CALL
CLibxml2XFormsExtension::getLibxml2ExtensionHandle() throw (RuntimeException
)
56 Libxml2ExtensionHandle aHandle
;
57 aHandle
.functionLookupFunction
= reinterpret_cast< sal_Int64
>( &xforms_lookupFunc
);
58 aHandle
.functionData
= reinterpret_cast< sal_Int64
>( this );
59 aHandle
.variableLookupFunction
= (sal_Int64
)0;
60 aHandle
.variableData
= (sal_Int64
)0;
64 void SAL_CALL
CLibxml2XFormsExtension::initialize(const Sequence
< Any
>& aSequence
) throw (RuntimeException
)
66 if (aSequence
.getLength() == 2
67 && (aSequence
[0] >>= m_aModel
)
68 && (aSequence
[1] >>= m_aContextNode
))
74 for (sal_Int32 i
= 0; i
< aSequence
.getLength(); i
++)
76 if (! (aSequence
[i
] >>= aValue
))
77 throw RuntimeException();
78 if ( aValue
.Name
== "Model" )
79 aValue
.Value
>>= m_aModel
;
80 else if ( aValue
.Name
== "ContextNode" )
81 aValue
.Value
>>= m_aContextNode
;
85 Reference
< XModel
> CLibxml2XFormsExtension::getModel()
90 Reference
< XNode
> CLibxml2XFormsExtension::getContextNode()
92 return m_aContextNode
;
95 extern "C" void SAL_CALL
createRegistryInfo_CLibxml2XFormsExtension()
97 static frm::OMultiInstanceAutoRegistration
< CLibxml2XFormsExtension
> aRegistration
;
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */