Kaydet (Commit) 92236c0f authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: fdo#46757 unsafe to pass expanded text to masking

So, use improved ModelToViewHelper to remove the hidden text right from the
start, which drops the need to mask out the hidden text and we can remove the
nNumOfMaskedChars hack

Change-Id: I3bd90598e496d4e82cd9cef4c8f9e61c180cb945
üst 27c2fe40
......@@ -1371,7 +1371,7 @@ sal_uInt16 SwScriptInfo::MaskHiddenRanges( const SwTxtNode& rNode, XubString& rT
const xub_StrLen nStt, const xub_StrLen nEnd,
const xub_Unicode cChar )
{
SAL_WARN_IF( rNode.GetTxt().Len() != rText.Len(), "sw.core", "MaskHiddenRanges, string len mismatch" );
assert(rNode.GetTxt().Len() == rText.Len());
PositionList aList;
xub_StrLen nHiddenStart;
......@@ -2194,6 +2194,9 @@ SwTwips SwTxtFrm::HangingMargin() const
void SwScriptInfo::selectHiddenTextProperty(const SwTxtNode& rNode, MultiSelection &rHiddenMulti)
{
assert((!rNode.GetTxt().Len() && rHiddenMulti.GetTotalRange().Len() == 1) ||
(rNode.GetTxt().Len() == rHiddenMulti.GetTotalRange().Len()));
const SfxPoolItem* pItem = 0;
if( SFX_ITEM_SET == rNode.GetSwAttrSet().GetItemState( RES_CHRATR_HIDDEN, sal_True, &pItem ) &&
((SvxCharHiddenItem*)pItem)->GetValue() )
......@@ -2228,6 +2231,9 @@ void SwScriptInfo::selectHiddenTextProperty(const SwTxtNode& rNode, MultiSelecti
void SwScriptInfo::selectRedLineDeleted(const SwTxtNode& rNode, MultiSelection &rHiddenMulti, bool bSelect)
{
assert((!rNode.GetTxt().Len() && rHiddenMulti.GetTotalRange().Len() == 1) ||
(rNode.GetTxt().Len() == rHiddenMulti.GetTotalRange().Len()));
const IDocumentRedlineAccess& rIDRA = *rNode.getIDocumentRedlineAccess();
if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineMode() ) )
{
......@@ -2243,6 +2249,8 @@ void SwScriptInfo::selectRedLineDeleted(const SwTxtNode& rNode, MultiSelection &
xub_StrLen nRedlStart;
xub_StrLen nRedlnEnd;
pRed->CalcStartEnd( rNode.GetIndex(), nRedlStart, nRedlnEnd );
//clip it if the redline extends past the end of the nodes text
nRedlnEnd = std::min(nRedlnEnd, rNode.GetTxt().Len());
if ( nRedlnEnd > nRedlStart )
{
Range aTmp( nRedlStart, nRedlnEnd - 1 );
......
......@@ -1860,8 +1860,8 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
return;
}
// expand text into aConversionMap for scanner
const ModelToViewHelper aConversionMap(*this);
// ConversionMap to expand fields, remove invisible and redline deleted text for scanner
const ModelToViewHelper aConversionMap(*this, EXPANDFIELDS | HIDEINVISIBLE | HIDEREDLINED);
rtl::OUString aExpandText = aConversionMap.getViewText();
// map start and end points onto the ConversionMap
......@@ -1874,12 +1874,6 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
return;
}
// make a copy of the expanded text for masking redlined/hidden text with ' '
String textCopy = aExpandText;
const xub_Unicode cChar(' ');
const sal_uInt16 nNumOfMaskedChars = lcl_MaskRedlinesAndHiddenText( *this, textCopy, nExpandBegin, nExpandEnd, cChar, false );
aExpandText = textCopy;
//do the count
// all counts exclude hidden paras and hidden+redlined within para
// definition of space/white chars in SwScanner (and BreakIter!)
......@@ -1914,7 +1908,6 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
}
nTmpChars = pBreakIt->getGraphemeCount(aExpandText, nExpandBegin, nExpandEnd);
nTmpChars -= nNumOfMaskedChars;
// no nTmpCharsExcludingSpaces adjust needed neither for blanked out MaskedChars
// nor for mid-word selection - set scanner bClip = true at creation
......
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