sw/inc/unostyle.hxx | 187 ------- sw/source/core/inc/unoevent.hxx | 5 sw/source/core/unocore/unocoll.cxx | 13 sw/source/core/unocore/unoevent.cxx | 40 - sw/source/core/unocore/unostyle.cxx | 856 +++++++++++++++++++----------------- sw/source/filter/xml/xmlfmt.cxx | 30 - sw/source/filter/xml/xmltexte.cxx | 148 +++--- 7 files changed, 580 insertions(+), 699 deletions(-)
New commits: commit e6c14e281e2f4e9c5d7cbc3d69da11cd86770adf Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 23:21:59 2015 +0100 remove (now) unused function Change-Id: Iddf0fce5343abeb199cb5d0c37d933d68c0e4c6a diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index d6d6018..9a55dee 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1001,8 +1001,6 @@ public: { rAny = rxPropertySet->getPropertyValue( rPropertyName ); } - const PropertyEntryVector_t& GetPropertyVector() const - { return aPropertyEntries; } }; static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily) commit ae83b3e95748e9b9c05d57127b0ee4fa4e8e5749 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 22:10:29 2015 +0100 refactor SwXStyle::ApplyDescriptorProperties Change-Id: I219e75082c655a0895c75932863e596fcfccc656 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 457f804..d6d6018 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -989,6 +989,14 @@ public: } void ClearAllProperties( ) { m_vPropertyValues.clear(); } + void Apply(SwXStyle& rStyle) + { + for(auto pPropertyPair : m_vPropertyValues) + { + if(pPropertyPair.second.hasValue()) + rStyle.setPropertyValue(pPropertyPair.first, pPropertyPair.second); + } + } static void GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny ) { rAny = rxPropertySet->getPropertyValue( rPropertyName ); @@ -1300,22 +1308,12 @@ uno::Reference<beans::XPropertySetInfo> SwXStyle::getPropertySetInfo() throw( un return m_rEntry.m_xPSInfo; } -void SwXStyle::ApplyDescriptorProperties() +void SwXStyle::ApplyDescriptorProperties() { m_bIsDescriptor = false; m_xStyleData.clear(); m_xStyleFamily.clear(); - - const PropertyEntryVector_t& rPropertyVector = m_pPropertiesImpl->GetPropertyVector(); - PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin(); - while(aIt != rPropertyVector.end()) - { - const uno::Any* pAny(nullptr); - m_pPropertiesImpl->GetProperty(aIt->sName, pAny); - if(pAny->hasValue()) - setPropertyValue(aIt->sName, *pAny); - ++aIt; - } + m_pPropertiesImpl->Apply(*this); } class SwStyleBase_Impl commit ddee7414f4859f02af26fdddd068f1d34c0ddeeb Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 20:43:46 2015 +0100 refactor SwXStyle::getPropertySetInfo Change-Id: If2ecee5c0e97c3955cffe4eb23d2bf651ec4ef2a diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index c66a434..457f804 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -99,6 +99,7 @@ namespace using TranslateIndex_t = std::function<sal_uInt16(const sal_uInt16)>; SfxStyleFamily m_eFamily; sal_uInt16 m_nPropMapType; + uno::Reference<beans::XPropertySetInfo> m_xPSInfo; SwGetPoolIdFromName m_aPoolId; OUString m_sName; sal_uInt32 m_nResId; @@ -108,13 +109,14 @@ namespace StyleFamilyEntry(SfxStyleFamily eFamily, sal_uInt16 nPropMapType, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle, TranslateIndex_t fTranslateIndex) : m_eFamily(eFamily) , m_nPropMapType(nPropMapType) + , m_xPSInfo(aSwMapProvider.GetPropertySet(nPropMapType)->getPropertySetInfo()) , m_aPoolId(aPoolId) , m_sName(sName) , m_nResId(nResId) , m_fGetCountOrName(fGetCountOrName) , m_fCreateStyle(fCreateStyle) , m_fTranslateIndex(fTranslateIndex) - {} + { } }; static const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries; // these should really be constexprs, but MSVC still is apparently too stupid for them @@ -1286,76 +1288,16 @@ void SwXStyle::setParentStyle(const OUString& rParentStyle) throw( container::No } } -static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, bool bIsConditional ) +uno::Reference<beans::XPropertySetInfo> SwXStyle::getPropertySetInfo() throw( uno::RuntimeException, std::exception ) { - uno::Reference< beans::XPropertySetInfo > xRet; - switch( eFamily ) + if(m_bIsConditional) { - case SFX_STYLE_FAMILY_CHAR: - { - static uno::Reference< beans::XPropertySetInfo > xCharRef; - if(!xCharRef.is()) - { - xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo(); - } - xRet = xCharRef; - } - break; - case SFX_STYLE_FAMILY_PARA: - { - static uno::Reference< beans::XPropertySetInfo > xCondParaRef; - static uno::Reference< beans::XPropertySetInfo > xParaRef; - if(!xParaRef.is()) - { - xCondParaRef = aSwMapProvider.GetPropertySet( - PROPERTY_MAP_CONDITIONAL_PARA_STYLE)->getPropertySetInfo(); - xParaRef = aSwMapProvider.GetPropertySet( - PROPERTY_MAP_PARA_STYLE)->getPropertySetInfo(); - } - xRet = bIsConditional ? xCondParaRef : xParaRef; - } - break; - case SFX_STYLE_FAMILY_PAGE : - { - static uno::Reference< beans::XPropertySetInfo > xPageRef; - if(!xPageRef.is()) - { - xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo(); - } - xRet = xPageRef; - } - break; - case SFX_STYLE_FAMILY_FRAME : - { - static uno::Reference< beans::XPropertySetInfo > xFrameRef; - if(!xFrameRef.is()) - { - xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo(); - } - xRet = xFrameRef; - } - break; - case SFX_STYLE_FAMILY_PSEUDO: - { - static uno::Reference< beans::XPropertySetInfo > xNumRef; - if(!xNumRef.is()) - { - xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo(); - } - xRet = xNumRef; - } - break; - - default: - ; + assert(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA); + static uno::Reference<beans::XPropertySetInfo> xCondParaRef; + xCondParaRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CONDITIONAL_PARA_STYLE)->getPropertySetInfo(); + return xCondParaRef; } - return xRet; -} - -uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo() - throw( uno::RuntimeException, std::exception ) -{ - return lcl_getPropertySetInfo( m_rEntry.m_eFamily, m_bIsConditional ); + return m_rEntry.m_xPSInfo; } void SwXStyle::ApplyDescriptorProperties() commit 15b11c8389c3fd1a5241fc5b37e3d7eaa79234db Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 20:29:24 2015 +0100 refactor SwXStyle::get/setParentStyle Change-Id: Ifb578244d511af153484d14ee92c5c22c2db0a3f diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 9b8d860..c66a434 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1238,68 +1238,52 @@ sal_Bool SwXStyle::isInUse() throw( uno::RuntimeException, std::exception ) OUString SwXStyle::getParentStyle() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - OUString aString; - if(m_pBasePool) + if(!m_pBasePool) { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - if(pBase) - aString = pBase->GetParent(); + if(!m_bIsDescriptor) + throw uno::RuntimeException(); + return m_sParentStyleName; } - else if(m_bIsDescriptor) - aString = m_sParentStyleName; - else - throw uno::RuntimeException(); - SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true ); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + OUString aString; + if(pBase) + aString = pBase->GetParent(); + SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum(m_rEntry.m_eFamily), true); return aString; } -void SwXStyle::setParentStyle(const OUString& rParentStyle) - throw( container::NoSuchElementException, uno::RuntimeException, std::exception ) +void SwXStyle::setParentStyle(const OUString& rParentStyle) throw( container::NoSuchElementException, uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; OUString sParentStyle; SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true ); - if(m_pBasePool) + if(!m_pBasePool) { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - bool bExcept = false; - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - if(pBase) - { - rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)) ); - //make it a 'real' style - necessary for pooled styles - xBase->GetItemSet(); - if(xBase->GetParent() != sParentStyle) - { - bExcept = !xBase->SetParent(sParentStyle); - } - } - else - bExcept = true; - if(bExcept) + if(!m_bIsDescriptor) throw uno::RuntimeException(); - } - else if(m_bIsDescriptor) - { m_sParentStyleName = sParentStyle; try { - uno::Any aAny = m_xStyleFamily->getByName ( sParentStyle ); - aAny >>= m_xStyleData; - } - catch ( container::NoSuchElementException& ) - { - } - catch ( lang::WrappedTargetException& ) - { - } - catch ( uno::RuntimeException& ) - { + const auto aAny = m_xStyleFamily->getByName(sParentStyle); + m_xStyleData = aAny.get<decltype(m_xStyleData)>(); } + catch(...) + { } + return; } - else + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + if(!pBase) throw uno::RuntimeException(); + rtl::Reference<SwDocStyleSheet> xBase(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + //make it a 'real' style - necessary for pooled styles + xBase->GetItemSet(); + if(xBase->GetParent() != sParentStyle) + { + if(!xBase->SetParent(sParentStyle)) + throw uno::RuntimeException(); + } } static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, bool bIsConditional ) commit b025e60b8d00b0d8fbb694285eafb2c95b7b129e Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 19:57:53 2015 +0100 refactor SwXStyle::isUserDefined/isInUse Change-Id: I67d8408d410698f0f31738fcc30321c627307c73 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 16313af..9b8d860 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1217,34 +1217,22 @@ void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException, std: sal_Bool SwXStyle::isUserDefined() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - bool bRet = false; - if(m_pBasePool) - { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - //if it is not found it must be non user defined - if(pBase) - bRet = pBase->IsUserDefined(); - } - else + if(!m_pBasePool) throw uno::RuntimeException(); - return bRet; + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + //if it is not found it must be non user defined + return pBase && pBase->IsUserDefined(); } sal_Bool SwXStyle::isInUse() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - bool bRet = false; - if(m_pBasePool) - { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily, SFXSTYLEBIT_USED); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - if(pBase) - bRet = pBase->IsUsed(); - } - else + if(!m_pBasePool) throw uno::RuntimeException(); - return bRet; + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily, SFXSTYLEBIT_USED); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + return pBase && pBase->IsUsed(); } OUString SwXStyle::getParentStyle() throw( uno::RuntimeException, std::exception ) commit dc7879fe51f1db089a2be9b42548e7bc6d99c0b4 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 19:48:42 2015 +0100 refactor SwXStyle::get/setName Change-Id: If814b6873796fcfa4cc7a2f62711a8b20f2f7d6b diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index f1bcd9b..16313af 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1183,41 +1183,35 @@ void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) OUString SwXStyle::getName() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - 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) - throw uno::RuntimeException(); - OUString aString; - SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true); - return aString; - } - return m_sStyleName; + if(!m_pBasePool) + return m_sStyleName; + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + SAL_WARN_IF(!pBase, "sw.uno", "where is the style?"); + if(!pBase) + throw uno::RuntimeException(); + OUString aString; + SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true); + return aString; } void SwXStyle::setName(const OUString& rName) 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?" ); - bool bExcept = true; - if(pBase && pBase->IsUserDefined()) - { - rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - bExcept = !xTmp->SetName(rName); - if(!bExcept) - m_sStyleName = rName; - } - if(bExcept) - throw uno::RuntimeException(); - } - else m_sStyleName = rName; + return; + } + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + SAL_WARN_IF(!pBase, "sw.uno", "where is the style?"); + if(!pBase || !pBase->IsUserDefined()) + throw uno::RuntimeException(); + rtl::Reference<SwDocStyleSheet> xTmp(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + if(!xTmp->SetName(rName)) + throw uno::RuntimeException(); + m_sStyleName = rName; } sal_Bool SwXStyle::isUserDefined() throw( uno::RuntimeException, std::exception ) commit 0046562f916dcf808be18a315c3be534a2aaaa9c Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 19:32:20 2015 +0100 use local init function for conditional too Change-Id: I687161aa9295a1b815d11dd10fa83d23b010764a diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 7779062..f1bcd9b 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -278,10 +278,7 @@ protected: virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; public: SwXStyle(SwDoc* pDoc, SfxStyleFamily eFam = SFX_STYLE_FAMILY_PARA, bool bConditional = false); - SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, - SwDoc* pDoc, - const OUString& rStyleName); - + SwXStyle(SfxStyleSheetBasePool* pPool, SfxStyleFamily eFamily, SwDoc* pDoc, const OUString& rStyleName); virtual ~SwXStyle(); @@ -375,7 +372,7 @@ public: SwXFrameStyle(SfxStyleSheetBasePool& rPool, SwDoc* pDoc, const OUString& rStyleName) : - SwXStyle(rPool, SFX_STYLE_FAMILY_FRAME, pDoc, rStyleName){} + SwXStyle(&rPool, SFX_STYLE_FAMILY_FRAME, pDoc, rStyleName){} SwXFrameStyle( SwDoc *pDoc ); virtual ~SwXFrameStyle(); @@ -690,11 +687,11 @@ sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUStrin template<enum SfxStyleFamily eFamily> static uno::Reference< css::style::XStyle> lcl_CreateStyle(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName) - { return pBasePool ? new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), eFamily, false); }; + { return pBasePool ? new SwXStyle(pBasePool, eFamily, pDocShell->GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), eFamily, false); }; template<> uno::Reference< css::style::XStyle> lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName) - { return pBasePool ? new SwXStyle(*pBasePool, SFX_STYLE_FAMILY_PARA, pDocShell->GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), SFX_STYLE_FAMILY_PARA, false); }; + { return pBasePool ? new SwXStyle(pBasePool, SFX_STYLE_FAMILY_PARA, pDocShell->GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), SFX_STYLE_FAMILY_PARA, false); }; template<> uno::Reference< css::style::XStyle> lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName) { return pBasePool ? new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), sStyleName) : new SwXFrameStyle(pDocShell->GetDoc()); }; @@ -1112,6 +1109,21 @@ static uno::Reference<container::XNameAccess> lcl_InitStyleFamily(SwDoc* pDoc, c return aResult.get<return_t>(); } +static bool lcl_InitConditional(SfxStyleSheetBasePool* pBasePool, const SfxStyleFamily eFamily, const OUString& rStyleName) +{ + if(!pBasePool || eFamily != SFX_STYLE_FAMILY_PARA) + return false; + pBasePool->SetSearchMask(eFamily); + SfxStyleSheetBase* pBase = pBasePool->Find(rStyleName); + SAL_WARN_IF(!pBase, "sw.uno", "where is the style?" ); + if(!pBase) + return false; + const sal_uInt16 nId(SwStyleNameMapper::GetPoolIdFromUIName(rStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL)); + if(nId != USHRT_MAX) + return ::IsConditionalByPoolId(nId); + return RES_CONDTXTFMTCOLL == static_cast<SwDocStyleSheet*>(pBase)->GetCollection()->Which(); +} + static const StyleFamilyEntry& lcl_GetStyleEntry(const SfxStyleFamily eFamily) { auto pEntries = lcl_GetStyleFamilyEntries(); @@ -1137,33 +1149,15 @@ SwXStyle::SwXStyle(SwDoc* pDoc, SfxStyleFamily eFamily, bool bConditional) new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType)->getPropertyMap())); } -SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, - SwDoc* pDoc, const OUString& rStyleName) : - m_pDoc(pDoc), - m_sStyleName(rStyleName), - m_rEntry(lcl_GetStyleEntry(eFam)), - m_bIsDescriptor(false), - m_bIsConditional(false), - m_pBasePool(&rPool), - m_pPropertiesImpl(nullptr) -{ - if(!m_pBasePool) - return; - if(eFam == SFX_STYLE_FAMILY_PARA) - { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "where is the style?" ); - if(pBase) - { - const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(m_sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL); - if(nId != USHRT_MAX) - m_bIsConditional = ::IsConditionalByPoolId( nId ); - else - m_bIsConditional = RES_CONDTXTFMTCOLL == static_cast<SwDocStyleSheet*>(pBase)->GetCollection()->Which(); - } - } -} +SwXStyle::SwXStyle(SfxStyleSheetBasePool* pPool, SfxStyleFamily eFamily, SwDoc* pDoc, const OUString& rStyleName) + : m_pDoc(pDoc) + , m_sStyleName(rStyleName) + , m_rEntry(lcl_GetStyleEntry(eFamily)) + , m_bIsDescriptor(false) + , m_bIsConditional(lcl_InitConditional(pPool, eFamily, rStyleName)) + , m_pBasePool(pPool) + , m_pPropertiesImpl(nullptr) +{ } SwXStyle::~SwXStyle() { @@ -3160,7 +3154,7 @@ void SwXStyle::Invalidate() SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool, SwDocShell* pDocSh, SfxStyleFamily eFam, const OUString& rStyleName): - SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName) + SwXStyle(&rPool, eFam, pDocSh->GetDoc(), rStyleName) { } commit 15da424506dfdd1fc9b794346914e170638133c0 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 19:06:11 2015 +0100 use init helpers in ctor Change-Id: If06321f5b353a09985d071290ece612fb98b34a1 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a6e7bd5..7779062 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -263,8 +263,8 @@ class SwXStyle : public cppu::WeakImplHelper protected: SfxStyleSheetBasePool* m_pBasePool; std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl; - css::uno::Reference< css::beans::XPropertySet > mxStyleData; - css::uno::Reference< css::container::XNameAccess > mxStyleFamily; + css::uno::Reference<css::container::XNameAccess> m_xStyleFamily; + css::uno::Reference<css::beans::XPropertySet> m_xStyleData; void SAL_CALL SetPropertyValues_Impl( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) throw (css::beans::UnknownPropertyException, @@ -1085,17 +1085,24 @@ uno::Sequence< OUString > SwXStyle::getSupportedServiceNames() throw( uno::Runti return aRet; } -static uno::Reference<beans::XPropertySet> lcl_GetStandardStyle(uno::Reference<container::XNameAccess>& rxStyleFamily) +static uno::Reference<beans::XPropertySet> lcl_InitStandardStyle(const SfxStyleFamily eFamily, uno::Reference<container::XNameAccess>& rxStyleFamily) { - using return_t = decltype(lcl_GetStandardStyle(rxStyleFamily)); + using return_t = decltype(lcl_InitStandardStyle(eFamily, rxStyleFamily)); + if(eFamily != SFX_STYLE_FAMILY_PARA && eFamily != SFX_STYLE_FAMILY_PAGE) + return {}; auto aResult(rxStyleFamily->getByName("Standard")); if(!aResult.isExtractableTo(cppu::UnoType<return_t>::get())) return {}; return aResult.get<return_t>(); } -static uno::Reference<container::XNameAccess> lcl_GetStyleFamily(SwDoc* pDoc, const StyleFamilyEntry& rEntry) + +static uno::Reference<container::XNameAccess> lcl_InitStyleFamily(SwDoc* pDoc, const StyleFamilyEntry& rEntry) { - using return_t = decltype(lcl_GetStyleFamily(pDoc, rEntry)); + using return_t = decltype(lcl_InitStyleFamily(pDoc, rEntry)); + if(rEntry.m_eFamily != SFX_STYLE_FAMILY_CHAR + && rEntry.m_eFamily != SFX_STYLE_FAMILY_PARA + && rEntry.m_eFamily != SFX_STYLE_FAMILY_PAGE) + return {}; auto xModel(pDoc->GetDocShell()->GetBaseModel()); uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xModel, uno::UNO_QUERY); auto xFamilies = xFamilySupplier->getStyleFamilies(); @@ -1113,28 +1120,19 @@ static const StyleFamilyEntry& lcl_GetStyleEntry(const SfxStyleFamily eFamily) assert(pEntry != pEntries->end()); return *pEntry; } -SwXStyle::SwXStyle(SwDoc *pDoc, SfxStyleFamily eFamily, bool bConditional) : - m_pDoc(pDoc), - m_rEntry(lcl_GetStyleEntry(eFamily)), - m_bIsDescriptor(true), - m_bIsConditional(bConditional), - m_pBasePool(nullptr) + +SwXStyle::SwXStyle(SwDoc* pDoc, SfxStyleFamily eFamily, bool bConditional) + : m_pDoc(pDoc) + , m_rEntry(lcl_GetStyleEntry(eFamily)) + , m_bIsDescriptor(true) + , m_bIsConditional(bConditional) + , m_pBasePool(nullptr) + , m_xStyleFamily(lcl_InitStyleFamily(pDoc, m_rEntry)) + , m_xStyleData(lcl_InitStandardStyle(eFamily, m_xStyleFamily)) { assert(!m_bIsConditional || m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA); // only paragraph styles are conditional // Register ourselves as a listener to the document (via the page descriptor) pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); - switch(m_rEntry.m_eFamily) - { - case SFX_STYLE_FAMILY_CHAR: - case SFX_STYLE_FAMILY_PARA: - case SFX_STYLE_FAMILY_PAGE: - mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); - break; - default: - ; - } - if(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA || m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PAGE) - mxStyleData = lcl_GetStandardStyle(mxStyleFamily); m_pPropertiesImpl = std::unique_ptr<SwStyleProperties_Impl>( new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType)->getPropertyMap())); } @@ -1183,8 +1181,8 @@ void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) if(!GetRegisteredIn()) { m_pDoc = nullptr; - mxStyleData.clear(); - mxStyleFamily.clear(); + m_xStyleData.clear(); + m_xStyleFamily.clear(); } } @@ -1311,8 +1309,8 @@ void SwXStyle::setParentStyle(const OUString& rParentStyle) m_sParentStyleName = sParentStyle; try { - uno::Any aAny = mxStyleFamily->getByName ( sParentStyle ); - aAny >>= mxStyleData; + uno::Any aAny = m_xStyleFamily->getByName ( sParentStyle ); + aAny >>= m_xStyleData; } catch ( container::NoSuchElementException& ) { @@ -1403,8 +1401,8 @@ uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo() void SwXStyle::ApplyDescriptorProperties() { m_bIsDescriptor = false; - mxStyleData.clear(); - mxStyleFamily.clear(); + m_xStyleData.clear(); + m_xStyleFamily.clear(); const PropertyEntryVector_t& rPropertyVector = m_pPropertiesImpl->GetPropertyVector(); PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin(); @@ -2558,7 +2556,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( break; case SFX_STYLE_FAMILY_PARA: case SFX_STYLE_FAMILY_PAGE: - SwStyleProperties_Impl::GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] ); + SwStyleProperties_Impl::GetProperty ( pNames[nProp], m_xStyleData, pRet[ nProp ] ); break; case SFX_STYLE_FAMILY_CHAR: case SFX_STYLE_FAMILY_FRAME : @@ -3155,8 +3153,8 @@ void SwXStyle::Invalidate() m_sStyleName.clear(); m_pBasePool = nullptr; m_pDoc = nullptr; - mxStyleData.clear(); - mxStyleFamily.clear(); + m_xStyleData.clear(); + m_xStyleFamily.clear(); } SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool, @@ -3747,7 +3745,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( m_pPropertiesImpl->GetProperty(rPropName, pAny); if (!pAny->hasValue()) { - SwStyleProperties_Impl::GetProperty(rPropName, mxStyleData, pRet[nProp]); + SwStyleProperties_Impl::GetProperty(rPropName, m_xStyleData, pRet[nProp]); } else { commit a7d3ab3e79fceef8dfa3181129d0e1d7d678e807 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 18:45:40 2015 +0100 have PROPERTY_MAP values in entries ... Change-Id: I478eb10315ee0709c43943945d500b82a8d9c8c9 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index e2cc7a3..a6e7bd5 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -98,14 +98,16 @@ namespace using CreateStyle_t = std::function<uno::Reference<css::style::XStyle>(SfxStyleSheetBasePool*, SwDocShell*, const OUString&)>; using TranslateIndex_t = std::function<sal_uInt16(const sal_uInt16)>; SfxStyleFamily m_eFamily; + sal_uInt16 m_nPropMapType; SwGetPoolIdFromName m_aPoolId; OUString m_sName; sal_uInt32 m_nResId; GetCountOrName_t m_fGetCountOrName; CreateStyle_t m_fCreateStyle; TranslateIndex_t m_fTranslateIndex; - StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle, TranslateIndex_t fTranslateIndex) + StyleFamilyEntry(SfxStyleFamily eFamily, sal_uInt16 nPropMapType, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle, TranslateIndex_t fTranslateIndex) : m_eFamily(eFamily) + , m_nPropMapType(nPropMapType) , m_aPoolId(aPoolId) , m_sName(sName) , m_nResId(nResId) @@ -936,11 +938,11 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries() if(!our_pStyleFamilyEntries) { our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{ - { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> }, - { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> }, - { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndexRange<RES_POOLPAGE_BEGIN, nPoolPageRange> }, - { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndexRange<RES_POOLFRM_BEGIN, nPoolFrameRange> }, - { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndexRange<RES_POOLNUMRULE_BEGIN, nPoolNumRange> } + { SFX_STYLE_FAMILY_CHAR, PROPERTY_MAP_CHAR_STYLE, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> }, + { SFX_STYLE_FAMILY_PARA, PROPERTY_MAP_PARA_STYLE, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> }, + { SFX_STYLE_FAMILY_PAGE, PROPERTY_MAP_PAGE_STYLE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndexRange<RES_POOLPAGE_BEGIN, nPoolPageRange> }, + { SFX_STYLE_FAMILY_FRAME, PROPERTY_MAP_FRAME_STYLE, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndexRange<RES_POOLFRM_BEGIN, nPoolFrameRange> }, + { SFX_STYLE_FAMILY_PSEUDO, PROPERTY_MAP_NUM_STYLE, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndexRange<RES_POOLNUMRULE_BEGIN, nPoolNumRange> } }; } return our_pStyleFamilyEntries; @@ -1111,53 +1113,30 @@ static const StyleFamilyEntry& lcl_GetStyleEntry(const SfxStyleFamily eFamily) assert(pEntry != pEntries->end()); return *pEntry; } -SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFamily, bool bConditional) : +SwXStyle::SwXStyle(SwDoc *pDoc, SfxStyleFamily eFamily, bool bConditional) : m_pDoc(pDoc), m_rEntry(lcl_GetStyleEntry(eFamily)), m_bIsDescriptor(true), m_bIsConditional(bConditional), m_pBasePool(nullptr) { + assert(!m_bIsConditional || m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA); // only paragraph styles are conditional // Register ourselves as a listener to the document (via the page descriptor) pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); - sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE; switch(m_rEntry.m_eFamily) { case SFX_STYLE_FAMILY_CHAR: - { - nMapId = PROPERTY_MAP_CHAR_STYLE; - mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); - } - break; case SFX_STYLE_FAMILY_PARA: - { - nMapId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; - mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); - mxStyleData = lcl_GetStandardStyle(mxStyleFamily); - } - break; case SFX_STYLE_FAMILY_PAGE: - { - nMapId = PROPERTY_MAP_PAGE_STYLE; mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); - mxStyleData = lcl_GetStandardStyle(mxStyleFamily); - } break; - case SFX_STYLE_FAMILY_FRAME : - { - nMapId = PROPERTY_MAP_FRAME_STYLE; - } - break; - case SFX_STYLE_FAMILY_PSEUDO: - { - nMapId = PROPERTY_MAP_NUM_STYLE; - } - break; - default: ; } - m_pPropertiesImpl = std::unique_ptr<SwStyleProperties_Impl>(new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap())); + if(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA || m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PAGE) + mxStyleData = lcl_GetStandardStyle(mxStyleFamily); + m_pPropertiesImpl = std::unique_ptr<SwStyleProperties_Impl>( + new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType)->getPropertyMap())); } SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, commit 31cb29eb50afdca4c02de33ff9d88275c18f8f57 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 18:14:20 2015 +0100 lets have a ref to a StyleEntry from a SwXStyle too Change-Id: I368b2a6a6b5c54a962fed637c7e8cd472414be5c diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index cc9a0e8..e2cc7a3 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -253,7 +253,7 @@ class SwXStyle : public cppu::WeakImplHelper { SwDoc* m_pDoc; OUString m_sStyleName; - SfxStyleFamily m_eFamily; // for Notify + const StyleFamilyEntry& m_rEntry; bool m_bIsDescriptor; bool m_bIsConditional; OUString m_sParentStyleName; @@ -342,7 +342,7 @@ public: //SfxListener virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; OUString GetStyleName() const { return m_sStyleName;} - SfxStyleFamily GetFamily() const {return m_eFamily;} + SfxStyleFamily GetFamily() const {return m_rEntry.m_eFamily;} bool IsDescriptor() const {return m_bIsDescriptor;} bool IsConditional() const { return m_bIsConditional;} @@ -359,7 +359,7 @@ public: void SetStyleName(const OUString& rSet){ m_sStyleName = rSet;} virtual const SwTextFormatColl* GetFormatColl() const { - assert(m_eFamily == SFX_STYLE_FAMILY_PARA); + assert(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA); return m_pDoc->FindTextFormatCollByName(GetStyleName()); } }; @@ -1043,20 +1043,20 @@ sal_Int64 SAL_CALL SwXStyle::getSomething(const uno::Sequence<sal_Int8>& rId) uno::Sequence< OUString > SwXStyle::getSupportedServiceNames() throw( uno::RuntimeException, std::exception ) { long nCount = 1; - if(SFX_STYLE_FAMILY_PARA == m_eFamily) + if(SFX_STYLE_FAMILY_PARA == m_rEntry.m_eFamily) { nCount = 5; if(m_bIsConditional) nCount++; } - else if(SFX_STYLE_FAMILY_CHAR == m_eFamily) + else if(SFX_STYLE_FAMILY_CHAR == m_rEntry.m_eFamily) nCount = 5; - else if(SFX_STYLE_FAMILY_PAGE == m_eFamily) + else if(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily) nCount = 3; uno::Sequence< OUString > aRet(nCount); OUString* pArray = aRet.getArray(); pArray[0] = "com.sun.star.style.Style"; - switch(m_eFamily) + switch(m_rEntry.m_eFamily) { case SFX_STYLE_FAMILY_CHAR: pArray[1] = "com.sun.star.style.CharacterStyle"; @@ -1091,24 +1091,29 @@ static uno::Reference<beans::XPropertySet> lcl_GetStandardStyle(uno::Reference<c return {}; return aResult.get<return_t>(); } -static uno::Reference<container::XNameAccess> lcl_GetStyleFamily(SwDoc* pDoc, const SfxStyleFamily eFamily) +static uno::Reference<container::XNameAccess> lcl_GetStyleFamily(SwDoc* pDoc, const StyleFamilyEntry& rEntry) { - using return_t = decltype(lcl_GetStyleFamily(pDoc, eFamily)); - auto pEntries = lcl_GetStyleFamilyEntries(); - const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(), - [eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; }); + using return_t = decltype(lcl_GetStyleFamily(pDoc, rEntry)); auto xModel(pDoc->GetDocShell()->GetBaseModel()); uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xModel, uno::UNO_QUERY); auto xFamilies = xFamilySupplier->getStyleFamilies(); - auto aResult(xFamilies->getByName(pEntry->m_sName)); + auto aResult(xFamilies->getByName(rEntry.m_sName)); if(!aResult.isExtractableTo(cppu::UnoType<return_t>::get())) return {}; return aResult.get<return_t>(); } +static const StyleFamilyEntry& lcl_GetStyleEntry(const SfxStyleFamily eFamily) +{ + auto pEntries = lcl_GetStyleFamilyEntries(); + const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(), + [eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; }); + assert(pEntry != pEntries->end()); + return *pEntry; +} SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFamily, bool bConditional) : m_pDoc(pDoc), - m_eFamily(eFamily), + m_rEntry(lcl_GetStyleEntry(eFamily)), m_bIsDescriptor(true), m_bIsConditional(bConditional), m_pBasePool(nullptr) @@ -1116,25 +1121,25 @@ SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFamily, bool bConditional) : // Register ourselves as a listener to the document (via the page descriptor) pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE; - switch( m_eFamily ) + switch(m_rEntry.m_eFamily) { case SFX_STYLE_FAMILY_CHAR: { nMapId = PROPERTY_MAP_CHAR_STYLE; - mxStyleFamily = lcl_GetStyleFamily(pDoc, eFamily); + mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); } break; case SFX_STYLE_FAMILY_PARA: { nMapId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; - mxStyleFamily = lcl_GetStyleFamily(pDoc, eFamily); + mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); mxStyleData = lcl_GetStandardStyle(mxStyleFamily); } break; case SFX_STYLE_FAMILY_PAGE: { nMapId = PROPERTY_MAP_PAGE_STYLE; - mxStyleFamily = lcl_GetStyleFamily(pDoc, eFamily); + mxStyleFamily = lcl_GetStyleFamily(pDoc, m_rEntry); mxStyleData = lcl_GetStandardStyle(mxStyleFamily); } break; @@ -1159,7 +1164,7 @@ SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, SwDoc* pDoc, const OUString& rStyleName) : m_pDoc(pDoc), m_sStyleName(rStyleName), - m_eFamily(eFam), + m_rEntry(lcl_GetStyleEntry(eFam)), m_bIsDescriptor(false), m_bIsConditional(false), m_pBasePool(&rPool), @@ -1169,7 +1174,7 @@ SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, return; if(eFam == SFX_STYLE_FAMILY_PARA) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "where is the style?" ); if(pBase) @@ -1209,13 +1214,13 @@ OUString SwXStyle::getName() throw( uno::RuntimeException, std::exception ) SolarMutexGuard aGuard; if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "where is the style?" ); if(!pBase) throw uno::RuntimeException(); OUString aString; - SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_eFamily ), true); + SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true); return aString; } return m_sStyleName; @@ -1226,7 +1231,7 @@ void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException, std: SolarMutexGuard aGuard; if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "where is the style?" ); bool bExcept = true; @@ -1250,7 +1255,7 @@ sal_Bool SwXStyle::isUserDefined() throw( uno::RuntimeException, std::exception bool bRet = false; if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); //if it is not found it must be non user defined if(pBase) @@ -1267,7 +1272,7 @@ sal_Bool SwXStyle::isInUse() throw( uno::RuntimeException, std::exception ) bool bRet = false; if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily, SFXSTYLEBIT_USED); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily, SFXSTYLEBIT_USED); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); if(pBase) bRet = pBase->IsUsed(); @@ -1283,7 +1288,7 @@ OUString SwXStyle::getParentStyle() throw( uno::RuntimeException, std::exception OUString aString; if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); if(pBase) aString = pBase->GetParent(); @@ -1292,7 +1297,7 @@ OUString SwXStyle::getParentStyle() throw( uno::RuntimeException, std::exception aString = m_sParentStyleName; else throw uno::RuntimeException(); - SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( m_eFamily ), true ); + SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true ); return aString; } @@ -1301,10 +1306,10 @@ void SwXStyle::setParentStyle(const OUString& rParentStyle) { SolarMutexGuard aGuard; OUString sParentStyle; - SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( m_eFamily ), true ); + SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true ); if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); bool bExcept = false; SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); if(pBase) @@ -1413,7 +1418,7 @@ static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyl uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo() throw( uno::RuntimeException, std::exception ) { - return lcl_getPropertySetInfo( m_eFamily, m_bIsConditional ); + return lcl_getPropertySetInfo( m_rEntry.m_eFamily, m_bIsConditional ); } void SwXStyle::ApplyDescriptorProperties() @@ -2111,7 +2116,7 @@ void SAL_CALL SwXStyle::SetPropertyValues_Impl( sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - switch(m_eFamily) + 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; @@ -2134,9 +2139,9 @@ void SAL_CALL SwXStyle::SetPropertyValues_Impl( if(m_pBasePool) { const sal_uInt16 nSaveMask = m_pBasePool->GetSearchMask(); - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - m_pBasePool->SetSearchMask(m_eFamily, nSaveMask ); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily, nSaveMask ); OSL_ENSURE(pBase, "where is the style?" ); if(pBase) aBaseImpl.setNewBase(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); @@ -2155,7 +2160,7 @@ void SAL_CALL SwXStyle::SetPropertyValues_Impl( throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); if(aBaseImpl.getNewBase().is()) { - lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, m_pBasePool, m_pDoc, m_eFamily); + lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, m_pBasePool, m_pDoc, m_rEntry.m_eFamily); } else if(m_bIsDescriptor) { @@ -2524,7 +2529,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - switch(m_eFamily) + 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; @@ -2553,12 +2558,12 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( if(!pBase) { const sal_uInt16 nSaveMask = m_pBasePool->GetSearchMask(); - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); pBase = m_pBasePool->Find(m_sStyleName); - m_pBasePool->SetSearchMask(m_eFamily, nSaveMask ); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily, nSaveMask ); } - pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, m_eFamily, GetDoc() ); + pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, m_rEntry.m_eFamily, GetDoc() ); } else if(m_bIsDescriptor) { @@ -2567,7 +2572,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( if(!pAny->hasValue()) { bool bExcept = false; - switch( m_eFamily ) + switch( m_rEntry.m_eFamily ) { case SFX_STYLE_FAMILY_PSEUDO: bExcept = true; @@ -2582,7 +2587,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END ) { SwFormat * pFormat; - if ( m_eFamily == SFX_STYLE_FAMILY_CHAR ) + if ( m_rEntry.m_eFamily == SFX_STYLE_FAMILY_CHAR ) pFormat = m_pDoc->GetDfltCharFormat(); else pFormat = m_pDoc->GetDfltFrameFormat(); @@ -2679,7 +2684,7 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily ); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily ); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "where is the style?" ); @@ -2689,7 +2694,7 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - switch(m_eFamily) + 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; @@ -2727,8 +2732,8 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( if(!bDone) { // check for Header/Footer entry - const bool bHeader(SFX_STYLE_FAMILY_PAGE == m_eFamily && sPropName.startsWith("Header")); - const bool bFooter(SFX_STYLE_FAMILY_PAGE == m_eFamily && sPropName.startsWith("Footer")); + 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) { @@ -2785,7 +2790,7 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( { pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet); - if(SFX_STYLE_FAMILY_PAGE == m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i]) + if(SFX_STYLE_FAMILY_PAGE == m_rEntry.m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i]) { const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE)); sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f; @@ -2830,14 +2835,14 @@ void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "Where is the style?"); if(pBase) { rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); - switch(m_eFamily) + switch(m_rEntry.m_eFamily) { case SFX_STYLE_FAMILY_CHAR: pTargetFormat = xStyle->GetCharFormat(); @@ -2867,7 +2872,7 @@ void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - switch(m_eFamily) + 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; @@ -2940,7 +2945,7 @@ void SAL_CALL SwXStyle::setAllPropertiesToDefault( ) if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "Where is the style?"); @@ -2949,7 +2954,7 @@ void SAL_CALL SwXStyle::setAllPropertiesToDefault( ) rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pBase) ) ); SwFormat *pTargetFormat = nullptr; size_t nPgDscPos = SIZE_MAX; - switch(m_eFamily) + switch(m_rEntry.m_eFamily) { case SFX_STYLE_FAMILY_CHAR: pTargetFormat = xStyle->GetCharFormat(); @@ -3071,7 +3076,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Seq { if(m_pBasePool) { - m_pBasePool->SetSearchMask(m_eFamily); + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); OSL_ENSURE(pBase, "Doesn't seem to be a style!"); @@ -3079,7 +3084,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Seq { rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE; - switch(m_eFamily) + 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; @@ -3154,7 +3159,7 @@ void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } else if( pHint->GetId() &(SfxStyleSheetHintId::CHANGED|SfxStyleSheetHintId::ERASED) ) { - static_cast<SfxStyleSheetBasePool&>(rBC).SetSearchMask(m_eFamily); + static_cast<SfxStyleSheetBasePool&>(rBC).SetSearchMask(m_rEntry.m_eFamily); SfxStyleSheetBase* pOwnBase = static_cast<SfxStyleSheetBasePool&>(rBC).Find(m_sStyleName); if(!pOwnBase) { commit 29c01a1695b473f35cbc2b333f68f60691db1581 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 17:50:59 2015 +0100 refactor SwXStyle ctor Change-Id: I306ca1b20af83519f81ca0867eb73cbbaa1874d2 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 0009d8f..cc9a0e8 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -254,7 +254,6 @@ class SwXStyle : public cppu::WeakImplHelper SwDoc* m_pDoc; OUString m_sStyleName; SfxStyleFamily m_eFamily; // for Notify - bool m_bIsDescriptor; bool m_bIsConditional; OUString m_sParentStyleName; @@ -1084,53 +1083,59 @@ uno::Sequence< OUString > SwXStyle::getSupportedServiceNames() throw( uno::Runti return aRet; } -SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, bool bConditional) : - m_pDoc( pDoc ), - m_eFamily(eFam), +static uno::Reference<beans::XPropertySet> lcl_GetStandardStyle(uno::Reference<container::XNameAccess>& rxStyleFamily) +{ + using return_t = decltype(lcl_GetStandardStyle(rxStyleFamily)); + auto aResult(rxStyleFamily->getByName("Standard")); + if(!aResult.isExtractableTo(cppu::UnoType<return_t>::get())) + return {}; + return aResult.get<return_t>(); +} +static uno::Reference<container::XNameAccess> lcl_GetStyleFamily(SwDoc* pDoc, const SfxStyleFamily eFamily) +{ + using return_t = decltype(lcl_GetStyleFamily(pDoc, eFamily)); + auto pEntries = lcl_GetStyleFamilyEntries(); + const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(), + [eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; }); + auto xModel(pDoc->GetDocShell()->GetBaseModel()); + uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xModel, uno::UNO_QUERY); + auto xFamilies = xFamilySupplier->getStyleFamilies(); + auto aResult(xFamilies->getByName(pEntry->m_sName)); + if(!aResult.isExtractableTo(cppu::UnoType<return_t>::get())) + return {}; + return aResult.get<return_t>(); +} + +SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFamily, bool bConditional) : + m_pDoc(pDoc), + m_eFamily(eFamily), m_bIsDescriptor(true), m_bIsConditional(bConditional), m_pBasePool(nullptr) { // Register ourselves as a listener to the document (via the page descriptor) pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); - // get the property set for the default style data - // First get the model - uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel(); - // Ask the model for it's family supplier interface - uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY ); - // Get the style families - uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies(); - - uno::Any aAny; sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE; switch( m_eFamily ) { case SFX_STYLE_FAMILY_CHAR: { nMapId = PROPERTY_MAP_CHAR_STYLE; - aAny = xFamilies->getByName ("CharacterStyles"); - // Get the Frame family (and keep it for later) - aAny >>= mxStyleFamily; + mxStyleFamily = lcl_GetStyleFamily(pDoc, eFamily); } break; case SFX_STYLE_FAMILY_PARA: { nMapId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; - aAny = xFamilies->getByName ("ParagraphStyles"); - // Get the Frame family (and keep it for later) - aAny >>= mxStyleFamily; - aAny = mxStyleFamily->getByName ("Standard"); - aAny >>= mxStyleData; + mxStyleFamily = lcl_GetStyleFamily(pDoc, eFamily); + mxStyleData = lcl_GetStandardStyle(mxStyleFamily); } break; case SFX_STYLE_FAMILY_PAGE: { nMapId = PROPERTY_MAP_PAGE_STYLE; - aAny = xFamilies->getByName ("PageStyles"); - // Get the Frame family (and keep it for later) - aAny >>= mxStyleFamily; - aAny = mxStyleFamily->getByName ("Standard"); - aAny >>= mxStyleData; + mxStyleFamily = lcl_GetStyleFamily(pDoc, eFamily); + mxStyleData = lcl_GetStandardStyle(mxStyleFamily); } break; case SFX_STYLE_FAMILY_FRAME : commit 09d90f8c4e2bf188ebc06862302084869fecc557 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 00:53:35 2015 +0100 remove GetPropImpl wrapper Change-Id: I53c3f97d35621af9b6c5c0336b8c998d3fe0b270 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 0e38301..0009d8f 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -258,11 +258,10 @@ class SwXStyle : public cppu::WeakImplHelper bool m_bIsDescriptor; bool m_bIsConditional; OUString m_sParentStyleName; - std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl; protected: SfxStyleSheetBasePool* m_pBasePool; - SwStyleProperties_Impl& GetPropImpl(){return *m_pPropertiesImpl;} + std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl; css::uno::Reference< css::beans::XPropertySet > mxStyleData; css::uno::Reference< css::container::XNameAccess > mxStyleFamily; @@ -1158,8 +1157,8 @@ SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, m_eFamily(eFam), m_bIsDescriptor(false), m_bIsConditional(false), - m_pPropertiesImpl(nullptr), - m_pBasePool(&rPool) + m_pBasePool(&rPool), + m_pPropertiesImpl(nullptr) { if(!m_pBasePool) return; @@ -3455,7 +3454,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( } else if(IsDescriptor()) { - if(!GetPropImpl().SetProperty(rPropName, pValues[nProp])) + if(!m_pPropertiesImpl->SetProperty(rPropName, pValues[nProp])) throw lang::IllegalArgumentException(); } else @@ -3756,7 +3755,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( else if(IsDescriptor()) { const uno::Any* pAny = nullptr; - GetPropImpl().GetProperty(rPropName, pAny); + m_pPropertiesImpl->GetProperty(rPropName, pAny); if (!pAny->hasValue()) { SwStyleProperties_Impl::GetProperty(rPropName, mxStyleData, pRet[nProp]); commit dc9d9ff650c135e9a9d84af3480d992c7b6d47e7 Author: Bjoern Michaelsen <[email protected]> Date: Wed Dec 23 00:41:32 2015 +0100 remove GetBasePool wrappers Change-Id: I0e7e8309c5d8873b9bde738a00579989d7b105fb diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 22fd71e..0e38301 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -262,9 +262,6 @@ class SwXStyle : public cppu::WeakImplHelper protected: SfxStyleSheetBasePool* m_pBasePool; - const SfxStyleSheetBasePool* GetBasePool() const {return m_pBasePool;} - SfxStyleSheetBasePool* GetBasePool() {return m_pBasePool;} - SwStyleProperties_Impl& GetPropImpl(){return *m_pPropertiesImpl;} css::uno::Reference< css::beans::XPropertySet > mxStyleData; css::uno::Reference< css::container::XNameAccess > mxStyleFamily; @@ -3233,12 +3230,12 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( 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(GetBasePool()) + if(m_pBasePool) { - const sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); - GetBasePool()->SetSearchMask(GetFamily()); - SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName()); - GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); + 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) { @@ -3265,7 +3262,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); } - if(GetBasePool()) + if(m_pBasePool) { switch(pEntry->nWID) { @@ -3293,7 +3290,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(), rPropName, bFooter, pSetItem)) { - lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); + lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, m_pBasePool, GetDoc(), GetFamily()); if (pEntry->nWID == SID_ATTR_PAGE_SHARED_FIRST) { @@ -3302,7 +3299,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET, false, reinterpret_cast<const SfxPoolItem**>(&pSetItem))) { - lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); + lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, m_pBasePool, GetDoc(), GetFamily()); } } } @@ -3357,7 +3354,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( default: { // part of PageStyle, fallback to default - lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); + lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, m_pBasePool, GetDoc(), GetFamily()); } } } @@ -3407,7 +3404,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the // default method to set the property SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet); - lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); + lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, m_pBasePool, GetDoc(), GetFamily()); aBaseImpl.replaceItemSet(pRememberItemSet); // reset paret at ItemSet from SetItem @@ -3421,7 +3418,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( else { // part of PageStyle, fallback to default - lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); + lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, m_pBasePool, GetDoc(), GetFamily()); } break; @@ -3451,7 +3448,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( default: { //UUUU - lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily()); + lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, m_pBasePool, GetDoc(), GetFamily()); break; } } @@ -3554,14 +3551,14 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( throw beans::UnknownPropertyException("Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > ( this ) ); } - if(GetBasePool()) + if(m_pBasePool) { if(!pBase) { - const sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask(); - GetBasePool()->SetSearchMask(GetFamily()); - pBase = GetBasePool()->Find(GetStyleName()); - GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); + 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; @@ -3835,7 +3832,7 @@ 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 = GetBasePool(); + SfxStyleSheetBasePool* pBasePool = m_pBasePool; if (pBasePool) { SfxStyleSheetBase* pBase = pBasePool->Find(GetStyleName()); @@ -3854,7 +3851,7 @@ 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 = GetBasePool(); + SfxStyleSheetBasePool* pBasePool = m_pBasePool; if(!pBasePool) return nullptr; SfxStyleSheetBase* pBase = pBasePool->Find(GetStyleName()); commit b23f6841b2e67958336c6ffadd6522dc0abbf1dc Author: Bjoern Michaelsen <[email protected]> Date: Tue Dec 22 14:35:50 2015 +0100 instead of lying with friendship, lets be honest Change-Id: I0582734a0995638f45888e32c108e56ab3f28e80 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 8a07481..22fd71e 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -251,25 +251,20 @@ class SwXStyle : public cppu::WeakImplHelper , public SfxListener , public SwClient { - friend class sw::XStyleFamily; - SwDoc* m_pDoc; - OUString m_sStyleName; - SfxStyleSheetBasePool* m_pBasePool; - SfxStyleFamily m_eFamily; // for Notify - - bool m_bIsDescriptor : 1; - bool m_bIsConditional : 1; - OUString m_sParentStyleName; + SwDoc* m_pDoc; + OUString m_sStyleName; + SfxStyleFamily m_eFamily; // for Notify + + bool m_bIsDescriptor; + bool m_bIsConditional; + OUString m_sParentStyleName; std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl; - void ApplyDescriptorProperties(); protected: - void Invalidate(); - + SfxStyleSheetBasePool* m_pBasePool; const SfxStyleSheetBasePool* GetBasePool() const {return m_pBasePool;} SfxStyleSheetBasePool* GetBasePool() {return m_pBasePool;} - void SetStyleName(const OUString& rSet){ m_sStyleName = rSet;} SwStyleProperties_Impl& GetPropImpl(){return *m_pPropertiesImpl;} css::uno::Reference< css::beans::XPropertySet > mxStyleData; css::uno::Reference< css::container::XNameAccess > mxStyleFamily; @@ -364,6 +359,9 @@ public: StartListening(*m_pBasePool); } SwDoc* GetDoc() const { return m_pDoc; } + void Invalidate(); + void ApplyDescriptorProperties(); + void SetStyleName(const OUString& rSet){ m_sStyleName = rSet;} virtual const SwTextFormatColl* GetFormatColl() const { assert(m_eFamily == SFX_STYLE_FAMILY_PARA); @@ -389,11 +387,8 @@ public: virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override; virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException, std::exception) override; - virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) throw(css::uno::RuntimeException, std::exception) override; - friend class SwFrameStyleEventDescriptor; - //ICoreStyle virtual void SetItem(enum RES_FRMATR eAtr, const SfxPoolItem& rItem); virtual const SfxPoolItem* GetItem(enum RES_FRMATR eAtr); @@ -1095,10 +1090,10 @@ uno::Sequence< OUString > SwXStyle::getSupportedServiceNames() throw( uno::Runti SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, bool bConditional) : m_pDoc( pDoc ), - m_pBasePool(nullptr), m_eFamily(eFam), m_bIsDescriptor(true), - m_bIsConditional(bConditional) + m_bIsConditional(bConditional), + m_pBasePool(nullptr) { // Register ourselves as a listener to the document (via the page descriptor) pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); @@ -1163,11 +1158,11 @@ SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, SwDoc* pDoc, const OUString& rStyleName) : m_pDoc(pDoc), m_sStyleName(rStyleName), - m_pBasePool(&rPool), m_eFamily(eFam), m_bIsDescriptor(false), m_bIsConditional(false), - m_pPropertiesImpl(nullptr) + m_pPropertiesImpl(nullptr), + m_pBasePool(&rPool) { if(!m_pBasePool) return; commit 0afe84d168b925f0f24139e1f595e3ac27a5df00 Author: Bjoern Michaelsen <[email protected]> Date: Tue Dec 22 14:26:05 2015 +0100 use a proper smart pointer here Change-Id: Ic413e08bbaf38a6858926b1309618762a9ed1444 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index e9d299a..8a07481 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -260,7 +260,7 @@ class SwXStyle : public cppu::WeakImplHelper bool m_bIsDescriptor : 1; bool m_bIsConditional : 1; OUString m_sParentStyleName; - SwStyleProperties_Impl* m_pPropertiesImpl; + std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl; void ApplyDescriptorProperties(); protected: @@ -270,7 +270,7 @@ protected: SfxStyleSheetBasePool* GetBasePool() {return m_pBasePool;} void SetStyleName(const OUString& rSet){ m_sStyleName = rSet;} - SwStyleProperties_Impl* GetPropImpl(){return m_pPropertiesImpl;} + SwStyleProperties_Impl& GetPropImpl(){return *m_pPropertiesImpl;} css::uno::Reference< css::beans::XPropertySet > mxStyleData; css::uno::Reference< css::container::XNameAccess > mxStyleFamily; @@ -1156,7 +1156,7 @@ SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, bool bConditional) : default: ; } - m_pPropertiesImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap()); + m_pPropertiesImpl = std::unique_ptr<SwStyleProperties_Impl>(new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap())); } SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, @@ -1192,7 +1192,7 @@ SwXStyle::~SwXStyle() SolarMutexGuard aGuard; if(m_pBasePool) EndListening(*m_pBasePool); - delete m_pPropertiesImpl; + m_pPropertiesImpl.reset(); if(GetRegisteredIn()) GetRegisteredIn()->Remove( this ); } @@ -3463,7 +3463,7 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( } else if(IsDescriptor()) { - if(!GetPropImpl()->SetProperty(rPropName, pValues[nProp])) + if(!GetPropImpl().SetProperty(rPropName, pValues[nProp])) throw lang::IllegalArgumentException(); } else @@ -3764,7 +3764,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( else if(IsDescriptor()) { const uno::Any* pAny = nullptr; - GetPropImpl()->GetProperty(rPropName, pAny); + GetPropImpl().GetProperty(rPropName, pAny); if (!pAny->hasValue()) { SwStyleProperties_Impl::GetProperty(rPropName, mxStyleData, pRet[nProp]); commit 2b03164c0a9e90af2966dbf6252143cfe973d2f1 Author: Bjoern Michaelsen <[email protected]> Date: Tue Dec 22 14:03:00 2015 +0100 move trivial functions inline Change-Id: Icc7c58e847a4087460a86686c790722e6651c85a diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 19dc497..e9d299a 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -312,17 +312,24 @@ public: virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString&, const css::uno::Reference< css::beans::XPropertyChangeListener >& ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override + { OSL_FAIL("not implemented"); }; + virtual void SAL_CALL removePropertyChangeListener( const OUString&, const css::uno::Reference< css::beans::XPropertyChangeListener >& ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override + { OSL_FAIL("not implemented"); }; + virtual void SAL_CALL addVetoableChangeListener( const OUString&, const css::uno::Reference< css::beans::XVetoableChangeListener >& ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override + { OSL_FAIL("not implemented"); }; + virtual void SAL_CALL removeVetoableChangeListener( const OUString&, const css::uno::Reference< css::beans::XVetoableChangeListener >& ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override + { OSL_FAIL("not implemented"); }; //XMultiPropertySet virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) throw(css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) throw(css::uno::RuntimeException, std::exception) override; + virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >&, const css::uno::Reference< css::beans::XPropertiesChangeListener >& ) throw(css::uno::RuntimeException, std::exception) override + {}; + virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& ) throw(css::uno::RuntimeException, std::exception) override + {}; + virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >&, const css::uno::Reference< css::beans::XPropertiesChangeListener >& ) throw(css::uno::RuntimeException, std::exception) override + {}; //XPropertyState virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) override; @@ -336,8 +343,10 @@ public: virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; //XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override; - virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override; + virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override + { return {"SwXStyle"}; }; + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw( css::uno::RuntimeException, std::exception ) override + { return cppu::supportsService(this, rServiceName); }; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override; //SfxListener @@ -1041,16 +1050,6 @@ sal_Int64 SAL_CALL SwXStyle::getSomething(const uno::Sequence<sal_Int8>& rId) } -OUString SwXStyle::getImplementationName() throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXStyle"); -} - -sal_Bool SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - uno::Sequence< OUString > SwXStyle::getSupportedServiceNames() throw( uno::RuntimeException, std::exception ) { long nCount = 1; @@ -2642,26 +2641,6 @@ uno::Sequence< uno::Any > SwXStyle::getPropertyValues( return aValues; } -void SwXStyle::addPropertiesChangeListener( - const uno::Sequence< OUString >& /*aPropertyNames*/, - const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException, std::exception) -{ -} - -void SwXStyle::removePropertiesChangeListener( - const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException, std::exception) -{ -} - -void SwXStyle::firePropertiesChangeEvent( - const uno::Sequence< OUString >& /*aPropertyNames*/, - const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException, std::exception) -{ -} - void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue) throw( beans::UnknownPropertyException, beans::PropertyVetoException, @@ -2685,34 +2664,6 @@ uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName) } -void SwXStyle::addPropertyChangeListener(const OUString& /*rPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -void SwXStyle::removePropertyChangeListener(const OUString& /*rPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -void SwXStyle::addVetoableChangeListener(const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -void SwXStyle::removeVetoableChangeListener(const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName) throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception ) { commit aef1e2dde5e53ba8416a393bbe155ef0c18511a7 Author: Bjoern Michaelsen <[email protected]> Date: Mon Dec 21 03:55:14 2015 +0100 move SwXStyle entirely into compilation unit Change-Id: Icfcb4320aef9ebe2c5fcc84106de005934d51a3f diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx index ea7f723..72b6b04 100644 --- a/sw/inc/unostyle.hxx +++ b/sw/inc/unostyle.hxx @@ -103,174 +103,24 @@ public: static css::uno::Reference<css::style::XStyle> CreateStyleCondParagraph(SwDoc& rDoc); }; - -class SwXStyle : public cppu::WeakImplHelper -< - css::style::XStyle, - css::beans::XPropertySet, - css::beans::XMultiPropertySet, - css::lang::XServiceInfo, - css::lang::XUnoTunnel, - css::beans::XPropertyState, - css::beans::XMultiPropertyStates ->, - public SfxListener, - public SwClient -{ - friend class sw::XStyleFamily; - SwDoc* m_pDoc; - OUString m_sStyleName; - SfxStyleSheetBasePool* m_pBasePool; - SfxStyleFamily m_eFamily; // for Notify - - bool m_bIsDescriptor : 1; - bool m_bIsConditional : 1; - OUString m_sParentStyleName; - SwStyleProperties_Impl* m_pPropertiesImpl; - - void ApplyDescriptorProperties(); -protected: - void Invalidate(); - - const SfxStyleSheetBasePool* GetBasePool() const {return m_pBasePool;} - SfxStyleSheetBasePool* GetBasePool() {return m_pBasePool;} - - void SetStyleName(const OUString& rSet){ m_sStyleName = rSet;} - SwStyleProperties_Impl* GetPropImpl(){return m_pPropertiesImpl;} - css::uno::Reference< css::beans::XPropertySet > mxStyleData; - css::uno::Reference< css::container::XNameAccess > mxStyleFamily; - - void SAL_CALL SetPropertyValues_Impl( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) - throw (css::beans::UnknownPropertyException, - css::beans::PropertyVetoException, - css::lang::IllegalArgumentException, - css::lang::WrappedTargetException, - css::uno::RuntimeException, - std::exception); - css::uno::Sequence< css::uno::Any > SAL_CALL GetPropertyValues_Impl( const css::uno::Sequence< OUString >& aPropertyNames ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception); - - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; -public: - SwXStyle(SwDoc* pDoc, SfxStyleFamily eFam = SFX_STYLE_FAMILY_PARA, bool bConditional = false); - SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam, - SwDoc* pDoc, - const OUString& rStyleName); - - virtual ~SwXStyle(); - - - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override; - - //XNamed - virtual OUString SAL_CALL getName() throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL setName(const OUString& Name_) throw( css::uno::RuntimeException, std::exception ) override; - - //XStyle - virtual sal_Bool SAL_CALL isUserDefined() throw( css::uno::RuntimeException, std::exception ) override; - virtual sal_Bool SAL_CALL isInUse() throw( css::uno::RuntimeException, std::exception ) override; - virtual OUString SAL_CALL getParentStyle() throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL setParentStyle(const OUString& aParentStyle) throw( css::container::NoSuchElementException, css::uno::RuntimeException, std::exception ) override; - - //XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - - //XMultiPropertySet - virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) throw(css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) throw(css::uno::RuntimeException, std::exception) override; - - //XPropertyState - virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) override; - virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) throw(css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) override; - virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - - //XMultiPropertyStates - virtual void SAL_CALL setAllPropertiesToDefault( ) throw (css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) override; - virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; - - //XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override; - virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override; - - //SfxListener - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; - - OUString GetStyleName() const { return m_sStyleName;} - SfxStyleFamily GetFamily() const {return m_eFamily;} - - bool IsDescriptor() const {return m_bIsDescriptor;} - bool IsConditional() const { return m_bIsConditional;} - OUString GetParentStyleName() const { return m_sParentStyleName;} - void SetDoc(SwDoc* pDc, SfxStyleSheetBasePool* pPool) - { - m_bIsDescriptor = false; m_pDoc = pDc; - m_pBasePool = pPool; - StartListening(*m_pBasePool); - } - SwDoc* GetDoc() const { return m_pDoc; } -}; - -class SwXFrameStyle : public SwXStyle, - public css::document::XEventsSupplier -{ -public: - SwXFrameStyle(SfxStyleSheetBasePool& rPool, - SwDoc* pDoc, - const OUString& rStyleName) : - SwXStyle(rPool, SFX_STYLE_FAMILY_FRAME, pDoc, rStyleName){} - SwXFrameStyle( SwDoc *pDoc ); - virtual ~SwXFrameStyle(); - - virtual void SAL_CALL acquire( ) throw() override {SwXStyle::acquire();} - virtual void SAL_CALL release( ) throw() override {SwXStyle::release();} - - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override; - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException, std::exception) override; - - virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) throw(css::uno::RuntimeException, std::exception) override; - - friend class SwFrameStyleEventDescriptor; -}; - -class SwXPageStyle : public SwXStyle +namespace sw { -protected: - void SAL_CALL SetPropertyValues_Impl( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) - throw (css::beans::UnknownPropertyException, - css::beans::PropertyVetoException, - css::lang::IllegalArgumentException, - css::lang::WrappedTargetException, - css::uno::RuntimeException, - std::exception); - css::uno::Sequence< css::uno::Any > SAL_CALL GetPropertyValues_Impl( const css::uno::Sequence< OUString >& aPropertyNames ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception); - -public: - SwXPageStyle(SfxStyleSheetBasePool& rPool, SwDocShell* pDocSh, SfxStyleFamily eFam, - const OUString& rStyleName); - SwXPageStyle(SwDocShell* pDocSh); - virtual ~SwXPageStyle(); - - virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
