summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-06-06 12:58:07 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-06-06 13:10:14 +0200
commit483c46716f269f5caf904f15676435edd8f1afd4 (patch)
tree6c1a76b040357e59f5922610ac96b13e1c339341
parentaa4197498a1abf53bb22843b38e827730b4d4ee1 (diff)
fdo#50665 rtftok: don't ignore character properties of text fields
The dmapper part was already fixed in commit 9486851baea59d16c449d79bd61a38f6e686cfe0 for DOCX, this fixes the RTF tokenizer. Change-Id: Iaca706e50367bb744f5a03e15134bda1646df8fc (cherry picked from commit b9508dd55f82d35f09a58021dc001cf79b390e08)
-rw-r--r--sw/qa/extras/rtftok/data/fdo50665.rtf16
-rw-r--r--sw/qa/extras/rtftok/rtftok.cxx20
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx7
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
4 files changed, 42 insertions, 3 deletions
diff --git a/sw/qa/extras/rtftok/data/fdo50665.rtf b/sw/qa/extras/rtftok/data/fdo50665.rtf
new file mode 100644
index 000000000000..2536eb0df66e
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo50665.rtf
@@ -0,0 +1,16 @@
+{\rtf1\ansi\deff6
+{\fonttbl
+{\f1\fnil\fprq0\fcharset0 Times New Roman;}
+{\f4\fmodern\fprq1\fcharset0 Cumberland
+{\*\falt Courier New}
+;}
+{\f6\froman\fprq2\fcharset1 Book Antiqua
+{\*\falt Times New Roman}
+;}
+}
+\sectd\sbknone\pgwsxn11909\pghsxn16834\marglsxn1080\margrsxn1080\margtsxn2437\margbsxn1080\headery1080
+\pard\plain \s7\cf0\tqr\tx9990\tqr\tx9900
+{\loch\f6\fs24\lang1033\i0\b
+Page : \chpgn\par
+}
+}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index a37d02e8244b..2555fb5df2c3 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -94,6 +94,7 @@ public:
void testFdo49692();
void testFdo45190();
void testFdo50539();
+ void testFdo50665();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -131,6 +132,7 @@ public:
CPPUNIT_TEST(testFdo49692);
CPPUNIT_TEST(testFdo45190);
CPPUNIT_TEST(testFdo50539);
+ CPPUNIT_TEST(testFdo50665);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -761,6 +763,24 @@ void Test::testFdo50539()
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), nValue);
}
+void Test::testFdo50665()
+{
+ load("fdo50665.rtf");
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
+
+ // Access the second run, which is a textfield
+ xRunEnum->nextElement();
+ uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ OUString aValue;
+ xRun->getPropertyValue("CharFontName") >>= aValue;
+ // This used to be the default, as character properties were ignored.
+ CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), aValue);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 51e95fda85cd..3acbddc96f54 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -846,12 +846,15 @@ bool RTFFrame::inFrame()
|| nY > 0;
}
-void RTFDocumentImpl::singleChar(sal_uInt8 nValue)
+void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps)
{
sal_uInt8 sValue[] = { nValue };
if (!m_pCurrentBuffer)
{
Mapper().startCharacterGroup();
+ // Should we send run properties?
+ if (bRunProps)
+ runProps();
Mapper().text(sValue, 1);
Mapper().endCharacterGroup();
}
@@ -1561,7 +1564,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
OUString aStr("PAGE");
singleChar(0x13);
text(aStr);
- singleChar(0x14);
+ singleChar(0x14, true);
singleChar(0x15);
}
break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 0f1a4cab662c..93ed15d55398 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -404,7 +404,7 @@ namespace writerfilter {
void text(rtl::OUString& rString);
// Sends a single character to dmapper, taking care of buffering.
- void singleChar(sal_uInt8 nValue);
+ void singleChar(sal_uInt8 nValue, bool bRunProps = false);
// Sends run properties to dmapper, taking care of buffering.
void runProps();
void parBreak();