[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/qa writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Jun 15 08:12:03 PDT 2012


 sw/qa/extras/rtfexport/data/fdo50087.rtf       |    8 ++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx           |   13 +++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   18 ++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    5 ++++-
 4 files changed, 43 insertions(+), 1 deletion(-)

New commits:
commit 085c5e467a956378a1b6ba9e0255a59915320276
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 15 16:15:07 2012 +0200

    fdo#50087 fix RTF import of Title, Subject, Comments document properties
    
    Change-Id: I3358fad4949c2c21ecf63983a36b7c8428df9f06

diff --git a/sw/qa/extras/rtfexport/data/fdo50087.rtf b/sw/qa/extras/rtfexport/data/fdo50087.rtf
new file mode 100644
index 0000000..f3716d8
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo50087.rtf
@@ -0,0 +1,8 @@
+{\rtf1
+{\info
+{\title Title}
+{\subject Subject}
+{\doccomm First line.\'0aSecond line.}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index a78fb9f..6df0aec 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -47,6 +47,7 @@ public:
     void testFdo38176();
     void testFdo49683();
     void testFdo44174();
+    void testFdo50087();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -54,6 +55,7 @@ public:
     CPPUNIT_TEST(testFdo38176);
     CPPUNIT_TEST(testFdo49683);
     CPPUNIT_TEST(testFdo44174);
+    CPPUNIT_TEST(testFdo50087);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -116,6 +118,17 @@ void Test::testFdo44174()
     CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
 }
 
+void Test::testFdo50087()
+{
+    roundtrip("fdo50087.rtf");
+
+    uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
+    CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
+    CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
+    CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a01e08d..9f45be3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -965,6 +965,9 @@ void RTFDocumentImpl::text(OUString& rString)
         case DESTINATION_FALT:
         case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
         case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
+        case DESTINATION_TITLE:
+        case DESTINATION_SUBJECT:
+        case DESTINATION_DOCCOMM:
             m_aStates.top().aDestinationText.append(rString);
             break;
         case DESTINATION_EQINSTRUCTION:
@@ -1374,6 +1377,15 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_PNTXTB:
             m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
             break;
+        case RTF_TITLE:
+            m_aStates.top().nDestinationState = DESTINATION_TITLE;
+            break;
+        case RTF_SUBJECT:
+            m_aStates.top().nDestinationState = DESTINATION_SUBJECT;
+            break;
+        case RTF_DOCCOMM:
+            m_aStates.top().nDestinationState = DESTINATION_DOCCOMM;
+            break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
             // Make sure we skip destinations (even without \*) till we don't handle them
@@ -3272,6 +3284,12 @@ int RTFDocumentImpl::popState()
         m_xDocumentProperties->setKeywords(comphelper::string::convertCommaSeparated(m_aStates.top().aDestinationText.makeStringAndClear()));
     else if (m_aStates.top().nDestinationState == DESTINATION_COMMENT && m_xDocumentProperties.is())
         m_xDocumentProperties->setGenerator(m_aStates.top().aDestinationText.makeStringAndClear());
+    else if (m_aStates.top().nDestinationState == DESTINATION_TITLE && m_xDocumentProperties.is())
+        m_xDocumentProperties->setTitle(m_aStates.top().aDestinationText.makeStringAndClear());
+    else if (m_aStates.top().nDestinationState == DESTINATION_SUBJECT && m_xDocumentProperties.is())
+        m_xDocumentProperties->setSubject(m_aStates.top().aDestinationText.makeStringAndClear());
+    else if (m_aStates.top().nDestinationState == DESTINATION_DOCCOMM && m_xDocumentProperties.is())
+        m_xDocumentProperties->setDescription(m_aStates.top().aDestinationText.makeStringAndClear());
     else if (m_aStates.top().nDestinationState == DESTINATION_OPERATOR
             || m_aStates.top().nDestinationState == DESTINATION_COMPANY)
     {
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 9bb994d..5756b5a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -114,7 +114,10 @@ namespace writerfilter {
             DESTINATION_DRAWINGOBJECT,
             DESTINATION_PARAGRAPHNUMBERING,
             DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE,
-            DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER
+            DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER,
+            DESTINATION_TITLE,
+            DESTINATION_SUBJECT,
+            DESTINATION_DOCCOMM
         };
 
         enum RTFBorderState


More information about the Libreoffice-commits mailing list