27 #include <com/sun/star/i18n/BreakType.hpp>
28 #include <com/sun/star/i18n/WordType.hpp>
29 #include <com/sun/star/i18n/XBreakIterator.hpp>
51 const sal_uInt16 nPorHeight )
60 "+SwTextGuess::Guess: invalid SwTextFormatInfo" );
62 OSL_ENSURE( nPorHeight,
"+SwTextGuess::Guess: no height" );
64 sal_uInt16 nMaxSizeDiff;
88 if ( rAdjust == SvxAdjust::Right || rAdjust == SvxAdjust::Center )
91 for (sal_Int32
i = rInf.
GetText().getLength() - 1;
100 if ( nSpaceCnt && nCharsCnt < rPor.
GetLen() )
110 if ( rInf.
GetLen() < nMaxLen )
116 sal_uInt16 nItalic = 0;
119 bool bAddItalic =
true;
144 nItalic = bAddItalic ? nPorHeight / 12 : 0;
146 nLineWidth -= nItalic;
149 if ( nLineWidth < 0 ) nLineWidth = 0;
152 const sal_Int32 nLeftRightBorderSpace =
156 nLineWidth -= nLeftRightBorderSpace;
162 if ( ( nLineWidth * 2 >
SwTwips(sal_Int32(nMaxLen)) * nPorHeight ) ||
169 if ( ( m_nBreakWidth <= nLineWidth ) || ( bUnbreakableNumberings && rPor.
IsNumberPortion() ) )
178 m_nBreakWidth = m_nBreakWidth + nItalic;
184 m_nBreakWidth += nLeftRightBorderSpace;
200 if ( !nHyphPos && rInf.
GetIdx() )
207 #if OSL_DEBUG_LEVEL > 1
212 nMaxComp, nMinSize, nMaxSizeDiff );
213 OSL_ENSURE( nMinSize <= nLineWidth,
"What a Guess!!!" );
227 if ( m_nBreakWidth <= nLineWidth )
230 m_nBreakWidth = m_nBreakWidth + nItalic;
236 m_nBreakWidth += nLeftRightBorderSpace;
256 if (IsBlank(cCutChar))
261 if ( rAdjust == SvxAdjust::Left )
294 #if OSL_DEBUG_LEVEL > 0
295 OUString aDebugString;
310 if ( !aText.isEmpty() )
316 #if OSL_DEBUG_LEVEL > 0
321 OUString& rOldText =
const_cast<OUString&
> (rInf.
GetText());
322 rOldText = rOldText.replaceAt(sal_Int32(rInf.
GetIdx()) - 1, 1, aText);
329 LineBreakHyphenationOptions aHyphOpt;
330 Reference< XHyphenator > xHyph;
334 aHyphOpt = LineBreakHyphenationOptions( xHyph,
363 if ( nLangIndex > nDoNotStepOver &&
367 while ( nLangIndex > nDoNotStepOver &&
373 if ( nLangIndex < rInf.
GetIdx() )
376 sal_Int32(nLangIndex));
377 OSL_ENSURE( nScript,
"Script is not between 1 and 4" );
391 const ForbiddenCharacters aForbidden(
398 LineBreakUserOptions aUserOpt(
399 aForbidden.beginLine, aForbidden.endLine,
425 bHyph = BreakType::HYPHENATION == aResult.breakType;
437 sal_Int32
const nSoftHyphPos =
440 if ( nSoftHyphPos >= 0 &&
468 if( rAdjust != SvxAdjust::Left )
498 aTmpSize.
Width(aTmpSize.
Width() + nLeftRightBorderSpace);
499 OSL_ENSURE( !
m_pHanging,
"A hanging portion is hanging around" );
502 nPorLen = m_nCutPos - rInf.
GetIdx();
521 "I've got field trouble, part2!" );
524 OUString& rOldText =
const_cast<OUString&
> (rInf.
GetText());
525 OUString aReplacement( cFieldChr );
526 rOldText = rOldText.replaceAt(sal_Int32(nOldIdx) - 1, sal_Int32(m_nFieldDiff) + 1, aReplacement);
529 #if OSL_DEBUG_LEVEL > 0
530 OSL_ENSURE( aDebugString == rInf.
GetText(),
531 "Somebody, somebody, somebody put something in my string" );
546 m_nBreakWidth += nItalic + nLeftRightBorderSpace;
569 rInf.
GetText(), sal_Int32(nPos),
571 WordType::DICTIONARY_WORD,
true );
573 sal_Int32 nWordLen = aBound.endPos - sal_Int32(
m_nBreakStart);
582 OSL_ENSURE( xHyph.is(),
"Hyphenator is missing");
584 m_xHyphWord = xHyph->queryAlternativeSpelling( aText,
586 sal::static_int_cast<sal_Int16>(sal_Int32(nPos -
m_nBreakStart)),
588 return m_xHyphWord.is() && m_xHyphWord->isAlternativeSpelling();
const sal_Unicode CH_BREAK
bool IsFirstMulti() const
sal_uInt16 GetLeftBorderSpace() const
const sal_Unicode CH_NB_SPACE
SvxAdjust GetAdjust() const
LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, bool bNoChar=false) const
const css::beans::PropertyValues & GetHyphValues() const
bool GetJoinBorderWithPrev() const
sal_uInt16 GetRightBorderSpace() const
virtual const css::i18n::ForbiddenCharacters * getForbiddenCharacters(LanguageType nLang, bool bLocaleData) const =0
Return the forbidden characters.
bool Guess(const SwTextPortion &rPor, SwTextFormatInfo &rInf, const sal_uInt16 nHeight)
css::uno::Reference< css::linguistic2::XHyphenatedWord > m_xHyphWord
SwPosSize GetTextSize(OutputDevice *pOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex nIdx, TextFrameIndex nLen) const
bool AlternativeSpelling(const SwTextFormatInfo &rInf, const TextFrameIndex nPos)
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
size_t CountCompChg() const
#define CH_TXTATR_BREAKWORD
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
bool IsFootnoteInside() const
sal_Unicode GetChar(TextFrameIndex const nPos) const
TextFrameIndex m_nBreakPos
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
TextFrameIndex GetLineStart() const
SwFontScript GetActual() const
This portion represents a part of the paragraph string.
SwTextNode const * GetTextNodeForParaProps() const
const sal_Unicode CH_FULL_BLANK
SwTwips GetLineWidth()
Returns the distance between the current horizontal position and the end of the line.
SwPageFrame * FindPageFrame()
SwParaPortion * GetParaPortion()
bool HasForbiddenChars() const
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
const sal_Unicode CH_BLANK
TextFrameIndex m_nFieldDiff
bool IsHyphForbud() const
bool IsNumberPortion() const
void SetMaxWidthDiff(const SwLinePortion *nKey, sal_uInt16 nVal)
const SvxAdjustItem & GetAdjust(bool=true) const
std::unique_ptr< SwHangingPortion > m_pHanging
TextFrameIndex GetIdx() const
bool IsDropPortion() const
TextFrameIndex GetLen() const
SwTextFrame * GetTextFrame()
const OUString & GetText() const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const std::shared_ptr< vcl::TextLayoutCache > & GetCachedVclData() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
LanguageType GetLanguage() const
bool IsHyphenate() const
If the Hyphenator returns ERROR or the language is set to NOLANGUAGE we do not hyphenate.
bool IsFootnotePortion() const
FontItalic GetItalic() const
TextFrameIndex m_nBreakStart
IDocumentSettingAccess const & getIDocumentSettingAccess() const
bool IsRightToLeft() const
TextFrameIndex GetLen() const
SwScriptInfo & GetScriptInfo()
TextFrameIndex GetTextBreak(const tools::Long nLineWidth, const TextFrameIndex nMaxLen, const sal_uInt16 nComp, vcl::TextLayoutCache const *) const
SwLinePortion * GetLast()
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
SwTextGrid GetGridType() const
bool GetJoinBorderWithNext() const
void SetIdx(const TextFrameIndex nNew)
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...
CharClass & GetAppCharClass()
const sal_Int32 COMPLETE_STRING
const sal_Unicode CH_SIX_PER_EM