[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Sun Jan 5 04:06:09 PST 2014


 sw/qa/extras/rtfimport/data/fdo68787.rtf       |    9 +++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |    7 +++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   18 +++++++++++++++++-
 writerfilter/source/rtftok/rtflistener.hxx     |    1 +
 4 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit e1afe4318787425dc40f2d0b1f02fa17e925c8da
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Jan 5 12:52:42 2014 +0100

    RTF import: handle RTF_FTNSEP and RTF_CHFTNSEP
    
    Commit 330b860205c7ba69dd6603f65324d0f89ad9cd5f (fdo#68787 DOCX import:
    handle when w:separator is missing for footnotes, 2013-09-04) disabled
    footnote separator by default in dmapper, as the OOXML tokenizer always
    provided a uFtnEdnSep in case a separator was wanted.
    
    Let the RTF tokenizer do the same, this way we're in sync with Word
    again: if RTF_CHFTNSEP is in RTF_FTNSEP, then we show the separator,
    otherwise we don't.
    
    Change-Id: I74b46c5d71227682e093695336dc9eb6fde22121

diff --git a/sw/qa/extras/rtfimport/data/fdo68787.rtf b/sw/qa/extras/rtfimport/data/fdo68787.rtf
new file mode 100644
index 0000000..4c8a68f
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo68787.rtf
@@ -0,0 +1,9 @@
+{\rtf1
+\ftnbj
+{\*\ftnsep \chftnsep \par}
+\pard\plain
+This will have a separator
+\chftn 
+{\footnote \chftn Footnote.}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a5ab93d..0ad5177 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1405,6 +1405,13 @@ DECLARE_RTFIMPORT_TEST(testBackground, "background.rtf")
     CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "Opaque")));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo68787, "fdo68787.rtf")
+{
+    uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+    // This was 0, the 'lack of \chftnsep' <-> '0 line width' mapping was missing in the RTF tokenizer.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
+}
+
 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 b8506c5..30702f6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1739,6 +1739,10 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
                 m_aStates.top().bInShapeGroup = true;
             }
             break;
+        case RTF_FTNSEP:
+            m_aStates.top().nDestinationState = DESTINATION_FOOTNOTESEPARATOR;
+            m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_FtnEdn_type, RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_separator)));
+            break;
         default:
             SAL_INFO("writerfilter", "TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
             // Make sure we skip destinations (even without \*) till we don't handle them
@@ -1806,7 +1810,13 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                     runProps();
                 if (!m_aStates.top().pCurrentBuffer)
                 {
-                    parBreak();
+                    if (m_aStates.top().nDestinationState == DESTINATION_FOOTNOTESEPARATOR)
+                    {
+                        static const sal_Unicode uCR = 0xd;
+                        Mapper().utext((const sal_uInt8*)&uCR, 1);
+                    }
+                    else
+                        parBreak();
                     // Not in table? Reset max width.
                     m_nCellxMax = 0;
                 }
@@ -2020,6 +2030,12 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 singleChar(0x15);
             }
             break;
+        case RTF_CHFTNSEP:
+            {
+                static const sal_Unicode uFtnEdnSep = 0x3;
+                Mapper().utext((const sal_uInt8*)&uFtnEdnSep, 1);
+            }
+            break;
         default:
             {
                 SAL_INFO("writerfilter", "TODO handle symbol '" << lcl_RtfToString(nKeyword) << "'");
diff --git a/writerfilter/source/rtftok/rtflistener.hxx b/writerfilter/source/rtftok/rtflistener.hxx
index 616da4b..0e07187 100644
--- a/writerfilter/source/rtftok/rtflistener.hxx
+++ b/writerfilter/source/rtftok/rtflistener.hxx
@@ -150,6 +150,7 @@ namespace writerfilter {
             DESTINATION_LFOLEVEL,
             DESTINATION_BACKGROUND,
             DESTINATION_SHAPEGROUP,
+            DESTINATION_FOOTNOTESEPARATOR,
         };
 
         enum RTFErrors


More information about the Libreoffice-commits mailing list