tdf#136911 fix ppt hyperlink import

If the hyperlink list is not found, try the secondary approach
by searching through the record list.

Change-Id: I5b3516e1005b102fb3b79f55c2485a7c41b56057
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103081
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/sd/qa/unit/data/ppt/tdf136911.ppt b/sd/qa/unit/data/ppt/tdf136911.ppt
new file mode 100644
index 0000000..550dc5c
--- /dev/null
+++ b/sd/qa/unit/data/ppt/tdf136911.ppt
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 861ca95..75222f2 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -99,6 +99,7 @@ public:
    void testTdf128345GradientRadial();
    void testTdf128345GradientAxial();
    void testTdf134969TransparencyOnColorGradient();
    void testTdf136911();

    CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);

@@ -147,6 +148,7 @@ public:
    CPPUNIT_TEST(testTdf128345GradientRadial);
    CPPUNIT_TEST(testTdf128345GradientAxial);
    CPPUNIT_TEST(testTdf134969TransparencyOnColorGradient);
    CPPUNIT_TEST(testTdf136911);

    CPPUNIT_TEST_SUITE_END();

@@ -646,6 +648,32 @@ void SdOOXMLExportTest1::testTextboxWithHyperlink()
    xDocShRef->DoClose();
}

void SdOOXMLExportTest1::testTdf136911()
{
    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf136911.ppt"), PPT);

    xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
    uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );

    // Get second paragraph
    uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );

    // first chunk of text
    uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
    uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );

    uno::Reference<text::XTextField> xField;
    xPropSet->getPropertyValue("TextField") >>= xField;
    CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );

    xPropSet.set(xField, uno::UNO_QUERY);
    OUString aURL;
    xPropSet->getPropertyValue("URL") >>= aURL;
    CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("http://google.com"), aURL);

    xDocShRef->DoClose();
}

void SdOOXMLExportTest1::testBulletColor()
{
    ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bulletColor.pptx"), PPTX );
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index d648cb4..3883f9d 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -531,6 +531,31 @@ bool ImplSdPPTImport::Import()
                if (!aHyperE.SeekToEndOfRecord(rStCtrl))
                    break;
            }

            if (m_aHyperList.size() == 0)
            {
                while(true)
                {

                    DffRecordHeader aHyperE;
                    if (!SeekToRec(rStCtrl, PPT_PST_ExHyperlink, nExObjHyperListLen, &aHyperE))
                        break;
                    if (!SeekToRec(rStCtrl, PPT_PST_ExHyperlinkAtom, nExObjHyperListLen))
                        continue;

                    SdHyperlinkEntry aHyperlink;

                    OUString aURLText;
                    OUString aURLLink;
                    rStCtrl.SeekRel(8);
                    rStCtrl.ReadUInt32(aHyperlink.nIndex);

                    ReadString(aURLText);
                    ReadString(aURLLink);
                    aHyperlink.aTarget = aURLLink;
                    m_aHyperList.push_back(aHyperlink);
                }
            }
        }
    }