Refactored IDocumentListItems out of SwDoc.
Into the new class DocumentListItemsManager. Change-Id: Ic86200280caa1b6e2c940bb12149235223ed0cd2
This commit is contained in:
@@ -190,6 +190,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
|
||||
sw/source/core/doc/DocumentChartDataProviderManager \
|
||||
sw/source/core/doc/DocumentTimerManager \
|
||||
sw/source/core/doc/DocumentLinksAdministrationManager \
|
||||
sw/source/core/doc/DocumentListItemsManager \
|
||||
sw/source/core/doc/extinput \
|
||||
sw/source/core/doc/fmtcol \
|
||||
sw/source/core/doc/ftnidx \
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include <IDocumentState.hxx>
|
||||
#include <IDocumentLayoutAccess.hxx>
|
||||
#include <IDocumentOutlineNodes.hxx>
|
||||
#include <IDocumentListItems.hxx>
|
||||
|
||||
#include <IDocumentListsAccess.hxx>
|
||||
class SwList;
|
||||
@@ -195,6 +194,7 @@ class IDocumentDrawModelAccess;
|
||||
class IDocumentChartDataProviderAccess;
|
||||
class IDocumentTimerAccess;
|
||||
class IDocumentLinksAdministration;
|
||||
class IDocumentListItems;
|
||||
class _SetGetExpFlds;
|
||||
|
||||
namespace sw { namespace mark {
|
||||
@@ -210,6 +210,7 @@ namespace sw {
|
||||
class DocumentChartDataProviderManager;
|
||||
class DocumentTimerManager;
|
||||
class DocumentLinksAdministrationManager;
|
||||
class DocumentListItemsManager;
|
||||
}
|
||||
|
||||
namespace com { namespace sun { namespace star {
|
||||
@@ -255,7 +256,6 @@ class SW_DLLPUBLIC SwDoc :
|
||||
public IDocumentStatistics,
|
||||
public IDocumentState,
|
||||
public IDocumentLayoutAccess,
|
||||
public IDocumentListItems,
|
||||
public IDocumentOutlineNodes,
|
||||
public IDocumentListsAccess,
|
||||
public IDocumentExternalData
|
||||
@@ -291,6 +291,7 @@ class SW_DLLPUBLIC SwDoc :
|
||||
::boost::scoped_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess;
|
||||
const ::boost::scoped_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager;
|
||||
const ::boost::scoped_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager;
|
||||
const ::boost::scoped_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
|
||||
|
||||
// Pointer
|
||||
SwFrmFmt *mpDfltFrmFmt; //< Default formats.
|
||||
@@ -368,17 +369,8 @@ class SW_DLLPUBLIC SwDoc :
|
||||
rtl::Reference<SvxForbiddenCharactersTable> mxForbiddenCharsTable;
|
||||
com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > mxVbaEvents;
|
||||
com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> m_xTemplateToProjectCache;
|
||||
public:
|
||||
struct lessThanNodeNum
|
||||
{
|
||||
bool operator()( const SwNodeNum* pNodeNumOne,
|
||||
const SwNodeNum* pNodeNumTwo ) const;
|
||||
};
|
||||
|
||||
typedef ::std::set< const SwNodeNum*, lessThanNodeNum > tImplSortedNodeNumList;
|
||||
private:
|
||||
tImplSortedNodeNumList* mpListItemsList;
|
||||
|
||||
::std::auto_ptr< ::sfx2::IXmlIdRegistry > m_pXmlIdRegistry;
|
||||
|
||||
// other
|
||||
@@ -774,13 +766,8 @@ public:
|
||||
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess();
|
||||
|
||||
// IDocumentListItems
|
||||
virtual void addListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
|
||||
virtual void removeListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
|
||||
virtual OUString getListItemText( const SwNodeNum& rNodeNum,
|
||||
const bool bWithNumber = true,
|
||||
const bool bWithSpacesForLevel = false ) const SAL_OVERRIDE;
|
||||
virtual void getListItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
|
||||
virtual void getNumItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
|
||||
IDocumentListItems const & getIDocumentListItems() const;
|
||||
IDocumentListItems & getIDocumentListItems();
|
||||
|
||||
// IDocumentOutlineNodes
|
||||
virtual sal_Int32 getOutlineNodesCount() const SAL_OVERRIDE;
|
||||
|
121
sw/source/core/doc/DocumentListItemsManager.cxx
Normal file
121
sw/source/core/doc/DocumentListItemsManager.cxx
Normal file
@@ -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: */
|
@@ -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 */
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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(); }
|
||||
|
69
sw/source/core/inc/DocumentListItemsManager.hxx
Normal file
69
sw/source/core/inc/DocumentListItemsManager.hxx
Normal file
@@ -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: */
|
@@ -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
|
||||
|
Reference in New Issue
Block a user