From a01047f0e6903bfae2bc2c6a118245b2a3a56625b560ae81ea5abf1c7c8b657d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Mon, 1 Mar 2021 09:36:19 +0000 Subject: [PATCH] Accepting request 875443 from LibreOffice:7.1 - Fix bsc#1181644 - LO-L3: Text changes are reproducibly lost (PPTX, SmartArt) * bsc1181644.diff OBS-URL: https://build.opensuse.org/request/show/875443 OBS-URL: https://build.opensuse.org/package/show/LibreOffice:Factory/libreoffice?expand=0&rev=948 --- bsc1181644.diff | 149 ++++++++++++++++++++++++++++++++++++++++++++ libreoffice.changes | 6 ++ libreoffice.spec | 3 + 3 files changed, 158 insertions(+) create mode 100644 bsc1181644.diff diff --git a/bsc1181644.diff b/bsc1181644.diff new file mode 100644 index 0000000..478b3e6 --- /dev/null +++ b/bsc1181644.diff @@ -0,0 +1,149 @@ +From 54ad2128db5d324f530cb15ee56e6512d9093872 Mon Sep 17 00:00:00 2001 +From: Miklos Vajna +Date: Thu, 25 Feb 2021 18:04:19 +0100 +Subject: [PATCH] tdf#132368 svx: empty the interop grab-bag on ending text + edit + +Regression from commit aafaf1f55fa413ad49d4556cf7c0a713dd206ae4 (PPTX +export: save SmartArt as diagram instead of group of shapes, +2019-03-13), the idea of interop grab-bag was to carry additional +information around as long as the object is not changed. + +However, actual clearing of the grab-bag was never implemented, do this +when editing shape text. + +An alternative would be to do this in SdrObject::SetChanged(), but +Writer sets the layer of SdrObjects during layout (when the import +filter is already finished and undo is enabled), so that would mean loss +of the smartart metadata for DOCX. + +Change-Id: I9ab205b4ef84169f4b5a16b86fe9a152e3370a6c +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111560 +Reviewed-by: Miklos Vajna +Tested-by: Jenkins +Signed-off-by: Xisco Fauli +--- + svx/CppunitTest_svx_unit.mk | 1 + + svx/qa/unit/svdraw.cxx | 55 ++++++++++++++++++++++++++++++++++++ + svx/source/svdraw/svdobj.cxx | 20 +++++++++++++ + 3 files changed, 76 insertions(+) + +diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk +index ac9f3e4531ad..892490265261 100644 +--- a/svx/CppunitTest_svx_unit.mk ++++ b/svx/CppunitTest_svx_unit.mk +@@ -36,6 +36,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ + $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ + basegfx \ + drawinglayer \ ++ editeng \ + sal \ + sfx \ + svxcore \ +diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx +index c96ccbb7aa97..783420d56fea 100644 +--- a/svx/qa/unit/svdraw.cxx ++++ b/svx/qa/unit/svdraw.cxx +@@ -25,6 +25,12 @@ + #include + #include + #include ++#include ++#include ++#include ++#include ++#include ++ + #include + + using namespace ::com::sun::star; +@@ -105,6 +111,55 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testSemiTransparentText) + CPPUNIT_ASSERT_EQUAL(nTransparence, + static_cast(basegfx::fround(fTransparence * 100))); + } ++ ++CPPUNIT_TEST_FIXTURE(SvdrawTest, testTextEditEmptyGrabBag) ++{ ++ // Given a document with a groupshape, which has 2 children. ++ getComponent() = loadFromDesktop("private:factory/sdraw"); ++ uno::Reference xFactory(getComponent(), uno::UNO_QUERY); ++ uno::Reference xRect1( ++ xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); ++ xRect1->setPosition(awt::Point(1000, 1000)); ++ xRect1->setSize(awt::Size(10000, 10000)); ++ uno::Reference xRect2( ++ xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); ++ xRect2->setPosition(awt::Point(1000, 1000)); ++ xRect2->setSize(awt::Size(10000, 10000)); ++ uno::Reference xGroup( ++ xFactory->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY); ++ uno::Reference xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); ++ uno::Reference xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), ++ uno::UNO_QUERY); ++ uno::Reference xGroupShape(xGroup, uno::UNO_QUERY); ++ xDrawPage->add(xGroupShape); ++ xGroup->add(xRect1); ++ xGroup->add(xRect2); ++ uno::Reference xRect2Text(xRect2, uno::UNO_QUERY); ++ xRect2Text->setString("x"); ++ uno::Sequence aGrabBag = { ++ comphelper::makePropertyValue("OOXLayout", true), ++ }; ++ uno::Reference xGroupProps(xGroup, uno::UNO_QUERY); ++ xGroupProps->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag)); ++ ++ // When editing the shape text of the 2nd rectangle (insert a char at the start). ++ SfxViewShell* pViewShell = SfxViewShell::Current(); ++ SdrView* pSdrView = pViewShell->GetDrawView(); ++ SdrObject* pObject = GetSdrObjectFromXShape(xRect2); ++ pSdrView->SdrBeginTextEdit(pObject); ++ EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView(); ++ rEditView.InsertText("y"); ++ pSdrView->SdrEndTextEdit(); ++ ++ // Then make sure that grab-bag is empty to avoid loosing the new text. ++ xGroupProps->getPropertyValue("InteropGrabBag") >>= aGrabBag; ++ // Without the accompanying fix in place, this test would have failed with: ++ // assertion failed ++ // - Expression: !aGrabBag.hasElements() ++ // i.e. the grab-bag was still around after modifying the shape, and that grab-bag contained the ++ // old text. ++ CPPUNIT_ASSERT(!aGrabBag.hasElements()); ++} + } + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx +index 638c590a52cd..5480ac1d86ce 100644 +--- a/svx/source/svdraw/svdobj.cxx ++++ b/svx/source/svdraw/svdobj.cxx +@@ -1740,6 +1740,26 @@ void SdrObject::SetOutlinerParaObject(std::unique_ptr pTextO + if (GetCurrentBoundRect()!=aBoundRect0) { + SendUserCall(SdrUserCallType::Resize,aBoundRect0); + } ++ ++ if (getSdrModelFromSdrObject().IsUndoEnabled()) ++ { ++ // Don't do this during import. ++ SdrObject* pTopGroupObj = nullptr; ++ if (getParentSdrObjectFromSdrObject()) ++ { ++ pTopGroupObj = getParentSdrObjectFromSdrObject(); ++ while (pTopGroupObj->getParentSdrObjectFromSdrObject()) ++ { ++ pTopGroupObj = pTopGroupObj->getParentSdrObjectFromSdrObject(); ++ } ++ } ++ if (pTopGroupObj) ++ { ++ // A shape was modified, which is in a group shape. Empty the group shape's grab-bag, ++ // which potentially contains the old text of the shapes in case of diagrams. ++ pTopGroupObj->SetGrabBagItem(uno::makeAny(uno::Sequence())); ++ } ++ } + } + + void SdrObject::NbcSetOutlinerParaObject(std::unique_ptr /*pTextObject*/) +-- +2.26.2 + diff --git a/libreoffice.changes b/libreoffice.changes index 0161144..d66f0ab 100644 --- a/libreoffice.changes +++ b/libreoffice.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Feb 26 15:00:29 UTC 2021 - Andras Timar + +- Fix bsc#1181644 - LO-L3: Text changes are reproducibly lost (PPTX, SmartArt) + * bsc1181644.diff + ------------------------------------------------------------------- Fri Feb 19 13:35:18 UTC 2021 - Andras Timar diff --git a/libreoffice.spec b/libreoffice.spec index 973be19..e81dc81 100644 --- a/libreoffice.spec +++ b/libreoffice.spec @@ -105,6 +105,8 @@ Patch4: use-comphelper.patch Patch10: bsc1177955.diff # Bug 1174465 - LO-L3: Impress in TW (7.0.0.0-beta2) messes up bullet points Patch11: bsc1174465.diff +# Bug 1181644 - LO-L3: Text changes are reproducibly lost (PPTX, SmartArt) +Patch12: bsc1181644.diff # try to save space by using hardlinks Patch990: install-with-hardlinks.diff # save time by relying on rpm check rather than doing stupid find+grep @@ -966,6 +968,7 @@ Provides %{langname} translations and additional resources (help files, etc.) fo %patch4 -p1 %patch10 -p1 %patch11 -p1 +%patch12 -p1 %patch990 -p1 %patch991 -p1