This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit a10e448eee6a08cf62d63da05d9da894588cfa72 Author: Damjan Jovanovic <[email protected]> AuthorDate: Tue Nov 18 08:00:48 2025 +0200 When converting the .sxc table:formula XML attribute to ODF, use the "of" namespace instead of "ooow". Also add a unit test for saving and reloading formulas to .sxc files. Patch by: me Fixes: https://bz.apache.org/ooo/show_bug.cgi?id=128625 importing .sxc corrupts formulas (cherry picked from commit 371410417827e07a8f8596550830c16c641bed7c) --- main/xmloff/source/transform/OOo2Oasis.cxx | 2 +- .../fvt/uno/sc/formula/TestFormulaRoundTrip.java | 53 ++++++++++++++++------ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/main/xmloff/source/transform/OOo2Oasis.cxx b/main/xmloff/source/transform/OOo2Oasis.cxx index 126535becb..90be61fb8f 100644 --- a/main/xmloff/source/transform/OOo2Oasis.cxx +++ b/main/xmloff/source/transform/OOo2Oasis.cxx @@ -887,7 +887,7 @@ static XMLTransformerActionInit aTableValueTypeActionTable[] = XML_NAMESPACE_OFFICE, XML_STRING_VALUE ), ENTRY0( TABLE, STYLE_NAME, XML_ATACTION_ENCODE_STYLE_NAME_REF ), ENTRY1( TABLE, FORMULA, XML_ATACTION_ADD_APP_NAMESPACE_PREFIX, - XML_NAMESPACE_OOOW ), + XML_NAMESPACE_OF ), ENTRY1Q( TABLE, VALIDATION_NAME, XML_ATACTION_RENAME, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME ), ENTRY0( TABLE, TOKEN_INVALID, XML_ATACTION_EOT ) diff --git a/test/testuno/source/fvt/uno/sc/formula/TestFormulaRoundTrip.java b/test/testuno/source/fvt/uno/sc/formula/TestFormulaRoundTrip.java index a1c2894732..8750a6ea72 100644 --- a/test/testuno/source/fvt/uno/sc/formula/TestFormulaRoundTrip.java +++ b/test/testuno/source/fvt/uno/sc/formula/TestFormulaRoundTrip.java @@ -68,34 +68,59 @@ public class TestFormulaRoundTrip { unoApp.close(); } - @Test - public void testMSExcel2003XMLFormulaRoundTrip() throws Exception { + private XSpreadsheet generateTestDocument(XSpreadsheetDocument scDocument) throws Exception { XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument); SCUtil.setTextToCell(sheet, 0, 0, "Hello world"); SCUtil.setFormulaToCell(sheet, 0, 1, "=A1"); + return sheet; + } + + @Test + public void testMSExcel2003XMLFormulaRoundTrip() throws Exception { + XSpreadsheet sheet = generateTestDocument(scDocument); String formulaValue = SCUtil.getTextFromCell(sheet, 0, 1); assertEquals("Hello world", formulaValue); + String path = "output/sc/temp.xml"; + saveFormatTo("MS Excel 2003 XML", Testspace.getUrl(path)); + unoApp.closeDocument(scComponent); - String storeUrl = Testspace.getUrl("output/sc/temp.xml"); - PropertyValue[] storeProps = new PropertyValue[2]; - storeProps[0] = new PropertyValue(); - storeProps[0].Name = "FilterName"; - storeProps[0].Value = "MS Excel 2003 XML"; - storeProps[1] = new PropertyValue(); - storeProps[1].Name = "Overwrite"; - storeProps[1].Value = new Boolean(true); - XStorable scStorable = - (XStorable) UnoRuntime.queryInterface(XStorable.class, scComponent); - scStorable.storeAsURL(storeUrl, storeProps); + scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface( + XSpreadsheetDocument.class, unoApp.loadDocument(Testspace.getPath(path))); + sheet = SCUtil.getCurrentSheet(scDocument); + String formulaValue2 = SCUtil.getTextFromCell(sheet, 0, 1); + assertEquals("Hello world", formulaValue2); + String formula2 = SCUtil.getFormulaFromCell(sheet, 0, 1); + assertEquals("=A1", formula2); + } + @Test + public void testStarOfficeXMLFormulaRoundTrip() throws Exception { + XSpreadsheet sheet = generateTestDocument(scDocument); + String formulaValue = SCUtil.getTextFromCell(sheet, 0, 1); + assertEquals("Hello world", formulaValue); + String path = "output/sc/temp.sxc"; + saveFormatTo("StarOffice XML (Calc)", Testspace.getUrl(path)); unoApp.closeDocument(scComponent); scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface( - XSpreadsheetDocument.class, unoApp.loadDocument(Testspace.getPath("output/sc/temp.xml"))); + XSpreadsheetDocument.class, unoApp.loadDocument(Testspace.getPath(path))); sheet = SCUtil.getCurrentSheet(scDocument); String formulaValue2 = SCUtil.getTextFromCell(sheet, 0, 1); assertEquals("Hello world", formulaValue2); String formula2 = SCUtil.getFormulaFromCell(sheet, 0, 1); assertEquals("=A1", formula2); } + + private void saveFormatTo(String filterName, String storeUrl) throws Exception { + PropertyValue[] storeProps = new PropertyValue[2]; + storeProps[0] = new PropertyValue(); + storeProps[0].Name = "FilterName"; + storeProps[0].Value = filterName; + storeProps[1] = new PropertyValue(); + storeProps[1].Name = "Overwrite"; + storeProps[1].Value = new Boolean(true); + XStorable scStorable = + (XStorable) UnoRuntime.queryInterface(XStorable.class, scComponent); + scStorable.storeAsURL(storeUrl, storeProps); + } }
