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