/************************************************************************* * * $RCSfile: cr_html.cxx,v $ * * $Revision: 1.1 $ * * last change: $Author: np $ $Date: 2001-03-09 15:23:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://www.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ #include #include "cr_html.hxx" #include "xmltree.hxx" #include "../support/syshelp.hxx" char C_sHtmlFileHeader1[] = "\n" "\n" "\n" " "; char C_sHtmlFileHeader2[] = "\n" " \n" "\n" "\n


"; char C_sHtmlFileFoot[] = "\n\n"; HtmlCreator::HtmlCreator( const char * i_pOutputFileName, const ModuleDescription & i_rDescr, const Simstr & i_sIDL_BaseDirectory ) : aFile(i_pOutputFileName, ios::out #ifdef WNT | ios::binary #endif ), rDescr(i_rDescr), sIdl_BaseDirectory(i_sIDL_BaseDirectory) { if ( !aFile ) { cerr << "Error: " << i_pOutputFileName << " could not be created." << endl; exit(0); } } HtmlCreator::~HtmlCreator() { aFile.close(); } void HtmlCreator::Run() { WriteStr( C_sHtmlFileHeader1 ); WriteStr( "ModuleDescription" ); WriteStr( C_sHtmlFileHeader2 ); StartTable(); const ParentElement::ChildList & rModuleElements = rDescr.Children(); unsigned i_max = rModuleElements.size(); for (unsigned i = 0; i < i_max; i++) { Write_TextElement( *rModuleElements[i], lt_nolink ); // Name, // ProjectBuildDependency, // RuntimeModuleDependency } // end for WriteStr( "\n" "


Components

\n" ); const ModuleDescription::CD_List & rCDs = rDescr.Components(); unsigned d_max = rCDs.size(); for (unsigned d = 0; d < d_max; d++) { WriteStr( "



\n" ); Write_Description( *rCDs[d] ); } // end for WriteStr( "\n" ); FinishTable(); WriteStr( "



\n" ); WriteStr( C_sHtmlFileFoot ); } void HtmlCreator::Write_Description( const ComponentDescription & i_rDescr ) { StartTable(); const ParentElement::ChildList & rDescrElements = i_rDescr.Children(); unsigned i_max = rDescrElements.size(); Write_TextElement( *rDescrElements[0], lt_nolink ); // Name Write_TextElement( *rDescrElements[1], lt_nolink ); // Author Write_TextElement( *rDescrElements[2], lt_nolink ); // Description Write_TextElement( *rDescrElements[3], lt_idl ); // Loader Name Write_TextElement( *rDescrElements[4], lt_nolink ); // Language Write_Status(i_rDescr.Status()); // Status for (unsigned i = 5; i < i_max; i++) { Write_TextElement( *rDescrElements[i], lt_idl ); // Supported Service, // Service Dependency, // Type } // end for const ComponentDescription::Docu_List & rDocuRefs = i_rDescr.DocuRefs(); unsigned r_max = rDocuRefs.size(); for (unsigned r = 0; r < r_max; r++) { Write_ReferenceDocu(*rDocuRefs[r]); } // end for FinishTable(); } void HtmlCreator::Write_TextElement( TextElement & i_rElement, E_LinkType i_eLinkType ) { StartRow(); WriteElementName( i_rElement ); WriteElementData( i_rElement, i_eLinkType ); FinishRow(); } void HtmlCreator::Write_ReferenceDocu( const ReferenceDocuElement & i_rRefDocu ) { StartRow(); StartCell( "23%" ); WriteStr("ReferenceDocu"); FinishCell(); StartCell( "77%" ); if ( i_rRefDocu.sAttr_href.l() > 0) { WriteStr(""); WriteStr(i_rRefDocu.sAttr_href.str()); WriteStr("
\n"); } if ( i_rRefDocu.sAttr_title.l() > 0) { WriteStr("Title: "); WriteStr(i_rRefDocu.sAttr_title.str()); WriteStr("
\n"); } if ( i_rRefDocu.sAttr_role.l() > 0) { WriteStr("Role: "); WriteStr(i_rRefDocu.sAttr_role.str()); } FinishCell(); FinishRow(); } void HtmlCreator::Write_Status(const char * i_sStatus) { StartRow(); StartCell( "23%" ); WriteStr("status"); FinishCell(); StartCell( "77%"); WriteName( aFile, sIdl_BaseDirectory, i_sStatus, lt_nolink ); FinishCell(); FinishRow(); } void HtmlCreator::PrintH1( char * i_pText) { static char sH1a[] = "

"; static char sH1e[] = "

"; WriteStr(sH1a); WriteStr(i_pText); WriteStr(sH1e); } void HtmlCreator::StartTable() { WriteStr( "\n" " \n" ); } void HtmlCreator::FinishTable() { WriteStr( " \n" "
\n\n" ); } void HtmlCreator::StartRow() { WriteStr( " \n" ); } void HtmlCreator::FinishRow() { WriteStr( " \n" ); } void HtmlCreator::StartCell( char * i_pWidth) { WriteStr( " \n

" ); } void HtmlCreator::FinishCell() { WriteStr( "

\n \n" ); } void HtmlCreator::WriteElementName( TextElement & i_rElement ) { StartCell( "23%" ); const char * pName = i_rElement.Name(); bool bStrong = strcmp(pName,"name") == 0 || strcmp(pName,"module-name") == 0; if (bStrong) WriteStr( "

" ); WriteStr(pName); if (bStrong) WriteStr( "

" ); FinishCell(); } void HtmlCreator::WriteElementData( TextElement & i_rElement, E_LinkType i_eLinkType ) { StartCell( "77%"); bool bStrong = strcmp(i_rElement.Name(),"name") == 0 || strcmp(i_rElement.Name(),"module-name") == 0; if (bStrong) { WriteStr( "

" ); } WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(), i_eLinkType ); if (bStrong) WriteStr( "

" ); unsigned i_max = i_rElement.Size(); if ( i_max > 1 ) { for ( unsigned i = 1; i < i_max; ++i ) { WriteStr( "
\n" ); WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_eLinkType ); } // end for } // end if FinishCell(); }