sw/inc/coreframestyle.hxx                            |   37 ++
 sw/inc/unostyle.hxx                                  |   26 -
 sw/inc/unotxdoc.hxx                                  |    4 
 sw/inc/unoxstyle.hxx                                 |  231 ++++++++++++++
 sw/source/core/unocore/unostyle.cxx                  |  306 ++++++-------------
 sw/source/uibase/uno/unotxdoc.cxx                    |   15 
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |    3 
 sw/source/writerfilter/dmapper/NumberingManager.cxx  |   27 -
 sw/source/writerfilter/dmapper/NumberingManager.hxx  |    6 
 sw/source/writerfilter/dmapper/PropertyMap.cxx       |   20 -
 sw/source/writerfilter/dmapper/PropertyMap.hxx       |    5 
 11 files changed, 435 insertions(+), 245 deletions(-)
New commits:
commit 0cfaf93bf5c6e4e505b45f5e4fbac54edd77ddd6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Apr 24 16:39:23 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Apr 28 22:26:51 2024 +0200

    use more concrete UNO classes in writerfilter (SwXStyle)
    
    Change-Id: I12b41369ee65f46e08494acda0435f767e28f290
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166804
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/coreframestyle.hxx b/sw/inc/coreframestyle.hxx
new file mode 100644
index 000000000000..07d5ab5e33c2
--- /dev/null
+++ b/sw/inc/coreframestyle.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <com/sun/star/document/XEventsSupplier.hpp>
+
+class SfxPoolItem;
+
+namespace sw
+{
+class ICoreFrameStyle
+{
+public:
+    virtual void SetItem(sal_uInt16 eAtr, const SfxPoolItem& rItem) = 0;
+    virtual const SfxPoolItem* GetItem(sal_uInt16 eAtr) = 0;
+    virtual css::document::XEventsSupplier& GetEventsSupplier() = 0;
+    virtual ~ICoreFrameStyle(){};
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index bcd2c96aba6a..77c2cc8856c0 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/style/XAutoStyles.hpp>
 #include <com/sun/star/style/XAutoStyle.hpp>
 
+#include "coreframestyle.hxx"
 #include "istyleaccess.hxx"
 #include <memory>
 #include <map>
@@ -43,6 +44,10 @@ namespace com::sun::star::document { class XEventsSupplier; }
 class SwDocShell;
 class SwAutoStylesEnumImpl;
 class SfxItemSet;
+class SwXStyle;
+class SwXTextCellStyle;
+class SwXPageStyle;
+class SwXFrameStyle;
 
 class SwXStyleFamilies final : public cppu::WeakImplHelper
 <
@@ -84,23 +89,16 @@ public:
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
     static css::uno::Reference<css::style::XStyle> CreateStyle(SfxStyleFamily 
eFamily, SwDoc& rDoc);
+    static rtl::Reference<SwXStyle> 
CreateStyleCharOrParaOrPseudo(SfxStyleFamily eFamily, SwDoc& rDoc);
+    static rtl::Reference<SwXPageStyle> CreateStylePage(SwDoc& rDoc);
+    static rtl::Reference<SwXFrameStyle> CreateStyleFrame(SwDoc& rDoc);
+    static rtl::Reference<SwXTextTableStyle> CreateStyleTable(SwDoc& rDoc);
+    static rtl::Reference<SwXTextCellStyle> CreateStyleCell(SwDoc& rDoc);
     // FIXME: This is very ugly as is the whole conditional paragraph style
     // hackety. Should be folded into CreateStyle hopefully one day
     static css::uno::Reference<css::style::XStyle> 
CreateStyleCondParagraph(SwDoc& rDoc);
 };
 
-namespace sw
-{
-    class ICoreFrameStyle
-    {
-        public:
-            virtual void SetItem(sal_uInt16 eAtr, const SfxPoolItem& rItem) =0;
-            virtual const SfxPoolItem* GetItem(sal_uInt16 eAtr) =0;
-            virtual css::document::XEventsSupplier& GetEventsSupplier() =0;
-            virtual ~ICoreFrameStyle() {};
-    };
-}
-
 // access to all automatic style families
 class SwXAutoStyles final :
     public cppu::WeakImplHelper< css::style::XAutoStyles >,
@@ -318,7 +316,7 @@ public:
     virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) 
override;
     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() 
override;
 
-    static css::uno::Reference<css::style::XStyle> 
CreateXTextTableStyle(SwDocShell* pDocShell, const OUString& 
rTableAutoFormatName);
+    static rtl::Reference<SwXTextTableStyle> CreateXTextTableStyle(SwDocShell* 
pDocShell, const OUString& rTableAutoFormatName);
 };
 
 /// A text cell style is a UNO API wrapper for a SwBoxAutoFormat core class
@@ -389,7 +387,7 @@ class SwXTextCellStyle final : public cppu::WeakImplHelper
     virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) 
override;
     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() 
override;
 
-    static css::uno::Reference<css::style::XStyle> 
CreateXTextCellStyle(SwDocShell* pDocShell, const OUString& sName);
+    static rtl::Reference<SwXTextCellStyle> CreateXTextCellStyle(SwDocShell* 
pDocShell, const OUString& sName);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index d84561244258..4651ccaee190 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -96,6 +96,7 @@ class SwXFootnotes;
 class SwXContentControls;
 class SwXDocumentIndexes;
 class SwXStyleFamilies;
+class SwXStyle;
 class SwXAutoStyles;
 class SwXBookmarks;
 class SwXChapterNumbering;
@@ -113,6 +114,7 @@ class SwXTextField;
 class SwXLineBreak;
 class SwXTextFrame;
 class SwXTextGraphicObject;
+class SwXPageStyle;
 namespace com::sun::star::container { class XNameContainer; }
 namespace com::sun::star::frame { class XController; }
 namespace com::sun::star::lang { struct Locale; }
@@ -524,6 +526,8 @@ public:
     SW_DLLPUBLIC rtl::Reference<SwXLineBreak> createLineBreak();
     SW_DLLPUBLIC rtl::Reference<SwXTextFrame> createTextFrame();
     SW_DLLPUBLIC rtl::Reference<SwXTextGraphicObject> 
createTextGraphicObject();
+    SW_DLLPUBLIC rtl::Reference<SwXStyle> createNumberingStyle();
+    SW_DLLPUBLIC rtl::Reference<SwXPageStyle> createPageStyle();
 };
 
 class SwXLinkTargetSupplier final : public cppu::WeakImplHelper
diff --git a/sw/inc/unoxstyle.hxx b/sw/inc/unoxstyle.hxx
new file mode 100644
index 000000000000..3a57b5b2087e
--- /dev/null
+++ b/sw/inc/unoxstyle.hxx
@@ -0,0 +1,231 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <rtl/ref.hxx>
+#include <svl/listener.hxx>
+#include <svl/style.hxx>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertyStates.hpp>
+#include <cppuhelper/implbase.hxx>
+#include "coreframestyle.hxx"
+
+class StyleFamilyEntry;
+class SwStyleBase_Impl;
+class SwStyleProperties_Impl;
+class SvxSetItem;
+struct SfxItemPropertyMapEntry;
+
+class SAL_DLLPUBLIC_RTTI 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 SvtListener
+{
+    SwDoc* m_pDoc;
+    OUString m_sStyleName;
+    const StyleFamilyEntry& m_rEntry;
+    bool m_bIsDescriptor;
+    bool m_bIsConditional;
+    OUString m_sParentStyleName;
+
+protected:
+    SfxStyleSheetBasePool* m_pBasePool;
+    std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl;
+    css::uno::Reference<css::container::XNameAccess> m_xStyleFamily;
+    css::uno::Reference<css::beans::XPropertySet> m_xStyleData;
+
+    template <sal_uInt16>
+    void SetPropertyValue(const SfxItemPropertyMapEntry&, const 
SfxItemPropertySet&,
+                          const css::uno::Any&, SwStyleBase_Impl&);
+    void SetPropertyValues_Impl(const css::uno::Sequence<OUString>& 
aPropertyNames,
+                                const css::uno::Sequence<css::uno::Any>& 
aValues);
+    SfxStyleSheetBase* GetStyleSheetBase();
+    void PrepareStyleBase(SwStyleBase_Impl& rBase);
+    template <sal_uInt16>
+    css::uno::Any GetStyleProperty(const SfxItemPropertyMapEntry& rEntry,
+                                   const SfxItemPropertySet& rPropSet, 
SwStyleBase_Impl& rBase);
+    css::uno::Any GetStyleProperty_Impl(const SfxItemPropertyMapEntry& rEntry,
+                                        const SfxItemPropertySet& rPropSet,
+                                        SwStyleBase_Impl& rBase);
+    css::uno::Any GetPropertyValue_Impl(const SfxItemPropertySet* pPropSet, 
SwStyleBase_Impl& rBase,
+                                        const OUString& rPropertyName);
+
+public:
+    SwXStyle(SwDoc* pDoc, SfxStyleFamily eFam, bool bConditional = false);
+    SwXStyle(SfxStyleSheetBasePool* pPool, SfxStyleFamily eFamily, SwDoc* pDoc,
+             const OUString& rStyleName);
+    virtual ~SwXStyle() override;
+
+    static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
+
+    //XUnoTunnel
+    virtual sal_Int64 SAL_CALL
+    getSomething(const css::uno::Sequence<sal_Int8>& aIdentifier) override;
+
+    //XNamed
+    virtual OUString SAL_CALL getName() override;
+    virtual void SAL_CALL setName(const OUString& Name_) override;
+
+    //XStyle
+    virtual sal_Bool SAL_CALL isUserDefined() override;
+    virtual sal_Bool SAL_CALL isInUse() override;
+    virtual OUString SAL_CALL getParentStyle() override;
+    virtual void SAL_CALL setParentStyle(const OUString& aParentStyle) 
override;
+
+    //XPropertySet
+    virtual css::uno::Reference<css::beans::XPropertySetInfo>
+        SAL_CALL getPropertySetInfo() override;
+    virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName,
+                                           const css::uno::Any& aValue) 
override;
+    virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& 
PropertyName) override;
+    virtual void SAL_CALL addPropertyChangeListener(
+        const OUString&, const 
css::uno::Reference<css::beans::XPropertyChangeListener>&) override
+    {
+        OSL_FAIL("not implemented");
+    };
+    virtual void SAL_CALL removePropertyChangeListener(
+        const OUString&, const 
css::uno::Reference<css::beans::XPropertyChangeListener>&) override
+    {
+        OSL_FAIL("not implemented");
+    };
+    virtual void SAL_CALL addVetoableChangeListener(
+        const OUString&, const 
css::uno::Reference<css::beans::XVetoableChangeListener>&) override
+    {
+        OSL_FAIL("not implemented");
+    };
+    virtual void SAL_CALL removeVetoableChangeListener(
+        const OUString&, const 
css::uno::Reference<css::beans::XVetoableChangeListener>&) 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) 
override;
+    virtual css::uno::Sequence<css::uno::Any>
+        SAL_CALL getPropertyValues(const css::uno::Sequence<OUString>& 
aPropertyNames) override;
+    virtual void SAL_CALL addPropertiesChangeListener(
+        const css::uno::Sequence<OUString>&,
+        const css::uno::Reference<css::beans::XPropertiesChangeListener>&) 
override{};
+    virtual void SAL_CALL removePropertiesChangeListener(
+        const css::uno::Reference<css::beans::XPropertiesChangeListener>&) 
override{};
+    virtual void SAL_CALL firePropertiesChangeEvent(
+        const css::uno::Sequence<OUString>&,
+        const css::uno::Reference<css::beans::XPropertiesChangeListener>&) 
override{};
+
+    //XPropertyState
+    virtual css::beans::PropertyState SAL_CALL
+    getPropertyState(const OUString& PropertyName) override;
+    virtual css::uno::Sequence<css::beans::PropertyState>
+        SAL_CALL getPropertyStates(const css::uno::Sequence<OUString>& 
aPropertyName) override;
+    virtual void SAL_CALL setPropertyToDefault(const OUString& PropertyName) 
override;
+    virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString& 
aPropertyName) override;
+
+    //XMultiPropertyStates
+    virtual void SAL_CALL setAllPropertiesToDefault() override;
+    virtual void SAL_CALL
+    setPropertiesToDefault(const css::uno::Sequence<OUString>& aPropertyNames) 
override;
+    virtual css::uno::Sequence<css::uno::Any>
+        SAL_CALL getPropertyDefaults(const css::uno::Sequence<OUString>& 
aPropertyNames) override;
+
+    //XServiceInfo
+    virtual OUString SAL_CALL getImplementationName() override;
+    virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) 
override;
+    virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() 
override;
+
+    //SfxListener
+    virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
+    //SvtListener
+    virtual void Notify(const SfxHint&) override;
+    const OUString& GetStyleName() const { return m_sStyleName; }
+    SfxStyleFamily GetFamily() const;
+
+    bool IsDescriptor() const { return m_bIsDescriptor; }
+    bool IsConditional() const { return m_bIsConditional; }
+    const OUString& GetParentStyleName() const { return m_sParentStyleName; }
+    void SetDoc(SwDoc* pDc, SfxStyleSheetBasePool* pPool)
+    {
+        m_bIsDescriptor = false;
+        m_pDoc = pDc;
+        m_pBasePool = pPool;
+        SfxListener::StartListening(*m_pBasePool);
+    }
+    SwDoc* GetDoc() const { return m_pDoc; }
+    void Invalidate();
+    void ApplyDescriptorProperties();
+    void SetStyleName(const OUString& rSet) { m_sStyleName = rSet; }
+    /// @throws beans::PropertyVetoException
+    /// @throws lang::IllegalArgumentException
+    /// @throws lang::WrappedTargetException
+    /// @throws uno::RuntimeException
+    void SetStyleProperty(const SfxItemPropertyMapEntry& rEntry, const 
SfxItemPropertySet& rPropSet,
+                          const css::uno::Any& rValue, SwStyleBase_Impl& 
rBase);
+    void PutItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet& 
rPropSet,
+                      const SfxItemPropertyMapEntry& rEntry, const 
css::uno::Any& rVal,
+                      SwStyleBase_Impl& rBaseImpl);
+};
+
+typedef cppu::ImplInheritanceHelper<SwXStyle, css::document::XEventsSupplier> 
SwXFrameStyle_Base;
+class SwXFrameStyle : public SwXFrameStyle_Base, public sw::ICoreFrameStyle
+{
+public:
+    SwXFrameStyle(SfxStyleSheetBasePool& rPool, SwDoc* pDoc, const OUString& 
rStyleName)
+        : SwXFrameStyle_Base(&rPool, SfxStyleFamily::Frame, pDoc, rStyleName)
+    {
+    }
+    explicit SwXFrameStyle(SwDoc* pDoc);
+
+    virtual css::uno::Reference<css::container::XNameReplace> SAL_CALL 
getEvents() override;
+
+    //ICoreStyle
+    virtual void SetItem(sal_uInt16 eAtr, const SfxPoolItem& rItem) override;
+    virtual const SfxPoolItem* GetItem(sal_uInt16 eAtr) override;
+    virtual css::document::XEventsSupplier& GetEventsSupplier() override { 
return *this; };
+};
+
+class SAL_DLLPUBLIC_RTTI SwXPageStyle : public SwXStyle
+{
+protected:
+    void SetPropertyValues_Impl(const css::uno::Sequence<OUString>& 
aPropertyNames,
+                                const css::uno::Sequence<css::uno::Any>& 
aValues);
+    css::uno::Sequence<css::uno::Any>
+    GetPropertyValues_Impl(const css::uno::Sequence<OUString>& aPropertyNames);
+
+public:
+    SwXPageStyle(SfxStyleSheetBasePool& rPool, SwDocShell* pDocSh, const 
OUString& rStyleName);
+    explicit SwXPageStyle(SwDocShell* pDocSh);
+
+    virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName,
+                                           const css::uno::Any& aValue) 
override;
+    virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& 
PropertyName) override;
+
+    virtual void SAL_CALL
+    setPropertyValues(const css::uno::Sequence<OUString>& aPropertyNames,
+                      const css::uno::Sequence<css::uno::Any>& aValues) 
override;
+    virtual css::uno::Sequence<css::uno::Any>
+        SAL_CALL getPropertyValues(const css::uno::Sequence<OUString>& 
aPropertyNames) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 80fda01afe80..3b5249efa8f8 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -117,6 +117,7 @@
 #include <ccoll.hxx>
 #include <hints.hxx>
 #include <uiitems.hxx>
+#include <unoxstyle.hxx>
 
 #include <cassert>
 #include <memory>
@@ -172,12 +173,14 @@ constexpr ParagraphStyleCategoryEntry 
sParagraphStyleCategoryEntries[]
         { style::ParagraphStyleCategory::HTML,    SfxStyleSearchBits::SwHtml,  
  COLL_HTML_BITS     }
 };
 
+} // namespace anonymous
+
 class StyleFamilyEntry
 {
 public:
     template <SfxStyleFamily f> static StyleFamilyEntry Create(sal_uInt16 
nPropMapType, SwGetPoolIdFromName aPoolId, OUString sName, TranslateId pResId)
     {
-        return StyleFamilyEntry(f, nPropMapType, aPoolId, sName, pResId, 
GetCountOrName<f>, CreateStyle<f>, TranslateIndex<f>);
+        return StyleFamilyEntry(f, nPropMapType, aPoolId, sName, pResId, 
GetCountOrName<f>, TranslateIndex<f>);
     }
 
     SfxStyleFamily family() const { return m_eFamily; }
@@ -188,12 +191,10 @@ public:
     const TranslateId& resId() const { return m_pResId; }
 
     sal_Int32 getCountOrName(const SwDoc& rDoc, OUString* pString, sal_Int32 
nIndex) const { return m_fGetCountOrName(rDoc, pString, nIndex); }
-    css::uno::Reference<css::style::XStyle> createStyle(SfxStyleSheetBasePool* 
pBasePool, SwDocShell* pDocShell, const OUString& sStyleName) const { return 
m_fCreateStyle(pBasePool, pDocShell, sStyleName); }
     sal_uInt16 translateIndex(const sal_uInt16 nIndex) const { return 
m_fTranslateIndex(nIndex); }
 
 private:
     using GetCountOrName_t = sal_Int32 (*)(const SwDoc&, OUString*, sal_Int32);
-    using CreateStyle_t = 
uno::Reference<css::style::XStyle>(*)(SfxStyleSheetBasePool*, SwDocShell*, 
const OUString&);
     using TranslateIndex_t = sal_uInt16(*)(const sal_uInt16);
     SfxStyleFamily m_eFamily;
     sal_uInt16 m_nPropMapType;
@@ -202,9 +203,8 @@ private:
     OUString m_sName;
     TranslateId m_pResId;
     GetCountOrName_t m_fGetCountOrName;
-    CreateStyle_t m_fCreateStyle;
     TranslateIndex_t m_fTranslateIndex;
-    StyleFamilyEntry(SfxStyleFamily eFamily, sal_uInt16 nPropMapType, 
SwGetPoolIdFromName aPoolId, OUString sName, TranslateId pResId, 
GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle, TranslateIndex_t 
fTranslateIndex)
+    StyleFamilyEntry(SfxStyleFamily eFamily, sal_uInt16 nPropMapType, 
SwGetPoolIdFromName aPoolId, OUString sName, TranslateId pResId, 
GetCountOrName_t fGetCountOrName, TranslateIndex_t fTranslateIndex)
             : m_eFamily(eFamily)
             , m_nPropMapType(nPropMapType)
             , 
m_xPSInfo(aSwMapProvider.GetPropertySet(nPropMapType)->getPropertySetInfo())
@@ -212,11 +212,9 @@ private:
             , m_sName(std::move(sName))
             , m_pResId(pResId)
             , m_fGetCountOrName(fGetCountOrName)
-            , m_fCreateStyle(fCreateStyle)
             , m_fTranslateIndex(fTranslateIndex)
         { }
     template<SfxStyleFamily> static inline sal_Int32 GetCountOrName(const 
SwDoc& rDoc, OUString* pString, sal_Int32 nIndex);
-    template<SfxStyleFamily> static inline 
css::uno::Reference<css::style::XStyle> CreateStyle(SfxStyleSheetBasePool* 
pBasePool, SwDocShell* pDocShell, const OUString& sStyleName);
     template<SfxStyleFamily> static inline sal_uInt16 TranslateIndex(const 
sal_uInt16 nIndex) { return nIndex; }
 };
 
@@ -423,7 +421,7 @@ sal_uInt16 
StyleFamilyEntry::TranslateIndex<SfxStyleFamily::Pseudo>(const sal_uI
     throw lang::IndexOutOfBoundsException();
 }
 
-const std::vector<StyleFamilyEntry>& lcl_GetStyleFamilyEntries()
+static const std::vector<StyleFamilyEntry>& lcl_GetStyleFamilyEntries()
 {
     static const std::vector<StyleFamilyEntry> our_pStyleFamilyEntries{
         StyleFamilyEntry::Create<SfxStyleFamily::Char>  
(PROPERTY_MAP_CHAR_STYLE,  SwGetPoolIdFromName::ChrFmt,    "CharacterStyles", 
STR_STYLE_FAMILY_CHARACTER),
@@ -502,171 +500,17 @@ public:
     };
 };
 
-class SwStyleProperties_Impl;
-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 SvtListener
-{
-    SwDoc* m_pDoc;
-    OUString m_sStyleName;
-    const StyleFamilyEntry& m_rEntry;
-    bool m_bIsDescriptor;
-    bool m_bIsConditional;
-    OUString m_sParentStyleName;
-
-protected:
-    SfxStyleSheetBasePool* m_pBasePool;
-    std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl;
-    css::uno::Reference<css::container::XNameAccess> m_xStyleFamily;
-    css::uno::Reference<css::beans::XPropertySet> m_xStyleData;
-
-    template<sal_uInt16>
-    void SetPropertyValue(const SfxItemPropertyMapEntry&, const 
SfxItemPropertySet&, const uno::Any&, SwStyleBase_Impl&);
-    void SetPropertyValues_Impl( const css::uno::Sequence< OUString >& 
aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues );
-    SfxStyleSheetBase* GetStyleSheetBase();
-    void PrepareStyleBase(SwStyleBase_Impl& rBase);
-    template<sal_uInt16>
-    uno::Any GetStyleProperty(const SfxItemPropertyMapEntry& rEntry, const 
SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase);
-    uno::Any GetStyleProperty_Impl(const SfxItemPropertyMapEntry& rEntry, 
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase);
-    uno::Any GetPropertyValue_Impl(const SfxItemPropertySet* pPropSet, 
SwStyleBase_Impl& rBase, const OUString& rPropertyName);
-
-public:
-    SwXStyle(SwDoc* pDoc, SfxStyleFamily eFam, bool bConditional = false);
-    SwXStyle(SfxStyleSheetBasePool* pPool, SfxStyleFamily eFamily, SwDoc* 
pDoc, const OUString& rStyleName);
-    virtual ~SwXStyle() override;
-
-
-    static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
 
-    //XUnoTunnel
-    virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
sal_Int8 >& aIdentifier ) override;
+SfxStyleFamily SwXStyle::GetFamily() const
+{return m_rEntry.family();}
 
-    //XNamed
-    virtual OUString SAL_CALL getName() override;
-    virtual void SAL_CALL setName(const OUString& Name_) override;
+OUString SwXStyle::getImplementationName()
+{ return {"SwXStyle"}; };
 
-    //XStyle
-    virtual sal_Bool SAL_CALL isUserDefined() override;
-    virtual sal_Bool SAL_CALL isInUse() override;
-    virtual OUString SAL_CALL getParentStyle() override;
-    virtual void SAL_CALL setParentStyle(const OUString& aParentStyle) 
override;
-
-    //XPropertySet
-    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL 
getPropertySetInfo(  ) override;
-    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, 
const css::uno::Any& aValue ) override;
-    virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& 
PropertyName ) override;
-    virtual void SAL_CALL addPropertyChangeListener( const OUString&, const 
css::uno::Reference< css::beans::XPropertyChangeListener >& ) override
-            { OSL_FAIL("not implemented"); };
-    virtual void SAL_CALL removePropertyChangeListener( const OUString&, const 
css::uno::Reference< css::beans::XPropertyChangeListener >& ) override
-            { OSL_FAIL("not implemented"); };
-    virtual void SAL_CALL addVetoableChangeListener( const OUString&, const 
css::uno::Reference< css::beans::XVetoableChangeListener >& ) override
-            { OSL_FAIL("not implemented"); };
-    virtual void SAL_CALL removeVetoableChangeListener( const OUString&, const 
css::uno::Reference< css::beans::XVetoableChangeListener >& ) 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 
) override;
-    virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( 
const css::uno::Sequence< OUString >& aPropertyNames ) override;
-    virtual void SAL_CALL addPropertiesChangeListener( const 
css::uno::Sequence< OUString >&, const css::uno::Reference< 
css::beans::XPropertiesChangeListener >& ) override
-            {};
-    virtual void SAL_CALL removePropertiesChangeListener( const 
css::uno::Reference< css::beans::XPropertiesChangeListener >& ) override
-            {};
-    virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< 
OUString >&, const css::uno::Reference< css::beans::XPropertiesChangeListener 
>& ) override
-            {};
-
-    //XPropertyState
-    virtual css::beans::PropertyState SAL_CALL getPropertyState( const 
OUString& PropertyName ) override;
-    virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL 
getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) 
override;
-    virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) 
override;
-    virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& 
aPropertyName ) override;
-
-    //XMultiPropertyStates
-    virtual void SAL_CALL setAllPropertiesToDefault(  ) override;
-    virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< 
OUString >& aPropertyNames ) override;
-    virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( 
const css::uno::Sequence< OUString >& aPropertyNames ) override;
+sal_Bool SwXStyle::supportsService(const OUString& rServiceName)
+{ return cppu::supportsService(this, rServiceName); };
 
-    //XServiceInfo
-    virtual OUString SAL_CALL getImplementationName() override
-            { return {"SwXStyle"}; };
-    virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) 
override
-            { return cppu::supportsService(this, rServiceName); };
-    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
-    //SfxListener
-    virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 
override;
-    //SvtListener
-    virtual void Notify(const SfxHint&) override;
-    const OUString&     GetStyleName() const { return m_sStyleName;}
-    SfxStyleFamily      GetFamily() const {return m_rEntry.family();}
-
-    bool                IsDescriptor() const {return m_bIsDescriptor;}
-    bool                IsConditional() const { return m_bIsConditional;}
-    const OUString&     GetParentStyleName() const { return 
m_sParentStyleName;}
-    void                SetDoc(SwDoc* pDc, SfxStyleSheetBasePool*   pPool)
-                            {
-                                m_bIsDescriptor = false; m_pDoc = pDc;
-                                m_pBasePool = pPool;
-                                SfxListener::StartListening(*m_pBasePool);
-                            }
-    SwDoc*                GetDoc() const { return m_pDoc; }
-    void Invalidate();
-    void ApplyDescriptorProperties();
-    void SetStyleName(const OUString& rSet){ m_sStyleName = rSet;}
-    /// @throws beans::PropertyVetoException
-    /// @throws lang::IllegalArgumentException
-    /// @throws lang::WrappedTargetException
-    /// @throws uno::RuntimeException
-    void SetStyleProperty(const SfxItemPropertyMapEntry& rEntry, const 
SfxItemPropertySet& rPropSet, const uno::Any& rValue, SwStyleBase_Impl& rBase);
-    void PutItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet& 
rPropSet, const SfxItemPropertyMapEntry& rEntry, const uno::Any& rVal, 
SwStyleBase_Impl& rBaseImpl);
-};
-
-typedef cppu::ImplInheritanceHelper< SwXStyle, css::document::XEventsSupplier> 
SwXFrameStyle_Base;
-class SwXFrameStyle
-    : public SwXFrameStyle_Base
-    , public sw::ICoreFrameStyle
-{
-public:
-    SwXFrameStyle(SfxStyleSheetBasePool& rPool,
-                                SwDoc*  pDoc,
-                                const OUString& rStyleName) :
-        SwXFrameStyle_Base(&rPool, SfxStyleFamily::Frame, pDoc, rStyleName){}
-    explicit SwXFrameStyle(SwDoc *pDoc);
-
-    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL 
getEvents(  ) override;
-
-    //ICoreStyle
-    virtual void SetItem(sal_uInt16 eAtr, const SfxPoolItem& rItem) override;
-    virtual const SfxPoolItem* GetItem(sal_uInt16 eAtr) override;
-    virtual css::document::XEventsSupplier& GetEventsSupplier() override
-            { return *this; };
-};
-
-class SwXPageStyle
-    : public SwXStyle
-{
-protected:
-    void SetPropertyValues_Impl( const css::uno::Sequence< OUString >& 
aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues );
-    css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl( const 
css::uno::Sequence< OUString >& aPropertyNames );
-
-public:
-    SwXPageStyle(SfxStyleSheetBasePool& rPool, SwDocShell* pDocSh, const 
OUString& rStyleName);
-    explicit SwXPageStyle(SwDocShell* pDocSh);
-
-    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, 
const css::uno::Any& aValue ) override;
-    virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& 
PropertyName ) override;
-
-    virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< 
OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues 
) override;
-    virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( 
const css::uno::Sequence< OUString >& aPropertyNames ) override;
-};
 
 class SwStyleProperties_Impl
 {
@@ -717,36 +561,33 @@ public:
     }
 };
 
-template<SfxStyleFamily eFamily>
-css::uno::Reference<css::style::XStyle> 
StyleFamilyEntry::CreateStyle(SfxStyleSheetBasePool* pBasePool, SwDocShell* 
pDocShell, const OUString& sStyleName)
+static rtl::Reference<SwXStyle> 
CreateStyleCharOrParaOrPseudo(SfxStyleSheetBasePool* pBasePool, SwDocShell* 
pDocShell, const OUString& sStyleName, SfxStyleFamily eFamily)
 {
     return pBasePool ? new SwXStyle(pBasePool, eFamily, pDocShell->GetDoc(), 
sStyleName) : new SwXStyle(pDocShell->GetDoc(), eFamily, false);
 }
 
-template<>
-css::uno::Reference<css::style::XStyle> 
StyleFamilyEntry::CreateStyle<SfxStyleFamily::Frame>(SfxStyleSheetBasePool* 
pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
+static rtl::Reference<SwXFrameStyle> CreateStyleFrame(SfxStyleSheetBasePool* 
pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
 {
     return pBasePool ? new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), 
sStyleName) : new SwXFrameStyle(pDocShell->GetDoc());
 }
 
-template<>
-css::uno::Reference<css::style::XStyle> 
StyleFamilyEntry::CreateStyle<SfxStyleFamily::Page>(SfxStyleSheetBasePool* 
pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
+static rtl::Reference<SwXPageStyle> CreateStylePage(SfxStyleSheetBasePool* 
pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
 {
     return pBasePool ? new SwXPageStyle(*pBasePool, pDocShell, sStyleName) : 
new SwXPageStyle(pDocShell);
 }
 
-template<>
-css::uno::Reference<css::style::XStyle> 
StyleFamilyEntry::CreateStyle<SfxStyleFamily::Table>(SfxStyleSheetBasePool* 
/*pBasePool*/, SwDocShell* pDocShell, const OUString& sStyleName)
+static rtl::Reference<SwXTextTableStyle> CreateStyleTable(SwDocShell* 
pDocShell, const OUString& sStyleName)
 {
     return SwXTextTableStyle::CreateXTextTableStyle(pDocShell, sStyleName);
 }
 
-template<>
-css::uno::Reference<css::style::XStyle> 
StyleFamilyEntry::CreateStyle<SfxStyleFamily::Cell>(SfxStyleSheetBasePool* 
/*pBasePool*/, SwDocShell* pDocShell, const OUString& sStyleName)
+static rtl::Reference<SwXTextCellStyle> CreateStyleCell(SwDocShell* pDocShell, 
const OUString& sStyleName)
 {
     return SwXTextCellStyle::CreateXTextCellStyle(pDocShell, sStyleName);
 }
 
+namespace {
+
 class XStyleFamily : public cppu::WeakImplHelper
 <
     container::XNameContainer,
@@ -996,12 +837,51 @@ static bool lcl_GetHeaderFooterItem(
     return o_rpItem;
 }
 
-uno::Reference<css::style::XStyle> 
SwXStyleFamilies::CreateStyle(SfxStyleFamily eFamily, SwDoc& rDoc)
+css::uno::Reference<css::style::XStyle> 
SwXStyleFamilies::CreateStyle(SfxStyleFamily eFamily, SwDoc& rDoc)
 {
-    auto& entries(lcl_GetStyleFamilyEntries());
-    const auto pEntry = std::find_if(entries.begin(), entries.end(),
-            [eFamily] (const StyleFamilyEntry& e) { return e.family() == 
eFamily; });
-    return pEntry == entries.end() ? nullptr : pEntry->createStyle(nullptr, 
rDoc.GetDocShell(), "");
+    switch (eFamily)
+    {
+        case SfxStyleFamily::Char:
+        case SfxStyleFamily::Para:
+        case SfxStyleFamily::Pseudo:
+            return CreateStyleCharOrParaOrPseudo(eFamily, rDoc);
+        case SfxStyleFamily::Page:
+            return CreateStylePage(rDoc);
+        case SfxStyleFamily::Frame:
+            return CreateStyleFrame(rDoc);
+        case SfxStyleFamily::Table:
+            return CreateStyleTable(rDoc);
+        case SfxStyleFamily::Cell:
+            return CreateStyleCell(rDoc);
+        default:
+            assert(false);
+            return nullptr;
+    }
+}
+
+rtl::Reference<SwXStyle> 
SwXStyleFamilies::CreateStyleCharOrParaOrPseudo(SfxStyleFamily eFamily, SwDoc& 
rDoc)
+{
+    return ::CreateStyleCharOrParaOrPseudo(nullptr, rDoc.GetDocShell(), "", 
eFamily);
+}
+
+rtl::Reference<SwXPageStyle> SwXStyleFamilies::CreateStylePage(SwDoc& rDoc)
+{
+    return ::CreateStylePage(nullptr, rDoc.GetDocShell(), "");
+}
+
+rtl::Reference<SwXFrameStyle> SwXStyleFamilies::CreateStyleFrame(SwDoc& rDoc)
+{
+    return ::CreateStyleFrame(nullptr, rDoc.GetDocShell(), "");
+}
+
+rtl::Reference<SwXTextTableStyle> SwXStyleFamilies::CreateStyleTable(SwDoc& 
rDoc)
+{
+    return ::CreateStyleTable(rDoc.GetDocShell(), "");
+}
+
+rtl::Reference<SwXTextCellStyle> SwXStyleFamilies::CreateStyleCell(SwDoc& rDoc)
+{
+    return ::CreateStyleCell(rDoc.GetDocShell(), "");
 }
 
 // FIXME: Ugly special casing that should die.
@@ -1039,7 +919,28 @@ uno::Any XStyleFamily::getByName(const OUString& rName)
         throw container::NoSuchElementException(rName);
     uno::Reference<style::XStyle> xStyle = FindStyle(sStyleName);
     if(!xStyle.is())
-        xStyle = m_rEntry.createStyle(m_pBasePool, m_pDocShell, 
m_rEntry.family() == SfxStyleFamily::Frame ? pBase->GetName() : sStyleName);
+        switch (m_rEntry.family())
+        {
+            case SfxStyleFamily::Char:
+            case SfxStyleFamily::Para:
+            case SfxStyleFamily::Pseudo:
+                xStyle = ::CreateStyleCharOrParaOrPseudo(m_pBasePool, 
m_pDocShell, sStyleName, m_rEntry.family());
+                break;
+            case SfxStyleFamily::Page:
+                xStyle = ::CreateStylePage(m_pBasePool, m_pDocShell, 
sStyleName);
+                break;
+            case SfxStyleFamily::Frame:
+                xStyle = ::CreateStyleFrame(m_pBasePool, m_pDocShell, 
pBase->GetName());
+                break;
+            case SfxStyleFamily::Table:
+                xStyle = ::CreateStyleTable(m_pDocShell, sStyleName);
+                break;
+            case SfxStyleFamily::Cell:
+                xStyle = ::CreateStyleCell(m_pDocShell, sStyleName);
+                break;
+            default:
+                assert(false);
+        }
     return uno::Any(xStyle);
 }
 
@@ -1515,22 +1416,21 @@ void SwXStyle::ApplyDescriptorProperties()
     m_pPropertiesImpl->Apply(*this);
 }
 
-namespace {
-    const TranslateId STR_POOLPAGE_ARY[] =
-    {
-        // Page styles
-        STR_POOLPAGE_STANDARD,
-        STR_POOLPAGE_FIRST,
-        STR_POOLPAGE_LEFT,
-        STR_POOLPAGE_RIGHT,
-        STR_POOLPAGE_ENVELOPE,
-        STR_POOLPAGE_REGISTER,
-        STR_POOLPAGE_HTML,
-        STR_POOLPAGE_FOOTNOTE,
-        STR_POOLPAGE_ENDNOTE,
-        STR_POOLPAGE_LANDSCAPE
-    };
-}
+const TranslateId STR_POOLPAGE_ARY[] =
+{
+    // Page styles
+    STR_POOLPAGE_STANDARD,
+    STR_POOLPAGE_FIRST,
+    STR_POOLPAGE_LEFT,
+    STR_POOLPAGE_RIGHT,
+    STR_POOLPAGE_ENVELOPE,
+    STR_POOLPAGE_REGISTER,
+    STR_POOLPAGE_HTML,
+    STR_POOLPAGE_FOOTNOTE,
+    STR_POOLPAGE_ENDNOTE,
+    STR_POOLPAGE_LANDSCAPE
+};
+
 
 const SwPageDesc* SwStyleBase_Impl::GetOldPageDesc()
 {
@@ -1556,7 +1456,6 @@ const SwPageDesc* SwStyleBase_Impl::GetOldPageDesc()
 }
 
 
-
 static sal_uInt8 lcl_TranslateMetric(const SfxItemPropertyMapEntry& rEntry, 
SwDoc* pDoc, uno::Any& o_aValue)
 {
     // check for needed metric translation
@@ -1577,6 +1476,7 @@ static sal_uInt8 lcl_TranslateMetric(const 
SfxItemPropertyMapEntry& rEntry, SwDo
         SvxUnoConvertFromMM(eMapUnit, o_aValue);
     return rEntry.nMemberId;
 }
+
 template<>
 void SwXStyle::SetPropertyValue<HINT_BEGIN>(const SfxItemPropertyMapEntry& 
rEntry, const SfxItemPropertySet& /*rPropSet*/, const uno::Any& rValue, 
SwStyleBase_Impl& o_rStyleBase)
 {
@@ -4331,7 +4231,7 @@ SwXTextTableStyle::SwXTextTableStyle(SwDocShell* 
pDocShell, const OUString& rTab
     UpdateCellStylesMapping();
 }
 
-uno::Reference<style::XStyle> 
SwXTextTableStyle::CreateXTextTableStyle(SwDocShell* pDocShell, const OUString& 
rTableAutoFormatName)
+rtl::Reference<SwXTextTableStyle> 
SwXTextTableStyle::CreateXTextTableStyle(SwDocShell* pDocShell, const OUString& 
rTableAutoFormatName)
 {
     SolarMutexGuard aGuard;
     rtl::Reference<SwXTextTableStyle> xTextTableStyle;
@@ -4743,7 +4643,7 @@ SwBoxAutoFormat* 
SwXTextCellStyle::GetBoxAutoFormat(SwDocShell* pDocShell, std::
     return pBoxAutoFormat;
 }
 
-css::uno::Reference<css::style::XStyle> 
SwXTextCellStyle::CreateXTextCellStyle(SwDocShell* pDocShell, const OUString& 
sName)
+rtl::Reference<SwXTextCellStyle> 
SwXTextCellStyle::CreateXTextCellStyle(SwDocShell* pDocShell, const OUString& 
sName)
 {
     rtl::Reference<SwXTextCellStyle> xTextCellStyle;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 2fa09ab06e70..1107072b7c2a 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -179,6 +179,7 @@
 #include <unosection.hxx>
 #include <unofield.hxx>
 #include <unoframe.hxx>
+#include <unoxstyle.hxx>
 #include <SwXTextDefaults.hxx>
 
 using namespace ::com::sun::star;
@@ -1720,6 +1721,20 @@ rtl::Reference< SwXTextGraphicObject > 
SwXTextDocument::createTextGraphicObject(
     return SwXTextGraphicObject::CreateXTextGraphicObject(GetDocOrThrow(), 
nullptr);
 }
 
+rtl::Reference< SwXStyle > SwXTextDocument::createNumberingStyle()
+{
+    SolarMutexGuard aGuard;
+    ThrowIfInvalid();
+    return 
SwXStyleFamilies::CreateStyleCharOrParaOrPseudo(SfxStyleFamily::Pseudo, 
GetDocOrThrow());
+}
+
+rtl::Reference< SwXPageStyle > SwXTextDocument::createPageStyle()
+{
+    SolarMutexGuard aGuard;
+    ThrowIfInvalid();
+    return SwXStyleFamilies::CreateStylePage(GetDocOrThrow());
+}
+
 Reference< XInterface >  SwXTextDocument::createInstance(const OUString& 
rServiceName)
 {
     return create(rServiceName, nullptr);
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index ff6bcf342b35..2fe1cde929a4 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -139,6 +139,7 @@
 #include <unofield.hxx>
 #include <unolinebreak.hxx>
 #include <unoframe.hxx>
+#include <unoxstyle.hxx>
 
 #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200
@@ -3819,7 +3820,7 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType 
ePagePartType, PageTyp
     if (!m_bIsNewDoc)
         return; // TODO sw cannot Undo insert header/footer without crashing
 
-    uno::Reference<beans::XPropertySet> xPageStyle = 
pSectionContext->GetPageStyle(*this);
+    rtl::Reference<SwXPageStyle> xPageStyle = 
pSectionContext->GetPageStyle(*this);
     if (!xPageStyle.is())
         return;
 
diff --git a/sw/source/writerfilter/dmapper/NumberingManager.cxx 
b/sw/source/writerfilter/dmapper/NumberingManager.cxx
index ec8e1be07c7f..3b72a2008709 100644
--- a/sw/source/writerfilter/dmapper/NumberingManager.cxx
+++ b/sw/source/writerfilter/dmapper/NumberingManager.cxx
@@ -44,6 +44,8 @@
 #include <comphelper/sequence.hxx>
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/string.hxx>
+#include <unotxdoc.hxx>
+#include <unoxstyle.hxx>
 #include <regex>
 #include <utility>
 
@@ -471,14 +473,15 @@ uno::Sequence<uno::Sequence<beans::PropertyValue>> 
ListDef::GetMergedPropertyVal
 }
 
 static uno::Reference< container::XNameContainer > lcl_getUnoNumberingStyles(
-       uno::Reference<lang::XMultiServiceFactory> const& xFactory)
+       rtl::Reference<SwXTextDocument> const& xTextDoc)
 {
     uno::Reference< container::XNameContainer > xStyles;
+    if (!xTextDoc)
+        return xStyles;
 
     try
     {
-        uno::Reference< style::XStyleFamiliesSupplier > xFamilies( xFactory, 
uno::UNO_QUERY_THROW );
-        uno::Any oFamily = xFamilies->getStyleFamilies( 
)->getByName("NumberingStyles");
+        uno::Any oFamily = xTextDoc->getStyleFamilies( 
)->getByName("NumberingStyles");
 
         oFamily >>= xStyles;
     }
@@ -523,13 +526,13 @@ sal_uInt16 ListDef::GetChapterNumberingWeight() const
 }
 
 void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
-        uno::Reference<lang::XMultiServiceFactory> const& xFactory, sal_Int16 
nOutline)
+        rtl::Reference<SwXTextDocument> const& xTextDoc, sal_Int16 nOutline)
 {
     // Get the UNO Numbering styles
-    uno::Reference< container::XNameContainer > xStyles = 
lcl_getUnoNumberingStyles( xFactory );
+    uno::Reference< container::XNameContainer > xStyles = 
lcl_getUnoNumberingStyles( xTextDoc );
 
     // Do the whole thing
-    if( !(!m_xNumRules.is() && xFactory.is() && xStyles.is( )) )
+    if( !(!m_xNumRules.is() && xTextDoc.is() && xStyles.is( )) )
         return;
 
     try
@@ -540,7 +543,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
         else
             xStyles->insertByName(
                 GetStyleName(GetId(), xStyles),
-                
css::uno::Any(xFactory->createInstance("com.sun.star.style.NumberingStyle")));
+                
css::uno::Any(uno::Reference<css::style::XStyle>(xTextDoc->createNumberingStyle())));
 
         uno::Any oStyle = xStyles->getByName(GetStyleName());
         uno::Reference< beans::XPropertySet > xStyle( oStyle, 
uno::UNO_QUERY_THROW );
@@ -601,10 +604,8 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
             // Handle the outline level here
             if (GetId() == nOutline && pAbsLevel && pAbsLevel->GetParaStyle())
             {
-                uno::Reference< text::XChapterNumberingSupplier > xOutlines (
-                    xFactory, uno::UNO_QUERY_THROW );
                 uno::Reference< container::XIndexReplace > xOutlineRules =
-                    xOutlines->getChapterNumberingRules( );
+                    xTextDoc->getChapterNumberingRules( );
 
                 StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle( );
                 pParaStyle->m_bAssignedAsChapterNumbering = true;
@@ -641,11 +642,11 @@ void ListDef::CreateNumberingRules( DomainMapper& 
rDMapper,
 
 
 ListsManager::ListsManager(DomainMapper& rDMapper,
-    uno::Reference<lang::XMultiServiceFactory> xFactory)
+    rtl::Reference<SwXTextDocument> xTextDoc)
     : LoggedProperties("ListsManager")
     , LoggedTable("ListsManager")
     , m_rDMapper(rDMapper)
-    , m_xFactory(std::move(xFactory))
+    , m_xTextDoc(std::move(xTextDoc))
 {
 }
 
@@ -1202,7 +1203,7 @@ void ListsManager::CreateNumberingRules( )
     // Loop over the definitions
     for ( const auto& rList : m_aLists )
     {
-        rList->CreateNumberingRules(m_rDMapper, m_xFactory, 
nChosenAsChapterNumberingId);
+        rList->CreateNumberingRules(m_rDMapper, m_xTextDoc, 
nChosenAsChapterNumberingId);
     }
     
m_rDMapper.GetStyleSheetTable()->ReApplyInheritedOutlineLevelFromChapterNumbering();
     m_rDMapper.GetStyleSheetTable()->ApplyNumberingStyleNameToParaStyles();
diff --git a/sw/source/writerfilter/dmapper/NumberingManager.hxx 
b/sw/source/writerfilter/dmapper/NumberingManager.hxx
index 64156ba60ceb..36571bc87ec4 100644
--- a/sw/source/writerfilter/dmapper/NumberingManager.hxx
+++ b/sw/source/writerfilter/dmapper/NumberingManager.hxx
@@ -194,7 +194,7 @@ public:
     css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > 
GetMergedPropertyValues();
 
     sal_uInt16 GetChapterNumberingWeight() const;
-    void CreateNumberingRules(DomainMapper& rDMapper, 
css::uno::Reference<css::lang::XMultiServiceFactory> const& xFactory, sal_Int16 
nOutline);
+    void CreateNumberingRules(DomainMapper& rDMapper, 
rtl::Reference<SwXTextDocument> const& xTextDoc, sal_Int16 nOutline);
 
     const css::uno::Reference<css::container::XIndexReplace>& 
GetNumberingRules() const { return m_xNumRules; }
 
@@ -209,7 +209,7 @@ class ListsManager :
 private:
 
     DomainMapper&                                       m_rDMapper;
-    css::uno::Reference<css::lang::XMultiServiceFactory> m_xFactory;
+    rtl::Reference<SwXTextDocument>                     m_xTextDoc;
 
     // The numbering entries
     std::vector< NumPicBullet::Pointer >                m_aNumPicBullets;
@@ -232,7 +232,7 @@ private:
 
 public:
 
-    ListsManager(DomainMapper& rDMapper, 
css::uno::Reference<css::lang::XMultiServiceFactory> xFactory);
+    ListsManager(DomainMapper& rDMapper, rtl::Reference<SwXTextDocument> 
xTextDoc);
     virtual ~ListsManager() override;
 
     typedef tools::SvRef< ListsManager >  Pointer;
diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx 
b/sw/source/writerfilter/dmapper/PropertyMap.cxx
index fd67ac04cda0..913dde2bc84e 100644
--- a/sw/source/writerfilter/dmapper/PropertyMap.cxx
+++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx
@@ -67,6 +67,7 @@
 #include <o3tl/unit_conversion.hxx>
 #include <unosection.hxx>
 #include <unotxdoc.hxx>
+#include <unoxstyle.hxx>
 #include <utility>
 
 #include <frozen/bits/defines.h>
@@ -478,10 +479,10 @@ SectionPropertyMap::SectionPropertyMap( bool 
bIsFirstSection )
     }
 }
 
-uno::Reference<beans::XPropertySet> 
SectionPropertyMap::GetPageStyle(DomainMapper_Impl& rDM_Impl)
+rtl::Reference<SwXPageStyle> 
SectionPropertyMap::GetPageStyle(DomainMapper_Impl& rDM_Impl)
 {
     const uno::Reference< container::XNameContainer >& xPageStyles = 
rDM_Impl.GetPageStyles();
-    uno::Reference<beans::XPropertySet> xReturnPageStyle;
+    rtl::Reference<SwXPageStyle> xReturnPageStyle;
     try
     {
         if (m_sPageStyleName.isEmpty() && xPageStyles.is())
@@ -490,12 +491,15 @@ uno::Reference<beans::XPropertySet> 
SectionPropertyMap::GetPageStyle(DomainMappe
 
             m_sPageStyleName = rDM_Impl.GetUnusedPageStyleName();
 
-            
m_aPageStyle.set(rDM_Impl.GetTextDocument()->createInstance("com.sun.star.style.PageStyle"),
 uno::UNO_QUERY );
-            xPageStyles->insertByName(m_sPageStyleName, 
uno::Any(m_aPageStyle));
+            m_aPageStyle = rDM_Impl.GetTextDocument()->createPageStyle();
+            xPageStyles->insertByName(m_sPageStyleName, 
uno::Any(uno::Reference<style::XStyle>(m_aPageStyle)));
         }
         else if (!m_aPageStyle.is() && xPageStyles.is())
         {
-            xPageStyles->getByName(m_sPageStyleName) >>= m_aPageStyle;
+            uno::Reference<style::XStyle> xTmpStyle;
+            xPageStyles->getByName(m_sPageStyleName) >>= xTmpStyle;
+            m_aPageStyle = dynamic_cast<SwXPageStyle*>(xTmpStyle.get());
+            assert(bool(xTmpStyle) == bool(m_aPageStyle) && "expect null or a 
SwXPageStyle here");
         }
         xReturnPageStyle = m_aPageStyle;
     }
@@ -1448,9 +1452,7 @@ void AfterConvertToTextFrame(DomainMapper_Impl& rDM_Impl, 
std::deque<css::uno::A
 void SectionPropertyMap::CreateEvenOddPageStyleCopy(DomainMapper_Impl& 
rDM_Impl, PageBreakType eBreakType)
 {
     OUString evenOddStyleName = rDM_Impl.GetUnusedPageStyleName();
-    uno::Reference<beans::XPropertySet> evenOddStyle(
-        
rDM_Impl.GetTextDocument()->createInstance("com.sun.star.style.PageStyle"),
-        uno::UNO_QUERY);
+    rtl::Reference<SwXPageStyle> evenOddStyle = 
rDM_Impl.GetTextDocument()->createPageStyle();
     // Unfortunately using setParent() does not work for page styles, so make 
a deep copy of the page style.
     uno::Reference<beans::XPropertySet> pageProperties(m_aPageStyle);
     uno::Reference<beans::XPropertySetInfo> 
pagePropertiesInfo(pageProperties->getPropertySetInfo());
@@ -1478,7 +1480,7 @@ void 
SectionPropertyMap::CreateEvenOddPageStyleCopy(DomainMapper_Impl& rDM_Impl,
     }
     evenOddStyle->setPropertyValue("FollowStyle", uno::Any(m_sPageStyleName));
 
-    rDM_Impl.GetPageStyles()->insertByName(evenOddStyleName, 
uno::Any(evenOddStyle));
+    rDM_Impl.GetPageStyles()->insertByName(evenOddStyleName, 
uno::Any(uno::Reference<style::XStyle>(evenOddStyle)));
 
     if (rDM_Impl.IsNewDoc())
     {
diff --git a/sw/source/writerfilter/dmapper/PropertyMap.hxx 
b/sw/source/writerfilter/dmapper/PropertyMap.hxx
index 6b624e089dad..a232604ccbff 100644
--- a/sw/source/writerfilter/dmapper/PropertyMap.hxx
+++ b/sw/source/writerfilter/dmapper/PropertyMap.hxx
@@ -39,6 +39,7 @@
 #include <deque>
 
 class SwXTextSection;
+class SwXPageStyle;
 namespace com::sun::star {
     namespace beans {
         struct PropertyValue;
@@ -255,7 +256,7 @@ private:
     css::uno::Reference< css::text::XTextRange >    m_xStartingRange;
 
     OUString m_sPageStyleName;
-    css::uno::Reference<css::beans::XPropertySet> m_aPageStyle;
+    rtl::Reference<SwXPageStyle>                    m_aPageStyle;
 
     std::optional< css::table::BorderLine2 >      m_oBorderLines[4];
     sal_Int32                                       m_nBorderDistances[4];
@@ -356,7 +357,7 @@ public:
 
     const css::uno::Reference< css::text::XTextRange >& GetStartingRange() 
const { return m_xStartingRange; }
 
-    css::uno::Reference<css::beans::XPropertySet> 
GetPageStyle(DomainMapper_Impl& rDM_Impl);
+    rtl::Reference<SwXPageStyle> GetPageStyle(DomainMapper_Impl& rDM_Impl);
 
     const OUString& GetPageStyleName()
     {

Reply via email to