diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-09-11 12:23:18 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-09-11 14:58:21 +0200 |
commit | 04fe5e6a31c9701177a744bbc8a53b2f664fe71c (patch) | |
tree | bcdc45c93149f7c2d2a7e809b26b0025cbc75c76 | |
parent | 4d3c88805d1917932ee88a0f22ae93c43e8e389a (diff) |
fdo#82114 RTF import: fix handling of first page in non-first section
Change-Id: If06c6bcdda97447e6014223d997c7ff8abd64b48
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo82114.rtf | 14 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 13 |
3 files changed, 32 insertions, 4 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo82114.rtf b/sw/qa/extras/rtfimport/data/fdo82114.rtf new file mode 100644 index 000000000000..073d2818b207 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo82114.rtf @@ -0,0 +1,14 @@ +{\rtf1 +\paperw11906\paperh16838\margl1134\margr567\margt1418\margb851\gutter0\ltrsect +\viewkind1\viewscale110\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nojkernpunct\rsidroot13516616\utinl \fet0 +\titlepg +{\headerr Right page header, section 1\par +} +{\headerf First page header, section 1\par +} +\pard\plain First page, section 1.\par\sect +\sectd\titlepg +{\headerf First page header, section 2\par +} +\pard\plain First page, section 2.\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index acd78d0461fe..1dda1c45b972 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1932,6 +1932,15 @@ DECLARE_RTFIMPORT_TEST(testCsBold, "cs-bold.rtf") CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), "CharWeight")); } +DECLARE_RTFIMPORT_TEST(testFdo82114, "fdo82114.rtf") +{ + uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Converted1"), "HeaderText"); + OUString aActual = xHeaderText->getString(); + OUString aExpected("First page header, section 2"); + // This was 'Right page header, section 1'. + CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index e774010e5764..c6dcc394ffcc 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -524,14 +524,18 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( m_aFirstPageStyle = uno::Reference< beans::XPropertySet > ( xTextFactory->createInstance("com.sun.star.style.PageStyle"), uno::UNO_QUERY); + + // Call insertByName() before GetPageStyle(), otherwise the + // first and the follow page style will have the same name, and + // insertByName() will fail. + if (xPageStyles.is()) + xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) ); + // Ensure that m_aFollowPageStyle has been created GetPageStyle( xPageStyles, xTextFactory, false ); // Chain m_aFollowPageStyle to be after m_aFirstPageStyle m_aFirstPageStyle->setPropertyValue("FollowStyle", uno::makeAny(m_sFollowPageStyleName)); - - if (xPageStyles.is()) - xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) ); } else if( !m_aFirstPageStyle.is() && xPageStyles.is() ) { @@ -558,8 +562,9 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( } } - catch( const uno::Exception& ) + catch( const uno::Exception& rException ) { + SAL_WARN("writerfilter", "SectionPropertyMap::GetPageStyle() failed: " << rException.Message); } return xRet; |