[Libreoffice-commits] core.git: sw/inc sw/source

Jan Holesovsky kendy at collabora.com
Mon Sep 28 05:12:28 PDT 2015


 sw/inc/swtable.hxx               |    9 +-
 sw/source/core/table/swtable.cxx |  124 +++++++++++++--------------------------
 2 files changed, 50 insertions(+), 83 deletions(-)

New commits:
commit 48639c150fed12a0c8d520e1a8f084fadbedc4a6
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Sep 28 11:50:20 2015 +0200

    sw table styles: Kill useless SwTableBox_Impl.
    
    Change-Id: If987793fb113039e6a1e254592afa958761c68a0

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 14e31c8..784b398 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -54,7 +54,6 @@ class SfxPoolItem;
 class SwUndoTableMerge;
 class SwUndo;
 class SwPaM;
-class SwTableBox_Impl;
 class SwUndoTableCpyTable;
 class SwBoxSelection;
 struct SwSaveRowSpan;
@@ -395,7 +394,11 @@ class SW_DLLPUBLIC SwTableBox: public SwClient      //Client of FrameFormat.
     SwTableLines aLines;
     const SwStartNode * pSttNd;
     SwTableLine *pUpper;
-    SwTableBox_Impl* pImpl;
+
+    std::unique_ptr<Color> mpUserColor;
+    std::unique_ptr<Color> mpNumFormatColor;
+    long mnRowSpan;
+    bool mbDummyFlag;
 
     /// Do we contain any direct formatting?
     bool mbDirectFormatting;
@@ -407,7 +410,7 @@ class SW_DLLPUBLIC SwTableBox: public SwClient      //Client of FrameFormat.
 public:
     TYPEINFO_OVERRIDE();
 
-    SwTableBox() : pSttNd(0), pUpper(0), pImpl(0), mbDirectFormatting(false) {}
+    SwTableBox();
 
     SwTableBox( SwTableBoxFormat*, sal_uInt16 nLines, SwTableLine *pUp = 0 );
     SwTableBox( SwTableBoxFormat*, const SwStartNode&, SwTableLine *pUp = 0 );
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index a3dfb89f..7004466 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -81,84 +81,50 @@ TYPEINIT1( SwTableLineFormat, SwFrameFormat );
 void ChgTextToNum( SwTableBox& rBox, const OUString& rText, const Color* pCol,
                     bool bChgAlign, sal_uLong nNdPos );
 
-class SwTableBox_Impl
-{
-    Color *mpUserColor, *mpNumFormatColor;
-    long mnRowSpan;
-    bool mbDummyFlag;
-
-    static void SetNewCol( Color** ppCol, const Color* pNewCol );
-public:
-    SwTableBox_Impl() : mpUserColor(0), mpNumFormatColor(0), mnRowSpan(1),
-        mbDummyFlag( false ) {}
-    ~SwTableBox_Impl() { delete mpUserColor; delete mpNumFormatColor; }
-
-    const Color* GetSaveUserColor() const       { return mpUserColor; }
-    const Color* GetSaveNumFormatColor() const     { return mpNumFormatColor; }
-    void SetSaveUserColor(const Color* p )      { SetNewCol( &mpUserColor, p ); }
-    void SetSaveNumFormatColor( const Color* p )   { SetNewCol( &mpNumFormatColor, p ); }
-    long getRowSpan() const { return mnRowSpan; }
-    void setRowSpan( long nNewRowSpan ) { mnRowSpan = nNewRowSpan; }
-    bool getDummyFlag() const { return mbDummyFlag; }
-    void setDummyFlag( bool bDummy ) { mbDummyFlag = bDummy; }
-};
-
 inline const Color* SwTableBox::GetSaveUserColor() const
 {
-    return pImpl ? pImpl->GetSaveUserColor() : 0;
+    return mpUserColor.get();
 }
 
 inline const Color* SwTableBox::GetSaveNumFormatColor() const
 {
-    return pImpl ? pImpl->GetSaveNumFormatColor() : 0;
+    return mpNumFormatColor.get();
 }
 
 inline void SwTableBox::SetSaveUserColor(const Color* p )
 {
-    if( pImpl )
-        pImpl->SetSaveUserColor( p );
-    else if( p )
-        ( pImpl = new SwTableBox_Impl ) ->SetSaveUserColor( p );
+    if (p)
+        mpUserColor.reset(new Color(*p));
+    else
+        mpUserColor.reset(nullptr);
 }
 
 inline void SwTableBox::SetSaveNumFormatColor( const Color* p )
 {
-    if( pImpl )
-        pImpl->SetSaveNumFormatColor( p );
-    else if( p )
-        ( pImpl = new SwTableBox_Impl )->SetSaveNumFormatColor( p );
+    if (p)
+        mpNumFormatColor.reset(new Color(*p));
+    else
+        mpNumFormatColor.reset(nullptr);
 }
 
 long SwTableBox::getRowSpan() const
 {
-    return pImpl ? pImpl->getRowSpan() : 1;
+    return mnRowSpan;
 }
 
 void SwTableBox::setRowSpan( long nNewRowSpan )
 {
-    if( !pImpl )
-    {
-        if( nNewRowSpan == 1 )
-            return;
-        pImpl = new SwTableBox_Impl();
-    }
-    pImpl->setRowSpan( nNewRowSpan );
+    mnRowSpan = nNewRowSpan;
 }
 
 bool SwTableBox::getDummyFlag() const
 {
-    return pImpl && pImpl->getDummyFlag();
+    return mbDummyFlag;
 }
 
 void SwTableBox::setDummyFlag( bool bDummy )
 {
-    if( !pImpl )
-    {
-        if( !bDummy )
-            return;
-        pImpl = new SwTableBox_Impl();
-    }
-    pImpl->setDummyFlag( bDummy );
+    mbDummyFlag = bDummy;
 }
 
 //JP 15.09.98: Bug 55741 - Keep tabs (front and rear)
@@ -1645,13 +1611,23 @@ SwTwips SwTableLine::GetTableLineHeight( bool& bLayoutAvailable ) const
     return nRet;
 }
 
+SwTableBox::SwTableBox()
+    : pSttNd(0)
+    , pUpper(0)
+    , mnRowSpan(1)
+    , mbDummyFlag(false)
+    , mbDirectFormatting(false)
+{
+}
+
 SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, sal_uInt16 nLines, SwTableLine *pUp )
-    : SwClient( 0 ),
-    aLines(),
-    pSttNd( 0 ),
-    pUpper( pUp ),
-    pImpl( 0 ),
-    mbDirectFormatting(false)
+    : SwClient(0)
+    , aLines()
+    , pSttNd(0)
+    , pUpper(pUp)
+    , mnRowSpan(1)
+    , mbDummyFlag(false)
+    , mbDirectFormatting(false)
 {
     aLines.reserve( nLines );
     CheckBoxFormat( pFormat )->Add( this );
@@ -1659,11 +1635,12 @@ SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, sal_uInt16 nLines, SwTableLin
 
 SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, const SwNodeIndex &rIdx,
                         SwTableLine *pUp )
-    : SwClient( 0 ),
-    aLines(),
-    pUpper( pUp ),
-    pImpl( 0 ),
-    mbDirectFormatting(false)
+    : SwClient(0)
+    , aLines()
+    , pUpper(pUp)
+    , mnRowSpan(1)
+    , mbDummyFlag(false)
+    , mbDirectFormatting(false)
 {
     CheckBoxFormat( pFormat )->Add( this );
 
@@ -1678,13 +1655,14 @@ SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, const SwNodeIndex &rIdx,
     rSrtArr.insert( p );        // insert
 }
 
-SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, const SwStartNode& rSttNd, SwTableLine *pUp ) :
-    SwClient( 0 ),
-    aLines(),
-    pSttNd( &rSttNd ),
-    pUpper( pUp ),
-    pImpl( 0 ),
-    mbDirectFormatting(false)
+SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, const SwStartNode& rSttNd, SwTableLine *pUp )
+    : SwClient(0)
+    , aLines()
+    , pSttNd(&rSttNd)
+    , pUpper(pUp)
+    , mnRowSpan(1)
+    , mbDummyFlag(false)
+    , mbDirectFormatting(false)
 {
     CheckBoxFormat( pFormat )->Add( this );
 
@@ -1724,8 +1702,6 @@ SwTableBox::~SwTableBox()
     pMod->Remove( this );               // remove,
     if( !pMod->HasWriterListeners() )
         delete pMod;    // and delete
-
-    delete pImpl;
 }
 
 SwTableBoxFormat* SwTableBox::CheckBoxFormat( SwTableBoxFormat* pFormat )
@@ -2593,18 +2569,6 @@ void SwTableBox::ActualiseValueBox()
     }
 }
 
-void SwTableBox_Impl::SetNewCol( Color** ppCol, const Color* pNewCol )
-{
-    if( *ppCol != pNewCol )
-    {
-        delete *ppCol;
-        if( pNewCol )
-            *ppCol = new Color( *pNewCol );
-        else
-            *ppCol = 0;
-    }
-}
-
 struct SwTableCellInfo::Impl
 {
     const SwTable * m_pTable;


More information about the Libreoffice-commits mailing list