[Libreoffice-commits] .: sw/qa sw/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Tue Apr 24 03:54:32 PDT 2012
sw/qa/extras/rtfexport/data/fdo38176.rtf | 3 +++
sw/qa/extras/rtfexport/rtfexport.cxx | 30 ++++++++++++++++++++++++++++++
sw/source/filter/ww8/rtfexport.cxx | 3 ++-
3 files changed, 35 insertions(+), 1 deletion(-)
New commits:
commit ef7cc64d8b5044251d6e31ca24aeb0ac11818e5d
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 24 12:47:16 2012 +0200
fdo#38176 fix RTF export of non-breaking space
diff --git a/sw/qa/extras/rtfexport/data/fdo38176.rtf b/sw/qa/extras/rtfexport/data/fdo38176.rtf
new file mode 100644
index 0000000..c5126e4
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo38176.rtf
@@ -0,0 +1,3 @@
+{\rtf1
+foo\~bar
+\par}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 642544d..607a39a 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -26,6 +26,7 @@
*/
#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
#include <test/bootstrapfixture.hxx>
@@ -44,15 +45,19 @@ public:
virtual void setUp();
virtual void tearDown();
void testZoom();
+ void testFdo38176();
CPPUNIT_TEST_SUITE(RtfExportTest);
#if !defined(MACOSX) && !defined(WNT)
CPPUNIT_TEST(testZoom);
+ CPPUNIT_TEST(testFdo38176);
#endif
CPPUNIT_TEST_SUITE_END();
private:
void roundtrip(const OUString& rURL);
+ /// Get the length of the whole document.
+ int getLength();
uno::Reference<lang::XComponent> mxComponent;
};
@@ -69,6 +74,25 @@ void RtfExportTest::roundtrip(const OUString& rFilename)
mxComponent = loadFromDesktop(aTempFile.GetURL());
}
+int RtfExportTest::getLength()
+{
+ 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();
+ OUStringBuffer aBuf;
+ while (xParaEnum->hasMoreElements())
+ {
+ uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
+ while (xRangeEnum->hasMoreElements())
+ {
+ uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
+ aBuf.append(xRange->getString());
+ }
+ }
+ return aBuf.getLength();
+}
+
void RtfExportTest::setUp()
{
test::BootstrapFixture::setUp();
@@ -97,6 +121,12 @@ void RtfExportTest::testZoom()
CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
}
+void RtfExportTest::testFdo38176()
+{
+ roundtrip("fdo38176.rtf");
+ CPPUNIT_ASSERT_EQUAL(7, getLength());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(RtfExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index d5a90ad..15eec5e 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -924,7 +924,8 @@ OString RtfExport::OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEn
}
if (pStr) {
aBuf.append(pStr);
- aBuf.append(' ');
+ if (c != 0xa0)
+ aBuf.append(' ');
}
return aBuf.makeStringAndClear();
}
More information about the Libreoffice-commits
mailing list