Kaydet (Commit) 831b712d authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#49683 implement RTF_KEYWORDS

Use comphelper::string::convertCommaSeparated(), as done in
RtfExport::WriteInfo().

Change-Id: Iad4c3c57cf2e16c7256b9853cb1a6a0843463387
üst f4f526e0
{\rtf1
{\info
{\keywords one, two}
}
\par }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/view/XViewSettingsSupplier.hpp> #include <com/sun/star/view/XViewSettingsSupplier.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <test/bootstrapfixture.hxx> #include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx> #include <unotest/macros_test.hxx>
...@@ -46,11 +47,13 @@ public: ...@@ -46,11 +47,13 @@ public:
virtual void tearDown(); virtual void tearDown();
void testZoom(); void testZoom();
void testFdo38176(); void testFdo38176();
void testFdo49683();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
CPPUNIT_TEST(testZoom); CPPUNIT_TEST(testZoom);
CPPUNIT_TEST(testFdo38176); CPPUNIT_TEST(testFdo38176);
CPPUNIT_TEST(testFdo49683);
#endif #endif
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -127,6 +130,18 @@ void Test::testFdo38176() ...@@ -127,6 +130,18 @@ void Test::testFdo38176()
CPPUNIT_ASSERT_EQUAL(9, getLength()); CPPUNIT_ASSERT_EQUAL(9, getLength());
} }
void Test::testFdo49683()
{
roundtrip("fdo49683.rtf");
uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_defs,rtftok,\ ...@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_defs,rtftok,\
)) ))
$(eval $(call gb_Library_use_libraries,rtftok,\ $(eval $(call gb_Library_use_libraries,rtftok,\
comphelper \
cppu \ cppu \
cppuhelper \ cppuhelper \
msfilter \ msfilter \
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <filter/msfilter/util.hxx> #include <filter/msfilter/util.hxx>
#include <filter/msfilter/escherex.hxx> #include <filter/msfilter/escherex.hxx>
#include <comphelper/string.hxx>
#include <doctok/sprmids.hxx> // NS_sprm namespace #include <doctok/sprmids.hxx> // NS_sprm namespace
#include <doctok/resourceids.hxx> // NS_rtf namespace #include <doctok/resourceids.hxx> // NS_rtf namespace
...@@ -931,6 +932,7 @@ void RTFDocumentImpl::text(OUString& rString) ...@@ -931,6 +932,7 @@ void RTFDocumentImpl::text(OUString& rString)
case DESTINATION_FORMFIELDLIST: case DESTINATION_FORMFIELDLIST:
case DESTINATION_DATAFIELD: case DESTINATION_DATAFIELD:
case DESTINATION_AUTHOR: case DESTINATION_AUTHOR:
case DESTINATION_KEYWORDS:
case DESTINATION_OPERATOR: case DESTINATION_OPERATOR:
case DESTINATION_COMPANY: case DESTINATION_COMPANY:
case DESTINATION_COMMENT: case DESTINATION_COMMENT:
...@@ -1306,6 +1308,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) ...@@ -1306,6 +1308,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_AUTHOR: case RTF_AUTHOR:
m_aStates.top().nDestinationState = DESTINATION_AUTHOR; m_aStates.top().nDestinationState = DESTINATION_AUTHOR;
break; break;
case RTF_KEYWORDS:
m_aStates.top().nDestinationState = DESTINATION_KEYWORDS;
break;
case RTF_OPERATOR: case RTF_OPERATOR:
m_aStates.top().nDestinationState = DESTINATION_OPERATOR; m_aStates.top().nDestinationState = DESTINATION_OPERATOR;
break; break;
...@@ -3242,6 +3247,8 @@ int RTFDocumentImpl::popState() ...@@ -3242,6 +3247,8 @@ int RTFDocumentImpl::popState()
m_xDocumentProperties->setPrintDate(lcl_getDateTime(m_aStates)); m_xDocumentProperties->setPrintDate(lcl_getDateTime(m_aStates));
else if (m_aStates.top().nDestinationState == DESTINATION_AUTHOR && m_xDocumentProperties.is()) else if (m_aStates.top().nDestinationState == DESTINATION_AUTHOR && m_xDocumentProperties.is())
m_xDocumentProperties->setAuthor(m_aStates.top().aDestinationText.makeStringAndClear()); m_xDocumentProperties->setAuthor(m_aStates.top().aDestinationText.makeStringAndClear());
else if (m_aStates.top().nDestinationState == DESTINATION_KEYWORDS && m_xDocumentProperties.is())
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_OPERATOR else if (m_aStates.top().nDestinationState == DESTINATION_OPERATOR
......
...@@ -100,6 +100,7 @@ namespace writerfilter { ...@@ -100,6 +100,7 @@ namespace writerfilter {
DESTINATION_REVISIONTIME, DESTINATION_REVISIONTIME,
DESTINATION_PRINTTIME, DESTINATION_PRINTTIME,
DESTINATION_AUTHOR, DESTINATION_AUTHOR,
DESTINATION_KEYWORDS,
DESTINATION_OPERATOR, DESTINATION_OPERATOR,
DESTINATION_COMPANY, DESTINATION_COMPANY,
DESTINATION_COMMENT, DESTINATION_COMMENT,
......
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