Kaydet (Commit) 7d4e2873 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Caolán McNamara

fdo#59953 RTF import: fix unreadable graphic and nested cell contents

There were two issues here:

1) c3b0f135 added a mechanism to work
around broken documents, but that didn't deal with nested tables.
Additionally, the check compared the max row width with the width of the
last cell, not the last row.

2) d276d3f3 cleaned up implicit
horizontal merge detection, but didn't deal with valid documents, where
each row definition is available twice.

(cherry picked from commit e15f9cea)

Conflicts:
	sw/qa/extras/rtfimport/rtfimport.cxx

Change-Id: I1a32ec2fcb0d1a8fca7a7bd26501d3daf17880c9
Reviewed-on: https://gerrit.libreoffice.org/2044Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 0977ba31
{\rtf1\ansi\deff0
\trowd\cellx7384\cellx9652
\pard\intbl\sl0
A1
\cell
\pard\intbl\sl0\lin10
B1
\cell
\trowd\cellx7384\cellx9652\row
\trowd\cellx7384\cellx9652
\pard\intbl A2\cell
\pard\intbl B2\cell
\trowd\cellx7384\cellx9652
\row
\pard\itap0\sl0\lin14\rin8 \par
}
...@@ -138,6 +138,7 @@ public: ...@@ -138,6 +138,7 @@ public:
void testFdo58933(); void testFdo58933();
void testFdo44053(); void testFdo44053();
void testFdo58646line(); void testFdo58646line();
void testFdo59953();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -226,6 +227,7 @@ void Test::run() ...@@ -226,6 +227,7 @@ void Test::run()
{"fdo58933.rtf", &Test::testFdo58933}, {"fdo58933.rtf", &Test::testFdo58933},
{"fdo44053.rtf", &Test::testFdo44053}, {"fdo44053.rtf", &Test::testFdo44053},
{"fdo58646line.rtf", &Test::testFdo58646line}, {"fdo58646line.rtf", &Test::testFdo58646line},
{"fdo59953.rtf", &Test::testFdo59953},
}; };
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{ {
...@@ -1073,6 +1075,16 @@ void Test::testFdo58646line() ...@@ -1073,6 +1075,16 @@ void Test::testFdo58646line()
getParagraph(1, "foo\nbar"); getParagraph(1, "foo\nbar");
} }
void Test::testFdo59953()
{
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);
// Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width)
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int16(7650), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -222,7 +222,10 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) ...@@ -222,7 +222,10 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
break; break;
case NS_ooxml::LN_CT_TblGridBase_gridCol: case NS_ooxml::LN_CT_TblGridBase_gridCol:
{ {
getCurrentGrid()->push_back( ConversionHelper::convertTwipToMM100( nIntValue ) ); if (nIntValue == -1)
getCurrentGrid()->clear();
else
getCurrentGrid()->push_back( ConversionHelper::convertTwipToMM100( nIntValue ) );
} }
break; break;
case NS_ooxml::LN_CT_TcPrBase_vMerge : //vertical merge case NS_ooxml::LN_CT_TcPrBase_vMerge : //vertical merge
......
...@@ -1718,8 +1718,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) ...@@ -1718,8 +1718,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
case RTF_NESTROW: case RTF_NESTROW:
{ {
// If the right edge of the last cell (row width) is smaller than the width of some other row, mimic the WW8 import: add a fake cell. // If the right edge of the last cell (row width) is smaller than the width of some other row, mimic the WW8 import: add a fake cell.
RTFValue::Pointer_t pLastCellx = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblGridBase_gridCol, false); if (nKeyword == RTF_ROW && m_aStates.top().nCellX < m_nCellxMax)
if (pLastCellx.get() && pLastCellx->getInt() < m_nCellxMax)
dispatchValue(RTF_CELLX, m_nCellxMax); dispatchValue(RTF_CELLX, m_nCellxMax);
if (m_aStates.top().nCells) if (m_aStates.top().nCells)
...@@ -2139,6 +2138,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -2139,6 +2138,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break; break;
case RTF_TROWD: case RTF_TROWD:
m_aStates.top().aTableRowSprms = m_aDefaultState.aTableRowSprms; m_aStates.top().aTableRowSprms = m_aDefaultState.aTableRowSprms;
m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, RTFValue::Pointer_t(new RTFValue(-1)), false);
m_aStates.top().aTableRowAttributes = m_aDefaultState.aTableRowAttributes; m_aStates.top().aTableRowAttributes = m_aDefaultState.aTableRowAttributes;
m_aStates.top().nCellX = 0; m_aStates.top().nCellX = 0;
// In case the table definition is in the middle of the row // In case the table definition is in the middle of the row
......
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