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_scripting.hxx" 26 27 #include "ScriptElement.hxx" 28 #include <util/util.hxx> 29 30 using namespace ::rtl; 31 using namespace ::com::sun::star; 32 using namespace ::com::sun::star::uno; 33 34 typedef ::std::vector < ::std::pair < ::rtl::OUString, bool > > dependencies_vec; 35 typedef ::std::vector < ::std::pair < ::rtl::OUString, ::rtl::OUString > > deliveries_vec; 36 37 namespace scripting_impl 38 { 39 40 //************************************************************************* 41 /** 42 Construct a ScriptElement from a ScriptData object 43 44 @param sII 45 the ScriptDataObject 46 */ 47 ScriptElement::ScriptElement( ScriptData & sII ) : 48 XMLElement( OUSTR( "parcel" ) ), 49 m_sII( sII ) 50 { 51 OSL_TRACE( "ScriptElement ctor called\n" ); 52 53 addAttribute( OUSTR( "language" ), sII.language ); 54 addAttribute( OUSTR( "xmlns:parcel" ), OUSTR( "scripting.dtd" ) ); 55 XMLElement* xScriptElt = new XMLElement( OUSTR( "script" ) ); 56 xScriptElt->addAttribute( OUSTR( "language" ), sII.language ); 57 Reference < xml::sax::XAttributeList > xal( xScriptElt ); 58 addSubElement( xal ); 59 60 strpair_map::const_iterator mp_it = sII.locales.begin(); 61 strpair_map::const_iterator mp_itend = sII.locales.end(); 62 63 for( ; mp_it != mp_itend; ++mp_it ) 64 { 65 XMLElement* xel = new XMLElement( OUSTR( "locale" ) ); 66 xel->addAttribute( OUSTR( "lang" ), mp_it->first ); 67 68 { 69 XMLElement* subxel = new XMLElement( OUSTR( "displayname" ) ); 70 subxel->addAttribute( OUSTR( "value" ), mp_it->second.first ); 71 Reference < xml::sax::XAttributeList > subxattl( subxel ); 72 xel->addSubElement( subxattl ); 73 } 74 { 75 XMLElement* subxel = new XMLElement( OUSTR( "description" ), 76 mp_it->second.second ); 77 Reference< xml::sax::XAttributeList > subxattl( subxel ); 78 xel->addSubElement( subxattl ); 79 } 80 81 Reference < xml::sax::XAttributeList > xal( xel ); 82 xScriptElt->addSubElement( xal ); 83 } 84 85 { 86 XMLElement* xel = new XMLElement( OUSTR( "functionname" ) ); 87 xel->addAttribute( OUSTR( "value" ), sII.functionname ); 88 Reference < xml::sax::XAttributeList > xal( xel ); 89 xScriptElt->addSubElement( xal ); 90 } 91 92 { 93 XMLElement* xel = new XMLElement( OUSTR( "logicalname" ) ); 94 xel->addAttribute( OUSTR( "value" ), sII.logicalname ); 95 Reference < xml::sax::XAttributeList > xal( xel ); 96 xScriptElt->addSubElement( xal ); 97 } 98 99 props_vec::const_iterator vp_it = sII.languagedepprops.begin(); 100 props_vec::const_iterator vp_itend = sII.languagedepprops.end(); 101 102 if ( vp_it != vp_itend ) 103 { 104 XMLElement* xel = new XMLElement( OUSTR( "languagedepprops" ) ); 105 106 for( ; vp_it != vp_itend ; ++vp_it ) 107 { 108 XMLElement* subxel = new XMLElement( OUSTR( "prop" ) ); 109 subxel->addAttribute( OUSTR( "name" ), vp_it->first ); 110 subxel->addAttribute( OUSTR( "value" ), vp_it->second ); 111 Reference < xml::sax::XAttributeList > subxattl( subxel ); 112 xel->addSubElement( subxattl ); 113 } 114 115 Reference < xml::sax::XAttributeList > xal( xel ); 116 xScriptElt->addSubElement( xal ); 117 } 118 119 filesets_map::const_iterator fm_it = sII.filesets.begin(); 120 filesets_map::const_iterator fm_itend = sII.filesets.end(); 121 122 for( ; fm_it != fm_itend; ++fm_it ) 123 { 124 XMLElement* xel = new XMLElement( OUSTR( "fileset" ) ); 125 xel->addAttribute( OUSTR( "name" ), fm_it->first ); 126 127 vp_it = fm_it->second.first.begin(); 128 vp_itend = fm_it->second.first.end(); 129 130 for( ; vp_it != vp_itend; ++vp_it ) 131 { 132 XMLElement* subxel = new XMLElement( OUSTR( "prop" ) ); 133 subxel->addAttribute( OUSTR( "name" ), vp_it->first ); 134 subxel->addAttribute( OUSTR("value"), vp_it->second ); 135 Reference < xml::sax::XAttributeList > subxattl( subxel ); 136 xel->addSubElement( subxattl ); 137 } 138 139 strpairvec_map::const_iterator sm_it = fm_it->second.second.begin(); 140 strpairvec_map::const_iterator sm_itend = fm_it->second.second.end(); 141 142 if( sm_it != sm_itend ) 143 { 144 // was there a purpose for contstructing this 145 // XMLElement* subxel = new XMLElement( OUSTR( "file" ) ); 146 xel->addAttribute( OUSTR( "name" ), sm_it->first ); 147 148 } 149 } 150 } 151 152 //************************************************************************* 153 ScriptElement::~ScriptElement() SAL_THROW(()) 154 { 155 } 156 157 } // namespace scripting_impl 158