From b62bfda66c1499806bfa35c26fdc05f76f8a4db2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 4 Apr 2019 21:34:31 +0200 Subject: 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 --- sw/qa/extras/rtfexport/data/btlr-cell.rtf | 9 +++++++++ sw/qa/extras/rtfexport/rtfexport4.cxx | 18 ++++++++++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 7 +++++++ 3 files changed, 34 insertions(+) create mode 100644 sw/qa/extras/rtfexport/data/btlr-cell.rtf 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 xSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTables = xSupplier->getTextTables(); + uno::Reference xTable(xTables->getByName("Table1"), uno::UNO_QUERY); + uno::Reference xA1(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty(xA1, "WritingMode")); + + uno::Reference xB1(xTable->getCellByName("B1"), uno::UNO_QUERY); + auto nActual = getProperty(xB1, "WritingMode"); + CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT); + + uno::Reference xC1(xTable->getCellByName("C1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty(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 -- cgit v1.2.3