Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/script/XMLScriptContextFactory.cxx
Line
Count
Source
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
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>
26
27
using namespace ::xmloff::token;
28
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;
33
34
constexpr OUString gsEventType(u"EventType"_ustr);
35
constexpr OUString gsScript(u"Script"_ustr);
36
constexpr OUString gsURL(u"Script"_ustr);
37
38
13
XMLScriptContextFactory::XMLScriptContextFactory() {}
39
40
13
XMLScriptContextFactory::~XMLScriptContextFactory() {}
41
42
SvXMLImportContext* XMLScriptContextFactory::CreateContext(
43
    SvXMLImport& rImport, const Reference<XFastAttributeList>& xAttrList,
44
    XMLEventsImportContext* rEvents, const OUString& rApiEventName)
45
7
{
46
7
    OUString sURLVal;
47
48
7
    for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
49
24
    {
50
24
        if (aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF))
51
5
            sURLVal = aIter.toString();
52
        // else: ignore
53
24
    }
54
55
7
    if (!sURLVal.isEmpty())
56
5
        rImport.NotifyMacroEventRead();
57
58
7
    Sequence<PropertyValue> aValues{ comphelper::makePropertyValue(gsEventType, gsScript),
59
7
                                     comphelper::makePropertyValue(gsURL, sURLVal) };
60
61
    // add values for event now
62
7
    rEvents->AddEventValues(rApiEventName, aValues);
63
64
    // return dummy context
65
7
    return new SvXMLImportContext(rImport);
66
7
}
67
68
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */