1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/log.hxx>
23 #include <tools/solar.h>
24 #include <svl/itempool.hxx>
25 #include <svl/SfxBroadcaster.hxx>
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
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");
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
) )
87 SfxPoolItemArray_Impl
& rItemArr
= pImpl
->maPoolItemArrays
[GetIndex_Impl(pItem
->Which())];
89 for ( auto p
: rItemArr
)
94 SAL_WARN( "svl.items", "Item not in the pool, with ID/pos " << pItem
->Which());
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */