diff options
author | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-06-30 20:58:00 +0200 |
---|---|---|
committer | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-07-15 15:44:04 +0200 |
commit | 3fed83524dc33453f3ec25baa4a170bac51ab1e0 (patch) | |
tree | 7e5eda4650329bcb66efb735436774e48e866c65 /sw | |
parent | 87cb919c7ccf5aacda27b36781d5896eebbd182b (diff) |
Refactored IDocumentOutlineNodes out of SwDoc.
Into the new class DocumentOutlineNodesManager.
Change-Id: I05581391a1474872113ae91d6429709d181cabfe
Diffstat (limited to 'sw')
-rw-r--r-- | sw/Library_sw.mk | 1 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 15 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentOutlineNodesManager.cxx | 76 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 41 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentOutlineNodesManager.hxx | 61 | ||||
-rw-r--r-- | sw/source/core/text/EnhancedPDFExportHelper.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 1 |
10 files changed, 161 insertions, 52 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 1eca0dc9dafd..89562acf3e9b 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 feedc4a67d78..7b87e8fecff8 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 000000000000..a967b909313d --- /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 6640c93c5890..9bcb632b90a1 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> #include <tools/shl.hxx> @@ -328,6 +329,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 70e0611ddc12..b87afd210ef7 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> @@ -205,6 +206,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 e582daebf826..bc5880d220a2 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 000000000000..96a42b85e97e --- /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 84c771d38d29..b3960cc81794 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 9acfa7857aee..c368c3077baf 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 c69eea0125f9..6cc53dae0396 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> |