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

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Mon Sep 30 11:01:12 UTC 2019


 sw/qa/extras/ooxmlexport/data/internal_hyperlink_ole.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx               |   11 +++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx             |    2 +-
 sw/source/filter/ww8/wrtw8nds.cxx                        |    2 +-
 sw/source/filter/ww8/wrtww8.cxx                          |   11 +++++++++++
 5 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 97fba7ebf350adcec6baa6c4a863d058fb90406a
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Tue Sep 24 14:29:44 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Sep 30 13:00:09 2019 +0200

    tdf#127733 DOCX export: fix internal hyperlinks to chart target
    
    Hyperlinks to internal chart targets didn't work after export.
    
    Change-Id: I724c6af8fd7f1961260b82331b9f62d8cbd88f25
    Reviewed-on: https://gerrit.libreoffice.org/79456
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/internal_hyperlink_ole.odt b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_ole.odt
new file mode 100644
index 000000000000..844cf1be6580
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_ole.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 33d767e0bd81..b95f0083e10e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -782,6 +782,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127732, "internal_hyperlink_frame.odt")
     CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf127733, "internal_hyperlink_ole.odt")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+
+    OUString bookmarkName = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:bookmarkStart", "name");
+    OUString anchor = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:hyperlink", "anchor");
+    CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b6f83787b673..3a7555ee305f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2914,7 +2914,7 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
                     }
                 }
             }
-            if (sMark.indexOf(' ') != -1 && !sMark.endsWith("|table") && !sMark.endsWith("|ole") && !sMark.endsWith("|region"))
+            if (sMark.indexOf(' ') != -1 && !sMark.endsWith("|table") && !sMark.endsWith("|region"))
             {
                 // Spaces are prohibited in bookmark name.
                 sMark = sMark.replace(' ', '_');
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 528cd498017b..7edf472786f1 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -917,7 +917,7 @@ bool AttributeOutputBase::AnalyzeURL( const OUString& rUrl, const OUString& /*rT
                                 OUString());
 
         // #i21465# Only interested in outline references
-        if ( !sRefType.isEmpty() && (sRefType == "outline" || sRefType == "graphic" || sRefType == "frame") )
+        if ( !sRefType.isEmpty() && (sRefType == "outline" || sRefType == "graphic" || sRefType == "frame" || sRefType == "ole") )
         {
             for ( const auto& rBookmarkPair : GetExport().m_aImplicitBookmarks )
             {
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 222466d8eb1e..bec217c60ddb 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3104,6 +3104,17 @@ void MSWordExportBase::AddLinkTarget(const OUString& rURL)
             noBookmark = true;
         }
     }
+    else if( sCmp == "ole" )
+    {
+        SwNodeIndex* pIdx;
+        OUString aName(BookmarkToWriter(aURL.copy(0, nPos)));
+        const SwFlyFrameFormat* pFormat = m_pDoc->FindFlyByName(aName, SwNodeType::Ole);
+        if (pFormat && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+        {
+            nIdx = pIdx->GetNext()->GetIndex();
+            noBookmark = true;
+        }
+    }
     if (noBookmark)
     {
         aBookmarkPair aImplicitBookmark;


More information about the Libreoffice-commits mailing list