# HG changeset patch
# User Michael Stahl <mst@openoffice.org>
# Date 1303140562 0
# Node ID b2dddb8a0155ccfce5eb3db211076c3cfa5dbc4a
# Parent  17c70429893f2272998d404440df3e79e4493355
rtftok01: writerfilter: ImportFilter.cxx: register rtftok filter

diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
--- a/writerfilter/source/filter/ImportFilter.cxx
+++ b/writerfilter/source/filter/ImportFilter.cxx
@@ -35,12 +35,14 @@
 #include <WriterFilter.hxx>
 #include <doctok/WW8Document.hxx>
 #include <ooxml/OOXMLDocument.hxx>
+#include <rtftok/RTFDocument.hxx>
 #ifdef DEBUG_IMPORT
 #include <iostream>
 #include <osl/process.h>
 #endif
 
 #include <resourcemodel/TagLogger.hxx>
+
 using namespace ::rtl;
 using namespace ::com::sun::star;
 using ::comphelper::MediaDescriptor;
@@ -69,13 +71,31 @@
         MediaDescriptor aMediaDesc( aDescriptor );
         OUString sFilterName = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FILTERNAME(), OUString() );
 
+    writerfilter::dmapper::SourceDocumentType const eType =
+        (m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "writer_MS_Word_2007" ) ) ||
+         m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "writer_MS_Word_2007_Template" ) ))
+        ?  writerfilter::dmapper::DOCUMENT_OOXML
+        : ((m_sFilterName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("writer_RTFtok") ))
+            ? writerfilter::dmapper::DOCUMENT_RTF
+            : writerfilter::dmapper::DOCUMENT_DOC);
+
+
         uno::Reference< io::XInputStream > xInputStream;
         try
         {
+            if (writerfilter::dmapper::DOCUMENT_RTF == eType)
+            {
+                aMediaDesc.addInputStream();
+                aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ]
+                    >>= xInputStream;
+            }
+            else
+            {
             // use the oox.core.FilterDetect implementation to extract the decrypted ZIP package
             uno::Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
             ::oox::core::FilterDetect aDetector( xFactory );
             xInputStream = aDetector.extractUnencryptedPackage( aMediaDesc );
+            }
         }
         catch( uno::Exception& )
         {
@@ -101,13 +121,16 @@
         dmapperLogger->startDocument();
 #endif
 
-    writerfilter::dmapper::SourceDocumentType eType =
-        (m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "writer_MS_Word_2007" ) ) ||
-         m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "writer_MS_Word_2007_Template" ) )) ?
-                writerfilter::dmapper::DOCUMENT_OOXML : writerfilter::dmapper::DOCUMENT_DOC;
     writerfilter::Stream::Pointer_t pStream(new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, eType));
     //create the tokenizer and domain mapper
-    if( eType == writerfilter::dmapper::DOCUMENT_OOXML )
+    if (writerfilter::dmapper::DOCUMENT_RTF == eType)
+    {
+        writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
+               writerfilter::rtftok::RTFDocumentFactory::createDocument(
+                   xInputStream) );
+        pDocument->resolve(*pStream);
+    }
+    else if (eType == writerfilter::dmapper::DOCUMENT_OOXML)
     {
         writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream = writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext, xInputStream);
         writerfilter::ooxml::OOXMLDocument::Pointer_t pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream));
diff --git a/writerfilter/util/makefile.mk b/writerfilter/util/makefile.mk
--- a/writerfilter/util/makefile.mk
+++ b/writerfilter/util/makefile.mk
@@ -42,6 +42,7 @@
 LIB1FILES=  \
     $(SLB)$/ooxml.lib \
     $(SLB)$/doctok.lib \
+    $(SLB)$/rtftok.lib \
 	$(SLB)$/resourcemodel.lib \
     $(SLB)$/dmapper.lib \
     $(SLB)$/filter.lib
