Kaydet (Commit) 24d5261f authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst cc8e169d
{\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
}
...@@ -146,6 +146,7 @@ public: ...@@ -146,6 +146,7 @@ public:
void testFdo59638(); void testFdo59638();
void testFdo60722(); void testFdo60722();
void testFdo61909(); void testFdo61909();
void testFdo62288();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -264,6 +265,7 @@ void Test::run() ...@@ -264,6 +265,7 @@ void Test::run()
{"fdo59638.rtf", &Test::testFdo59638}, {"fdo59638.rtf", &Test::testFdo59638},
{"fdo60722.rtf", &Test::testFdo60722}, {"fdo60722.rtf", &Test::testFdo60722},
{"fdo61909.rtf", &Test::testFdo61909}, {"fdo61909.rtf", &Test::testFdo61909},
{"fdo62288.rtf", &Test::testFdo62288},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
...@@ -1177,6 +1179,19 @@ void Test::testFdo61909() ...@@ -1177,6 +1179,19 @@ void Test::testFdo61909()
CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor")); 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_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -2173,11 +2173,20 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -2173,11 +2173,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. // \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) if (m_aStates.top().nCells == 0)
{ {
// Reset everything.
m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms; m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes; m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT) if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
m_pCurrentBuffer = 0; 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(); m_aStates.top().resetFrame();
break; break;
case RTF_SECTD: 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