From e63923b0334ae381e0fcc576a6b6e08a62e657cf Mon Sep 17 00:00:00 2001 From: László Németh Date: Thu, 30 Jan 2014 14:56:30 +0100 Subject: fdo#44314 non-standard hyphenation at soft hyphens + with pers. dic. Change-Id: I25e7c13036c6ce1948cc33d45901ef69a258fb03 --- .../source/hyphenator/hyphen/hyphenimp.cxx | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'lingucomponent') diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx index 64fe545fcd21..1cb79963b41e 100644 --- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx @@ -508,16 +508,22 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo Reference < XHyphenatedWord > SAL_CALL Hyphenator::queryAlternativeSpelling( - const OUString& /*aWord*/, - const ::com::sun::star::lang::Locale& /*aLocale*/, - sal_Int16 /*nIndex*/, - const ::com::sun::star::beans::PropertyValues& /*aProperties*/ ) + const OUString& aWord, + const ::com::sun::star::lang::Locale& aLocale, + sal_Int16 nIndex, + const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - /* alternative spelling isn't supported by tex dictionaries */ - /* XXX: OOo's extended libhjn algorithm can support alternative spellings with extended TeX dic. */ - /* TASK: implement queryAlternativeSpelling() */ - return NULL; + // FIXME: multiple character change, eg. briddzsel -> bridzs-dzsel is not supported, + // because Writer has got a layout problem here. + // Firstly we allow only one plus character before the hyphen to avoid to miss the right break point: + for (int extrachar = 1; extrachar < 2; extrachar++) // temporarily i < 2 instead of i <= 2 + { + Reference< XHyphenatedWord > xRes = hyphenate(aWord, aLocale, nIndex + 1 + extrachar, aProperties); + if (xRes.is() && xRes->isAlternativeSpelling() && xRes->getHyphenationPos() == nIndex) + return xRes; + } + return NULL; } Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const OUString& aWord, @@ -658,7 +664,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const for ( i = 0; i < encWord.getLength(); i++) { - if (hyphens[i]&1 && (!rep || !rep[i])) + if (hyphens[i]&1) nHyphCount++; } @@ -670,8 +676,8 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const for (i = 0; i < nWord.getLength(); i++) { hyphenatedWordBuffer.append(aWord[i]); - // hyphenation position (not alternative) - if (hyphens[i]&1 && (!rep || !rep[i])) + // hyphenation position + if (hyphens[i]&1) { pPos[nHyphCount] = i; hyphenatedWordBuffer.append('='); -- cgit