27#include <com/sun/star/i18n/BreakType.hpp>
28#include <com/sun/star/i18n/WordType.hpp>
29#include <com/sun/star/i18n/XBreakIterator.hpp>
52 const sal_uInt16 nPorHeight )
61 "+SwTextGuess::Guess: invalid SwTextFormatInfo" );
63 OSL_ENSURE( nPorHeight,
"+SwTextGuess::Guess: no height" );
65 sal_uInt16 nMaxSizeDiff;
89 if ( rAdjust == SvxAdjust::Right || rAdjust == SvxAdjust::Center )
92 for (sal_Int32
i = rInf.
GetText().getLength() - 1;
101 if ( nSpaceCnt && nCharsCnt < rPor.
GetLen() )
114 if ( rInf.
GetLen() < nMaxLen )
120 sal_uInt16 nItalic = 0;
123 bool bAddItalic =
true;
148 nItalic = bAddItalic ? nPorHeight / 12 : 0;
156 const sal_Int32 nLeftRightBorderSpace =
205 sal_Int32 nHyphZone = -1;
206 const css::beans::PropertyValues & rHyphValues = rInf.
GetHyphValues();
207 assert( rHyphValues.getLength() > 5 && rHyphValues[5].Name ==
UPN_HYPH_ZONE );
209 sal_uInt16 nTextHyphenZone;
210 if ( rHyphValues[5].
Value >>= nTextHyphenZone )
221 sal_Int32 nZonePos = sal_Int32(
m_nCutPos);
227 for (; sal_Int32(rInf.
GetIdx()) <= nZonePos && nHyphZone <= nZonePos; --nZonePos )
241 sal_Int32 nLastWord = rInf.
GetText().getLength() - 1;
242 bool bHyphenationNoLastWord =
false;
244 if ( rHyphValues[3].
Value >>= bHyphenationNoLastWord )
247 bool bCutBlank =
false;
248 for (; sal_Int32(rInf.
GetIdx()) <= nLastWord; --nLastWord )
253 else if ( bCutBlank )
259 if ( bHyphenationNoLastWord && sal_Int32(
m_nCutPos) > nLastWord &&
266 if ( !nHyphPos && rInf.
GetIdx() )
273#if OSL_DEBUG_LEVEL > 1
278 nMaxComp, nMinSize, nMaxSizeDiff );
279 OSL_ENSURE( nMinSize <=
nLineWidth,
"What a Guess!!!" );
322 if (IsBlank(cCutChar))
327 if ( rAdjust == SvxAdjust::Left )
360#if OSL_DEBUG_LEVEL > 0
361 OUString aDebugString;
376 if ( !aText.isEmpty() )
382#if OSL_DEBUG_LEVEL > 0
387 OUString& rOldText =
const_cast<OUString&
> (rInf.
GetText());
388 rOldText = rOldText.replaceAt(sal_Int32(rInf.
GetIdx()) - 1, 1, aText);
395 LineBreakHyphenationOptions aHyphOpt;
396 Reference< XHyphenator > xHyph;
400 aHyphOpt = LineBreakHyphenationOptions( xHyph,
429 if ( nLangIndex > nDoNotStepOver &&
433 while ( nLangIndex > nDoNotStepOver &&
439 if ( nLangIndex < rInf.
GetIdx() )
442 sal_Int32(nLangIndex));
443 OSL_ENSURE( nScript,
"Script is not between 1 and 4" );
457 const ForbiddenCharacters aForbidden(
464 LineBreakUserOptions aUserOpt(
465 aForbidden.beginLine, aForbidden.endLine,
491 bHyph = BreakType::HYPHENATION == aResult.breakType;
503 sal_Int32
const nSoftHyphPos =
506 if ( nSoftHyphPos >= 0 &&
534 if( rAdjust != SvxAdjust::Left )
564 aTmpSize.
Width(aTmpSize.
Width() + nLeftRightBorderSpace);
565 OSL_ENSURE( !
m_pHanging,
"A hanging portion is hanging around" );
587 "I've got field trouble, part2!" );
590 OUString& rOldText =
const_cast<OUString&
> (rInf.
GetText());
591 OUString aReplacement( cFieldChr );
592 rOldText = rOldText.replaceAt(sal_Int32(nOldIdx) - 1, sal_Int32(
m_nFieldDiff) + 1, aReplacement);
595#if OSL_DEBUG_LEVEL > 0
596 OSL_ENSURE( aDebugString == rInf.
GetText(),
597 "Somebody, somebody, somebody put something in my string" );
644 WordType::DICTIONARY_WORD,
true );
646 sal_Int32 nWordLen = aBound.endPos - sal_Int32(
m_nBreakStart);
655 OSL_ENSURE( xHyph.is(),
"Hyphenator is missing");
657 m_xHyphWord = xHyph->queryAlternativeSpelling( aText,
@ MS_WORD_COMP_TRAILING_BLANKS
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
virtual const css::i18n::ForbiddenCharacters * getForbiddenCharacters(LanguageType nLang, bool bLocaleData) const =0
Return the forbidden characters.
SvxAdjust GetAdjust() const
const SvxAdjustItem & GetAdjust(bool=true) const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
IDocumentSettingAccess const & getIDocumentSettingAccess() const
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
FontItalic GetItalic() const
sal_uInt16 GetRightBorderSpace() const
SwFontScript GetActual() const
LanguageType GetLanguage() const
sal_uInt16 GetLeftBorderSpace() const
bool IsRightToLeft() const
SwPageFrame * FindPageFrame()
bool GetJoinBorderWithPrev() const
TextFrameIndex GetLen() const
bool GetJoinBorderWithNext() const
bool IsFootnotePortion() const
bool IsDropPortion() const
bool IsNumberPortion() const
SwScriptInfo & GetScriptInfo()
size_t CountCompChg() const
SwLinePortion * GetLast()
TextFrameIndex GetLineStart() const
bool IsHyphenate() const
If the Hyphenator returns ERROR or the language is set to NOLANGUAGE we do not hyphenate.
SwTwips GetLineWidth()
Returns the distance between the current horizontal position and the end of the line.
const css::beans::PropertyValues & GetHyphValues() const
bool IsHyphForbud() const
LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, bool bNoChar=false) const
SwTextNode const * GetTextNodeForParaProps() const
SwTextGrid GetGridType() const
bool AlternativeSpelling(const SwTextFormatInfo &rInf, const TextFrameIndex nPos)
sal_uInt16 m_nExtraBlankWidth
TextFrameIndex m_nBreakPos
std::unique_ptr< SwHangingPortion > m_pHanging
TextFrameIndex m_nBreakStart
css::uno::Reference< css::linguistic2::XHyphenatedWord > m_xHyphWord
bool Guess(const SwTextPortion &rPor, SwTextFormatInfo &rInf, const sal_uInt16 nHeight)
TextFrameIndex m_nFieldDiff
SwParaPortion * GetParaPortion()
This portion represents a part of the paragraph string.
SwTextFrame * GetTextFrame()
void SetMaxWidthDiff(const SwLinePortion *nKey, sal_uInt16 nVal)
TextFrameIndex GetTextBreak(const tools::Long nLineWidth, const TextFrameIndex nMaxLen, const sal_uInt16 nComp, vcl::text::TextLayoutCache const *) const
const std::shared_ptr< const vcl::text::TextLayoutCache > & GetCachedVclData() const
void SetIdx(const TextFrameIndex nNew)
SwPosSize GetTextSize(OutputDevice *pOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex nIdx, TextFrameIndex nLen) const
sal_Unicode GetChar(TextFrameIndex const nPos) const
TextFrameIndex GetLen() const
bool IsFootnoteInside() const
bool IsFirstMulti() const
const OUString & GetText() const
TextFrameIndex GetIdx() const
bool HasForbiddenChars() const
#define CH_TXTATR_BREAKWORD
CharClass & GetAppCharClass()
constexpr OUStringLiteral UPN_HYPH_ZONE
constexpr OUStringLiteral UPN_HYPH_NO_LAST_WORD
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
const sal_Unicode CH_BREAK
const sal_Unicode CH_NB_SPACE
const sal_Unicode CH_SIX_PER_EM
const sal_Unicode CH_BLANK
const sal_Unicode CH_FULL_BLANK
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
constexpr sal_Int32 COMPLETE_STRING