diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-04-07 16:59:32 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-04-08 11:12:53 +0200 |
commit | 267555f2458e6670a03013a5def67e87d6dc56cd (patch) | |
tree | 41eebe37a6753e24ef8136460a25568b8540b0a3 | |
parent | 2ce52702116b703345f91d7152d134b2e51e77e3 (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
(cherry picked from commit 97c18cf32a9a3088b5a51e2b0d535d8caf5daca8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132697
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-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 6b73f1f756b5..db9518b2cecd 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 ); |