sw/qa/extras/ooxmlexport/data/formula-result.fodt | 36 ++++++++++++++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 24 ++++++++++++++ sw/source/uibase/uiview/view.cxx | 5 +-- 3 files changed, 62 insertions(+), 3 deletions(-)
New commits: commit b595dff0bf2fcdb63586e36d007408cf23359a65 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Apr 11 16:50:43 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Apr 11 18:19:12 2025 +0200 tdf#166125 Revert "tdf#158532 sw: fix toolbar buttons remain disabled ... ... after pasting an image" This reverts commit a586ce188086ff27b08b8a4de4672c07ddf8ed7c (tdf#158532 sw: fix toolbar buttons remain disabled after pasting an image, 2024-01-03). The original problem is not reproducible anymore and it causes tdf#166125, so best to revert it. Change-Id: I7bee45da2835106915d4f9f7e6410725d6c854d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184054 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/formula-result.fodt b/sw/qa/extras/ooxmlexport/data/formula-result.fodt new file mode 100644 index 000000000000..b80074592da2 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/formula-result.fodt @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:ooow="http://openoffice.org/2004/writer" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:styles> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:default-style style:family="paragraph"> + <style:text-properties fo:language="en" fo:country="US"/> + </style:default-style> + </office:styles> + <office:body> + <office:text> + <table:table> + <table:table-column/> + <table:table-row> + <table:table-cell office:value-type="string"> + <text:p>1</text:p> + </table:table-cell> + </table:table-row> + <table:table-row> + <table:table-cell office:value-type="string"> + <text:p>2</text:p> + </table:table-cell> + </table:table-row> + <table:table-row> + <table:table-cell office:value-type="string"> + <text:p><text:table-formula text:formula="ooow: <A1>+<A2>" style:data-style-name="N0">3</text:table-formula></text:p> + </table:table-cell> + </table:table-row> + <table:table-row> + <table:table-cell office:value-type="string"> + <text:p><text:table-formula text:formula="ooow:SUM(<A1:A3>)" style:data-style-name="N0">6</text:table-formula></text:p> + </table:table-cell> + </table:table-row> + </table:table> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx index 3d482f88ac1e..f6db65e8ca1e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -13,6 +13,7 @@ #include <comphelper/configuration.hxx> #include <comphelper/sequenceashashmap.hxx> +#include <comphelper/propertyvalue.hxx> #include <officecfg/Office/Common.hxx> #include <pam.hxx> @@ -247,6 +248,29 @@ CPPUNIT_TEST_FIXTURE(Test, testAnnotationRef) assertXPath(pXmlComments, "//w:comments/w:comment[1]/w:p[1]/w:r[1]/w:annotationRef"); } +CPPUNIT_TEST_FIXTURE(Test, testBadFormulaResult) +{ + // Given a loaded by not laid out document: + uno::Sequence<beans::PropertyValue> aFilterOptions = { + comphelper::makePropertyValue("Hidden", true), + }; + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(u"/sw/qa/extras/ooxmlexport/data/") + + "formula-result.fodt", + "com.sun.star.text.TextDocument", aFilterOptions); + + // When saving to DOCX: + save(mpFilter); + + // Then make sure that the field result in the last row's last run is not empty: + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 6 + // - Actual : 0 + // i.e. the SUM() field evaluated to an empty result. + assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[4]/w:t", u"6"); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index c5bec7511103..1af36d3bdf3a 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -302,13 +302,12 @@ void SwView::SelectShell() // Determine if a different fly frame was selected. bool bUpdateFly = false; const SwFrameFormat* pCurFlyFormat = nullptr; - if (m_pWrtShell->IsSelFrameMode()) + if (m_nSelectionType & SelectionType::Ole || m_nSelectionType & SelectionType::Graphic) { pCurFlyFormat = m_pWrtShell->GetFlyFrameFormat(); } - if (pCurFlyFormat && m_pLastFlyFormat && pCurFlyFormat != m_pLastFlyFormat) + if (pCurFlyFormat && pCurFlyFormat != m_pLastFlyFormat) { - // Only do an explicit update when switching between flys. bUpdateFly = true; } m_pLastFlyFormat = pCurFlyFormat;