1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24acc546SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24acc546SAndrew Rist  * distributed with this work for additional information
6*24acc546SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24acc546SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist  * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24acc546SAndrew Rist  *
11*24acc546SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24acc546SAndrew Rist  *
13*24acc546SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist  * software distributed under the License is distributed on an
15*24acc546SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist  * KIND, either express or implied.  See the License for the
17*24acc546SAndrew Rist  * specific language governing permissions and limitations
18*24acc546SAndrew Rist  * under the License.
19*24acc546SAndrew Rist  *
20*24acc546SAndrew Rist  *************************************************************/
21*24acc546SAndrew Rist 
22*24acc546SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_forms.hxx"
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir #include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
30cdf0e10cSrcweir #include "extension.hxx"
31cdf0e10cSrcweir #include "xpathlib.hxx"
32cdf0e10cSrcweir #include "frm_module.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace com::sun::star::uno;
35cdf0e10cSrcweir using namespace com::sun::star::lang;
36cdf0e10cSrcweir using namespace com::sun::star::xforms;
37cdf0e10cSrcweir using namespace com::sun::star::xml::xpath;
38cdf0e10cSrcweir using namespace com::sun::star::beans;
39cdf0e10cSrcweir using com::sun::star::xml::dom::XNode;
40cdf0e10cSrcweir 
Create(const Reference<XMultiServiceFactory> &)41cdf0e10cSrcweir Reference< XInterface > SAL_CALL CLibxml2XFormsExtension::Create(
42cdf0e10cSrcweir     const Reference< XMultiServiceFactory >& /*aFactory*/)
43cdf0e10cSrcweir {
44cdf0e10cSrcweir     // printf("_create_\n");
45cdf0e10cSrcweir     Reference< XInterface > aInstance(static_cast< XXPathExtension* >(new CLibxml2XFormsExtension(/*aFactory*/)));
46cdf0e10cSrcweir     return aInstance;
47cdf0e10cSrcweir }
48cdf0e10cSrcweir 
getImplementationName_Static()49cdf0e10cSrcweir ::rtl::OUString SAL_CALL CLibxml2XFormsExtension::getImplementationName_Static()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     // printf("_implname_\n");
52cdf0e10cSrcweir     return ::rtl::OUString::createFromAscii("com.sun.star.comp.xml.xpath.XFormsExtension");
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
getSupportedServiceNames_Static()55cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL CLibxml2XFormsExtension::getSupportedServiceNames_Static()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     // printf("_services_\n");
58cdf0e10cSrcweir     Sequence< ::rtl::OUString > aSequence(1);
59cdf0e10cSrcweir     aSequence[0] = ::rtl::OUString::createFromAscii("com.sun.star.xml.xpath.XPathExtension");
60cdf0e10cSrcweir     return aSequence;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
getLibxml2ExtensionHandle()63cdf0e10cSrcweir Libxml2ExtensionHandle SAL_CALL CLibxml2XFormsExtension::getLibxml2ExtensionHandle() throw (RuntimeException)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     Libxml2ExtensionHandle aHandle;
66cdf0e10cSrcweir     aHandle.functionLookupFunction = reinterpret_cast< sal_Int64 >( &xforms_lookupFunc );
67cdf0e10cSrcweir     aHandle.functionData = reinterpret_cast< sal_Int64 >( this );
68cdf0e10cSrcweir     aHandle.variableLookupFunction = (sal_Int64)0;
69cdf0e10cSrcweir     aHandle.variableData = (sal_Int64)0;
70cdf0e10cSrcweir     return aHandle;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
initialize(const Sequence<Any> & aSequence)73cdf0e10cSrcweir void SAL_CALL CLibxml2XFormsExtension::initialize(const Sequence< Any >& aSequence) throw (RuntimeException)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     NamedValue aValue;
76cdf0e10cSrcweir     for (sal_Int32 i = 0; i < aSequence.getLength(); i++)
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         if (! (aSequence[i] >>= aValue))
79cdf0e10cSrcweir             throw RuntimeException();
80cdf0e10cSrcweir         if (aValue.Name.equalsAscii("Model"))
81cdf0e10cSrcweir             aValue.Value >>= m_aModel;
82cdf0e10cSrcweir         else if (aValue.Name.equalsAscii("ContextNode"))
83cdf0e10cSrcweir             aValue.Value >>= m_aContextNode;
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
getModel()87cdf0e10cSrcweir Reference< XModel > CLibxml2XFormsExtension::getModel()
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     return m_aModel;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
getContextNode()92cdf0e10cSrcweir Reference< XNode > CLibxml2XFormsExtension::getContextNode()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     return m_aContextNode;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
createRegistryInfo_CLibxml2XFormsExtension()97cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_CLibxml2XFormsExtension()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     static frm::OMultiInstanceAutoRegistration< CLibxml2XFormsExtension >   aRegistration;
100cdf0e10cSrcweir }
101