[Libreoffice-commits] core.git: oox/source sd/qa

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 29 14:56:34 UTC 2021


 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 f35e0b2cbfd6e7150aeb5699e1db1d7c13fdb935
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Fri Mar 12 11:35:53 2021 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Mar 29 16:55: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 <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx
index be2336be5ba7..7ea5d5d10b53 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 64c215d9b02a..1b36fc2ba866 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -118,6 +118,7 @@ public:
     virtual void setUp() override;
 
     void testDocumentLayout();
+    void testHyperlinkColor();
     void testSmoketest();
     void testTdf131269();
     void testN759180();
@@ -236,6 +237,7 @@ public:
     CPPUNIT_TEST_SUITE(SdImportTest);
 
     CPPUNIT_TEST(testDocumentLayout);
+    CPPUNIT_TEST(testHyperlinkColor);
     CPPUNIT_TEST(testSmoketest);
     CPPUNIT_TEST(testTdf131269);
     CPPUNIT_TEST(testN759180);
@@ -430,6 +432,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(u"/sd/qa/unit/data/smoketest.pptx"), PPTX);


More information about the Libreoffice-commits mailing list