sw/inc/numrule.hxx                 |    4 +++-
 sw/source/core/doc/number.cxx      |   17 +++++++++++++++++
 sw/source/ui/misc/outline.cxx      |    2 +-
 sw/source/uibase/config/uinums.cxx |    9 ++++-----
 sw/source/uibase/inc/uinums.hxx    |    2 +-
 5 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit 4247d9e4d29cc8f6863f904d2f69a2de4fcd4e66
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Feb 27 15:05:21 2021 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Mar 1 11:38:14 2021 +0100

    tdf#140528 Crash in writer when switching from Numbering to Position
    
    regression from
        commit e5ecb998fd78137aec32ad2cc996eaa4bb3e499d
        Date:   Mon Dec 5 09:52:43 2016 +0000
        avoid coverity#1371269 Missing move assignment operator
    
    rather write this code in a more obvious fashion, and bypass
    the use of the very weird operator= method, which barely
    copies anything at all.
    
    Change-Id: I548d8f73224c2625ed6389861551038b18396b0f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111677
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 9ab2284660857f52efc9b68b9d2dd8ea768d6916)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111696
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 1e00c377559d387a5b1111bf63e9684ff441b90b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111699
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index 6152e6bee99f..fec64d076833 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -135,7 +135,7 @@ private:
     bool mbCountPhantoms;
     bool mbUsedByRedline;    /// it needs to export as part of tracked 
numbering change
 
-    const SvxNumberFormat::SvxNumPositionAndSpaceMode 
meDefaultNumberFormatPositionAndSpaceMode;
+    SvxNumberFormat::SvxNumPositionAndSpaceMode 
meDefaultNumberFormatPositionAndSpaceMode;
     OUString msDefaultListId;
     std::shared_ptr<SfxGrabBagItem> mpGrabBagItem; ///< Style InteropGrabBag.
 
@@ -152,6 +152,8 @@ public:
     bool operator==( const SwNumRule& ) const;
     bool operator!=( const SwNumRule& r ) const { return !(*this == r); }
 
+    void Reset( const OUString& rName );
+
     const SwNumFormat* GetNumFormat( sal_uInt16 i ) const;
     const SwNumFormat& Get( sal_uInt16 i ) const;
 
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 1de08ae9f761..9d27a68783cd 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -550,6 +550,23 @@ SwNumRule& SwNumRule::operator=( const SwNumRule& rNumRule 
)
     return *this;
 }
 
+void SwNumRule::Reset( const OUString& rName )
+{
+    for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
+        Set( n, nullptr);
+
+    meRuleType = NUM_RULE;
+    msName = rName;
+    mbAutoRuleFlag = true;
+    mbInvalidRuleFlag = true;
+    mbContinusNum = false;
+    mbAbsSpaces = false;
+    mbHidden = false;
+    mnPoolFormatId = USHRT_MAX;
+    mnPoolHelpId = USHRT_MAX;
+    mnPoolHlpFileId = UCHAR_MAX;
+}
+
 bool SwNumRule::operator==( const SwNumRule& rRule ) const
 {
     bool bRet = meRuleType == rRule.meRuleType &&
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index d95731321120..8a62e03054ea 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -277,7 +277,7 @@ IMPL_LINK(SwOutlineTabDialog, MenuSelectHdl, const 
OString&, rIdent, void)
         const SwNumRulesWithName *pRules = pChapterNumRules->GetRules( 
nLevelNo );
         if( pRules )
         {
-            xNumRule = pRules->MakeNumRule(rWrtSh);
+            pRules->ResetNumRule(rWrtSh, *xNumRule);
             xNumRule->SetRuleType( OUTLINE_RULE );
             SfxTabPage* pOutlinePage = GetTabPage("numbering");
             assert(pOutlinePage);
diff --git a/sw/source/uibase/config/uinums.cxx 
b/sw/source/uibase/config/uinums.cxx
index 0ffee44376e2..f287a15360ac 100644
--- a/sw/source/uibase/config/uinums.cxx
+++ b/sw/source/uibase/config/uinums.cxx
@@ -143,19 +143,18 @@ SwNumRulesWithName& SwNumRulesWithName::operator=(const 
SwNumRulesWithName &rCop
     return *this;
 }
 
-std::unique_ptr<SwNumRule> SwNumRulesWithName::MakeNumRule(SwWrtShell& rSh) 
const
+void SwNumRulesWithName::ResetNumRule(SwWrtShell& rSh, SwNumRule& rNumRule) 
const
 {
     // #i89178#
-    std::unique_ptr<SwNumRule> pChg(new SwNumRule(maName, 
numfunc::GetDefaultPositionAndSpaceMode()));
-    pChg->SetAutoRule( false );
+    rNumRule.Reset(maName);
+    rNumRule.SetAutoRule( false );
     for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
     {
         SwNumFormatGlobal* pFormat = aFormats[ n ].get();
         if (!pFormat)
             continue;
-        pChg->Set(n, pFormat->MakeNumFormat(rSh));
+        rNumRule.Set(n, pFormat->MakeNumFormat(rSh));
     }
-    return pChg;
 }
 
 void SwNumRulesWithName::GetNumFormat(
diff --git a/sw/source/uibase/inc/uinums.hxx b/sw/source/uibase/inc/uinums.hxx
index 7da897aa5860..0ba7d3f59525 100644
--- a/sw/source/uibase/inc/uinums.hxx
+++ b/sw/source/uibase/inc/uinums.hxx
@@ -72,7 +72,7 @@ public:
     SwNumRulesWithName &operator=(const SwNumRulesWithName &);
 
     const OUString& GetName() const               { return maName; }
-    std::unique_ptr<SwNumRule> MakeNumRule(SwWrtShell& rSh) const;
+    void ResetNumRule(SwWrtShell& rSh, SwNumRule& ) const;
 
     void GetNumFormat(size_t, SwNumFormat const*&, OUString const*&) const;
 };
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to