My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
HtmlHelp Class Reference

#include <htmlhelp.h>

Inheritance diagram for HtmlHelp:
IndexIntf

Public Member Functions

 HtmlHelp ()
 
 ~HtmlHelp ()
 
void initialize ()
 
void finalize ()
 
void incContentsDepth ()
 
void decContentsDepth ()
 
void addContentsItem (bool isDir, const char *name, const char *ref, const char *file, const char *anchor, bool separateIndex, bool addToNavIndex, Definition *def)
 
void addIndexItem (Definition *context, MemberDef *md, const char *sectionAnchor, const char *title)
 
void addIndexFile (const char *name)
 
void addImageFile (const char *)
 
void addStyleSheetFile (const char *)
 
- Public Member Functions inherited from IndexIntf
virtual ~IndexIntf ()
 

Static Public Member Functions

static QCString getLanguageString ()
 

Private Types

enum  ImageNumber {
  BOOK_CLOSED =1, BOOK_OPEN, BOOK_CLOSED_NEW, BOOK_OPEN_NEW,
  FOLDER_CLOSED, FOLDER_OPEN, FOLDER_CLOSED_NEW, FOLDER_OPEN_NEW,
  QUERY, QUERY_NEW, TEXT, TEXT_NEW,
  WEB_DOC, WEB_DOC_NEW, WEB_LINK, WEB_LINK_NEW,
  INFO, INFO_NEW, LINK, LINK_NEW,
  BOOKLET, BOOKLET_NEW, EMAIL, EMAIL_NEW,
  EMAIL2, EMAIL2_NEW, IMAGE, IMAGE_NEW,
  AUDIO, AUDIO_NEW, MUSIC, MUSIC_NEW,
  VIDEO, VIDEO_NEW, INDEX, INDEX_NEW,
  IDEA, IDEA_NEW, NOTE, NOTE_NEW,
  TOOL, TOOL_NEW
}
 

Private Member Functions

void createProjectFile ()
 
QCString recode (const QCString &s)
 

Private Attributes

QFile * cf
 
QFile * kf
 
FTextStream cts
 
FTextStream kts
 
HtmlHelpIndexindex
 
int dc
 
QStrList indexFiles
 
QStrList imageFiles
 
QDict< void > indexFileDict
 
void * m_fromUtf8
 

Static Private Attributes

static HtmlHelptheInstance = 0
 

Friends

class HtmlHelpIndex
 

Detailed Description

A class that generated the HTML Help specific files.

These files can be used with the Microsoft HTML Help workshop to generate compressed HTML files (.chm).

Definition at line 38 of file htmlhelp.h.

Member Enumeration Documentation

enum HtmlHelp::ImageNumber
private

used in imageNumber param of HTMLHelp::addContentsItem() function to specify document icon in tree view. Writes <param name="ImageNumber" value="xx"> in .HHC file.

Enumerator
BOOK_CLOSED 
BOOK_OPEN 
BOOK_CLOSED_NEW 
BOOK_OPEN_NEW 
FOLDER_CLOSED 
FOLDER_OPEN 
FOLDER_CLOSED_NEW 
FOLDER_OPEN_NEW 
QUERY 
QUERY_NEW 
TEXT 
TEXT_NEW 
WEB_DOC 
WEB_DOC_NEW 
WEB_LINK 
WEB_LINK_NEW 
INFO 
INFO_NEW 
LINK 
LINK_NEW 
BOOKLET 
BOOKLET_NEW 
EMAIL 
EMAIL_NEW 
EMAIL2 
EMAIL2_NEW 
IMAGE 
IMAGE_NEW 
AUDIO 
AUDIO_NEW 
MUSIC 
MUSIC_NEW 
VIDEO 
VIDEO_NEW 
INDEX 
INDEX_NEW 
IDEA 
IDEA_NEW 
NOTE 
NOTE_NEW 
TOOL 
TOOL_NEW 

Definition at line 43 of file htmlhelp.h.

Constructor & Destructor Documentation

HtmlHelp::HtmlHelp ( )

Constructs an html object. The object has to be initialized before it can be used.

Definition at line 273 of file htmlhelp.cpp.

References cf, dc, HtmlHelpIndex, index, kf, and m_fromUtf8.

: indexFileDict(1009)
{
/* initial depth */
dc = 0;
cf = kf = 0;
index = new HtmlHelpIndex(this);
m_fromUtf8 = (void *)(-1);
}
HtmlHelp::~HtmlHelp ( )

Definition at line 282 of file htmlhelp.cpp.

References index, m_fromUtf8, and portable_iconv_close().

{
delete index;
}

Member Function Documentation

void HtmlHelp::addContentsItem ( bool  isDir,
const char *  name,
const char *  ref,
const char *  file,
const char *  anchor,
bool  separateIndex,
bool  addToNavIndex,
Definition def 
)
virtual

Add an list item to the contents file.

Parameters
isDirboolean indicating if this is a dir or file entry
namethe name of the item.
refthe URL of to the item.
filethe file in which the item is defined.
anchorthe anchor of the item.
separateIndexnot used.
addToNavIndexnot used.
defnot used.

Implements IndexIntf.

Definition at line 628 of file htmlhelp.cpp.

References BOOK_CLOSED, convertToHtml(), cts, dc, Doxygen::htmlFileExtension, recode(), and TEXT.

{
// If we're using a binary toc then folders cannot have links.
// Tried this and I didn't see any problems, when not using
// the resetting of file and anchor the TOC works better
// (prev / next button)
//if(Config_getBool(BINARY_TOC) && isDir)
//{
//file = 0;
//anchor = 0;
//}
int i; for (i=0;i<dc;i++) cts << " ";
cts << "<LI><OBJECT type=\"text/sitemap\">";
cts << "<param name=\"Name\" value=\"" << convertToHtml(recode(name),TRUE) << "\">";
if (file) // made file optional param - KPW
{
if (file && (file[0]=='!' || file[0]=='^')) // special markers for user defined URLs
{
cts << "<param name=\"";
if (file[0]=='^') cts << "URL"; else cts << "Local";
cts << "\" value=\"";
cts << &file[1];
}
else
{
cts << "<param name=\"Local\" value=\"";
if (anchor) cts << "#" << anchor;
}
cts << "\">";
}
cts << "<param name=\"ImageNumber\" value=\"";
if (isDir) // added - KPW
{
cts << (int)BOOK_CLOSED ;
}
else
{
cts << (int)TEXT;
}
cts << "\">";
cts << "</OBJECT>\n";
}
void HtmlHelp::addImageFile ( const char *  fileName)
virtual

Implements IndexIntf.

Definition at line 712 of file htmlhelp.cpp.

References imageFiles.

{
if (!imageFiles.contains(fileName)) imageFiles.append(fileName);
}
void HtmlHelp::addIndexFile ( const char *  name)
virtual

Implements IndexIntf.

Definition at line 537 of file htmlhelp.cpp.

References indexFileDict, and indexFiles.

{
if (indexFileDict.find(s)==0)
{
indexFiles.append(s);
indexFileDict.insert(s,(void *)0x8);
}
}
void HtmlHelp::addIndexItem ( Definition context,
MemberDef md,
const char *  sectionAnchor,
const char *  title 
)
virtual

Implements IndexIntf.

Definition at line 680 of file htmlhelp.cpp.

References HtmlHelpIndex::addItem(), MemberDef::anchor(), Config_getBool, MemberDef::getFileDef(), MemberDef::getGroupDef(), MemberDef::getOutputFileBase(), Definition::getOutputFileBase(), index, and Definition::name().

{
if (md)
{
static bool separateMemberPages = Config_getBool(SEPARATE_MEMBER_PAGES);
if (context==0) // global member
{
if (md->getGroupDef())
context = md->getGroupDef();
else if (md->getFileDef())
context = md->getFileDef();
}
if (context==0) return; // should not happen
QCString cfname = md->getOutputFileBase();
QCString cfiname = context->getOutputFileBase();
QCString level1 = context->name();
QCString level2 = md->name();
QCString contRef = separateMemberPages ? cfname : cfiname;
QCString memRef = cfname;
QCString anchor = sectionAnchor ? QCString(sectionAnchor) : md->anchor();
index->addItem(level1,level2,contRef,anchor,TRUE,FALSE);
index->addItem(level2,level1,memRef,anchor,TRUE,TRUE);
}
else if (context)
{
QCString level1 = word ? QCString(word) : context->name();
index->addItem(level1,0,context->getOutputFileBase(),sectionAnchor,TRUE,FALSE);
}
}
void HtmlHelp::addStyleSheetFile ( const char *  )
inlinevirtual

Implements IndexIntf.

Definition at line 86 of file htmlhelp.h.

{}
void HtmlHelp::createProjectFile ( )
private

Definition at line 466 of file htmlhelp.cpp.

References Config_getBool, Config_getString, endl(), err(), getLanguageString(), Doxygen::htmlFileExtension, imageFiles, indexFiles, and recode().

Referenced by finalize().

{
/* Write the project file */
QCString fName = Config_getString(HTML_OUTPUT) + "/index.hhp";
QFile f(fName);
if (f.open(IO_WriteOnly))
{
FTextStream t(&f);
QCString indexName="index"+Doxygen::htmlFileExtension;
t << "[OPTIONS]\n";
if (!Config_getString(CHM_FILE).isEmpty())
{
t << "Compiled file=" << Config_getString(CHM_FILE) << "\n";
}
t << "Compatibility=1.1\n"
"Full-text search=Yes\n"
"Contents file=index.hhc\n"
"Default Window=main\n"
"Default topic=" << indexName << "\n"
"Index file=index.hhk\n"
"Language=" << getLanguageString() << endl;
if (Config_getBool(BINARY_TOC)) t << "Binary TOC=YES\n";
if (Config_getBool(GENERATE_CHI)) t << "Create CHI file=YES\n";
t << "Title=" << recode(Config_getString(PROJECT_NAME)) << endl << endl;
t << "[WINDOWS]" << endl;
// NOTE: the 0x10387e number is a set of bits specifying the buttons
// which should appear in the CHM viewer; that specific value
// means "show all buttons including the font-size one";
// the font-size one is not normally settable by the HTML Help Workshop
// utility but the way to set it is described here:
// http://support.microsoft.com/?scid=kb%3Ben-us%3B240062&x=17&y=18
// NOTE: the 0x70387e number in addition to the above the Next and Prev button
// are shown. They can only be shown in case of a binary toc.
// dee http://www.mif2go.com/xhtml/htmlhelp_0016_943addingtabsandtoolbarbuttonstohtmlhelp.htm#Rz108x95873
// Value has been taken from htmlhelp.h file of the HTML Help Workshop
if (Config_getBool(BINARY_TOC))
{
t << "main=\"" << recode(Config_getString(PROJECT_NAME)) << "\",\"index.hhc\","
"\"index.hhk\",\"" << indexName << "\",\"" <<
indexName << "\",,,,,0x23520,,0x70387e,,,,,,,,0" << endl << endl;
}
else
{
t << "main=\"" << recode(Config_getString(PROJECT_NAME)) << "\",\"index.hhc\","
"\"index.hhk\",\"" << indexName << "\",\"" <<
indexName << "\",,,,,0x23520,,0x10387e,,,,,,,,0" << endl << endl;
}
t << "[FILES]" << endl;
char *s = indexFiles.first();
while (s)
{
t << s << endl;
s = indexFiles.next();
}
uint i;
for (i=0;i<imageFiles.count();i++)
{
t << imageFiles.at(i) << endl;
}
f.close();
}
else
{
err("Could not open file %s for writing\n",fName.data());
}
}
void HtmlHelp::decContentsDepth ( )
virtual

Decrease the level of the contents hierarchy. This will end the unnumber HTML list.

See Also
incContentsDepth()

Implements IndexIntf.

Definition at line 589 of file htmlhelp.cpp.

References cts, and dc.

{
int i; for (i=0;i<dc;i++) cts << " ";
cts << "</UL>\n";
--dc;
}
void HtmlHelp::finalize ( )
virtual

Finalizes the HTML help. This will finish and close the contents file (index.hhc) and the index file (index.hhk).

See Also
initialize()

Implements IndexIntf.

Definition at line 550 of file htmlhelp.cpp.

References cf, createProjectFile(), cts, index, kf, kts, FTextStream::unsetDevice(), and HtmlHelpIndex::writeFields().

{
// end the contents file
cts << "</UL>\n";
cts << "</BODY>\n";
cts << "</HTML>\n";
cf->close();
delete cf;
// end the index file
kts << "</UL>\n";
kts << "</BODY>\n";
kts << "</HTML>\n";
kf->close();
delete kf;
s_languageDict.clear();
}
QCString HtmlHelp::getLanguageString ( )
static

Definition at line 450 of file htmlhelp.cpp.

References Translator::idLanguage(), and theTranslator.

Referenced by createProjectFile(), and TranslateContext::Private::langString().

{
if (!theTranslator->idLanguage().isEmpty())
{
if (s)
{
return *s;
}
}
// default language
return "0x409 English (United States)";
}
void HtmlHelp::incContentsDepth ( )
virtual

Increase the level of the contents hierarchy. This will start a new unnumbered HTML list in contents file.

See Also
decContentsDepth()

Implements IndexIntf.

Definition at line 578 of file htmlhelp.cpp.

References cts, and dc.

{
int i; for (i=0;i<dc+1;i++) cts << " ";
cts << "<UL>\n";
++dc;
}
void HtmlHelp::initialize ( )
virtual

This will create a contents file (index.hhc) and a index file (index.hhk) and write the header of those files. It also creates a project file (index.hhp)

See Also
finalize()

Implements IndexIntf.

Definition at line 304 of file htmlhelp.cpp.

References cf, Config_getString, cts, err(), kf, kts, m_fromUtf8, portable_iconv_open(), and FTextStream::setDevice().

{
const char *str = Config_getString(CHM_INDEX_ENCODING);
if (!str) str = "CP1250"; // use safe and likely default
if (m_fromUtf8==(void *)(-1))
{
err("unsupported character conversion for CHM_INDEX_ENCODING: '%s'->'UTF-8'\n", str);
exit(1);
}
/* open the contents file */
QCString fName = Config_getString(HTML_OUTPUT) + "/index.hhc";
cf = new QFile(fName);
if (!cf->open(IO_WriteOnly))
{
err("Could not open file %s for writing\n",fName.data());
exit(1);
}
/* Write the header of the contents file */
cts << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
"<HTML><HEAD></HEAD><BODY>\n"
"<OBJECT type=\"text/site properties\">\n"
"<param name=\"FrameName\" value=\"right\">\n"
"</OBJECT>\n"
"<UL>\n";
/* open the contents file */
fName = Config_getString(HTML_OUTPUT) + "/index.hhk";
kf = new QFile(fName);
if (!kf->open(IO_WriteOnly))
{
err("Could not open file %s for writing\n",fName.data());
exit(1);
}
/* Write the header of the contents file */
kts << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
"<HTML><HEAD></HEAD><BODY>\n"
"<OBJECT type=\"text/site properties\">\n"
"<param name=\"FrameName\" value=\"right\">\n"
"</OBJECT>\n"
"<UL>\n";
/* language codes for Html help
0x405 Czech
0x406 Danish
0x413 Dutch
0xC09 English (Australia)
0x809 English (Britain)
0x1009 English (Canada)
0x1809 English (Ireland)
0x1409 English (New Zealand)
0x1C09 English (South Africa)
0x409 English (United States)
0x40B Finnish
0x40C French
0x407 German
0x408 Greece
0x40E Hungarian
0x410 Italian
0x814 Norwegian
0x415 Polish
0x816 Portuguese(Portugal)
0x416 Portuguese(Brazil)
0x419 Russian
0x80A Spanish(Mexico)
0xC0A Spanish(Modern Sort)
0x40A Spanish(Traditional Sort)
0x41D Swedish
0x41F Turkey
0x411 Japanese
0x412 Korean
0x804 Chinese (PRC)
0x404 Chinese (Taiwan)
New LCIDs:
0x421 Indonesian
0x41A Croatian
0x418 Romanian
0x424 Slovenian
0x41B Slovak
0x422 Ukrainian
0x81A Serbian (Serbia, Latin)
0x403 Catalan
0x426 Latvian
0x427 Lithuanian
0x436 Afrikaans
0x42A Vietnamese
0x429 Persian (Iran)
0xC01 Arabic (Egypt) - I don't know which version of arabic is used inside translator_ar.h ,
so I have chosen Egypt at random
*/
s_languageDict.setAutoDelete(TRUE);
s_languageDict.clear();
s_languageDict.insert("czech", new QCString("0x405 Czech"));
s_languageDict.insert("danish", new QCString("0x406 Danish"));
s_languageDict.insert("dutch", new QCString("0x413 Dutch"));
s_languageDict.insert("finnish", new QCString("0x40B Finnish"));
s_languageDict.insert("french", new QCString("0x40C French"));
s_languageDict.insert("german", new QCString("0x407 German"));
s_languageDict.insert("greek", new QCString("0x408 Greece"));
s_languageDict.insert("hungarian", new QCString("0x40E Hungarian"));
s_languageDict.insert("italian", new QCString("0x410 Italian"));
s_languageDict.insert("norwegian", new QCString("0x814 Norwegian"));
s_languageDict.insert("polish", new QCString("0x415 Polish"));
s_languageDict.insert("portuguese", new QCString("0x816 Portuguese(Portugal)"));
s_languageDict.insert("brazilian", new QCString("0x416 Portuguese(Brazil)"));
s_languageDict.insert("russian", new QCString("0x419 Russian"));
s_languageDict.insert("spanish", new QCString("0x40A Spanish(Traditional Sort)"));
s_languageDict.insert("swedish", new QCString("0x41D Swedish"));
s_languageDict.insert("turkish", new QCString("0x41F Turkey"));
s_languageDict.insert("japanese", new QCString("0x411 Japanese"));
s_languageDict.insert("japanese-en", new QCString("0x411 Japanese"));
s_languageDict.insert("korean", new QCString("0x412 Korean"));
s_languageDict.insert("korean-en", new QCString("0x412 Korean"));
s_languageDict.insert("chinese", new QCString("0x804 Chinese (PRC)"));
s_languageDict.insert("chinese-traditional", new QCString("0x404 Chinese (Taiwan)"));
// new LCIDs
s_languageDict.insert("indonesian", new QCString("0x412 Indonesian"));
s_languageDict.insert("croatian", new QCString("0x41A Croatian"));
s_languageDict.insert("romanian", new QCString("0x418 Romanian"));
s_languageDict.insert("slovene", new QCString("0x424 Slovenian"));
s_languageDict.insert("slovak", new QCString("0x41B Slovak"));
s_languageDict.insert("ukrainian", new QCString("0x422 Ukrainian"));
s_languageDict.insert("serbian", new QCString("0x81A Serbian (Serbia, Latin)"));
s_languageDict.insert("catalan", new QCString("0x403 Catalan"));
s_languageDict.insert("lithuanian", new QCString("0x427 Lithuanian"));
s_languageDict.insert("afrikaans", new QCString("0x436 Afrikaans"));
s_languageDict.insert("vietnamese", new QCString("0x42A Vietnamese"));
s_languageDict.insert("persian", new QCString("0x429 Persian (Iran)"));
s_languageDict.insert("arabic", new QCString("0xC01 Arabic (Egypt)"));
s_languageDict.insert("latvian", new QCString("0x426 Latvian"));
s_languageDict.insert("macedonian", new QCString("0x042f Macedonian (Former Yugoslav Republic of Macedonia)"));
s_languageDict.insert("armenian", new QCString("0x42b Armenian"));
//Code for Esperanto should be as shown below but the htmlhelp compiler 1.3 does not support this
// (and no newer version is available).
//So do a fallback to the default language (see getLanguageString())
//s_languageDict.insert("esperanto", new QCString("0x48f Esperanto"));
s_languageDict.insert("serbian-cyrillic", new QCString("0xC1A Serbian (Serbia, Cyrillic)"));
}
QCString HtmlHelp::recode ( const QCString &  s)
private

Definition at line 596 of file htmlhelp.cpp.

References m_fromUtf8, and portable_iconv().

Referenced by addContentsItem(), createProjectFile(), and HtmlHelpIndex::writeFields().

{
int iSize = s.length();
int oSize = iSize*4+1;
QCString output(oSize);
size_t iLeft = iSize;
size_t oLeft = oSize;
char *iPtr = s.rawData();
char *oPtr = output.rawData();
if (!portable_iconv(m_fromUtf8,&iPtr,&iLeft,&oPtr,&oLeft))
{
oSize -= (int)oLeft;
output.resize(oSize+1);
output.at(oSize)='\0';
return output;
}
else
{
return s;
}
}

Friends And Related Function Documentation

friend class HtmlHelpIndex
friend

Definition at line 90 of file htmlhelp.h.

Referenced by HtmlHelp().

Member Data Documentation

QFile* HtmlHelp::cf
private

Definition at line 93 of file htmlhelp.h.

Referenced by finalize(), HtmlHelp(), and initialize().

FTextStream HtmlHelp::cts
private

Definition at line 94 of file htmlhelp.h.

Referenced by addContentsItem(), decContentsDepth(), finalize(), incContentsDepth(), and initialize().

int HtmlHelp::dc
private

Definition at line 96 of file htmlhelp.h.

Referenced by addContentsItem(), decContentsDepth(), HtmlHelp(), and incContentsDepth().

QStrList HtmlHelp::imageFiles
private

Definition at line 98 of file htmlhelp.h.

Referenced by addImageFile(), and createProjectFile().

HtmlHelpIndex* HtmlHelp::index
private

Definition at line 95 of file htmlhelp.h.

Referenced by addIndexItem(), finalize(), HtmlHelp(), and ~HtmlHelp().

QDict<void> HtmlHelp::indexFileDict
private

Definition at line 99 of file htmlhelp.h.

Referenced by addIndexFile().

QStrList HtmlHelp::indexFiles
private

Definition at line 97 of file htmlhelp.h.

Referenced by addIndexFile(), and createProjectFile().

QFile * HtmlHelp::kf
private

Definition at line 93 of file htmlhelp.h.

Referenced by finalize(), HtmlHelp(), and initialize().

FTextStream HtmlHelp::kts
private

Definition at line 94 of file htmlhelp.h.

Referenced by finalize(), and initialize().

void* HtmlHelp::m_fromUtf8
private

Definition at line 102 of file htmlhelp.h.

Referenced by HtmlHelp(), initialize(), recode(), and ~HtmlHelp().

HtmlHelp * HtmlHelp::theInstance = 0
staticprivate

Definition at line 100 of file htmlhelp.h.


The documentation for this class was generated from the following files: