summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-06-27 16:02:45 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-02 08:22:37 +0000
commitf9d7927c615a0998456f2d72b4d88c16a0314c24 (patch)
tree0f1e015bb2fa7590fce4170e0803464ebda095b7 /sw
parent32eddb3f48fcea0a052401a8a5dc075c7847f1c5 (diff)
fdo#78758: sw: RTF export: don't export multiple \fldrst for one hyperlink
Ensure that we export only one \fldresult per hyperlink by doing that in StartURL() and EndURL(); the TextINetFormat() is called once per text portion. This shouldn't cause problems as there can't be anything between the end of the \field group and the start of \fldresult anyway. Replace the annoying call to EndURL() from EndRun() with a special case in EndURL() to store things in the right buffer (hopefully). (somehow this is regression from c4498251cb7181a9f272b0720f398597c0daef09) (cherry picked from commit b8907bf3d3b37c686a414ffbbd2d732348aab5b9) Conflicts: sw/source/filter/ww8/docxattributeoutput.hxx sw/source/filter/ww8/rtfattributeoutput.cxx sw/source/filter/ww8/rtfattributeoutput.hxx sw/source/filter/ww8/ww8attributeoutput.hxx Change-Id: I209ea7a384fb1cb5d1505a70ecc4a4536bbf26a2 Reviewed-on: https://gerrit.libreoffice.org/10021 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/fdo78758.rtf9
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx10
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx37
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx9
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx2
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx4
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx2
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx2
11 files changed, 47 insertions, 34 deletions
diff --git a/sw/qa/extras/rtfexport/data/fdo78758.rtf b/sw/qa/extras/rtfexport/data/fdo78758.rtf
new file mode 100644
index 000000000000..49c05021275d
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo78758.rtf
@@ -0,0 +1,9 @@
+{\rtf1\ansi
+\par \pard\plain
+{{\field{\*\fldinst HYPERLINK "#__RefHeading___Toc264438068" }
+{\fldrslt {\langfe1024\rtlch \ltrch\loch\lang1024
+EE5E EeEEE5EE}{\scaps\langfe1024\rtlch \ltrch\loch\lang1024
+e}{\langfe1024\rtlch \ltrch\loch\lang1024
+\tab 46}}}}
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index a3fb2cb29899..e53537481b8c 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -457,6 +457,16 @@ DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf")
CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL"));
}
+DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf")
+{
+ CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
+ getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL"));
+ CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
+ getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL"));
+ CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
+ getProperty<OUString>(getRun(getParagraph(2), 3, "\t46"), "HyperLinkURL"));
+}
+
DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf")
{
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 34e62eec4b66..dce83ba304af 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -208,7 +208,7 @@ public:
virtual bool StartURL( const OUString& rUrl, const OUString& rTarget ) = 0;
/// Output URL end.
- virtual bool EndURL() = 0;
+ virtual bool EndURL(bool isAtEndOfParagraph) = 0;
virtual void FieldVanish( const OUString& rTxt, ww::eField eType ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 054e946aaefe..205686343ee1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1437,7 +1437,7 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
return true;
}
-bool DocxAttributeOutput::EndURL()
+bool DocxAttributeOutput::EndURL(bool const)
{
m_closeHyperlinkInThisRun = true;
return true;
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 20991164b4d4..5da77159b661 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -162,7 +162,7 @@ public:
virtual bool StartURL( const OUString& rUrl, const OUString& rTarget );
/// Output URL end.
- virtual bool EndURL();
+ virtual bool EndURL(bool) SAL_OVERRIDE;
virtual void FieldVanish( const OUString& rTxt, ww::eField eType );
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 5844c0d46cc8..f73ab4d4164e 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -413,8 +413,6 @@ void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool bSing
void RtfAttributeOutput::EndRun()
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
- if (m_bInURL)
- EndURL();
m_aRun->append(SAL_NEWLINE_STRING);
m_aRun.appendAndClear(m_aRunText);
if (!m_bSingleEmptyRun && m_bInRun)
@@ -494,25 +492,32 @@ bool RtfAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarget
}
m_aStyles.append("}");
- m_bHadFieldResult = false;
- m_bInURL = true;
+ m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {");
return true;
}
-bool RtfAttributeOutput::EndURL()
+bool RtfAttributeOutput::EndURL(bool const isAtEndOfParagraph)
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
- if (m_bInURL)
- m_bInURL = false;
- else
- return true;
-
- // close the fldrslt group
- if (m_bHadFieldResult)
+ // 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('}');
- // close the field group
- m_aRunText->append('}');
+ }
+ else
+ {
+ // close the fldrslt group
+ m_aRun->append("}}");
+ // close the field group
+ m_aRun->append('}');
+ }
return true;
}
@@ -2395,8 +2400,6 @@ void RtfAttributeOutput::TextINetFormat( const SwFmtINetFmt& rURL )
const SwCharFmt* pFmt;
const SwTxtINetFmt* pTxtAtr = rURL.GetTxtINetFmt();
- m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
- m_bHadFieldResult = true;
if( pTxtAtr && 0 != ( pFmt = pTxtAtr->GetCharFmt() ))
{
sal_uInt16 nStyle = m_rExport.GetId( *pFmt );
@@ -3249,13 +3252,11 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
m_bBufferSectionHeaders( false ),
m_bLastTable( true ),
m_bWroteCellInfo( false ),
- m_bHadFieldResult( false ),
m_bTableRowEnded( false ),
m_aCells(),
m_bSingleEmptyRun(false),
m_bInRun(false),
m_nPostitFieldsMaxId(0),
- m_bInURL(false),
m_pFlyFrameSize(0),
m_pPrevPageDesc(0)
{
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index b5b19a982463..fd9b6f78a381 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -95,7 +95,7 @@ public:
virtual bool StartURL( const OUString& rUrl, const OUString& rTarget );
/// Output URL end.
- virtual bool EndURL();
+ virtual bool EndURL(bool isAtEndOfParagraph) SAL_OVERRIDE;
virtual void FieldVanish( const OUString& rTxt, ww::eField eType );
@@ -557,11 +557,6 @@ private:
*/
bool m_bWroteCellInfo;
- /*
- * If we had a field result in the URL.
- */
- bool m_bHadFieldResult;
-
/// If we ended a table row without starting a new one.
bool m_bTableRowEnded;
@@ -575,8 +570,6 @@ private:
unsigned int m_nPostitFieldsMaxId;
- bool m_bInURL;
-
/// When exporting fly frames, this holds the real size of the frame.
const Size* m_pFlyFrameSize;
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index b3b6c1109541..ced46d4aff2b 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1165,7 +1165,7 @@ void MSWord_SdrAttrIter::OutEEField(const SfxPoolItem& rHt)
const OUString &rStr = pURL->GetRepresentation();
m_rExport.AttrOutput().RawText( rStr, true, GetNodeCharSet() ); // FIXME kendy: is the 'true' actually correct here? It was here before, but... ;-)
- m_rExport.AttrOutput().EndURL();
+ m_rExport.AttrOutput().EndURL(false);
m_rExport.nTxtTyp = nOldTxtTyp;
}
}
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 72ad2fea72da..132e2f6278ea 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -999,7 +999,7 @@ bool WW8AttributeOutput::StartURL( const OUString &rUrl, const OUString &rTarget
return true;
}
-bool WW8AttributeOutput::EndURL()
+bool WW8AttributeOutput::EndURL(bool const)
{
// hyperlinks only in WW8
if ( !m_rWW8Export.bWrtWW8 )
@@ -1141,7 +1141,7 @@ int SwWW8AttrIter::OutAttrWithRange(xub_StrLen nPos)
}
if ( 0 != ( pEnd = pHt->End() ) && nPos == *pEnd )
{
- if ( m_rExport.AttrOutput().EndURL() )
+ if (m_rExport.AttrOutput().EndURL(nPos == rNd.Len()))
--nRet;
}
break;
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 92677df1b81d..61a8c175e7da 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -512,7 +512,7 @@ void WW8Export::OutGrf(const sw::Frame &rFrame)
//Added for i120568,the hyperlink info within a graphic whose anchor type is
//"As character" will be exported to ensure the fidelity
if( bURLStarted )
- m_pAttrOutput->EndURL();
+ m_pAttrOutput->EndURL(false);
}
GraphicDetails& GraphicDetails::operator=(const GraphicDetails &rOther)
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 2c844334be4e..8ef2124aaa88 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -80,7 +80,7 @@ public:
virtual bool StartURL( const OUString &rUrl, const OUString &rTarget );
/// Output URL end.
- virtual bool EndURL();
+ virtual bool EndURL(bool) SAL_OVERRIDE;
virtual void FieldVanish( const OUString& rTxt, ww::eField eType );