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 "XMLStarBasicExportHandler.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 ::rtl::OUStringBuffer; 43 using ::com::sun::star::beans::PropertyValue; 44 45 46 XMLStarBasicExportHandler::XMLStarBasicExportHandler() : 47 sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")), 48 sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")), 49 sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")), 50 sStarOffice(RTL_CONSTASCII_USTRINGPARAM("StarOffice")), 51 sApplication(RTL_CONSTASCII_USTRINGPARAM("application")) 52 { 53 } 54 55 XMLStarBasicExportHandler::~XMLStarBasicExportHandler() 56 { 57 } 58 59 void XMLStarBasicExportHandler::Export( 60 SvXMLExport& rExport, 61 const OUString& rEventQName, 62 Sequence<PropertyValue> & rValues, 63 sal_Bool bUseWhitespace) 64 { 65 rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_LANGUAGE, 66 rExport.GetNamespaceMap().GetQNameByKey( 67 XML_NAMESPACE_OOO, sStarBasic ) ); 68 rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, rEventQName); 69 70 OUString sLocation, sName; 71 sal_Int32 nCount = rValues.getLength(); 72 for(sal_Int32 i = 0; i < nCount; i++) 73 { 74 if (sLibrary.equals(rValues[i].Name)) 75 { 76 OUString sTmp; 77 rValues[i].Value >>= sTmp; 78 sLocation = GetXMLToken( 79 (sTmp.equalsIgnoreAsciiCase(sApplication) || 80 sTmp.equalsIgnoreAsciiCase(sStarOffice) ) ? XML_APPLICATION 81 : XML_DOCUMENT ); 82 } 83 else if (sMacroName.equals(rValues[i].Name)) 84 { 85 rValues[i].Value >>= sName; 86 } 87 // else: disregard 88 } 89 90 if( sLocation.getLength() ) 91 { 92 OUStringBuffer sTmp( sLocation.getLength() + sName.getLength() + 1 ); 93 sTmp = sLocation; 94 sTmp.append( sal_Unicode( ':' ) ); 95 sTmp.append( sName ); 96 rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME, 97 sTmp.makeStringAndClear()); 98 } 99 else 100 { 101 rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME, sName ); 102 } 103 104 SvXMLElementExport aEventElemt(rExport, XML_NAMESPACE_SCRIPT, 105 XML_EVENT_LISTENER, 106 bUseWhitespace, sal_False); 107 } 108