Rebased ref, commits from common ancestor: commit 5e4aec90aefbb86c98ccaba9c775d4a539f1b934 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 15:05:39 2016 +0100
getTypes/queryInterface/getEvents: remove superfluous getArray() and simplify Change-Id: I5b19d01d2760c95d9c52b15f8d6174dc4aafb4e3 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 4c54906..da53140 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3202,28 +3202,28 @@ const SfxPoolItem* SwXFrameStyle::GetItem(enum RES_FRMATR eAtr) return &xStyle->GetItemSet().Get(eAtr); } -uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException, std::exception) +uno::Sequence<uno::Type> SwXFrameStyle::getTypes() + throw(uno::RuntimeException, std::exception) { - uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes(); + uno::Sequence<uno::Type> aTypes = SwXStyle::getTypes(); sal_Int32 nLen = aTypes.getLength(); aTypes.realloc(nLen + 1); - aTypes.getArray()[nLen] = cppu::UnoType<XEventsSupplier>::get(); + aTypes[nLen] = cppu::UnoType<XEventsSupplier>::get(); return aTypes; } -uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception) +uno::Any SwXFrameStyle::queryInterface(const uno::Type& rType) + throw(uno::RuntimeException, std::exception) { - uno::Any aRet; if(rType == cppu::UnoType<XEventsSupplier>::get()) - aRet <<= uno::Reference<XEventsSupplier>(this); - else - aRet = SwXStyle::queryInterface(rType); - return aRet; + return uno::makeAny(uno::Reference<XEventsSupplier>(this)); + return SwXStyle::queryInterface(rType); } -uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException, std::exception) +uno::Reference<container::XNameReplace> SwXFrameStyle::getEvents() + throw(uno::RuntimeException, std::exception) { - return new SwFrameStyleEventDescriptor( *this ); + return new SwFrameStyleEventDescriptor(*this); } // Already implemented autostyle families: 3 commit 47b6239950adef2ced7f4602acc7d6b22b9ca721 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 15:02:01 2016 +0100 GetItem/SetItem: use GetStyleSheetBase() Change-Id: I7c3b563c6bd095ac9305a5cffdda206c5de94926 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index adbd801..4c54906 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3183,34 +3183,22 @@ SwXFrameStyle::~SwXFrameStyle() void SwXFrameStyle::SetItem(enum RES_FRMATR eAtr, const SfxPoolItem& rItem) { - // As I was told, for some entirely unobvious reason getting an - // item from a style has to look as follows: - SfxStyleSheetBasePool* pBasePool = m_pBasePool; - if (pBasePool) - { - SfxStyleSheetBase* pBase = pBasePool->Find(GetStyleName()); - if (pBase) - { - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - SfxItemSet& rStyleSet = xStyle->GetItemSet(); - SfxItemSet aSet(*rStyleSet.GetPool(), eAtr, eAtr); - aSet.Put(rItem); - xStyle->SetItemSet(aSet); - } - } + SfxStyleSheetBase* pBase = GetStyleSheetBase(); + if(!pBase) + return; + rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + SfxItemSet& rStyleSet = xStyle->GetItemSet(); + SfxItemSet aSet(*rStyleSet.GetPool(), eAtr, eAtr); + aSet.Put(rItem); + xStyle->SetItemSet(aSet); } const SfxPoolItem* SwXFrameStyle::GetItem(enum RES_FRMATR eAtr) { - // As I was told, for some entirely unobvious reason getting an - // item from a style has to look as follows: - SfxStyleSheetBasePool* pBasePool = m_pBasePool; - if(!pBasePool) - return nullptr; - SfxStyleSheetBase* pBase = pBasePool->Find(GetStyleName()); + SfxStyleSheetBase* pBase = GetStyleSheetBase(); if(!pBase) return nullptr; - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase)) ); + rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); return &xStyle->GetItemSet().Get(eAtr); } commit a4d50fa571ff24fb6d842675e550539de2a9c7da Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 14:58:30 2016 +0100 getPropertyValues, getPropertyValue, setPropertyValue: formatting/whitespace Change-Id: I9a08b46037eee210fd9beae7670a2efb0e5e8888 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a999463..adbd801 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3134,59 +3134,53 @@ uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(const uno::Sequence return aRet; } -uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues( - const uno::Sequence< OUString >& rPropertyNames ) +uno::Sequence<uno::Any> SwXPageStyle::getPropertyValues(const uno::Sequence<OUString>& rPropertyNames) throw(uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - uno::Sequence< uno::Any > aValues; + uno::Sequence<uno::Any> aValues; // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = GetPropertyValues_Impl(rPropertyNames); } - catch (beans::UnknownPropertyException &) + catch(beans::UnknownPropertyException &) { - throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("Unknown property exception caught", static_cast<cppu::OWeakObject*>(this)); } - catch (lang::WrappedTargetException &) + catch(lang::WrappedTargetException &) { - throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("WrappedTargetException caught", static_cast<cppu::OWeakObject*>(this)); } return aValues; } -uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw( - beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) +uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; const uno::Sequence<OUString> aProperties(&rPropertyName, 1); - return GetPropertyValues_Impl(aProperties).getConstArray()[0]; + return GetPropertyValues_Impl(aProperties)[0]; } void SwXPageStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue) - throw( beans::UnknownPropertyException, - beans::PropertyVetoException, - lang::IllegalArgumentException, - lang::WrappedTargetException, - uno::RuntimeException, std::exception) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; const uno::Sequence<OUString> aProperties(&rPropertyName, 1); const uno::Sequence<uno::Any> aValues(&rValue, 1); - SetPropertyValues_Impl( aProperties, aValues ); + SetPropertyValues_Impl(aProperties, aValues); } -SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc ) -: SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, false) -{ -} +SwXFrameStyle::SwXFrameStyle(SwDoc *pDoc) + : SwXStyle(pDoc, SFX_STYLE_FAMILY_FRAME, false) +{ } SwXFrameStyle::~SwXFrameStyle() -{ -} +{ } + void SwXFrameStyle::SetItem(enum RES_FRMATR eAtr, const SfxPoolItem& rItem) { // As I was told, for some entirely unobvious reason getting an commit daf39a7626f1ccaf2c0a32c33a4c3edc1b6069fd Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 14:30:11 2016 +0100 refactor GetPropertyValues_Impl - use GetStyleSheetBase() - check preconditions and special cases early - limit scope of variables Change-Id: Idb49f84e97348bcbf8a3a75831b56ad82872720e diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 8923871..a999463 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2950,38 +2950,40 @@ uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(const uno::Sequence throw uno::RuntimeException(); sal_Int32 nLength = rPropertyNames.getLength(); - const OUString* pNames = rPropertyNames.getConstArray(); - uno::Sequence< uno::Any > aRet ( nLength ); - - uno::Any* pRet = aRet.getArray(); + uno::Sequence<uno::Any> aRet (nLength); + if(!m_pBasePool) + { + if(!IsDescriptor()) + throw uno::RuntimeException(); + for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp) + { + const uno::Any* pAny = nullptr; + m_pPropertiesImpl->GetProperty(rPropertyNames[nProp], pAny); + if (!pAny->hasValue()) + SwStyleProperties_Impl::GetProperty(rPropertyNames[nProp], m_xStyleData, aRet[nProp]); + else + aRet[nProp] = *pAny; + } + return aRet; + } const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap(); SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet()); //UUUU add pDfltFrameFormat as parent - SfxStyleSheetBase* pBase = nullptr; - - for(sal_Int32 nProp = 0; nProp < nLength; nProp++) + SfxStyleSheetBase* pBase = GetStyleSheetBase(); + if(!pBase) + throw uno::RuntimeException(); + for(sal_Int32 nProp = 0; nProp < nLength; ++nProp) { - const OUString& rPropName = pNames[nProp]; + const OUString& rPropName = rPropertyNames[nProp]; const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName); if (!pEntry) - { throw beans::UnknownPropertyException("Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); - } - - if(m_pBasePool) + const bool bHeader(rPropName.startsWith("Header")); + const bool bFooter(rPropName.startsWith("Footer")); + const bool bFirstIsShared(rPropName == UNO_NAME_FIRST_IS_SHARED); + if(bHeader || bFooter || bFirstIsShared) { - if(!pBase) - { - const sal_uInt16 nSaveMask = m_pBasePool->GetSearchMask(); - m_pBasePool->SetSearchMask(GetFamily()); - pBase = m_pBasePool->Find(GetStyleName()); - m_pBasePool->SetSearchMask(GetFamily(), nSaveMask ); - } - - sal_uInt16 nRes = 0; - const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); - switch(pEntry->nWID) { case SID_ATTR_PAGE_ON: @@ -2996,57 +2998,27 @@ uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(const uno::Sequence case SID_ATTR_PAGE_SIZE: case RES_HEADER_FOOTER_EAT_SPACING: { - // These slots are used for Header, Footer and (partially) for PageStyle directly. - // Check for Header/Footer entry - const bool bHeader(rPropName.startsWith("Header")); - const bool bFooter(rPropName.startsWith("Footer")); + // slot is a Header/Footer slot + rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); + const SfxItemSet& rSet = xStyle->GetItemSet(); + const SvxSetItem* pSetItem; - if(bHeader || bFooter || rPropName == UNO_NAME_FIRST_IS_SHARED) + if (lcl_GetHeaderFooterItem(rSet, rPropName, bFooter, pSetItem)) { - // slot is a Header/Footer slot - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - const SfxItemSet& rSet = xStyle->GetItemSet(); - const SvxSetItem* pSetItem; - - if (lcl_GetHeaderFooterItem(rSet, rPropName, bFooter, pSetItem)) - { - // get from SfxItemSet of the corresponding SfxSetItem - const SfxItemSet& rSetSet = pSetItem->GetItemSet(); - { - SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast< SfxItemSet& >(rSetSet)); - pRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); - } - } - else if(pEntry->nWID == SID_ATTR_PAGE_ON) + // get from SfxItemSet of the corresponding SfxSetItem + const SfxItemSet& rSetSet = pSetItem->GetItemSet(); { - // header/footer is not available, thus off. Default is <false>, though - pRet[nProp] <<= false; + SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast< SfxItemSet& >(rSetSet)); + aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); } } - else + else if(pEntry->nWID == SID_ATTR_PAGE_ON) { - switch(pEntry->nWID) - { - case SID_ATTR_PAGE_DYNAMIC: - case SID_ATTR_PAGE_SHARED: - case SID_ATTR_PAGE_SHARED_FIRST: - case SID_ATTR_PAGE_ON: - case RES_HEADER_FOOTER_EAT_SPACING: - { - // these slots are exclusive to Header/Footer, thus this is an error - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); - } - default: - { - // part of PageStyle, fallback to default - pRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); - } - } + // header/footer is not available, thus off. Default is <false>, though + aRet[nProp] <<= false; } - - break; } - + continue; case XATTR_FILLBMP_SIZELOG: case XATTR_FILLBMP_TILEOFFSETX: case XATTR_FILLBMP_TILEOFFSETY: @@ -3068,130 +3040,97 @@ uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(const uno::Sequence case XATTR_FILLTRANSPARENCE: case XATTR_FILLFLOATTRANSPARENCE: case XATTR_SECONDARYFILLCOLOR: + if(bFirstIsShared) // only special handling for headers/footers here + break; { - // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle - // itself, so decide what to do using the name - const bool bHeader(rPropName.startsWith("Header")); - const bool bFooter(rPropName.startsWith("Footer")); - - if (bHeader || bFooter) + rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); + const SfxItemSet& rSet = xStyle->GetItemSet(); + const SvxSetItem* pSetItem; + if(SfxItemState::SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) { - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - const SfxItemSet& rSet = xStyle->GetItemSet(); - const SvxSetItem* pSetItem; - if(SfxItemState::SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) + // set at SfxItemSet of the corresponding SfxSetItem + const SfxItemSet& rSetSet = pSetItem->GetItemSet(); { - // set at SfxItemSet of the corresponding SfxSetItem - const SfxItemSet& rSetSet = pSetItem->GetItemSet(); - { - SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast<SfxItemSet&>(rSetSet)); - pRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); - } + SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast<SfxItemSet&>(rSetSet)); + aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); } } - else - { - // part of PageStyle, fallback to default - pRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); - } - - break; } - - case FN_UNO_HEADER: - case FN_UNO_HEADER_LEFT: - case FN_UNO_HEADER_FIRST: - case FN_UNO_HEADER_RIGHT: - case FN_UNO_FOOTER: - case FN_UNO_FOOTER_LEFT: - case FN_UNO_FOOTER_FIRST: - case FN_UNO_FOOTER_RIGHT: + continue; + default: ; + } + } + switch(pEntry->nWID) + { + // these slots are exclusive to Header/Footer, thus this is an error + case SID_ATTR_PAGE_DYNAMIC: + case SID_ATTR_PAGE_SHARED: + case SID_ATTR_PAGE_SHARED_FIRST: + case SID_ATTR_PAGE_ON: + case RES_HEADER_FOOTER_EAT_SPACING: + throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); + case FN_UNO_HEADER: + case FN_UNO_HEADER_LEFT: + case FN_UNO_HEADER_FIRST: + case FN_UNO_HEADER_RIGHT: + case FN_UNO_FOOTER: + case FN_UNO_FOOTER_LEFT: + case FN_UNO_FOOTER_FIRST: + case FN_UNO_FOOTER_RIGHT: + { + bool bLeft(false); + bool bFirst(false); + sal_uInt16 nRes = 0; + switch(pEntry->nWID) { - //UUUU cleanups for readability (undos removed, rearranged) - bool bHeader(false); - bool bLeft(false); - bool bFirst(false); - - switch(pEntry->nWID) - { - case FN_UNO_HEADER: bHeader = true; nRes = RES_HEADER; break; - case FN_UNO_HEADER_LEFT: bHeader = true; nRes = RES_HEADER; bLeft = true; break; - case FN_UNO_HEADER_FIRST: bHeader = true; nRes = RES_HEADER; bFirst = true; break; - case FN_UNO_HEADER_RIGHT: bHeader = true; nRes = RES_HEADER; break; - case FN_UNO_FOOTER: bHeader = false; nRes = RES_FOOTER; break; - case FN_UNO_FOOTER_LEFT: bHeader = false; nRes = RES_FOOTER; bLeft = true; break; - case FN_UNO_FOOTER_FIRST: bHeader = false; nRes = RES_FOOTER; bFirst = true; break; - case FN_UNO_FOOTER_RIGHT: bHeader = false; nRes = RES_FOOTER; break; - default: break; - } - - const SwPageDesc* pDesc = aBase.GetOldPageDesc(); - assert(pDesc); - const SwFrameFormat* pFrameFormat = nullptr; - bool bShare = (bHeader && pDesc->IsHeaderShared()) || (!bHeader && pDesc->IsFooterShared()); - bool bShareFirst = pDesc->IsFirstShared(); - // TextLeft returns the left content if there is one, - // Text and TextRight return the master content. - // TextRight does the same as Text and is for - // compatibility only. - if( bLeft && !bShare ) - { - pFrameFormat = &pDesc->GetLeft(); - } - else if (bFirst && !bShareFirst) - { - pFrameFormat = &pDesc->GetFirstMaster(); - // no need to make GetFirstLeft() accessible - // since it is always shared - } - else - { - pFrameFormat = &pDesc->GetMaster(); - } - const uno::Reference< text::XText > xRet = - lcl_makeHeaderFooter(nRes, bHeader, pFrameFormat); - if (xRet.is()) - { - pRet[nProp] <<= xRet; - } - break; + case FN_UNO_HEADER: nRes = RES_HEADER; break; + case FN_UNO_HEADER_LEFT: nRes = RES_HEADER; bLeft = true; break; + case FN_UNO_HEADER_FIRST: nRes = RES_HEADER; bFirst = true; break; + case FN_UNO_HEADER_RIGHT: nRes = RES_HEADER; break; + case FN_UNO_FOOTER: nRes = RES_FOOTER; break; + case FN_UNO_FOOTER_LEFT: nRes = RES_FOOTER; bLeft = true; break; + case FN_UNO_FOOTER_FIRST: nRes = RES_FOOTER; bFirst = true; break; + case FN_UNO_FOOTER_RIGHT: nRes = RES_FOOTER; break; + default: ; } - case FN_PARAM_FTN_INFO : + const SwPageDesc* pDesc = aBase.GetOldPageDesc(); + assert(pDesc); + const SwFrameFormat* pFrameFormat = nullptr; + bool bShare = (nRes == RES_HEADER && pDesc->IsHeaderShared()) || (nRes == RES_FOOTER && pDesc->IsFooterShared()); + bool bShareFirst = pDesc->IsFirstShared(); + // TextLeft returns the left content if there is one, + // Text and TextRight return the master content. + // TextRight does the same as Text and is for + // compatibility only. + if(bLeft && !bShare) + pFrameFormat = &pDesc->GetLeft(); + else if(bFirst && !bShareFirst) { - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - const SfxItemSet& rSet = xStyle->GetItemSet(); - const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO); - rItem.QueryValue(pRet[nProp], nMemberId); - break; + pFrameFormat = &pDesc->GetFirstMaster(); + // no need to make GetFirstLeft() accessible + // since it is always shared } - default: - { - //UUUU - pRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); - break; - } - } - } - else if(IsDescriptor()) - { - const uno::Any* pAny = nullptr; - m_pPropertiesImpl->GetProperty(rPropName, pAny); - if (!pAny->hasValue()) - { - SwStyleProperties_Impl::GetProperty(rPropName, m_xStyleData, pRet[nProp]); + else + pFrameFormat = &pDesc->GetMaster(); + const uno::Reference<text::XText> xRet = lcl_makeHeaderFooter(nRes, nRes == RES_HEADER, pFrameFormat); + if (xRet.is()) + aRet[nProp] = uno::makeAny(xRet); } - else + break; + case FN_PARAM_FTN_INFO: { - pRet[nProp] = *pAny; + rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + const SfxItemSet& rSet = xStyle->GetItemSet(); + const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO); + const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); + rItem.QueryValue(aRet[nProp], nMemberId); } - } - else - { - throw uno::RuntimeException(); + break; + default: + aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); } } - return aRet; } commit 281623aa411d5ed9ef2f2f14293af98f07bb0013 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 13:04:16 2016 +0100 formatting: setPropertyValues, lcl_makeHeaderFooter Change-Id: I55e9d5a0616b5ee8d0d678317086d0fdb2386e1a diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index e5d5851..8923871 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2908,9 +2908,7 @@ void SwXPageStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rProper } } -void SwXPageStyle::setPropertyValues( - const uno::Sequence< OUString >& rPropertyNames, - const uno::Sequence< uno::Any >& rValues ) +void SwXPageStyle::setPropertyValues(const uno::Sequence<OUString>& rPropertyNames, const uno::Sequence<uno::Any>& rValues) throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; @@ -2918,7 +2916,7 @@ void SwXPageStyle::setPropertyValues( // workaround for bad designed API try { - SetPropertyValues_Impl( rPropertyNames, rValues ); + SetPropertyValues_Impl(rPropertyNames, rValues); } catch (const beans::UnknownPropertyException &rException) { @@ -2930,27 +2928,20 @@ void SwXPageStyle::setPropertyValues( } } -static uno::Reference<text::XText> -lcl_makeHeaderFooter( - const sal_uInt16 nRes, const bool bHeader, SwFrameFormat const*const pFrameFormat) +static uno::Reference<text::XText> lcl_makeHeaderFooter(const sal_uInt16 nRes, const bool bHeader, SwFrameFormat const*const pFrameFormat) { - if (!pFrameFormat) { return nullptr; } - + if (!pFrameFormat) + return nullptr; const SfxItemSet& rSet = pFrameFormat->GetAttrSet(); const SfxPoolItem* pItem; - if (SfxItemState::SET == rSet.GetItemState(nRes, true, &pItem)) - { - SwFrameFormat *const pHeadFootFormat = (bHeader) - ? static_cast<SwFormatHeader*>(const_cast<SfxPoolItem*>(pItem))-> - GetHeaderFormat() - : static_cast<SwFormatFooter*>(const_cast<SfxPoolItem*>(pItem))-> - GetFooterFormat(); - if (pHeadFootFormat) - { - return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFormat, bHeader); - } - } - return nullptr; + if(SfxItemState::SET != rSet.GetItemState(nRes, true, &pItem)) + return nullptr; + SwFrameFormat* const pHeadFootFormat = (bHeader) + ? static_cast<SwFormatHeader*>(const_cast<SfxPoolItem*>(pItem))->GetHeaderFormat() + : static_cast<SwFormatFooter*>(const_cast<SfxPoolItem*>(pItem))->GetFooterFormat(); + if(!pHeadFootFormat) + return nullptr; + return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFormat, bHeader); } uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNames) commit 189ffe46107f10e3da80c4f11bc629bebd584960 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 12:20:36 2016 +0100 refactor SetPropertyValues_Impl - use GetStyleSheetBase() - check preconditions and special cases early Change-Id: I95eb4cde66b9da2969bb257bd2de6b319b2b3950 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index e042560..e5d5851 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2705,9 +2705,7 @@ void SwXStyle::PutItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet rBaseImpl.GetItemSet().Put(*pNewSetItem); } -void SwXPageStyle::SetPropertyValues_Impl( - const uno::Sequence< OUString >& rPropertyNames, - const uno::Sequence< uno::Any >& rValues ) +void SwXPageStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNames, const uno::Sequence<uno::Any>& rValues) { if(!GetDoc()) throw uno::RuntimeException(); @@ -2715,44 +2713,36 @@ void SwXPageStyle::SetPropertyValues_Impl( if(rPropertyNames.getLength() != rValues.getLength()) throw lang::IllegalArgumentException(); - const OUString* pNames = rPropertyNames.getConstArray(); - const uno::Any* pValues = rValues.getConstArray(); const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE); const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap(); SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet()); //UUUU add pDfltFrameFormat as parent - if(m_pBasePool) + if(!m_pBasePool) { - const sal_uInt16 nSaveMask = m_pBasePool->GetSearchMask(); - m_pBasePool->SetSearchMask(GetFamily()); - SfxStyleSheetBase* pBase = m_pBasePool->Find(GetStyleName()); - m_pBasePool->SetSearchMask(GetFamily(), nSaveMask ); - OSL_ENSURE(pBase, "where is the style?" ); - if(pBase) - { - aBaseImpl.setNewBase(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); - } - else - { + if(!IsDescriptor()) throw uno::RuntimeException(); - } + for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp) + if(!m_pPropertiesImpl->SetProperty(rPropertyNames[nProp], rValues[nProp])) + throw lang::IllegalArgumentException(); + return; } - - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxStyleSheetBase* pBase = GetStyleSheetBase(); + if(!pBase) + throw uno::RuntimeException(); + aBaseImpl.setNewBase(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp) { - const OUString& rPropName = pNames[nProp]; + const OUString& rPropName = rPropertyNames[nProp]; const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName); - if (!pEntry) - { - throw beans::UnknownPropertyException("Unknown property: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - } - - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - { - throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - } + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(this)); + if(pEntry->nFlags & beans::PropertyAttribute::READONLY) + throw beans::PropertyVetoException("Property is read-only: " + rPropName, static_cast<cppu::OWeakObject*>(this)); - if(m_pBasePool) + const bool bHeader(rPropName.startsWith("Header")); + const bool bFooter(rPropName.startsWith("Footer")); + const bool bFirstIsShared(rPropName == UNO_NAME_FIRST_IS_SHARED); + if(bHeader || bFooter || bFirstIsShared) { switch(pEntry->nWID) { @@ -2768,89 +2758,54 @@ void SwXPageStyle::SetPropertyValues_Impl( case SID_ATTR_PAGE_SIZE: case RES_HEADER_FOOTER_EAT_SPACING: { - // these entries are used in Header, Footer and (partially) in the PageStyle itself. - // Check for Header/Footer entry - const bool bHeader(rPropName.startsWith("Header")); - const bool bFooter(rPropName.startsWith("Footer")); - - if(bHeader || bFooter || rPropName == UNO_NAME_FIRST_IS_SHARED) + // it is a Header/Footer entry, access the SvxSetItem containing it's information + const SvxSetItem* pSetItem = nullptr; + if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(), rPropName, bFooter, pSetItem)) { - // it is a Header/Footer entry, access the SvxSetItem containing it's information - const SvxSetItem* pSetItem = nullptr; - if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(), - rPropName, bFooter, pSetItem)) - { - PutItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl); + PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl); - if (pEntry->nWID == SID_ATTR_PAGE_SHARED_FIRST) - { - // Need to add this to the other as well - if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState( - bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET, - false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) - { - PutItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl); - } - } - } - else if(pEntry->nWID == SID_ATTR_PAGE_ON) + if (pEntry->nWID == SID_ATTR_PAGE_SHARED_FIRST) { - bool bVal = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); - - if(bVal) + // Need to add this to the other as well + if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState( + bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET, + false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) { - // Header/footer gets switched on, create defaults and the needed SfxSetItem - SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(), - RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 - - //UUUU FillAttribute support - XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 - - SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 - SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 - SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 - SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST, - 0); - - //UUUU set correct parent to get the XFILL_NONE FillStyle as needed - aTempSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet()); - - aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, true)); - aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50))); - aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE)); - aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE)); - aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, true)); - aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST, true)); - aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, true)); - - SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet); - aBaseImpl.GetItemSet().Put(aNewSetItem); + PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl); } } } - else + else if(pEntry->nWID == SID_ATTR_PAGE_ON && rValues[nProp].get<bool>()) { - switch(pEntry->nWID) - { - case SID_ATTR_PAGE_DYNAMIC: - case SID_ATTR_PAGE_SHARED: - case SID_ATTR_PAGE_SHARED_FIRST: - case SID_ATTR_PAGE_ON: - case RES_HEADER_FOOTER_EAT_SPACING: - { - // these slots are exclusive to Header/Footer, thus this is an error - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); - } - default: - { - // part of PageStyle, fallback to default - SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl); - } - } + // Header/footer gets switched on, create defaults and the needed SfxSetItem + SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(), + RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82 + + //UUUU FillAttribute support + XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 + + SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023 + SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051 + SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060 + SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST, + 0); + + //UUUU set correct parent to get the XFILL_NONE FillStyle as needed + aTempSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet()); + + aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, true)); + aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50))); + aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE)); + aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE)); + aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, true)); + aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST, true)); + aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, true)); + + SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet); + aBaseImpl.GetItemSet().Put(aNewSetItem); } - break; } - + continue; case XATTR_FILLBMP_SIZELOG: case XATTR_FILLBMP_TILEOFFSETX: case XATTR_FILLBMP_TILEOFFSETY: @@ -2872,85 +2827,70 @@ void SwXPageStyle::SetPropertyValues_Impl( case XATTR_FILLTRANSPARENCE: case XATTR_FILLFLOATTRANSPARENCE: case XATTR_SECONDARYFILLCOLOR: + if(bFirstIsShared) // only special handling for headers/footers here + break; { - // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle - // itself, so decide what to do using the name - const bool bHeader(rPropName.startsWith("Header")); - const bool bFooter(rPropName.startsWith("Footer")); + const SvxSetItem* pSetItem = nullptr; - if (bHeader || bFooter) + if(SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) { - const SvxSetItem* pSetItem = nullptr; + // create a new SvxSetItem and get it's ItemSet as new target + std::unique_ptr<SvxSetItem> pNewSetItem(static_cast<SvxSetItem*>(pSetItem->Clone())); + SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); - if(SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) - { - // create a new SvxSetItem and get it's ItemSet as new target - SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone()); - SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); - - // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem - rSetSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet()); + // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem + rSetSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet()); - // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the - // default method to set the property - { - SwStyleBase_Impl::ItemSetOverrider o(aBaseImpl, &rSetSet); - SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl); - } + // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the + // default method to set the property + { + SwStyleBase_Impl::ItemSetOverrider o(aBaseImpl, &rSetSet); + SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl); + } - // reset paret at ItemSet from SetItem - rSetSet.SetParent(nullptr); + // reset paret at ItemSet from SetItem + rSetSet.SetParent(nullptr); - // set the new SvxSetItem at the real target and delete it - aBaseImpl.GetItemSet().Put(*pNewSetItem); - delete pNewSetItem; - } + // set the new SvxSetItem at the real target and delete it + aBaseImpl.GetItemSet().Put(*pNewSetItem); } - else - { - // part of PageStyle, fallback to default - SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl); - } - - break; - } - case FN_PARAM_FTN_INFO : - { - const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO); - SfxPoolItem* pNewFootnoteItem = rItem.Clone(); - bool bPut = pNewFootnoteItem->PutValue(pValues[nProp], pEntry->nMemberId); - aBaseImpl.GetItemSet().Put(*pNewFootnoteItem); - delete pNewFootnoteItem; - if(!bPut) - throw lang::IllegalArgumentException(); - break; - } - case FN_UNO_HEADER : - case FN_UNO_HEADER_LEFT : - case FN_UNO_HEADER_RIGHT : - case FN_UNO_HEADER_FIRST : - case FN_UNO_FOOTER : - case FN_UNO_FOOTER_LEFT : - case FN_UNO_FOOTER_RIGHT : - case FN_UNO_FOOTER_FIRST : - { - throw lang::IllegalArgumentException(); - } - default: - { - SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl); - break; } + continue; + default: ; } } - else if(IsDescriptor()) + switch(pEntry->nWID) { - if(!m_pPropertiesImpl->SetProperty(rPropName, pValues[nProp])) + case SID_ATTR_PAGE_DYNAMIC: + case SID_ATTR_PAGE_SHARED: + case SID_ATTR_PAGE_SHARED_FIRST: + case SID_ATTR_PAGE_ON: + case RES_HEADER_FOOTER_EAT_SPACING: + // these slots are exclusive to Header/Footer, thus this is an error + throw beans::UnknownPropertyException(OUString("Unknown property: ") + rPropName, static_cast<cppu::OWeakObject*>(this)); + case FN_UNO_HEADER: + case FN_UNO_HEADER_LEFT: + case FN_UNO_HEADER_RIGHT: + case FN_UNO_HEADER_FIRST: + case FN_UNO_FOOTER: + case FN_UNO_FOOTER_LEFT: + case FN_UNO_FOOTER_RIGHT: + case FN_UNO_FOOTER_FIRST: throw lang::IllegalArgumentException(); - } - else - { - throw uno::RuntimeException(); + case FN_PARAM_FTN_INFO: + { + const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO); + const std::unique_ptr<SfxPoolItem> pNewFootnoteItem(rItem.Clone()); + if(!pNewFootnoteItem->PutValue(rValues[nProp], pEntry->nMemberId)) + throw lang::IllegalArgumentException(); + aBaseImpl.GetItemSet().Put(*pNewFootnoteItem); + break; + } + default: + { + SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl); + break; + } } } commit 83963a33da88f47f6e9b865188f9ec442d1ad770 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 12:09:52 2016 +0100 use unique_ptr instead of manual mem-mgmt Change-Id: I68a3d1721fd6e1bcc206bdaec8dcf89a256b5ca1 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 3f88672..e042560 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2685,7 +2685,7 @@ SwXPageStyle::~SwXPageStyle() void SwXStyle::PutItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rVal, SwStyleBase_Impl& rBaseImpl) { // create a new SvxSetItem and get it's ItemSet as new target - SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone()); + const std::unique_ptr<SvxSetItem> pNewSetItem(static_cast<SvxSetItem*>(pSetItem->Clone())); SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem @@ -2703,7 +2703,6 @@ void SwXStyle::PutItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet // set the new SvxSetItem at the real target and delete it rBaseImpl.GetItemSet().Put(*pNewSetItem); - delete pNewSetItem; } void SwXPageStyle::SetPropertyValues_Impl( commit fe60e39ac322303dbba91d49cf215c0c9f3edabe Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 11:52:35 2016 +0100 formatting/whitespace Change-Id: Ia0cdeefdfe7b3800568b96b4bf904d7d0d62f4b9 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 24fec49..3f88672 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2671,23 +2671,16 @@ void SwXStyle::Invalidate() m_xStyleFamily.clear(); } -SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool, - SwDocShell* pDocSh, SfxStyleFamily eFam, - const OUString& rStyleName): - SwXStyle(&rPool, eFam, pDocSh->GetDoc(), rStyleName) -{ - -} +SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool, SwDocShell* pDocSh, SfxStyleFamily eFam, const OUString& rStyleName) + : SwXStyle(&rPool, eFam, pDocSh->GetDoc(), rStyleName) +{ } -SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) : - SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE) -{ -} +SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) + : SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE) +{ } SwXPageStyle::~SwXPageStyle() -{ - -} +{ } void SwXStyle::PutItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rVal, SwStyleBase_Impl& rBaseImpl) { commit ac378355651a34bd0b88cdbea9de78beed6eac95 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 11:50:47 2016 +0100 refactor Notify - check preconditions early - SfxStyleSheetHintId::ERASED is already handled by first if() branch Change-Id: I971eb460c3f006f19dde30f7aac30117be41a621 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index f28f320..24fec49 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2640,30 +2640,28 @@ uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName) return getPropertyDefaults(aSequence)[0]; } -void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +void SwXStyle::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) { const SfxSimpleHint* pHint = dynamic_cast<const SfxSimpleHint*>(&rHint); - if( pHint ) + if(!pHint) + return; + if((pHint->GetId() & SFX_HINT_DYING) || (pHint->GetId() & SfxStyleSheetHintId::ERASED)) + { + m_pBasePool = nullptr; + EndListening(rBC); + } + else if(pHint->GetId() & (SfxStyleSheetHintId::CHANGED)) { - if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SfxStyleSheetHintId::ERASED)) + static_cast<SfxStyleSheetBasePool&>(rBC).SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pOwnBase = static_cast<SfxStyleSheetBasePool&>(rBC).Find(m_sStyleName); + if(!pOwnBase) { - m_pBasePool = nullptr; EndListening(rBC); - } - else if( pHint->GetId() &(SfxStyleSheetHintId::CHANGED|SfxStyleSheetHintId::ERASED) ) - { - static_cast<SfxStyleSheetBasePool&>(rBC).SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pOwnBase = static_cast<SfxStyleSheetBasePool&>(rBC).Find(m_sStyleName); - if(!pOwnBase) - { - EndListening(rBC); - Invalidate(); - } + Invalidate(); } } } - void SwXStyle::Invalidate() { m_sStyleName.clear(); commit fdf280853d54d6786479e15f231f5d447627fba1 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 11:42:48 2016 +0100 fix plenking, remove superficial getConstArray Change-Id: I19afc0fe11e5457dfe2efc6b0224a6857d60a74b diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 29aa51c..f28f320 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2634,10 +2634,10 @@ uno::Sequence<uno::Any> SAL_CALL SwXStyle::getPropertyDefaults(const uno::Sequen } uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { - const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); - return getPropertyDefaults ( aSequence ).getConstArray()[0]; + const uno::Sequence<OUString> aSequence(&rPropertyName, 1); + return getPropertyDefaults(aSequence)[0]; } void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) commit abb0c77a9bd76bf8eb46ee0ab1277cc4535731ee Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Wed Mar 16 11:33:48 2016 +0100 refactor getPropertyDefaults - check preconditions early - use GetStyleSheetBase() - get nPropSetId from m_rEntry Change-Id: I45854bf2b232552ccaffaedeeaa13f77fec82ecd diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 2add207..29aa51c 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2592,77 +2592,42 @@ void SAL_CALL SwXStyle::setAllPropertiesToDefault() pTargetFormat->ResetAllFormatAttr(); } -uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) - throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) +uno::Sequence<uno::Any> SAL_CALL SwXStyle::getPropertyDefaults(const uno::Sequence<OUString>& aPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; sal_Int32 nCount = aPropertyNames.getLength(); + uno::Sequence<uno::Any> aRet(nCount); + if(!nCount) + return aRet; + SfxStyleSheetBase* pBase = GetStyleSheetBase(); + if(!pBase) + throw uno::RuntimeException(); + rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType; + const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); + const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap(); - uno::Sequence < uno::Any > aRet(nCount); - - if(nCount) + const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent(); + for(sal_Int32 i = 0; i < nCount; ++i) { - if(m_pBasePool) - { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "Doesn't seem to be a style!"); - - if(pBase) - { - rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); - sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - switch(m_rEntry.m_eFamily) - { - case SFX_STYLE_FAMILY_PARA : nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; - case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; - case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; - case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; - default: ; - } - const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); - const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap(); - - const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent(); - const OUString *pNames = aPropertyNames.getConstArray(); - uno::Any *pRet = aRet.getArray(); - - for(sal_Int32 i = 0; i < nCount; i++) - { - const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pNames[i]); - - if(!pEntry) - { - throw beans::UnknownPropertyException("Unknown property: " + pNames[i], static_cast < cppu::OWeakObject * >(this)); - } + const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(aPropertyNames[i]); - if (pEntry->nWID >= RES_UNKNOWNATR_END) - { - // these cannot be in an item set, especially not the - // parent set, so the default value is void - continue; - } - - if(pParentSet) - { - aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i], *pParentSet, pRet[i]); - } - else if(pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID)) - { - const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID); + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + aPropertyNames[i], static_cast < cppu::OWeakObject * >(this)); + // these cannot be in an item set, especially not the + // parent set, so the default value is void + if (pEntry->nWID >= RES_UNKNOWNATR_END) + continue; - rItem.QueryValue(pRet[i], pEntry->nMemberId); - } - } - } - else - { - throw uno::RuntimeException(); - } + if(pParentSet) + { + aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(aPropertyNames[i], *pParentSet, aRet[i]); } - else + else if(pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID)) { - throw uno::RuntimeException(); + const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID); + rItem.QueryValue(aRet[i], pEntry->nMemberId); } } return aRet; commit 2ad92da790a65cfb447867e27ce959b85febfea1 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Tue Mar 15 22:33:13 2016 +0100 refactor setAllPropertiesToDefault - check preconditions early - move the SwDocStyleSheet creation out of lcl_GetFormatForStyle Change-Id: I877d2d32ca8b631332f234a2cd3eefd43f099d43 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index bb61514..2add207 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2442,16 +2442,10 @@ void SwXStyle::setPropertyToDefault(const OUString& rPropertyName) setPropertiesToDefault(aSequence); } -SwFormat* lcl_GetFormatForStyle(SfxStyleSheetBasePool* pBasePool, SwDoc* pDoc, const OUString& sStyleName, const SfxStyleFamily eFamily) +SwFormat* lcl_GetFormatForStyle(SwDoc* pDoc, rtl::Reference<SwDocStyleSheet> xStyle, const SfxStyleFamily eFamily) { - if(!pBasePool) - return nullptr; - pBasePool->SetSearchMask(eFamily); - SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); - SAL_WARN_IF(!pBase, "sw.uno", "Where is the style?"); - if(pBase) + if(!xStyle.is()) return nullptr; - rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); switch(eFamily) { case SFX_STYLE_FAMILY_CHAR: return xStyle->GetCharFormat(); @@ -2464,7 +2458,6 @@ SwFormat* lcl_GetFormatForStyle(SfxStyleSheetBasePool* pBasePool, SwDoc* pDoc, c return &pDesc->GetMaster(); } break; - case SFX_STYLE_FAMILY_PSEUDO: break; default: ; } return nullptr; @@ -2474,7 +2467,8 @@ void SAL_CALL SwXStyle::setPropertiesToDefault(const uno::Sequence<OUString>& aP throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - SwFormat* pTargetFormat = lcl_GetFormatForStyle(m_pBasePool, m_pDoc, m_sStyleName, m_rEntry.m_eFamily); + const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(GetStyleSheetBase()))); + SwFormat* pTargetFormat = lcl_GetFormatForStyle(m_pDoc, xStyle, m_rEntry.m_eFamily); if(!pTargetFormat) { if(!m_bIsDescriptor) @@ -2516,130 +2510,86 @@ void SAL_CALL SwXStyle::setPropertiesToDefault(const uno::Sequence<OUString>& aP } } -void SAL_CALL SwXStyle::setAllPropertiesToDefault( ) - throw (uno::RuntimeException, std::exception) +void SAL_CALL SwXStyle::setAllPropertiesToDefault() + throw(uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - - if(m_pBasePool) + if(!m_pBasePool) { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "Where is the style?"); - - if(pBase) + if(!m_bIsDescriptor) + throw uno::RuntimeException(); + m_pPropertiesImpl->ClearAllProperties(); + return; + } + const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(GetStyleSheetBase()))); + if(!xStyle.is()) + throw uno::RuntimeException(); + if(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily) + { + size_t nPgDscPos(0); + SwPageDesc* pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName(), &nPgDscPos); + SwFormat* pPageFormat(nullptr); + if(pDesc) { - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - SwFormat *pTargetFormat = nullptr; - size_t nPgDscPos = SIZE_MAX; - switch(m_rEntry.m_eFamily) + pPageFormat = &pDesc->GetMaster(); + pDesc->SetUseOn(nsUseOnPage::PD_ALL); + } + else + pPageFormat = lcl_GetFormatForStyle(m_pDoc, xStyle, m_rEntry.m_eFamily); + SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos); + rPageDesc.ResetAllMasterAttr(); + + SvxLRSpaceItem aLR(RES_LR_SPACE); + sal_Int32 nSize = GetMetricVal(CM_1) * 2; + aLR.SetLeft(nSize); + aLR.SetLeft(nSize); + SvxULSpaceItem aUL(RES_UL_SPACE); + aUL.SetUpper(static_cast<sal_uInt16>(nSize)); + aUL.SetLower(static_cast<sal_uInt16>(nSize)); + pPageFormat->SetFormatAttr(aLR); + pPageFormat->SetFormatAttr(aUL); + SwPageDesc* pStdPgDsc = m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD); + SwFormatFrameSize aFrameSz(ATT_FIX_SIZE); + + if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFormatId()) + { + if(m_pDoc->getIDocumentDeviceAccess().getPrinter(false)) { - case SFX_STYLE_FAMILY_CHAR: - pTargetFormat = xStyle->GetCharFormat(); - break; - - case SFX_STYLE_FAMILY_PARA: - { - pTargetFormat = xStyle->GetCollection(); - if(xStyle->GetCollection()) - { - xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); - } - break; - } - - case SFX_STYLE_FAMILY_FRAME: - pTargetFormat = xStyle->GetFrameFormat(); - break; - - case SFX_STYLE_FAMILY_PAGE: - { - SwPageDesc *pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName(), &nPgDscPos); - if( pDesc ) - { - pTargetFormat = &pDesc->GetMaster(); - pDesc->SetUseOn(nsUseOnPage::PD_ALL); - } - break; - } - - case SFX_STYLE_FAMILY_PSEUDO: - break; - - default: ; + const Size aPhysSize( SvxPaperInfo::GetPaperSize( + static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(false)))); + aFrameSz.SetSize(aPhysSize); } - - if(pTargetFormat) + else { - if(SIZE_MAX != nPgDscPos) - { - SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos); - rPageDesc.ResetAllMasterAttr(); - - SvxLRSpaceItem aLR(RES_LR_SPACE); - sal_Int32 nSize = GetMetricVal(CM_1) * 2; - aLR.SetLeft(nSize); - aLR.SetLeft(nSize); - SvxULSpaceItem aUL(RES_UL_SPACE); - aUL.SetUpper(static_cast <sal_uInt16> (nSize)); - aUL.SetLower(static_cast <sal_uInt16> (nSize)); - pTargetFormat->SetFormatAttr(aLR); - pTargetFormat->SetFormatAttr(aUL); - SwPageDesc* pStdPgDsc = m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD); - SwFormatFrameSize aFrameSz(ATT_FIX_SIZE); - - if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFormatId()) - { - if(m_pDoc->getIDocumentDeviceAccess().getPrinter(false)) - { - const Size aPhysSize( SvxPaperInfo::GetPaperSize( - static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(false)))); - aFrameSz.SetSize(aPhysSize); - } - else - { - aFrameSz.SetSize(SvxPaperInfo::GetDefaultPaperSize()); - } - - } - else - { - aFrameSz = pStdPgDsc->GetMaster().GetFrameSize(); - } - - if(pStdPgDsc->GetLandscape()) - { - SwTwips nTmp = aFrameSz.GetHeight(); - aFrameSz.SetHeight(aFrameSz.GetWidth()); - aFrameSz.SetWidth(nTmp); - } - - pTargetFormat->SetFormatAttr( aFrameSz ); - } - else - { - pTargetFormat->ResetAllFormatAttr(); - } - - if(SIZE_MAX != nPgDscPos) - { - m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos)); - } + aFrameSz.SetSize(SvxPaperInfo::GetDefaultPaperSize()); } + } else { - throw uno::RuntimeException(); + aFrameSz = pStdPgDsc->GetMaster().GetFrameSize(); } + + if(pStdPgDsc->GetLandscape()) + { + SwTwips nTmp = aFrameSz.GetHeight(); + aFrameSz.SetHeight(aFrameSz.GetWidth()); + aFrameSz.SetWidth(nTmp); + } + + pPageFormat->SetFormatAttr(aFrameSz); + m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos)); + return; } - else if ( m_bIsDescriptor ) - { - m_pPropertiesImpl->ClearAllProperties(); - } - else + if(SFX_STYLE_FAMILY_PARA == m_rEntry.m_eFamily) { - throw uno::RuntimeException(); + if(xStyle->GetCollection()) + xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); } + SwFormat* const pTargetFormat = lcl_GetFormatForStyle(m_pDoc, xStyle, m_rEntry.m_eFamily); + if(!pTargetFormat) + return; + pTargetFormat->ResetAllFormatAttr(); } uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) commit 36a2245198f8bdbf5840ec9c6b85075184e15503 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Tue Mar 15 13:25:11 2016 +0100 refactor setPropertyToDefault - check preconditions early - extract finding the SwFormat in a helper function - use ranged-for instead of naked pointer arithmetic - OSL_ENSURE -> SAL_WARN_IF Change-Id: I3f5754632c9dab29ce3acc4f59e33cb32e239cbb diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 07eb1e5..bb61514 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2442,113 +2442,76 @@ void SwXStyle::setPropertyToDefault(const OUString& rPropertyName) setPropertiesToDefault(aSequence); } -void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) - throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception) +SwFormat* lcl_GetFormatForStyle(SfxStyleSheetBasePool* pBasePool, SwDoc* pDoc, const OUString& sStyleName, const SfxStyleFamily eFamily) { - SolarMutexGuard aGuard; - SwFormat *pTargetFormat = nullptr; - - if(m_pBasePool) + if(!pBasePool) + return nullptr; + pBasePool->SetSearchMask(eFamily); + SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); + SAL_WARN_IF(!pBase, "sw.uno", "Where is the style?"); + if(pBase) + return nullptr; + rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + switch(eFamily) { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "Where is the style?"); - - if(pBase) + case SFX_STYLE_FAMILY_CHAR: return xStyle->GetCharFormat(); + case SFX_STYLE_FAMILY_PARA: return xStyle->GetCollection(); + case SFX_STYLE_FAMILY_FRAME: return xStyle->GetFrameFormat(); + case SFX_STYLE_FAMILY_PAGE: { - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - switch(m_rEntry.m_eFamily) - { - case SFX_STYLE_FAMILY_CHAR: - pTargetFormat = xStyle->GetCharFormat(); - break; - - case SFX_STYLE_FAMILY_PARA: - pTargetFormat = xStyle->GetCollection(); - break; - - case SFX_STYLE_FAMILY_FRAME: - pTargetFormat = xStyle->GetFrameFormat(); - break; - - case SFX_STYLE_FAMILY_PAGE: - { - SwPageDesc *pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName()); - if( pDesc ) - pTargetFormat = &pDesc->GetMaster(); - break; - } - case SFX_STYLE_FAMILY_PSEUDO: - break; - default: ; - } + SwPageDesc* pDesc(pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName())); + if(pDesc) + return &pDesc->GetMaster(); } + break; + case SFX_STYLE_FAMILY_PSEUDO: break; + default: ; } + return nullptr; +} - sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - - switch(m_rEntry.m_eFamily) +void SAL_CALL SwXStyle::setPropertiesToDefault(const uno::Sequence<OUString>& aPropertyNames) + throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception) +{ + SolarMutexGuard aGuard; + SwFormat* pTargetFormat = lcl_GetFormatForStyle(m_pBasePool, m_pDoc, m_sStyleName, m_rEntry.m_eFamily); + if(!pTargetFormat) { - case SFX_STYLE_FAMILY_PARA : nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; - case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break; - case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; - case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break; - default: ; + if(!m_bIsDescriptor) + return; + for(const auto& rName : aPropertyNames) + m_pPropertiesImpl->ClearProperty(rName); + return; } - + const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType; const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap(); - const OUString* pNames = aPropertyNames.getConstArray(); - - if(pTargetFormat) + for(const auto& rName : aPropertyNames) { - for(sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++) + const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rName); + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rName, static_cast<cppu::OWeakObject*>(this)); + if(pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES) + throw uno::RuntimeException("Cannot reset: " + rName, static_cast<cppu::OWeakObject*>(this)); + if(pEntry->nFlags & beans::PropertyAttribute::READONLY) + throw uno::RuntimeException("setPropertiesToDefault: property is read-only: " + rName, static_cast<cppu::OWeakObject*>(this)); + if(pEntry->nWID == RES_PARATR_OUTLINELEVEL) { - const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pNames[nProp]); - - if( !pEntry ) - { - throw beans::UnknownPropertyException ( "Unknown property: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - } - - if ( pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES ) - { - throw uno::RuntimeException ("Cannot reset: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - } - - if (pEntry->nFlags & beans::PropertyAttribute::READONLY) - { - throw uno::RuntimeException("setPropertiesToDefault: property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - } - - if( pEntry->nWID == RES_PARATR_OUTLINELEVEL ) - { - static_cast<SwTextFormatColl*>(pTargetFormat)->DeleteAssignmentToListLevelOfOutlineStyle(); - } - else - { - pTargetFormat->ResetFormatAttr( pEntry->nWID ); - } - - if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) - { - //UUUU - SwDoc* pDoc = pTargetFormat->GetDoc(); - SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); - aSet.SetParent(&pTargetFormat->GetAttrSet()); - - aSet.ClearItem(XATTR_FILLBMP_STRETCH); - aSet.ClearItem(XATTR_FILLBMP_TILE); - - pTargetFormat->SetFormatAttr(aSet); - } + static_cast<SwTextFormatColl*>(pTargetFormat)->DeleteAssignmentToListLevelOfOutlineStyle(); + continue; } - } - else if(m_bIsDescriptor) - { - for(sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++) + pTargetFormat->ResetFormatAttr(pEntry->nWID); + if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) { - m_pPropertiesImpl->ClearProperty(pNames[nProp]); + //UUUU + SwDoc* pDoc = pTargetFormat->GetDoc(); + SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); + aSet.SetParent(&pTargetFormat->GetAttrSet()); + + aSet.ClearItem(XATTR_FILLBMP_STRETCH); + aSet.ClearItem(XATTR_FILLBMP_TILE); + + pTargetFormat->SetFormatAttr(aSet); } } } commit ee105a940751bcc31e18643220b631301a82587b Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Tue Mar 15 12:42:42 2016 +0100 whitespace: fix plenking Change-Id: Ie5473191f5121eab95a3aaef67738240e5c75393 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index d1111b9..07eb1e5 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2436,10 +2436,10 @@ uno::Sequence<beans::PropertyState> SwXStyle::getPropertyStates(const uno::Seque } void SwXStyle::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception ) + throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception) { - const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); - setPropertiesToDefault ( aSequence ); + const uno::Sequence<OUString> aSequence(&rPropertyName, 1); + setPropertiesToDefault(aSequence); } void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) commit 4dbc3f0dfb8e7b337477fa70d6fd687a3f1d2ef9 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Tue Mar 15 00:37:36 2016 +0100 refactor getPropertyStates - refactor out Header/Footer special casing - check preconditions early - OSL_ENSURE -> SAL_WARN_IIF - use m_rEntry to find nPropSetId - remove bDone cludge and use switch/case for remainders Change-Id: I7fcac7e9c44190b6695bb0ced4278b50bd7f1c46 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index bc8064b..d1111b9 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2323,149 +2323,115 @@ beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName) return aStates.getConstArray()[0]; } -uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( - const uno::Sequence< OUString >& rPropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception ) +// allow to retarget the SfxItemSet working on, default correctly. Only +// use pSourceSet below this point (except in header/footer processing) +const SfxItemSet* lcl_GetItemsetForProperty(const SfxItemSet& rSet, SfxStyleFamily eFamily, const OUString& rPropertyName) +{ + if(eFamily != SFX_STYLE_FAMILY_PAGE) + return &rSet; + const bool isFooter = rPropertyName.startsWith("Footer"); + if(!isFooter && !rPropertyName.startsWith("Header") && rPropertyName != UNO_NAME_FIRST_IS_SHARED) + return &rSet; + const SvxSetItem* pSetItem; + if(!lcl_GetHeaderFooterItem(rSet, rPropertyName, isFooter, pSetItem)) + return nullptr; + return &pSetItem->GetItemSet(); +} +uno::Sequence<beans::PropertyState> SwXStyle::getPropertyStates(const uno::Sequence<OUString>& rPropertyNames) + throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); + uno::Sequence<beans::PropertyState> aRet(rPropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); - if(m_pBasePool) - { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily ); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "where is the style?" ); + if(!m_pBasePool) + throw uno::RuntimeException(); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - if(pBase) - { - const OUString* pNames = rPropertyNames.getConstArray(); - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; + SAL_WARN_IF(!pBase, "sw.uno", "where is the style?"); + if(!pBase) + throw uno::RuntimeException(); - switch(m_rEntry.m_eFamily) - { - case SFX_STYLE_FAMILY_PARA : nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break; - case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break; - case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break; - case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break; - default: ; - } + const OUString* pNames = rPropertyNames.getConstArray(); + rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType; - const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); - const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap(); - const SfxItemSet& rSet = xStyle->GetItemSet(); + const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); + const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap(); + const SfxItemSet& rSet = xStyle->GetItemSet(); - for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) - { - const OUString sPropName = pNames[i]; - const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName); - bool bDone(false); + for(sal_Int32 i = 0; i < rPropertyNames.getLength(); ++i) + { + const OUString sPropName = pNames[i]; + const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName); - if(!pEntry) - { - throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) ); - } + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast<cppu::OWeakObject*>(this)); - if( FN_UNO_NUM_RULES == pEntry->nWID || FN_UNO_FOLLOW_STYLE == pEntry->nWID ) + if(FN_UNO_NUM_RULES == pEntry->nWID || FN_UNO_FOLLOW_STYLE == pEntry->nWID) + { + // handle NumRules first, done + pStates[i] = beans::PropertyState_DIRECT_VALUE; + continue; + } + const SfxItemSet* pSourceSet = lcl_GetItemsetForProperty(rSet, m_rEntry.m_eFamily, sPropName); + if(!pSourceSet) + { + // if no SetItem, value is ambigous and we are done + pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; + continue; + } + switch(pEntry->nWID) + { + case OWN_ATTR_FILLBMP_MODE: + { + //UUUU + if(SfxItemState::SET == pSourceSet->GetItemState(XATTR_FILLBMP_STRETCH, false) + || SfxItemState::SET == pSourceSet->GetItemState(XATTR_FILLBMP_TILE, false)) { - // handle NumRules first, done pStates[i] = beans::PropertyState_DIRECT_VALUE; - bDone = true; } - - // allow to retarget the SfxItemSet working on, default correctly. Only - // use pSourceSet below this point (except in header/footer processing) - const SfxItemSet* pSourceSet = &rSet; - - if(!bDone) - { - // check for Header/Footer entry - const bool bHeader(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily && sPropName.startsWith("Header")); - const bool bFooter(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily && sPropName.startsWith("Footer")); - - if(bHeader || bFooter || sPropName == UNO_NAME_FIRST_IS_SHARED) - { - const SvxSetItem* pSetItem; - - if (lcl_GetHeaderFooterItem(rSet, sPropName, bFooter, pSetItem)) - { - // retarget the SfxItemSet to the HeaderFooter SfxSetItem's SfxItenSet - pSourceSet = &pSetItem->GetItemSet(); - } - else - { - // if no SetItem, value is ambigous and we are done - pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; - bDone = true; - } - } - } - - if(!bDone && OWN_ATTR_FILLBMP_MODE == pEntry->nWID) + else { - //UUUU - if(SfxItemState::SET == pSourceSet->GetItemState(XATTR_FILLBMP_STRETCH, false) - || SfxItemState::SET == pSourceSet->GetItemState(XATTR_FILLBMP_TILE, false)) - { - pStates[i] = beans::PropertyState_DIRECT_VALUE; - } - else - { - pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; - } - - bDone = true; + pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; } - + } + break; + case RES_BACKGROUND: + { //UUUU for FlyFrames we need to mark the used properties from type RES_BACKGROUND // as beans::PropertyState_DIRECT_VALUE to let users of this property call // getPropertyValue where the member properties will be mapped from the // fill attributes to the according SvxBrushItem entries - if (!bDone && RES_BACKGROUND == pEntry->nWID) + if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet, pEntry->nMemberId)) { - if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet, pEntry->nMemberId)) - { - pStates[i] = beans::PropertyState_DIRECT_VALUE; - } - else - { - pStates[i] = beans::PropertyState_DEFAULT_VALUE; - } - bDone = true; + pStates[i] = beans::PropertyState_DIRECT_VALUE; } + else + { + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } + } + break; + default: + { + pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet); - if(!bDone) + if(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i]) { - pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet); + const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE)); + sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f; - if(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i]) + if((LONG_MAX == rSize.GetSize().Width() && (MID_SIZE_WIDTH == nMemberId || MID_SIZE_SIZE == nMemberId)) || + (LONG_MAX == rSize.GetSize().Height() && MID_SIZE_HEIGHT == nMemberId)) { - const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE)); - sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f; - - if( ( LONG_MAX == rSize.GetSize().Width() && - (MID_SIZE_WIDTH == nMemberId || - MID_SIZE_SIZE == nMemberId ) ) || - ( LONG_MAX == rSize.GetSize().Height() && - MID_SIZE_HEIGHT == nMemberId ) ) - { - pStates[i] = beans::PropertyState_DEFAULT_VALUE; - } + pStates[i] = beans::PropertyState_DEFAULT_VALUE; } } } } - else - { - throw uno::RuntimeException(); - } - } - else - { - throw uno::RuntimeException(); } - return aRet; } commit fee21c82cbabeceb4a7776ebdb46905f5dac769d Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Mon Mar 14 23:10:00 2016 +0100 minor whitespace fixes Change-Id: Iea6e6bff9dfbb713b587b01d08e3e570e683609d diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 5bce3bb..bc8064b 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2306,26 +2306,20 @@ uno::Sequence<uno::Any> SwXStyle::getPropertyValues(const uno::Sequence<OUString } void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue) - throw( beans::UnknownPropertyException, - beans::PropertyVetoException, - lang::IllegalArgumentException, - lang::WrappedTargetException, - uno::RuntimeException, std::exception) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; const uno::Sequence<OUString> aProperties(&rPropertyName, 1); const uno::Sequence<uno::Any> aValues(&rValue, 1); - - SetPropertyValues_Impl( aProperties, aValues ); + SetPropertyValues_Impl(aProperties, aValues); } - beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception ) + throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - uno::Sequence< OUString > aNames { rPropertyName }; - uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames); + uno::Sequence<OUString> aNames{rPropertyName}; + uno::Sequence<beans::PropertyState> aStates = getPropertyStates(aNames); return aStates.getConstArray()[0]; } commit 454aebe35e63d16348e680286f90883b0f27051c Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Mon Mar 14 00:55:40 2016 +0100 rename/move main logic from GetPropertyValues_Impl to GetPropertyValue_Impl Change-Id: Iaf428141383f29da33c3102c40dd5a8f5392edff diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 21e9331..5bce3bb 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -295,7 +295,7 @@ protected: template<sal_uInt16> uno::Any GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase); uno::Any GetStyleProperty_Impl(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase); - css::uno::Sequence<uno::Any> GetPropertyValues_Impl(const css::uno::Sequence< OUString >& aPropertyNames); + uno::Any GetPropertyValue_Impl(const SfxItemPropertySet* pPropSet, SwStyleBase_Impl& rBase, const OUString& rPropertyName); virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; public: @@ -2219,91 +2219,89 @@ uno::Any SwXStyle::GetStyleProperty_Impl(const SfxItemPropertySimpleEntry& rEntr return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase); } -uno::Sequence<uno::Any> SwXStyle::GetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNames) +uno::Any SwXStyle::GetPropertyValue_Impl(const SfxItemPropertySet* pPropSet, SwStyleBase_Impl& rBase, const OUString& rPropertyName) { - if(!m_pDoc) - throw uno::RuntimeException(); - - sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType; - - const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); - const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap(); - const OUString* pNames = rPropertyNames.getConstArray(); - uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); - uno::Any* pRet = aRet.getArray(); - SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTextFormatColl()->GetAttrSet()); //UUUU add pDfltTextFormatColl as parent - - if(!m_pBasePool && !m_bIsDescriptor) - throw uno::RuntimeException(); - - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap(); + const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropertyName); + if(!pEntry || (!m_bIsConditional && rPropertyName == UNO_NAME_PARA_STYLE_CONDITIONS)) + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this)); + if(m_pBasePool) + return GetStyleProperty_Impl(*pEntry, *pPropSet, rBase); + const uno::Any* pAny = nullptr; + m_pPropertiesImpl->GetProperty(rPropertyName, pAny); + if(pAny->hasValue()) + return *pAny; + uno::Any aValue; + switch(m_rEntry.m_eFamily) { - const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp]); - if(!pEntry || (!m_bIsConditional && pNames[nProp] == UNO_NAME_PARA_STYLE_CONDITIONS)) - throw beans::UnknownPropertyException("Unknown property: " + pNames[nProp], static_cast<cppu::OWeakObject*>(this)); - if(m_pBasePool) - pRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase); - else + case SFX_STYLE_FAMILY_PSEUDO: + throw uno::RuntimeException("No default value for: " + rPropertyName); + break; + case SFX_STYLE_FAMILY_PARA: + case SFX_STYLE_FAMILY_PAGE: + SwStyleProperties_Impl::GetProperty(rPropertyName, m_xStyleData, aValue); + break; + case SFX_STYLE_FAMILY_CHAR: + case SFX_STYLE_FAMILY_FRAME: { - const uno::Any* pAny = nullptr; - m_pPropertiesImpl->GetProperty(pNames[nProp], pAny); - if(pAny->hasValue()) - pRet[nProp] = *pAny; + if(pEntry->nWID < POOLATTR_BEGIN || pEntry->nWID >= RES_UNKNOWNATR_END) + throw uno::RuntimeException("No default value for: " + rPropertyName); + SwFormat* pFormat; + if(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_CHAR) + pFormat = m_pDoc->GetDfltCharFormat(); else - { - switch(m_rEntry.m_eFamily) - { - case SFX_STYLE_FAMILY_PSEUDO: - throw uno::RuntimeException("No default value for: " + pNames[nProp]); - break; - case SFX_STYLE_FAMILY_PARA: - case SFX_STYLE_FAMILY_PAGE: - SwStyleProperties_Impl::GetProperty(pNames[nProp], m_xStyleData, pRet[nProp]); - break; - case SFX_STYLE_FAMILY_CHAR: - case SFX_STYLE_FAMILY_FRAME: - { - if(pEntry->nWID < POOLATTR_BEGIN || pEntry->nWID >= RES_UNKNOWNATR_END) - throw uno::RuntimeException("No default value for: " + pNames[nProp]); - SwFormat* pFormat; - if(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_CHAR) - pFormat = m_pDoc->GetDfltCharFormat(); - else - pFormat = m_pDoc->GetDfltFrameFormat(); - const SwAttrPool* pPool = pFormat->GetAttrSet().GetPool(); - const SfxPoolItem& rItem = pPool->GetDefaultItem(pEntry->nWID); - rItem.QueryValue(pRet[nProp], pEntry->nMemberId); - } - break; - default: - ; - } - } + pFormat = m_pDoc->GetDfltFrameFormat(); + const SwAttrPool* pPool = pFormat->GetAttrSet().GetPool(); + const SfxPoolItem& rItem = pPool->GetDefaultItem(pEntry->nWID); + rItem.QueryValue(aValue, pEntry->nMemberId); } + break; + default: + ; } - return aRet; + return aValue; } -uno::Sequence< uno::Any > SwXStyle::getPropertyValues( - const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException, std::exception) +uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - uno::Sequence< uno::Any > aValues; + if(!m_pDoc) + throw uno::RuntimeException(); + if(!m_pBasePool && !m_bIsDescriptor) + throw uno::RuntimeException(); + sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType; + const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); + SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet()); //UUUU add pDfltTextFormatColl as parent + return GetPropertyValue_Impl(pPropSet, aBase, rPropertyName); +} +uno::Sequence<uno::Any> SwXStyle::getPropertyValues(const uno::Sequence<OUString>& rPropertyNames) + throw(uno::RuntimeException, std::exception) +{ + SolarMutexGuard aGuard; + if(!m_pDoc) + throw uno::RuntimeException(); + if(!m_pBasePool && !m_bIsDescriptor) + throw uno::RuntimeException(); + sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType; + const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId); + SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet()); //UUUU add pDfltTextFormatColl as parent + uno::Sequence<uno::Any> aValues(rPropertyNames.getLength()); // workaround for bad designed API try { ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits