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_xmlscript.hxx" 26 27 #include <xmlscript/xmlmod_imexp.hxx> 28 #include <xmlscript/xml_helper.hxx> 29 30 using namespace com::sun::star::uno; 31 using namespace com::sun::star; 32 using namespace rtl; 33 34 namespace xmlscript 35 { 36 37 //================================================================================================== 38 39 void 40 SAL_CALL exportScriptModule( 41 Reference< xml::sax::XExtendedDocumentHandler > const & xOut, 42 const ModuleDescriptor& rMod ) 43 { 44 xOut->startDocument(); 45 46 OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM( 47 "<!DOCTYPE script:module PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\"" 48 " \"module.dtd\">" ) ); 49 xOut->unknown( aDocTypeStr ); 50 xOut->ignorableWhitespace( OUString() ); 51 52 OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":module") ); 53 XMLElement* pModElement = new XMLElement( aModuleName ); 54 Reference< xml::sax::XAttributeList > xAttributes( pModElement ); 55 56 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ), 57 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) ); 58 59 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":name") ), 60 rMod.aName ); 61 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ), 62 rMod.aLanguage ); 63 if( rMod.aModuleType.getLength()>0 ) 64 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":moduleType") ), 65 rMod.aModuleType ); 66 67 xOut->ignorableWhitespace( OUString() ); 68 xOut->startElement( aModuleName, xAttributes ); 69 xOut->characters( rMod.aCode ); 70 xOut->endElement( aModuleName ); 71 xOut->endDocument(); 72 } 73 74 } 75