Change in core[master]: Removing useless SwTableBox_Impl from Writter

Arnaud Versini (via Code Review) gerrit at gerrit.libreoffice.org
Sun Jan 27 07:04:10 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1885

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/85/1885/1

Removing useless SwTableBox_Impl from Writter

Change-Id: I2cb471e9b0784673deb75beb7d403b136fbce500
---
M sw/inc/swtable.hxx
M sw/source/core/table/swtable.cxx
2 files changed, 31 insertions(+), 87 deletions(-)



diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 81f2696..1074aae 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -53,7 +53,6 @@
 class SwUndoTblMerge;
 class SwUndo;
 class SwPaM;
-class SwTableBox_Impl;
 class SwUndoTblCpyTbl;
 class SwBoxSelection;
 struct SwSaveRowSpan;
@@ -391,7 +390,10 @@
     SwTableLines aLines;
     const SwStartNode * pSttNd;
     SwTableLine *pUpper;
-    SwTableBox_Impl* pImpl;
+
+    Color *pSaveUserColor, *pSaveNumFmtColor;
+    long nRowSpan;
+    bool bDummyFlag;
 
     // In case Format contains formulas/values already,
     // a new one must be created for the new box.
@@ -400,7 +402,7 @@
 public:
     TYPEINFO();
 
-    SwTableBox() : pSttNd(0), pUpper(0), pImpl(0) {}
+    SwTableBox() : pSttNd(0), pUpper(0), pSaveUserColor(0), pSaveNumFmtColor(0), nRowSpan(1), bDummyFlag(false) {}
 
     SwTableBox( SwTableBoxFmt*, sal_uInt16 nLines, SwTableLine *pUp = 0 );
     SwTableBox( SwTableBoxFmt*, const SwStartNode&, SwTableLine *pUp = 0 );
@@ -457,15 +459,15 @@
     DECL_FIXEDMEMPOOL_NEWDEL(SwTableBox)
 
     // Access on internal data - currently used for the NumFormatter.
-    inline const Color* GetSaveUserColor()  const;
-    inline const Color* GetSaveNumFmtColor() const;
+    inline const Color* GetSaveUserColor()  const { return pSaveUserColor; }
+    inline const Color* GetSaveNumFmtColor() const { return pSaveNumFmtColor; }
     inline void SetSaveUserColor(const Color* p );
     inline void SetSaveNumFmtColor( const Color* p );
 
-    long getRowSpan() const;
-    void setRowSpan( long nNewRowSpan );
-    bool getDummyFlag() const;
-    void setDummyFlag( bool bDummy );
+    long getRowSpan() const {return nRowSpan;}
+    void setRowSpan( long nNewRowSpan ) { nRowSpan = nNewRowSpan;}
+    bool getDummyFlag() const { return bDummyFlag;}
+    void setDummyFlag( bool bDummy ) { bDummyFlag = bDummy;}
 
     SwTableBox& FindStartOfRowSpan( const SwTable&, sal_uInt16 nMaxStep = USHRT_MAX );
     const SwTableBox& FindStartOfRowSpan( const SwTable& rTable,
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 466ed90..3b7d192 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -81,86 +81,18 @@
                     sal_Bool bChgAlign,sal_uLong nNdPos );
 //----------------------------------
 
-class SwTableBox_Impl
-{
-    Color *mpUserColor, *mpNumFmtColor;
-    long mnRowSpan;
-    bool mbDummyFlag;
-
-    void SetNewCol( Color** ppCol, const Color* pNewCol );
-public:
-    SwTableBox_Impl() : mpUserColor(0), mpNumFmtColor(0), mnRowSpan(1),
-        mbDummyFlag( false ) {}
-    ~SwTableBox_Impl() { delete mpUserColor; delete mpNumFmtColor; }
-
-    const Color* GetSaveUserColor() const       { return mpUserColor; }
-    const Color* GetSaveNumFmtColor() const     { return mpNumFmtColor; }
-    void SetSaveUserColor(const Color* p )      { SetNewCol( &mpUserColor, p ); }
-    void SetSaveNumFmtColor( const Color* p )   { SetNewCol( &mpNumFmtColor, p ); }
-    long getRowSpan() const { return mnRowSpan; }
-    void setRowSpan( long nNewRowSpan ) { mnRowSpan = nNewRowSpan; }
-    bool getDummyFlag() const { return mbDummyFlag; }
-    void setDummyFlag( bool bDummy ) { mbDummyFlag = bDummy; }
-};
+static void lcl_SetNewColor(Color** ppCol, const Color* pNewCol);
 
 // ----------- Inlines -----------------------------
 
-inline const Color* SwTableBox::GetSaveUserColor() const
+inline void SwTableBox::SetSaveUserColor(const Color* pNewColor )
 {
-    return pImpl ? pImpl->GetSaveUserColor() : 0;
+    lcl_SetNewColor(&pSaveUserColor, pNewColor);
 }
 
-inline const Color* SwTableBox::GetSaveNumFmtColor() const
+inline void SwTableBox::SetSaveNumFmtColor( const Color* pNewColor )
 {
-    return pImpl ? pImpl->GetSaveNumFmtColor() : 0;
-}
-
-inline void SwTableBox::SetSaveUserColor(const Color* p )
-{
-    if( pImpl )
-        pImpl->SetSaveUserColor( p );
-    else if( p )
-        ( pImpl = new SwTableBox_Impl ) ->SetSaveUserColor( p );
-}
-
-inline void SwTableBox::SetSaveNumFmtColor( const Color* p )
-{
-    if( pImpl )
-        pImpl->SetSaveNumFmtColor( p );
-    else if( p )
-        ( pImpl = new SwTableBox_Impl )->SetSaveNumFmtColor( p );
-}
-
-long SwTableBox::getRowSpan() const
-{
-    return pImpl ? pImpl->getRowSpan() : 1;
-}
-
-void SwTableBox::setRowSpan( long nNewRowSpan )
-{
-    if( !pImpl )
-    {
-        if( nNewRowSpan == 1 )
-            return;
-        pImpl = new SwTableBox_Impl();
-    }
-    pImpl->setRowSpan( nNewRowSpan );
-}
-
-bool SwTableBox::getDummyFlag() const
-{
-    return pImpl ? pImpl->getDummyFlag() : false;
-}
-
-void SwTableBox::setDummyFlag( bool bDummy )
-{
-    if( !pImpl )
-    {
-        if( !bDummy )
-            return;
-        pImpl = new SwTableBox_Impl();
-    }
-    pImpl->setDummyFlag( bDummy );
+    lcl_SetNewColor(&pSaveNumFmtColor, pNewColor);
 }
 
 //JP 15.09.98: Bug 55741 - Keep tabs (front and rear)
@@ -1681,7 +1613,10 @@
     aLines(),
     pSttNd( 0 ),
     pUpper( pUp ),
-    pImpl( 0 )
+    pSaveUserColor(0),
+    pSaveNumFmtColor(0),
+    nRowSpan(1),
+    bDummyFlag(false)
 {
     aLines.reserve( (sal_uInt8)nLines );
     CheckBoxFmt( pFmt )->Add( this );
@@ -1692,7 +1627,10 @@
     : SwClient( 0 ),
     aLines(),
     pUpper( pUp ),
-    pImpl( 0 )
+    pSaveUserColor(0),
+    pSaveNumFmtColor(0),
+    nRowSpan(1),
+    bDummyFlag(false)
 {
     CheckBoxFmt( pFmt )->Add( this );
 
@@ -1712,7 +1650,10 @@
     aLines(),
     pSttNd( &rSttNd ),
     pUpper( pUp ),
-    pImpl( 0 )
+    pSaveUserColor(0),
+    pSaveNumFmtColor(0),
+    nRowSpan(1),
+    bDummyFlag(false)
 {
     CheckBoxFmt( pFmt )->Add( this );
 
@@ -1753,7 +1694,8 @@
     if( !pMod->GetDepends() )
         delete pMod;    // and delete
 
-    delete pImpl;
+    delete pSaveUserColor;
+    delete pSaveNumFmtColor;
 }
 
 SwTableBoxFmt* SwTableBox::CheckBoxFmt( SwTableBoxFmt* pFmt )
@@ -2608,7 +2550,7 @@
     }
 }
 
-void SwTableBox_Impl::SetNewCol( Color** ppCol, const Color* pNewCol )
+static void lcl_SetNewColor( Color** ppCol, const Color* pNewCol )
 {
     if( *ppCol != pNewCol )
     {

-- 
To view, visit https://gerrit.libreoffice.org/1885
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cb471e9b0784673deb75beb7d403b136fbce500
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Arnaud Versini <arnaud.versini at gmail.com>


More information about the LibreOffice mailing list