sw/inc/unostyle.hxx                                  |    5 -
 sw/source/core/unocore/unostyle.cxx                  |    5 +
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |   32 ++----
 sw/source/writerfilter/dmapper/NumberingManager.cxx  |   18 +--
 sw/source/writerfilter/dmapper/PropertyMap.cxx       |   10 +-
 sw/source/writerfilter/dmapper/SettingsTable.cxx     |   31 ++----
 sw/source/writerfilter/dmapper/StyleSheetTable.cxx   |   92 +++++++------------
 7 files changed, 85 insertions(+), 108 deletions(-)

New commits:
commit 59471bb949e8d8d64023b17136921f59e0bf705e
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Aug 4 09:30:29 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Aug 4 21:07:57 2024 +0200

    use more concrete UNO type in writerfilter
    
    Change-Id: I70dd95a647c5a1e89d505da6d971c48662026d95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171456
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index d4618570bd9e..1790944e282f 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -70,7 +70,7 @@ public:
     SwXStyleFamilies(SwDocShell& rDocShell);
 
     //XNameAccess
-    virtual css::uno::Any SAL_CALL getByName(const OUString& Name) override;
+    SW_DLLPUBLIC virtual css::uno::Any SAL_CALL getByName(const OUString& 
Name) override;
     virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
     virtual sal_Bool SAL_CALL hasByName(const OUString& Name) override;
 
@@ -94,7 +94,8 @@ public:
     SW_DLLPUBLIC rtl::Reference<SwXStyleFamily> GetPageStyles();
     SW_DLLPUBLIC rtl::Reference<SwXStyleFamily> GetCharacterStyles();
     SW_DLLPUBLIC rtl::Reference<SwXStyleFamily> GetParagraphStyles();
-    rtl::Reference<SwXStyleFamily> GetStylesByName(const OUString& rName);
+    SW_DLLPUBLIC rtl::Reference<SwXStyleFamily> GetNumberingStyles();
+    SW_DLLPUBLIC rtl::Reference<SwXStyleFamily> GetStylesByName(const 
OUString& rName);
     rtl::Reference<SwXStyleFamily> GetStylesByIndex(sal_Int32 nIndex);
 
     static css::uno::Reference<css::style::XStyle> CreateStyle(SfxStyleFamily 
eFamily, SwDoc& rDoc);
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 3de7cdfe92a1..0cdb0d119764 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -721,6 +721,11 @@ rtl::Reference<SwXStyleFamily> 
SwXStyleFamilies::GetParagraphStyles()
     return GetStylesByName(u"ParagraphStyles"_ustr);
 }
 
+rtl::Reference<SwXStyleFamily> SwXStyleFamilies::GetNumberingStyles()
+{
+    return GetStylesByName(u"NumberingStyles"_ustr);
+}
+
 uno::Sequence< OUString > SwXStyleFamilies::getElementNames()
 {
     auto& entries(lcl_GetStyleFamilyEntries());
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index 805173b27cf2..8039968ead11 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -156,7 +156,7 @@ using namespace oox;
 namespace writerfilter::dmapper{
 
 //line numbering for header/footer
-static void lcl_linenumberingHeaderFooter( const 
uno::Reference<container::XNameContainer>& xStyles, const OUString& rname, 
DomainMapper_Impl* dmapper )
+static void lcl_linenumberingHeaderFooter( const 
rtl::Reference<SwXStyleFamily>& xStyles, const OUString& rname, 
DomainMapper_Impl* dmapper )
 {
     const StyleSheetEntryPtr pEntry = 
dmapper->GetStyleSheetTable()->FindStyleSheetByISTD( rname );
     if (!pEntry)
@@ -169,12 +169,10 @@ static void lcl_linenumberingHeaderFooter( const 
uno::Reference<container::XName
     {
         if( xStyles->hasByName( rname ) )
         {
-            uno::Reference< style::XStyle > xStyle;
-            xStyles->getByName( rname ) >>= xStyle;
+            rtl::Reference< SwXBaseStyle > xStyle = xStyles->getStyleByName( 
rname );
             if( !xStyle.is() )
                 return;
-            uno::Reference<beans::XPropertySet> xPropertySet( xStyle, 
uno::UNO_QUERY );
-            xPropertySet->setPropertyValue( getPropertyName( 
PROP_PARA_LINE_NUMBER_COUNT ), uno::Any( nListId >= 0 ) );
+            xStyle->setPropertyValue( getPropertyName( 
PROP_PARA_LINE_NUMBER_COUNT ), uno::Any( nListId >= 0 ) );
         }
     }
 }
@@ -7358,11 +7356,11 @@ void DomainMapper_Impl::handleToc
         uno::Reference<container::XIndexAccess> xChapterNumberingRules;
         if (m_xTextDocument)
             xChapterNumberingRules = 
m_xTextDocument->getChapterNumberingRules();
-        uno::Reference<container::XNameContainer> xStyles;
+        rtl::Reference<SwXStyleFamily> xStyles;
         if (m_xTextDocument)
         {
-            auto xStyleFamilies = m_xTextDocument->getStyleFamilies();
-            xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) 
>>= xStyles;
+            rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
m_xTextDocument->getSwStyleFamilies();
+            xStyles = xStyleFamilies->GetParagraphStyles();
         }
 
         uno::Reference< container::XIndexReplace> xLevelFormats;
@@ -7398,10 +7396,10 @@ void DomainMapper_Impl::handleToc
                 {
                     OUString style;
                     xTOC->getPropertyValue("ParaStyleLevel" + 
OUString::number(nLevel)) >>= style;
-                    uno::Reference<beans::XPropertySet> xStyle;
-                    if (xStyles->getByName(style) >>= xStyle)
+                    rtl::Reference<SwXBaseStyle> xStyle = 
xStyles->getStyleByName(style);
+                    if (xStyle)
                     {
-                        if (uno::Reference<beans::XPropertyState> xPropState{ 
xStyle,
+                        if (uno::Reference<beans::XPropertyState> xPropState{ 
static_cast<cppu::OWeakObject*>(xStyle.get()),
                                                                               
uno::UNO_QUERY })
                         {
                             if 
(xPropState->getPropertyState(u"ParaTabStops"_ustr)
@@ -9576,9 +9574,8 @@ void DomainMapper_Impl::SetLineNumbering( sal_Int32 
nLnnMod, sal_uInt32 nLnc, sa
         {}
     }
     m_bLineNumberingSet = true;
-    uno::Reference< container::XNameAccess > xStyleFamilies = 
m_xTextDocument->getStyleFamilies();
-    uno::Reference<container::XNameContainer> xStyles;
-    xStyleFamilies->getByName(getPropertyName( PROP_PARAGRAPH_STYLES )) >>= 
xStyles;
+    rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
m_xTextDocument->getSwStyleFamilies();
+    rtl::Reference<SwXStyleFamily> xStyles = 
xStyleFamilies->GetParagraphStyles();
     lcl_linenumberingHeaderFooter( xStyles, u"Header"_ustr, this );
     lcl_linenumberingHeaderFooter( xStyles, u"Footer"_ustr, this );
 }
@@ -9916,10 +9913,9 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const 
sal_Int32 nListId, sal_I
         auto const pList(GetListTable()->GetList(nListId));
         assert(pList);
         const OUString aListName = pList->GetStyleName();
-        const uno::Reference< container::XNameAccess > xStyleFamilies = 
m_xTextDocument->getStyleFamilies();
-        uno::Reference<container::XNameAccess> xNumberingStyles;
-        xStyleFamilies->getByName(u"NumberingStyles"_ustr) >>= 
xNumberingStyles;
-        const uno::Reference<beans::XPropertySet> 
xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
+        const rtl::Reference< SwXStyleFamilies > xStyleFamilies = 
m_xTextDocument->getSwStyleFamilies();
+        rtl::Reference<SwXStyleFamily> xNumberingStyles = 
xStyleFamilies->GetNumberingStyles();
+        const rtl::Reference<SwXBaseStyle> xStyle = 
xNumberingStyles->getStyleByName(aListName);
         const uno::Reference<container::XIndexAccess> 
xNumberingRules(xStyle->getPropertyValue(u"NumberingRules"_ustr), 
uno::UNO_QUERY);
         if (xNumberingRules.is())
         {
diff --git a/sw/source/writerfilter/dmapper/NumberingManager.cxx 
b/sw/source/writerfilter/dmapper/NumberingManager.cxx
index 726ba50dbdc0..af97ead5f9c6 100644
--- a/sw/source/writerfilter/dmapper/NumberingManager.cxx
+++ b/sw/source/writerfilter/dmapper/NumberingManager.cxx
@@ -46,6 +46,7 @@
 #include <comphelper/string.hxx>
 #include <unotxdoc.hxx>
 #include <unoxstyle.hxx>
+#include <unostyle.hxx>
 #include <regex>
 #include <utility>
 
@@ -479,18 +480,16 @@ uno::Sequence<uno::Sequence<beans::PropertyValue>> 
ListDef::GetMergedPropertyVal
     return aAbstract;
 }
 
-static uno::Reference< container::XNameContainer > lcl_getUnoNumberingStyles(
+static rtl::Reference< SwXStyleFamily > lcl_getUnoNumberingStyles(
        rtl::Reference<SwXTextDocument> const& xTextDoc)
 {
-    uno::Reference< container::XNameContainer > xStyles;
+    rtl::Reference< SwXStyleFamily > xStyles;
     if (!xTextDoc)
         return xStyles;
 
     try
     {
-        uno::Any oFamily = xTextDoc->getStyleFamilies( 
)->getByName(u"NumberingStyles"_ustr);
-
-        oFamily >>= xStyles;
+        xStyles = xTextDoc->getSwStyleFamilies( )->GetNumberingStyles();
     }
     catch ( const uno::Exception & )
     {
@@ -536,7 +535,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
         rtl::Reference<SwXTextDocument> const& xTextDoc, sal_Int16 nOutline)
 {
     // Get the UNO Numbering styles
-    uno::Reference< container::XNameContainer > xStyles = 
lcl_getUnoNumberingStyles( xTextDoc );
+    rtl::Reference< SwXStyleFamily > xStyles = lcl_getUnoNumberingStyles( 
xTextDoc );
 
     // Do the whole thing
     if( !(!m_xNumRules.is() && xTextDoc.is() && xStyles.is( )) )
@@ -558,14 +557,13 @@ void ListDef::CreateNumberingRules( DomainMapper& 
rDMapper,
             }
             else
             {
-                xStyles->insertByName(
+                xStyles->insertStyleByName(
                     aStyleName,
-                    
css::uno::Any(uno::Reference<css::style::XStyle>(xTextDoc->createNumberingStyle())));
+                    xTextDoc->createNumberingStyle());
             }
         }
 
-        uno::Any oStyle = xStyles->getByName(GetStyleName());
-        uno::Reference< beans::XPropertySet > xStyle( oStyle, 
uno::UNO_QUERY_THROW );
+        rtl::Reference<SwXBaseStyle> xStyle = 
xStyles->getStyleByName(GetStyleName());
 
         // Get the default OOo Numbering style rules
         uno::Any aRules = xStyle->getPropertyValue( getPropertyName( 
PROP_NUMBERING_RULES ) );
diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx 
b/sw/source/writerfilter/dmapper/PropertyMap.cxx
index c033995a80dd..407e8871b9e2 100644
--- a/sw/source/writerfilter/dmapper/PropertyMap.cxx
+++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx
@@ -1228,13 +1228,13 @@ void 
SectionPropertyMap::HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl)
         //and for RTL locales, LTR default paragraph style should present a 
left aligned footnote separator
         try
         {
-            uno::Reference<container::XNameAccess> xStyleFamilies = 
rDM_Impl.GetTextDocument()->getStyleFamilies();
-            uno::Reference<container::XNameAccess> xParagraphStyles;
+            rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
rDM_Impl.GetTextDocument()->getSwStyleFamilies();
+            rtl::Reference<SwXStyleFamily> xParagraphStyles;
             if ( xStyleFamilies.is() )
-                xStyleFamilies->getByName(u"ParagraphStyles"_ustr) >>= 
xParagraphStyles;
-            uno::Reference<beans::XPropertySet> xStandard;
+                xParagraphStyles = xStyleFamilies->GetParagraphStyles();
+            rtl::Reference<SwXBaseStyle> xStandard;
             if ( xParagraphStyles.is() )
-                xParagraphStyles->getByName(u"Standard"_ustr) >>= xStandard;
+                xStandard = xParagraphStyles->getStyleByName(u"Standard"_ustr) 
;
             if ( xStandard.is() )
             {
                 sal_Int16 aWritingMode(0);
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx 
b/sw/source/writerfilter/dmapper/SettingsTable.cxx
index dcf42d370371..0c7cc0140907 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.cxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx
@@ -45,6 +45,7 @@
 #include "util.hxx"
 #include <SwXDocumentSettings.hxx>
 #include <unotxdoc.hxx>
+#include <unostyle.hxx>
 
 using namespace com::sun::star;
 
@@ -707,42 +708,36 @@ void 
SettingsTable::ApplyProperties(rtl::Reference<SwXTextDocument> const& xDoc)
     if (!(m_pImpl->m_bAutoHyphenation || m_pImpl->m_bNoHyphenateCaps || 
m_pImpl->m_bWidowControl))
         return;
 
-    uno::Reference<container::XNameAccess> xStyleFamilies = 
xDoc->getStyleFamilies();
-    uno::Reference<container::XNameContainer> xParagraphStyles = 
xStyleFamilies->getByName(u"ParagraphStyles"_ustr).get< 
uno::Reference<container::XNameContainer> >();
-    uno::Reference<style::XStyle> xDefault = 
xParagraphStyles->getByName(u"Standard"_ustr).get< 
uno::Reference<style::XStyle> >();
-    uno::Reference<beans::XPropertyState> xPropertyState(xDefault, 
uno::UNO_QUERY);
+    rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
xDoc->getSwStyleFamilies();
+    rtl::Reference<SwXStyleFamily> xParagraphStyles = 
xStyleFamilies->GetParagraphStyles();
+    rtl::Reference<SwXBaseStyle> xDefault = 
xParagraphStyles->getStyleByName(u"Standard"_ustr);
+    uno::Reference<beans::XPropertyState> 
xPropertyState(static_cast<cppu::OWeakObject*>(xDefault.get()), uno::UNO_QUERY);
     if (m_pImpl->m_bAutoHyphenation && lcl_isDefault(xPropertyState, 
u"ParaIsHyphenation"_ustr))
     {
-        uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
-        xPropertySet->setPropertyValue(u"ParaIsHyphenation"_ustr, 
uno::Any(true));
+        xDefault->setPropertyValue(u"ParaIsHyphenation"_ustr, uno::Any(true));
     }
     if (m_pImpl->m_bNoHyphenateCaps)
     {
-        uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
-        xPropertySet->setPropertyValue(u"ParaHyphenationNoCaps"_ustr, 
uno::Any(true));
+        xDefault->setPropertyValue(u"ParaHyphenationNoCaps"_ustr, 
uno::Any(true));
     }
     if (m_pImpl->m_nHyphenationZone)
     {
-        uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
-        xPropertySet->setPropertyValue(u"ParaHyphenationZone"_ustr, 
uno::Any(GetHyphenationZone()));
+        xDefault->setPropertyValue(u"ParaHyphenationZone"_ustr, 
uno::Any(GetHyphenationZone()));
     }
     if (m_pImpl->m_nConsecutiveHyphenLimit)
     {
-        uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
-        xPropertySet->setPropertyValue(u"ParaHyphenationMaxHyphens"_ustr, 
uno::Any(GetConsecutiveHyphenLimit()));
+        xDefault->setPropertyValue(u"ParaHyphenationMaxHyphens"_ustr, 
uno::Any(GetConsecutiveHyphenLimit()));
     }
     if (m_pImpl->m_bWidowControl && lcl_isDefault(xPropertyState, 
u"ParaWidows"_ustr) && lcl_isDefault(xPropertyState, u"ParaOrphans"_ustr))
     {
-        uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
         uno::Any aAny(static_cast<sal_Int8>(2));
-        xPropertySet->setPropertyValue(u"ParaWidows"_ustr, aAny);
-        xPropertySet->setPropertyValue(u"ParaOrphans"_ustr, aAny);
+        xDefault->setPropertyValue(u"ParaWidows"_ustr, aAny);
+        xDefault->setPropertyValue(u"ParaOrphans"_ustr, aAny);
     }
     if ( GetHyphenationKeep() )
     {
-        uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
-        xPropertySet->setPropertyValue(u"ParaHyphenationKeep"_ustr, 
uno::Any(true));
-        xPropertySet->setPropertyValue(u"ParaHyphenationKeepType"_ustr, 
uno::Any(text::ParagraphHyphenationKeepType::COLUMN));
+        xDefault->setPropertyValue(u"ParaHyphenationKeep"_ustr, 
uno::Any(true));
+        xDefault->setPropertyValue(u"ParaHyphenationKeepType"_ustr, 
uno::Any(text::ParagraphHyphenationKeepType::COLUMN));
     }
 }
 
diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx 
b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx
index 012177cda9d9..6e892cf4574c 100644
--- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx
+++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx
@@ -909,9 +909,8 @@ void StyleSheetTable::ApplyNumberingStyleNameToParaStyles()
         return;
     try
     {
-        uno::Reference< container::XNameAccess > xStyleFamilies = 
m_pImpl->m_xTextDocument->getStyleFamilies();
-        uno::Reference<container::XNameContainer> xParaStyles;
-        xStyleFamilies->getByName(getPropertyName( PROP_PARAGRAPH_STYLES )) 
>>= xParaStyles;
+        rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
m_pImpl->m_xTextDocument->getSwStyleFamilies();
+        rtl::Reference<SwXStyleFamily> xParaStyles = 
xStyleFamilies->GetParagraphStyles();
 
         if ( !xParaStyles.is() )
             return;
@@ -924,17 +923,15 @@ void 
StyleSheetTable::ApplyNumberingStyleNameToParaStyles()
                 // ListId 0 means turn off numbering - to cancel inheritance - 
so make sure that can be set.
                 if (pStyleSheetProperties->props().GetListId() > -1)
                 {
-                    uno::Reference< style::XStyle > xStyle;
-                    
xParaStyles->getByName(ConvertStyleName(pEntry->m_sStyleName).first) >>= xStyle;
+                    rtl::Reference< SwXBaseStyle > xStyle = 
xParaStyles->getStyleByName(ConvertStyleName(pEntry->m_sStyleName).first);
 
                     if ( !xStyle.is() )
                         break;
 
-                    uno::Reference<beans::XPropertySet> xPropertySet( xStyle, 
uno::UNO_QUERY_THROW );
                     const OUString sNumberingStyleName = 
m_pImpl->m_rDMapper.GetListStyleName( 
pStyleSheetProperties->props().GetListId() );
                     if ( !sNumberingStyleName.isEmpty()
                          || !pStyleSheetProperties->props().GetListId() )
-                        xPropertySet->setPropertyValue( 
getPropertyName(PROP_NUMBERING_STYLE_NAME), uno::Any(sNumberingStyleName) );
+                        xStyle->setPropertyValue( 
getPropertyName(PROP_NUMBERING_STYLE_NAME), uno::Any(sNumberingStyleName) );
 
                     // Word 2010+ (not Word 2003, and Word 2007 is completely 
broken)
                     // does something rather strange. It does not allow two 
paragraph styles
@@ -963,9 +960,8 @@ void 
StyleSheetTable::ReApplyInheritedOutlineLevelFromChapterNumbering()
         return;
     try
     {
-        uno::Reference< container::XNameAccess > xStyleFamilies = 
m_pImpl->m_xTextDocument->getStyleFamilies();
-        uno::Reference<container::XNameContainer> xParaStyles;
-        xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) >>= 
xParaStyles;
+        rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
m_pImpl->m_xTextDocument->getSwStyleFamilies();
+        rtl::Reference<SwXStyleFamily> xParaStyles = 
xStyleFamilies->GetParagraphStyles();
 
         if (!xParaStyles.is())
             return;
@@ -979,18 +975,16 @@ void 
StyleSheetTable::ReApplyInheritedOutlineLevelFromChapterNumbering()
             if (!pParent || !pParent->m_bAssignedAsChapterNumbering)
                 continue;
 
-            uno::Reference< style::XStyle > xStyle;
-            xParaStyles->getByName(pEntry->m_sConvertedStyleName) >>= xStyle;
+            rtl::Reference< SwXBaseStyle > xStyle = 
xParaStyles->getStyleByName(pEntry->m_sConvertedStyleName);
             if (!xStyle.is())
                 continue;
 
-            uno::Reference<beans::XPropertySet> xPropertySet(xStyle, 
uno::UNO_QUERY_THROW);
             const sal_Int16 nListId = 
pEntry->m_pProperties->props().GetListId();
             const OUString& sParentNumberingStyleName
                 = 
m_pImpl->m_rDMapper.GetListStyleName(pParent->m_pProperties->props().GetListId());
             if (nListId == -1 && !sParentNumberingStyleName.isEmpty())
             {
-                
xPropertySet->setPropertyValue(getPropertyName(PROP_NUMBERING_STYLE_NAME),
+                
xStyle->setPropertyValue(getPropertyName(PROP_NUMBERING_STYLE_NAME),
                                                
uno::Any(sParentNumberingStyleName));
             }
 
@@ -1004,7 +998,7 @@ void 
StyleSheetTable::ReApplyInheritedOutlineLevelFromChapterNumbering()
             // convert MS level to LO equivalent outline level
             ++nOutlineLevel;
 
-            
xPropertySet->setPropertyValue(getPropertyName(PROP_OUTLINE_LEVEL), 
uno::Any(nOutlineLevel));
+            xStyle->setPropertyValue(getPropertyName(PROP_OUTLINE_LEVEL), 
uno::Any(nOutlineLevel));
         }
     }
     catch( const uno::Exception& )
@@ -1123,19 +1117,16 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
         return;
     try
     {
-        uno::Reference< container::XNameAccess > xStyleFamilies = 
m_pImpl->m_xTextDocument->getStyleFamilies();
-        uno::Reference<container::XNameContainer> xCharStyles;
-        uno::Reference<container::XNameContainer> xParaStyles;
-        uno::Reference<container::XNameContainer> xNumberingStyles;
-
-        xStyleFamilies->getByName(getPropertyName( PROP_CHARACTER_STYLES )) 
>>= xCharStyles;
-        xStyleFamilies->getByName(getPropertyName( PROP_PARAGRAPH_STYLES )) 
>>= xParaStyles;
-        xStyleFamilies->getByName(u"NumberingStyles"_ustr) >>= 
xNumberingStyles;
+        rtl::Reference< SwXStyleFamilies > xStyleFamilies = 
m_pImpl->m_xTextDocument->getSwStyleFamilies();
+        rtl::Reference<SwXStyleFamily> xCharStyles = 
xStyleFamilies->GetCharacterStyles();
+        rtl::Reference<SwXStyleFamily> xParaStyles = 
xStyleFamilies->GetParagraphStyles();
+        rtl::Reference<SwXStyleFamily> xNumberingStyles = 
xStyleFamilies->GetNumberingStyles();
+
         if(xCharStyles.is() && xParaStyles.is())
         {
-            std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> 
> aMissingParent;
-            std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> 
> aMissingFollow;
-            std::vector<std::pair<OUString, uno::Reference<style::XStyle>>> 
aMissingLink;
+            std::vector< ::std::pair<OUString, rtl::Reference<SwXBaseStyle>> > 
aMissingParent;
+            std::vector< ::std::pair<OUString, rtl::Reference<SwXBaseStyle>> > 
aMissingFollow;
+            std::vector<std::pair<OUString, rtl::Reference<SwXBaseStyle>>> 
aMissingLink;
             std::vector<beans::PropertyValue> aTableStylesVec;
             for (auto& pEntry : rEntries)
             {
@@ -1148,8 +1139,8 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                     bool bCharStyle = pEntry->m_nStyleTypeCode == 
STYLE_TYPE_CHAR;
                     bool bListStyle = pEntry->m_nStyleTypeCode == 
STYLE_TYPE_LIST;
                     bool bInsert = false;
-                    uno::Reference< container::XNameContainer > xStyles = 
bParaStyle ? xParaStyles : (bListStyle ? xNumberingStyles : xCharStyles);
-                    uno::Reference< style::XStyle > xStyle;
+                    rtl::Reference< SwXStyleFamily > xStyles = bParaStyle ? 
xParaStyles : (bListStyle ? xNumberingStyles : xCharStyles);
+                    rtl::Reference< SwXBaseStyle > xStyle;
                     const OUString 
sConvertedStyleName(ConvertStyleName(pEntry->m_sStyleName).first);
 
                     if(xStyles->hasByName( sConvertedStyleName ))
@@ -1159,7 +1150,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                         {
                             continue;
                         }
-                        xStyles->getByName( sConvertedStyleName ) >>= xStyle;
+                        xStyle = xStyles->getStyleByName( sConvertedStyleName 
);
 
                         {
                             
StyleSheetTable_Impl::SetPropertiesToDefault(xStyle);
@@ -1186,16 +1177,15 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                         // Numbering styles have to be inserted early, as e.g. 
the NumberingRules property is only available after insertion.
                         if (bListStyle)
                         {
-                            xStyles->insertByName( sConvertedStyleName, 
uno::Any( xStyle ) );
-                            
xStyle.set(xStyles->getByName(sConvertedStyleName), uno::UNO_QUERY_THROW);
+                            xStyles->insertStyleByName( sConvertedStyleName, 
static_cast<SwXStyle*>(xStyle.get()) );
+                            xStyle = 
xStyles->getStyleByName(sConvertedStyleName);
 
                             StyleSheetPropertyMap* pPropertyMap = 
pEntry->m_pProperties.get();
                             if (pPropertyMap && 
pPropertyMap->props().GetListId() == -1)
                             {
                                 // No properties? Word default is 'none', 
Writer one is 'arabic', handle this.
-                                uno::Reference<beans::XPropertySet> 
xPropertySet(xStyle, uno::UNO_QUERY_THROW);
                                 uno::Reference<container::XIndexReplace> 
xNumberingRules;
-                                
xPropertySet->getPropertyValue(u"NumberingRules"_ustr) >>= xNumberingRules;
+                                
xStyle->getPropertyValue(u"NumberingRules"_ustr) >>= xNumberingRules;
                                 uno::Reference<container::XIndexAccess> 
xIndexAccess(xNumberingRules, uno::UNO_QUERY_THROW);
                                 for (sal_Int32 i = 0; i < 
xIndexAccess->getCount(); ++i)
                                 {
@@ -1204,7 +1194,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                                             u"NumberingType"_ustr, 
style::NumberingType::NUMBER_NONE)
                                     };
                                     xNumberingRules->replaceByIndex(i, 
uno::Any(aLvlProps));
-                                    
xPropertySet->setPropertyValue(u"NumberingRules"_ustr, 
uno::Any(xNumberingRules));
+                                    
xStyle->setPropertyValue(u"NumberingRules"_ustr, uno::Any(xNumberingRules));
                                 }
                             }
                         }
@@ -1314,7 +1304,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                             }
                         }
 
-                        uno::Reference< beans::XPropertyState >xState( xStyle, 
uno::UNO_QUERY_THROW );
+                        uno::Reference< beans::XPropertyState >xState( 
static_cast<cppu::OWeakObject*>(xStyle.get()), uno::UNO_QUERY_THROW );
                         if( sConvertedStyleName == "Contents Heading" ||
                             sConvertedStyleName == "User Index Heading" ||
                             sConvertedStyleName == "Index Heading" )
@@ -1364,19 +1354,18 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
 
                         try
                         {
-                            uno::Reference< beans::XMultiPropertySet > 
xMultiPropertySet( xStyle, uno::UNO_QUERY_THROW);
+                            uno::Reference< beans::XMultiPropertySet > 
xMultiPropertySet( static_cast<cppu::OWeakObject*>(xStyle.get()), 
uno::UNO_QUERY_THROW);
                             try
                             {
                                 xMultiPropertySet->setPropertyValues( 
aSortedPropVals.getNames(), aSortedPropVals.getValues() );
                             }
                             catch ( const uno::Exception& )
                             {
-                                uno::Reference<beans::XPropertySet> 
xPropertySet(xStyle, uno::UNO_QUERY_THROW);
                                 for ( const beans::PropertyValue& rValue : 
aSortedPropVals.getProperties() )
                                 {
                                     try
                                     {
-                                       xPropertySet->setPropertyValue( 
rValue.Name, rValue.Value );
+                                       xStyle->setPropertyValue( rValue.Name, 
rValue.Value );
                                     }
                                     catch ( const uno::Exception& )
                                     {
@@ -1424,7 +1413,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                         if( !sParentStyle.isEmpty() && !xStyles->hasByName( 
sParentStyle ) )
                             aMissingParent.emplace_back( sParentStyle, xStyle 
);
 
-                        xStyles->insertByName( sConvertedStyleName, uno::Any( 
xStyle) );
+                        xStyles->insertStyleByName( sConvertedStyleName, 
static_cast<SwXStyle*>(xStyle.get()) );
 
                         if (!m_pImpl->m_bIsNewDoc && bParaStyle)
                         {
@@ -1435,15 +1424,14 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
                     }
 
                     beans::PropertyValues aGrabBag = 
pEntry->GetInteropGrabBagSeq();
-                    uno::Reference<beans::XPropertySet> xPropertySet(xStyle, 
uno::UNO_QUERY);
                     if (aGrabBag.hasElements())
                     {
-                        
xPropertySet->setPropertyValue(u"StyleInteropGrabBag"_ustr, uno::Any(aGrabBag));
+                        xStyle->setPropertyValue(u"StyleInteropGrabBag"_ustr, 
uno::Any(aGrabBag));
                     }
 
                     // Only paragraph styles support automatic updates.
                     if (pEntry->m_bAutoRedefine && bParaStyle)
-                        xPropertySet->setPropertyValue(u"IsAutoUpdate"_ustr, 
uno::Any(true));
+                        xStyle->setPropertyValue(u"IsAutoUpdate"_ustr, 
uno::Any(true));
                 }
                 else if(pEntry->m_nStyleTypeCode == STYLE_TYPE_TABLE)
                 {
@@ -1467,8 +1455,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
             {
                 try
                 {
-                    uno::Reference<beans::XPropertySet> 
xPropertySet(iter.second, uno::UNO_QUERY);
-                    xPropertySet->setPropertyValue( u"FollowStyle"_ustr, 
uno::Any(iter.first) );
+                    iter.second->setPropertyValue( u"FollowStyle"_ustr, 
uno::Any(iter.first) );
                 }
                 catch( uno::Exception & ) {}
             }
@@ -1478,9 +1465,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const 
FontTablePtr& rFontTable, std::
             {
                 try
                 {
-                    uno::Reference<beans::XPropertySet> 
xPropertySet(rLinked.second,
-                                                                     
uno::UNO_QUERY);
-                    xPropertySet->setPropertyValue(u"LinkStyle"_ustr, 
uno::Any(rLinked.first));
+                    rLinked.second->setPropertyValue(u"LinkStyle"_ustr, 
uno::Any(rLinked.first));
                 }
                 catch (uno::Exception&)
                 {
@@ -2089,12 +2074,10 @@ void StyleSheetTable::applyDefaults(bool 
bParaProperties)
             SetDefaultParaProps(PROP_PARA_WIDOWS, aTwo);
             SetDefaultParaProps(PROP_PARA_ORPHANS, aTwo);
 
-            uno::Reference<container::XNameAccess> xStyleFamilies = 
m_pImpl->m_xTextDocument->getStyleFamilies();
-            uno::Reference<container::XNameAccess> xParagraphStyles;
-            xStyleFamilies->getByName(u"ParagraphStyles"_ustr) >>= 
xParagraphStyles;
-            uno::Reference<beans::XPropertySet> xDefault;
+            rtl::Reference<SwXStyleFamilies> xStyleFamilies = 
m_pImpl->m_xTextDocument->getSwStyleFamilies();
+            rtl::Reference<SwXStyleFamily> xParagraphStyles = 
xStyleFamilies->GetParagraphStyles();
             // This is the built-in default style that every style inherits 
from
-            xParagraphStyles->getByName(u"Paragraph style"_ustr) >>= xDefault;
+            rtl::Reference<SwXBaseStyle> xDefault = 
xParagraphStyles->getStyleByName(u"Paragraph style"_ustr);
 
             const uno::Sequence< beans::PropertyValue > aPropValues = 
m_pImpl->m_pDefaultParaProps->GetPropertyValues();
             for( const auto& rPropValue : aPropValues )
@@ -2182,9 +2165,8 @@ void StyleSheetTable::MarkParagraphStyleAsUsed(const 
OUString& rName)
 
 void StyleSheetTable::RemoveUnusedParagraphStyles()
 {
-    uno::Reference< container::XNameAccess > xStyleFamilies = 
m_pImpl->m_xTextDocument->getStyleFamilies();
-    uno::Reference<container::XNameContainer> xParaStyles;
-    xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) >>= 
xParaStyles;
+    rtl::Reference< SwXStyleFamilies > xStyleFamilies = 
m_pImpl->m_xTextDocument->getSwStyleFamilies();
+    rtl::Reference<SwXStyleFamily> xParaStyles = 
xStyleFamilies->GetParagraphStyles();
     for (const auto& rName : m_pImpl->m_aInsertedParagraphStyles)
     {
         if (m_pImpl->m_aUsedParagraphStyles.contains(rName))

Reply via email to