[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sd/qa xmloff/source
sd/qa/unit/export-tests.cxx| 11 + xmloff/source/draw/shapeexport.cxx | 45 + 2 files changed, 56 insertions(+) New commits: commit 134df0c64da6392648b8d4f7020d95e337307e67 Author: Tünde Tóth AuthorDate: Fri Jan 27 09:55:40 2023 +0100 Commit: Xisco Fauli CommitDate: Thu Feb 16 08:41:46 2023 + tdf#153179 ODP export regression: fix lost shape at missing object If the object is missing, it's still possible to keep its shape by exporting its preview graphic, as before the regression. Regression from commit adc042f95d3dbd65b778260025d59283146916e5 "tdf#124333 PPTX import: fix Z-order of embedded OLE objects". See also commit 907da02bf8b33c080538731864225b3c44251328 "tdf#152436 PPTX export regression: fix lost shape at missing object" Change-Id: I614730435a857c6cdf01d4cdfc525fc452dffa29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146247 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit da725dfe07f2cf10349772d1667591c4d6a6fe8a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146990 Reviewed-by: Xisco Fauli diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 9b5c73bd43f3..029ee7267054 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -102,6 +102,7 @@ public: void testTdf112126(); void testCellProperties(); void testUserTableStyles(); +void testTdf153179(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -154,6 +155,7 @@ public: CPPUNIT_TEST(testTdf112126); CPPUNIT_TEST(testCellProperties); CPPUNIT_TEST(testUserTableStyles); +CPPUNIT_TEST(testTdf153179); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -1847,6 +1849,15 @@ void SdExportTest::testUserTableStyles() CPPUNIT_ASSERT(xTableStyle->isUserDefined()); } +void SdExportTest::testTdf153179() +{ +createSdImpressDoc("pptx/ole-emf_min.pptx"); +saveAndReload("impress8"); + +// Check number of shapes after export. +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 6e687e746ba4..c8d513d4e724 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -3011,6 +3011,51 @@ void XMLShapeExport::ImpExportOLE2Shape( mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED ); mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); } +else +{ +// tdf#153179 Export the preview graphic of the object if the object is missing. +uno::Reference xGraphic; +xPropSet->getPropertyValue("Graphic") >>= xGraphic; + +if (xGraphic.is()) +{ +OUString aMimeType; +const OUString aHref = mrExport.AddEmbeddedXGraphic(xGraphic, aMimeType); + +if (aMimeType.isEmpty()) +mrExport.GetGraphicMimeTypeFromStream(xGraphic, aMimeType); + +if (!aHref.isEmpty()) +{ +mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aHref); +mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE); +mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED); +mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD); +} + +if (!aMimeType.isEmpty() +&& GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012) +{ // ODF 1.3 OFFICE-3943 +mrExport.AddAttribute(SvtSaveOptions::ODFSVER_013 + <= GetExport().getSaneDefaultVersion() + ? XML_NAMESPACE_DRAW + : XML_NAMESPACE_LO_EXT, + "mime-type", aMimeType); +} + +SvXMLElementExport aImageElem(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, + true); + +// optional office:binary-data +mrExport.AddEmbeddedXGraphicAsBase64(xGraphic); + +ImpExportEvents(xShape); +ImpExportGluePoints(xShape); +ImpExportDescription(xShape); +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sd/qa xmloff/source
sd/qa/uitest/data/tdf153161_FlushToSave.odp |binary sd/qa/uitest/impress_tests2/tdf153161.py| 37 xmloff/source/draw/shapeexport.cxx | 12 + 3 files changed, 49 insertions(+) New commits: commit 8a53a45dfc6fb126ef4e60038df385a2b72effd9 Author: Mike Kaganski AuthorDate: Wed Jan 25 01:37:00 2023 +0300 Commit: Xisco Fauli CommitDate: Wed Jan 25 11:17:23 2023 + tdf#153161: (Ab)use a call to XTextRange::getString to flush edits Restore the call (without checking its returned value), removed in commit d194474aabd699806cb3631bc8641dd0548b8026 ("tdf#151100: xText->getString() may be empty for content needing export", 2022-09-22), side effects of which obviously allow some object's changes to get flushed and saved. Change-Id: I62f27cd056c32ad76f79a4862e2f4a0964eaadef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146106 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski (cherry picked from commit d183daea1abbd7b564d083298874dd7c40d5a5b3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146080 Reviewed-by: Michael Stahl Tested-by: Jenkins diff --git a/sd/qa/uitest/data/tdf153161_FlushToSave.odp b/sd/qa/uitest/data/tdf153161_FlushToSave.odp new file mode 100644 index ..1fd5c20c2a52 Binary files /dev/null and b/sd/qa/uitest/data/tdf153161_FlushToSave.odp differ diff --git a/sd/qa/uitest/impress_tests2/tdf153161.py b/sd/qa/uitest/impress_tests2/tdf153161.py new file mode 100644 index ..db14d7986f5b --- /dev/null +++ b/sd/qa/uitest/impress_tests2/tdf153161.py @@ -0,0 +1,37 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +class TestTdf153161(UITestCase): + +def testTdf153161(self): +url = get_url_for_data_file('tdf153161_FlushToSave.odp') + +with self.ui_test.load_file(url) as document: +oldText = document.DrawPages[0].getByIndex(1).String +self.assertTrue(oldText.startswith('在没有版本控制系统的时期')) + +xImpressDoc = self.xUITest.getTopFocusWindow() +xEditWin = xImpressDoc.getChild('impress_win') +xEditWin.executeAction('SELECT', mkPropertyValues({'OBJECT':'Unnamed Drawinglayer object 1'})) + +# Type something, getting into text editing mode (appending) automatically +xEditWin.executeAction('TYPE', mkPropertyValues({'TEXT': 'Foo Bar'})) +xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') +xToolkit.processEventsToIdle() +self.xUITest.executeCommand('.uno:Save') + +# Reload and check that the edit was saved +with self.ui_test.load_file(url) as document: +self.assertEqual(oldText + 'Foo Bar', document.DrawPages[0].getByIndex(1).String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 51ee4c894250..6e687e746ba4 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -310,6 +310,18 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY); if (xText.is()) { +try +{ +// tdf#153161: it seems that the call to XTextRange::getString flushes the changes +// for some objects, that otherwise fail to get exported correctly. Maybe at some +// point it would make sense to find a better place for more targeted flush. +xText->getString(); +} +catch (uno::RuntimeException const&) +{ +// E.g., SwXTextFrame that contains only a table will throw; this is not an error +} + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("IsEmptyPresentationObject") )
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sd/qa xmloff/source
sd/qa/unit/misc-tests.cxx | 52 + xmloff/source/table/XMLTableExport.cxx |4 +- xmloff/source/table/XMLTableImport.cxx |2 - 3 files changed, 55 insertions(+), 3 deletions(-) New commits: commit 03a84f60e94edc803bc3825b3ccb81771d4e522a Author: Maxim Monastirsky AuthorDate: Wed Dec 7 15:51:01 2022 +0200 Commit: Xisco Fauli CommitDate: Fri Dec 9 17:49:17 2022 + Fix sd encoded table style name handling Found this while looking into improving insertion of pages with tables, as SdDrawDocument::InsertBookmarkAsPage uses "_" as the rename suffix for styles with identical names but a different content. This commit fixes two issues: - For import, cell styles with encoded names couldn't be found by table styles. The reason is that styles are referenced in ODF by encoded names, but at runtime by display names. Yet we were searching the cell style family by encoded names. This was already handled for sw in insertTabletemplate(), and now do the same for sd. - For export, table template names were encoded, but then referenced by tables using their non-encoded names. This is unlike the sw code that doesn't encode them, and therefore doesn't have this problem. Looking at the schema, both table:name attribute of a table template, and table:template-name attribute of a table are of type "string", which suggests that there is indeed no need to encode those names. This aligns with the fact that table templates don't have a display-name attribute. Change-Id: Ie61b6a1c95b033404ee98f3fc40d8e82434a6a6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143839 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky (cherry picked from commit 8bd31225d79f10993d0e0727ee7d27c729874b51) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143729 Reviewed-by: Xisco Fauli diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index bc741c6ac2fe..ee03008dfb47 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -80,6 +81,7 @@ public: void testTdf131033(); void testTdf129898LayerDrawnInSlideshow(); void testTdf136956(); +void testEncodedTableStyles(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf99396); @@ -101,6 +103,7 @@ public: CPPUNIT_TEST(testTdf131033); CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow); CPPUNIT_TEST(testTdf136956); +CPPUNIT_TEST(testEncodedTableStyles); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -891,6 +894,55 @@ void SdMiscTest::testTdf136956() CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); } +void SdMiscTest::testEncodedTableStyles() +{ +// Silence unrelated failure: +// Error: element "table:table-template" is missing "first-row-start-column" attribute +skipValidation(); + +createSdDrawDoc(); + +{ +uno::Reference xStyleFamiliesSupplier(mxComponent, + uno::UNO_QUERY_THROW); +uno::Reference xTableStyleFamily( +xStyleFamiliesSupplier->getStyleFamilies()->getByName("table"), uno::UNO_QUERY_THROW); +uno::Reference xCellStyleFamily( +xStyleFamiliesSupplier->getStyleFamilies()->getByName("cell"), uno::UNO_QUERY_THROW); + +uno::Reference xTableStyle(xTableStyleFamily->createInstance(), + uno::UNO_QUERY_THROW); +uno::Reference xCellStyle(xCellStyleFamily->createInstance(), + uno::UNO_QUERY_THROW); + +uno::Reference(xTableStyleFamily, uno::UNO_QUERY_THROW) +->insertByName("table_1", uno::Any(xTableStyle)); +uno::Reference(xCellStyleFamily, uno::UNO_QUERY_THROW) +->insertByName("table-body_1", uno::Any(xCellStyle)); +uno::Reference(xTableStyle, uno::UNO_QUERY_THROW) +->replaceByName("body", uno::Any(xCellStyle)); +} + +saveAndReload("draw8"); + +{ +uno::Reference xStyleFamiliesSupplier(mxComponent, + uno::UNO_QUERY_THROW); +uno::Reference xTableStyleFamily( +xStyleFamiliesSupplier->getStyleFamilies()->getByName("table"), uno::UNO_QUERY_THROW); +// Such style used to be exported as "table_5f_1" instead. +CPPUNIT_ASSERT(xTableStyleFamily->hasByName("table_1")); + +uno::Reference xTableStyle(xTableStyleFamily->getByName("table_1"), + uno::UNO_QUERY_THROW); +uno::Reference xCellStyle(xTableStyle->getByName("body"), uno::UNO_QUERY); +