diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2024-02-02 20:10:24 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-02-06 20:34:59 +0100 |
commit | a2a85724b3260713b1938a934fd73211d6e1d99d (patch) | |
tree | 6daf8038c482076df16bab644493e74658073aa3 /sw/qa | |
parent | 536096309f78de9eabac38ffb9c04bff95ea7d91 (diff) |
tdf#123968 sw: fix assert on importing ooo62823-1.sxw
svl/source/items/itemset.cxx:662: const SfxPoolItem* implCreateItemEntry(SfxItemPool&, const SfxPoolItem*, bool): Assertion `pSource->Which() == nWhich && "ITEM: Clone of Item did NOT copy/set WhichID (!)"' failed.
XMLVariableInputFieldImportContext::PrepareField() first sets "Input"
and then "SubType" property.
Apparently i missed that *both* of these are mutable in the API, and
both together determine whether the field is a RES_TXTATR_INPUTFIELD or
RES_TXTATR_FIELD.
So call SwXTextField::TransmuteLeadToInputField() also when the
"SubType" is set, and adapt it to toggling 2 different things.
Hmm... actually this will change these fields to be inline editable
after ODF import, which was the intention all along.
It turns out that there is even a unit test testTdf123968 for this; it
works in the usual case, but in this case the input field is in a
header, so in styles.xml, and the styles.xml is imported before
content.xml and does not contain the variable-decls element, so the
variable field type has the GSE_EXPR subtype (default?), and setting the
"Input" property doesn't transmute it.
(regression from commit 742baabbe4d077e1ba913a7989300908f4637ac7)
Change-Id: Ib5757cda32287e51651f05f5b19e82d7be0431e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162941
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 99055ae98ef1fe67b8db4a8c3167a8acaeaac02f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163012
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/odfimport/data/tdf123968.odt | bin | 9591 -> 8904 bytes | |||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 12 |
2 files changed, 12 insertions, 0 deletions
diff --git a/sw/qa/extras/odfimport/data/tdf123968.odt b/sw/qa/extras/odfimport/data/tdf123968.odt Binary files differindex 1c081619ea30..cd1ec8a3859a 100644 --- a/sw/qa/extras/odfimport/data/tdf123968.odt +++ b/sw/qa/extras/odfimport/data/tdf123968.odt diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 168de4fb6db7..70c6452e3d9f 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -1167,9 +1167,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf123968) SwTextNode& rStart = dynamic_cast<SwTextNode&>(pShellCursor->Start()->GetNode()); // The field is now editable like any text, thus the field content "New value" shows up for the cursor. + // This field's variable is declared as string and used as string - typical. CPPUNIT_ASSERT_EQUAL(OUString("inputfield: " + OUStringChar(CH_TXT_ATR_INPUTFIELDSTART) + "New value" + OUStringChar(CH_TXT_ATR_INPUTFIELDEND)), rStart.GetText()); + + // This field's variable is declared as float and used as string - not + // typical; this can easily happen if the input field is in a header/footer, + // because only content.xml contains the variable-decls, styles.xml is + // imported before content.xml, and apparently the default variable type is + // numeric. + SwTextNode& rEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode()); + CPPUNIT_ASSERT_EQUAL(OUString("inputfield: " + OUStringChar(CH_TXT_ATR_INPUTFIELDSTART) + + "String input for num variable" + OUStringChar(CH_TXT_ATR_INPUTFIELDEND)), + rEnd.GetText()); + } CPPUNIT_TEST_FIXTURE(Test, testTdf133459) |