diff options
| author | Michael Stahl <mstahl@redhat.com> | 2014-12-16 23:45:15 +0100 |
|---|---|---|
| committer | Michael Stahl <mstahl@redhat.com> | 2014-12-16 23:56:45 +0100 |
| commit | 6631b46dfb894ff8f2bbb09c92f1786c756ee352 (patch) | |
| tree | b6a0ac0ca0aa858c4c2a9d7891df95314343f710 | |
| parent | 6b2cb891eb415f94ad54237e6e8c42acef513f45 (diff) | |
(related fdo#84685): writerfilter: RTF import: support \tc TOC entry
Change-Id: Icda252e1f092707728d3a24df50fba7080e759bb
(cherry picked from commit 1dd1dfc152c7cbeb374fe4f38b08c6af9cef2c06)
| -rw-r--r-- | sw/qa/extras/rtfimport/data/fdo84685.rtf | 2 | ||||
| -rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 8 | ||||
| -rw-r--r-- | writerfilter/source/rtftok/rtfcontrolwords.hxx | 1 | ||||
| -rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 10 |
4 files changed, 20 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo84685.rtf b/sw/qa/extras/rtfimport/data/fdo84685.rtf index 431dbd3fea22..af73b1a57bf0 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 fafb2b07d9d0..e6a36196875c 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 ac45593ac7ef..f2f8ad51a81c 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 68fcbfda0fcf..1ae1986f3e13 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); |
