bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / poolio.cxx
bloba909450f4588d9d5fd9cd6db05a12d46600af636
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 <poolio.hxx>
22 #include <sal/log.hxx>
23 #include <tools/solar.h>
24 #include <svl/itempool.hxx>
25 #include <svl/SfxBroadcaster.hxx>
27 #include <algorithm>
28 #include <memory>
30 /// clear array of PoolItem variants
31 /// after all PoolItems are deleted
32 /// or all ref counts are decreased
33 void SfxPoolItemArray_Impl::clear()
35 maPoolItemSet.clear();
36 maSortablePoolItems.clear();
39 sal_uInt16 SfxItemPool::GetFirstWhich() const
41 return pImpl->mnStart;
44 sal_uInt16 SfxItemPool::GetLastWhich() const
46 return pImpl->mnEnd;
49 bool SfxItemPool::IsInRange( sal_uInt16 nWhich ) const
51 return nWhich >= pImpl->mnStart && nWhich <= pImpl->mnEnd;
54 sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const
56 if (nWhich < pImpl->mnStart || nWhich > pImpl->mnEnd)
58 assert(false && "missing bounds check before use");
59 return 0;
61 return nWhich - pImpl->mnStart;
64 sal_uInt16 SfxItemPool::GetSize_Impl() const
66 return pImpl->mnEnd - pImpl->mnStart + 1;
70 bool SfxItemPool::CheckItemInPool(const SfxPoolItem *pItem) const
72 DBG_ASSERT( pItem, "no 0-Pointer Surrogate" );
73 DBG_ASSERT( !IsInvalidItem(pItem), "no Invalid-Item Surrogate" );
74 DBG_ASSERT( !IsPoolDefaultItem(pItem), "no Pool-Default-Item Surrogate" );
76 if ( !IsInRange(pItem->Which()) )
78 if ( pImpl->mpSecondary )
79 return pImpl->mpSecondary->CheckItemInPool( pItem );
80 SAL_WARN( "svl.items", "unknown Which-Id - don't ask me for surrogates, with ID/pos " << pItem->Which());
83 // Pointer on static or pool-default attribute?
84 if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) )
85 return true;
87 SfxPoolItemArray_Impl& rItemArr = pImpl->maPoolItemArrays[GetIndex_Impl(pItem->Which())];
89 for ( auto p : rItemArr )
91 if ( p == pItem )
92 return true;
94 SAL_WARN( "svl.items", "Item not in the pool, with ID/pos " << pItem->Which());
95 return false;
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */