sw/qa/extras/rtfexport/data/fdo78758.rtf     |    9 ++++++
 sw/qa/extras/rtfexport/rtfexport.cxx         |   10 +++++++
 sw/source/filter/ww8/attributeoutputbase.hxx |    2 -
 sw/source/filter/ww8/docxattributeoutput.cxx |    2 -
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 -
 sw/source/filter/ww8/rtfattributeoutput.cxx  |   37 +++++++++++++--------------
 sw/source/filter/ww8/rtfattributeoutput.hxx  |    9 ------
 sw/source/filter/ww8/writerwordglue.cxx      |    3 +-
 sw/source/filter/ww8/wrtw8esh.cxx            |    2 -
 sw/source/filter/ww8/wrtw8nds.cxx            |    4 +-
 sw/source/filter/ww8/wrtww8gr.cxx            |    2 -
 sw/source/filter/ww8/ww8attributeoutput.hxx  |    2 -
 12 files changed, 49 insertions(+), 35 deletions(-)

New commits:
commit b8907bf3d3b37c686a414ffbbd2d732348aab5b9
Author: Michael Stahl <mst...@redhat.com>
Date:   Fri Jun 27 16:02:45 2014 +0200

    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)
    
    Change-Id: I209ea7a384fb1cb5d1505a70ecc4a4536bbf26a2

diff --git a/sw/qa/extras/rtfexport/data/fdo78758.rtf 
b/sw/qa/extras/rtfexport/data/fdo78758.rtf
new file mode 100644
index 0000000..49c0502
--- /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 c01dc38..c2ed07c 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -468,6 +468,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 d2df9c0..a32a4ba 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -203,7 +203,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 3b74b5b..fcd5794 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2070,7 +2070,7 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, 
const OUString& rTarge
     return true;
 }
 
-bool DocxAttributeOutput::EndURL()
+bool DocxAttributeOutput::EndURL(bool const)
 {
     m_closeHyperlinkInThisRun = true;
     if(m_startedHyperlink && m_hyperLinkAnchor != "" && 
m_hyperLinkAnchor.startsWith("_Toc"))
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 6465a71..5f979ad 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -190,7 +190,7 @@ public:
     virtual bool StartURL( const OUString& rUrl, const OUString& rTarget ) 
SAL_OVERRIDE;
 
     /// Output URL end.
-    virtual bool EndURL() SAL_OVERRIDE;
+    virtual bool EndURL(bool) SAL_OVERRIDE;
 
     virtual void FieldVanish( const OUString& rTxt, ww::eField eType ) 
SAL_OVERRIDE;
 
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx 
b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 5f41c34..6dabc93 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -408,8 +408,6 @@ void RtfAttributeOutput::StartRun(const SwRedlineData* 
pRedlineData, bool bSingl
 
 void RtfAttributeOutput::EndRun()
 {
-    if (m_bInURL)
-        EndURL();
     m_aRun->append(SAL_NEWLINE_STRING);
     m_aRun.appendAndClear(m_aRunText);
     if (!m_bSingleEmptyRun && m_bInRun)
@@ -479,23 +477,30 @@ 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)
 {
-    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;
 }
 
@@ -2404,8 +2409,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);
@@ -3245,12 +3248,10 @@ 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_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 8452f73..d10cb92 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -94,7 +94,7 @@ public:
     virtual bool StartURL(const OUString& rUrl, const OUString& rTarget) 
SAL_OVERRIDE;
 
     /// Output URL end.
-    virtual bool EndURL() SAL_OVERRIDE;
+    virtual bool EndURL(bool isAtEndOfParagraph) SAL_OVERRIDE;
 
     virtual void FieldVanish(const OUString& rTxt, ww::eField eType) 
SAL_OVERRIDE;
 
@@ -573,11 +573,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;
 
@@ -589,8 +584,6 @@ private:
 
     bool m_bInRun;
 
-    bool m_bInURL;
-
     /// Maps ID's to postit fields, used in atrfstart/end and atnref.
     std::map<sal_uInt16, const SwPostItField*> m_aPostitFields;
 
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index b2e33e6..a7bef43 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1155,7 +1155,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 9b662f9..9f2af01 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1071,7 +1071,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 )
@@ -1213,7 +1213,7 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 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 9f2d09a..53e9eb5 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -511,7 +511,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 e86ce67..8e8f392 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 ) 
SAL_OVERRIDE;
 
     /// Output URL end.
-    virtual bool EndURL() SAL_OVERRIDE;
+    virtual bool EndURL(bool) SAL_OVERRIDE;
 
     virtual void FieldVanish( const OUString& rTxt, ww::eField eType ) 
SAL_OVERRIDE;
 
commit b51d9c633c2b5d03478be7b175fdbea367376c72
Author: Michael Stahl <mst...@redhat.com>
Date:   Thu Jun 26 17:09:07 2014 +0200

    sw: avoid calling convertToString() with unsupported encodings
    
    Change-Id: If0b589c884cd306ca7c94d3366af66276a120176

diff --git a/sw/source/filter/ww8/writerwordglue.cxx 
b/sw/source/filter/ww8/writerwordglue.cxx
index 56f9284..ddc8313 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -728,7 +728,8 @@ namespace sw
             sal_uInt8 nRet =
                 rtl_getBestWindowsCharsetFromTextEncoding(eTextEncoding);
             rtl_TextEncoding enc2 = 
rtl_getTextEncodingFromWindowsCharset(nRet);
-            if (!(CanEncode(rFontName, enc2) && CanEncode(rAltName, enc2)))
+            if (!rtl_isOctetTextEncoding(enc2) /* check to avoid asserts */ ||
+                !(CanEncode(rFontName, enc2) && CanEncode(rAltName, enc2)))
             {
                 static struct { rtl_TextEncoding enc; sal_uInt8 charset; }
                 const s_fallbacks [] = {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to