diff options
-rw-r--r-- | sw/inc/unostyle.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 73 |
2 files changed, 9 insertions, 70 deletions
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx index 8aabdff3c082..7a96fbb545ba 100644 --- a/sw/inc/unostyle.hxx +++ b/sw/inc/unostyle.hxx @@ -62,11 +62,7 @@ class SwXStyleFamilies : public cppu::WeakImplHelper { SwDocShell* m_pDocShell; - css::uno::Reference< css::container::XNameContainer > m_xCharStyles; - css::uno::Reference< css::container::XNameContainer > m_xParaStyles; - css::uno::Reference< css::container::XNameContainer > m_xFrameStyles; - css::uno::Reference< css::container::XNameContainer > m_xPageStyles; - css::uno::Reference< css::container::XNameContainer > m_xNumberingStyles; + std::map<SfxStyleFamily, css::uno::Reference<css::container::XNameContainer>> m_vContainers; protected: virtual ~SwXStyleFamilies(); public: diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index b2954c296aec..23dad41d4585 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -162,12 +162,7 @@ uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames() throw( un SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) : SwUnoCollection(rDocShell.GetDoc()), - m_pDocShell(&rDocShell), - m_xCharStyles(), - m_xParaStyles(), - m_xFrameStyles(), - m_xPageStyles(), - m_xNumberingStyles() + m_pDocShell(&rDocShell) { } @@ -216,68 +211,16 @@ uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - uno::Any aRet; if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(our_vStyleFamilyEntries.size())) throw lang::IndexOutOfBoundsException(); - if(IsValid()) - { - uno::Reference< container::XNameContainer > aRef; - auto eFamily = our_vStyleFamilyEntries[nIndex].m_eFamily; - switch( eFamily ) - { - case SFX_STYLE_FAMILY_CHAR: - { - if(!m_xCharStyles.is()) - { - m_xCharStyles = new SwXStyleFamily(m_pDocShell, eFamily); - } - aRef = m_xCharStyles; - } - break; - case SFX_STYLE_FAMILY_PARA: - { - if(!m_xParaStyles.is()) - { - m_xParaStyles = new SwXStyleFamily(m_pDocShell, eFamily); - } - aRef = m_xParaStyles; - } - break; - case SFX_STYLE_FAMILY_PAGE: - { - if(!m_xPageStyles.is()) - { - m_xPageStyles = new SwXStyleFamily(m_pDocShell, eFamily); - } - aRef = m_xPageStyles; - } - break; - case SFX_STYLE_FAMILY_FRAME: - { - if(!m_xFrameStyles.is()) - { - m_xFrameStyles = new SwXStyleFamily(m_pDocShell, eFamily); - } - aRef = m_xFrameStyles; - } - break; - case SFX_STYLE_FAMILY_PSEUDO: - { - if(!m_xNumberingStyles.is()) - { - m_xNumberingStyles = new SwXStyleFamily(m_pDocShell, eFamily); - } - aRef = m_xNumberingStyles; - } - break; - case SFX_STYLE_FAMILY_ALL: - assert(false); - } - aRet.setValue(&aRef, cppu::UnoType<container::XNameContainer>::get()); - } - else + if(!IsValid()) throw uno::RuntimeException(); - return aRet; + auto eFamily = our_vStyleFamilyEntries[nIndex].m_eFamily; + assert(eFamily != SFX_STYLE_FAMILY_ALL); + auto& rxContainer = m_vContainers[eFamily]; + if(!rxContainer.is()) + rxContainer = new SwXStyleFamily(m_pDocShell, eFamily); + return uno::makeAny(rxContainer); } uno::Type SwXStyleFamilies::getElementType() |