2001-03-09 14:23:00 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* $RCSfile: cr_html.cxx,v $
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2006-06-19 19:04:59 +00:00
|
|
|
* $Revision: 1.8 $
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2006-06-19 19:04:59 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2006-06-19 20:04:45 $
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* 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.
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* 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.
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
2005-09-09 11:01:08 +00:00
|
|
|
* 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
|
2001-03-09 14:23:00 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2001-03-12 18:24:52 +00:00
|
|
|
#include <fstream>
|
2001-03-09 14:23:00 +00:00
|
|
|
#include "cr_html.hxx"
|
|
|
|
#include "xmltree.hxx"
|
|
|
|
#include "../support/syshelp.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char C_sHtmlFileHeader1[] =
|
|
|
|
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"
|
|
|
|
"<HTML>\n"
|
|
|
|
"<HEAD>\n"
|
|
|
|
" <TITLE>";
|
|
|
|
|
|
|
|
char C_sHtmlFileHeader2[] =
|
|
|
|
"</TITLE>\n"
|
|
|
|
" <META NAME=\"GENERATOR\" CONTENT=\"xml2cmp\">\n"
|
|
|
|
"</HEAD>\n"
|
|
|
|
"<BODY BGCOLOR=\"#ffffff\">\n<P><BR></P>";
|
|
|
|
|
|
|
|
|
|
|
|
char C_sHtmlFileFoot[] = "</BODY>\n</HTML>\n";
|
|
|
|
|
|
|
|
|
|
|
|
HtmlCreator::HtmlCreator( const char * i_pOutputFileName,
|
2001-03-23 12:24:04 +00:00
|
|
|
const XmlElement & i_rDocument,
|
2001-03-09 14:23:00 +00:00
|
|
|
const Simstr & i_sIDL_BaseDirectory )
|
2002-08-08 15:08:20 +00:00
|
|
|
: aFile(i_pOutputFileName, std::ios::out
|
2001-03-09 14:23:00 +00:00
|
|
|
#ifdef WNT
|
2002-08-08 15:08:20 +00:00
|
|
|
| std::ios::binary
|
2001-03-09 14:23:00 +00:00
|
|
|
#endif
|
|
|
|
),
|
2001-03-23 12:24:04 +00:00
|
|
|
rDocument(i_rDocument),
|
2001-03-09 14:23:00 +00:00
|
|
|
sIdl_BaseDirectory(i_sIDL_BaseDirectory)
|
|
|
|
{
|
|
|
|
if ( !aFile )
|
|
|
|
{
|
2002-08-08 15:08:20 +00:00
|
|
|
std::cerr << "Error: " << i_pOutputFileName << " could not be created." << std::endl;
|
2001-03-09 14:23:00 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HtmlCreator::~HtmlCreator()
|
|
|
|
{
|
|
|
|
aFile.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HtmlCreator::Run()
|
|
|
|
{
|
|
|
|
WriteStr( C_sHtmlFileHeader1 );
|
|
|
|
WriteStr( "ModuleDescription" );
|
|
|
|
WriteStr( C_sHtmlFileHeader2 );
|
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
rDocument.Write2Html(*this);
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteStr( "<P><BR><BR></P>\n" );
|
|
|
|
WriteStr( C_sHtmlFileFoot );
|
|
|
|
}
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
void
|
|
|
|
HtmlCreator::StartTable()
|
|
|
|
{
|
|
|
|
WriteStr( "<P><BR></P>\n" );
|
|
|
|
WriteStr(
|
|
|
|
"<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n"
|
|
|
|
" <TBODY>\n" );
|
|
|
|
}
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
void
|
|
|
|
HtmlCreator::FinishTable()
|
|
|
|
{
|
|
|
|
WriteStr( " </TBODY>\n"
|
|
|
|
"</TABLE>\n\n" );
|
|
|
|
}
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
void
|
|
|
|
HtmlCreator::StartBigCell( const char * i_sTitle )
|
|
|
|
{
|
|
|
|
WriteStr( "<TR><TD COLSPAN=2>\n"
|
|
|
|
"<H4><BR>" );
|
|
|
|
WriteStr( i_sTitle );
|
|
|
|
WriteStr( "</H4>\n" );
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
}
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
void
|
|
|
|
HtmlCreator::FinishBigCell()
|
|
|
|
{
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr( "</TD><TR>\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-03-23 12:24:04 +00:00
|
|
|
HtmlCreator::Write_SglTextElement( const SglTextElement & i_rElement,
|
|
|
|
bool i_bStrong )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
2001-03-23 12:24:04 +00:00
|
|
|
StartRow();
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteElementName( i_rElement.Name(), i_bStrong );
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
StartCell( "77%");
|
|
|
|
if (i_bStrong)
|
|
|
|
{
|
|
|
|
WriteStr( "<H4><A NAME=\"" );
|
|
|
|
unsigned nLen = strlen(i_rElement.Data());
|
|
|
|
if ( i_rElement.IsReversedName())
|
|
|
|
{
|
|
|
|
const char * pEnd = strchr(i_rElement.Data(), ' ');
|
|
|
|
nLen = pEnd - i_rElement.Data();
|
|
|
|
}
|
|
|
|
aFile.write( i_rElement.Data(), nLen );
|
|
|
|
WriteStr( "\">" );
|
|
|
|
}
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(),
|
|
|
|
i_bStrong ? lt_nolink : i_rElement.LinkType() );
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
if (i_bStrong)
|
|
|
|
WriteStr( "</A></H4>" );
|
|
|
|
FinishCell();
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
FinishRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HtmlCreator::Write_MultiTextElement( const MultipleTextElement & i_rElement )
|
|
|
|
{
|
|
|
|
StartRow();
|
|
|
|
|
|
|
|
WriteElementName( i_rElement.Name(), false );
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
StartCell( "77%");
|
|
|
|
unsigned i_max = i_rElement.Size();
|
|
|
|
for ( unsigned i = 0; i < i_max; ++i )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
2001-03-23 12:24:04 +00:00
|
|
|
if (i > 0)
|
|
|
|
WriteStr( "<BR>\n" );
|
|
|
|
WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_rElement.LinkType() );
|
|
|
|
} // end for
|
|
|
|
FinishCell();
|
2001-03-09 14:23:00 +00:00
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
FinishRow();
|
2001-03-09 14:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-03-23 12:24:04 +00:00
|
|
|
HtmlCreator::Write_SglText( const Simstr & i_sName,
|
|
|
|
const Simstr & i_sValue )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
|
|
|
StartRow();
|
|
|
|
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteElementName( i_sName, false );
|
|
|
|
|
|
|
|
StartCell( "77%");
|
|
|
|
WriteStr( i_sValue );
|
|
|
|
FinishCell();
|
2001-03-09 14:23:00 +00:00
|
|
|
|
|
|
|
FinishRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-03-23 12:24:04 +00:00
|
|
|
HtmlCreator::Write_ReferenceDocu( const Simstr & i_sName,
|
|
|
|
const Simstr & i_sRef,
|
|
|
|
const Simstr & i_sRole,
|
|
|
|
const Simstr & i_sTitle )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
|
|
|
StartRow();
|
|
|
|
|
|
|
|
StartCell( "23%" );
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteStr(i_sName);
|
2001-03-09 14:23:00 +00:00
|
|
|
FinishCell();
|
|
|
|
|
|
|
|
StartCell( "77%" );
|
2001-03-23 12:24:04 +00:00
|
|
|
if ( !i_sRef.is_empty() )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteStr("<A href=\"");
|
|
|
|
WriteStr(i_sRef);
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr("\">");
|
2001-03-23 12:24:04 +00:00
|
|
|
if ( !i_sTitle.is_empty() )
|
|
|
|
WriteStr( i_sTitle );
|
|
|
|
else
|
|
|
|
WriteStr(i_sRef);
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr("</A><BR>\n");
|
|
|
|
}
|
2001-03-23 12:24:04 +00:00
|
|
|
else if ( !i_sTitle.is_empty() )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
|
|
|
WriteStr("Title: ");
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteStr( i_sTitle );
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr("<BR>\n");
|
|
|
|
}
|
2001-03-23 12:24:04 +00:00
|
|
|
if ( !i_sRole.is_empty() )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
|
|
|
WriteStr("Role: ");
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteStr( i_sRole );
|
2001-03-09 14:23:00 +00:00
|
|
|
}
|
|
|
|
FinishCell();
|
|
|
|
|
|
|
|
FinishRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-06-19 19:04:59 +00:00
|
|
|
HtmlCreator::PrintH1( const char * i_pText)
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
2006-06-19 19:04:59 +00:00
|
|
|
static const char sH1a[] = "<H1 ALIGN=CENTER>";
|
|
|
|
static const char sH1e[] = "</H1>";
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr(sH1a);
|
|
|
|
WriteStr(i_pText);
|
|
|
|
WriteStr(sH1e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HtmlCreator::StartRow()
|
|
|
|
{
|
|
|
|
WriteStr( " <TR VALIGN=TOP>\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HtmlCreator::FinishRow()
|
|
|
|
{
|
|
|
|
WriteStr( " </TR>\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-06-19 19:04:59 +00:00
|
|
|
HtmlCreator::StartCell( const char * i_pWidth)
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
|
|
|
WriteStr( " <TD WIDTH=" );
|
|
|
|
WriteStr( i_pWidth );
|
|
|
|
WriteStr( ">\n <P>" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HtmlCreator::FinishCell()
|
|
|
|
{
|
|
|
|
WriteStr( "</P>\n </TD>\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-03-23 12:24:04 +00:00
|
|
|
HtmlCreator::WriteElementName( const Simstr & i_sName,
|
|
|
|
bool i_bStrong )
|
2001-03-09 14:23:00 +00:00
|
|
|
{
|
|
|
|
StartCell( "23%" );
|
2001-03-23 12:24:04 +00:00
|
|
|
if (i_bStrong)
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr( "<H4>" );
|
2001-03-23 12:24:04 +00:00
|
|
|
WriteStr(i_sName);
|
|
|
|
if (i_bStrong)
|
2001-03-09 14:23:00 +00:00
|
|
|
WriteStr( "</H4>" );
|
|
|
|
FinishCell();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|