oox/inc/ooxresid.hxx | 1 oox/inc/strings.hrc | 1 oox/source/helper/ooxresid.cxx | 1 oox/source/ppt/presentationfragmenthandler.cxx | 7 ++++- sd/qa/unit/data/pptx/tdf149314.pptx |binary sd/qa/unit/import-tests.cxx | 31 +++++++++++++++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-)
New commits: commit 325edd3846c968cdcbd218305195ea96c7787e18 Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Wed Jun 1 16:10:42 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Jun 24 16:18:10 2022 +0200 tdf#149314 PPTX import: fix internal hyperlink in editor Hyperlinks on text weren't imported correctly if the linked slides have default slide name, resulting broken links in the editor (hyperlinks work well in slide shows without this fix, too). Change-Id: I797fa94134c1346bc83729c713e65b2a268a14c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135245 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 00b920af618d549fbd8180ad98bfaeca75830ed0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136326 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/oox/inc/ooxresid.hxx b/oox/inc/ooxresid.hxx index 473e13407ac3..c374b664525c 100644 --- a/oox/inc/ooxresid.hxx +++ b/oox/inc/ooxresid.hxx @@ -14,6 +14,7 @@ #include <unotools/resmgr.hxx> OUString OoxResId(TranslateId aId); +OUString URLResId(TranslateId aId); #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/oox/inc/strings.hrc b/oox/inc/strings.hrc index c9b4f3cf7230..cd107aa36a02 100644 --- a/oox/inc/strings.hrc +++ b/oox/inc/strings.hrc @@ -14,5 +14,6 @@ #define STR_DIAGRAM_TITLE NC_("STR_DIAGRAM_TITLE", "Chart Title") #define STR_DIAGRAM_AXISTITLE NC_("STR_DIAGRAM_AXISTITLE", "Axis Title") +#define STR_SLIDE_NAME NC_("STR_SLIDE_NAME", "Slide" ) #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/oox/source/helper/ooxresid.cxx b/oox/source/helper/ooxresid.cxx index 58e0e8cb33e0..6ad02a70b056 100644 --- a/oox/source/helper/ooxresid.cxx +++ b/oox/source/helper/ooxresid.cxx @@ -12,5 +12,6 @@ #include <unotools/resmgr.hxx> OUString OoxResId(TranslateId aId) { return Translate::get(aId, Translate::Create("oox")); } +OUString URLResId(TranslateId aId) { return Translate::get(aId, Translate::Create("sd")); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index c9deec076edc..b0a7b7ec0fd3 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -60,6 +60,8 @@ #include <com/sun/star/office/XAnnotation.hpp> #include <com/sun/star/office/XAnnotationAccess.hpp> +#include <ooxresid.hxx> +#include <strings.hrc> using namespace ::com::sun::star; using namespace ::oox::core; @@ -195,7 +197,10 @@ static void ResolveTextFields( XmlFilterBase const & rFilter ) xDrawPage = xPresentationPage->getNotesPage(); } Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW ); - aURL = "#" + xNamed->getName(); + if (!xNamed->getName().startsWith("page")) + aURL = "#" + xNamed->getName(); + else + aURL = "#" + URLResId(STR_SLIDE_NAME) + " " + OUString::number(nPageNumber); xPropSet->setPropertyValue( sURL, Any( aURL ) ); Reference< text::XTextContent > xContent( rTextField.xTextField); Reference< text::XTextRange > xTextRange = rTextField.xTextCursor; diff --git a/sd/qa/unit/data/pptx/tdf149314.pptx b/sd/qa/unit/data/pptx/tdf149314.pptx new file mode 100644 index 000000000000..3138c1ddaf78 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149314.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index aa329dfddec6..68161536da93 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -83,6 +83,7 @@ public: virtual void setUp() override; void testDocumentLayout(); + void testTdf149314(); void testTdf149124(); void testTdf148965(); void testTdf89449(); @@ -153,6 +154,7 @@ public: CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST(testDocumentLayout); + CPPUNIT_TEST(testTdf149314); CPPUNIT_TEST(testTdf149124); CPPUNIT_TEST(testTdf148965); CPPUNIT_TEST(testTdf89449); @@ -301,6 +303,35 @@ void SdImportTest::testDocumentLayout() } } +void SdImportTest::testTdf149314() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf149314.pptx"), PPTX); + + OUString aURL; + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 1, xDocShRef)); + + uno::Reference<text::XTextRange> const xParagraph1(getParagraphFromShape(0, xShape)); + uno::Reference<text::XTextRange> xRun1(getRunFromParagraph(0, xParagraph1)); + uno::Reference<beans::XPropertySet> xPropSet1(xRun1, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextField> xField1; + xPropSet1->getPropertyValue("TextField") >>= xField1; + xPropSet1.set(xField1, uno::UNO_QUERY); + xPropSet1->getPropertyValue("URL") >>= aURL; + CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide 1"), aURL); + + uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(1, xShape)); + uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2)); + uno::Reference<beans::XPropertySet> xPropSet2(xRun2, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextField> xField2; + xPropSet2->getPropertyValue("TextField") >>= xField2; + xPropSet2.set(xField2, uno::UNO_QUERY); + xPropSet2->getPropertyValue("URL") >>= aURL; + CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide 3"), aURL); + + xDocShRef->DoClose(); +} + void SdImportTest::testTdf149124() { sd::DrawDocShellRef xDocShRef