Kaydet (Commit) 8fdbda18 authored tarafından Miklos Vajna's avatar Miklos Vajna

sw btlr writing mode: implement DOCX filter

Replace the old trick with character-level rotation with the usage of
the new writing direction.

This means that finally table cells with btlr text direction and
multiple paragraphs show all content, not only the first paragraph, as
before (seen as data loss by users).

Change-Id: I094f36fa6ba0701579e487e8e0212707987b1b2f
Reviewed-on: https://gerrit.libreoffice.org/67870Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 3473e1df
......@@ -775,9 +775,8 @@ DECLARE_OOXMLEXPORT_TEST(testTbLrHeight, "tblr-height.docx")
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
// btLr text direction was imported as MIN, it should be FIX to avoid incorrectly large height in case of too much content.
CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType"));
uno::Reference<table::XCell> xCell = xTable->getCellByName("B1");
CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xCell, "WritingMode"));
}
DECLARE_OOXMLEXPORT_TEST(testBnc865381, "bnc865381.docx")
......@@ -785,11 +784,8 @@ DECLARE_OOXMLEXPORT_TEST(testBnc865381, "bnc865381.docx")
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
// Second row has a vertically merged cell, make sure size type is not FIX in that case (otherwise B2 is not readable).
CPPUNIT_ASSERT(text::SizeType::FIX != getProperty<sal_Int16>(xTableRows->getByIndex(1), "SizeType"));
// Explicit size of 41 mm100 was set, so the vertical text in A2 was not readable.
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTableRows->getByIndex(1), "Height"));
uno::Reference<table::XCell> xCell = xTextTable->getCellByName("A2");
CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty<sal_Int16>(xCell, "WritingMode"));
}
DECLARE_OOXMLEXPORT_TEST(testFdo53985, "fdo53985.docx")
......
......@@ -4192,28 +4192,11 @@ void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer
m_pSerializer->singleElementNS( XML_w, XML_textDirection,
FSNS( XML_w, XML_val ), "tbRl",
FSEND );
else if ( SvxFrameDirection::Horizontal_LR_TB == m_rExport.TrueFrameDirection( *pFrameFormat ) )
else if ( SvxFrameDirection::Vertical_LR_BT == m_rExport.TrueFrameDirection( *pFrameFormat ) )
{
// Undo the text direction mangling done by the btLr handler in writerfilter::dmapper::DomainMapperTableManager::sprm()
const SwStartNode* pSttNd = pTabBox->GetSttNd();
if (pSttNd)
{
SwPaM aPam(*pSttNd, 0);
++aPam.GetPoint()->nNode;
if (aPam.GetPoint()->nNode.GetNode().IsTextNode())
{
const SwTextNode& rTextNode = static_cast<const SwTextNode&>(aPam.GetPoint()->nNode.GetNode());
if( const SwAttrSet* pAttrSet = rTextNode.GetpSwAttrSet())
{
const SvxCharRotateItem& rCharRotate = pAttrSet->GetCharRotate();
if (rCharRotate.GetValue() == 900)
{
m_pSerializer->singleElementNS( XML_w, XML_textDirection, FSNS( XML_w, XML_val ), "btLr", FSEND );
m_bBtLr = true;
}
}
}
}
m_pSerializer->singleElementNS( XML_w, XML_textDirection,
FSNS( XML_w, XML_val ), "btLr",
FSEND );
}
const SwWriteTableRows& rRows = m_xTableWrt->GetRows( );
......
......@@ -298,20 +298,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
SAL_INFO( "writerfilter", "Have inserted textDirection " << nIntValue );
break;
case NS_ooxml::LN_Value_ST_TextDirection_btLr:
{
// We have to fake this text direction
pPropMap->Insert( PROP_FRM_DIRECTION, uno::makeAny( text::WritingMode2::LR_TB ));
pPropMap->Insert( PROP_CHAR_ROTATION, uno::makeAny( sal_Int16( 900 ) ));
SAL_INFO( "writerfilter", "Have inserted textDirection " << nIntValue );
// We're faking a text direction, so don't allow multiple lines.
if (!getCellProps() || !getCellProps()->isSet(PROP_VERTICAL_MERGE))
{
// Though in case there will be a vertical merge, don't do this, it hides text that is supposed to be visible.
m_bRowSizeTypeInserted = true;
}
m_bHasBtlrCell = true;
}
pPropMap->Insert( PROP_FRM_DIRECTION, uno::makeAny( text::WritingMode2::BT_LR ));
break;
case NS_ooxml::LN_Value_ST_TextDirection_lrTbV:
pPropMap->Insert( PROP_FRM_DIRECTION, uno::makeAny( text::WritingMode2::LR_TB ));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment