android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / doc / DocumentListItemsManager.cxx
blob2a8f0691d37260106856de5224a907319c5bf699
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <DocumentListItemsManager.hxx>
22 #include <SwNodeNum.hxx>
23 #include <txtfrm.hxx>
24 #include <ndtxt.hxx>
25 #include <osl/diagnose.h>
27 namespace sw
30 DocumentListItemsManager::DocumentListItemsManager() : mpListItemsList( new tImplSortedNodeNumList ) // #i83479#
34 bool DocumentListItemsManager::lessThanNodeNum::operator()( const SwNodeNum* pNodeNumOne,
35 const SwNodeNum* pNodeNumTwo ) const
37 return pNodeNumOne->LessThan( *pNodeNumTwo );
40 void DocumentListItemsManager::addListItem( const SwNodeNum& rNodeNum )
42 if ( mpListItemsList == nullptr )
44 return;
47 const bool bAlreadyInserted(
48 mpListItemsList->insert( &rNodeNum ).second );
49 OSL_ENSURE( bAlreadyInserted,
50 "<DocumentListItemsManager::addListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
53 void DocumentListItemsManager::removeListItem( const SwNodeNum& rNodeNum )
55 if ( mpListItemsList == nullptr )
57 return;
60 const tImplSortedNodeNumList::size_type nDeleted = mpListItemsList->erase( &rNodeNum );
61 if ( nDeleted > 1 )
63 OSL_FAIL( "<DocumentListItemsManager::removeListItem(..)> - <SwNodeNum> was registered more than once as numbered item!" );
67 OUString DocumentListItemsManager::getListItemText(const SwNodeNum& rNodeNum,
68 SwRootFrame const& rLayout) const
70 SwTextNode const*const pNode(rNodeNum.GetTextNode());
71 assert(pNode);
72 return sw::GetExpandTextMerged(&rLayout, *pNode, true, true, ExpandMode::ExpandFootnote);
75 bool DocumentListItemsManager::isNumberedInLayout(
76 SwNodeNum const& rNodeNum, // note: this is the non-hidden Num ...
77 SwRootFrame const& rLayout) const
79 return sw::IsParaPropsNode(rLayout, *rNodeNum.GetTextNode());
82 void DocumentListItemsManager::getNumItems( tSortedNodeNumList& orNodeNumList ) const
84 orNodeNumList.clear();
85 orNodeNumList.reserve( mpListItemsList->size() );
87 for ( const SwNodeNum* pNodeNum : *mpListItemsList )
89 if ( pNodeNum->IsCounted() &&
90 pNodeNum->GetTextNode() && pNodeNum->GetTextNode()->HasNumber() )
92 orNodeNumList.push_back( pNodeNum );
97 DocumentListItemsManager::~DocumentListItemsManager()
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */