Kaydet (Commit) cd8de6c4 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Fridrich Strba

fdo#62288 fix RTF import of table paragraph margins

Regression from 4a507f73. The problem
was that in some cases \pard can't reset all paragraph properties. The
original commit just made this keyword a noop when it occurred between
\cell and \row, but this is too much. At least margins do need
resetting.

Change-Id: I5cbb1df72bf1211f85ef69ab64d5b46cbce5c742
(cherry picked from commit 24d5261f)
Reviewed-on: https://gerrit.libreoffice.org/2906Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst 11025337
{\rtf1
\paperw11907\paperh16840\margl567\margr567\margt567\margb567
\sb113\sa113
{\b\fs22\cf1\kerning1\cgrid0 Objectives}
{\fs24\kerning1\cgrid0
\par }
\trowd \trgaph10\trleft-10 \clvertalt\cltxlrtb \cellx4808\clvertalt\cltxlrtb \cellx5375\clvertalt\cltxlrtb \cellx10194\clvertalt\cltxlrtb \cellx10762\pard \li567\nowidctlpar\intbl\adjustright
{\cf1\kerning1\cgrid0 One}
{\fs24\kerning1\cgrid0 \cell }
\pard \qc\nowidctlpar\intbl\adjustright
{\cf1\kerning1\cgrid0 [ ]}
{\fs24\kerning1\cgrid0 \cell }
\pard \li567\nowidctlpar\intbl\adjustright
{\cf1\kerning1\cgrid0 Two}
{
\fs24\kerning1\cgrid0 \cell }
\pard \qc\nowidctlpar\intbl\adjustright
{\cf1\kerning1\cgrid0 [ ]}
{\fs24\kerning1\cgrid0 \cell }
\pard \widctlpar\intbl\adjustright
{\fs24\kerning1\cgrid0 \row }
\pard\par
}
......@@ -142,6 +142,7 @@ public:
void testFdo59638();
void testFdo60722();
void testFdo61909();
void testFdo62288();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
......@@ -234,6 +235,7 @@ void Test::run()
{"fdo59638.rtf", &Test::testFdo59638},
{"fdo60722.rtf", &Test::testFdo60722},
{"fdo61909.rtf", &Test::testFdo61909},
{"fdo62288.rtf", &Test::testFdo62288},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
......@@ -1142,6 +1144,19 @@ void Test::testFdo61909()
CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor"));
}
void Test::testFdo62288()
{
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<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
// Margins were inherited from the previous cell, even there was a \pard there.
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaLeftMargin"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -2172,11 +2172,20 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
// \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table.
if (m_aStates.top().nCells == 0)
{
// Reset everything.
m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
m_pCurrentBuffer = 0;
}
else
{
// Reset only margins.
lcl_eraseNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_before);
lcl_eraseNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_after);
m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PDxaLeft);
m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PDxaRight);
}
m_aStates.top().resetFrame();
break;
case RTF_SECTD:
......
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