fdo#45183 fix RTF import of tables with different row widths
This commit is contained in:
34
sw/qa/extras/rtfimport/data/fdo45183.rtf
Normal file
34
sw/qa/extras/rtfimport/data/fdo45183.rtf
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{\rtf1
|
||||||
|
\titlepg
|
||||||
|
{\headerf \pard\plain \s18\ql \li0\ri0\widctlpar\tqc\tx4536\tqr\tx9072\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1029\langfe1029\cgrid\langnp1029\langfenp1029
|
||||||
|
{\lang1024\langfe1024\noproof
|
||||||
|
{\shp
|
||||||
|
{\*\shpinst\shpleft0\shptop0\shpright9632\shpbottom14448\shpfhdr1\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz0\shplid2055
|
||||||
|
{\sp
|
||||||
|
{\sn shapeType}
|
||||||
|
{\sv 75}
|
||||||
|
}
|
||||||
|
{\sp
|
||||||
|
{\sn pib}
|
||||||
|
{\sv
|
||||||
|
{\pict\picscalex111\picscaley111\piccropl0\piccropr0\piccropt0\piccropb0\picw15238\pich22856\picwgoal8639\pichgoal12958\pngblip\bliptag-1542381464
|
||||||
|
{\*\blipuid a41120687e26e79d08f14204528a39df}
|
||||||
|
47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\par}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\pard\plain
|
||||||
|
\par
|
||||||
|
\trowd\cellx9205
|
||||||
|
\pard\plain aaa\par
|
||||||
|
\pard bbb
|
||||||
|
\cell
|
||||||
|
\trowd\cellx9205\row
|
||||||
|
\trowd\cellx140
|
||||||
|
\pard\cell
|
||||||
|
\trowd\cellx140\row
|
||||||
|
\pard\par
|
||||||
|
}
|
@@ -132,6 +132,7 @@ public:
|
|||||||
void testFdo57886();
|
void testFdo57886();
|
||||||
void testFdo58076();
|
void testFdo58076();
|
||||||
void testFdo57678();
|
void testFdo57678();
|
||||||
|
void testFdo45183();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(Test);
|
CPPUNIT_TEST_SUITE(Test);
|
||||||
#if !defined(MACOSX) && !defined(WNT)
|
#if !defined(MACOSX) && !defined(WNT)
|
||||||
@@ -214,6 +215,7 @@ void Test::run()
|
|||||||
{"fdo57886.rtf", &Test::testFdo57886},
|
{"fdo57886.rtf", &Test::testFdo57886},
|
||||||
{"fdo58076.rtf", &Test::testFdo58076},
|
{"fdo58076.rtf", &Test::testFdo58076},
|
||||||
{"fdo57678.rtf", &Test::testFdo57678},
|
{"fdo57678.rtf", &Test::testFdo57678},
|
||||||
|
{"fdo45183.rtf", &Test::testFdo45183},
|
||||||
};
|
};
|
||||||
header();
|
header();
|
||||||
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
|
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
|
||||||
@@ -990,6 +992,19 @@ void Test::testFdo57678()
|
|||||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
|
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Test::testFdo45183()
|
||||||
|
{
|
||||||
|
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
|
||||||
|
// Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text.
|
||||||
|
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xDraws->getByIndex(0), "Surround"));
|
||||||
|
|
||||||
|
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
|
||||||
|
// Was 247, resulting in a table having width almost zero and height of 10+ pages.
|
||||||
|
CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
|
||||||
|
}
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
|
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -277,7 +277,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
|
|||||||
m_bNeedSect(true),
|
m_bNeedSect(true),
|
||||||
m_bWasInFrame(false),
|
m_bWasInFrame(false),
|
||||||
m_bHadPicture(false),
|
m_bHadPicture(false),
|
||||||
m_bHadSect(false)
|
m_bHadSect(false),
|
||||||
|
m_nCellxMax(0)
|
||||||
{
|
{
|
||||||
OSL_ASSERT(xInputStream.is());
|
OSL_ASSERT(xInputStream.is());
|
||||||
m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True));
|
m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True));
|
||||||
@@ -1620,7 +1621,11 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
|
|||||||
if (bNeedPap)
|
if (bNeedPap)
|
||||||
runProps();
|
runProps();
|
||||||
if (!m_pCurrentBuffer)
|
if (!m_pCurrentBuffer)
|
||||||
|
{
|
||||||
parBreak();
|
parBreak();
|
||||||
|
// Not in table? Reset max width.
|
||||||
|
m_nCellxMax = 0;
|
||||||
|
}
|
||||||
else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
|
else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
|
||||||
{
|
{
|
||||||
RTFValue::Pointer_t pValue;
|
RTFValue::Pointer_t pValue;
|
||||||
@@ -1684,6 +1689,11 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
|
|||||||
case RTF_ROW:
|
case RTF_ROW:
|
||||||
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.
|
||||||
|
RTFValue::Pointer_t pLastCellx = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblGridBase_gridCol, false);
|
||||||
|
if (pLastCellx.get() && pLastCellx->getInt() < m_nCellxMax)
|
||||||
|
dispatchValue(RTF_CELLX, m_nCellxMax);
|
||||||
|
|
||||||
if (m_aStates.top().nCells)
|
if (m_aStates.top().nCells)
|
||||||
{
|
{
|
||||||
// Make a backup before we start popping elements
|
// Make a backup before we start popping elements
|
||||||
@@ -2946,6 +2956,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
|
|||||||
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
|
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
|
||||||
// We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
|
// We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
|
||||||
dispatchFlag(RTF_INTBL);
|
dispatchFlag(RTF_INTBL);
|
||||||
|
m_nCellxMax = std::max(m_nCellxMax, nParam);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RTF_TRRH:
|
case RTF_TRRH:
|
||||||
|
@@ -592,6 +592,8 @@ namespace writerfilter {
|
|||||||
bool m_bHadPicture;
|
bool m_bHadPicture;
|
||||||
/// The document has multiple sections.
|
/// The document has multiple sections.
|
||||||
bool m_bHadSect;
|
bool m_bHadSect;
|
||||||
|
/// Max width of the rows in the current table.
|
||||||
|
int m_nCellxMax;
|
||||||
};
|
};
|
||||||
} // namespace rtftok
|
} // namespace rtftok
|
||||||
} // namespace writerfilter
|
} // namespace writerfilter
|
||||||
|
@@ -98,12 +98,17 @@ std::string RTFSprm::toString() const
|
|||||||
return aBuf.makeStringAndClear().getStr();
|
return aBuf.makeStringAndClear().getStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
RTFValue::Pointer_t RTFSprms::find(Id nKeyword)
|
RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst)
|
||||||
{
|
{
|
||||||
|
RTFValue::Pointer_t pValue;
|
||||||
for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
|
for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
|
||||||
if (i->first == nKeyword)
|
if (i->first == nKeyword)
|
||||||
|
{
|
||||||
|
if (bFirst)
|
||||||
return i->second;
|
return i->second;
|
||||||
RTFValue::Pointer_t pValue;
|
else
|
||||||
|
pValue = i->second;
|
||||||
|
}
|
||||||
return pValue;
|
return pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ namespace writerfilter {
|
|||||||
RTFSprms(const RTFSprms& rSprms);
|
RTFSprms(const RTFSprms& rSprms);
|
||||||
~RTFSprms();
|
~RTFSprms();
|
||||||
RTFSprms& operator=(const RTFSprms& rOther);
|
RTFSprms& operator=(const RTFSprms& rOther);
|
||||||
RTFValue::Pointer_t find(Id nKeyword);
|
RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true);
|
||||||
/// Does the same as ->push_back(), except that it can overwrite existing entries.
|
/// Does the same as ->push_back(), except that it can overwrite existing entries.
|
||||||
void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true);
|
void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true);
|
||||||
bool erase(Id nKeyword);
|
bool erase(Id nKeyword);
|
||||||
|
Reference in New Issue
Block a user