sw/qa/core/doc/doc.cxx | 28 ++++++++++++++++++++++++++++ sw/source/core/doc/docfly.cxx | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-)
New commits: commit 0983dca4d64f3099c9cfe6341e9c219ea37e9aa5 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Apr 7 16:59:32 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Apr 8 16:44:23 2022 +0200 sw: keep URL when applying frame style on images It seems that the intention is to reset properties which are possible to set in a style when applying a style. For example the paragraph alignment can be defined in a paragraph style, so reset that on style apply. URLs on frames can't be defined for frame styles, so it looks incorrect to reset the URL of a frame/image on style apply, fix this. (cherry picked from commit 97c18cf32a9a3088b5a51e2b0d535d8caf5daca8) Conflicts: sw/qa/core/doc/doc.cxx Change-Id: Ie3a57b654cf06b9512b25d2dc103d15cd83727b7 diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index a8489e01a274..59a73751308d 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -82,6 +82,34 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextboxTextRotateAngle) ErrorRegistry::Reset(); } +CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testImageHyperlinkStyle) +{ + // Given a document with an image with a hyperlink: + loadURL("private:factory/swriter", nullptr); + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextDocument> xDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XText> xText = xDocument->getText(); + uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); + uno::Reference<text::XTextContent> xImage( + xFactory->createInstance("com.sun.star.text.TextGraphicObject"), uno::UNO_QUERY); + xText->insertTextContent(xCursor, xImage, /*bAbsorb=*/false); + uno::Reference<beans::XPropertySet> xImageProps(xImage, uno::UNO_QUERY); + OUString aExpected = "http://www.example.com"; + xImageProps->setPropertyValue("HyperLinkURL", uno::makeAny(aExpected)); + + // When applying a frame style on it: + xImageProps->setPropertyValue("FrameStyleName", uno::makeAny(OUString("Frame"))); + + // Then make sure that the hyperlink is not lost: + auto aActual = getProperty<OUString>(xImageProps, "HyperLinkURL"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: http://www.example.com + // - Actual : + // i.e. the link was lost, even if the frame style dialog doesn't allow specifying a link on + // frames. + CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index e435920da879..b5aa5465cdc8 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -700,7 +700,7 @@ bool SwDoc::SetFrameFormatToFly( SwFrameFormat& rFormat, SwFrameFormat& rNewForm rFormat.ResetFormatAttr( RES_PRINT, RES_SURROUND ); rFormat.ResetFormatAttr( RES_LR_SPACE, RES_UL_SPACE ); rFormat.ResetFormatAttr( RES_BACKGROUND, RES_COL ); - rFormat.ResetFormatAttr( RES_URL, RES_EDIT_IN_READONLY ); + rFormat.ResetFormatAttr( RES_EDIT_IN_READONLY ); if( !bFrameSz ) rFormat.SetFormatAttr( aFrameSz );