diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-01-31 00:13:02 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-02-01 05:00:07 +0100 |
commit | 1276daee3d0d4f30ee8844b6df55d72e0b54093f (patch) | |
tree | 6ee3eb8f1b77d80123dc3b7c92f3d187a4288f0e /sc/qa | |
parent | 2cac2ee38445c19c9281f54c2b961bbc9149cc00 (diff) |
Currency pop-up: move getDocumentCurrencies to cxx, extend test
Test now checks that multiple cells with the same currency still
result in only one entry returned by getDocumentCurrencies.
Change-Id: I34b0fd3b117ce01b3fd462f684d0927dd53f796d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162788
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index be7f19f1d2b6..efd836c89190 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6865,7 +6865,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDocumentModelAccessor_getDocumentCurrencies) { m_pDoc->InsertTab(0, "Sheet1"); - // Check Document Currencies + // Check document currencies - expect 0 auto pAccessor = m_xDocShell->GetDocumentModelAccessor(); CPPUNIT_ASSERT(pAccessor); CPPUNIT_ASSERT_EQUAL(size_t(0), pAccessor->getDocumentCurrencies().size()); @@ -6891,13 +6891,45 @@ CPPUNIT_TEST_FIXTURE(Test, testDocumentModelAccessor_getDocumentCurrencies) CPPUNIT_ASSERT_EQUAL(u"2,00€"_ustr, m_pDoc->GetString(ScAddress(0, 0, 0))); } - // Check Document Currencies Again + // Check document currencies again auto aCurrencyIDs = pAccessor->getDocumentCurrencies(); CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size()); CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage); CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension); CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol); + + // Set the same currency to 2 more cells + { + m_pDoc->SetValue(ScAddress(1, 1, 0), 5.0); + m_pDoc->SetValue(ScAddress(2, 2, 0), 7.0); + + OUString aCode = u"#.##0,00[$€-424]"_ustr; + + sal_Int32 nCheckPos; + SvNumFormatType eType; + sal_uInt32 nFormat; + + m_pDoc->GetFormatTable()->PutEntry(aCode, nCheckPos, eType, nFormat, LANGUAGE_SLOVENIAN); + CPPUNIT_ASSERT_EQUAL(SvNumFormatType::CURRENCY, eType); + + ScPatternAttr aNewAttrs(m_pDoc->getCellAttributeHelper()); + SfxItemSet& rSet = aNewAttrs.GetItemSet(); + rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat)); + m_pDoc->ApplyPattern(1, 1, 0, aNewAttrs); // B2. + m_pDoc->ApplyPattern(2, 2, 0, aNewAttrs); // C3. + + CPPUNIT_ASSERT_EQUAL(u"5,00€"_ustr, m_pDoc->GetString(ScAddress(1, 1, 0))); + CPPUNIT_ASSERT_EQUAL(u"7,00€"_ustr, m_pDoc->GetString(ScAddress(2, 2, 0))); + } + + // Check document currencies again - should be 1 entry only + aCurrencyIDs = pAccessor->getDocumentCurrencies(); + CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size()); + + CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage); + CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension); + CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol); } |