1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_XMLOFF_XMLEVENT_HXX
21 #define INCLUDED_XMLOFF_XMLEVENT_HXX
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
30 * Several definition used in im- and export of events
33 namespace com
{ namespace sun
{ namespace star
{
34 namespace xml
{ namespace sax
{ class XAttributeList
; } }
35 namespace beans
{ struct PropertyValue
; }
39 class SvXMLImportContext
;
41 class XMLEventsImportContext
;
49 XMLEventName() : m_nPrefix( 0 ) {}
50 XMLEventName( sal_uInt16 n
, const sal_Char
*p
) :
52 m_aName( OUString::createFromAscii(p
) )
55 XMLEventName( sal_uInt16 n
, const OUString
& r
) :
60 bool operator<( const XMLEventName
& r
) const
62 return m_nPrefix
< r
.m_nPrefix
||
63 (m_nPrefix
== r
.m_nPrefix
&& m_aName
< r
.m_aName
);
69 * XMLEventNameTranslation: define tables that translate between event names
70 * as used in the XML file format and in the StarOffice API.
71 * The last entry in the table must be { NULL, 0, NULL }.
73 struct XMLEventNameTranslation
75 const sal_Char
* sAPIName
;
76 sal_uInt16 nPrefix
; // namespace prefix
77 const sal_Char
* sXMLName
;
80 /// a translation table for the events defined in the XEventsSupplier service
81 /// (implemented in XMLEventExport.cxx)
82 extern const XMLEventNameTranslation aStandardEventTable
[];
86 * Handle export of an event for a certain event type (event type as
87 * defined by the PropertyValue "EventType" in API).
89 * The Handler has to generate the full <script:event> element.
91 class XMLEventExportHandler
94 virtual ~XMLEventExportHandler() {};
97 SvXMLExport
& rExport
, /// the current XML export
98 const OUString
& rEventQName
, /// the XML name of the event
99 css::uno::Sequence
<css::beans::PropertyValue
> & rValues
, /// the values for the event
100 bool bUseWhitespace
) = 0; /// create whitespace around elements?
105 * Handle import of an event for a certain event type (as defined by
106 * the PropertyValue "EventType" in the API).
108 * EventContextFactories must be registered with the EventImportHelper
109 * that is attached to the SvXMLImport.
111 * The factory has to create an import context for a <script:event>
112 * element. The context has to call the
113 * EventsImportContext::AddEventValues() method to save its event
114 * registered with the enclosing element. For events consisting only
115 * of attributes (and an empty element) an easy solution is to handle
116 * all attributes in the CreateContext()-method and return a default
119 * EventContextFactory objects have to be registered with the
120 * EventsImportHelper.
122 class XMLEventContextFactory
125 virtual ~XMLEventContextFactory() {};
127 virtual SvXMLImportContext
* CreateContext(
128 SvXMLImport
& rImport
, /// import context
129 sal_uInt16 nPrefix
, /// element: namespace prefix
130 const OUString
& rLocalName
, /// element: local name
131 const css::uno::Reference
<css::xml::sax::XAttributeList
> & xAttrList
, /// attribute list
132 /// the context for the enclosing <script:events> element
133 XMLEventsImportContext
* rEvents
,
134 /// the event name (as understood by the API)
135 const OUString
& rApiEventName
,
136 /// the event type name (as registered)
137 const OUString
& rApiLanguage
) = 0;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */