CPPUNIT_TEST_FIXTURE(TxtExportTest, testClearingBreakExport)
{ // Given a document with a clearing break:
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextContent> xLineBreak(
xMSF->createInstance(u"com.sun.star.text.LineBreak"_ustr), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); auto eClear = static_cast<sal_Int16>(SwLineBreakClear::ALL);
xLineBreakProps->setPropertyValue(u"Clear"_ustr, uno::Any(eClear));
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
xText->insertString(xCursor, u"bar"_ustr, /*bAbsorb=*/false);
// When exporting to plain text:
save(mpFilter);
// Then make sure that the newline is not lost:
OString aActual = readExportedFile(); // Without the accompanying fix in place, this test would have failed with: // - Expected: foo\nbar // - Actual : foobar // i.e. the clearing break was not downgraded to a plain line break.
CPPUNIT_ASSERT_EQUAL("foo\nbar" SAL_NEWLINE_STRING ""_ostr, aActual);
}
} // end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.