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

Lubos Lunak llunak at kemper.freedesktop.org
Fri Dec 9 06:40:33 PST 2011


 sw/inc/node.hxx                  |   29 +++++++++++++++++++++++++++--
 sw/source/core/docnode/nodes.cxx |   12 ++++++------
 2 files changed, 33 insertions(+), 8 deletions(-)

New commits:
commit 3dec8b847f3522cd037c861047fc536f1bdc6f8c
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Dec 9 15:36:47 2011 +0100

    make SwNode and SwCntntNode abstract base classes

diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index f50e65f..ec8f58f 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -114,7 +114,9 @@ protected:
     SwNode( SwNodes& rNodes, sal_uLong nPos, const sal_uInt8 nNodeId );
 
 public:
-    virtual ~SwNode();
+    // the = 0 forces the class to be an abstract base class, but the dtor can be still called
+    // from subclasses
+    virtual ~SwNode() = 0;
 
 #ifdef DBG_UTIL
     long GetSerial() const { return m_nSerial; }
@@ -387,7 +389,9 @@ class SW_DLLPUBLIC SwCntntNode: public SwModify, public SwNode, public SwIndexRe
 protected:
     SwCntntNode( const SwNodeIndex &rWhere, const sal_uInt8 nNodeType,
                 SwFmtColl *pFmtColl );
-    virtual ~SwCntntNode();
+    // the = 0 forces the class to be an abstract base class, but the dtor can be still called
+    // from subclasses
+    virtual ~SwCntntNode() = 0;
 
     //  Attribute-set for all auto attributes of a CntntNode.
     //  (e.g. TxtNode or NoTxtNode).
@@ -601,6 +605,21 @@ public:
 };
 
 
+//----------------
+// SwDummySectionNode
+//----------------
+
+// This class is internal. And quite frankly I don't know what ND_SECTIONDUMMY is for,
+// the class has been merely created to replace "SwNode( ND_SECTIONDUMMY )", the only case
+// of instantiating SwNode directly. Now SwNode can be an abstract base class.
+class SwDummySectionNode
+    : private SwNode
+{
+private:
+    friend class SwNodes;
+    SwDummySectionNode( const SwNodeIndex &rWhere );
+};
+
 
 inline       SwEndNode   *SwNode::GetEndNode()
 {
@@ -756,6 +775,12 @@ inline const SfxPoolItem& SwCntntNode::GetAttr( sal_uInt16 nWhich,
 {
     return GetSwAttrSet().Get( nWhich, bInParents );
 }
+
+inline SwDummySectionNode::SwDummySectionNode( const SwNodeIndex &rWhere )
+    : SwNode( rWhere, ND_SECTIONDUMMY )
+{
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 6d0e45b..dfc0e6f 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -653,7 +653,7 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
                         {
                             // im UndoNodes-Array spendieren wir einen
                             // Platzhalter
-                            new SwNode( aIdx, ND_SECTIONDUMMY );
+                            new SwDummySectionNode( aIdx );
                         }
                         else
                         {
@@ -728,7 +728,7 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
                     aIdx -= nInsPos;
                     nInsPos = 0;
                 }
-                new SwNode( aIdx, ND_SECTIONDUMMY );
+                new SwDummySectionNode( aIdx );
                 aRg.aEnd--;
                 aIdx--;
                 break;
@@ -1929,7 +1929,7 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange,
                 // dann alle Nodes der Tabelle in die akt. Zelle kopieren
                 // fuer den TabellenNode einen DummyNode einfuegen?
                 if( bTblInsDummyNode )
-                    new SwNode( aInsPos, ND_SECTIONDUMMY );
+                    new SwDummySectionNode( aInsPos );
 
                 for( aRg.aStart++; aRg.aStart.GetIndex() <
                     pAktNode->EndOfSectionIndex();
@@ -1937,7 +1937,7 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange,
                 {
                     // fuer den Box-StartNode einen DummyNode einfuegen?
                     if( bTblInsDummyNode )
-                        new SwNode( aInsPos, ND_SECTIONDUMMY );
+                        new SwDummySectionNode( aInsPos );
 
                     SwStartNode* pSttNd = aRg.aStart.GetNode().GetStartNode();
                     _CopyNodes( SwNodeRange( *pSttNd, + 1,
@@ -1946,12 +1946,12 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange,
 
                     // fuer den Box-EndNode einen DummyNode einfuegen?
                     if( bTblInsDummyNode )
-                        new SwNode( aInsPos, ND_SECTIONDUMMY );
+                        new SwDummySectionNode( aInsPos );
                     aRg.aStart = *pSttNd->EndOfSectionNode();
                 }
                 // fuer den TabellenEndNode einen DummyNode einfuegen?
                 if( bTblInsDummyNode )
-                    new SwNode( aInsPos, ND_SECTIONDUMMY );
+                    new SwDummySectionNode( aInsPos );
                 aRg.aStart = *pAktNode->EndOfSectionNode();
             }
             else


More information about the Libreoffice-commits mailing list