[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - 2 commits - sw/qa writerfilter/source

Michael Stahl mstahl at redhat.com
Tue Dec 16 15:01:54 PST 2014


 sw/qa/extras/rtfimport/data/fdo84685.rtf       |    7 ++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   20 +++++++++++++++++++
 writerfilter/source/rtftok/rtfcontrolwords.hxx |    2 +
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   26 +++++++++++++++++++++++++
 4 files changed, 55 insertions(+)

New commits:
commit 6631b46dfb894ff8f2bbb09c92f1786c756ee352
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Dec 16 23:45:15 2014 +0100

    (related fdo#84685): writerfilter: RTF import: support \tc TOC entry
    
    Change-Id: Icda252e1f092707728d3a24df50fba7080e759bb
    (cherry picked from commit 1dd1dfc152c7cbeb374fe4f38b08c6af9cef2c06)

diff --git a/sw/qa/extras/rtfimport/data/fdo84685.rtf b/sw/qa/extras/rtfimport/data/fdo84685.rtf
index 431dbd3..af73b1a 100644
--- a/sw/qa/extras/rtfimport/data/fdo84685.rtf
+++ b/sw/qa/extras/rtfimport/data/fdo84685.rtf
@@ -2,4 +2,6 @@
 \pard
 {\v {\xe {\v {\f0\fs20 Key the 1st}}}} Some text
 \par
+{\v {\tc {\v {\f0\fs20 foo}}}} Some text
+\par
 }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index fafb2b0..e6a3619 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2092,6 +2092,14 @@ DECLARE_RTFIMPORT_TEST(testFdo84685, "fdo84685.rtf")
             "DocumentIndexMark"));
     CPPUNIT_ASSERT(xMark.is());
     CPPUNIT_ASSERT_EQUAL(OUString("Key the 1st"), getProperty<OUString>(xMark, "PrimaryKey"));
+    // let's test toc entry too
+    uno::Reference<text::XDocumentIndexMark> xTOCMark(
+        getProperty<uno::Reference<text::XDocumentIndexMark>>(
+            getRun(getParagraph(2), 1),
+            "DocumentIndexMark"));
+    CPPUNIT_ASSERT(xTOCMark.is());
+    uno::Reference<lang::XServiceInfo> xTOCSI(xTOCMark, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xTOCSI->supportsService("com.sun.star.text.ContentIndexMark"));
 }
 
 DECLARE_RTFIMPORT_TEST(testFdo83204, "fdo83204.rtf")
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index ac45593..f2f8ad5 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -150,6 +150,7 @@ enum RTFDestinationState
     DESTINATION_SHAPEGROUP,
     DESTINATION_FOOTNOTESEPARATOR,
     DESTINATION_INDEXENTRY,
+    DESTINATION_TOCENTRY,
 };
 
 enum RTFKeyword
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 68fcbfd..1ae1986 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1262,6 +1262,7 @@ void RTFDocumentImpl::text(OUString& rString)
     case DESTINATION_MTYPE:
     case DESTINATION_MGROW:
     case DESTINATION_INDEXENTRY:
+    case DESTINATION_TOCENTRY:
         m_aStates.top().pDestinationText->append(rString);
         break;
     default:
@@ -1735,6 +1736,10 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_XE:
             m_aStates.top().nDestinationState = DESTINATION_INDEXENTRY;
             break;
+        case RTF_TC:
+        case RTF_TCN:
+            m_aStates.top().nDestinationState = DESTINATION_TOCENTRY;
+            break;
         case RTF_REVTBL:
             m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
             break;
@@ -5203,12 +5208,15 @@ int RTFDocumentImpl::popState()
     }
     break;
     case DESTINATION_INDEXENTRY:
+    case DESTINATION_TOCENTRY:
     {
         if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText)
             break; // not for nested group
         OUString str(m_aStates.top().pDestinationText->makeStringAndClear());
         // dmapper expects this as a field, so let's fake something...
-        str = "XE \"" + str.replaceAll("\"", "\\\"") + "\"";
+        OUString const field(
+            (DESTINATION_INDEXENTRY == aState.nDestinationState) ? "XE" : "TC");
+        str = field + " \"" + str.replaceAll("\"", "\\\"") + "\"";
         singleChar(0x13);
         Mapper().utext(reinterpret_cast<sal_uInt8 const*>(str.getStr()), str.getLength());
         singleChar(0x14);
commit 6b2cb891eb415f94ad54237e6e8c42acef513f45
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Dec 16 23:17:28 2014 +0100

    fdo#84685: writerfilter: RTF import: support \xe index entry
    
    Change-Id: Ia957541a5997961aa86b2eb8537ebd29d3092691
    (cherry picked from commit f14e6e06b9e3c82c267649d63512a3538e5ee2f5)

diff --git a/sw/qa/extras/rtfimport/data/fdo84685.rtf b/sw/qa/extras/rtfimport/data/fdo84685.rtf
new file mode 100644
index 0000000..431dbd3
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo84685.rtf
@@ -0,0 +1,5 @@
+{\rtf1\ansi\ansicpg1252\uc1
+\pard
+{\v {\xe {\v {\f0\fs20 Key the 1st}}}} Some text
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 61a3864..fafb2b0 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/text/SizeType.hpp>
 #include <com/sun/star/text/TableColumnSeparator.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/XDocumentIndexMark.hpp>
 #include <com/sun/star/text/XFootnotesSupplier.hpp>
 #include <com/sun/star/text/XPageCursor.hpp>
 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
@@ -2082,6 +2083,17 @@ DECLARE_RTFIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.rtf")
     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo84685, "fdo84685.rtf")
+{
+    // index mark was not imported
+    uno::Reference<text::XDocumentIndexMark> xMark(
+        getProperty<uno::Reference<text::XDocumentIndexMark>>(
+            getRun(getParagraph(1), 1),
+            "DocumentIndexMark"));
+    CPPUNIT_ASSERT(xMark.is());
+    CPPUNIT_ASSERT_EQUAL(OUString("Key the 1st"), getProperty<OUString>(xMark, "PrimaryKey"));
+}
+
 DECLARE_RTFIMPORT_TEST(testFdo83204, "fdo83204.rtf")
 {
     // This was Standard, \sN was ignored after \bkmkstart and \pard.
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index b55c2f2..ac45593 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -149,6 +149,7 @@ enum RTFDestinationState
     DESTINATION_BACKGROUND,
     DESTINATION_SHAPEGROUP,
     DESTINATION_FOOTNOTESEPARATOR,
+    DESTINATION_INDEXENTRY,
 };
 
 enum RTFKeyword
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 5fb1225..68fcbfd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1261,6 +1261,7 @@ void RTFDocumentImpl::text(OUString& rString)
     case DESTINATION_MSUPHIDE:
     case DESTINATION_MTYPE:
     case DESTINATION_MGROW:
+    case DESTINATION_INDEXENTRY:
         m_aStates.top().pDestinationText->append(rString);
         break;
     default:
@@ -1731,6 +1732,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_BKMKEND:
             m_aStates.top().nDestinationState = DESTINATION_BOOKMARKEND;
             break;
+        case RTF_XE:
+            m_aStates.top().nDestinationState = DESTINATION_INDEXENTRY;
+            break;
         case RTF_REVTBL:
             m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
             break;
@@ -5198,6 +5202,20 @@ int RTFDocumentImpl::popState()
         Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr));
     }
     break;
+    case DESTINATION_INDEXENTRY:
+    {
+        if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText)
+            break; // not for nested group
+        OUString str(m_aStates.top().pDestinationText->makeStringAndClear());
+        // dmapper expects this as a field, so let's fake something...
+        str = "XE \"" + str.replaceAll("\"", "\\\"") + "\"";
+        singleChar(0x13);
+        Mapper().utext(reinterpret_cast<sal_uInt8 const*>(str.getStr()), str.getLength());
+        singleChar(0x14);
+        // no result
+        singleChar(0x15);
+    }
+    break;
     case DESTINATION_FORMFIELDNAME:
     {
         if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText)


More information about the Libreoffice-commits mailing list