1*2c696243SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2c696243SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2c696243SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2c696243SAndrew Rist  * distributed with this work for additional information
6*2c696243SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2c696243SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2c696243SAndrew Rist  * "License"); you may not use this file except in compliance
9*2c696243SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2c696243SAndrew Rist  *
11*2c696243SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2c696243SAndrew Rist  *
13*2c696243SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2c696243SAndrew Rist  * software distributed under the License is distributed on an
15*2c696243SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2c696243SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2c696243SAndrew Rist  * specific language governing permissions and limitations
18*2c696243SAndrew Rist  * under the License.
19*2c696243SAndrew Rist  *
20*2c696243SAndrew Rist  *************************************************************/
21*2c696243SAndrew Rist 
22*2c696243SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_scripting.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "ScriptElement.hxx"
28cdf0e10cSrcweir #include <util/util.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using namespace ::rtl;
31cdf0e10cSrcweir using namespace ::com::sun::star;
32cdf0e10cSrcweir using namespace ::com::sun::star::uno;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir typedef ::std::vector < ::std::pair < ::rtl::OUString, bool > >  dependencies_vec;
35cdf0e10cSrcweir typedef ::std::vector < ::std::pair < ::rtl::OUString, ::rtl::OUString > > deliveries_vec;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace scripting_impl
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //*************************************************************************
41cdf0e10cSrcweir /**
42cdf0e10cSrcweir     Construct a ScriptElement from a ScriptData object
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     @param sII
45cdf0e10cSrcweir     the ScriptDataObject
46cdf0e10cSrcweir */
ScriptElement(ScriptData & sII)47cdf0e10cSrcweir ScriptElement::ScriptElement( ScriptData & sII ) :
48cdf0e10cSrcweir         XMLElement( OUSTR( "parcel" ) ),
49cdf0e10cSrcweir         m_sII( sII )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     OSL_TRACE( "ScriptElement ctor called\n" );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     addAttribute( OUSTR( "language" ), sII.language );
54cdf0e10cSrcweir     addAttribute( OUSTR( "xmlns:parcel" ), OUSTR( "scripting.dtd" ) );
55cdf0e10cSrcweir     XMLElement* xScriptElt = new XMLElement( OUSTR( "script" ) );
56cdf0e10cSrcweir     xScriptElt->addAttribute( OUSTR( "language" ), sII.language );
57cdf0e10cSrcweir     Reference < xml::sax::XAttributeList > xal( xScriptElt );
58cdf0e10cSrcweir     addSubElement( xal );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     strpair_map::const_iterator mp_it = sII.locales.begin();
61cdf0e10cSrcweir     strpair_map::const_iterator mp_itend = sII.locales.end();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     for( ; mp_it != mp_itend; ++mp_it )
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         XMLElement* xel = new XMLElement( OUSTR( "locale" ) );
66cdf0e10cSrcweir         xel->addAttribute( OUSTR( "lang" ), mp_it->first );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         {
69cdf0e10cSrcweir             XMLElement* subxel = new XMLElement( OUSTR( "displayname" ) );
70cdf0e10cSrcweir             subxel->addAttribute( OUSTR( "value" ), mp_it->second.first );
71cdf0e10cSrcweir             Reference < xml::sax::XAttributeList > subxattl( subxel );
72cdf0e10cSrcweir             xel->addSubElement( subxattl );
73cdf0e10cSrcweir         }
74cdf0e10cSrcweir         {
75cdf0e10cSrcweir             XMLElement* subxel = new XMLElement( OUSTR( "description" ),
76cdf0e10cSrcweir                                      mp_it->second.second );
77cdf0e10cSrcweir             Reference< xml::sax::XAttributeList > subxattl( subxel );
78cdf0e10cSrcweir             xel->addSubElement( subxattl );
79cdf0e10cSrcweir         }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         Reference < xml::sax::XAttributeList > xal( xel );
82cdf0e10cSrcweir         xScriptElt->addSubElement( xal );
83cdf0e10cSrcweir     }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     {
86cdf0e10cSrcweir         XMLElement* xel = new XMLElement( OUSTR( "functionname" ) );
87cdf0e10cSrcweir         xel->addAttribute( OUSTR( "value" ), sII.functionname );
88cdf0e10cSrcweir         Reference < xml::sax::XAttributeList > xal( xel );
89cdf0e10cSrcweir         xScriptElt->addSubElement( xal );
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         XMLElement* xel = new XMLElement( OUSTR( "logicalname" ) );
94cdf0e10cSrcweir         xel->addAttribute( OUSTR( "value" ), sII.logicalname );
95cdf0e10cSrcweir         Reference < xml::sax::XAttributeList > xal( xel );
96cdf0e10cSrcweir         xScriptElt->addSubElement( xal );
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     props_vec::const_iterator vp_it = sII.languagedepprops.begin();
100cdf0e10cSrcweir     props_vec::const_iterator vp_itend = sII.languagedepprops.end();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     if ( vp_it != vp_itend )
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         XMLElement* xel = new XMLElement( OUSTR( "languagedepprops" ) );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         for( ; vp_it != vp_itend ; ++vp_it )
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir             XMLElement* subxel =  new XMLElement( OUSTR( "prop" ) );
109cdf0e10cSrcweir             subxel->addAttribute( OUSTR( "name" ), vp_it->first );
110cdf0e10cSrcweir             subxel->addAttribute( OUSTR( "value" ), vp_it->second );
111cdf0e10cSrcweir             Reference < xml::sax::XAttributeList > subxattl( subxel );
112cdf0e10cSrcweir             xel->addSubElement( subxattl );
113cdf0e10cSrcweir         }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         Reference < xml::sax::XAttributeList > xal( xel );
116cdf0e10cSrcweir         xScriptElt->addSubElement( xal );
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     filesets_map::const_iterator fm_it = sII.filesets.begin();
120cdf0e10cSrcweir     filesets_map::const_iterator fm_itend = sII.filesets.end();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     for( ; fm_it != fm_itend; ++fm_it )
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir         XMLElement* xel = new XMLElement( OUSTR( "fileset" ) );
125cdf0e10cSrcweir         xel->addAttribute( OUSTR( "name" ), fm_it->first );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         vp_it = fm_it->second.first.begin();
128cdf0e10cSrcweir         vp_itend = fm_it->second.first.end();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         for( ; vp_it != vp_itend; ++vp_it )
131cdf0e10cSrcweir         {
132cdf0e10cSrcweir             XMLElement* subxel = new XMLElement( OUSTR( "prop" ) );
133cdf0e10cSrcweir             subxel->addAttribute( OUSTR( "name" ), vp_it->first );
134cdf0e10cSrcweir             subxel->addAttribute( OUSTR("value"), vp_it->second );
135cdf0e10cSrcweir             Reference < xml::sax::XAttributeList > subxattl( subxel );
136cdf0e10cSrcweir             xel->addSubElement( subxattl );
137cdf0e10cSrcweir        }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir        strpairvec_map::const_iterator sm_it = fm_it->second.second.begin();
140cdf0e10cSrcweir        strpairvec_map::const_iterator sm_itend = fm_it->second.second.end();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir        if( sm_it != sm_itend )
143cdf0e10cSrcweir        {
144cdf0e10cSrcweir            // was there a purpose for contstructing this
145cdf0e10cSrcweir            // XMLElement* subxel = new XMLElement( OUSTR( "file" ) );
146cdf0e10cSrcweir            xel->addAttribute( OUSTR( "name" ), sm_it->first );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir        }
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir //*************************************************************************
~ScriptElement()153cdf0e10cSrcweir ScriptElement::~ScriptElement() SAL_THROW(())
154cdf0e10cSrcweir {
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir } // namespace scripting_impl
158