diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-14 20:25:26 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-15 03:15:19 +0200 |
commit | 82fc1fdebc622507d4220fefa72b9b4bda0f55d8 (patch) | |
tree | 8b4a78e284a5425c925c495e63a10cbd4ef1e317 | |
parent | 213a644a121a1b4145f5abe35c9b2f10ea00ac89 (diff) |
tdf#91801: also restore command (formula) string on validating value
SwUserFieldType::GetValue calls SwCalc::Calculate on this object, which
resets own m_sCommand to the variable name being verified. Restore it
after calculations, like other values.
Change-Id: I1582fa2d356064e6e951063fa8479cd615a6591a
Reviewed-on: https://gerrit.libreoffice.org/55789
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rwxr-xr-x | sw/qa/extras/uiwriter/data/tdf91801.fodt | 21 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/bastyp/calc.cxx | 2 |
3 files changed, 34 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf91801.fodt b/sw/qa/extras/uiwriter/data/tdf91801.fodt new file mode 100755 index 000000000000..4d5486f71bbb --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf91801.fodt @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:ooow="http://openoffice.org/2004/writer" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:user-field-decls> + <text:user-field-decl office:value-type="float" office:value="111" text:name="aaa"/> + <text:user-field-decl office:value-type="float" office:value="222" text:name="bbb"/> + </text:user-field-decls> + <table:table table:name="Table1"> + <table:table-column/> + <table:table-row> + <table:table-cell table:formula="ooow:aaa+bbb*2" office:value-type="float" office:value="111"> + <text:p>111</text:p> + </table:table-cell> + </table:table-row> + </table:table> + <text:p/> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 924ff04f6911..d2086048ad94 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -342,6 +342,7 @@ public: void testHtmlCopyImages(); void testTdf116789(); void testTdf117225(); + void testTdf91801(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -535,6 +536,7 @@ public: CPPUNIT_TEST(testHtmlCopyImages); CPPUNIT_TEST(testTdf116789); CPPUNIT_TEST(testTdf117225); + CPPUNIT_TEST(testTdf91801); CPPUNIT_TEST_SUITE_END(); private: @@ -6232,6 +6234,15 @@ void SwUiWriterTest::testTdf117225() CPPUNIT_ASSERT_EQUAL(nExpected, nActual); } +void SwUiWriterTest::testTdf91801() +{ + // Tests calculation with several user field variables without prior user fields + createDoc("tdf91801.fodt"); + uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); + uno::Reference<table::XCell> xCell(xTable->getCellByName("A1")); + CPPUNIT_ASSERT_EQUAL(555.0, xCell->getValue()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 30a1ca83a5ab..1e407f8a0225 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -449,6 +449,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns ) sal_Int32 nCommandPos = m_nCommandPos; SwCalcOper eCurrOper = m_eCurrOper; SwCalcOper eCurrListOper = m_eCurrListOper; + OUString sCurrCommand = m_sCommand; pFnd->nValue.PutDouble( pUField->GetValue( *this ) ); @@ -459,6 +460,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns ) m_nCommandPos = nCommandPos; m_eCurrOper = eCurrOper; m_eCurrListOper = eCurrListOper; + m_sCommand = sCurrCommand; } else { |