sw/inc/swtypes.hxx | 2 ++ sw/qa/extras/globalfilter/globalfilter.cxx | 9 +++------ sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 3 +-- sw/qa/extras/uiwriter/uiwriter5.cxx | 14 +++++--------- sw/source/core/text/itrform2.cxx | 1 - sw/source/filter/ww8/ww8par3.cxx | 4 +--- sw/source/uibase/shells/basesh.cxx | 24 ++++++++++++++++++++++++ sw/source/uibase/shells/textfld.cxx | 4 +--- 8 files changed, 37 insertions(+), 24 deletions(-)
New commits: commit 11f5edc07feab68251bb13fde0c284ee593fe2e4 Author: Juergen Funk <juergen.funk...@cib.de> AuthorDate: Wed Jul 17 05:23:30 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Aug 23 00:25:41 2024 +0200 tdf#160163 reset placeholder in Text field when empty for all the Text field made a global define of the NonBreakSpaces mask Change-Id: I7107f941ee9008415325aefe5487555d91dbf1ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170596 Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> (cherry picked from commit e8a271dd53d605a835c493eef5c34e4fb077f16d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171747 Tested-by: allotropia jenkins <jenk...@allotropia.de> diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index b3cdfa531074..2a528403f2a4 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -179,6 +179,8 @@ constexpr bool SW_ISPRINTABLE(sal_Unicode c) { return c >= ' ' && 127 != c; } #define CHAR_WJ u'\x2060' #define CHAR_NNBSP u'\x202F' //NARROW NO-BREAK SPACE +inline constexpr OUString vEnSpaces = u"\u2002\u2002\u2002\u2002\u2002"_ustr; + // Returns the APP - CharClass instance - used for all ToUpper/ToLower/... SW_DLLPUBLIC CharClass& GetAppCharClass(); SW_DLLPUBLIC LanguageType GetAppLanguage(); diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 9d7c28b83ff8..171aeb2db8b6 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -1823,8 +1823,7 @@ void Test::testTextFormField() CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("TextFieldStart"), getProperty<OUString>(getRun(xPara, 1), "TextPortionType")); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("TextFieldSeparator"), getProperty<OUString>(getRun(xPara, 2), "TextPortionType")); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("Text"), getProperty<OUString>(getRun(xPara, 3), "TextPortionType")); - sal_Unicode vEnSpaces[5] = {8194, 8194, 8194, 8194, 8194}; - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString(vEnSpaces, 5), getRun(xPara, 3)->getString()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), vEnSpaces, getRun(xPara, 3)->getString()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("TextFieldEnd"), getProperty<OUString>(getRun(xPara, 4), "TextPortionType")); // In the second paragraph we have a set text @@ -2023,8 +2022,7 @@ void Test::testDateFormField() CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("MM/DD/YY"), sDateFormat); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("en-US"), sLang); - sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString(vEnSpaces, 5), sCurrentDate); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), vEnSpaces, sCurrentDate); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), SwNodeOffset(9), pFieldmark->GetMarkStart().GetNodeIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(5), pFieldmark->GetMarkStart().GetContentIndex()); @@ -2116,8 +2114,7 @@ void Test::testDateFormField() { CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("MM/DD/YY"), sDateFormat); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("en-US"), sLang); - sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString(vEnSpaces, 5), sCurrentDate); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), vEnSpaces, sCurrentDate); } else if (nIndex == 1) // The second has the default format { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 91f0deb4bb05..be2ec378ef6a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -1305,8 +1305,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf111964) loadAndSave("tdf111964.docx"); xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); // Unicode spaces that are not XML whitespace must not be trimmed - static constexpr OUStringLiteral sWSReference = u"\u2002\u2002\u2002\u2002\u2002"; - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[6]/w:t"_ostr, sWSReference); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[6]/w:t"_ostr, vEnSpaces); } DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark-shapetype.docx") diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 702f6d7dd30e..9343bd9061ff 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -755,8 +755,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTextFormFieldInsertion) // The text form field has the placeholder text in it uno::Reference<text::XTextRange> xPara = getParagraph(1); - sal_Unicode vEnSpaces[5] = { 8194, 8194, 8194, 8194, 8194 }; - CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), xPara->getString()); + CPPUNIT_ASSERT_EQUAL(vEnSpaces, xPara->getString()); // Undo insertion dispatchCommand(mxComponent, ".uno:Undo", {}); @@ -768,7 +767,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTextFormFieldInsertion) dispatchCommand(mxComponent, ".uno:Redo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); xPara.set(getParagraph(1)); - CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), xPara->getString()); + CPPUNIT_ASSERT_EQUAL(vEnSpaces, xPara->getString()); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testCheckboxFormFieldInsertion) @@ -1506,8 +1505,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testDateFormFieldInsertion) // The date form field has the placeholder text in it uno::Reference<text::XTextRange> xPara = getParagraph(1); - sal_Unicode vEnSpaces[5] = { 8194, 8194, 8194, 8194, 8194 }; - CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), xPara->getString()); + CPPUNIT_ASSERT_EQUAL(vEnSpaces, xPara->getString()); // Undo insertion dispatchCommand(mxComponent, ".uno:Undo", {}); @@ -1544,8 +1542,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testDateFormFieldContentOperations) // Check the default content added by insertion uno::Reference<text::XTextRange> xPara = getParagraph(1); - sal_Unicode vEnSpaces[5] = { 8194, 8194, 8194, 8194, 8194 }; - CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), pFieldmark->GetContent()); + CPPUNIT_ASSERT_EQUAL(vEnSpaces, pFieldmark->GetContent()); // Set content to empty string pFieldmark->ReplaceContent(""); @@ -1578,8 +1575,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testDateFormFieldCurrentDateHandling) // The default content is not a valid date uno::Reference<text::XTextRange> xPara = getParagraph(1); - sal_Unicode vEnSpaces[5] = { 8194, 8194, 8194, 8194, 8194 }; - CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), pFieldmark->GetContent()); + CPPUNIT_ASSERT_EQUAL(vEnSpaces, pFieldmark->GetContent()); std::pair<bool, double> aResult = pFieldmark->GetCurrentDate(); CPPUNIT_ASSERT(!aResult.first); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index d31d67f95089..ccaee98986a2 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1189,7 +1189,6 @@ namespace sw::mark { return vListEntries[nCurrentIdx]; } - static constexpr OUStringLiteral vEnSpaces = u"\u2002\u2002\u2002\u2002\u2002"; return vEnSpaces; } } diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 41b203f92496..02b13c030bbb 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -2460,9 +2460,7 @@ bool WW8FormulaListBox::Import(const uno::Reference < } else { - static constexpr OUStringLiteral aBlank = - u"\u2002\u2002\u2002\u2002\u2002"; - rSz = mrRdr.MiserableDropDownFormHack(aBlank, xPropSet); + rSz = mrRdr.MiserableDropDownFormHack(vEnSpaces, xPropSet); } return true; diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 57e7c8299546..62548c235dcb 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -293,6 +293,30 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq) //#i42732# - notify the edit window that from now on we do not use the input language rTmpEditWin.SetUseInputLanguage( false ); + + std::function<void(SwPosition* sp, const IDocumentMarkAccess* pMarksAccess)> + NoEmptyTextField = [](SwPosition* sp, const IDocumentMarkAccess* pMarksAccess) + { + // Legacy text/combo/checkbox: never return read-only when inside these form fields. + sw::mark::IFieldmark* pA = pMarksAccess->getInnerFieldmarkFor(*sp); + if (pA != nullptr) + { + bool fm = IDocumentMarkAccess::GetType(*pA) == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK; + if ((pA->GetContent().getLength() == 0) && fm) + { + pA->ReplaceContent(vEnSpaces); + }; + } + }; + + const IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); + for (SwPaM& rPaM : rSh.GetCursor()->GetRingContainer()) + { + auto [pStt, pEnd] = rPaM.StartEnd(); // SwPosition* + NoEmptyTextField(pStt, pMarksAccess); + NoEmptyTextField(pEnd, pMarksAccess); + } + } void SwBaseShell::ExecClpbrd(SfxRequest &rReq) diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 68561d8b8ded..55706be5b5c7 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -794,7 +794,6 @@ FIELD_INSERT: if(pCursorPos) { // Insert five En Space into the text field so the field has extent - static constexpr OUStringLiteral vEnSpaces = u"\u2002\u2002\u2002\u2002\u2002"; OUString aFieldResult(vEnSpaces); const SfxStringItem* pFieldResult = rReq.GetArg<SfxStringItem>(FN_PARAM_3); if (pFieldResult) @@ -912,8 +911,7 @@ FIELD_INSERT: if(pCursorPos) { // Insert five enspaces into the text field so the field has extent - sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; - bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH)); + bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, vEnSpaces); if(bSuccess) { IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();