sw/qa/extras/odfimport/data/fdo79269.odt |binary sw/qa/extras/odfimport/data/fdo79269_header.odt |binary sw/qa/extras/odfimport/odfimport.cxx | 35 ++++++++++++++++++++++++ sw/source/core/unocore/unostyle.cxx | 35 +++++++++++++----------- 4 files changed, 55 insertions(+), 15 deletions(-)
New commits: commit 902de8a1cbdb86c1eb1a05c8307b109fd75f493c Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 30 17:59:08 2014 +0200 fdo#79269: fix ODF import of style:footer-first The implementation of SwXStyle's FirstIsShared property is busted, and that causes xmloff to write the footer-first content into the master footer. This is a re-implementation of 0f21f932081471b2a5eda820fa1a194fbf3ab85c because unostyle.cxx is very different on master... Change-Id: I485d8089c1fb5ba3ca369fbfe8f3115bf700ba13 Reviewed-on: https://gerrit.libreoffice.org/11722 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/odfimport/data/fdo79269.odt b/sw/qa/extras/odfimport/data/fdo79269.odt new file mode 100644 index 0000000..2e3bf1e Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo79269.odt differ diff --git a/sw/qa/extras/odfimport/data/fdo79269_header.odt b/sw/qa/extras/odfimport/data/fdo79269_header.odt new file mode 100644 index 0000000..6f1a839 Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo79269_header.odt differ diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 8cd4b09..36aa437 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -272,6 +272,41 @@ DECLARE_ODFIMPORT_TEST(testFdo60842, "fdo60842.odt") getCell(xTable, "E1", "01/04/2012"); } +DECLARE_ODFIMPORT_TEST(testFdo79269, "fdo79269.odt") +{ + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage()); + + // The problem was that the first-footer was shared. + uno::Reference<beans::XPropertySet> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropSet, "FirstIsShared")); + + uno::Reference<text::XTextRange> xFooter1 = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "FooterTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1->getString()); + uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "FooterText"); + CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter->getString()); +} + +DECLARE_ODFIMPORT_TEST(testFdo79269_header, "fdo79269_header.odt") +{ + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage()); + + uno::Reference<beans::XPropertySet> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropSet, "FirstIsShared")); + + uno::Reference<text::XTextRange> xFooter1 = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "HeaderTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1->getString()); + uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter->getString()); +} + DECLARE_ODFIMPORT_TEST(testFdo56272, "fdo56272.odt") { uno::Reference<drawing::XShape> xShape = getShape(1); diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 5c24b91..4ed26e0 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -462,6 +462,24 @@ SwXStyleFamily::~SwXStyleFamily() } +static bool lcl_GetHeaderFooterItem( + SfxItemSet const& rSet, OUString const& rPropName, bool const bFooter, + SvxSetItem const*& o_rpItem) +{ + SfxItemState eState = rSet.GetItemState( + (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, + false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem)); + if (SFX_ITEM_SET != eState && + rPropName == UNO_NAME_FIRST_IS_SHARED) + { // fdo#79269 header may not exist, check footer then + eState = rSet.GetItemState( + (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, + false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem)); + } + return SFX_ITEM_SET == eState; +} + + static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, SfxStyleFamily eFamily, OUString *pString, sal_uInt16 nIndex = USHRT_MAX) { @@ -3093,20 +3111,9 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( break; } const SvxSetItem* pSetItem; - if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState( - bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, (const SfxPoolItem**)&pSetItem)) + if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(), pNames[nProp], bFooter, pSetItem)) { lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl); - - if (nRes == SID_ATTR_PAGE_SHARED_FIRST) - { - // Need to add this to the other as well - if (SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState( - bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET, - false, (const SfxPoolItem**)&pSetItem)) - lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl); - } } else if(SID_ATTR_PAGE_ON == nRes ) { @@ -3350,9 +3357,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( break; } const SvxSetItem* pSetItem; - if(SFX_ITEM_SET == rSet.GetItemState( - bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, (const SfxPoolItem**)&pSetItem)) + if (lcl_GetHeaderFooterItem(rSet, pNames[nProp], bFooter, pSetItem)) { const SfxItemSet& rTmpSet = pSetItem->GetItemSet(); const SfxPoolItem* pItem = 0; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits