summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-12-16 23:17:28 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-18 15:46:57 +0000
commitd90c5fbf67dc76c18cf703267139e7ad6b26564b (patch)
tree49233340faf9a864f27cd87dcc1454f4d835428c
parent99b3e159726b51537563790e8f73b43a88970e13 (diff)
fdo#84685: writerfilter: RTF import: support \xe index entry
(cherry picked from commit f14e6e06b9e3c82c267649d63512a3538e5ee2f5) (related fdo#84685): writerfilter: RTF import: support \tc TOC entry (cherry picked from commit 1dd1dfc152c7cbeb374fe4f38b08c6af9cef2c06) fix Windows build (cherry picked from commit acfd640fd8547d3275c5db714b88d52b3fe7c4d5) Change-Id: Ia957541a5997961aa86b2eb8537ebd29d3092691 Reviewed-on: https://gerrit.libreoffice.org/13508 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo84685.rtf7
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx20
-rw-r--r--writerfilter/source/rtftok/rtfcontrolwords.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx26
4 files changed, 55 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo84685.rtf b/sw/qa/extras/rtfimport/data/fdo84685.rtf
new file mode 100644
index 000000000000..af73b1a57bf0
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo84685.rtf
@@ -0,0 +1,7 @@
+{\rtf1\ansi\ansicpg1252\uc1
+\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 721fd73f7367..e2b9030aabf2 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -30,6 +30,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>
@@ -2023,6 +2024,25 @@ 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"));
+ // 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")
{
// 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 f89e4cfe3860..8f56e8806097 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -148,6 +148,8 @@ enum RTFDestinationState
DESTINATION_BACKGROUND,
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 b61f5a764074..447493cfeacf 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1248,6 +1248,8 @@ void RTFDocumentImpl::text(OUString& rString)
case DESTINATION_MSUPHIDE:
case DESTINATION_MTYPE:
case DESTINATION_MGROW:
+ case DESTINATION_INDEXENTRY:
+ case DESTINATION_TOCENTRY:
m_aStates.top().pDestinationText->append(rString);
break;
default:
@@ -1716,6 +1718,13 @@ 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_TC:
+ case RTF_TCN:
+ m_aStates.top().nDestinationState = DESTINATION_TOCENTRY;
+ break;
case RTF_REVTBL:
m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
break;
@@ -5047,6 +5056,23 @@ int RTFDocumentImpl::popState()
break; // not for nested group
Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[m_aStates.top().pDestinationText->makeStringAndClear()]));
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...
+ OUString const field = OUString::createFromAscii(
+ (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);
+ // no result
+ singleChar(0x15);
+ }
+ break;
case DESTINATION_FORMFIELDNAME:
{
if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText)