Kaydet (Commit) 7209feef authored tarafından László Németh's avatar László Németh

tdf#122224 DOCX import: fix formula field syntax

by removing the DOCX custom number format string
which caused a syntax error message here instead
of the formula calculation.

Change-Id: Ia643e966440117871f6b4ddceab610100ac34138
Reviewed-on: https://gerrit.libreoffice.org/65945
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst 17dd2662
......@@ -295,6 +295,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf115094v2, "tdf115094v2.docx")
CPPUNIT_ASSERT(getProperty<bool>(getShapeByName("Grafik 19"), "IsLayoutInCell"));
}
DECLARE_OOXMLIMPORT_TEST(testTdf122224, "tdf122224.docx")
{
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A2"), uno::UNO_QUERY_THROW);
// This was "** Expression is faulty **", because of the unnecessary DOCX number format string
CPPUNIT_ASSERT_EQUAL(OUString("2000"), xCell->getString());
}
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -3401,6 +3401,15 @@ void DomainMapper_Impl::handleFieldFormula
uno::Reference< beans::XPropertySet > const& xFieldProperties)
{
OUString command = pContext->GetCommand().trim();
// Remove number formatting from \# to end of command
// TODO: handle custom number formatting
sal_Int32 delimPos = command.indexOf("\\#");
if (delimPos != -1)
{
command = command.replaceAt(delimPos, command.getLength() - delimPos, "").trim();
}
// command must contains = and at least another char
if (command.getLength() < 2)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment