summaryrefslogtreecommitdiff
path: root/sw/source/core/text/txtdrop.cxx
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-05-24 14:26:53 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-06-08 21:51:32 +0200
commitf041a3d02b72b97a78af26c2ff0ec6ec97cc0fb2 (patch)
treeea6fea819550c073ebf6b3507406d4e09c902d43 /sw/source/core/text/txtdrop.cxx
parent224cbdfa4a626b714e58197e39aa097255e2d2f2 (diff)
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
Diffstat (limited to 'sw/source/core/text/txtdrop.cxx')
-rw-r--r--sw/source/core/text/txtdrop.cxx57
1 files changed, 56 insertions, 1 deletions
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 2f8ca9d0decf..85138e2cd35f 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -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();