summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/rtftok/data/fdo48193.rtf10
-rw-r--r--sw/qa/extras/rtftok/rtftok.cxx8
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx26
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx9
4 files changed, 52 insertions, 1 deletions
diff --git a/sw/qa/extras/rtftok/data/fdo48193.rtf b/sw/qa/extras/rtftok/data/fdo48193.rtf
new file mode 100644
index 000000000000..ca585496eaf4
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo48193.rtf
@@ -0,0 +1,10 @@
+{\rtf1
+\pard\plain
+foo
+{\field
+{\*\fldinst
+{\f8\fs16\f8 PAGE }
+}
+}
+bar
+\par }
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index 0bb45e47d0d7..48e33e23a4b7 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -86,6 +86,7 @@ public:
void testFdo48356();
void testFdo48023();
void testFdo48876();
+ void testFdo48193();
CPPUNIT_TEST_SUITE(RtfModelTest);
#if !defined(MACOSX) && !defined(WNT)
@@ -112,6 +113,7 @@ public:
CPPUNIT_TEST(testFdo48356);
CPPUNIT_TEST(testFdo48023);
CPPUNIT_TEST(testFdo48876);
+ CPPUNIT_TEST(testFdo48193);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -616,6 +618,12 @@ void RtfModelTest::testFdo48876()
CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM, aSpacing.Mode);
}
+void RtfModelTest::testFdo48193()
+{
+ load("fdo48193.rtf");
+ CPPUNIT_ASSERT_EQUAL(7, getLength());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 6bcfdc7998b5..ed89aa2983e1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1043,7 +1043,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
m_aStates.top().nDestinationState = DESTINATION_STYLESHEET;
break;
case RTF_FIELD:
- // A field consists of an fldinst and an fldrslt group.
+ m_aStates.top().nDestinationState = DESTINATION_FIELD;
break;
case RTF_FLDINST:
{
@@ -3458,6 +3458,30 @@ int RTFDocumentImpl::popState()
}
else if (aState.nDestinationState == DESTINATION_LEVELNUMBERS)
m_aStates.top().aTableSprms = aState.aTableSprms;
+ else if (aState.nDestinationState == DESTINATION_FIELDINSTRUCTION)
+ m_aStates.top().nFieldStatus = FIELD_INSTRUCTION;
+ else if (aState.nDestinationState == DESTINATION_FIELDRESULT)
+ m_aStates.top().nFieldStatus = FIELD_RESULT;
+ else if (aState.nDestinationState == DESTINATION_FIELD)
+ {
+ if (aState.nFieldStatus == FIELD_INSTRUCTION)
+ {
+ sal_uInt8 sFieldEnd[] = { 0x15 };
+ if (!m_pCurrentBuffer)
+ {
+ Mapper().startCharacterGroup();
+ Mapper().text(sFieldEnd, 1);
+ Mapper().endCharacterGroup();
+ }
+ else
+ {
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
+ RTFValue::Pointer_t pValue(new RTFValue(*sFieldEnd));
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
+ m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
+ }
+ }
+ }
else if (bPopShapeProperties)
{
m_aStates.top().aShape = aShape;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 3a1bad4fa625..c905909334a1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -65,6 +65,7 @@ namespace writerfilter {
DESTINATION_STYLESHEET,
DESTINATION_STYLEENTRY,
DESTINATION_EQINSTRUCTION,
+ DESTINATION_FIELD,
DESTINATION_FIELDINSTRUCTION,
DESTINATION_FIELDRESULT,
DESTINATION_LISTTABLE,
@@ -161,6 +162,13 @@ namespace writerfilter {
BMPSTYLE_PNG
};
+ enum RTFFieldStatus
+ {
+ FIELD_NONE,
+ FIELD_INSTRUCTION,
+ FIELD_RESULT
+ };
+
/// A buffer storing dmapper calls.
typedef std::deque< std::pair<RTFBufferTypes, RTFValue::Pointer_t> > RTFBuffer_t;
@@ -244,6 +252,7 @@ namespace writerfilter {
RTFDocumentImpl* m_pDocumentImpl;
RTFInternalState nInternalState;
RTFDesitnationState nDestinationState;
+ RTFFieldStatus nFieldStatus;
RTFBorderState nBorderState;
// font table, stylesheet table
RTFSprms aTableSprms;