[PATCH] fdo#37584: Make a real copy of the text where to count words

Cédric Bosdonnat cedric.bosdonnat.ooo at free.fr
Wed Jun 8 01:06:23 PDT 2011


Const-casting a reference doesn't create a copy of it and then the
spaces replacement made by the WordCount was also made on the actual
text node. Use String::Copy() to actually copy the text and safely
operate on it.
---
 sw/source/core/txtnode/txtedt.cxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index d4c02b6..08d0c6b 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1814,7 +1814,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
     }
 
     // make a copy of the text
-    String& rTextCopy = const_cast<String&>(m_Text);
+    String rTextCopy = m_Text.Copy( );
 
     // mask out the redlined and hidden text with ' '
     const xub_Unicode cChar(' ');
-- 
1.7.3.4


--=-MbrFdN38wdzHexSYbuQa--



More information about the LibreOffice mailing list