1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 #include <xmltree.hxx> 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <cr_html.hxx> 34 #include <cr_index.hxx> 35 36 37 char C_sMODULEDESCRIPTION[] = "module-description"; 38 char C_sCOMPONENTDESCRIPTION[] = "component-description"; 39 char C_sAuthor[] = "author"; 40 char C_sName[] = "name"; 41 char C_sDescription[] = "description"; 42 char C_sReferenceDocu[] = "reference-docu"; 43 char C_sModuleName[] = "module-name"; 44 char C_sLoaderName[] = "loader-name"; 45 char C_sSupportedService[] = "supported-service"; 46 char C_sServiceDependency[] = "service-dependency"; 47 char C_sProjectBuildDependency[] = "project-build-dependency"; 48 char C_sRuntimeModuleDependency[] = "runtime-module-dependency"; 49 char C_sLanguage[] = "language"; 50 char C_sStatus[] = "status"; 51 char C_sType[] = "type"; 52 char C_sAttr_value[] = "value"; 53 char C_sAttr_xl_href[] = "xlink:href"; 54 char C_sAttr_xl_role[] = "xlink:role"; 55 char C_sAttr_xl_title[] = "xlink:title"; 56 char C_sAttr_xmlns[] = "xmlns:xlink"; 57 char C_sAttr_xl_type[] = "xlink:type"; 58 char C_sCompDescrListTitle[] = "Component Descriptions"; 59 60 61 FreeChoiceElement * Create_ModuleDescrOptional_Element( 62 MultipleTextElement * & 63 o_rTypes, 64 MultipleTextElement * & 65 o_rServiceDependencies ); 66 FreeChoiceElement * Create_CompDescrOptional_Element( 67 MultipleTextElement * & 68 o_rTypes, 69 MultipleTextElement * & 70 o_rServiceDependencies ); 71 72 73 74 ModuleDescription::ModuleDescription() 75 : SequenceElement(C_sMODULEDESCRIPTION), 76 pModuleName(0), 77 pCdList(0), 78 pTypes(0), 79 pServiceDependencies(0) 80 { 81 pModuleName = new MdName; 82 AddChild( *pModuleName ); 83 pCdList = new CompDescrList; 84 AddChild( *pCdList ); 85 AddChild( *Create_ModuleDescrOptional_Element( pTypes, pServiceDependencies ) ); 86 } 87 88 const Simstr & 89 ModuleDescription::ModuleName() const 90 { 91 return pModuleName->Data(); 92 } 93 94 void 95 ModuleDescription::Get_SupportedServices( List< const MultipleTextElement * > & o_rServices ) const 96 { 97 o_rServices.push_back(pServiceDependencies); 98 pCdList->Get_SupportedServices( o_rServices ); 99 } 100 101 void 102 ModuleDescription::Get_Types( List< const MultipleTextElement * > & o_rTypes ) const 103 { 104 o_rTypes.push_back(pTypes); 105 pCdList->Get_Types( o_rTypes ); 106 } 107 108 void 109 ModuleDescription::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rServices ) const 110 { 111 pCdList->Get_ServiceDependencies( o_rServices ); 112 } 113 114 ComponentDescription::ComponentDescription() 115 : SequenceElement(C_sCOMPONENTDESCRIPTION,1), 116 pComponentName(0), 117 pSupportedServices(0), 118 pTypes(0), 119 pServiceDependencies(0) 120 { 121 AddChild( *new SglTextElement(C_sAuthor, lt_nolink, false) ); 122 pComponentName = new CdName; 123 AddChild( *pComponentName ); 124 AddChild( *new SglTextElement(C_sDescription, lt_nolink, false) ); 125 AddChild( *new SglTextElement(C_sLoaderName, lt_idl, true) ); 126 AddChild( *new SglTextElement(C_sLanguage, lt_nolink, false) ); 127 AddChild( *new SglAttrElement(C_sStatus, C_sAttr_value) ); 128 pSupportedServices = new SupportedService; 129 AddChild( *pSupportedServices ); 130 AddChild( *Create_CompDescrOptional_Element( pTypes, pServiceDependencies ) ); 131 } 132 133 CompDescrList::CompDescrList() 134 : ListElement(C_sCOMPONENTDESCRIPTION, 0) 135 { 136 } 137 138 void 139 CompDescrList::Write2Html( HtmlCreator & io_rHC ) const 140 { 141 io_rHC.StartBigCell(C_sCompDescrListTitle); 142 ListElement::Write2Html(io_rHC); 143 io_rHC.FinishBigCell(); 144 } 145 146 XmlElement * 147 CompDescrList::Create_and_Add_NewElement() 148 { 149 ComponentDescription * pCD = new ComponentDescription; 150 Children().push_back(pCD); 151 aCDs.push_back(pCD); 152 return pCD; 153 } 154 155 void 156 CompDescrList::Get_SupportedServices( List< const MultipleTextElement * > & o_rResult ) const 157 { 158 unsigned i_max = aCDs.size();; 159 for (unsigned i = 0; i < i_max; ++i) 160 { 161 o_rResult.push_back(& aCDs[i]->SupportedServices()); 162 } // end for 163 } 164 165 void 166 CompDescrList::Get_Types( List< const MultipleTextElement * > & o_rResult ) const 167 { 168 unsigned i_max = aCDs.size();; 169 for (unsigned i = 0; i < i_max; ++i) 170 { 171 o_rResult.push_back(& aCDs[i]->Types()); 172 } // end for 173 } 174 175 void 176 CompDescrList::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rResult ) const 177 { 178 unsigned i_max = aCDs.size();; 179 for (unsigned i = 0; i < i_max; ++i) 180 { 181 o_rResult.push_back(& aCDs[i]->ServiceDependencies()); 182 } // end for 183 } 184 185 MdName::MdName() 186 : SglTextElement(C_sModuleName, lt_html, false) 187 { 188 } 189 190 void 191 MdName::Write2Html( HtmlCreator & io_rHC ) const 192 { 193 io_rHC.Write_SglTextElement( *this, true ); 194 } 195 196 CdName::CdName() 197 : SglTextElement(C_sName, lt_html, true) 198 { 199 } 200 201 void 202 CdName::Write2Html( HtmlCreator & io_rHC ) const 203 { 204 io_rHC.Write_SglTextElement( *this, true ); 205 } 206 207 SupportedService::SupportedService() 208 : MultipleTextElement(C_sSupportedService, lt_idl, true) 209 { 210 } 211 212 void 213 SupportedService::Insert2Index( Index & o_rIndex ) const 214 { 215 for ( unsigned i = 0; i < Size(); ++i ) 216 { 217 o_rIndex.InsertSupportedService( Data(i) ); 218 } 219 } 220 221 FreeChoiceElement * 222 Create_ModuleDescrOptional_Element( MultipleTextElement * & o_rTypes, 223 MultipleTextElement * & o_rServiceDependencies ) 224 { 225 FreeChoiceElement * ret = Create_CompDescrOptional_Element( o_rTypes, o_rServiceDependencies ); 226 227 ret->AddChild( *new MultipleTextElement(C_sProjectBuildDependency, lt_nolink, false) ); 228 ret->AddChild( *new MultipleTextElement(C_sRuntimeModuleDependency, lt_nolink, false) ); 229 return ret; 230 } 231 232 FreeChoiceElement * 233 Create_CompDescrOptional_Element( MultipleTextElement * & o_rTypes, 234 MultipleTextElement * & o_rServiceDependencies ) 235 { 236 FreeChoiceElement * ret = new FreeChoiceElement; 237 const unsigned C_sRefDocuAttrNumber = 5; 238 static const char * C_sRefDocuAttrNames[C_sRefDocuAttrNumber] 239 = { C_sAttr_xl_href, C_sAttr_xl_role, C_sAttr_xl_title, C_sAttr_xmlns, C_sAttr_xl_type }; 240 241 ret->AddChild( *new MultipleAttrElement(C_sReferenceDocu, C_sRefDocuAttrNames, C_sRefDocuAttrNumber) ); 242 o_rServiceDependencies = new MultipleTextElement(C_sServiceDependency, lt_idl, true); 243 ret->AddChild( *o_rServiceDependencies ); 244 o_rTypes = new MultipleTextElement(C_sType, lt_idl, true); 245 ret->AddChild( *o_rTypes ); 246 return ret; 247 } 248 249 250 #if 0 251 252 const TextElement * 253 ModuleDescription::ServiceDependencies() const 254 { 255 const unsigned nEarliestPossibleServiceDependenciesIndexInModules = 1; 256 257 for ( unsigned i = nEarliestPossibleServiceDependenciesIndexInModules; 258 i < Children().size(); 259 ++i ) 260 { 261 if ( strcmp(Children()[i]->Name(), C_sServiceDependency) == 0 ) 262 return Children()[i]; 263 } 264 return 0; 265 } 266 267 const TextElement & 268 ComponentDescription::SupportedServices() const 269 { 270 return *Children()[C_nSupportedServicesIndex]; 271 } 272 273 const TextElement * 274 ComponentDescription::ServiceDependencies() const 275 { 276 for ( unsigned i = C_nEarliestPossibleServiceDependenciesIndex; i < Children().size(); ++i ) 277 { 278 if ( strcmp(Children()[i]->Name(),C_sServiceDependency) == 0) 279 return Children()[i]; 280 } 281 return 0; 282 } 283 284 #endif 285 286 287