Branch libreoffice-5-0-4
[LibreOffice.git] / include / xmloff / xmlevent.hxx
blob261c89a5715a0c5c2ee5baa061d008ff082087c7
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 #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>
27 /**
28 * @#file
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; }
36 } } }
38 class SvXMLExport;
39 class SvXMLImportContext;
40 class SvXMLImport;
41 class XMLEventsImportContext;
44 struct XMLEventName
46 sal_uInt16 m_nPrefix;
47 OUString m_aName;
49 XMLEventName() : m_nPrefix( 0 ) {}
50 XMLEventName( sal_uInt16 n, const sal_Char *p ) :
51 m_nPrefix( n ),
52 m_aName( OUString::createFromAscii(p) )
55 XMLEventName( sal_uInt16 n, const OUString& r ) :
56 m_nPrefix( n ),
57 m_aName( 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 );
68 /**
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[];
85 /**
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
93 public:
94 virtual ~XMLEventExportHandler() {};
96 virtual void Export(
97 SvXMLExport& rExport, /// the current XML export
98 const OUString& rEventQName, /// the XML name of the event
99 ::com::sun::star::uno::Sequence< /// the values for the event
100 ::com::sun::star::beans::PropertyValue> & rValues,
101 bool bUseWhitespace) = 0; /// create whitespace around elements?
106 * Handle import of an event for a certain event type (as defined by
107 * the PropertyValue "EventType" in the API).
109 * EventContextFactories must be registered with the EventImportHelper
110 * that is attached to the SvXMLImport.
112 * The factory has to create an import context for a <script:event>
113 * element. The context has to call the
114 * EventsImportContext::AddEventValues() method to fave its event
115 * registered with the enclosing element. For events consisting only
116 * of attributes (and an empty element) an easy solution is to handle
117 * all attributes in the CreateContext()-method and return a default
118 * context.
120 * EventContextFactory objects have to be registered with the
121 * EventsImportHelper.
123 class XMLEventContextFactory
125 public:
126 virtual ~XMLEventContextFactory() {};
128 virtual SvXMLImportContext* CreateContext(
129 SvXMLImport& rImport, /// import context
130 sal_uInt16 nPrefix, /// element: namespace prefix
131 const OUString& rLocalName, /// element: local name
132 const ::com::sun::star::uno::Reference< /// attribute list
133 ::com::sun::star::xml::sax::XAttributeList> & xAttrList,
134 /// the context for the enclosing <script:events> element
135 XMLEventsImportContext* rEvents,
136 /// the event name (as understood by the API)
137 const OUString& rApiEventName,
138 /// the event type name (as registered)
139 const OUString& rApiLanguage) = 0;
143 #endif
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */