sw/qa/extras/inc/swmodeltestbase.hxx | 6 ++ sw/qa/extras/rtfexport/data/tdf90421.fodt | 8 +++ sw/qa/extras/rtfexport/rtfexport.cxx | 23 ++++++++ sw/source/core/txtnode/txatbase.cxx | 7 ++ sw/source/filter/ww8/rtfattributeoutput.cxx | 74 +++++++++++++++------------- sw/source/filter/ww8/rtfattributeoutput.hxx | 3 + 6 files changed, 87 insertions(+), 34 deletions(-)
New commits: commit 7d42346ba77c9c4df241ea40eaf550993ca18783 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Apr 21 17:00:57 2015 +0200 tdf#90421 RTF export: ignore hyperlinks without an URL Commit fe444d1f74abe417962be0bcd3340f40f2446b58 (fdo#62536: sw: fix AutoCorrect bold/underline on existing AUTOFMT, 2013-06-20) adds an empty inet format hint on the text node during autocorrection, on export we can safely ignore that to provide well-formed output. Change-Id: Iafae941a13e29dcc7d8b4bade5ce94a486b59638 diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 7528ced..f0d3428 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -240,6 +240,7 @@ protected: header(); preTest(filename); load(mpTestDocumentPath, filename); + postLoad(filename); reload(mpFilter, filename); postTest(filename); verify(); @@ -289,6 +290,11 @@ protected: { } + /// Override this function if some special file-specific setup is needed during export test: after load, but before save. + virtual void postLoad(const char* /*pFilename*/) + { + } + /** * Override this function if some special filename-specific teardown is needed */ diff --git a/sw/qa/extras/rtfexport/data/tdf90421.fodt b/sw/qa/extras/rtfexport/data/tdf90421.fodt new file mode 100644 index 0000000..a0da4b8 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf90421.fodt @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:p text:style-name="P1">A <text:a xlink:type="simple" xlink:href="http://s/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">http://s/</text:a> B</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 20f2a7d..33d6ca4 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -78,6 +78,16 @@ public: return false; } + + virtual void postLoad(const char* pFilename) SAL_OVERRIDE + { + if (OString(pFilename) == "tdf90421.fodt") + { + // Change the hyperlink, so its URL is empty. + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY); + xRun->setPropertyValue("HyperLinkURL", uno::makeAny(OUString())); + } + } }; DECLARE_RTFEXPORT_TEST(testZoom, "zoom.rtf") @@ -889,6 +899,19 @@ DECLARE_RTFEXPORT_TEST(testTdf80708, "tdf80708.rtf") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); } +DECLARE_RTFEXPORT_TEST(testTdf90421, "tdf90421.fodt") +{ + if (mbExported) + { + SvMemoryStream aMemoryStream; + SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ); + aStream.ReadStream(aMemoryStream); + OString aData(static_cast<const char*>(aMemoryStream.GetData()), aMemoryStream.GetSize()); + // This was some positive number, i.e. we exported a hyperlink with an empty URL. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aData.indexOf("HYPERLINK")); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 54ab984..6290ae0 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -423,52 +423,58 @@ void RtfAttributeOutput::EndRuby() bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget) { - m_aStyles.append('{'); - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD); - m_aStyles.append('{'); - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE); - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST); - m_aStyles.append(" HYPERLINK "); - - OUString sURL(rUrl); - if (!sURL.isEmpty()) + m_sURL = rUrl; + // Ignore hyperlink without an URL. + if (!rUrl.isEmpty()) { + m_aStyles.append('{'); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD); + m_aStyles.append('{'); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST); + m_aStyles.append(" HYPERLINK "); + + OUString sURL(rUrl); m_aStyles.append("\""); m_aStyles.append(msfilter::rtfutil::OutString(sURL, m_rExport.eCurrentEncoding)); m_aStyles.append("\" "); - } - if (!rTarget.isEmpty()) - { - m_aStyles.append("\\\\t \""); - m_aStyles.append(msfilter::rtfutil::OutString(rTarget, m_rExport.eCurrentEncoding)); - m_aStyles.append("\" "); - } + if (!rTarget.isEmpty()) + { + m_aStyles.append("\\\\t \""); + m_aStyles.append(msfilter::rtfutil::OutString(rTarget, m_rExport.eCurrentEncoding)); + m_aStyles.append("\" "); + } - m_aStyles.append("}"); - m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {"); + m_aStyles.append("}"); + m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {"); + } return true; } bool RtfAttributeOutput::EndURL(bool const isAtEndOfParagraph) { - // UGLY: usually EndRun is called earlier, but there is an extra - // call to OutAttrWithRange() when at the end of the paragraph, - // so in that special case the output needs to be appended to the - // new run's text instead of the previous run - if (isAtEndOfParagraph) + if (!m_sURL.isEmpty()) { - // close the fldrslt group - m_aRunText->append("}}"); - // close the field group - m_aRunText->append('}'); - } - else - { - // close the fldrslt group - m_aRun->append("}}"); - // close the field group - m_aRun->append('}'); + // UGLY: usually EndRun is called earlier, but there is an extra + // call to OutAttrWithRange() when at the end of the paragraph, + // so in that special case the output needs to be appended to the + // new run's text instead of the previous run + if (isAtEndOfParagraph) + { + // close the fldrslt group + m_aRunText->append("}}"); + // close the field group + m_aRunText->append('}'); + } + else + { + // close the fldrslt group + m_aRun->append("}}"); + // close the field group + m_aRun->append('}'); + } + m_sURL.clear(); } return true; } diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index a307885d..f6b6415 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -596,6 +596,9 @@ private: boost::optional<css::drawing::FillStyle> m_oFillStyle; + /// If we're in the process of exporting a hyperlink, then its URL. + OUString m_sURL; + public: RtfAttributeOutput(RtfExport& rExport); commit d31d038f4e385e228488fd76f6d463a43a2f6266 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Apr 21 16:01:10 2015 +0200 SwTxtAttr::dumpAsXml: show hyperlink URLs Change-Id: Ie887db2793a8bc85a6cd381db7543436bbd5a9d5 diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 061cb25..d0be2b4 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -103,6 +103,13 @@ void SwTxtAttr::dumpAsXml(xmlTextWriterPtr pWriter) const oValue = "name: " + OUStringToOString(pCharFmt->GetName(), RTL_TEXTENCODING_UTF8); break; } + case RES_TXTATR_INETFMT: + { + pWhich = "inet format"; + const SwFmtINetFmt& rFmt = GetINetFmt(); + oValue = "url: " + rFmt.GetValue().toUtf8(); + break; + } default: break; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits