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
exportScriptModule(Reference<xml::sax::XExtendedDocumentHandler> const & xOut,const ModuleDescriptor & rMod)40 SAL_CALL exportScriptModule(
41 Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
42 const ModuleDescriptor& rMod )
43 SAL_THROW( (Exception) )
44 {
45 xOut->startDocument();
46
47 OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
48 "<!DOCTYPE script:module PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
49 " \"module.dtd\">" ) );
50 xOut->unknown( aDocTypeStr );
51 xOut->ignorableWhitespace( OUString() );
52
53 OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":module") );
54 XMLElement* pModElement = new XMLElement( aModuleName );
55 Reference< xml::sax::XAttributeList > xAttributes( pModElement );
56
57 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ),
58 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) );
59
60 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":name") ),
61 rMod.aName );
62 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
63 rMod.aLanguage );
64 if( rMod.aModuleType.getLength()>0 )
65 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":moduleType") ),
66 rMod.aModuleType );
67
68 xOut->ignorableWhitespace( OUString() );
69 xOut->startElement( aModuleName, xAttributes );
70 xOut->characters( rMod.aCode );
71 xOut->endElement( aModuleName );
72 xOut->endDocument();
73 }
74
75 }
76
77