[Libreoffice-commits] .: lotuswordpro/source

Julien Nabet serval2412 at kemper.freedesktop.org
Mon Jul 16 13:55:56 PDT 2012


 lotuswordpro/source/filter/xfilter/xfparastyle.cxx |   86 ++++++++++-----------
 1 file changed, 45 insertions(+), 41 deletions(-)

New commits:
commit 00ae1cec08ae970f0640c0cc5d612eb0b9035207
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Mon Jul 16 22:54:38 2012 +0200

    Change form of checking self-assignment + cleaning before assigning
    
    Change-Id: Idc8e8445b870805b99d2b9434cf1f752c63cc6a0

diff --git a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
index 1bccbcd..64296a2 100644
--- a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
@@ -116,7 +116,7 @@ XFParaStyle::XFParaStyle(const XFParaStyle& other) : XFStyle(other)
     m_aLineHeight = other.m_aLineHeight;
     m_aPadding = other.m_aPadding;
     m_aBreaks = other.m_aBreaks;
-//  m_aTabs = other.m_aTabs;
+
     for (size_t i=0; i<other.m_aTabs.GetCount(); ++i)
     {
         const IXFStyle *pStyle = other.m_aTabs.Item(i);
@@ -135,52 +135,56 @@ XFParaStyle::XFParaStyle(const XFParaStyle& other) : XFStyle(other)
 XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
 {
     // Check for self-assignment
-    if (this == &other)
-        return *this;
-    m_strParentStyleName = other.m_strParentStyleName;
-    m_nFlag = other.m_nFlag;
-    m_eAlignType = other.m_eAlignType;
-    m_fTextIndent = other.m_fTextIndent;
-    m_bNumberLines = other.m_bNumberLines;
-    m_nLineNumberRestart = other.m_nLineNumberRestart;
-    m_bNumberRight = other.m_bNumberRight;
-
-    if( other.m_pFont )
-        m_pFont = other.m_pFont;
-    else
-        m_pFont = NULL;
-
-    if( other.m_pBorders )
-        m_pBorders = new XFBorders(*other.m_pBorders);
-    else
-        m_pBorders = NULL;
-    m_aBackColor = other.m_aBackColor;
-    if( other.m_pBGImage )
-        m_pBGImage = new XFBGImage(*other.m_pBGImage);
-    else
-        m_pBGImage = NULL;
-
-    m_aShadow = other.m_aShadow;
-    m_aMargin = other.m_aMargin;
-    m_aDropcap = other.m_aDropcap;
-    m_aLineHeight = other.m_aLineHeight;
-    m_aPadding = other.m_aPadding;
-    m_aBreaks = other.m_aBreaks;
-    //  m_aTabs = other.m_aTabs;
-    for (size_t i=0; i<other.m_aTabs.GetCount(); ++i)
+    if (this != &other)
     {
-        const IXFStyle *pStyle = other.m_aTabs.Item(i);
-        if( pStyle )
+        // first , clean member
+        delete(m_pBGImage);
+        m_aTabs.Reset();
+
+        m_strParentStyleName = other.m_strParentStyleName;
+        m_nFlag = other.m_nFlag;
+        m_eAlignType = other.m_eAlignType;
+        m_fTextIndent = other.m_fTextIndent;
+        m_bNumberLines = other.m_bNumberLines;
+        m_nLineNumberRestart = other.m_nLineNumberRestart;
+        m_bNumberRight = other.m_bNumberRight;
+
+        if( other.m_pFont )
+            m_pFont = other.m_pFont;
+        else
+            m_pFont = NULL;
+
+        if( other.m_pBorders )
+            m_pBorders = new XFBorders(*other.m_pBorders);
+        else
+            m_pBorders = NULL;
+        m_aBackColor = other.m_aBackColor;
+        if( other.m_pBGImage )
+            m_pBGImage = new XFBGImage(*other.m_pBGImage);
+        else
+            m_pBGImage = NULL;
+
+        m_aShadow = other.m_aShadow;
+        m_aMargin = other.m_aMargin;
+        m_aDropcap = other.m_aDropcap;
+        m_aLineHeight = other.m_aLineHeight;
+        m_aPadding = other.m_aPadding;
+        m_aBreaks = other.m_aBreaks;
+
+        for (size_t i=0; i<other.m_aTabs.GetCount(); ++i)
         {
-            const XFTabStyle *pTabStyle = dynamic_cast<const XFTabStyle*>(pStyle);
-            if( pTabStyle )
+            const IXFStyle *pStyle = other.m_aTabs.Item(i);
+            if( pStyle )
             {
-                XFTabStyle *pCopyStyle = new XFTabStyle(*pTabStyle);
-                m_aTabs.AddStyle(pCopyStyle);
+                const XFTabStyle *pTabStyle = dynamic_cast<const XFTabStyle*>(pStyle);
+                if( pTabStyle )
+                {
+                    XFTabStyle *pCopyStyle = new XFTabStyle(*pTabStyle);
+                    m_aTabs.AddStyle(pCopyStyle);
+                }
             }
         }
     }
-
     return *this;
 }
 


More information about the Libreoffice-commits mailing list