lok: avoid expensive fetching of a property.
[LibreOffice.git] / include / xmloff / xmlevent.hxx
blob900a03694ae726b48f0a070d3a64d0f1fc62385f
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 <rtl/ustring.hxx>
25 namespace com::sun::star::uno { template <class interface_type> class Reference; }
26 namespace com::sun::star::uno { template <typename > class Sequence; }
29 /**
30 * @#file
32 * Several definition used in im- and export of events
35 namespace com::sun::star {
36 namespace xml::sax { class XFastAttributeList; }
37 namespace beans { struct PropertyValue; }
40 class SvXMLExport;
41 class SvXMLImportContext;
42 class SvXMLImport;
43 class XMLEventsImportContext;
46 struct XMLEventName
48 sal_uInt16 m_nPrefix;
49 OUString m_aName;
51 XMLEventName() : m_nPrefix( 0 ) {}
52 XMLEventName( sal_uInt16 n, const char *p ) :
53 m_nPrefix( n ),
54 m_aName( OUString::createFromAscii(p) )
57 XMLEventName( sal_uInt16 n, const OUString& r ) :
58 m_nPrefix( n ),
59 m_aName( r )
62 bool operator<( const XMLEventName& r ) const
64 return m_nPrefix < r.m_nPrefix ||
65 (m_nPrefix == r.m_nPrefix && m_aName < r.m_aName );
70 /**
71 * XMLEventNameTranslation: define tables that translate between event names
72 * as used in the XML file format and in the StarOffice API.
73 * The last entry in the table must be { NULL, 0, NULL }.
75 struct XMLEventNameTranslation
77 const char* sAPIName;
78 sal_uInt16 nPrefix; // namespace prefix
79 const char* sXMLName;
82 /// a translation table for the events defined in the XEventsSupplier service
83 /// (implemented in XMLEventExport.cxx)
84 extern const XMLEventNameTranslation aStandardEventTable[];
87 /**
88 * Handle export of an event for a certain event type (event type as
89 * defined by the PropertyValue "EventType" in API).
91 * The Handler has to generate the full <script:event> element.
93 class XMLEventExportHandler
95 public:
96 virtual ~XMLEventExportHandler() {};
98 virtual void Export(
99 SvXMLExport& rExport, /// the current XML export
100 const OUString& rEventQName, /// the XML name of the event
101 const css::uno::Sequence<css::beans::PropertyValue> & rValues, /// the values for the event
102 bool bUseWhitespace) = 0; /// create whitespace around elements?
107 * Handle import of an event for a certain event type (as defined by
108 * the PropertyValue "EventType" in the API).
110 * EventContextFactories must be registered with the EventImportHelper
111 * that is attached to the SvXMLImport.
113 * The factory has to create an import context for a <script:event>
114 * element. The context has to call the
115 * EventsImportContext::AddEventValues() method to save its event
116 * registered with the enclosing element. For events consisting only
117 * of attributes (and an empty element) an easy solution is to handle
118 * all attributes in the CreateContext()-method and return a default
119 * context.
121 * EventContextFactory objects have to be registered with the
122 * EventsImportHelper.
124 class XMLEventContextFactory
126 public:
127 virtual ~XMLEventContextFactory() {};
129 virtual SvXMLImportContext* CreateContext(
130 SvXMLImport& rImport, /// import context
131 const css::uno::Reference<css::xml::sax::XFastAttributeList> & 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) = 0;
139 #endif
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */