diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-04-07 16:59:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-04-07 18:26:49 +0200 |
commit | 97c18cf32a9a3088b5a51e2b0d535d8caf5daca8 (patch) | |
tree | b78d3988ca60aa7cd9b0f60e1ac6eee6f7c6eb45 /sw | |
parent | 584b700a2cccb9a7e730dadae15dc926736becf1 (diff) |
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.
Change-Id: Ie3a57b654cf06b9512b25d2dc103d15cd83727b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132675
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/doc/doc.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/doc/docfly.cxx | 2 |
2 files changed, 29 insertions, 1 deletions
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 0d39c2fbd508..43894afa03dc 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -197,6 +197,34 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testIMEGrouping) #endif } +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 f34b78141fb1..3ab1e80b4e0a 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -696,7 +696,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 ); |