merge the formfield patch from ooo-build
[ooovba.git] / xml2cmp / source / xcd / xmltree.cxx
blobd7bf6e9934aa511df57de5a3be7a22ebe7b64ac7
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: xmltree.cxx,v $
10 * $Revision: 1.6 $
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 <xmltree.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <cr_html.hxx>
37 #include <cr_index.hxx>
40 char C_sMODULEDESCRIPTION[] = "module-description";
41 char C_sCOMPONENTDESCRIPTION[] = "component-description";
42 char C_sAuthor[] = "author";
43 char C_sName[] = "name";
44 char C_sDescription[] = "description";
45 char C_sReferenceDocu[] = "reference-docu";
46 char C_sModuleName[] = "module-name";
47 char C_sLoaderName[] = "loader-name";
48 char C_sSupportedService[] = "supported-service";
49 char C_sServiceDependency[] = "service-dependency";
50 char C_sProjectBuildDependency[] = "project-build-dependency";
51 char C_sRuntimeModuleDependency[] = "runtime-module-dependency";
52 char C_sLanguage[] = "language";
53 char C_sStatus[] = "status";
54 char C_sType[] = "type";
55 char C_sAttr_value[] = "value";
56 char C_sAttr_xl_href[] = "xlink:href";
57 char C_sAttr_xl_role[] = "xlink:role";
58 char C_sAttr_xl_title[] = "xlink:title";
59 char C_sAttr_xmlns[] = "xmlns:xlink";
60 char C_sAttr_xl_type[] = "xlink:type";
61 char C_sCompDescrListTitle[] = "Component Descriptions";
64 FreeChoiceElement * Create_ModuleDescrOptional_Element(
65 MultipleTextElement * &
66 o_rTypes,
67 MultipleTextElement * &
68 o_rServiceDependencies );
69 FreeChoiceElement * Create_CompDescrOptional_Element(
70 MultipleTextElement * &
71 o_rTypes,
72 MultipleTextElement * &
73 o_rServiceDependencies );
77 ModuleDescription::ModuleDescription()
78 : SequenceElement(C_sMODULEDESCRIPTION),
79 pModuleName(0),
80 pCdList(0),
81 pTypes(0),
82 pServiceDependencies(0)
84 pModuleName = new MdName;
85 AddChild( *pModuleName );
86 pCdList = new CompDescrList;
87 AddChild( *pCdList );
88 AddChild( *Create_ModuleDescrOptional_Element( pTypes, pServiceDependencies ) );
91 const Simstr &
92 ModuleDescription::ModuleName() const
94 return pModuleName->Data();
97 void
98 ModuleDescription::Get_SupportedServices( List< const MultipleTextElement * > & o_rServices ) const
100 o_rServices.push_back(pServiceDependencies);
101 pCdList->Get_SupportedServices( o_rServices );
104 void
105 ModuleDescription::Get_Types( List< const MultipleTextElement * > & o_rTypes ) const
107 o_rTypes.push_back(pTypes);
108 pCdList->Get_Types( o_rTypes );
111 void
112 ModuleDescription::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rServices ) const
114 pCdList->Get_ServiceDependencies( o_rServices );
117 ComponentDescription::ComponentDescription()
118 : SequenceElement(C_sCOMPONENTDESCRIPTION,1),
119 pComponentName(0),
120 pSupportedServices(0),
121 pTypes(0),
122 pServiceDependencies(0)
124 AddChild( *new SglTextElement(C_sAuthor, lt_nolink, false) );
125 pComponentName = new CdName;
126 AddChild( *pComponentName );
127 AddChild( *new SglTextElement(C_sDescription, lt_nolink, false) );
128 AddChild( *new SglTextElement(C_sLoaderName, lt_idl, true) );
129 AddChild( *new SglTextElement(C_sLanguage, lt_nolink, false) );
130 AddChild( *new SglAttrElement(C_sStatus, C_sAttr_value) );
131 pSupportedServices = new SupportedService;
132 AddChild( *pSupportedServices );
133 AddChild( *Create_CompDescrOptional_Element( pTypes, pServiceDependencies ) );
136 CompDescrList::CompDescrList()
137 : ListElement(C_sCOMPONENTDESCRIPTION, 0)
141 void
142 CompDescrList::Write2Html( HtmlCreator & io_rHC ) const
144 io_rHC.StartBigCell(C_sCompDescrListTitle);
145 ListElement::Write2Html(io_rHC);
146 io_rHC.FinishBigCell();
149 XmlElement *
150 CompDescrList::Create_and_Add_NewElement()
152 ComponentDescription * pCD = new ComponentDescription;
153 Children().push_back(pCD);
154 aCDs.push_back(pCD);
155 return pCD;
158 void
159 CompDescrList::Get_SupportedServices( List< const MultipleTextElement * > & o_rResult ) const
161 unsigned i_max = aCDs.size();;
162 for (unsigned i = 0; i < i_max; ++i)
164 o_rResult.push_back(& aCDs[i]->SupportedServices());
165 } // end for
168 void
169 CompDescrList::Get_Types( List< const MultipleTextElement * > & o_rResult ) const
171 unsigned i_max = aCDs.size();;
172 for (unsigned i = 0; i < i_max; ++i)
174 o_rResult.push_back(& aCDs[i]->Types());
175 } // end for
178 void
179 CompDescrList::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rResult ) const
181 unsigned i_max = aCDs.size();;
182 for (unsigned i = 0; i < i_max; ++i)
184 o_rResult.push_back(& aCDs[i]->ServiceDependencies());
185 } // end for
188 MdName::MdName()
189 : SglTextElement(C_sModuleName, lt_html, false)
193 void
194 MdName::Write2Html( HtmlCreator & io_rHC ) const
196 io_rHC.Write_SglTextElement( *this, true );
199 CdName::CdName()
200 : SglTextElement(C_sName, lt_html, true)
204 void
205 CdName::Write2Html( HtmlCreator & io_rHC ) const
207 io_rHC.Write_SglTextElement( *this, true );
210 SupportedService::SupportedService()
211 : MultipleTextElement(C_sSupportedService, lt_idl, true)
215 void
216 SupportedService::Insert2Index( Index & o_rIndex ) const
218 for ( unsigned i = 0; i < Size(); ++i )
220 o_rIndex.InsertSupportedService( Data(i) );
224 FreeChoiceElement *
225 Create_ModuleDescrOptional_Element( MultipleTextElement * & o_rTypes,
226 MultipleTextElement * & o_rServiceDependencies )
228 FreeChoiceElement * ret = Create_CompDescrOptional_Element( o_rTypes, o_rServiceDependencies );
230 ret->AddChild( *new MultipleTextElement(C_sProjectBuildDependency, lt_nolink, false) );
231 ret->AddChild( *new MultipleTextElement(C_sRuntimeModuleDependency, lt_nolink, false) );
232 return ret;
235 FreeChoiceElement *
236 Create_CompDescrOptional_Element( MultipleTextElement * & o_rTypes,
237 MultipleTextElement * & o_rServiceDependencies )
239 FreeChoiceElement * ret = new FreeChoiceElement;
240 const unsigned C_sRefDocuAttrNumber = 5;
241 static const char * C_sRefDocuAttrNames[C_sRefDocuAttrNumber]
242 = { C_sAttr_xl_href, C_sAttr_xl_role, C_sAttr_xl_title, C_sAttr_xmlns, C_sAttr_xl_type };
244 ret->AddChild( *new MultipleAttrElement(C_sReferenceDocu, C_sRefDocuAttrNames, C_sRefDocuAttrNumber) );
245 o_rServiceDependencies = new MultipleTextElement(C_sServiceDependency, lt_idl, true);
246 ret->AddChild( *o_rServiceDependencies );
247 o_rTypes = new MultipleTextElement(C_sType, lt_idl, true);
248 ret->AddChild( *o_rTypes );
249 return ret;
253 #if 0
255 const TextElement *
256 ModuleDescription::ServiceDependencies() const
258 const unsigned nEarliestPossibleServiceDependenciesIndexInModules = 1;
260 for ( unsigned i = nEarliestPossibleServiceDependenciesIndexInModules;
261 i < Children().size();
262 ++i )
264 if ( strcmp(Children()[i]->Name(), C_sServiceDependency) == 0 )
265 return Children()[i];
267 return 0;
270 const TextElement &
271 ComponentDescription::SupportedServices() const
273 return *Children()[C_nSupportedServicesIndex];
276 const TextElement *
277 ComponentDescription::ServiceDependencies() const
279 for ( unsigned i = C_nEarliestPossibleServiceDependenciesIndex; i < Children().size(); ++i )
281 if ( strcmp(Children()[i]->Name(),C_sServiceDependency) == 0)
282 return Children()[i];
284 return 0;
287 #endif