[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Feb 14 09:35:14 UTC 2017
sw/qa/extras/rtfexport/data/hyperlink-target.rtf | 11 +++++++++++
sw/qa/extras/rtfexport/rtfexport.cxx | 6 ++++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 9 +++++++++
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 4 ++++
4 files changed, 30 insertions(+)
New commits:
commit 31de0ac30d6c521ad663db78feb936688be5bccb
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Feb 14 09:32:25 2017 +0100
RTF import: handle target of hyperlink
lcov pointed out that there is no testcase for the export of this, and
turns out the import part wasn't implemented. As a side effect this
implements the same for DOCX import as well.
Change-Id: I016ebc100ec3856bf3a43aea8ea55af72c2ead1e
diff --git a/sw/qa/extras/rtfexport/data/hyperlink-target.rtf b/sw/qa/extras/rtfexport/data/hyperlink-target.rtf
new file mode 100644
index 0000000..0679e31
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/hyperlink-target.rtf
@@ -0,0 +1,11 @@
+{\rtf1
+\pard\plain
+{
+{\field
+{\*\fldinst HYPERLINK "http://libreoffice.org/" \\t "_blank" }
+{\fldrslt
+{http://libreoffice.org/}
+}
+}
+}
+\par }
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index cf09769..bffb2b1 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1180,6 +1180,12 @@ DECLARE_RTFEXPORT_TEST(testLeveljcCenter, "leveljc-center.rtf")
CPPUNIT_FAIL("no Adjust property");
}
+DECLARE_RTFEXPORT_TEST(testHyperlinkTarget, "hyperlink-target.rtf")
+{
+ // This was empty, hyperlink target was lost on import.
+ CPPUNIT_ASSERT_EQUAL(OUString("_blank"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkTarget"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 09da1b3..334814b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3868,6 +3868,7 @@ void DomainMapper_Impl::CloseFieldCommand()
::std::vector<OUString>::const_iterator aPartIt = aParts.begin();
OUString sURL;
+ OUString sTarget;
while (aPartIt != aItEnd)
{
@@ -3889,6 +3890,8 @@ void DomainMapper_Impl::CloseFieldCommand()
if (aPartIt == aItEnd)
break;
+
+ sTarget = *aPartIt;
}
else
{
@@ -3916,6 +3919,9 @@ void DomainMapper_Impl::CloseFieldCommand()
}
pContext->SetHyperlinkURL(sURL);
}
+
+ if (!sTarget.isEmpty())
+ pContext->SetHyperlinkTarget(sTarget);
}
break;
case FIELD_IF : break;
@@ -4579,6 +4585,9 @@ void DomainMapper_Impl::PopFieldContext()
xCrsrProperties->setPropertyValue(getPropertyName(PROP_HYPER_LINK_U_R_L), uno::
makeAny(pContext->GetHyperlinkURL()));
+ if (!pContext->GetHyperlinkTarget().isEmpty())
+ xCrsrProperties->setPropertyValue("HyperLinkTarget", uno::makeAny(pContext->GetHyperlinkTarget()));
+
if (m_bStartTOC) {
OUString sDisplayName("Index Link");
xCrsrProperties->setPropertyValue("VisitedCharStyleName",uno::makeAny(sDisplayName));
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index cce9d59..bfa2a5b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -150,6 +150,8 @@ class FieldContext
css::uno::Reference<css::beans::XPropertySet> m_xTC; // TOX entry
css::uno::Reference<css::beans::XPropertySet> m_xCustomField;
OUString m_sHyperlinkURL;
+ /// A frame for the the hyperlink when one exists.
+ OUString m_sHyperlinkTarget;
FFDataHandler::Pointer_t m_pFFDataHandler;
FormControlHelper::Pointer_t m_pFormControlHelper;
/// (Character) properties of the field itself.
@@ -188,6 +190,8 @@ public:
void SetHyperlinkURL( const OUString& rURL ) { m_sHyperlinkURL = rURL; }
const OUString& GetHyperlinkURL() { return m_sHyperlinkURL; }
+ void SetHyperlinkTarget(const OUString& rTarget) { m_sHyperlinkTarget = rTarget; }
+ const OUString& GetHyperlinkTarget() { return m_sHyperlinkTarget; }
void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; }
const FFDataHandler::Pointer_t& getFFDataHandler() const { return m_pFFDataHandler; }
More information about the Libreoffice-commits
mailing list