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_XMLAUTOTEXTEVENTEXPORT_HXX
29 #define _XMLOFF_XMLAUTOTEXTEVENTEXPORT_HXX
30 
31 #include <xmloff/xmlexp.hxx>
32 
33 #include <set>
34 
35 
36 namespace rtl {	class OUString; }
37 namespace com { namespace sun { namespace star {
38 	namespace container { class XNameAccess; }
39 	namespace frame { class XModel; }
40 	namespace lang { class XMultiServiceFactory; }
41 	namespace uno { template<class X> class Reference; }
42 	namespace uno { template<class X> class Sequence; }
43 	namespace uno { class XInterface; }
44 	namespace uno { class Exception; }
45 	namespace xml { namespace sax { class XDocumentHandler; } }
46 } } }
47 
48 
49 /**
50  * Component for the export of events attached to autotext blocks.
51  * Via the XInitialization interface it expects up to two strings, the
52  * first giving the file name (URL) of the autotext group, and the second
53  * identifying the autotext. If one of the strings is not given, it
54  * will export the whole group / all groups.
55  */
56 class XMLAutoTextEventExport : public SvXMLExport
57 {
58 	::com::sun::star::uno::Reference<
59 		::com::sun::star::container::XNameAccess> xEvents;
60 
61 	const ::rtl::OUString sEventType;
62 	const ::rtl::OUString sNone;
63 
64 
65 public:
66 
67 	// #110680#
68 	//XMLAutoTextEventExport();
69 	XMLAutoTextEventExport(
70 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, sal_uInt16 nFlags
71 		);
72 
73 	// #110680#
74 	//XMLAutoTextEventExport(
75 	//	const ::rtl::OUString& rFileName,
76 	//	const ::com::sun::star::uno::Reference<
77 	//		::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
78 	//	const ::com::sun::star::uno::Reference<
79 	//		::com::sun::star::frame::XModel > & rModel,
80 	//	const ::com::sun::star::uno::Reference<
81 	//		::com::sun::star::container::XNameAccess > & rEvents);
82 	XMLAutoTextEventExport(
83 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
84 		const ::rtl::OUString& rFileName,
85 		const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
86 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
87 		const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & rEvents, sal_uInt16 nFlags);
88 
89 	~XMLAutoTextEventExport();
90 
91 	// XInitialization
92     virtual void SAL_CALL initialize(
93 		const ::com::sun::star::uno::Sequence<
94 			::com::sun::star::uno::Any> & rArguments )
95 		throw(
96 			::com::sun::star::uno::Exception,
97 			::com::sun::star::uno::RuntimeException);
98 
99 protected:
100 
101 	/// export the events off all autotexts
102 	virtual sal_uInt32 exportDoc(
103         enum ::xmloff::token::XMLTokenEnum eClass = xmloff::token::XML_TOKEN_INVALID );
104 
105 	/// does the document have any events ?
106 	sal_Bool hasEvents();
107 
108 	/// export the events element
109 	void exportEvents();
110 
111 
112 	/// add the namespaces used by events
113 	/// (to be called for the document element)
114 	void addNamespaces();
115 
116 
117 	// methods without content:
118 	virtual void _ExportMeta();
119 	virtual void _ExportScripts();
120 	virtual void _ExportFontDecls();
121 	virtual void _ExportStyles( sal_Bool bUsed ) ;
122 	virtual void _ExportAutoStyles();
123 	virtual void _ExportMasterStyles();
124 	virtual void _ExportChangeTracking();
125 	virtual void _ExportContent();
126 };
127 
128 
129 
130 // global functions to support the component
131 
132 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
133 	XMLAutoTextEventExport_getSupportedServiceNames()
134 	throw();
135 
136 ::rtl::OUString SAL_CALL XMLAutoTextEventExport_getImplementationName()
137 	throw();
138 
139 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
140 	XMLAutoTextEventExportOOO_createInstance(
141 		const ::com::sun::star::uno::Reference<
142 			::com::sun::star::lang::XMultiServiceFactory > & )
143 	throw( ::com::sun::star::uno::Exception );
144 
145 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
146 	XMLAutoTextEventExportOOO_getSupportedServiceNames()
147 	throw();
148 
149 ::rtl::OUString SAL_CALL XMLAutoTextEventExportOOO_getImplementationName()
150 	throw();
151 
152 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
153 	XMLAutoTextEventExportOOO_createInstance(
154 		const ::com::sun::star::uno::Reference<
155 			::com::sun::star::lang::XMultiServiceFactory > & )
156 	throw( ::com::sun::star::uno::Exception );
157 
158 #endif
159 
160