summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-08-03 10:54:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-08-03 10:55:43 +0100
commit92236c0fc4c8704a72f20a3c2e6f22df3c5ae333 (patch)
tree08cbbe450445e56431a8d551fa63c979ded416b9
parent27c2fe405ca55a2630176a657fb4895c5e31fcea (diff)
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
-rw-r--r--sw/source/core/text/porlay.cxx10
-rw-r--r--sw/source/core/txtnode/txtedt.cxx11
2 files changed, 11 insertions, 10 deletions
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 64e67b87d285..d03304a28b6d 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -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 );
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index daeda95e491f..66650bab0d4c 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -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