diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-11-15 09:53:20 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-15 11:34:49 +0100 |
commit | 6870c0c3385bf5d19e9c80bf973fca255ae38c08 (patch) | |
tree | 9abcb20a38b24b620b3380c053ae0aa47bc7172e /sw/qa/uibase | |
parent | 1caf3f2554ffac3624d43defb4252a5b40945bbc (diff) |
sw: add new FieldCode parameter for the .uno:TextFormField command
The field code/command is the input of the field expand.
Also allow setting a field result, given that the entire point of
"unhandled" fieldmarks is that Writer itself doesn't know how to compute
the field result / expanded string.
Note that a field result can be a multi-paragraph and formatted content,
so far we only allow single-paragraph plain text.
Change-Id: I1739cb985d1d4ed8e45068f15a4e0d82fd118d83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142726
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/uibase')
-rw-r--r-- | sw/qa/uibase/shells/shells.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index c107913e6469..803c41657e89 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -277,8 +277,12 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testInsertTextFormField) SwDoc* pDoc = getSwDoc(); // When inserting an ODF_UNHANDLED fieldmark: + OUString aExpectedCommand("ADDIN ZOTERO_BIBL foo bar"); + OUString aExpectedResult("(Abrikosov, n.d.)"); uno::Sequence<css::beans::PropertyValue> aArgs = { comphelper::makePropertyValue("FieldType", uno::Any(OUString(ODF_UNHANDLED))), + comphelper::makePropertyValue("FieldCommand", uno::Any(aExpectedCommand)), + comphelper::makePropertyValue("FieldResult", uno::Any(aExpectedResult)), }; dispatchCommand(mxComponent, ".uno:TextFormField", aArgs); @@ -294,6 +298,15 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testInsertTextFormField) // - Actual : vnd.oasis.opendocument.field.FORMTEXT // i.e. the custom type parameter was ignored. CPPUNIT_ASSERT_EQUAL(OUString(ODF_UNHANDLED), pFieldmark->GetFieldname()); + + auto it = pFieldmark->GetParameters()->find(ODF_CODE_PARAM); + CPPUNIT_ASSERT(it != pFieldmark->GetParameters()->end()); + OUString aActualCommand; + it->second >>= aActualCommand; + CPPUNIT_ASSERT_EQUAL(aExpectedCommand, aActualCommand); + + OUString aActualResult = pFieldmark->GetContent(); + CPPUNIT_ASSERT_EQUAL(aExpectedResult, aActualResult); } CPPUNIT_PLUGIN_IMPLEMENT(); |