Bump for 3.6-28
[LibreOffice.git] / xmloff / source / script / XMLScriptContextFactory.cxx
blob7c87ab4f57dafd103035232c54c4caa69d74a093
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "XMLScriptContextFactory.hxx"
30 #include <xmloff/XMLEventsImportContext.hxx>
31 #include <xmloff/xmlimp.hxx>
32 #include <xmloff/nmspmap.hxx>
33 #include "xmloff/xmlnmspe.hxx"
34 #include <xmloff/xmltoken.hxx>
37 using namespace ::xmloff::token;
39 using ::rtl::OUString;
40 using ::com::sun::star::xml::sax::XAttributeList;
41 using ::com::sun::star::beans::PropertyValue;
42 using ::com::sun::star::uno::Reference;
43 using ::com::sun::star::uno::Sequence;
44 using ::com::sun::star::uno::Any;
46 XMLScriptContextFactory::XMLScriptContextFactory() :
47 sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
48 sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
49 sURL(RTL_CONSTASCII_USTRINGPARAM("Script"))
53 XMLScriptContextFactory::~XMLScriptContextFactory()
57 SvXMLImportContext * XMLScriptContextFactory::CreateContext
58 (SvXMLImport & rImport,
59 sal_uInt16 p_nPrefix,
60 const OUString & rLocalName,
61 const Reference<XAttributeList> & xAttrList,
62 XMLEventsImportContext * rEvents,
63 const OUString & rApiEventName,
64 const OUString & /*rApiLanguage*/)
66 OUString sURLVal;
68 sal_Int16 nCount = xAttrList->getLength();
69 for (sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
71 OUString sLocalName;
72 sal_uInt16 nPrefix = rImport.GetNamespaceMap().
73 GetKeyByAttrName(xAttrList->getNameByIndex(nAttr), &sLocalName);
75 if (XML_NAMESPACE_XLINK == nPrefix)
77 if (IsXMLToken(sLocalName, XML_HREF))
78 sURLVal = xAttrList->getValueByIndex(nAttr);
79 // else: ignore
81 // else ignore
84 Sequence<PropertyValue> aValues(2);
86 // EventType
87 aValues[0].Name = sEventType;
88 aValues[0].Value <<= sScript;
90 // URL
91 aValues[1].Name = sURL;
92 aValues[1].Value <<= sURLVal;
94 // add values for event now
95 rEvents->AddEventValues(rApiEventName, aValues);
97 // return dummy context
98 return new SvXMLImportContext(rImport, p_nPrefix, rLocalName);
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */