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: cr_html.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 "cr_html.hxx"
33 #include "xmltree.hxx"
34 #include "../support/syshelp.hxx"
39 char C_sHtmlFileHeader1
[] =
40 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"
45 char C_sHtmlFileHeader2
[] =
47 " <META NAME=\"GENERATOR\" CONTENT=\"xml2cmp\">\n"
49 "<BODY BGCOLOR=\"#ffffff\">\n<P><BR></P>";
52 char C_sHtmlFileFoot
[] = "</BODY>\n</HTML>\n";
55 HtmlCreator::HtmlCreator( const char * i_pOutputFileName
,
56 const XmlElement
& i_rDocument
,
57 const Simstr
& i_sIDL_BaseDirectory
)
58 : aFile(i_pOutputFileName
, std::ios::out
59 #if defined(WNT) || defined(OS2)
63 rDocument(i_rDocument
),
64 sIdl_BaseDirectory(i_sIDL_BaseDirectory
)
68 std::cerr
<< "Error: " << i_pOutputFileName
<< " could not be created." << std::endl
;
73 HtmlCreator::~HtmlCreator()
81 WriteStr( C_sHtmlFileHeader1
);
82 WriteStr( "ModuleDescription" );
83 WriteStr( C_sHtmlFileHeader2
);
85 rDocument
.Write2Html(*this);
87 WriteStr( "<P><BR><BR></P>\n" );
88 WriteStr( C_sHtmlFileFoot
);
92 HtmlCreator::StartTable()
94 WriteStr( "<P><BR></P>\n" );
96 "<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n"
101 HtmlCreator::FinishTable()
103 WriteStr( " </TBODY>\n"
108 HtmlCreator::StartBigCell( const char * i_sTitle
)
110 WriteStr( "<TR><TD COLSPAN=2>\n"
112 WriteStr( i_sTitle
);
113 WriteStr( "</H4>\n" );
118 HtmlCreator::FinishBigCell()
120 WriteStr( "</TD><TR>\n" );
124 HtmlCreator::Write_SglTextElement( const SglTextElement
& i_rElement
,
129 WriteElementName( i_rElement
.Name(), i_bStrong
);
134 WriteStr( "<H4><A NAME=\"" );
135 unsigned nLen
= strlen(i_rElement
.Data());
136 if ( i_rElement
.IsReversedName())
138 const char * pEnd
= strchr(i_rElement
.Data(), ' ');
139 nLen
= (unsigned)( pEnd
- i_rElement
.Data() );
141 aFile
.write( i_rElement
.Data(), (int) nLen
);
145 WriteName( aFile
, sIdl_BaseDirectory
, i_rElement
.Data(),
146 i_bStrong
? lt_nolink
: i_rElement
.LinkType() );
149 WriteStr( "</A></H4>" );
156 HtmlCreator::Write_MultiTextElement( const MultipleTextElement
& i_rElement
)
160 WriteElementName( i_rElement
.Name(), false );
163 unsigned i_max
= i_rElement
.Size();
164 for ( unsigned i
= 0; i
< i_max
; ++i
)
167 WriteStr( "<BR>\n" );
168 WriteName( aFile
, sIdl_BaseDirectory
, i_rElement
.Data(i
), i_rElement
.LinkType() );
176 HtmlCreator::Write_SglText( const Simstr
& i_sName
,
177 const Simstr
& i_sValue
)
181 WriteElementName( i_sName
, false );
184 WriteStr( i_sValue
);
191 HtmlCreator::Write_ReferenceDocu( const Simstr
& i_sName
,
192 const Simstr
& i_sRef
,
193 const Simstr
& i_sRole
,
194 const Simstr
& i_sTitle
)
203 if ( !i_sRef
.is_empty() )
205 WriteStr("<A href=\"");
208 if ( !i_sTitle
.is_empty() )
209 WriteStr( i_sTitle
);
212 WriteStr("</A><BR>\n");
214 else if ( !i_sTitle
.is_empty() )
217 WriteStr( i_sTitle
);
220 if ( !i_sRole
.is_empty() )
232 HtmlCreator::StartRow()
234 WriteStr( " <TR VALIGN=TOP>\n" );
238 HtmlCreator::FinishRow()
240 WriteStr( " </TR>\n" );
244 HtmlCreator::StartCell( const char * i_pWidth
)
246 WriteStr( " <TD WIDTH=" );
247 WriteStr( i_pWidth
);
248 WriteStr( ">\n <P>" );
252 HtmlCreator::FinishCell()
254 WriteStr( "</P>\n </TD>\n" );
258 HtmlCreator::WriteElementName( const Simstr
& i_sName
,