tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / script / XMLScriptContextFactory.cxx
blob082a28eefbc6b056940349d8b6ad8ab5f9494be9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <comphelper/propertyvalue.hxx>
21 #include <XMLScriptContextFactory.hxx>
22 #include <xmloff/XMLEventsImportContext.hxx>
23 #include <xmloff/xmlimp.hxx>
24 #include <xmloff/xmlnamespace.hxx>
25 #include <xmloff/xmltoken.hxx>
27 using namespace ::xmloff::token;
29 using ::com::sun::star::xml::sax::XFastAttributeList;
30 using ::com::sun::star::beans::PropertyValue;
31 using ::com::sun::star::uno::Reference;
32 using ::com::sun::star::uno::Sequence;
34 constexpr OUString gsEventType(u"EventType"_ustr);
35 constexpr OUString gsScript(u"Script"_ustr);
36 constexpr OUString gsURL(u"Script"_ustr);
38 XMLScriptContextFactory::XMLScriptContextFactory() {}
40 XMLScriptContextFactory::~XMLScriptContextFactory() {}
42 SvXMLImportContext* XMLScriptContextFactory::CreateContext(
43 SvXMLImport& rImport, const Reference<XFastAttributeList>& xAttrList,
44 XMLEventsImportContext* rEvents, const OUString& rApiEventName)
46 OUString sURLVal;
48 for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
50 if (aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF))
51 sURLVal = aIter.toString();
52 // else: ignore
55 if (!sURLVal.isEmpty())
56 rImport.NotifyMacroEventRead();
58 Sequence<PropertyValue> aValues{ comphelper::makePropertyValue(gsEventType, gsScript),
59 comphelper::makePropertyValue(gsURL, sURLVal) };
61 // add values for event now
62 rEvents->AddEventValues(rApiEventName, aValues);
64 // return dummy context
65 return new SvXMLImportContext(rImport);
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */