Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / xmloff / XMLEventsImportContext.hxx
blobedbb27aee733fb440be5278f1cdd8da6c5d64251
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_XMLEVENTSIMPORTCONTEXT_HXX
21 #define INCLUDED_XMLOFF_XMLEVENTSIMPORTCONTEXT_HXX
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <xmloff/xmlictxt.hxx>
28 #include <xmloff/xmlevent.hxx>
30 #include <map>
31 #include <vector>
33 namespace com { namespace sun { namespace star {
34 namespace xml { namespace sax { class XAttributeList; } }
35 namespace beans { struct PropertyValue; }
36 namespace container { class XNameReplace; }
37 namespace document { class XEventsSupplier; }
38 } } }
40 typedef ::std::pair<
41 OUString,
42 css::uno::Sequence<css::beans::PropertyValue> > EventNameValuesPair;
44 typedef ::std::vector< EventNameValuesPair > EventsVector;
46 /**
47 * Import <script:events> element.
49 * The import context usually sets the events immediately at the event
50 * XNameReplace. If none was given on construction, it operates in
51 * delayed mode: All events are collected and may then be set
52 * with the setEvents() method.
54 class XMLOFF_DLLPUBLIC XMLEventsImportContext : public SvXMLImportContext
56 // the event XNameReplace; may be empty
57 css::uno::Reference<css::container::XNameReplace> xEvents;
59 protected:
60 // if no XNameReplace is given, use this vector to collect events
61 EventsVector aCollectEvents;
63 public:
66 XMLEventsImportContext(
67 SvXMLImport& rImport,
68 sal_uInt16 nPrfx,
69 const OUString& rLocalName);
71 XMLEventsImportContext(
72 SvXMLImport& rImport,
73 sal_uInt16 nPrfx,
74 const OUString& rLocalName,
75 const css::uno::Reference<css::document::XEventsSupplier> & xEventsSupplier);
77 XMLEventsImportContext(
78 SvXMLImport& rImport,
79 sal_uInt16 nPrfx,
80 const OUString& rLocalName,
81 const css::uno::Reference<css::container::XNameReplace> & xNameRepl);
83 virtual ~XMLEventsImportContext() override;
85 void AddEventValues(
86 const OUString& rEventName,
87 const css::uno::Sequence<css::beans::PropertyValue> & rValues);
89 /// if the import operates in delayed mode, you can use this method
90 /// to set all events that have been read on the XEventsSupplier
91 void SetEvents(
92 const css::uno::Reference<css::document::XEventsSupplier> & xEventsSupplier);
94 /// if the import operates in delayed mode, you can use this method
95 /// to set all events that have been read on the XNameReplace
96 void SetEvents(
97 const css::uno::Reference<css::container::XNameReplace> & xNameRepl);
99 /// if the import operates in delayed mode, you can use this method
100 /// to obtain the value sequence for a specific event
101 void GetEventSequence(
102 const OUString& rName,
103 css::uno::Sequence<css::beans::PropertyValue> & rSequence );
105 protected:
107 virtual void StartElement(
108 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
110 virtual void EndElement() override;
112 virtual SvXMLImportContext *CreateChildContext(
113 sal_uInt16 nPrefix,
114 const OUString& rLocalName,
115 const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList ) override;
118 #endif
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */