[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.3' - 4 commits - sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Sat Jan 24 07:04:37 PST 2015


 sw/qa/extras/rtfexport/data/abi10039.odt       |binary
 sw/qa/extras/rtfexport/data/fdo32613.odt       |binary
 sw/qa/extras/rtfexport/rtfexport.cxx           |   15 +++
 sw/qa/extras/rtfimport/data/fdo74229.rtf       |   33 +++++++
 sw/qa/extras/rtfimport/data/fdo79959.rtf       |    4 
 sw/qa/extras/rtfimport/rtfimport.cxx           |   16 +++
 sw/source/filter/ww8/rtfattributeoutput.cxx    |  109 +++++++++++++++++++++----
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   16 +++
 8 files changed, 174 insertions(+), 19 deletions(-)

New commits:
commit f41efa94a0be35f9cae65d6a44246a5b13865122
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Aug 29 17:40:51 2014 +0200

    fdo#79959 RTF import: trim whitespace around style names
    
    Change-Id: Id23cbd62b057442c577fef124a5705e4d551076f
    (cherry picked from commit 305ecd1848a802a6c43ecc6e76f4c6bc36a03418)

diff --git a/sw/qa/extras/rtfimport/data/fdo79959.rtf b/sw/qa/extras/rtfimport/data/fdo79959.rtf
new file mode 100644
index 0000000..231f39a
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo79959.rtf
@@ -0,0 +1,4 @@
+{\rtf1\ansi\ansicpg1251\deff0\deflang1049{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
+{\stylesheet{\s0  Test;}}
+\viewkind4\uc1\pard\s0\slmult1\lang9\f0\fs22 Hello world!\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index f0f64fd..1c8f15d 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2096,6 +2096,12 @@ DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo79959, "fdo79959.rtf")
+{
+    // This was false, as the style was imported as " Test", i.e. no whitespace stripping.
+    CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(getStyles("ParagraphStyles")->hasByName("Test")));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1a40e06..24183aa 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1184,8 +1184,9 @@ void RTFDocumentImpl::text(OUString& rString)
             case DESTINATION_STYLEENTRY:
                 if (m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type))
                 {
-                    m_aStyleNames[m_nCurrentStyleIndex] = aName;
-                    RTFValue::Pointer_t pValue(new RTFValue(aName));
+                    // Word strips whitespace around style names.
+                    m_aStyleNames[m_nCurrentStyleIndex] = aName.trim();
+                    RTFValue::Pointer_t pValue(new RTFValue(aName.trim()));
                     m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_styleId, pValue);
                     m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);
 
commit cfc8d88a542eaa6613a05f03e2b32b9fda7be20d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 5 10:36:08 2014 +0200

    abi#10039 RTF export: support page-anchored frames
    
    Change-Id: I71c961799f76446cdf24faeba86f881ae02ffe3b
    (cherry picked from commit 845fb7bf6753ec9582d0b1d1c9b4276aa9e6c65e)

diff --git a/sw/qa/extras/rtfexport/data/abi10039.odt b/sw/qa/extras/rtfexport/data/abi10039.odt
new file mode 100644
index 0000000..4d5dde5
Binary files /dev/null and b/sw/qa/extras/rtfexport/data/abi10039.odt differ
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 54eca8a..d405b91 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -679,6 +679,12 @@ DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt")
     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
 }
 
+DECLARE_RTFEXPORT_TEST(testAbi10039, "abi10039.odt")
+{
+    // Make sure we don't just crash on export, and additionally the shape should not be inline (as it's at-page anchored originally).
+    CPPUNIT_ASSERT(text::TextContentAnchorType_AS_CHARACTER != getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index c18eebe..20a49e2 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3698,8 +3698,16 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
         aRendered.Height() = rS.GetHeight();
     }
 
-    const SwPosition* pAnchor = pFlyFrmFmt->GetAnchor().GetCntntAnchor();
-    sw::Frame aFrame(*pFlyFrmFmt, *pAnchor);
+    sw::Frame* pFrame = 0;
+    for (sw::FrameIter it = m_rExport.maFrames.begin(); it != m_rExport.maFrames.end(); ++it)
+    {
+        if (pFlyFrmFmt == &it->GetFrmFmt())
+        {
+            pFrame = &(*it);
+            break;
+        }
+    }
+    assert(pFrame);
 
     /*
        If the graphic is not of type WMF then we will have to store two
@@ -3708,7 +3716,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
        a wmf already then we don't need any such wrapping
        */
     bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
-    if (aFrame.IsInline())
+    if (pFrame->IsInline())
     {
         if (!bIsWMF)
             m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
@@ -3717,9 +3725,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     {
         m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHP "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
         m_pFlyFrameSize = &aRendered;
-        m_rExport.mpParentFrame = &aFrame;
+        m_rExport.mpParentFrame = pFrame;
         m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = true;
-        m_rExport.OutputFormat(aFrame.GetFrmFmt(), false, false, true);
+        m_rExport.OutputFormat(pFrame->GetFrmFmt(), false, false, true);
         m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = false;
         m_rExport.mpParentFrame = NULL;
         m_pFlyFrameSize = 0;
@@ -3740,7 +3748,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
         m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{" OOO_STRING_SVTOOLS_RTF_SN " pib" "}{" OOO_STRING_SVTOOLS_RTF_SV " ");
     }
 
-    bool bWritePicProp = aFrame.IsInline();
+    bool bWritePicProp = pFrame->IsInline();
     if (pBLIPType)
         ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm(), bWritePicProp);
     else
@@ -3755,7 +3763,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
         ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm(), bWritePicProp);
     }
 
-    if (aFrame.IsInline())
+    if (pFrame->IsInline())
     {
         if (!bIsWMF)
         {
commit a97a783a302232701245c3ac6d6bd9f5ce7d664e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Aug 29 14:26:11 2014 +0200

    fdo#32613 RTF export: implemented anchored picture export
    
    RTF originally didn't support anchored pictures: they were always
    inline. Then it was invented that pictures can be exported anchored, if
    they are in fact shapes, but their "pib" property is set to the hexdump
    of the picture contents.
    
    The RTF importer handled this situation for quite some time, but not the
    exporter -- this commit implements that.
    
    (cherry picked from commit cb01957aa0ac3caea8e87522116086ac256d4ee2)
    
    Conflicts:
    	sw/qa/extras/inc/swmodeltestbase.hxx
    
    Change-Id: I173ad9f4f2e24620508ca63c0b892b7d5da4e5b2

diff --git a/sw/qa/extras/rtfexport/data/fdo32613.odt b/sw/qa/extras/rtfexport/data/fdo32613.odt
new file mode 100644
index 0000000..bd1e950
Binary files /dev/null and b/sw/qa/extras/rtfexport/data/fdo32613.odt differ
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 83b9aba..54eca8a 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -17,11 +17,12 @@
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/XFootnotesSupplier.hpp>
 #include <com/sun/star/text/XPageCursor.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
-#include <com/sun/star/text/RelOrientation.hpp>
 
 #include <vcl/svapp.hxx>
 
@@ -672,6 +673,12 @@ DECLARE_RTFEXPORT_TEST(testFdo82006, "fdo82006.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), getProperty<sal_Int32>(getParagraph(0), "ParaBottomMargin"));
 }
 
+DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt")
+{
+    // This was AS_CHARACTER, RTF export did not support writing anchored pictures.
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 1ac0795..c18eebe 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -2847,6 +2847,37 @@ void RtfAttributeOutput::FormatSurround(const SwFmtSurround& rSurround)
         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
         m_aRunText->append((sal_Int32) aMC.GetValue());
     }
+    else if (m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax)
+    {
+        // See DocxSdrExport::startDMLAnchorInline() for SwFmtSurround -> WR / WRK mappings.
+        sal_Int32 nWr = -1;
+        boost::optional<sal_Int32> oWrk;
+        switch (rSurround.GetValue())
+        {
+        case SURROUND_NONE:
+            nWr = 1; // top and bottom
+            break;
+        case SURROUND_THROUGHT:
+            nWr = 3; // none
+            break;
+        case SURROUND_PARALLEL:
+            nWr = 2; // around
+            oWrk = 0; // both sides
+            break;
+        case SURROUND_IDEAL:
+        default:
+            nWr = 2; // around
+            oWrk = 3; // largest
+            break;
+        }
+        m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPWR);
+        m_rExport.OutLong(nWr);
+        if (oWrk)
+        {
+            m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPWRK);
+            m_rExport.OutLong(*oWrk);
+        }
+    }
 }
 
 void RtfAttributeOutput::FormatVertOrientation(const SwFmtVertOrient& rFlyVert)
@@ -3435,7 +3466,7 @@ static void lcl_AppendSP(OStringBuffer& rBuffer,
 
 static OString ExportPICT(const SwFlyFrmFmt* pFlyFrmFmt, const Size& rOrig, const Size& rRendered, const Size& rMapped,
                           const SwCropGrf& rCr, const char* pBLIPType, const sal_uInt8* pGraphicAry,
-                          unsigned long nSize, const RtfExport& rExport, SvStream* pStream = 0)
+                          unsigned long nSize, const RtfExport& rExport, SvStream* pStream = 0, bool bWritePicProp = true)
 {
     OStringBuffer aRet;
     if (pBLIPType && nSize && pGraphicAry)
@@ -3444,7 +3475,7 @@ static OString ExportPICT(const SwFlyFrmFmt* pFlyFrmFmt, const Size& rOrig, cons
 
         aRet.append("{" OOO_STRING_SVTOOLS_RTF_PICT);
 
-        if (pFlyFrmFmt)
+        if (pFlyFrmFmt && bWritePicProp)
         {
             OUString sDescription = pFlyFrmFmt->GetObjDescription();
             //write picture properties - wzDescription at first
@@ -3667,6 +3698,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
         aRendered.Height() = rS.GetHeight();
     }
 
+    const SwPosition* pAnchor = pFlyFrmFmt->GetAnchor().GetCntntAnchor();
+    sw::Frame aFrame(*pFlyFrmFmt, *pAnchor);
+
     /*
        If the graphic is not of type WMF then we will have to store two
        graphics, one in the native format wrapped in shppict, and the other in
@@ -3674,11 +3708,41 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
        a wmf already then we don't need any such wrapping
        */
     bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
-    if (!bIsWMF)
-        m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+    if (aFrame.IsInline())
+    {
+        if (!bIsWMF)
+            m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+    }
+    else
+    {
+        m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHP "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST);
+        m_pFlyFrameSize = &aRendered;
+        m_rExport.mpParentFrame = &aFrame;
+        m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = true;
+        m_rExport.OutputFormat(aFrame.GetFrmFmt(), false, false, true);
+        m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = false;
+        m_rExport.mpParentFrame = NULL;
+        m_pFlyFrameSize = 0;
 
+        std::vector< std::pair<OString, OString> > aFlyProperties;
+        aFlyProperties.push_back(std::make_pair<OString, OString>("shapeType", OString::number(ESCHER_ShpInst_PictureFrame)));
+        aFlyProperties.push_back(std::make_pair<OString, OString>("wzDescription", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjDescription(), m_rExport.eCurrentEncoding)));
+        aFlyProperties.push_back(std::make_pair<OString, OString>("wzName", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjTitle(), m_rExport.eCurrentEncoding)));
+        for (size_t i = 0; i < aFlyProperties.size(); ++i)
+        {
+            m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{");
+            m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SN " ");
+            m_rExport.Strm().WriteCharPtr(aFlyProperties[i].first.getStr());
+            m_rExport.Strm().WriteCharPtr("}{" OOO_STRING_SVTOOLS_RTF_SV " ");
+            m_rExport.Strm().WriteCharPtr(aFlyProperties[i].second.getStr());
+            m_rExport.Strm().WriteCharPtr("}}");
+        }
+        m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{" OOO_STRING_SVTOOLS_RTF_SN " pib" "}{" OOO_STRING_SVTOOLS_RTF_SV " ");
+    }
+
+    bool bWritePicProp = aFrame.IsInline();
     if (pBLIPType)
-        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm());
+        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm(), bWritePicProp);
     else
     {
         aStream.Seek(0);
@@ -3688,24 +3752,29 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
         nSize = aStream.Tell();
         pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm());
+        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm(), bWritePicProp);
     }
 
-    if (!bIsWMF)
+    if (aFrame.IsInline())
     {
-        m_rExport.Strm().WriteCharPtr("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
+        if (!bIsWMF)
+        {
+            m_rExport.Strm().WriteCharPtr("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
 
-        aStream.Seek(0);
-        GraphicConverter::Export(aStream, rGraphic, CVT_WMF);
-        pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
-        aStream.Seek(STREAM_SEEK_TO_END);
-        nSize = aStream.Tell();
-        pGraphicAry = (sal_uInt8*)aStream.GetData();
+            aStream.Seek(0);
+            GraphicConverter::Export(aStream, rGraphic, CVT_WMF);
+            pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
+            aStream.Seek(STREAM_SEEK_TO_END);
+            nSize = aStream.Tell();
+            pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm());
+            ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm());
 
-        m_rExport.Strm().WriteChar('}');
+            m_rExport.Strm().WriteChar('}');
+        }
     }
+    else
+        m_rExport.Strm().WriteCharPtr("}}}}"); // Close SV, SP, SHPINST and SHP.
 
     if (bSwapped)
         const_cast<Graphic&>(rGraphic).SwapOut();
commit f23c0e1633fb39e78a3a498ce86492c82d7fa7a0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Aug 28 15:45:21 2014 +0200

    fdo#74229 import RTF_TRGAPH
    
    Regression from commit c4b91ae3178011c66c76c711c1a6469ba658872e
    (fdo#55525 import RTF_TRLEFT, 2012-11-13).
    
    Change-Id: I90f2c6399cfaf8399de0cf3488a23af6cc84710d
    (cherry picked from commit 54bdfe0a891f2119bc35c5d82ecbc94c8cb13c0b)

diff --git a/sw/qa/extras/rtfimport/data/fdo74229.rtf b/sw/qa/extras/rtfimport/data/fdo74229.rtf
new file mode 100644
index 0000000..f425f08
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo74229.rtf
@@ -0,0 +1,33 @@
+{\rtf1\ansi\ansicpg1252\uc1\deff0\deflang1036
+{\fonttbl
+{\f1\fmodern\fprq1\fcharset0 Courier new;}
+}
+{\colortbl;
+\red0\green0\blue0;
+\red0\green0\blue255;
+\red0\green255\blue255;
+\red0\green255\blue0;
+\red255\green0\blue255;
+\red255\green0\blue0;
+\red255\green255\blue0;
+\red255\green255\blue255;
+\red0\green0\blue128;
+\red0\green128\blue128;
+\red0\green128\blue0;
+\red128\green0\blue128;
+\red128\green0\blue0;
+\red128\green128\blue0;
+\red128\green128\blue128;
+\red192\green192\blue192;
+}
+\pard
+\trowd\trkeep\trql\trgaph67
+\clbrdrb\brdrs\brdrw10\brdrcf1\cltxlrtb\clvertalt\clcbpat8\cellx731
+\clbrdrb\brdrs\brdrw10\brdrcf1\cltxlrtb\clvertalt\clcbpat8\cellx1462
+\pard\plain\intbl\b\sb67\sa67\qc\f1\fs16\cf1
+{A1\cell}
+\pard\plain\intbl\sb67\sa67\qr\f1\fs16\cf1
+{A2\cell}
+{\row}
+\pard\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index e2b9030..f0f64fd 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2086,6 +2086,16 @@ DECLARE_RTFIMPORT_TEST(testFdo86750, "fdo86750.rtf")
     CPPUNIT_ASSERT_EQUAL(OUString("#anchor"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf")
+{
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    // This was 0, due to ignoring RTF_TRGAPH.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(67)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 447493c..1a40e06 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -4617,6 +4617,17 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     case RTF_OUTLINELEVEL:
         m_aStates.top().aParagraphSprms.set(NS_ooxml::LN_CT_PPrBase_outlineLvl, pIntValue);
         break;
+    case RTF_TRGAPH:
+        // Half of the space between the cells of a table row: default left/right table cell margin.
+        if (nParam > 0)
+        {
+            RTFSprms aAttributes;
+            aAttributes.set(NS_ooxml::LN_CT_TblWidth_type, RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa)));
+            aAttributes.set(NS_ooxml::LN_CT_TblWidth_w, pIntValue);
+            lcl_putNestedSprm(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_left, RTFValue::Pointer_t(new RTFValue(aAttributes)));
+            lcl_putNestedSprm(m_aStates.top().aTableRowSprms, NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_right, RTFValue::Pointer_t(new RTFValue(aAttributes)));
+        }
+        break;
     default:
     {
         SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");


More information about the Libreoffice-commits mailing list