sw/qa/extras/ww8export/data/btlr-cell.doc |binary sw/qa/extras/ww8export/ww8export3.cxx | 20 ++++++++++++++++++++ sw/source/filter/ww8/wrtww8.cxx | 18 ++++++++++++++++-- sw/source/filter/ww8/ww8par2.cxx | 23 +---------------------- sw/source/filter/ww8/ww8par2.hxx | 2 -- 5 files changed, 37 insertions(+), 26 deletions(-)
New commits: commit 89e5b431d468745da3a1eff14d48296107b9101b Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Mar 28 21:27:40 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Mar 29 09:59:28 2019 +0100 sw btlr writing mode: implement DOC filter Replace WW8TabDesc::Start/EndMiserableHackForUnsupportedDirection() added in commit 69ba46df8be261e665214390cd57a141ad65c210 (INTEGRATION: CWS vertcell (1.95.32); FILE MERGED, 2004-04-21) with the usage of the new writing direction. Adapt export accordingly. Change-Id: Ic85b69c806fbd1c1b4eb21cff3ee46dd5da497e8 Reviewed-on: https://gerrit.libreoffice.org/69901 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ww8export/data/btlr-cell.doc b/sw/qa/extras/ww8export/data/btlr-cell.doc new file mode 100644 index 000000000000..f99e9e67e4e9 Binary files /dev/null and b/sw/qa/extras/ww8export/data/btlr-cell.doc differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 955093393ed3..ba99e05deb36 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -16,6 +16,7 @@ #include <com/sun/star/text/XTextFramesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/WritingMode2.hpp> #include <drawdoc.hxx> #include <svx/xfillit0.hxx> @@ -203,6 +204,25 @@ DECLARE_WW8EXPORT_TEST(testTdf120711_joinedParagraphWithChangeTracking, "tdf1207 CPPUNIT_ASSERT(style::NumberingType::CHAR_SPECIAL != numFormat); } +DECLARE_WW8EXPORT_TEST(testBtlrCell, "btlr-cell.doc") +{ + // Without the accompanying fix in place, this test would have failed, as + // the btlr text direction in the A1 cell was lost on DOC import and + // export. + 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/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 3906acfaf20c..c737156568d9 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2133,12 +2133,26 @@ void WW8AttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_ const SwTableBox * pTabBox1 = rTableBoxes[n]; const SwFrameFormat * pFrameFormat = pTabBox1->GetFrameFormat(); - if ( SvxFrameDirection::Vertical_RL_TB == m_rWW8Export.TrueFrameDirection( *pFrameFormat ) ) + // Map from our SvxFrameDirection to WW8 TextFlow. + sal_uInt16 nTextFlow = 0; + switch (m_rWW8Export.TrueFrameDirection(*pFrameFormat)) + { + case SvxFrameDirection::Vertical_RL_TB: + nTextFlow = 5; + break; + case SvxFrameDirection::Vertical_LR_BT: + nTextFlow = 3; + break; + default: + break; + } + + if (nTextFlow != 0) { m_rWW8Export.InsUInt16( NS_sprm::sprmTTextFlow ); m_rWW8Export.pO->push_back( n ); //start range m_rWW8Export.pO->push_back( sal_uInt8(n + 1) ); //end range - m_rWW8Export.InsUInt16( 5 ); //Equals vertical writing + m_rWW8Export.InsUInt16(nTextFlow); } } } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index c036df0955a8..3f02c4c7ba49 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2887,23 +2887,6 @@ bool WW8TabDesc::InFirstParaInCell() const return m_pIo->m_pPaM->GetPoint()->nNode == m_pTabBox->GetSttIdx() + 1; } -void WW8TabDesc::StartMiserableHackForUnsupportedDirection(short nWwCol) -{ - OSL_ENSURE(m_pActBand, "Impossible"); - if (m_pActBand && nWwCol <= MAX_COL && m_pActBand->maDirections[nWwCol] == 3) - { - m_pIo->m_xCtrlStck->NewAttr(*m_pIo->m_pPaM->GetPoint(), - SvxCharRotateItem(900, false, RES_CHRATR_ROTATE)); - } -} - -void WW8TabDesc::EndMiserableHackForUnsupportedDirection(short nWwCol) -{ - OSL_ENSURE(m_pActBand, "Impossible"); - if (m_pActBand && nWwCol <= MAX_COL && m_pActBand->maDirections[nWwCol] == 3) - m_pIo->m_xCtrlStck->SetAttr(*m_pIo->m_pPaM->GetPoint(), RES_CHRATR_ROTATE); -} - void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam) { OSL_ENSURE( m_pActBand, "pActBand is 0" ); @@ -3007,8 +2990,6 @@ void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam) m_pIo->m_xCtrlStck->SetAttr(*pGridPos, RES_PARATR_SNAPTOGRID); } } - - StartMiserableHackForUnsupportedDirection(nWwCol); } } @@ -3117,7 +3098,7 @@ static SvxFrameDirection MakeDirection(sal_uInt16 nCode, bool bIsBiDi) OSL_ENSURE(eDir == SvxFrameDirection::Environment, "unknown direction code, maybe it's a bitfield"); [[fallthrough]]; case 3: - eDir = bIsBiDi ? SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB; // #i38158# - Consider RTL tables + eDir = SvxFrameDirection::Vertical_LR_BT; break; case 5: eDir = SvxFrameDirection::Vertical_RL_TB; @@ -3277,8 +3258,6 @@ void WW8TabDesc::TableCellEnd() { ::SetProgressState(m_pIo->m_nProgress, m_pIo->m_pDocShell); // Update - EndMiserableHackForUnsupportedDirection(m_nCurrentCol); - // new line/row if( m_pIo->m_bWasTabRowEnd ) { diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx index 16b4f58c0800..4875270e6e27 100644 --- a/sw/source/filter/ww8/ww8par2.hxx +++ b/sw/source/filter/ww8/ww8par2.hxx @@ -259,8 +259,6 @@ class WW8TabDesc // (the merge groups are processed later at once) void UpdateTableMergeGroup(WW8_TCell const & rCell, WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol ); - void StartMiserableHackForUnsupportedDirection(short nWwCol); - void EndMiserableHackForUnsupportedDirection(short nWwCol); WW8TabDesc(WW8TabDesc const&) = delete; WW8TabDesc& operator=(WW8TabDesc const&) = delete; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits