From 62cc2217217650d23c72e4646ccd793f76722d94 Mon Sep 17 00:00:00 2001 From: Gökay Şatır Date: Fri, 1 Sep 2023 09:49:53 +0300 Subject: Added parent / child relationship to comments. Adding parent name of a comment into odf file when there is a parent. Also includes: Added test case to comment property test. Change-Id: I033f6574b4875fcb76b16c8b5b9d9f7d55b52cbe Also includes: Add parent / child relations to replied comments. Change-Id: Ia7d95c4e6020b501798a89cbdcae64dc5691437c Change-Id: I08b5ab6eb11adcafcbf3559896d79d41b449b26a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156824 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- xmloff/inc/txtfldi.hxx | 1 + xmloff/qa/unit/text.cxx | 8 +++++++- xmloff/source/core/xmltoken.cxx | 1 + xmloff/source/text/txtflde.cxx | 9 +++++++++ xmloff/source/text/txtfldi.cxx | 6 ++++++ xmloff/source/token/tokens.txt | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) (limited to 'xmloff') diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index 243feb630fc8..0a15329c31ec 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -961,6 +961,7 @@ class XMLAnnotationImportContext final : public XMLTextFieldImportContext OUStringBuffer aAuthorBuffer; OUStringBuffer aInitialsBuffer; OUString aName; + OUString aParentName; OUStringBuffer aTextBuffer; OUStringBuffer aDateBuffer; OUString aResolved; diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 8c500dccce24..47bd6d969fb5 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -50,7 +50,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMailMergeInEditeng) loadFromURL(u"mail-merge-editeng.odt"); } -CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentResolved) +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentProperty) { mxComponent = loadFromDesktop("private:factory/swriter"); uno::Sequence aCommentProps = comphelper::InitPropertySequence({ @@ -67,6 +67,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentResolved) uno::Reference xField(xPortion->getPropertyValue("TextField"), uno::UNO_QUERY); xField->setPropertyValue("Resolved", uno::Any(true)); + xField->setPropertyValue("ParentName", uno::Any(OUString("parent_comment_name"))); saveAndReload("writer8"); xTextDocument.set(mxComponent, uno::UNO_QUERY); @@ -78,6 +79,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentResolved) xField.set(xPortion->getPropertyValue("TextField"), uno::UNO_QUERY); bool bResolved = false; xField->getPropertyValue("Resolved") >>= bResolved; + OUString parentName; + xField->getPropertyValue("ParentName") >>= parentName; + CPPUNIT_ASSERT_EQUAL( + OUString("parent_comment_name"), + parentName); // Check if the parent comment name is written and read correctly. // Without the accompanying fix in place, this test would have failed, as the resolved state was // not saved for non-range comments. CPPUNIT_ASSERT(bResolved); diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index eac87c5e2c63..38ee9bb853c3 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -1519,6 +1519,7 @@ namespace xmloff::token { TOKEN( "paragraph-start-margin", XML_PARAGRAPH_START_MARGIN ), TOKEN( "parallel", XML_PARALLEL ), TOKEN( "param", XML_PARAM ), + TOKEN( "parent-name", XML_PARENT_NAME ), TOKEN( "parent-style-name", XML_PARENT_STYLE_NAME ), TOKEN( "parse-sql-statement", XML_PARSE_SQL_STATEMENT ), TOKEN( "parsed", XML_PARSED ), diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index a6a0936423d8..271a7d41285d 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -342,6 +342,7 @@ constexpr OUStringLiteral gsPropertyItems(u"Items"); constexpr OUStringLiteral gsPropertyLevel(u"Level"); constexpr OUStringLiteral gsPropertyMeasureKind(u"Kind"); constexpr OUStringLiteral gsPropertyName(u"Name"); +constexpr OUStringLiteral gsPropertyParentName(u"ParentName"); constexpr OUStringLiteral gsPropertyNumberFormat(u"NumberFormat"); constexpr OUStringLiteral gsPropertyNumberingSeparator(u"NumberingSeparator"); constexpr OUStringLiteral gsPropertyNumberingType(u"NumberingType"); @@ -1728,6 +1729,14 @@ void XMLTextFieldExport::ExportFieldHelper( { GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, aName); } + + OUString aParentName; + rPropSet->getPropertyValue(gsPropertyParentName) >>= aParentName; + if (!aParentName.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_PARENT_NAME, aParentName); + } + SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion(); if (eVersion & SvtSaveOptions::ODFSVER_EXTENDED) { diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index af89551343c8..dc6fb6646857 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -106,6 +106,7 @@ constexpr OUStringLiteral sAPI_content = u"Content"; constexpr OUStringLiteral sAPI_author = u"Author"; constexpr OUStringLiteral sAPI_hint = u"Hint"; constexpr OUStringLiteral sAPI_name = u"Name"; +constexpr OUStringLiteral sAPI_parent_name = u"ParentName"; constexpr OUStringLiteral sAPI_sub_type = u"SubType"; constexpr OUStringLiteral sAPI_date_time_value = u"DateTimeValue"; constexpr OUStringLiteral sAPI_number_format = u"NumberFormat"; @@ -3152,6 +3153,8 @@ void XMLAnnotationImportContext::ProcessAttribute( aName = OUString::fromUtf8(sAttrValue); else if (nAttrToken == XML_ELEMENT(LO_EXT, XML_RESOLVED)) aResolved = OUString::fromUtf8(sAttrValue); + else if (nAttrToken == XML_ELEMENT(LO_EXT, XML_PARENT_NAME)) + aParentName = OUString::fromUtf8(sAttrValue); else XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue); } @@ -3340,6 +3343,9 @@ void XMLAnnotationImportContext::PrepareField( if (!aName.isEmpty()) xPropertySet->setPropertyValue(sAPI_name, Any(aName)); + + if (!aParentName.isEmpty()) + xPropertySet->setPropertyValue(sAPI_parent_name, Any(aParentName)); } diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 8bc75993eadf..58f8ff8e8c4e 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -1419,6 +1419,7 @@ paragraph-end-margin paragraph-start-margin parallel param +parent-name parent-style-name parse-sql-statement parsed -- cgit