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() );
361 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwHyphPortion"));
365 (void)xmlTextWriterEndElement(pWriter);
402 m_bExpand(false), m_nViewWidth(0)
469 const bool bHyph = rInf.
ChgHyph(
true );
534 if( bFull || !rInf.
GetFly() )
537 rInf.
X( nOldX +
Width() );
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...
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
virtual void Paint(const SwTextPaintInfo &rInf) const override
void GetFontCacheId(const void *&rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich)
SwFontScript GetActual() const
bool IsSymbol(SwViewShell const *pSh)
LanguageType GetLanguage() const
virtual void Calc(vcl::RenderContext *pRenderContext) const
SwRootFrame * getRootFrame()
virtual void HandlePortion(SwPortionHandler &rPH) const override
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
virtual bool Format(SwTextFormatInfo &rInf) override
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &nOffset) const override
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
virtual void HandlePortion(SwPortionHandler &rPH) const override
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &xHW)
TextFrameIndex m_nWordLen
TextFrameIndex m_nStart
input: requested range to hyphenate
TextFrameIndex m_nWordStart
output: found word
Collection of SwLinePortion instances, representing one line of text.
void SetMidHyph(const bool bNew)
SwLinePortion * GetFirstPortion() const
void SetEndHyph(const bool bNew)
Base class for anything that can be part of a line in the Writer layout.
void PrtWidth(SwTwips nNewWidth)
void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view rText, TextFrameIndex nOffset) const
SwLinePortion * mpNextPortion
bool IsSoftHyphPortion() const
SwLinePortion * GetNextPortion() const
void SetAscent(const SwTwips nNewAsc)
PortionType GetWhichPor() const
TextFrameIndex GetLen() const
bool IsParaPortion() const
bool IsLayPortion() const
bool IsDropPortion() const
bool IsBreakPortion() const
void CalcTextSize(const SwTextSizeInfo &rInfo)
SwLinePortion * FindPrevPortion(const SwLinePortion *pRoot)
void SetLen(TextFrameIndex const nLen)
void SetWhichPor(const PortionType nNew)
virtual SwLinePortion * Insert(SwLinePortion *pPortion)
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
virtual void Special(TextFrameIndex nLength, const OUString &rText, PortionType nType)=0
special portion.
SwViewShell * GetCurrShell() const
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
We're expanding:
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
virtual void Paint(const SwTextPaintInfo &rInf) const override
Cases:
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Format End of Line.
virtual void HandlePortion(SwPortionHandler &rPH) const override
virtual bool Format(SwTextFormatInfo &rInf) override
We get the final width from the FormatEOL()
void SetExpand(const bool bNew)
virtual SwLinePortion * Compress() override
virtual void Paint(const SwTextPaintInfo &rInf) const override
SwSoftHyphStrPortion(std::u16string_view rStr)
SwLinePortion * GetLast()
css::uno::Reference< css::linguistic2::XHyphenatedWord > HyphWord(const OUString &rText, const sal_Int32 nMinTrail)
TextFrameIndex GetLineStart() const
void SetLast(SwLinePortion *pNewLast)
TextFrameIndex GetSoftHyphPos() const
bool IsHyphenate() const
If the Hyphenator returns ERROR or the language is set to NOLANGUAGE we do not hyphenate.
const css::beans::PropertyValues & GetHyphValues() const
bool IsHyphForbud() const
void SetUnderflow(SwLinePortion *pNew)
void SetSoftHyphPos(TextFrameIndex const nNew)
bool ChgHyph(const bool bNew)
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
TextFrameIndex FormatLine(TextFrameIndex nStart)
SwTextFormatInfo & GetInfo()
SwTextFrame * GetFormatted(bool bForceQuickFormat=false)
In case the SwLineLayout was cleared out of the s_pTextCache, recreate it.
SwTextFrame * GetFollow()
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
We format a Line for interactive hyphenation.
void SwapWidthAndHeight()
Swaps width and height of the text frame.
bool AlternativeSpelling(const SwTextFormatInfo &rInf, const TextFrameIndex nPos)
TextFrameIndex FieldDiff() const
TextFrameIndex BreakStart() const
const css::uno::Reference< css::linguistic2::XHyphenatedWord > & HyphWord() const
const SwLineLayout * GetNext() const
TextFrameIndex GetStart() const
const SwLineLayout * Next()
void CharToLine(TextFrameIndex)
const SwLineLayout * GetCurr() const
const SwLineLayout * Prev()
void DrawViewOpt(const SwLinePortion &rPor, PortionType nWhich, const Color *pColor=nullptr) const
bool CreateHyphen(SwTextFormatInfo &rInf, SwTextGuess const &rGuess)
void BreakCut(SwTextFormatInfo &rInf, const SwTextGuess &rGuess)
const SwViewOption & GetOpt() const
void SetLen(const TextFrameIndex nNew)
void SetIdx(const TextFrameIndex nNew)
SwPosSize GetTextSize(OutputDevice *pOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex nIdx, TextFrameIndex nLen) const
TextFrameIndex GetLen() const
const OUString & GetText() const
TextFrameIndex GetIdx() const
vcl::RenderContext * GetOut() const
struct _xmlTextWriter * xmlTextWriterPtr
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
void SetParaPortion(SwTextInfo *pInf, SwParaPortion *pRoot)
We format a row for interactive hyphenation We can assume that we've already formatted.
SvxAlternativeSpelling SvxGetAltSpelling(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rHyphWord)