sc/source/filter/xml/XMLConsolidationContext.cxx | 4 +- sw/qa/extras/odfimport/data/fdo79269.odt |binary sw/qa/extras/odfimport/odfimport.cxx | 18 +++++++++++ sw/source/core/unocore/unostyle.cxx | 34 ++++++++++++++-------- xmloff/source/text/XMLTextHeaderFooterContext.cxx | 8 +++-- 5 files changed, 49 insertions(+), 15 deletions(-)
New commits: commit 9ea9d4d7c5db4fa85be2e14d29fe631d58b9e60f Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 29 23:41:22 2014 +0200 fdo#79269: sw: more cleanup of SwXStyle's FirstIsShared property Some of the checks for it can never be true given the preceding list of WhichIds, but there is one other case that needs the special handling. Change-Id: Iaf396960d064d0c9f2a950c2d02db1654a669d45 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 81c14ac..3270a31 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -425,6 +425,23 @@ 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 (SfxItemState::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 SfxItemState::SET == eState; +} + static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, SfxStyleFamily eFamily, OUString *pString, sal_uInt16 nIndex = USHRT_MAX) { @@ -2867,10 +2884,7 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( { const SvxSetItem* pSetItem; - if(SfxItemState::SET == rSet.GetItemState( - bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, - (const SfxPoolItem**)&pSetItem)) + if (lcl_GetHeaderFooterItem(rSet, sPropName, bFooter, pSetItem)) { // retarget the SfxItemSet to the HeaderFooter SfxSetItem's SfxItenSet pSourceSet = &pSetItem->GetItemSet(); @@ -3420,18 +3434,8 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( { // it is a Header/Footer entry, access the SvxSetItem containing it's information const SvxSetItem* pSetItem = 0; - - SfxItemState eState = aBaseImpl.GetItemSet().GetItemState( - (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)); - if (SfxItemState::SET != eState && - rPropName == UNO_NAME_FIRST_IS_SHARED) - { // fdo#79269 header may not exist, check footer then - eState = aBaseImpl.GetItemSet().GetItemState( - (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)); - } - if (SfxItemState::SET == eState) + if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(), + rPropName, bFooter, pSetItem)) { lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); @@ -3532,7 +3536,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( const bool bHeader(rPropName.startsWith("Header")); const bool bFooter(rPropName.startsWith("Footer")); - if(bHeader || bFooter || rPropName == UNO_NAME_FIRST_IS_SHARED) + if (bHeader || bFooter) { const SvxSetItem* pSetItem = 0; @@ -3736,17 +3740,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( const SfxItemSet& rSet = xStyle->GetItemSet(); const SvxSetItem* pSetItem; - SfxItemState eState = rSet.GetItemState( - (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)); - if (SfxItemState::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**>(&pSetItem)); - } - if (SfxItemState::SET == eState) + if (lcl_GetHeaderFooterItem(rSet, rPropName, bFooter, pSetItem)) { // get from SfxItemSet of the corresponding SfxSetItem const SfxItemSet& rSetSet = pSetItem->GetItemSet(); @@ -3813,7 +3807,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( const bool bHeader(rPropName.startsWith("Header")); const bool bFooter(rPropName.startsWith("Footer")); - if(bHeader || bFooter || rPropName == UNO_NAME_FIRST_IS_SHARED) + if (bHeader || bFooter) { rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) ); const SfxItemSet& rSet = xStyle->GetItemSet(); commit 0f21f932081471b2a5eda820fa1a194fbf3ab85c Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 29 23:22:12 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. Change-Id: I520a4929d9d7313da65bcdcf4094f8244382377d 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/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 76f00bb..94eeb83 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -272,6 +272,24 @@ 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(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 e17fce9..81c14ac 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3421,9 +3421,17 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( // it is a Header/Footer entry, access the SvxSetItem containing it's information const SvxSetItem* pSetItem = 0; - if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState( - bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, - false, (const SfxPoolItem**)&pSetItem)) + SfxItemState eState = aBaseImpl.GetItemSet().GetItemState( + (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, + false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)); + if (SfxItemState::SET != eState && + rPropName == UNO_NAME_FIRST_IS_SHARED) + { // fdo#79269 header may not exist, check footer then + eState = aBaseImpl.GetItemSet().GetItemState( + (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, + false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)); + } + if (SfxItemState::SET == eState) { lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); @@ -3728,7 +3736,17 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( const SfxItemSet& rSet = xStyle->GetItemSet(); const SvxSetItem* pSetItem; - if(SfxItemState::SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, (const SfxPoolItem**)&pSetItem)) + SfxItemState eState = rSet.GetItemState( + (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, + false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)); + if (SfxItemState::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**>(&pSetItem)); + } + if (SfxItemState::SET == eState) { // get from SfxItemSet of the corresponding SfxSetItem const SfxItemSet& rSetSet = pSetItem->GetItemSet(); diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx index 6ee1e73..b396e91 100644 --- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx +++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx @@ -68,7 +68,9 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa if (bLeft) { aAny = xPropSet->getPropertyValue( sShareContent ); - sal_Bool bShared = *(sal_Bool *)aAny.getValue(); + bool bShared; + if (!(aAny >>= bShared)) + assert(false); // should return a value! if( bShared ) { // Don't share headers any longer @@ -80,7 +82,9 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa if (bFirst) { aAny = xPropSet->getPropertyValue( sShareContentFirst ); - sal_Bool bSharedFirst = aAny.has<sal_Bool>() && *(sal_Bool *)aAny.getValue(); + bool bSharedFirst; + if (!(aAny >>= bSharedFirst)) + assert(false); // should return a value! if( bSharedFirst ) { // Don't share first/right headers any longer commit 87331efa9b190793c1719b31a62a2eef6a66f92d Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 29 21:23:20 2014 +0200 sc: fix locking in ScXMLConsolidationContext Essentially revert commit 4fa05ecc089a027f243e87f76cc9bcd1f70447e4, plus move the unlock to the dtor for more RAII-ness. Change-Id: Ie5a9cc183626e3f5b005348606bffa69c4be4f7f diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx index e211505..525aacf 100644 --- a/sc/source/filter/xml/XMLConsolidationContext.cxx +++ b/sc/source/filter/xml/XMLConsolidationContext.cxx @@ -38,7 +38,7 @@ ScXMLConsolidationContext::ScXMLConsolidationContext( bLinkToSource( false ), bTargetAddr(false) { - ScXMLImport::MutexGuard aGuard(GetScImport()); + rImport.LockSolarMutex(); if( !xAttrList.is() ) return; sal_Int16 nAttrCount = xAttrList->getLength(); @@ -78,6 +78,7 @@ ScXMLConsolidationContext::ScXMLConsolidationContext( ScXMLConsolidationContext::~ScXMLConsolidationContext() { + GetScImport().UnlockSolarMutex(); } SvXMLImportContext *ScXMLConsolidationContext::CreateChildContext( @@ -136,7 +137,6 @@ void ScXMLConsolidationContext::EndElement() if( pDoc ) pDoc->SetConsolidateDlgData( &aConsParam ); } - GetScImport().UnlockSolarMutex(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits