tdf#148540 Revert "tdf#109790 RTF import: keep remembering...

... paragraph style between \cell and \row"
This reverts 5.4.1 commit aaa6a5202a,
and rtfexport7's tdf109790.rtf unit test still passes.
I also did a visual test, which looks good.

After \cell, we normally get more \cells, so an impending
\row is completely unexpected most of the time.
I'm not really sure why that patch was ever thought to be good.

The problem was that \pard was not removing the paragraph style
that was assigned to an earlier column. The end result seemed
innocent (no bad formatting noticed),
but that is probably based on other work
done in the meantime which allows the unit test to still pass
even after all of "its code" has been reverted.

[If this causes a regression, perhaps m_pLastCharacterContext
could be of value?]

Change-Id: Ide9b65f5e5fa39c21bac6d8ed354bb88e0bbefe5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160233
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
This commit is contained in:
Justin Luth 2023-12-01 14:30:45 -05:00 committed by Miklos Vajna
parent caecfff1ad
commit b63a12d481
5 changed files with 3 additions and 16 deletions

View file

@ -172,6 +172,8 @@ DECLARE_RTFEXPORT_TEST(testTdf108505_fieldCharFormat, "tdf108505_fieldCharFormat
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xRun, "CharWeight"));
CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xRun, "CharPosture"));
CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, getProperty<Color>(xRun, "CharColor"));
CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(xPara, "ParaStyleName"));
}
DECLARE_RTFEXPORT_TEST(testTdf108505_fieldCharFormat2, "tdf108505_fieldCharFormat2.rtf")

View file

@ -579,8 +579,6 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
dispatchSymbol(RTFKeyword::PAR);
// \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table.
// It should not reset the paragraph style, either, so remember the old paragraph style.
RTFValue::Pointer_t pOldStyle
= m_aStates.top().getParagraphSprms().find(NS_ooxml::LN_CT_PPrBase_pStyle);
m_aStates.top().getParagraphSprms() = m_aDefaultState.getParagraphSprms();
m_aStates.top().getParagraphAttributes() = m_aDefaultState.getParagraphAttributes();
@ -593,19 +591,14 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
{
// We are still in a table.
m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_inTbl, new RTFValue(1));
if (m_bAfterCellBeforeRow && pOldStyle)
// And we still have the same paragraph style.
m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle,
pOldStyle);
// Ideally getDefaultSPRM() would take care of this, but it would not when we're buffering.
m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_tabs,
new RTFValue());
}
resetFrame();
// Reset currently selected paragraph style as well, unless we are in the special "after \cell, before \row" state.
// Reset currently selected paragraph style as well.
// By default the style with index 0 is applied.
if (!m_bAfterCellBeforeRow)
{
OUString const aName = getStyleName(0);
// But only in case it's not a character style.

View file

@ -180,9 +180,6 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
case RTFKeyword::CELL:
case RTFKeyword::NESTCELL:
{
if (nKeyword == RTFKeyword::CELL)
m_bAfterCellBeforeRow = true;
checkFirstRun();
if (m_bNeedPap)
{
@ -236,7 +233,6 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
break;
case RTFKeyword::ROW:
{
m_bAfterCellBeforeRow = false;
if (m_aStates.top().getTableRowWidthAfter() > 0)
{
// Add fake cellx / cell, RTF equivalent of

View file

@ -330,7 +330,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
, m_hasFHeader(false)
, m_hasRFooter(false)
, m_hasFFooter(false)
, m_bAfterCellBeforeRow(false)
{
OSL_ASSERT(xInputStream.is());
m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, true);

View file

@ -988,9 +988,6 @@ private:
bool m_hasFHeader;
bool m_hasRFooter;
bool m_hasFFooter;
/// Are we after a \cell, but before a \row?
bool m_bAfterCellBeforeRow;
};
} // namespace writerfilter::rtftok