summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorValentin Kettner <vakevk+libreoffice@gmail.com>2014-06-23 14:56:59 +0200
committerValentin Kettner <vakevk+libreoffice@gmail.com>2014-07-15 15:44:03 +0200
commitc8a8695d4d82a8ff66cb2f03f52dbc664264bf69 (patch)
tree22958a09f48e2a5bd20ca72bfbdae77f8c6a47b3 /sw/source
parent54ca3a6efa89eb2222abf0a51597074be25ce322 (diff)
Refactored IDocumentListItems out of SwDoc.
Into the new class DocumentListItemsManager. Change-Id: Ic86200280caa1b6e2c940bb12149235223ed0cd2
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/DocumentListItemsManager.cxx121
-rw-r--r--sw/source/core/doc/doc.cxx12
-rw-r--r--sw/source/core/doc/docnew.cxx7
-rw-r--r--sw/source/core/doc/docnum.cxx79
-rw-r--r--sw/source/core/docnode/node.cxx2
-rw-r--r--sw/source/core/inc/DocumentListItemsManager.hxx69
-rw-r--r--sw/source/core/view/viewsh.cxx2
7 files changed, 206 insertions, 86 deletions
diff --git a/sw/source/core/doc/DocumentListItemsManager.cxx b/sw/source/core/doc/DocumentListItemsManager.cxx
new file mode 100644
index 000000000000..5844fd27abed
--- /dev/null
+++ b/sw/source/core/doc/DocumentListItemsManager.cxx
@@ -0,0 +1,121 @@
+/* -*- 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 <DocumentListItemsManager.hxx>
+#include <SwNodeNum.hxx>
+#include <ndtxt.hxx>
+
+
+namespace sw
+{
+
+DocumentListItemsManager::DocumentListItemsManager() : mpListItemsList( new tImplSortedNodeNumList() ) // #i83479#
+{
+}
+
+bool DocumentListItemsManager::lessThanNodeNum::operator()( const SwNodeNum* pNodeNumOne,
+ const SwNodeNum* pNodeNumTwo ) const
+{
+ return pNodeNumOne->LessThan( *pNodeNumTwo );
+}
+
+void DocumentListItemsManager::addListItem( const SwNodeNum& rNodeNum )
+{
+ if ( mpListItemsList == 0 )
+ {
+ return;
+ }
+
+ const bool bAlreadyInserted(
+ mpListItemsList->find( &rNodeNum ) != mpListItemsList->end() );
+ OSL_ENSURE( !bAlreadyInserted,
+ "<DocumentListItemsManager::addListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
+ if ( !bAlreadyInserted )
+ {
+ mpListItemsList->insert( &rNodeNum );
+ }
+}
+
+void DocumentListItemsManager::removeListItem( const SwNodeNum& rNodeNum )
+{
+ if ( mpListItemsList == 0 )
+ {
+ return;
+ }
+
+ const tImplSortedNodeNumList::size_type nDeleted = mpListItemsList->erase( &rNodeNum );
+ if ( nDeleted > 1 )
+ {
+ OSL_FAIL( "<DocumentListItemsManager::removeListItem(..)> - <SwNodeNum> was registered more than once as numbered item!" );
+ }
+}
+
+OUString DocumentListItemsManager::getListItemText( const SwNodeNum& rNodeNum,
+ const bool bWithNumber,
+ const bool bWithSpacesForLevel ) const
+{
+ return rNodeNum.GetTxtNode()
+ ? rNodeNum.GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
+ bWithNumber, bWithSpacesForLevel )
+ : OUString();
+}
+
+void DocumentListItemsManager::getListItems( tSortedNodeNumList& orNodeNumList ) const
+{
+ orNodeNumList.clear();
+ orNodeNumList.reserve( mpListItemsList->size() );
+
+ tImplSortedNodeNumList::iterator aIter;
+ tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
+ for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
+ {
+ orNodeNumList.push_back( (*aIter) );
+ }
+}
+
+void DocumentListItemsManager::getNumItems( tSortedNodeNumList& orNodeNumList ) const
+{
+ orNodeNumList.clear();
+ orNodeNumList.reserve( mpListItemsList->size() );
+
+ tImplSortedNodeNumList::iterator aIter;
+ tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
+ for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
+ {
+ const SwNodeNum* pNodeNum = (*aIter);
+ if ( pNodeNum->IsCounted() &&
+ pNodeNum->GetTxtNode() && pNodeNum->GetTxtNode()->HasNumber() )
+ {
+ orNodeNumList.push_back( pNodeNum );
+ }
+ }
+}
+
+DocumentListItemsManager::~DocumentListItemsManager()
+{
+// #i83479#
+delete mpListItemsList;
+mpListItemsList = 0;
+}
+
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 6966696c88be..e5535fcf1925 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -24,6 +24,7 @@
#include <DocumentDeviceManager.hxx>
#include <DocumentChartDataProviderManager.hxx>
#include <DocumentLinksAdministrationManager.hxx>
+#include <DocumentListItemsManager.hxx>
#include <UndoManager.hxx>
#include <hintids.hxx>
#include <tools/shl.hxx>
@@ -303,6 +304,17 @@ IDocumentLinksAdministration & SwDoc::getIDocumentLinksAdministration()
return *m_pDocumentLinksAdministrationManager;
}
+//IDocumentListItems
+IDocumentListItems const & SwDoc::getIDocumentListItems() const
+{
+ return *m_pDocumentListItemsManager;
+}
+
+//IDocumentListItems
+IDocumentListItems & SwDoc::getIDocumentListItems()
+{
+ return *m_pDocumentListItemsManager;
+}
/* Implementations the next Interface here */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index a6344a0b177c..55baed135392 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -93,6 +93,7 @@
#include <DocumentChartDataProviderManager.hxx>
#include <DocumentTimerManager.hxx>
#include <DocumentLinksAdministrationManager.hxx>
+#include <DocumentListItemsManager.hxx>
#include <unochart.hxx>
#include <fldbas.hxx>
@@ -202,6 +203,7 @@ SwDoc::SwDoc()
m_pDeviceAccess( new ::sw::DocumentDeviceManager( *this ) ),
m_pDocumentTimerManager( new ::sw::DocumentTimerManager( *this ) ),
m_pDocumentLinksAdministrationManager( new ::sw::DocumentLinksAdministrationManager( *this ) ),
+ m_pDocumentListItemsManager( new ::sw::DocumentListItemsManager() ),
mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -245,7 +247,6 @@ SwDoc::SwDoc()
mpLayoutCache( 0 ),
mpUnoCallBack(new SwModify(0)),
mpGrammarContact(createGrammarContact()),
- mpListItemsList( new tImplSortedNodeNumList() ), // #i83479#
m_pXmlIdRegistry(),
mnAutoFmtRedlnCommentNo( 0 ),
meRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
@@ -436,10 +437,6 @@ SwDoc::~SwDoc()
mpDocShell->SetUndoManager(0);
}
- // #i83479#
- delete mpListItemsList;
- mpListItemsList = 0;
-
delete mpGrammarContact;
mpGrammarContact = 0;
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index bf7b4f2ccb7e..35944bd4cfc7 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2325,85 +2325,6 @@ bool SwDoc::IsFirstOfNumRuleAtPos( const SwPosition & rPos )
return bResult;
}
-// implementation for interface <IDocumentListItems>
-bool SwDoc::lessThanNodeNum::operator()( const SwNodeNum* pNodeNumOne,
- const SwNodeNum* pNodeNumTwo ) const
-{
- return pNodeNumOne->LessThan( *pNodeNumTwo );
-}
-
-void SwDoc::addListItem( const SwNodeNum& rNodeNum )
-{
- if ( mpListItemsList == 0 )
- {
- return;
- }
-
- const bool bAlreadyInserted(
- mpListItemsList->find( &rNodeNum ) != mpListItemsList->end() );
- OSL_ENSURE( !bAlreadyInserted,
- "<SwDoc::InsertListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
- if ( !bAlreadyInserted )
- {
- mpListItemsList->insert( &rNodeNum );
- }
-}
-
-void SwDoc::removeListItem( const SwNodeNum& rNodeNum )
-{
- if ( mpListItemsList == 0 )
- {
- return;
- }
-
- const tImplSortedNodeNumList::size_type nDeleted = mpListItemsList->erase( &rNodeNum );
- if ( nDeleted > 1 )
- {
- OSL_FAIL( "<SwDoc::RemoveListItem(..)> - <SwNodeNum> was registered more than once as numbered item!" );
- }
-}
-
-OUString SwDoc::getListItemText( const SwNodeNum& rNodeNum,
- const bool bWithNumber,
- const bool bWithSpacesForLevel ) const
-{
- return rNodeNum.GetTxtNode()
- ? rNodeNum.GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
- bWithNumber, bWithSpacesForLevel )
- : OUString();
-}
-
-void SwDoc::getListItems( tSortedNodeNumList& orNodeNumList ) const
-{
- orNodeNumList.clear();
- orNodeNumList.reserve( mpListItemsList->size() );
-
- tImplSortedNodeNumList::iterator aIter;
- tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
- for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
- {
- orNodeNumList.push_back( (*aIter) );
- }
-}
-
-void SwDoc::getNumItems( tSortedNodeNumList& orNodeNumList ) const
-{
- orNodeNumList.clear();
- orNodeNumList.reserve( mpListItemsList->size() );
-
- tImplSortedNodeNumList::iterator aIter;
- tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
- for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
- {
- const SwNodeNum* pNodeNum = (*aIter);
- if ( pNodeNum->IsCounted() &&
- pNodeNum->GetTxtNode() && pNodeNum->GetTxtNode()->HasNumber() )
- {
- orNodeNumList.push_back( pNodeNum );
- }
- }
-}
-
// implementation for interface <IDocumentOutlineNodes>
sal_Int32 SwDoc::getOutlineNodesCount() const
{
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index e3d2fa811fb7..c2278295c0cb 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1933,7 +1933,7 @@ IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return
const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return GetDoc(); }
IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return GetDoc(); }
IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return GetDoc(); }
-IDocumentListItems& SwNode::getIDocumentListItems() { return *GetDoc(); } // #i83479#
+IDocumentListItems& SwNode::getIDocumentListItems() { return GetDoc()->getIDocumentListItems(); } // #i83479#
const IDocumentMarkAccess* SwNode::getIDocumentMarkAccess() const { return GetDoc()->getIDocumentMarkAccess(); }
IStyleAccess& SwNode::getIDocumentStyleAccess() { return GetDoc()->GetIStyleAccess(); }
diff --git a/sw/source/core/inc/DocumentListItemsManager.hxx b/sw/source/core/inc/DocumentListItemsManager.hxx
new file mode 100644
index 000000000000..c292967b13d0
--- /dev/null
+++ b/sw/source/core/inc/DocumentListItemsManager.hxx
@@ -0,0 +1,69 @@
+/* -*- 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_DOCUMENTLISTITEMSMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX
+
+#include <IDocumentListItems.hxx>
+#include <boost/utility.hpp>
+#include <set>
+
+namespace sw
+{
+
+class DocumentListItemsManager : public IDocumentListItems,
+ public ::boost::noncopyable
+{
+public:
+
+ DocumentListItemsManager();
+
+ void addListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
+ void removeListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
+
+ OUString getListItemText( const SwNodeNum& rNodeNum,
+ const bool bWithNumber = true,
+ const bool bWithSpacesForLevel = false ) const SAL_OVERRIDE;
+
+ void getListItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
+
+ void getNumItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
+
+ virtual ~DocumentListItemsManager();
+
+
+ //Non Interface
+ struct lessThanNodeNum
+ {
+ bool operator()( const SwNodeNum* pNodeNumOne,
+ const SwNodeNum* pNodeNumTwo ) const;
+ };
+
+ typedef ::std::set< const SwNodeNum*, lessThanNodeNum > tImplSortedNodeNumList;
+
+private:
+
+ tImplSortedNodeNumList* mpListItemsList;
+};
+
+}
+
+ #endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 1b6b1e594536..9acfa7857aee 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2540,7 +2540,7 @@ IDocumentUndoRedo const& SwViewShell::GetIDocumentUndoRedo() const
// --> OD 2007-11-14 #i83479#
const IDocumentListItems* SwViewShell::getIDocumentListItemsAccess() const
{
- return mpDoc;
+ return &mpDoc->getIDocumentListItems();
}
const IDocumentOutlineNodes* SwViewShell::getIDocumentOutlineNodesAccess() const