LibreOffice Module xmloff (master) 1
XMLScriptContextFactory.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
23#include <xmloff/xmlimp.hxx>
26#include <xmloff/xmltoken.hxx>
27
28using namespace ::xmloff::token;
29
30using ::com::sun::star::xml::sax::XFastAttributeList;
31using ::com::sun::star::beans::PropertyValue;
32using ::com::sun::star::uno::Reference;
33using ::com::sun::star::uno::Sequence;
34
35constexpr OUStringLiteral gsEventType(u"EventType");
36constexpr OUStringLiteral gsScript(u"Script");
37constexpr OUStringLiteral gsURL(u"Script");
38
40
42
44 SvXMLImport& rImport, const Reference<XFastAttributeList>& xAttrList,
45 XMLEventsImportContext* rEvents, const OUString& rApiEventName)
46{
47 OUString sURLVal;
48
49 for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
50 {
51 if (aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF))
52 sURLVal = aIter.toString();
53 // else: ignore
54 }
55
56 Sequence<PropertyValue> aValues{ comphelper::makePropertyValue(gsEventType, OUString(gsScript)),
58
59 // add values for event now
60 rEvents->AddEventValues(rApiEventName, aValues);
61
62 // return dummy context
63 return new SvXMLImportContext(rImport);
64}
65
66/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral gsURL(u"Script")
constexpr OUStringLiteral gsScript(u"Script")
constexpr OUStringLiteral gsEventType(u"EventType")
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
Import <script:events> element.
void AddEventValues(const OUString &rEventName, const css::uno::Sequence< css::beans::PropertyValue > &rValues)
virtual SvXMLImportContext * CreateContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XMLEventsImportContext *rEvents, const OUString &rApiEventName) override
virtual ~XMLScriptContextFactory() override
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:98