1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScriptElement.cxx,v $
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_scripting.hxx"
34 #include "ScriptElement.hxx"
35 #include <util/util.hxx>
37 using namespace ::rtl
;
38 using namespace ::com::sun::star
;
39 using namespace ::com::sun::star::uno
;
41 typedef ::std::vector
< ::std::pair
< ::rtl::OUString
, bool > > dependencies_vec
;
42 typedef ::std::vector
< ::std::pair
< ::rtl::OUString
, ::rtl::OUString
> > deliveries_vec
;
44 namespace scripting_impl
47 //*************************************************************************
49 Construct a ScriptElement from a ScriptData object
54 ScriptElement::ScriptElement( ScriptData
& sII
) :
55 XMLElement( OUSTR( "parcel" ) ),
58 OSL_TRACE( "ScriptElement ctor called\n" );
60 addAttribute( OUSTR( "language" ), sII
.language
);
61 addAttribute( OUSTR( "xmlns:parcel" ), OUSTR( "scripting.dtd" ) );
62 XMLElement
* xScriptElt
= new XMLElement( OUSTR( "script" ) );
63 xScriptElt
->addAttribute( OUSTR( "language" ), sII
.language
);
64 Reference
< xml::sax::XAttributeList
> xal( xScriptElt
);
67 strpair_map::const_iterator mp_it
= sII
.locales
.begin();
68 strpair_map::const_iterator mp_itend
= sII
.locales
.end();
70 for( ; mp_it
!= mp_itend
; ++mp_it
)
72 XMLElement
* xel
= new XMLElement( OUSTR( "locale" ) );
73 xel
->addAttribute( OUSTR( "lang" ), mp_it
->first
);
76 XMLElement
* subxel
= new XMLElement( OUSTR( "displayname" ) );
77 subxel
->addAttribute( OUSTR( "value" ), mp_it
->second
.first
);
78 Reference
< xml::sax::XAttributeList
> subxattl( subxel
);
79 xel
->addSubElement( subxattl
);
82 XMLElement
* subxel
= new XMLElement( OUSTR( "description" ),
83 mp_it
->second
.second
);
84 Reference
< xml::sax::XAttributeList
> subxattl( subxel
);
85 xel
->addSubElement( subxattl
);
88 Reference
< xml::sax::XAttributeList
> xal( xel
);
89 xScriptElt
->addSubElement( xal
);
93 XMLElement
* xel
= new XMLElement( OUSTR( "functionname" ) );
94 xel
->addAttribute( OUSTR( "value" ), sII
.functionname
);
95 Reference
< xml::sax::XAttributeList
> xal( xel
);
96 xScriptElt
->addSubElement( xal
);
100 XMLElement
* xel
= new XMLElement( OUSTR( "logicalname" ) );
101 xel
->addAttribute( OUSTR( "value" ), sII
.logicalname
);
102 Reference
< xml::sax::XAttributeList
> xal( xel
);
103 xScriptElt
->addSubElement( xal
);
106 props_vec::const_iterator vp_it
= sII
.languagedepprops
.begin();
107 props_vec::const_iterator vp_itend
= sII
.languagedepprops
.end();
109 if ( vp_it
!= vp_itend
)
111 XMLElement
* xel
= new XMLElement( OUSTR( "languagedepprops" ) );
113 for( ; vp_it
!= vp_itend
; ++vp_it
)
115 XMLElement
* subxel
= new XMLElement( OUSTR( "prop" ) );
116 subxel
->addAttribute( OUSTR( "name" ), vp_it
->first
);
117 subxel
->addAttribute( OUSTR( "value" ), vp_it
->second
);
118 Reference
< xml::sax::XAttributeList
> subxattl( subxel
);
119 xel
->addSubElement( subxattl
);
122 Reference
< xml::sax::XAttributeList
> xal( xel
);
123 xScriptElt
->addSubElement( xal
);
126 filesets_map::const_iterator fm_it
= sII
.filesets
.begin();
127 filesets_map::const_iterator fm_itend
= sII
.filesets
.end();
129 for( ; fm_it
!= fm_itend
; ++fm_it
)
131 XMLElement
* xel
= new XMLElement( OUSTR( "fileset" ) );
132 xel
->addAttribute( OUSTR( "name" ), fm_it
->first
);
134 vp_it
= fm_it
->second
.first
.begin();
135 vp_itend
= fm_it
->second
.first
.end();
137 for( ; vp_it
!= vp_itend
; ++vp_it
)
139 XMLElement
* subxel
= new XMLElement( OUSTR( "prop" ) );
140 subxel
->addAttribute( OUSTR( "name" ), vp_it
->first
);
141 subxel
->addAttribute( OUSTR("value"), vp_it
->second
);
142 Reference
< xml::sax::XAttributeList
> subxattl( subxel
);
143 xel
->addSubElement( subxattl
);
146 strpairvec_map::const_iterator sm_it
= fm_it
->second
.second
.begin();
147 strpairvec_map::const_iterator sm_itend
= fm_it
->second
.second
.end();
149 if( sm_it
!= sm_itend
)
151 // was there a purpose for contstructing this
152 // XMLElement* subxel = new XMLElement( OUSTR( "file" ) );
153 xel
->addAttribute( OUSTR( "name" ), sm_it
->first
);
159 //*************************************************************************
160 ScriptElement::~ScriptElement() SAL_THROW(())
164 } // namespace scripting_impl