1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _XMLOFF_XMLEVENTSIMPORTCONTEXT_HXX 29 #define _XMLOFF_XMLEVENTSIMPORTCONTEXT_HXX 30 31 #include "sal/config.h" 32 #include "xmloff/dllapi.h" 33 #include <com/sun/star/uno/Reference.hxx> 34 #include <com/sun/star/uno/Sequence.hxx> 35 #include <xmloff/xmlictxt.hxx> 36 #include <xmloff/xmlevent.hxx> 37 38 #include <map> 39 #include <vector> 40 41 namespace com { namespace sun { namespace star { 42 namespace xml { namespace sax { class XAttributeList; } } 43 namespace beans { struct PropertyValue; } 44 namespace container { class XNameReplace; } 45 namespace document { class XEventsSupplier; } 46 } } } 47 namespace rtl { class OUString; } 48 49 typedef ::std::pair< 50 ::rtl::OUString, 51 ::com::sun::star::uno::Sequence< 52 ::com::sun::star::beans::PropertyValue> > EventNameValuesPair; 53 54 typedef ::std::vector< EventNameValuesPair > EventsVector; 55 56 /** 57 * Import <script:events> element. 58 * 59 * The import context usually sets the events immediatly at the event 60 * XNameReplace. If none was given on construction, it operates in 61 * delayed mode: All events are collected and may then be set 62 * with the setEvents() method. 63 */ 64 class XMLOFF_DLLPUBLIC XMLEventsImportContext : public SvXMLImportContext 65 { 66 protected: 67 // the event XNameReplace; may be empty 68 ::com::sun::star::uno::Reference< 69 ::com::sun::star::container::XNameReplace> xEvents; 70 71 // if no XNameReplace is given, use this vector to collect events 72 EventsVector aCollectEvents; 73 74 public: 75 76 TYPEINFO(); 77 78 XMLEventsImportContext( 79 SvXMLImport& rImport, 80 sal_uInt16 nPrfx, 81 const ::rtl::OUString& rLocalName); 82 83 XMLEventsImportContext( 84 SvXMLImport& rImport, 85 sal_uInt16 nPrfx, 86 const ::rtl::OUString& rLocalName, 87 const ::com::sun::star::uno::Reference< 88 ::com::sun::star::document::XEventsSupplier> & xEventsSupplier); 89 90 XMLEventsImportContext( 91 SvXMLImport& rImport, 92 sal_uInt16 nPrfx, 93 const ::rtl::OUString& rLocalName, 94 const ::com::sun::star::uno::Reference< 95 ::com::sun::star::container::XNameReplace> & xNameRepl); 96 97 ~XMLEventsImportContext(); 98 99 void AddEventValues( 100 const ::rtl::OUString& rEventName, 101 const ::com::sun::star::uno::Sequence< 102 ::com::sun::star::beans::PropertyValue> & rValues); 103 104 /// if the import operates in delayed mode, you can use this method 105 /// to set all events that have been read on the XEventsSupplier 106 void SetEvents( 107 const ::com::sun::star::uno::Reference< 108 ::com::sun::star::document::XEventsSupplier> & xEventsSupplier); 109 110 /// if the import operates in delayed mode, you can use this method 111 /// to set all events that have been read on the XNameReplace 112 void SetEvents( 113 const ::com::sun::star::uno::Reference< 114 ::com::sun::star::container::XNameReplace> & xNameRepl); 115 116 /// if the import operates indelayed mode, you can use this method 117 /// to obtain the value sequence for a specific event 118 sal_Bool GetEventSequence( 119 const ::rtl::OUString& rName, 120 ::com::sun::star::uno::Sequence< 121 ::com::sun::star::beans::PropertyValue> & rSequence ); 122 123 protected: 124 125 virtual void StartElement( 126 const ::com::sun::star::uno::Reference< 127 ::com::sun::star::xml::sax::XAttributeList> & xAttrList); 128 129 virtual void EndElement(); 130 131 virtual SvXMLImportContext *CreateChildContext( 132 sal_uInt16 nPrefix, 133 const ::rtl::OUString& rLocalName, 134 const ::com::sun::star::uno::Reference< 135 ::com::sun::star::xml::sax::XAttributeList> & xAttrList ); 136 }; 137 138 #endif 139