1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "XMLScriptExportHandler.hxx"
27
28 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP
29 #include <com/sun/star/beans/PropertyValue.hpp>
30 #endif
31 #include <tools/debug.hxx>
32 #include <xmloff/xmlexp.hxx>
33 #include <xmloff/xmltoken.hxx>
34 #include <xmloff/nmspmap.hxx>
35 #include "xmloff/xmlnmspe.hxx"
36
37
38 using namespace ::com::sun::star::uno;
39 using namespace ::xmloff::token;
40
41 using ::rtl::OUString;
42 using ::com::sun::star::beans::PropertyValue;
43
44
XMLScriptExportHandler()45 XMLScriptExportHandler::XMLScriptExportHandler() :
46 sURL(RTL_CONSTASCII_USTRINGPARAM("Script"))
47 {
48 }
49
~XMLScriptExportHandler()50 XMLScriptExportHandler::~XMLScriptExportHandler()
51 {
52 }
53
Export(SvXMLExport & rExport,const OUString & rEventQName,Sequence<PropertyValue> & rValues,sal_Bool bUseWhitespace)54 void XMLScriptExportHandler::Export(
55 SvXMLExport& rExport,
56 const OUString& rEventQName,
57 Sequence<PropertyValue> & rValues,
58 sal_Bool bUseWhitespace)
59 {
60
61 rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_LANGUAGE,
62 rExport.GetNamespaceMap().GetQNameByKey(
63 XML_NAMESPACE_OOO, GetXMLToken(XML_SCRIPT) ) );
64 rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, rEventQName);
65
66 sal_Int32 nCount = rValues.getLength();
67 for(sal_Int32 i = 0; i < nCount; i++)
68 {
69 if (sURL.equals(rValues[i].Name))
70 {
71 OUString sTmp;
72 rValues[i].Value >>= sTmp;
73 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sTmp);
74
75 // #i110911# xlink:type="simple" is required
76 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
77 }
78 // else: disregard
79 }
80
81 SvXMLElementExport aEventElemt(rExport, XML_NAMESPACE_SCRIPT,
82 XML_EVENT_LISTENER,
83 bUseWhitespace, sal_False);
84 }
85