summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-04-07 16:59:32 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-04-07 18:26:49 +0200
commit97c18cf32a9a3088b5a51e2b0d535d8caf5daca8 (patch)
treeb78d3988ca60aa7cd9b0f60e1ac6eee6f7c6eb45 /sw
parent584b700a2cccb9a7e730dadae15dc926736becf1 (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.cxx28
-rw-r--r--sw/source/core/doc/docfly.cxx2
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 );