Kaydet (Commit) 629001d4 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#50087 fix RTF import of Title, Subject, Comments document properties

Change-Id: I3358fad4949c2c21ecf63983a36b7c8428df9f06
üst fa200682
{\rtf1
{\info
{\title Title}
{\subject Subject}
{\doccomm First line.\'0aSecond line.}
}
\par
}
...@@ -47,6 +47,7 @@ public: ...@@ -47,6 +47,7 @@ public:
void testFdo38176(); void testFdo38176();
void testFdo49683(); void testFdo49683();
void testFdo44174(); void testFdo44174();
void testFdo50087();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -54,6 +55,7 @@ public: ...@@ -54,6 +55,7 @@ public:
CPPUNIT_TEST(testFdo38176); CPPUNIT_TEST(testFdo38176);
CPPUNIT_TEST(testFdo49683); CPPUNIT_TEST(testFdo49683);
CPPUNIT_TEST(testFdo44174); CPPUNIT_TEST(testFdo44174);
CPPUNIT_TEST(testFdo50087);
#endif #endif
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -116,6 +118,17 @@ void Test::testFdo44174() ...@@ -116,6 +118,17 @@ void Test::testFdo44174()
CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue); 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_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -968,6 +968,9 @@ void RTFDocumentImpl::text(OUString& rString) ...@@ -968,6 +968,9 @@ void RTFDocumentImpl::text(OUString& rString)
case DESTINATION_FALT: case DESTINATION_FALT:
case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER: case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE: case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
case DESTINATION_TITLE:
case DESTINATION_SUBJECT:
case DESTINATION_DOCCOMM:
m_aStates.top().aDestinationText.append(rString); m_aStates.top().aDestinationText.append(rString);
break; break;
case DESTINATION_EQINSTRUCTION: case DESTINATION_EQINSTRUCTION:
...@@ -1377,6 +1380,15 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) ...@@ -1377,6 +1380,15 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_PNTXTB: case RTF_PNTXTB:
m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE; m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
break; 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: default:
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'"); 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 // Make sure we skip destinations (even without \*) till we don't handle them
...@@ -3275,6 +3287,12 @@ int RTFDocumentImpl::popState() ...@@ -3275,6 +3287,12 @@ int RTFDocumentImpl::popState()
m_xDocumentProperties->setKeywords(comphelper::string::convertCommaSeparated(m_aStates.top().aDestinationText.makeStringAndClear())); m_xDocumentProperties->setKeywords(comphelper::string::convertCommaSeparated(m_aStates.top().aDestinationText.makeStringAndClear()));
else if (m_aStates.top().nDestinationState == DESTINATION_COMMENT && m_xDocumentProperties.is()) else if (m_aStates.top().nDestinationState == DESTINATION_COMMENT && m_xDocumentProperties.is())
m_xDocumentProperties->setGenerator(m_aStates.top().aDestinationText.makeStringAndClear()); 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 else if (m_aStates.top().nDestinationState == DESTINATION_OPERATOR
|| m_aStates.top().nDestinationState == DESTINATION_COMPANY) || m_aStates.top().nDestinationState == DESTINATION_COMPANY)
{ {
......
...@@ -114,7 +114,10 @@ namespace writerfilter { ...@@ -114,7 +114,10 @@ namespace writerfilter {
DESTINATION_DRAWINGOBJECT, DESTINATION_DRAWINGOBJECT,
DESTINATION_PARAGRAPHNUMBERING, DESTINATION_PARAGRAPHNUMBERING,
DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE, DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE,
DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER,
DESTINATION_TITLE,
DESTINATION_SUBJECT,
DESTINATION_DOCCOMM
}; };
enum RTFBorderState enum RTFBorderState
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment