summaryrefslogtreecommitdiff
path: root/sw/qa/uitest
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-07-13 11:37:30 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-07-14 07:43:14 +0200
commit9f4af852c4050d45bb5ab314480fc83639bea90a (patch)
tree23ce60d8ef929d52efc587d3d6308fd24641cd7d /sw/qa/uitest
parentfc8b757dad5d98f4ba1cd40d03505873128670cd (diff)
tdf#148198: merge identical hyperlinks of adjacent text ranges on ODF export
The true hyperlink boundaries are available as SwpHints starts/ends, which are used in DOC(X) export (see SwWW8AttrIter::OutAttrWithRange). However, I don't see a reasonable way to expose this information to xmloff, so I decided instead to just merge the identical hyperlink properties of adjacent ranges into a single hyperlink. This will allow to fix already split hyperlinks saved in previous versions. The downside is that this disallows to have separate adjacent identical hyperlinks - I hope that this would not be a real issue. Change-Id: I901e6035a5e89bc515b5742c6a5f564c77faf05b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137013 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/qa/uitest')
-rw-r--r--sw/qa/uitest/data/hyperlink_multiple_spans.fodt44
-rw-r--r--sw/qa/uitest/navigator/tdf148198.py61
2 files changed, 105 insertions, 0 deletions
diff --git a/sw/qa/uitest/data/hyperlink_multiple_spans.fodt b/sw/qa/uitest/data/hyperlink_multiple_spans.fodt
new file mode 100644
index 000000000000..bdf405ffd39d
--- /dev/null
+++ b/sw/qa/uitest/data/hyperlink_multiple_spans.fodt
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Emphasis" style:family="text">
+ <style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/>
+ </style:style>
+ <style:style style:name="Strong_20_Emphasis" style:display-name="Strong Emphasis" style:family="text">
+ <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
+ </style:style>
+ <style:style style:name="Internet_20_link" style:display-name="Internet link" style:family="text">
+ <style:text-properties fo:color="#000080" loext:opacity="100%" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/>
+ </style:style>
+ <style:style style:name="Visited_20_Internet_20_Link" style:display-name="Visited Internet Link" style:family="text">
+ <style:text-properties fo:color="#800000" loext:opacity="100%" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/>
+ </style:style>
+ <style:style style:name="Footnote_20_Symbol" style:display-name="Footnote Symbol" style:family="text"/>
+ <style:style style:name="Footnote_20_anchor" style:display-name="Footnote anchor" style:family="text">
+ <style:text-properties style:text-position="super 58%"/>
+ </style:style>
+ <text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_20_Symbol" text:citation-body-style-name="Footnote_20_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="T1" style:family="text">
+ <style:text-properties officeooo:rsid="00083fb4"/>
+ </style:style>
+ <style:style style:name="gr1" style:family="graphic">
+ <style:graphic-properties draw:stroke="none" svg:stroke-color="#000000" draw:fill="solid" draw:fill-color="#ffff80" fo:min-height="2cm" style:run-through="foreground" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" style:flow-with-text="false"/>
+ <style:paragraph-properties style:writing-mode="lr-tb"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p><text:bookmark-start text:name="Bookmark"/>This is a bookmark<text:bookmark-end text:name="Bookmark"/></text:p>
+ <text:p/>
+ <text:p>No hyperlink; <text:a xlink:type="simple" xlink:href="#Bookmark" office:target-frame-name="_top" xlink:show="replace" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link"><text:span text:style-name="Strong_20_Emphasis">a hyperlink with an anchor</text:span><draw:frame text:anchor-type="char" draw:z-index="0" draw:name="Text Frame 1" draw:style-name="gr1" draw:text-style-name="P4" svg:width="2cm" svg:height="2cm" svg:x="6cm" svg:y="2cm">
+ <draw:text-box>
+ <text:p>text</text:p>
+ </draw:text-box>
+ </draw:frame>, <text:span text:style-name="Emphasis">different character styles</text:span>, a footnote<text:span text:style-name="Emphasis"><text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body>
+ <text:p>A footnote</text:p></text:note-body></text:note></text:span>, a field <text:bookmark-ref text:reference-format="text" text:ref-name="Bookmark">This is a bookmark</text:bookmark-ref>, and <text:span text:style-name="T1">a rsid</text:span></text:a>; no hyperlink; <text:a xlink:type="simple" xlink:href="#Bookmark" office:target-frame-name="_top" xlink:show="replace" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">another hyperlink</text:a>; no hyperlink</text:p>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/uitest/navigator/tdf148198.py b/sw/qa/uitest/navigator/tdf148198.py
new file mode 100644
index 000000000000..d273bb6b5e2b
--- /dev/null
+++ b/sw/qa/uitest/navigator/tdf148198.py
@@ -0,0 +1,61 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
+
+class tdf148198(UITestCase):
+
+ def test_tdf148198(self):
+ sHyperlink0 = 'a hyperlink with an anchor, different character styles, a footnote1, a field This is a bookmark, and a rsid'
+ sHyperlink1 = 'another hyperlink'
+
+ with self.ui_test.load_file(get_url_for_data_file('hyperlink_multiple_spans.fodt')):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild('writer_edit')
+
+ self.xUITest.executeCommand('.uno:Sidebar')
+ xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'}))
+
+ # wait until the navigator panel is available
+ xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
+
+ xContentTree = xNavigatorPanel.getChild('contenttree')
+ xHyperlinks = xContentTree.getChild('7')
+ self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text'])
+
+ xHyperlinks.executeAction('EXPAND', tuple())
+
+ self.assertEqual('2', get_state_as_dict(xHyperlinks)['Children'])
+ self.assertEqual(sHyperlink0, get_state_as_dict(xHyperlinks.getChild('0'))['Text'])
+ self.assertEqual(sHyperlink1, get_state_as_dict(xHyperlinks.getChild('1'))['Text'])
+
+ # save and reload: the first hyperlink must be kept in one piece
+ self.xUITest.executeCommand('.uno:Save')
+ self.xUITest.executeCommand('.uno:Reload')
+
+ # wait until the navigator panel is available
+ xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
+
+ xContentTree = xNavigatorPanel.getChild('contenttree')
+ xHyperlinks = xContentTree.getChild('7')
+ self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text'])
+
+ xHyperlinks.executeAction('EXPAND', tuple())
+
+ # without the fix in place, this would fail:
+ # AssertionError: '2' != '11'
+ self.assertEqual('2', get_state_as_dict(xHyperlinks)['Children'])
+ self.assertEqual(sHyperlink0, get_state_as_dict(xHyperlinks.getChild('0'))['Text'])
+ self.assertEqual(sHyperlink1, get_state_as_dict(xHyperlinks.getChild('1'))['Text'])
+
+ self.xUITest.executeCommand('.uno:Sidebar')
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: