diff options
-rw-r--r-- | sw/qa/core/data/ww5/pass/ofz18526-1.doc | bin | 0 -> 781 bytes | |||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 54 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 6 |
4 files changed, 48 insertions, 14 deletions
diff --git a/sw/qa/core/data/ww5/pass/ofz18526-1.doc b/sw/qa/core/data/ww5/pass/ofz18526-1.doc Binary files differnew file mode 100644 index 000000000000..e651650f9a26 --- /dev/null +++ b/sw/qa/core/data/ww5/pass/ofz18526-1.doc diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 98569b059863..efb4b2942920 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -115,6 +115,8 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> #include <com/sun/star/document/IndexedPropertyValues.hpp> + +#include <svl/lngmisc.hxx> #include <svl/itemiter.hxx> #include <comphelper/processfactory.hxx> @@ -3391,13 +3393,37 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString } } +namespace sw { + +auto FilterControlChars(OUString const& rString) -> OUString +{ + OUStringBuffer buf(rString.getLength()); + for (sal_Int32 i = 0; i < rString.getLength(); ++i) + { + sal_Unicode const ch(rString[i]); + if (!linguistic::IsControlChar(ch) || ch == '\r' || ch == '\n' || ch == '\t') + { + buf.append(ch); + } + else + { + SAL_INFO("sw.ww8", "filtering control character"); + } + } + return buf.makeStringAndClear(); +} + +} // namespace sw + void SwWW8ImplReader::simpleAddTextToParagraph(const OUString& rAddString) { - if (rAddString.isEmpty()) + OUString const addString(sw::FilterControlChars(rAddString)); + + if (addString.isEmpty()) return; #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("sw.ww8", "<addTextToParagraph>" << rAddString << "</addTextToParagraph>"); + SAL_INFO("sw.ww8", "<addTextToParagraph>" << addString << "</addTextToParagraph>"); #endif const SwContentNode *pCntNd = m_pPaM->GetContentNode(); @@ -3411,21 +3437,21 @@ void SwWW8ImplReader::simpleAddTextToParagraph(const OUString& rAddString) const sal_Int32 nCharsLeft = SAL_MAX_INT32 - pNd->GetText().getLength(); if (nCharsLeft > 0) { - if (rAddString.getLength() <= nCharsLeft) + if (addString.getLength() <= nCharsLeft) { - m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, rAddString); + m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString); } else { - m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, rAddString.copy(0, nCharsLeft)); + m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString.copy(0, nCharsLeft)); AppendTextNode(*m_pPaM->GetPoint()); - m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, rAddString.copy(nCharsLeft)); + m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString.copy(nCharsLeft)); } } else { AppendTextNode(*m_pPaM->GetPoint()); - m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, rAddString); + m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, addString); } m_bReadTable = false; @@ -3451,13 +3477,17 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd, nRequested = nMaxPossible; } - for (WW8_CP nCh = 0; nCh < nRequested; ++nCh) + if (!linguistic::IsControlChar(m_cSymbol) + || m_cSymbol == '\r' || m_cSymbol == '\n' || m_cSymbol == '\t') { - m_rDoc.getIDocumentContentOperations().InsertString( *m_pPaM, OUString(m_cSymbol) ); + for (WW8_CP nCh = 0; nCh < nRequested; ++nCh) + { + m_rDoc.getIDocumentContentOperations().InsertString(*m_pPaM, OUString(m_cSymbol)); + } + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_CHRATR_FONT); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_CHRATR_CJK_FONT); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_CHRATR_CTL_FONT); } - m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_FONT ); - m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_CJK_FONT ); - m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_CTL_FONT ); } m_pStrm->SeekRel(nRequested); rPos = nEnd; // Ignore until attribute end diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index ee5a8b68b795..676745d07078 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -550,6 +550,8 @@ namespace sw sal_Int32 GetPtContent() { return mnPtContent; }; }; } + + auto FilterControlChars(OUString const& rString) -> OUString; } class WW8FieldEntry diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 1d2430db8d69..963364531d19 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -34,6 +34,7 @@ #include <svl/urihelper.hxx> #include <svl/zforlist.hxx> #include <svl/zformat.hxx> +#include <svl/lngmisc.hxx> #include <sfx2/linkmgr.hxx> #include <rtl/character.hxx> #include <unotools/charclass.hxx> @@ -1906,7 +1907,8 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, OUString& rStr ) if( aQ.isEmpty() ) return eF_ResT::TAGIGN; // -> no 0-char in text - if (sal_Unicode cChar = static_cast<sal_Unicode>(aQ.toInt32())) + sal_Unicode const cChar = static_cast<sal_Unicode>(aQ.toInt32()); + if (!linguistic::IsControlChar(cChar) || cChar == '\r' || cChar == '\n' || cChar == '\t') { if (!aName.isEmpty()) // Font Name set ? { @@ -2686,11 +2688,11 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam) if ((nBegin != -1) && (nEnd != -1) && (nBegin < nEnd)) { sText = sPart.copy(nBegin+1,nEnd-nBegin-1); + sText = sw::FilterControlChars(sText); } } } } - } break; } |