include/svl/style.hxx               |    4 --
 sfx2/source/dialog/StyleList.cxx    |    3 +
 svl/source/items/style.cxx          |   11 ------
 sw/inc/docstyle.hxx                 |    3 -
 sw/source/core/unocore/unostyle.cxx |   11 +-----
 sw/source/uibase/app/docstyle.cxx   |   57 ------------------------------------
 6 files changed, 4 insertions(+), 85 deletions(-)

New commits:
commit ce391e52fbb759997f7e2c225513cc074a0f3974
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Mon Jun 26 17:17:53 2023 +0300
Commit:     Maxim Monastirsky <momonas...@gmail.com>
CommitDate: Fri Jun 30 10:00:40 2023 +0200

    Drop SfxStyleSheetBasePool::SetParent
    
    Use SfxStyleSheetBase::SetParent directly instead. The
    base class was just calling it anyway, while the
    SwDocStyleSheetPool override was mostly a copy & paste
    of its override in SwDocStyleSheet.
    
    Change-Id: I18d8208ed2d079e0f2ce4f13a5dbdda6fe4730e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153773
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index 257b1786eb57..fc12dc0be74e 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -274,10 +274,6 @@ public:
     SfxStyleSheetBase*  Next();
     virtual SfxStyleSheetBase*  Find( const OUString&, SfxStyleFamily eFam, 
SfxStyleSearchBits n=SfxStyleSearchBits::All );
 
-    virtual bool                SetParent(SfxStyleFamily eFam,
-                                          const OUString &rStyle,
-                                          const OUString &rParent);
-
     void                        Reindex();
     /** Add a style sheet.
      * Not an actual public function. Do not call it from non-subclasses.
diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index bf9bf80d9db8..b9f9c0c62237 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -580,7 +580,8 @@ void StyleList::DropHdl(const OUString& rStyle, const 
OUString& rParent)
     m_bDontUpdate = true;
     const SfxStyleFamilyItem* pItem = GetFamilyItem();
     const SfxStyleFamily eFam = pItem->GetFamily();
-    m_pStyleSheetPool->SetParent(eFam, rStyle, rParent);
+    if (auto pStyle = m_pStyleSheetPool->Find(rStyle, eFam))
+        pStyle->SetParent(rParent);
     m_bDontUpdate = false;
 }
 
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 40ba0ca85f72..41551e506498 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -585,17 +585,6 @@ SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
     Clear();
 }
 
-bool SfxStyleSheetBasePool::SetParent(SfxStyleFamily eFam, const OUString& 
rStyle, const OUString& rParent)
-{
-    SfxStyleSheetIterator aIter(this, eFam, SfxStyleSearchBits::All);
-    SfxStyleSheetBase *pStyle = aIter.Find(rStyle);
-    OSL_ENSURE(pStyle, "Template not found. Writer with solar <2541?");
-    if(pStyle)
-        return pStyle->SetParent(rParent);
-    else
-        return false;
-}
-
 std::unique_ptr<SfxStyleSheetIterator> SfxStyleSheetBasePool::CreateIterator
 (
  SfxStyleFamily eFam,
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 7d0a07de2dc8..b411bfe4b1ce 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -226,9 +226,6 @@ public:
     virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
                                     SfxStyleSearchBits 
n=SfxStyleSearchBits::All ) override;
 
-    virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
-                            const OUString &rParent ) override;
-
     virtual void Remove( SfxStyleSheetBase* pStyle) override;
 
     bool    IsOrganizerMode() const         { return m_bOrganizer; }
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 75428e103eab..071ca0daae31 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1114,17 +1114,10 @@ void XStyleFamily::insertByName(const OUString& rName, 
const uno::Any& rElement)
         SfxStyleSearchBits nMask = SfxStyleSearchBits::All;
         if(m_rEntry.family() == SfxStyleFamily::Para && 
!pNewStyle->IsConditional())
             nMask &= ~SfxStyleSearchBits::SwCondColl;
-        m_pBasePool->Make(sStyleName, m_rEntry.family(), nMask);
+        auto pStyle = &m_pBasePool->Make(sStyleName, m_rEntry.family(), nMask);
         pNewStyle->SetDoc(m_pDocShell->GetDoc(), m_pBasePool);
         pNewStyle->SetStyleName(sStyleName);
-        const OUString sParentStyleName(pNewStyle->GetParentStyleName());
-        if (!sParentStyleName.isEmpty())
-        {
-            SfxStyleSheetBase* pParentBase = 
m_pBasePool->Find(sParentStyleName, m_rEntry.family());
-            if(pParentBase && pParentBase->GetFamily() == m_rEntry.family() &&
-                pParentBase->GetPool() == m_pBasePool)
-                m_pBasePool->SetParent(m_rEntry.family(), sStyleName, 
sParentStyleName);
-        }
+        pStyle->SetParent(pNewStyle->GetParentStyleName());
         // after all, we still need to apply the properties of the descriptor
         pNewStyle->ApplyDescriptorProperties();
     }
diff --git a/sw/source/uibase/app/docstyle.cxx 
b/sw/source/uibase/app/docstyle.cxx
index fe6835f9d8d4..456aae85c5e9 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -2712,63 +2712,6 @@ void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* 
pStyle)
         Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetErased, *pStyle ) );
 }
 
-bool  SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
-                                      const OUString &rStyle, const OUString 
&rParent )
-{
-    SwFormat* pFormat = nullptr, *pParent = nullptr;
-    switch( eFam )
-    {
-    case SfxStyleFamily::Char :
-        if( nullptr != ( pFormat = lcl_FindCharFormat( m_rDoc, rStyle ) ) && 
!rParent.isEmpty() )
-            pParent = lcl_FindCharFormat(m_rDoc, rParent );
-        break;
-
-    case SfxStyleFamily::Para :
-        if( nullptr != ( pFormat = lcl_FindParaFormat( m_rDoc, rStyle ) ) && 
!rParent.isEmpty() )
-            pParent = lcl_FindParaFormat( m_rDoc, rParent );
-        break;
-
-    case SfxStyleFamily::Frame:
-        if( nullptr != ( pFormat = lcl_FindFrameFormat( m_rDoc, rStyle ) ) && 
!rParent.isEmpty() )
-            pParent = lcl_FindFrameFormat( m_rDoc, rParent );
-        break;
-
-    case SfxStyleFamily::Page:
-    case SfxStyleFamily::Pseudo:
-        break;
-
-    default:
-        OSL_ENSURE(false, "unknown style family");
-    }
-
-    bool bRet = false;
-    if( pFormat && pFormat->DerivedFrom() &&
-        pFormat->DerivedFrom()->GetName() != rParent )
-    {
-        {
-            SwImplShellAction aTmpSh( m_rDoc );
-            bRet = pFormat->SetDerivedFrom( pParent );
-        }
-
-        if( bRet )
-        {
-            // only for Broadcasting
-            mxStyleSheet->SetPhysical( false );
-            mxStyleSheet->PresetName( rStyle );
-            mxStyleSheet->PresetParent( rParent );
-            if( SfxStyleFamily::Para == eFam )
-                mxStyleSheet->PresetFollow( 
static_cast<SwTextFormatColl*>(pFormat)->
-                        GetNextTextFormatColl().GetName() );
-            else
-                mxStyleSheet->PresetFollow( OUString() );
-
-            Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, 
*mxStyleSheet ) );
-        }
-    }
-
-    return bRet;
-}
-
 SfxStyleSheetBase* SwDocStyleSheetPool::Find(const OUString& rName,
                                              SfxStyleFamily eFam, 
SfxStyleSearchBits n)
 {

Reply via email to