[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Sat Aug 17 03:31:21 PDT 2013
sw/qa/extras/rtfimport/data/fdo44715.rtf | 42 +++++++++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 10 +++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 14 ++------
3 files changed, 57 insertions(+), 9 deletions(-)
New commits:
commit b9c1a9b9aa41dbbb6bed0c77f4370ab6105c7fb1
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sat Aug 17 11:38:45 2013 +0200
fdo#44715 RTF import: reset styles in tables on RTF_PARD
Commit 4a507f732d82c188ad81b022cbe3037951e58ac3 added an exception to
RTF_PARD (reset paragraph properties) handling: when we're inside a
table, it should not reset the fact that we're inside a table (which is
a paragraph property).
However, instead of just re-adding that property, it disabled resetting
for all properties, and we had a growing list of exceptions since then.
The next thing to add there would be the paragraph attributes, which
contains the style information. Instead of growing that ad-hoc list,
reset everything again and just re-add the "in table" SPRM.
This makes the second and later paragraphs in the A1 cell of the bugdoc
have proper font size.
Change-Id: I2de80894fcd5da3bf45d221af9a04a307c70a29b
diff --git a/sw/qa/extras/rtfimport/data/fdo44715.rtf b/sw/qa/extras/rtfimport/data/fdo44715.rtf
new file mode 100644
index 0000000..1b2287f
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo44715.rtf
@@ -0,0 +1,42 @@
+{\rtf1\ansi\ansicpg1251\uc1 \deff0\deflang1033\deflangfe1049
+{\fonttbl
+{\f0\froman\fcharset204\fprq2
+Times New Roman;}
+{\f1\fswiss\fcharset204\fprq2
+Arial;}
+}
+{\stylesheet
+{\nowidctlpar\widctlpar\adjustright \lang1049\cgrid \snext0 style0;}
+{\s1\sb240\sa60\nowidctlpar\widctlpar\adjustright \b\f1\fs32\lang1049\kerning32\cgrid
+\sbasedon0 \snext0 style 1;}
+{\*\cs10 \additive style10;}
+}
+\paperw16838\paperh11906\margl1134\margr1134\margt1701\margb851
+\deftab708\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot \fet0\sectd \lndscpsxn\psz9\linex0\headery709\footery709\colsx708\endnhere\sectlinegrid360\sectdefaultcl
+\trowd \trgaph108\trrh105\trleft237\trkeep\trbrdrt\brdrs\brdrw45 \trbrdrl\brdrs\brdrw45 \trbrdrb\brdrs\brdrw45 \trbrdrr\brdrs\brdrw45 \clvmgf\clvertalt\clbrdrt
+\brdrs\brdrw45 \clbrdrl\brdrs\brdrw45 \clbrdrb\brdrs\brdrw45 \clbrdrr\brdrs\brdrw45 \cltxlrtb \cellx3274\clvmgf\clvertalt\clbrdrt\brdrs\brdrw45 \clbrdrl\brdrs\brdrw45 \clbrdrb\brdrs\brdrw15 \cltxlrtb \cellx7187\clvertalt\clbrdrt\brdrs\brdrw45 \cltxlrtb
+\cellx7753\clvmgf\clvertalt\clbrdrt\brdrs\brdrw45 \clbrdrb\brdrs\brdrw15 \clbrdrr\brdrs\brdrw45 \cltxlrtb \cellx11026\pard\plain \s1\qc\sb240\sa60\nowidctlpar\widctlpar\intbl\outlinelevel0\adjustright \b\f1\fs32\lang1049\kerning32\cgrid
+{\fs16 first line
+\par }
+\pard\plain \qc\nowidctlpar\widctlpar\intbl\adjustright \lang1049\cgrid
+{
+\par
+\par }
+{\b\fs18 last line\cell }
+\pard \nowidctlpar\widctlpar\intbl\adjustright
+{\fs16
+picture
+}
+{\fs16\lang1033
+\par }
+{\fs16 \cell }
+{\f15\fs16 \cell }
+{\b\i\f15\fs16 last cell}
+{\fs16 )
+\par \cell }
+\pard \nowidctlpar\widctlpar\intbl\adjustright
+{\fs20 \row }
+\pard \nowidctlpar\widctlpar\adjustright
+{
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index e1437c8..fcd33da 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -164,6 +164,7 @@ public:
void testFdo53556();
void testFdo63428();
void testGroupshapeRotation();
+ void testFdo44715();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -312,6 +313,7 @@ void Test::run()
{"fdo53556.rtf", &Test::testFdo53556},
{"hello.rtf", &Test::testFdo63428},
{"groupshape-rotation.rtf", &Test::testGroupshapeRotation},
+ {"fdo44715.rtf", &Test::testFdo44715},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1530,6 +1532,14 @@ void Test::testGroupshapeRotation()
CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty<sal_Int32>(xDraws->getByIndex(0), "RotateAngle"));
}
+void Test::testFdo44715()
+{
+ uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+ // Style information wasn't reset, which caused character height to be 16.
+ CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getParagraphOfText(2, xCell->getText()), "CharHeight"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 3d995c6..da7a81c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2268,21 +2268,17 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
if (m_bHadPicture)
dispatchSymbol(RTF_PAR);
// \pard is allowed between \cell and \row, but in that case it should not reset the fact that we're inside a table.
+ m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
+ m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
if (m_aStates.top().nCells == 0)
{
- // Reset everything.
- m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
- m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
+ // Reset that we're in a table.
m_aStates.top().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().aParagraphSprms.erase(NS_sprm::LN_PJc);
+ // We are still in a table.
+ m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PFInTable, RTFValue::Pointer_t(new RTFValue(1)));
}
m_aStates.top().resetFrame();
break;
More information about the Libreoffice-commits
mailing list