Kaydet (Commit) f041a3d0 authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide: add a SwTextFrame::GetDropLen()

Copy the SwTextNode::GetDropLen, as it can't be used in case the
drop-text would include a delete redline, but the SwTextNode one is
apparently needed by the WW8 filter.

Change-Id: I26a8a15e977120d601d87a76d712005e2888b713
üst 224cbdfa
......@@ -504,6 +504,8 @@ public:
*/
SwTwips GetFootnoteLine( const SwTextFootnote *pFootnote ) const;
TextFrameIndex GetDropLen(TextFrameIndex nWishLen) const;
virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
virtual void CheckDirection( bool bVert ) override;
......
......@@ -169,6 +169,61 @@ sal_Int32 SwTextNode::GetDropLen( sal_Int32 nWishLen ) const
return i;
}
/// nWishLen = 0 indicates that we want a whole word
TextFrameIndex SwTextFrame::GetDropLen(TextFrameIndex const nWishLen) const
{
TextFrameIndex nEnd(GetText().getLength());
if (nWishLen && nWishLen < nEnd)
nEnd = nWishLen;
if (! nWishLen)
{
// find first word
const SwAttrSet& rAttrSet = GetTextNodeForParaProps()->GetSwAttrSet();
const sal_uInt16 nTextScript = g_pBreakIt->GetRealScriptOfText(GetText(), 0);
LanguageType eLanguage;
switch ( nTextScript )
{
case i18n::ScriptType::ASIAN :
eLanguage = rAttrSet.GetCJKLanguage().GetLanguage();
break;
case i18n::ScriptType::COMPLEX :
eLanguage = rAttrSet.GetCTLLanguage().GetLanguage();
break;
default :
eLanguage = rAttrSet.GetLanguage().GetLanguage();
break;
}
Boundary aBound = g_pBreakIt->GetBreakIter()->getWordBoundary(
GetText(), 0, g_pBreakIt->GetLocale(eLanguage),
WordType::DICTIONARY_WORD, true );
nEnd = TextFrameIndex(aBound.endPos);
}
TextFrameIndex i(0);
for ( ; i < nEnd; ++i)
{
sal_Unicode const cChar = GetText()[sal_Int32(i)];
if (CH_TAB == cChar || CH_BREAK == cChar ||
CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar)
{
#ifndef NDEBUG
if (CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar)
{
std::pair<SwTextNode const*, sal_Int32> const pos(MapViewToModel(i));
assert(pos.first->GetTextAttrForCharAt(pos.second) != nullptr);
}
#endif
break;
}
}
return i;
}
/**
* If a dropcap is found the return value is true otherwise false. The
* drop cap sizes passed back by reference are font height, drop height
......@@ -510,7 +565,7 @@ SwDropPortion *SwTextFormatter::NewDropPortion( SwTextFormatInfo &rInf )
return nullptr;
TextFrameIndex nPorLen(pDropFormat->GetWholeWord() ? 0 : pDropFormat->GetChars());
nPorLen = m_pFrame->GetTextNode()->GetDropLen( nPorLen );
nPorLen = m_pFrame->GetDropLen( nPorLen );
if( !nPorLen )
{
ClearDropFormat();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment