InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HypAdapter Class Reference

#include <HypAdapter.h>

Public Member Functions

virtual PMString GetDictionaryFolderPath ()
 
virtual void Install (Hyp::HyphenationServices &hyphenationServices, const PMString &rPath)
 
virtual IHyphenatedWordHyphenate (const TextCharBuffer &rWord, uint16 nMinTail, uint16 nMinHead, const LinguisticServiceMode &serviceMode, const LanguageID &languageID)
 

Protected Member Functions

virtual void installService (Hyp::HyphenationServices &hyphenationServices, const PMString &rPath, const LanguageID &languageID, const PMString &languageName, const PMString &primaryLanguageName, const PMString &subLanguageName)
 
virtual PMString getDictionaryFile (const LanguageID &languageID)
 
virtual void findHyphenationPoints (const TextCharBuffer &rWord, uint16 nMinTail, uint16 nMinHead, const LinguisticServiceMode &serviceMode, const LanguageID &languageID, Hyp::HyphenationPoints &hyphenationPoints)
 
virtual char * textCharToChar (const TextCharBuffer &rWord)
 

Detailed Description

Placeholder for vendor code to adapt vendor hyphenation to the linguistic API. A dummy implementation is provided that creates two regular hyphenation points, one at the index given by parameter nMinHead and the other at the index given by the word length - parameter nMinTail. For example if Hyphenate were called like this for the word elizabeth: Hyphenate("elizabeth", 3, 3, ...

hyphenation points would be created that could result in the word being hyphenated as eli-zab-eth. The implementation also respects and creates hyphenation points for discretionary hyphens or hard coded hyphens passed in the word.

Notes:

To convert the Unicode text to ASCII before presenting a word to an ASCII hyphenator check out HypAdapter::textCharToChar.

Converting Unicode to a PMString then using PMString::GetPlatformString().c_str() to get ASCII is likely to lead to bugs. Unicode character codes that have no ASCII equivalent appear encoded in the string returned by GetPlatformString().c_str.

The following characters may be presented as part of the word to be hyphenated if they are not preceeded or followed by a word break character. If such characters must be stripped from the word before presenting it to a hyphenator re-adjust the hyphenation points so they are relative to the word passed by the application: kTextChar_FlushSpace kTextChar_EnSpace kTextChar_EmSpace kTextChar_FigureSpace kTextChar_PunctuationSpace kTextChar_ThinSpace kTextChar_HairSpace kTextChar_HardSpace kTextChar_ZeroSpaceBreak kTextChar_ZeroSpaceNoBreak kTextChar_EnDash kTextChar_EmDash kTextChar_Ellipse kTextChar_UnicodeHyphen kTextChar_NoBreakHyphen kTextChar_FigureDash kTextChar_HorizontalBar kTextChar_LeftDoubleQuotationMark kTextChar_RightDoubleQuotationMark kTextChar_DoubleLow9QuotationMark kTextChar_DoubleHighReversed9QuotationMark kTextChar_LeftDblAngQuote kTextChar_RightDblAngQuote kTextChar_LeftSingleQuotationMark kTextChar_RightSingleQuotationMark kTextChar_SingleLow9QuotationMark kTextChar_SingleHighReversed9QuotationMark

Member Function Documentation

void HypAdapter::findHyphenationPoints (const TextCharBufferrWord,
uint16 nMinTail,
uint16 nMinHead,
const LinguisticServiceMode & serviceMode,
const LanguageID & languageID,
Hyp::HyphenationPointshyphenationPoints 
)
protectedvirtual

Analyse the given word and return hyphenationPoints giving the index and type of each point.

Parameters
rWord
nMinTail
nMinHead
serviceMode
languageID
hyphenationPointsfor the given word.
PMString HypAdapter::getDictionaryFile (const LanguageID & languageID)
protectedvirtual
Parameters
languageID
Returns
the name of the dictionary file for the given language. The filename returned here is concatenated with the folder returned by GetDictionaryFolderPath and gets passed to your hyphenation service (IHyphenationService::Set()).
PMString HypAdapter::GetDictionaryFolderPath ()
virtual
Returns
path to folder containing dictionary data files, empty string if you don't have any. The path you return here is made available on your linguistic service's ILinguisticServiceData interface in the service registry. It's also passed back to you when HypAdapter::Install is called.
IHyphenatedWord * HypAdapter::Hyphenate (const TextCharBufferrWord,
uint16 nMinTail,
uint16 nMinHead,
const LinguisticServiceMode & serviceMode,
const LanguageID & languageID 
)
virtual

Hypenate the given word. Parameters nMinHead and nMinTail specify the range of indexes in the word where hyphen breaks are permitted. For example, by specifying 3 for these values, the word kitten could be hyphenated kit-ten. i.e.

kit-ten

0 1 2 3 4 5

k i t t e n

0 0 1 0 0 0 (where 1 indicates valid hyphen index)

A hyphen index is the position before the hyphen: i.e. kit-ten has a hyphen index = 2.

Given i is a valid hyphen index it will lie in this range:

nMinHead: i >=(nMinHead - 1) for nMinHead = 3, first i would be 2 (>= 3-1)

nMinTail: i < (wordLength - nMinTail) for nMinTail = 3, last i would be 2 (< 6-3)

Parameters
rWordto be hyphenated.
nMinTailthe minimum number of characters at the end of a word after a hyphen.
nMinHeadthe minimum number of characters at the start of a word before a hyphen.
serviceModeis the type of hyphenation desired (algorithmic, dictionary, see LinguisticID.h). The value passed is controlled by text attribute kTextAttrHyphenModeBoss.
languageIDthe language of the word (see LanguageID.h).
Returns
hypenated word (see HypHyphenatedWord).
void HypAdapter::Install (Hyp::HyphenationServiceshyphenationServices,
const PMStringrPath 
)
virtual

Create hyphenation service boss objects (kHypHyphenationServiceBoss) supported languages. Called by HypHyphenationMgr.

Parameters
hyphenationServicesOUT collection in which to return created services.
rPathIN path to dictionary folder.
void HypAdapter::installService (Hyp::HyphenationServiceshyphenationServices,
const PMStringrPath,
const LanguageID & languageID,
const PMStringlanguageName,
const PMStringprimaryLanguageName,
const PMStringsubLanguageName 
)
protectedvirtual

Create hyphenation service (kHypHyphenationServiceBoss) for given language.

Parameters
hyphenationServicesOUT collection created service to be added to.
rPathto dictionary folder (if any).
languageID
languageName
primaryLanguageName
subLanguageName
char * HypAdapter::textCharToChar (const TextCharBufferrWord)
protectedvirtual
Parameters
rWordUnicode word to be converted to ASCII.
Returns
ASCII equivalent of Unicode word.