sw/qa/extras/odfexport/data/tdf160877.odt |binary sw/qa/extras/odfexport/odfexport2.cxx | 14 ++++++++++++++ sw/source/core/edit/edfcol.cxx | 21 ++++++++------------- 3 files changed, 22 insertions(+), 13 deletions(-)
New commits: commit ac2db9b4726e92153a7be2ed0fd2987a7922caf0 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Jun 5 13:55:08 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jun 11 13:06:53 2024 +0200 tdf#160877: call lcl_getRDF since graph-names can change partially revert 3750d0533e0e00941e5aef92fe5a26b6e7e27734 "sw: paragraph-sign: get graph-names only once" Change-Id: I7f99679f4a361acdd841037b782421a53350dbbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168477 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/odfexport/data/tdf160877.odt b/sw/qa/extras/odfexport/data/tdf160877.odt new file mode 100644 index 000000000000..7137eee8067a Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf160877.odt differ diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index 8ec307dd4e6f..2bce72b8ec61 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -1684,6 +1684,20 @@ CPPUNIT_TEST_FIXTURE(Test, testDeletedTableAutostylesExport) loadAndReload("deleted_table.fodt"); } +DECLARE_ODFEXPORT_TEST(testTdf160877, "tdf160877.odt") +{ + CPPUNIT_ASSERT_EQUAL(1, getPages()); + + uno::Reference<text::XText> xHeaderTextPage1 = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName("Standard"), "HeaderTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("Classification: General Business"), xHeaderTextPage1->getString()); + + // Without the fix in place, this test would have failed with + // - Expected: (Sign GB)Test + // - Actual : Test + CPPUNIT_ASSERT_EQUAL(OUString("(Sign GB)Test"), getParagraph(1)->getString()); +} + CPPUNIT_TEST_FIXTURE(Test, testMidnightRedlineDatetime) { // Given a document with a tracked change with a midnight datetime: diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index fcfa98634667..1229c0130923 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -1939,7 +1939,6 @@ void SwEditShell::RestoreMetadataFieldsAndValidateParagraphSignatures() static constexpr OUString sBlank(u""_ustr); const sfx::ClassificationKeyCreator aKeyCreator(SfxClassificationHelper::getPolicyType()); - const css::uno::Sequence<css::uno::Reference<rdf::XURI>> aGraphNames = SwRDFHelper::getGraphNames(xModel, MetaNS); while (xParagraphs->hasMoreElements()) { @@ -1949,14 +1948,11 @@ void SwEditShell::RestoreMetadataFieldsAndValidateParagraphSignatures() try { const css::uno::Reference<css::rdf::XResource> xSubject(xParagraph); - const std::map<OUString, OUString> aStatements = SwRDFHelper::getStatements(xModel, aGraphNames, xSubject); + const OUString sFieldNames = lcl_getRDF(xModel, xSubject, ParagraphClassificationFieldNamesRDFName).second; - const auto it = aStatements.find(ParagraphClassificationFieldNamesRDFName); - const OUString sFieldNames = (it != aStatements.end() ? it->second : sBlank); std::vector<svx::ClassificationResult> aResults; if (!sFieldNames.isEmpty()) { - assert(it != aStatements.end() && "can only be non-empty if it was valid"); // Order the fields sal_Int32 nIndex = 0; do @@ -1965,10 +1961,9 @@ void SwEditShell::RestoreMetadataFieldsAndValidateParagraphSignatures() if (sCurFieldName.isEmpty()) break; - const auto it2 = aStatements.find(sCurFieldName); - bool bStatementFound = it2 != aStatements.end(); - const OUString sName = bStatementFound ? it->first : sBlank; - const OUString sValue = bStatementFound ? it->second : sBlank; + const std::pair<OUString, OUString> fieldNameValue = lcl_getRDF(xModel, xSubject, sCurFieldName); + const OUString sName = fieldNameValue.first; + const OUString sValue = fieldNameValue.second; if (aKeyCreator.isMarkingTextKey(sName)) { @@ -1976,14 +1971,14 @@ void SwEditShell::RestoreMetadataFieldsAndValidateParagraphSignatures() } else if (aKeyCreator.isCategoryNameKey(sName)) { - const auto it3 = aStatements.find(ParagraphClassificationAbbrRDFName); - const OUString sAbbreviatedName = (it3 != aStatements.end() && !it3->second.isEmpty() ? it3->second : sValue); + const std::pair<OUString, OUString> pairAbbr = lcl_getRDF(xModel, xSubject, ParagraphClassificationAbbrRDFName); + const OUString sAbbreviatedName = (!pairAbbr.second.isEmpty() ? pairAbbr.second : sValue); aResults.emplace_back(svx::ClassificationType::CATEGORY, sValue, sAbbreviatedName, sBlank); } else if (aKeyCreator.isCategoryIdentifierKey(sName)) { - const auto it3 = aStatements.find(ParagraphClassificationAbbrRDFName); - const OUString sAbbreviatedName = (it3 != aStatements.end() && !it3->second.isEmpty() ? it3->second : sValue); + const std::pair<OUString, OUString> pairAbbr = lcl_getRDF(xModel, xSubject, ParagraphClassificationAbbrRDFName); + const OUString sAbbreviatedName = (!pairAbbr.second.isEmpty() ? pairAbbr.second : sValue); aResults.emplace_back(svx::ClassificationType::CATEGORY, sBlank, sAbbreviatedName, sValue); } else if (aKeyCreator.isMarkingKey(sName))