[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Wed Jun 6 04:10:02 PDT 2012
sw/qa/extras/rtftok/data/fdo50665.rtf | 16 ++++++++++++++++
sw/qa/extras/rtftok/rtftok.cxx | 20 ++++++++++++++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 7 +++++--
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 +-
4 files changed, 42 insertions(+), 3 deletions(-)
New commits:
commit 483c46716f269f5caf904f15676435edd8f1afd4
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jun 6 12:58:07 2012 +0200
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)
diff --git a/sw/qa/extras/rtftok/data/fdo50665.rtf b/sw/qa/extras/rtftok/data/fdo50665.rtf
new file mode 100644
index 0000000..2536eb0
--- /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 a37d02e..2555fb5 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 51e95fd..3acbddc 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 0f1a4ca..93ed15d 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();
More information about the Libreoffice-commits
mailing list