22 #include <com/sun/star/i18n/WordType.hpp>
23 #include <com/sun/star/i18n/XBreakIterator.hpp>
40 const OUString &rText,
const sal_Int32 nMinTrail )
45 Reference< XHyphenatedWord > xHyphWord;
48 xHyphWord = xHyph->hyphenate( rText,
66 OSL_ENSURE( !
IsLocked(),
"SwTextFrame::Hyphenate: this is locked" );
100 while( !bRet && aLine.
GetStart() < nEnd )
122 OSL_ENSURE( pRoot,
"SetParaPortion: no root anymore" );
154 OSL_ENSURE(
IsParaLine(),
"SwTextFormatter::Hyphenate: not the first" );
177 if( nWrdStart >= nEnd )
183 if( nWrdStart >= nPamStart && pPos->
InHyphGrp()
187 nWrdStart = nWrdStart + pPos->
GetLen();
191 nWrdStart = nWrdStart + pPos->
GetLen();
211 OSL_ENSURE(
IsParaLine(),
"SwTextFormatter::Hyphenate: even not the first" );
224 Reference< XHyphenatedWord > xHyphWord;
227 rInf.
GetText(), sal_Int32(nWrdStart),
234 OUString
const aSelText(rInf.
GetText().copy(sal_Int32(nWrdStart), sal_Int32(nLen)));
235 const sal_Int32 nMinTrail = (nWrdStart + nLen > nEnd)
236 ? sal_Int32(nWrdStart + nLen - nEnd) - 1
240 xHyphWord = rInf.
HyphWord( aSelText, nMinTrail );
241 if ( xHyphWord.is() )
254 const Reference< XHyphenatedWord >& xHyphWord = rGuess.
HyphWord();
256 OSL_ENSURE( !
mpNextPortion,
"SwTextPortion::CreateHyphen(): another portion, another planet..." );
257 OSL_ENSURE( xHyphWord.is(),
"SwTextPortion::CreateHyphen(): You are lucky! The code is robust here." );
266 std::unique_ptr<SwHyphPortion> pHyphPor;
271 if ( xHyphWord->isAlternativeSpelling() )
274 OSL_ENSURE( aAltSpell.
bIsAltSpelling,
"no alternative spelling" );
278 sal_Int32 nTmpLen = 0;
292 static_cast<SwPosSize&
>(*pHyphPor) = pHyphPor->GetTextSize( rInf );
301 static const void* nLastFontCacheId =
nullptr;
302 static sal_uInt16 aMiniCacheH = 0, aMiniCacheW = 0;
303 const void* nTmpFontCacheId;
306 if( !nLastFontCacheId || nLastFontCacheId != nTmpFontCacheId ) {
307 nLastFontCacheId = nTmpFontCacheId;
308 static_cast<SwPosSize&
>(*pHyphPor) = pHyphPor->GetTextSize( rInf );
309 aMiniCacheH = pHyphPor->
Height();
310 aMiniCacheW = pHyphPor->Width();
312 pHyphPor->Height( aMiniCacheH );
313 pHyphPor->Width( aMiniCacheW );
324 if ( nPorEnd > rInf.
GetIdx() ||
332 Insert( pHyphPor.release() );
392 bExpand(false), nViewWidth(0)
459 const bool bHyph = rInf.
ChgHyph(
true );
524 if( bFull || !rInf.
GetFly() )
527 rInf.
X( nOldX +
Width() );
vcl::RenderContext * GetOut() const
virtual void HandlePortion(SwPortionHandler &rPH) const override
TextFrameIndex FieldDiff() const
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Format End of Line.
SwSoftHyphStrPortion(std::u16string_view rStr)
SvxAlternativeSpelling SvxGetAltSpelling(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rHyphWord)
const css::beans::PropertyValues & GetHyphValues() const
sal_uInt16 Height() const
TextFrameIndex GetStart() const
void SetParaPortion(SwTextInfo *pInf, SwParaPortion *pRoot)
We format a row for interactive hyphenation We can assume that we've already formatted.
virtual void Paint(const SwTextPaintInfo &rInf) const override
virtual void Paint(const SwTextPaintInfo &rInf) const override
void BreakCut(SwTextFormatInfo &rInf, const SwTextGuess &rGuess)
void CalcTextSize(const SwTextSizeInfo &rInfo)
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
void SetLast(SwLinePortion *pNewLast)
virtual bool Format(SwTextFormatInfo &rInf) override
We get the final width from the FormatEOL()
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
void SetLen(TextFrameIndex const nLen)
void CharToLine(TextFrameIndex)
const SwLineLayout * Next()
bool IsSymbol(SwViewShell const *pSh)
virtual void Calc(vcl::RenderContext *pRenderContext) const
SwPosSize GetTextSize(OutputDevice *pOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex nIdx, TextFrameIndex nLen) const
bool AlternativeSpelling(const SwTextFormatInfo &rInf, const TextFrameIndex nPos)
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
bool ChgHyph(const bool bNew)
bool IsParaPortion() const
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
We format a Line for interactive hyphenation.
SwTextFormatInfo & GetInfo()
bool IsLayPortion() const
virtual SwLinePortion * Compress() override
bool IsBreakPortion() const
TextFrameIndex m_nWordStart
output: found word
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
TextFrameIndex BreakStart() const
TextFrameIndex GetLineStart() const
SwFontScript GetActual() const
SwTextFrame * GetFollow()
virtual void Special(TextFrameIndex nLength, const OUString &rText, PortionType nType, sal_Int32 nHeight=0, sal_Int32 nWidth=0, const SwFont *pFont=nullptr)=0
special portion.
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
bool IsSoftHyphPortion() const
virtual bool Format(SwTextFormatInfo &rInf) override
void SetEndHyph(const bool bNew)
const SwViewOption & GetOpt() const
Collection of SwLinePortion instances, representing one line of text.
void SetWhichPor(const PortionType nNew)
void SetUnderflow(SwLinePortion *pNew)
SwLinePortion * GetFirstPortion() const
bool IsHyphForbud() const
void SetExpand(const bool bNew)
SwTextFrame * GetFormatted(bool bForceQuickFormat=false)
In case the SwLineLayout was cleared out of the s_pTextCache, recreate it.
TextFrameIndex GetIdx() const
bool IsDropPortion() const
TextFrameIndex GetLen() const
const OUString & GetText() const
SwLinePortion * mpNextPortion
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
Base class for anything that can be part of a line in the Writer layout.
const SwLineLayout * Prev()
const css::lang::Locale & GetLocale(const LanguageType aLang)
void SetSoftHyphPos(TextFrameIndex const nNew)
bool CreateHyphen(SwTextFormatInfo &rInf, SwTextGuess const &rGuess)
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
We're expanding:
LanguageType GetLanguage() const
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
TextFrameIndex FormatLine(TextFrameIndex nStart)
bool IsHyphenate() const
If the Hyphenator returns ERROR or the language is set to NOLANGUAGE we do not hyphenate.
void SetLen(const TextFrameIndex nNew)
css::uno::Reference< css::linguistic2::XHyphenatedWord > HyphWord(const OUString &rText, const sal_Int32 nMinTrail)
PortionType GetWhichPor() const
void SwapWidthAndHeight()
Swaps width and height of the text frame.
TextFrameIndex m_nStart
input: requested range to hyphenate
TextFrameIndex GetLen() const
SwLinePortion * FindPrevPortion(const SwLinePortion *pRoot)
virtual void Paint(const SwTextPaintInfo &rInf) const override
Cases:
virtual void HandlePortion(SwPortionHandler &rPH) const override
SwLinePortion * GetLast()
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
const SwLineLayout * GetNext() const
const SwLineLayout * GetCurr() const
void SetAscent(const sal_uInt16 nNewAsc)
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
void PrtWidth(sal_uInt16 nNewWidth)
virtual void HandlePortion(SwPortionHandler &rPH) const override
sal_uInt16 PrtWidth() const
void SetMidHyph(const bool bNew)
SwLinePortion * GetNextPortion() const
void SetIdx(const TextFrameIndex nNew)
SwViewShell * GetCurrShell() const
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...
TextFrameIndex m_nWordLen
virtual SwLinePortion * Insert(SwLinePortion *pPortion)
TextFrameIndex GetSoftHyphPos() const
SwRootFrame * getRootFrame()
void DrawViewOpt(const SwLinePortion &rPor, PortionType nWhich) const
void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &xHW)
const css::uno::Reference< css::linguistic2::XHyphenatedWord > & HyphWord() const
void GetFontCacheId(const void *&rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich)