diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-04-04 21:34:31 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-04-05 09:04:50 +0200 |
commit | b62bfda66c1499806bfa35c26fdc05f76f8a4db2 (patch) | |
tree | 894afa60453b7a04a1ed798586064b887a1faaf8 | |
parent | 7327260de3c0c627e62f7c3fddbe3d71ea88e88f (diff) |
sw btlr writing mode: implement RTF export
Note that we can't work with the table box (and frame format) of
pTableTextNodeInfoInner in RtfAttributeOutput::TableVerticalCell(). This
is because cell definitions are written in
RtfAttributeOutput::TableDefinition(), and the loop only calls
setCell(), i.e. the cell index is updated in the node info, but the
table box is not.
Import was already working as-is.
Change-Id: Ia089c42b3a49f1a8f012a8cadaa8bcad16128c3e
Reviewed-on: https://gerrit.libreoffice.org/70269
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/rtfexport/data/btlr-cell.rtf | 9 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport4.cxx | 18 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 7 |
3 files changed, 34 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/btlr-cell.rtf b/sw/qa/extras/rtfexport/data/btlr-cell.rtf new file mode 100644 index 000000000000..2a2117358cbb --- /dev/null +++ b/sw/qa/extras/rtfexport/data/btlr-cell.rtf @@ -0,0 +1,9 @@ +{\rtf1 +\trowd\trrh1500\cltxbtlr\cellx3000\cellx6000\cltxtbrl\cellx9000 +\intbl +AAA1.\par AAA2.\cell +BBB1.\par BBB2.\cell +CCC1.\par CCC2.\cell +\pard \intbl\row +\pard \par +} diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index 4fb9eb3daeb5..5f327782df6b 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -132,6 +132,24 @@ DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf") CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat); } +DECLARE_RTFEXPORT_TEST(testBtlrCell, "btlr-cell.rtf") +{ + // Without the accompanying fix in place, this test would have failed, as + // the btlr text direction in the A1 cell was lost. + uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xTables = xSupplier->getTextTables(); + uno::Reference<text::XTextTable> xTable(xTables->getByName("Table1"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xA1(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xA1, "WritingMode")); + + uno::Reference<beans::XPropertySet> xB1(xTable->getCellByName("B1"), uno::UNO_QUERY); + auto nActual = getProperty<sal_Int16>(xB1, "WritingMode"); + CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT); + + uno::Reference<beans::XPropertySet> xC1(xTable->getCellByName("C1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 554fc7291a22..de0098a07fc4 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -847,6 +847,13 @@ void RtfAttributeOutput::TableVerticalCell( const SwWriteTableCell* const pCell = pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get(); const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat(); + + // Text direction. + if (SvxFrameDirection::Vertical_RL_TB == m_rExport.TrueFrameDirection(*pCellFormat)) + m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLTXTBRL); + else if (SvxFrameDirection::Vertical_LR_BT == m_rExport.TrueFrameDirection(*pCellFormat)) + m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLTXBTLR); + const SfxPoolItem* pItem; // vertical merges |