Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/xmloff/xmlevent.hxx
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
#ifndef INCLUDED_XMLOFF_XMLEVENT_HXX
21
#define INCLUDED_XMLOFF_XMLEVENT_HXX
22
23
#include <rtl/ustring.hxx>
24
25
namespace com::sun::star::uno { template <class interface_type> class Reference; }
26
namespace com::sun::star::uno { template <typename > class Sequence; }
27
28
29
/**
30
 * @#file
31
 *
32
 * Several definition used in im- and export of events
33
 */
34
35
namespace com::sun::star {
36
    namespace xml::sax { class XFastAttributeList; }
37
    namespace beans { struct PropertyValue; }
38
}
39
40
class SvXMLExport;
41
class SvXMLImportContext;
42
class SvXMLImport;
43
class XMLEventsImportContext;
44
45
46
struct XMLEventName
47
{
48
    sal_uInt16 m_nPrefix;
49
    OUString m_aName;
50
51
744
    XMLEventName() : m_nPrefix( 0 ) {}
52
53
    XMLEventName( sal_uInt16 n, const OUString& s ) :
54
1.59k
        m_nPrefix( n ),
55
1.59k
        m_aName( s )
56
1.59k
       {}
57
58
    bool operator<( const XMLEventName& r ) const
59
5.97k
    {
60
5.97k
        return m_nPrefix < r.m_nPrefix ||
61
4.96k
               (m_nPrefix == r.m_nPrefix && m_aName < r.m_aName );
62
5.97k
    }
63
64
};
65
66
/**
67
 * XMLEventNameTranslation: define tables that translate between event names
68
 * as used in the XML file format and in the StarOffice API.
69
 * The last entry in the table must be { NULL, 0, NULL }.
70
 */
71
struct XMLEventNameTranslation
72
{
73
    OUString sAPIName;
74
    sal_uInt16 nPrefix;    // namespace prefix
75
    OUString sXMLName;
76
};
77
78
/// a translation table for the events defined in the XEventsSupplier service
79
/// (implemented in XMLEventExport.cxx)
80
extern const XMLEventNameTranslation aStandardEventTable[];
81
82
83
/**
84
 * Handle export of an event for a certain event type (event type as
85
 * defined by the PropertyValue "EventType" in API).
86
 *
87
 * The Handler has to generate the full <script:event> element.
88
 */
89
class XMLEventExportHandler
90
{
91
public:
92
16
    virtual ~XMLEventExportHandler() {};
93
94
    virtual void Export(
95
        SvXMLExport& rExport,                   /// the current XML export
96
        const OUString& rEventQName,     /// the XML name of the event
97
        const css::uno::Sequence<css::beans::PropertyValue> & rValues, /// the values for the event
98
        bool bUseWhitespace) = 0;  /// create whitespace around elements?
99
};
100
101
102
/**
103
 * Handle import of an event for a certain event type (as defined by
104
 * the PropertyValue "EventType" in the API).
105
 *
106
 * EventContextFactories must be registered with the EventImportHelper
107
 * that is attached to the SvXMLImport.
108
 *
109
 * The factory has to create an import context for a <script:event>
110
 * element.  The context has to call the
111
 * EventsImportContext::AddEventValues() method to save its event
112
 * registered with the enclosing element. For events consisting only
113
 * of attributes (and an empty element) an easy solution is to handle
114
 * all attributes in the CreateContext()-method and return a default
115
 * context.
116
 *
117
 * EventContextFactory objects have to be registered with the
118
 * EventsImportHelper.
119
 */
120
class XMLEventContextFactory
121
{
122
public:
123
39
    virtual ~XMLEventContextFactory() {};
124
125
    virtual SvXMLImportContext* CreateContext(
126
        SvXMLImport& rImport,               /// import context
127
        const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList, /// attribute list
128
        /// the context for the enclosing <script:events> element
129
        XMLEventsImportContext* rEvents,
130
        /// the event name (as understood by the API)
131
        const OUString& rApiEventName) = 0;
132
};
133
134
135
#endif
136
137
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */