Update ooo320-m1
[ooovba.git] / xmloff / source / script / XMLScriptContextFactory.cxx
blob58928e3be7507c8d841cb9461c60b04acfc85457
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: XMLScriptContextFactory.cxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLScriptContextFactory.hxx"
34 #include <xmloff/XMLEventsImportContext.hxx>
35 #include <tools/debug.hxx>
36 #include <xmloff/xmlimp.hxx>
37 #include <xmloff/nmspmap.hxx>
38 #include "xmlnmspe.hxx"
39 #include <xmloff/xmltoken.hxx>
42 using namespace ::xmloff::token;
44 using ::rtl::OUString;
45 using ::com::sun::star::xml::sax::XAttributeList;
46 using ::com::sun::star::beans::PropertyValue;
47 using ::com::sun::star::uno::Reference;
48 using ::com::sun::star::uno::Sequence;
49 using ::com::sun::star::uno::Any;
51 XMLScriptContextFactory::XMLScriptContextFactory() :
52 sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
53 sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
54 sURL(RTL_CONSTASCII_USTRINGPARAM("Script"))
58 XMLScriptContextFactory::~XMLScriptContextFactory()
62 SvXMLImportContext * XMLScriptContextFactory::CreateContext
63 (SvXMLImport & rImport,
64 sal_uInt16 p_nPrefix,
65 const OUString & rLocalName,
66 const Reference<XAttributeList> & xAttrList,
67 XMLEventsImportContext * rEvents,
68 const OUString & rApiEventName,
69 const OUString & /*rApiLanguage*/)
71 OUString sURLVal;
73 sal_Int16 nCount = xAttrList->getLength();
74 for (sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
76 OUString sLocalName;
77 sal_uInt16 nPrefix = rImport.GetNamespaceMap().
78 GetKeyByAttrName(xAttrList->getNameByIndex(nAttr), &sLocalName);
80 if (XML_NAMESPACE_XLINK == nPrefix)
82 if (IsXMLToken(sLocalName, XML_HREF))
83 sURLVal = xAttrList->getValueByIndex(nAttr);
84 // else: ignore
86 // else ignore
89 Sequence<PropertyValue> aValues(2);
91 // EventType
92 aValues[0].Name = sEventType;
93 aValues[0].Value <<= sScript;
95 // URL
96 aValues[1].Name = sURL;
97 aValues[1].Value <<= sURLVal;
99 // add values for event now
100 rEvents->AddEventValues(rApiEventName, aValues);
102 // return dummy context
103 return new SvXMLImportContext(rImport, p_nPrefix, rLocalName);