oox/source/drawingml/hyperlinkcontext.cxx | 3 +- oox/source/drawingml/textrun.cxx | 4 ++ sd/qa/unit/data/pptx/tdf137367.pptx |binary sd/qa/unit/import-tests.cxx | 41 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-)
New commits: commit a8f834ed66d4b2c2eab06be751d913b5eba2aeac Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Fri Mar 12 11:35:53 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Mar 30 15:45:57 2021 +0200 tdf#137367 PPTX import: fix lost direct hyperlink colors Regression from commit 92f74f6ccb5a55807724db85815f7ea0c49370e0 (bnc#887230: always use theme color for hyperlinks in Impress) Testing: direct color of the first text line is theme based (a:rPr/a:solidFill/a:schemeClr), the second line contains a direct color (a:rPr/a:solidFill/a:srgbClr), the third one contains a theme based direct color darkened by 25.000% (val=75000 of a:rPr/a:solidFill/a:schemeClr/a:lumMod). Note: overwriting default theme based hyperlink colors is also supported by Google Docs, Office 365 and MS Office 2019. Change-Id: I1e3e78fac729a97f42c8dddcffd877a16383adbf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112377 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit f35e0b2cbfd6e7150aeb5699e1db1d7c13fdb935) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113290 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx index d0a09b140dcf..267216ff7500 100644 --- a/oox/source/drawingml/hyperlinkcontext.cxx +++ b/oox/source/drawingml/hyperlinkcontext.cxx @@ -150,7 +150,8 @@ ContextHandlerRef HyperLinkContext::onCreateContext( switch( aElement ) { case A_TOKEN( extLst ): - return nullptr; + maProperties.setProperty(PROP_CharColor, XML_fillcolor); + break; case A_TOKEN( snd ): // TODO use getEmbeddedWAVAudioFile() here break; diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx index 8b34fd99082e..ab87fb732141 100644 --- a/oox/source/drawingml/textrun.cxx +++ b/oox/source/drawingml/textrun.cxx @@ -148,7 +148,9 @@ sal_Int32 TextRun::insertAt( xTextFieldCursor->gotoEnd( true ); - aTextCharacterProps.maFillProperties.maFillColor.setSchemeClr( XML_hlink ); + if (!maTextCharacterProperties.maHyperlinkPropertyMap.hasProperty(PROP_CharColor)) + aTextCharacterProps.maFillProperties.maFillColor.setSchemeClr(XML_hlink); + aTextCharacterProps.maFillProperties.moFillType.set(XML_solidFill); if ( !maTextCharacterProperties.moUnderline.has() ) aTextCharacterProps.moUnderline.set( XML_sng ); diff --git a/sd/qa/unit/data/pptx/tdf137367.pptx b/sd/qa/unit/data/pptx/tdf137367.pptx new file mode 100644 index 000000000000..cf6aa086d9a8 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf137367.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index a60d6f601bfc..e140c41c126d 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -122,6 +122,7 @@ public: virtual void setUp() override; void testDocumentLayout(); + void testHyperlinkColor(); void testSmoketest(); void testN759180(); void testN778859(); @@ -239,6 +240,7 @@ public: CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST(testDocumentLayout); + CPPUNIT_TEST(testHyperlinkColor); CPPUNIT_TEST(testSmoketest); CPPUNIT_TEST(testN759180); CPPUNIT_TEST(testN778859); @@ -432,6 +434,45 @@ void SdImportTest::testDocumentLayout() } } +void SdImportTest::testHyperlinkColor() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf137367.pptx"), PPTX); + + uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) ); + + // Get first paragraph of the text + uno::Reference<text::XTextRange> const xParagraph1( getParagraphFromShape( 0, xShape ) ); + // Get second paragraph of the text + uno::Reference<text::XTextRange> const xParagraph2( getParagraphFromShape( 1, xShape ) ); + // Get third paragraph of the text + uno::Reference<text::XTextRange> const xParagraph3( getParagraphFromShape( 2, xShape ) ); + + // Get run of the first paragraph + uno::Reference<text::XTextRange> xRun1( getRunFromParagraph (0, xParagraph1 ) ); + uno::Reference< beans::XPropertySet > xPropSet1( xRun1, uno::UNO_QUERY_THROW ); + sal_Int32 nCharColorBlue; + xPropSet1->getPropertyValue( "CharColor" ) >>= nCharColorBlue; + + // Get run of the second paragraph + uno::Reference<text::XTextRange> xRun2( getRunFromParagraph (1, xParagraph2 ) ); + uno::Reference< beans::XPropertySet > xPropSet2( xRun2, uno::UNO_QUERY_THROW ); + sal_Int32 nCharColorRed; + xPropSet2->getPropertyValue( "CharColor" ) >>= nCharColorRed; + + // Get run of the third paragraph + uno::Reference<text::XTextRange> xRun3( getRunFromParagraph (2, xParagraph3 ) ); + uno::Reference< beans::XPropertySet > xPropSet3( xRun3, uno::UNO_QUERY_THROW ); + sal_Int32 nCharColorGreen; + xPropSet3->getPropertyValue( "CharColor" ) >>= nCharColorGreen; + + // Hyperlink colors should be blue, red, green. + CPPUNIT_ASSERT_EQUAL( sal_Int32(4485828), nCharColorBlue ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(16711680), nCharColorRed ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(5538357), nCharColorGreen ); + + xDocShRef->DoClose(); +} + void SdImportTest::testSmoketest() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"), PPTX); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits