Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/XMLAutoTextEventImport.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 "XMLAutoTextEventImport.hxx"
21
#include <com/sun/star/uno/Reference.hxx>
22
#include <com/sun/star/document/XEventsSupplier.hpp>
23
#include <com/sun/star/uno/XInterface.hpp>
24
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
25
#include "XMLAutoTextContainerEventImport.hxx"
26
#include <xmloff/xmlnamespace.hxx>
27
#include <xmloff/xmltoken.hxx>
28
#include <tools/debug.hxx>
29
30
using namespace ::com::sun::star;
31
32
using ::com::sun::star::uno::Any;
33
using ::com::sun::star::uno::Reference;
34
using ::com::sun::star::uno::Sequence;
35
using ::com::sun::star::uno::Type;
36
using ::com::sun::star::uno::XInterface;
37
using ::com::sun::star::document::XEventsSupplier;
38
using ::com::sun::star::container::XNameReplace;
39
using ::xmloff::token::XML_AUTO_TEXT_EVENTS;
40
41
XMLAutoTextEventImport::XMLAutoTextEventImport(
42
    const css::uno::Reference<css::uno::XComponentContext>& xContext)
43
0
    : SvXMLImport(xContext, u"com.sun.star.comp.Writer.XMLOasisAutotextEventsImporter"_ustr)
44
0
{
45
0
}
46
47
0
XMLAutoTextEventImport::~XMLAutoTextEventImport() noexcept {}
48
49
void XMLAutoTextEventImport::initialize(const Sequence<Any>& rArguments)
50
0
{
51
    // The events may come as either an XNameReplace or XEventsSupplier.
52
53
0
    for (const auto& rArgument : rArguments)
54
0
    {
55
0
        if (Reference<XEventsSupplier> xSupplier; rArgument >>= xSupplier)
56
0
        {
57
0
            DBG_ASSERT(xSupplier.is(), "need XEventsSupplier or XNameReplace");
58
59
0
            xEvents = xSupplier->getEvents();
60
0
        }
61
0
        else if (rArgument >>= xEvents)
62
0
        {
63
0
            DBG_ASSERT(xEvents.is(), "need XEventsSupplier or XNameReplace");
64
0
        }
65
0
    }
66
67
    // call parent
68
0
    SvXMLImport::initialize(rArguments);
69
0
}
70
71
SvXMLImportContext* XMLAutoTextEventImport::CreateFastContext(
72
    sal_Int32 nElement, const Reference<css::xml::sax::XFastAttributeList>& /*xAttrList*/)
73
0
{
74
0
    if (xEvents.is() && nElement == XML_ELEMENT(OOO, XML_AUTO_TEXT_EVENTS))
75
0
    {
76
0
        return new XMLAutoTextContainerEventImport(*this, xEvents);
77
0
    }
78
0
    return nullptr;
79
0
}
80
81
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
82
com_sun_star_comp_Writer_XMLOasisAutotextEventsImporter_get_implementation(
83
    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
84
0
{
85
0
    return cppu::acquire(new XMLAutoTextEventImport(context));
86
0
}
87
88
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */