Line data Source code
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 _XMLOFF_XMLEVENT_HXX
21 : #define _XMLOFF_XMLEVENT_HXX
22 :
23 : #include <com/sun/star/uno/Sequence.hxx>
24 : #include <com/sun/star/uno/Reference.hxx>
25 :
26 :
27 : /**
28 : * @#file
29 : *
30 : * Several definition used in im- and export of events
31 : */
32 :
33 : namespace com { namespace sun { namespace star {
34 : namespace xml { namespace sax { class XAttributeList; } }
35 : namespace beans { struct PropertyValue; }
36 : } } }
37 : namespace rtl { class OUString; }
38 :
39 : class SvXMLExport;
40 : class SvXMLImportContext;
41 : class SvXMLImport;
42 : class XMLEventsImportContext;
43 :
44 :
45 : struct XMLEventName
46 : {
47 : sal_uInt16 m_nPrefix;
48 : ::rtl::OUString m_aName;
49 :
50 : XMLEventName() : m_nPrefix( 0 ) {}
51 : XMLEventName( sal_uInt16 n, const sal_Char *p ) :
52 : m_nPrefix( n ),
53 : m_aName( ::rtl::OUString::createFromAscii(p) )
54 : {}
55 :
56 : XMLEventName( sal_uInt16 n, const ::rtl::OUString& r ) :
57 : m_nPrefix( n ),
58 : m_aName( r )
59 : {}
60 :
61 : bool operator<( const XMLEventName& r ) const
62 : {
63 : return m_nPrefix < r.m_nPrefix ||
64 : (m_nPrefix == r.m_nPrefix && m_aName < r.m_aName );
65 : }
66 :
67 : };
68 :
69 : /**
70 : * XMLEventNameTranslation: define tables that translate between event names
71 : * as used in the XML file format and in the StarOffice API.
72 : * The last entry in the table must be { NULL, 0, NULL }.
73 : */
74 : struct XMLEventNameTranslation
75 : {
76 : const sal_Char* sAPIName;
77 : sal_uInt16 nPrefix; // namespace prefix
78 : const sal_Char* sXMLName;
79 : };
80 :
81 : /// a translation table for the events defined in the XEventsSupplier service
82 : /// (implemented in XMLEventExport.cxx)
83 : extern const XMLEventNameTranslation aStandardEventTable[];
84 :
85 :
86 : /**
87 : * Handle export of an event for a certain event type (event type as
88 : * defined by the PropertyValue "EventType" in API).
89 : *
90 : * The Handler has to generate the full <script:event> element.
91 : */
92 : class XMLEventExportHandler
93 : {
94 : public:
95 0 : virtual ~XMLEventExportHandler() {};
96 :
97 : virtual void Export(
98 : SvXMLExport& rExport, /// the current XML export
99 : const ::rtl::OUString& rEventQName, /// the XML name of the event
100 : ::com::sun::star::uno::Sequence< /// the values for the event
101 : ::com::sun::star::beans::PropertyValue> & rValues,
102 : sal_Bool bUseWhitespace) = 0; /// create whitespace around elements?
103 : };
104 :
105 :
106 : /**
107 : * Handle import of an event for a certain event type (as defined by
108 : * the PropertyValue "EventType" in the API).
109 : *
110 : * EventContextFactories must be registered with the EventImportHelper
111 : * that is attached to the SvXMLImport.
112 : *
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 fave 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.
120 : *
121 : * EventContextFactory objects have to be registered with the
122 : * EventsImportHelper.
123 : */
124 : class XMLEventContextFactory
125 : {
126 : public:
127 0 : virtual ~XMLEventContextFactory() {};
128 :
129 : virtual SvXMLImportContext* CreateContext(
130 : SvXMLImport& rImport, /// import context
131 : sal_uInt16 nPrefix, /// element: namespace prefix
132 : const ::rtl::OUString& rLocalName, /// element: local name
133 : const ::com::sun::star::uno::Reference< /// attribute list
134 : ::com::sun::star::xml::sax::XAttributeList> & xAttrList,
135 : /// the context for the enclosing <script:events> element
136 : XMLEventsImportContext* rEvents,
137 : /// the event name (as understood by the API)
138 : const ::rtl::OUString& rApiEventName,
139 : /// the event type name (as registered)
140 : const ::rtl::OUString& rApiLanguage) = 0;
141 : };
142 :
143 :
144 : #endif
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|