sw/source/filter/ww8/ww8par.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 0c6756652fe9a189aca80774eb167439b5b087eb
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Dec 17 11:50:02 2024 +0000
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Dec 19 11:37:15 2024 +0100

    crashtesting: unable to import rtf export of forum-mso-en-14843.doc
    
    user field names have control chars in them and import from rtf hits
    the code added by:
    
    commit a6516c76c01b92f7d35bfb352b63af7de42b5707
    CommitDate: Wed Oct 30 14:44:09 2019 +0100
    
        writerfilter: rtftok: filter control characters
    
    so control chars are stripped out, which results in a duplicate
    user field name which throws. Filtering out at doc import time
    seems to work better, so lets do that as well.
    
    Change-Id: I463e30b223bfb5639de23c696d112eda2c27b428
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178657
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 7c2d94c6b41a71e0440953d753f6a7092626bc9c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178672
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 7d0e6c4c0233..e3ccec3caf8e 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4831,7 +4831,7 @@ void SwWW8ImplReader::ReadDocVars()
     uno::Reference< container::XNameAccess > xFieldMasterAccess = 
xFieldsSupplier->getTextFieldMasters();
     for(size_t i = 0; i < aDocVarStrings.size(); i++)
     {
-        const OUString &rName = aDocVarStrings[i];
+        const OUString sName = sw::FilterControlChars(aDocVarStrings[i]);
         uno::Any aValue;
         if (aDocValueStrings.size() > i)
         {
@@ -4843,7 +4843,7 @@ void SwWW8ImplReader::ReadDocVars()
         }
 
         uno::Reference< beans::XPropertySet > xMaster;
-        OUString sFieldMasterService("com.sun.star.text.FieldMaster.User." + 
rName);
+        OUString sFieldMasterService("com.sun.star.text.FieldMaster.User." + 
sName);
 
         // Find or create Field Master
         if (xFieldMasterAccess->hasByName(sFieldMasterService))
@@ -4853,7 +4853,7 @@ void SwWW8ImplReader::ReadDocVars()
         else
         {
             
xMaster.set(xTextFactory->createInstance(u"com.sun.star.text.FieldMaster.User"_ustr),
 uno::UNO_QUERY_THROW);
-            xMaster->setPropertyValue(u"Name"_ustr, uno::Any(rName));
+            xMaster->setPropertyValue(u"Name"_ustr, uno::Any(sName));
         }
         xMaster->setPropertyValue(u"Content"_ustr, aValue);
     }

Reply via email to