fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / text / XMLAutoTextEventExport.cxx
blob0212621ad528b89214914a0eebdf22080376e4c1
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 #include "XMLAutoTextEventExport.hxx"
21 #include <com/sun/star/frame/XModel.hpp>
22 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
23 #include <com/sun/star/util/MeasureUnit.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/document/XEventsSupplier.hpp>
26 #include <com/sun/star/container/XNameReplace.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/uno/Exception.hpp>
31 #include <rtl/ustrbuf.hxx>
32 #include "xmloff/xmlnmspe.hxx"
33 #include <xmloff/nmspmap.hxx>
34 #include <xmloff/xmltoken.hxx>
35 #include <xmloff/XMLEventExport.hxx>
36 #include <tools/debug.hxx>
37 #include <tools/fldunit.hxx>
38 #include <comphelper/processfactory.hxx>
41 using namespace ::com::sun::star;
42 using namespace ::xmloff::token;
44 using ::std::set;
45 using ::com::sun::star::beans::XPropertySet;
46 using ::com::sun::star::beans::PropertyValue;
47 using ::com::sun::star::container::XNameAccess;
48 using ::com::sun::star::container::XNameReplace;
49 using ::com::sun::star::document::XEventsSupplier;
50 using ::com::sun::star::frame::XModel;
51 using ::com::sun::star::lang::XMultiServiceFactory;
52 using ::com::sun::star::uno::Any;
53 using ::com::sun::star::uno::Exception;
54 using ::com::sun::star::uno::Reference;
55 using ::com::sun::star::uno::Sequence;
56 using ::com::sun::star::uno::XInterface;
57 using ::com::sun::star::uno::UNO_QUERY;
58 using ::com::sun::star::xml::sax::XDocumentHandler;
61 XMLAutoTextEventExport::XMLAutoTextEventExport(
62 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
63 sal_uInt16 nFlags
65 : SvXMLExport(util::MeasureUnit::INCH, xContext, XML_AUTO_TEXT, nFlags)
67 sEventType("EventType"),
68 sNone("None")
72 XMLAutoTextEventExport::~XMLAutoTextEventExport()
76 void XMLAutoTextEventExport::initialize(
77 const Sequence<Any> & rArguments )
78 throw(uno::Exception, uno::RuntimeException)
80 if (rArguments.getLength() > 1)
82 Reference<XEventsSupplier> xSupplier;
83 rArguments[1] >>= xSupplier;
84 if (xSupplier.is())
86 Reference<XNameAccess> xAccess(xSupplier->getEvents(), UNO_QUERY);
87 xEvents = xAccess;
89 else
91 Reference<XNameReplace> xReplace;
92 rArguments[1] >>= xReplace;
93 if (xReplace.is())
95 Reference<XNameAccess> xAccess(xReplace, UNO_QUERY);
96 xEvents = xAccess;
98 else
100 rArguments[1] >>= xEvents;
105 // call super class (for XHandler)
106 SvXMLExport::initialize(rArguments);
110 sal_uInt32 XMLAutoTextEventExport::exportDoc( enum XMLTokenEnum )
112 if( (getExportFlags() & EXPORT_OASIS) == 0 )
114 Reference< uno::XComponentContext> xContext = getComponentContext();
118 Sequence<Any> aArgs( 1 );
119 aArgs[0] <<= GetDocHandler();
121 // get filter component
122 Reference< xml::sax::XDocumentHandler > xTmpDocHandler(
123 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
124 "com.sun.star.comp.Oasis2OOoTransformer",
125 aArgs,
126 xContext),
127 UNO_QUERY);
128 OSL_ENSURE( xTmpDocHandler.is(),
129 "can't instantiate OASIS transformer component" );
130 if( xTmpDocHandler.is() )
132 SetDocHandler( xTmpDocHandler );
135 catch( com::sun::star::uno::Exception& )
139 if (hasEvents())
141 GetDocHandler()->startDocument();
143 addChaffWhenEncryptedStorage();
145 addNamespaces();
148 // container element
149 SvXMLElementExport aContainerElement(
150 *this, XML_NAMESPACE_OOO, XML_AUTO_TEXT_EVENTS,
151 sal_True, sal_True);
153 exportEvents();
156 // and close document again
157 GetDocHandler()->endDocument();
160 return 0;
163 sal_Bool XMLAutoTextEventExport::hasEvents()
165 // TODO: provide full implementation that check for presence of events
166 return xEvents.is();
169 void XMLAutoTextEventExport::addNamespaces()
171 // namespaces for office:, text: and script:
172 GetAttrList().AddAttribute(
173 GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_OFFICE ),
174 GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_OFFICE ) );
175 GetAttrList().AddAttribute(
176 GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_TEXT ),
177 GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_TEXT ) );
178 GetAttrList().AddAttribute(
179 GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_SCRIPT ),
180 GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_SCRIPT ) );
181 GetAttrList().AddAttribute(
182 GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_DOM ),
183 GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_DOM ) );
184 GetAttrList().AddAttribute(
185 GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_OOO ),
186 GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_OOO ) );
187 GetAttrList().AddAttribute(
188 GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_XLINK ),
189 GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_XLINK ) );
192 void XMLAutoTextEventExport::exportEvents()
194 DBG_ASSERT(hasEvents(), "no events to export!");
196 GetEventExport().Export(xEvents, sal_True);
201 // methods without content:
203 void XMLAutoTextEventExport::_ExportMeta() {}
204 void XMLAutoTextEventExport::_ExportScripts() {}
205 void XMLAutoTextEventExport::_ExportFontDecls() {}
206 void XMLAutoTextEventExport::_ExportStyles( sal_Bool ) {}
207 void XMLAutoTextEventExport::_ExportAutoStyles() {}
208 void XMLAutoTextEventExport::_ExportMasterStyles() {}
209 void XMLAutoTextEventExport::_ExportContent() {}
213 // methods to support the component registration
215 Sequence< OUString > SAL_CALL XMLAutoTextEventExport_getSupportedServiceNames()
216 throw()
218 Sequence< OUString > aSeq( 1 );
219 aSeq[0] = XMLAutoTextEventExport_getImplementationName();
220 return aSeq;
223 OUString SAL_CALL XMLAutoTextEventExport_getImplementationName() throw()
225 return OUString( "com.sun.star.comp.Writer.XMLOasisAutotextEventsExporter" );
228 Reference< XInterface > SAL_CALL XMLAutoTextEventExport_createInstance(
229 const Reference< XMultiServiceFactory > & rSMgr)
230 throw( Exception )
232 return (cppu::OWeakObject*)new XMLAutoTextEventExport( comphelper::getComponentContext(rSMgr), EXPORT_ALL|EXPORT_OASIS);
235 // methods to support the component registration
237 Sequence< OUString > SAL_CALL XMLAutoTextEventExportOOO_getSupportedServiceNames()
238 throw()
240 Sequence< OUString > aSeq( 1 );
241 aSeq[0] = XMLAutoTextEventExportOOO_getImplementationName();
242 return aSeq;
245 OUString SAL_CALL XMLAutoTextEventExportOOO_getImplementationName() throw()
247 return OUString( "com.sun.star.comp.Writer.XMLAutotextEventsExporter" );
250 Reference< XInterface > SAL_CALL XMLAutoTextEventExportOOO_createInstance(
251 const Reference< XMultiServiceFactory > & rSMgr)
252 throw( Exception )
254 return (cppu::OWeakObject*)new XMLAutoTextEventExport( comphelper::getComponentContext(rSMgr),EXPORT_ALL);
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */