[Libreoffice-commits] core.git: Branch 'feature/refactor-god-objects' - sw/inc sw/Library_sw.mk sw/source

Valentin Kettner vakevk+libreoffice at gmail.com
Mon Jun 30 12:00:22 PDT 2014


 sw/Library_sw.mk                                   |    1 
 sw/inc/doc.hxx                                     |   15 +---
 sw/source/core/doc/DocumentOutlineNodesManager.cxx |   76 +++++++++++++++++++++
 sw/source/core/doc/doc.cxx                         |   12 +++
 sw/source/core/doc/docnew.cxx                      |    2 
 sw/source/core/doc/docnum.cxx                      |   41 -----------
 sw/source/core/inc/DocumentOutlineNodesManager.hxx |   61 ++++++++++++++++
 sw/source/core/text/EnhancedPDFExportHelper.cxx    |    1 
 sw/source/core/view/viewsh.cxx                     |    3 
 sw/source/uibase/utlui/content.cxx                 |    1 
 10 files changed, 161 insertions(+), 52 deletions(-)

New commits:
commit c0a5feffea7e8630ceb11eef261507be3f1fa622
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date:   Mon Jun 30 20:58:00 2014 +0200

    Refactored IDocumentOutlineNodes out of SwDoc.
    
    Into the new class DocumentOutlineNodesManager.
    
    Change-Id: I05581391a1474872113ae91d6429709d181cabfe

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 855c17f..0f5d0a4 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -192,6 +192,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/doc/DocumentLinksAdministrationManager \
     sw/source/core/doc/DocumentListItemsManager \
     sw/source/core/doc/DocumentListsManager \
+    sw/source/core/doc/DocumentOutlineNodesManager \
     sw/source/core/doc/extinput \
     sw/source/core/doc/fmtcol \
     sw/source/core/doc/ftnidx \
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5d53f7a..ab74b4e 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -30,7 +30,6 @@
 #include <IDocumentStatistics.hxx>
 #include <IDocumentState.hxx>
 #include <IDocumentLayoutAccess.hxx>
-#include <IDocumentOutlineNodes.hxx>
 #include <IDocumentExternalData.hxx>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
@@ -193,6 +192,7 @@ class IDocumentTimerAccess;
 class IDocumentLinksAdministration;
 class IDocumentListItems;
 class IDocumentListsAccess;
+class IDocumentOutlineNodes;
 class _SetGetExpFlds;
 
 namespace sw { namespace mark {
@@ -210,6 +210,7 @@ namespace sw {
     class DocumentLinksAdministrationManager;
     class DocumentListItemsManager;
     class DocumentListsManager;
+    class DocumentOutlineNodesManager;
 }
 
 namespace com { namespace sun { namespace star {
@@ -255,7 +256,6 @@ class SW_DLLPUBLIC SwDoc :
     public IDocumentStatistics,
     public IDocumentState,
     public IDocumentLayoutAccess,
-    public IDocumentOutlineNodes,
     public IDocumentExternalData
 {
 
@@ -291,6 +291,7 @@ class SW_DLLPUBLIC SwDoc :
     const ::boost::scoped_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager;
     const ::boost::scoped_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
     const ::boost::scoped_ptr< ::sw::DocumentListsManager > m_pDocumentListsManager;
+    const ::boost::scoped_ptr< ::sw::DocumentOutlineNodesManager > m_pDocumentOutlineNodesManager;
 
     // Pointer
     SwFrmFmt        *mpDfltFrmFmt;       //< Default formats.
@@ -763,14 +764,8 @@ public:
     IDocumentListItems & getIDocumentListItems();
 
     // IDocumentOutlineNodes
-    virtual sal_Int32 getOutlineNodesCount() const SAL_OVERRIDE;
-    virtual int getOutlineLevel( const sal_Int32 nIdx ) const SAL_OVERRIDE;
-    virtual OUString getOutlineText( const sal_Int32 nIdx,
-                                   const bool bWithNumber,
-                                   const bool bWithSpacesForLevel,
-                                   const bool bWithFtn ) const SAL_OVERRIDE;
-    virtual SwTxtNode* getOutlineNode( const sal_Int32 nIdx ) const SAL_OVERRIDE;
-    virtual void getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const SAL_OVERRIDE;
+    IDocumentOutlineNodes const & getIDocumentOutlineNodes() const;
+    IDocumentOutlineNodes & getIDocumentOutlineNodes();
 
     // IDocumentListsAccess
     IDocumentListsAccess const & getIDocumentListsAccess() const;
diff --git a/sw/source/core/doc/DocumentOutlineNodesManager.cxx b/sw/source/core/doc/DocumentOutlineNodesManager.cxx
new file mode 100644
index 0000000..a967b90
--- /dev/null
+++ b/sw/source/core/doc/DocumentOutlineNodesManager.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <DocumentOutlineNodesManager.hxx>
+#include <doc.hxx>
+#include <ndtxt.hxx>
+
+namespace sw
+{
+
+DocumentOutlineNodesManager::DocumentOutlineNodesManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc )
+{
+}
+
+sal_Int32 DocumentOutlineNodesManager::getOutlineNodesCount() const
+{
+    return m_rSwdoc.GetNodes().GetOutLineNds().size();
+}
+
+int DocumentOutlineNodesManager::getOutlineLevel( const sal_Int32 nIdx ) const
+{
+    return m_rSwdoc.GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->
+                                GetTxtNode()->GetAttrOutlineLevel()-1;
+}
+
+OUString DocumentOutlineNodesManager::getOutlineText( const sal_Int32 nIdx,
+                              const bool bWithNumber,
+                              const bool bWithSpacesForLevel,
+                              const bool bWithFtn ) const
+{
+    return m_rSwdoc.GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->
+                GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
+                                            bWithNumber, bWithSpacesForLevel, bWithFtn );
+}
+
+SwTxtNode* DocumentOutlineNodesManager::getOutlineNode( const sal_Int32 nIdx ) const
+{
+    return m_rSwdoc.GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->GetTxtNode();
+}
+
+void DocumentOutlineNodesManager::getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const
+{
+    orOutlineNodeList.clear();
+    orOutlineNodeList.reserve( getOutlineNodesCount() );
+
+    const sal_uInt16 nOutlCount( static_cast<sal_uInt16>(getOutlineNodesCount()) );
+    for ( sal_uInt16 i = 0; i < nOutlCount; ++i )
+    {
+        orOutlineNodeList.push_back(
+            m_rSwdoc.GetNodes().GetOutLineNds()[i]->GetTxtNode() );
+    }
+}
+
+DocumentOutlineNodesManager::~DocumentOutlineNodesManager()
+{
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 9ff3443..f4f54e2 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -26,6 +26,7 @@
 #include <DocumentLinksAdministrationManager.hxx>
 #include <DocumentListItemsManager.hxx>
 #include <DocumentListsManager.hxx>
+#include <DocumentOutlineNodesManager.hxx>
 #include <UndoManager.hxx>
 #include <hintids.hxx>
 
@@ -331,6 +332,17 @@ IDocumentListsAccess & SwDoc::getIDocumentListsAccess()
     return *m_pDocumentListsManager;
 }
 
+//IDocumentOutlinesNodes
+IDocumentOutlineNodes const & SwDoc::getIDocumentOutlineNodes() const
+{
+    return *m_pDocumentOutlineNodesManager;
+}
+
+IDocumentOutlineNodes & SwDoc::getIDocumentOutlineNodes()
+{
+    return *m_pDocumentOutlineNodesManager;
+}
+
 /* Implementations the next Interface here */
 
 /*
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 4cfd187..55f1951 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -95,6 +95,7 @@
 #include <DocumentLinksAdministrationManager.hxx>
 #include <DocumentListItemsManager.hxx>
 #include <DocumentListsManager.hxx>
+#include <DocumentOutlineNodesManager.hxx>
 #include <unochart.hxx>
 #include <fldbas.hxx>
 
@@ -202,6 +203,7 @@ SwDoc::SwDoc()
     m_pDocumentLinksAdministrationManager( new ::sw::DocumentLinksAdministrationManager( *this ) ),
     m_pDocumentListItemsManager( new ::sw::DocumentListItemsManager() ),
     m_pDocumentListsManager( new ::sw::DocumentListsManager( *this ) ),
+    m_pDocumentOutlineNodesManager( new ::sw::DocumentOutlineNodesManager( *this ) ),
     mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
     mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
     mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index e582dae..bc5880d 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2305,45 +2305,4 @@ bool SwDoc::IsFirstOfNumRuleAtPos( const SwPosition & rPos )
     return bResult;
 }
 
-// implementation for interface <IDocumentOutlineNodes>
-sal_Int32 SwDoc::getOutlineNodesCount() const
-{
-    return GetNodes().GetOutLineNds().size();
-}
-
-int SwDoc::getOutlineLevel( const sal_Int32 nIdx ) const
-{
-    return GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->
-                                GetTxtNode()->GetAttrOutlineLevel()-1;
-}
-
-OUString SwDoc::getOutlineText( const sal_Int32 nIdx,
-                              const bool bWithNumber,
-                              const bool bWithSpacesForLevel,
-                              const bool bWithFtn ) const
-{
-    return GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->
-                GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
-                                            bWithNumber, bWithSpacesForLevel, bWithFtn );
-}
-
-SwTxtNode* SwDoc::getOutlineNode( const sal_Int32 nIdx ) const
-{
-    return GetNodes().GetOutLineNds()[ static_cast<sal_uInt16>(nIdx) ]->GetTxtNode();
-}
-
-void SwDoc::getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const
-{
-    orOutlineNodeList.clear();
-    orOutlineNodeList.reserve( getOutlineNodesCount() );
-
-    const sal_uInt16 nOutlCount( static_cast<sal_uInt16>(getOutlineNodesCount()) );
-    for ( sal_uInt16 i = 0; i < nOutlCount; ++i )
-    {
-        orOutlineNodeList.push_back(
-            GetNodes().GetOutLineNds()[i]->GetTxtNode() );
-    }
-}
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/DocumentOutlineNodesManager.hxx b/sw/source/core/inc/DocumentOutlineNodesManager.hxx
new file mode 100644
index 0000000..96a42b8
--- /dev/null
+++ b/sw/source/core/inc/DocumentOutlineNodesManager.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTOUTLINENODESMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTOUTLINENODESMANAGER_HXX
+
+#include <IDocumentOutlineNodes.hxx>
+#include <boost/utility.hpp>
+
+class SwDoc;
+
+namespace sw
+{
+
+class DocumentOutlineNodesManager : public IDocumentOutlineNodes,
+                                    public ::boost::noncopyable
+{
+public:
+
+    DocumentOutlineNodesManager( SwDoc& i_rSwdoc );
+
+    //typedef ::std::vector< const SwTxtNode* > tSortedOutlineNodeList;
+
+    sal_Int32 getOutlineNodesCount() const SAL_OVERRIDE;
+
+    int getOutlineLevel( const sal_Int32 nIdx ) const SAL_OVERRIDE;
+    OUString getOutlineText( const sal_Int32 nIdx,
+                                  const bool bWithNumber = true,
+                                  const bool bWithSpacesForLevel = false,
+                                  const bool bWithFtn = true ) const SAL_OVERRIDE;
+    SwTxtNode* getOutlineNode( const sal_Int32 nIdx ) const SAL_OVERRIDE;
+    void getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const SAL_OVERRIDE;
+
+    ~DocumentOutlineNodesManager();
+
+private:
+
+    SwDoc& m_rSwdoc;
+};
+
+}
+
+#endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTOUTLINENODESMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 84c771d..b3960cc 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -49,6 +49,7 @@
 #include <txtfld.hxx>
 #include <reffld.hxx>
 #include <doc.hxx>
+#include <IDocumentOutlineNodes.hxx>
 #include <docary.hxx>
 #include <crsskip.hxx>
 #include <mdiexp.hxx>
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index b17ae5e..9c48d57 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -34,6 +34,7 @@
 #include <doc.hxx>
 #include <IDocumentDeviceAccess.hxx>
 #include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentOutlineNodes.hxx>
 #include <rootfrm.hxx>
 #include <pagefrm.hxx>
 #include <cntfrm.hxx>
@@ -2545,7 +2546,7 @@ const IDocumentListItems* SwViewShell::getIDocumentListItemsAccess() const
 
 const IDocumentOutlineNodes* SwViewShell::getIDocumentOutlineNodesAccess() const
 {
-    return mpDoc;
+    return &mpDoc->getIDocumentOutlineNodes();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index faf3371..dbbbaf9 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -48,6 +48,7 @@
 #include <edtwin.hxx>
 #include <doc.hxx>
 #include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentOutlineNodes.hxx>
 #include <unotools.hxx>
 #include <crsskip.hxx>
 #include <cmdid.h>


More information about the Libreoffice-commits mailing list