Update ooo320-m1
[ooovba.git] / forms / source / xforms / xpathlib / extension.cxx
blobf759ba9a0fd22dc9dc7242ad0dc4a9dcc0590e00
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: extension.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_forms.hxx"
34 #include <stdio.h>
35 #include <com/sun/star/xml/xpath/Libxml2ExtensionHandle.hpp>
36 #include <com/sun/star/beans/NamedValue.hpp>
37 #include "extension.hxx"
38 #include "xpathlib.hxx"
39 #include "frm_module.hxx"
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::lang;
43 using namespace com::sun::star::xforms;
44 using namespace com::sun::star::xml::xpath;
45 using namespace com::sun::star::beans;
46 using com::sun::star::xml::dom::XNode;
48 Reference< XInterface > SAL_CALL CLibxml2XFormsExtension::Create(
49 const Reference< XMultiServiceFactory >& /*aFactory*/)
51 // printf("_create_\n");
52 Reference< XInterface > aInstance(static_cast< XXPathExtension* >(new CLibxml2XFormsExtension(/*aFactory*/)));
53 return aInstance;
56 ::rtl::OUString SAL_CALL CLibxml2XFormsExtension::getImplementationName_Static()
58 // printf("_implname_\n");
59 return ::rtl::OUString::createFromAscii("com.sun.star.comp.xml.xpath.XFormsExtension");
62 Sequence< ::rtl::OUString > SAL_CALL CLibxml2XFormsExtension::getSupportedServiceNames_Static()
64 // printf("_services_\n");
65 Sequence< ::rtl::OUString > aSequence(1);
66 aSequence[0] = ::rtl::OUString::createFromAscii("com.sun.star.xml.xpath.XPathExtension");
67 return aSequence;
70 Libxml2ExtensionHandle SAL_CALL CLibxml2XFormsExtension::getLibxml2ExtensionHandle() throw (RuntimeException)
72 Libxml2ExtensionHandle aHandle;
73 aHandle.functionLookupFunction = reinterpret_cast< sal_Int64 >( &xforms_lookupFunc );
74 aHandle.functionData = reinterpret_cast< sal_Int64 >( this );
75 aHandle.variableLookupFunction = (sal_Int64)0;
76 aHandle.variableData = (sal_Int64)0;
77 return aHandle;
80 void SAL_CALL CLibxml2XFormsExtension::initialize(const Sequence< Any >& aSequence) throw (RuntimeException)
82 NamedValue aValue;
83 for (sal_Int32 i = 0; i < aSequence.getLength(); i++)
85 if (! (aSequence[i] >>= aValue))
86 throw RuntimeException();
87 if (aValue.Name.equalsAscii("Model"))
88 aValue.Value >>= m_aModel;
89 else if (aValue.Name.equalsAscii("ContextNode"))
90 aValue.Value >>= m_aContextNode;
94 Reference< XModel > CLibxml2XFormsExtension::getModel()
96 return m_aModel;
99 Reference< XNode > CLibxml2XFormsExtension::getContextNode()
101 return m_aContextNode;
104 extern "C" void SAL_CALL createRegistryInfo_CLibxml2XFormsExtension()
106 static frm::OMultiInstanceAutoRegistration< CLibxml2XFormsExtension > aRegistration;