merge the formfield patch from ooo-build
[ooovba.git] / xmlscript / source / xmlmod_imexp / xmlmod_export.cxx
bloba14f62e8f96226f10d4f5a67a550c08a65d484c2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlmod_export.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlscript.hxx"
34 #include <xmlscript/xmlmod_imexp.hxx>
35 #include <xmlscript/xml_helper.hxx>
37 using namespace com::sun::star::uno;
38 using namespace com::sun::star;
39 using namespace rtl;
41 namespace xmlscript
44 //==================================================================================================
46 void
47 SAL_CALL exportScriptModule(
48 Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
49 const ModuleDescriptor& rMod )
50 SAL_THROW( (Exception) )
52 xOut->startDocument();
54 OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
55 "<!DOCTYPE script:module PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
56 " \"module.dtd\">" ) );
57 xOut->unknown( aDocTypeStr );
58 xOut->ignorableWhitespace( OUString() );
60 OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":module") );
61 XMLElement* pModElement = new XMLElement( aModuleName );
62 Reference< xml::sax::XAttributeList > xAttributes( pModElement );
64 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ),
65 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) );
67 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":name") ),
68 rMod.aName );
69 pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
70 rMod.aLanguage );
72 xOut->ignorableWhitespace( OUString() );
73 xOut->startElement( aModuleName, xAttributes );
74 xOut->characters( rMod.aCode );
75 xOut->endElement( aModuleName );
76 xOut->endDocument();