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: xmlelem.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 ************************************************************************/
32 #include <xmlelem.hxx>
35 // NOT FULLY DEFINED SERVICES
37 #include <cr_html.hxx>
39 #if OSL_DEBUG_LEVEL == 0
48 XmlElement::XmlElement( const char * i_sName
)
54 XmlElement::Insert2Index( Index
& ) const
56 // Default version. Does nothing.
60 MultipleElement::FindChild( const Simstr
& i_sChildName
)
62 unsigned i_max
= aChildren
.size();
63 for ( unsigned i
= 0; i
< i_max
; ++i
)
65 if ( aChildren
[i
]->Name() == i_sChildName
)
72 MultipleElement::~MultipleElement()
76 MultipleElement::MultipleElement( const char * i_sName
)
82 MultipleElement::AddChild( XmlElement
& let_drElement
)
84 aChildren
.push_back(&let_drElement
);
88 SequenceElement::Parse( X2CParser
& io_rParser
)
90 io_rParser
.Parse_Sequence( Children(), Name() );
94 SequenceElement::Write2Html( HtmlCreator
& io_rHC
) const
98 Children()[nIndexNameElement
]->Write2Html(io_rHC
);
99 for ( unsigned i
= 0; i
< Children().size(); ++i
)
101 if (i
!= nIndexNameElement
)
103 Children()[i
]->Write2Html(io_rHC
);
107 io_rHC
.FinishTable();
111 SequenceElement::SequenceElement( const char * i_sName
,
112 unsigned i_nIndexNameElement
)
113 : MultipleElement(i_sName
),
114 nIndexNameElement(i_nIndexNameElement
)
118 FreeChoiceElement::FreeChoiceElement()
119 : MultipleElement("")
124 FreeChoiceElement::Parse( X2CParser
& io_rParser
)
126 io_rParser
.Parse_FreeChoice(Children());
130 FreeChoiceElement::Write2Html( HtmlCreator
& io_rHC
) const
132 for ( unsigned i
= 0; i
< Children().size(); ++i
)
134 Children()[i
]->Write2Html(io_rHC
);
138 ListElement::ListElement( const char * i_sElementsName
,
139 F_CREATE i_fCreateNewElement
)
140 : MultipleElement(i_sElementsName
),
141 fCreateNewElement(i_fCreateNewElement
)
146 ListElement::Parse( X2CParser
& io_rParser
)
148 io_rParser
.Parse_List( *this );
152 ListElement::Write2Html( HtmlCreator
& io_rHC
) const
154 for ( unsigned i
= 0; i
< Children().size(); ++i
)
156 Children()[i
]->Write2Html(io_rHC
);
161 ListElement::Create_and_Add_NewElement()
163 assert(fCreateNewElement
!= 0);
164 XmlElement
* pNew
= (*fCreateNewElement
)(Name());
165 Children().push_back( pNew
);
169 TextElement::TextElement( const char * i_sName
,
170 E_LinkType i_eLinkType
,
171 bool i_bReverseName
)
172 : XmlElement(i_sName
),
173 eLinkType(i_eLinkType
),
174 bReverseName(i_bReverseName
)
178 SglTextElement::SglTextElement( const char * i_sName
,
179 E_LinkType i_eLinkType
,
180 bool i_bReverseName
)
181 : TextElement(i_sName
, i_eLinkType
, i_bReverseName
)
186 SglTextElement::Parse( X2CParser
& io_rParser
)
188 io_rParser
.Parse_Text(sContent
, Name(), IsReversedName());
192 SglTextElement::Write2Html( HtmlCreator
& io_rHC
) const
194 if ( !sContent
.is_no_text() )
195 io_rHC
.Write_SglTextElement( *this );
198 MultipleTextElement::MultipleTextElement( const char * i_sName
,
199 E_LinkType i_eLinkType
,
200 bool i_bReverseName
)
201 : TextElement(i_sName
, i_eLinkType
, i_bReverseName
)
206 MultipleTextElement::Parse( X2CParser
& io_rParser
)
208 io_rParser
.Parse_MultipleText(aContent
, Name(), IsReversedName());
212 MultipleTextElement::Write2Html( HtmlCreator
& io_rHC
) const
215 io_rHC
.Write_MultiTextElement( *this );
219 MultipleTextElement::Data( unsigned i_nNr
) const
221 static const Simstr sNull_
;
223 if (aContent
.is_valid_index(i_nNr
))
224 return aContent
[i_nNr
];
228 EmptyElement::EmptyElement( const char * i_sName
)
229 : XmlElement(i_sName
)
233 SglAttrElement::SglAttrElement( const char * i_sName
,
234 const char * i_sAttrName
)
235 : EmptyElement(i_sName
),
236 sAttrName(i_sAttrName
)
241 SglAttrElement::Parse( X2CParser
& io_rParser
)
243 io_rParser
.Parse_SglAttr(sAttrValue
, Name(), sAttrName
);
247 SglAttrElement::Write2Html( HtmlCreator
& io_rHC
) const
249 io_rHC
.Write_SglText( Name(), sAttrValue
);
252 MultipleAttrElement::MultipleAttrElement( const char * i_sName
,
253 const char ** i_sAttrNames
,
255 : EmptyElement(i_sName
)
257 for ( unsigned i
= 0; i
< i_nSize
; ++i
)
259 aAttrNames
.push_back(Simstr(i_sAttrNames
[i
]));
260 aAttrValues
.push_back(Simstr(""));
265 MultipleAttrElement::Parse( X2CParser
& io_rParser
)
267 io_rParser
.Parse_MultipleAttr(aAttrValues
, Name(), aAttrNames
);
271 MultipleAttrElement::Write2Html( HtmlCreator
& io_rHC
) const
273 if ( ! aAttrValues
[0].is_no_text() )
274 io_rHC
.Write_ReferenceDocu( Name(), aAttrValues
[0], aAttrValues
[1], aAttrValues
[2] );