1*e1d5bd03SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*e1d5bd03SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e1d5bd03SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e1d5bd03SAndrew Rist  * distributed with this work for additional information
6*e1d5bd03SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e1d5bd03SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e1d5bd03SAndrew Rist  * "License"); you may not use this file except in compliance
9*e1d5bd03SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e1d5bd03SAndrew Rist  *
11*e1d5bd03SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e1d5bd03SAndrew Rist  *
13*e1d5bd03SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e1d5bd03SAndrew Rist  * software distributed under the License is distributed on an
15*e1d5bd03SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e1d5bd03SAndrew Rist  * KIND, either express or implied.  See the License for the
17*e1d5bd03SAndrew Rist  * specific language governing permissions and limitations
18*e1d5bd03SAndrew Rist  * under the License.
19*e1d5bd03SAndrew Rist  *
20*e1d5bd03SAndrew Rist  *************************************************************/
21*e1d5bd03SAndrew Rist 
22*e1d5bd03SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlscript.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <xmlscript/xmlmod_imexp.hxx>
28cdf0e10cSrcweir #include <xmlscript/xml_helper.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using namespace com::sun::star::uno;
31cdf0e10cSrcweir using namespace com::sun::star;
32cdf0e10cSrcweir using namespace rtl;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace xmlscript
35cdf0e10cSrcweir {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //==================================================================================================
38cdf0e10cSrcweir 
39cdf0e10cSrcweir void
exportScriptModule(Reference<xml::sax::XExtendedDocumentHandler> const & xOut,const ModuleDescriptor & rMod)40cdf0e10cSrcweir SAL_CALL exportScriptModule(
41cdf0e10cSrcweir 	Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
42cdf0e10cSrcweir 	const ModuleDescriptor& rMod )
43cdf0e10cSrcweir 		SAL_THROW( (Exception) )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	xOut->startDocument();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
48cdf0e10cSrcweir         "<!DOCTYPE script:module PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
49cdf0e10cSrcweir         " \"module.dtd\">" ) );
50cdf0e10cSrcweir 	xOut->unknown( aDocTypeStr );
51cdf0e10cSrcweir 	xOut->ignorableWhitespace( OUString() );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":module") );
54cdf0e10cSrcweir 	XMLElement* pModElement = new XMLElement( aModuleName );
55cdf0e10cSrcweir 	Reference< xml::sax::XAttributeList > xAttributes( pModElement );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ),
58cdf0e10cSrcweir 							    OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":name") ),
61cdf0e10cSrcweir 								rMod.aName );
62cdf0e10cSrcweir 	pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
63cdf0e10cSrcweir 								rMod.aLanguage );
64cdf0e10cSrcweir 	if( rMod.aModuleType.getLength()>0 )
65cdf0e10cSrcweir 		pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":moduleType") ),
66cdf0e10cSrcweir 									rMod.aModuleType );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	xOut->ignorableWhitespace( OUString() );
69cdf0e10cSrcweir 	xOut->startElement( aModuleName, xAttributes );
70cdf0e10cSrcweir 	xOut->characters( rMod.aCode );
71cdf0e10cSrcweir 	xOut->endElement( aModuleName );
72cdf0e10cSrcweir 	xOut->endDocument();
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77