summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2016-09-01 01:27:42 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-09-01 06:37:15 +0000
commitd22525fcb03497a38ef5c9308ae7b50416ea9fb2 (patch)
tree7a90d81f97dc8c47079bbd1c5926e5f6f9f1bf39 /svl
parentfa5a9b970ebf73b2c3a316903ced1b1e8bddb2be (diff)
avoid warning in PoolItemTest
> warn:legacy.tools:19758:1:svl/source/inc/poolio.hxx:139: > Start-Which-Id must be greater 0 adapt ID range in the test and leave usage comment in SfxItemPool ctor params Change-Id: I93150be8d3d1e330c6574b9f8d05b3b1ef2ffa43 Reviewed-on: https://gerrit.libreoffice.org/28570 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/items/test_itempool.cxx53
-rw-r--r--svl/source/items/itempool.cxx2
2 files changed, 27 insertions, 28 deletions
diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx
index cc43694493e4..bf52772e763a 100644
--- a/svl/qa/unit/items/test_itempool.cxx
+++ b/svl/qa/unit/items/test_itempool.cxx
@@ -35,69 +35,68 @@ class PoolItemTest : public CppUnit::TestFixture
void PoolItemTest::testPool()
{
SfxItemInfo aItems[] =
- { { 0, true },
- { 1, false /* not poolable */ },
- { 2, false },
- { 3, false /* not poolable */}
+ { { 1, true },
+ { 2, false /* not poolable */ },
+ { 3, false },
+ { 4, false /* not poolable */}
};
- SfxItemPool *pPool = new SfxItemPool("testpool", 0, 3, aItems);
+ SfxItemPool *pPool = new SfxItemPool("testpool", 1, 4, aItems);
SfxItemPool_Impl *pImpl = SfxItemPool_Impl::GetImpl(pPool);
CPPUNIT_ASSERT(pImpl != nullptr);
CPPUNIT_ASSERT(pImpl->maPoolItems.size() == 4);
// Poolable
- SfxVoidItem aItemZero( 0 );
- SfxVoidItem aNotherZero( 0 );
+ SfxVoidItem aItemOne( 1 );
+ SfxVoidItem aNotherOne( 1 );
{
CPPUNIT_ASSERT(pImpl->maPoolItems[0] == nullptr);
- const SfxPoolItem &rVal = pPool->Put(aItemZero);
- CPPUNIT_ASSERT(rVal == aItemZero);
+ const SfxPoolItem &rVal = pPool->Put(aItemOne);
+ CPPUNIT_ASSERT(rVal == aItemOne);
CPPUNIT_ASSERT(pImpl->maPoolItems[0] != nullptr);
- const SfxPoolItem &rVal2 = pPool->Put(aNotherZero);
+ const SfxPoolItem &rVal2 = pPool->Put(aNotherOne);
CPPUNIT_ASSERT(rVal2 == rVal);
CPPUNIT_ASSERT(&rVal2 == &rVal);
// Clones on Put ...
- CPPUNIT_ASSERT(&rVal2 != &aItemZero);
- CPPUNIT_ASSERT(&rVal2 != &aNotherZero);
- CPPUNIT_ASSERT(&rVal != &aItemZero);
- CPPUNIT_ASSERT(&rVal != &aNotherZero);
+ CPPUNIT_ASSERT(&rVal2 != &aItemOne);
+ CPPUNIT_ASSERT(&rVal2 != &aNotherOne);
+ CPPUNIT_ASSERT(&rVal != &aItemOne);
+ CPPUNIT_ASSERT(&rVal != &aNotherOne);
}
// non-poolable
- SfxVoidItem aItemOne( 1 );
- SfxVoidItem aNotherOne( 1 );
+ SfxVoidItem aItemTwo( 2 );
+ SfxVoidItem aNotherTwo( 2 );
{
CPPUNIT_ASSERT(pImpl->maPoolItems[1] == nullptr);
- const SfxPoolItem &rVal = pPool->Put(aItemOne);
- CPPUNIT_ASSERT(rVal == aItemOne);
+ const SfxPoolItem &rVal = pPool->Put(aItemTwo);
+ CPPUNIT_ASSERT(rVal == aItemTwo);
CPPUNIT_ASSERT(pImpl->maPoolItems[1] != nullptr);
- const SfxPoolItem &rVal2 = pPool->Put(aNotherOne);
+ const SfxPoolItem &rVal2 = pPool->Put(aNotherTwo);
CPPUNIT_ASSERT(rVal2 == rVal);
CPPUNIT_ASSERT(&rVal2 != &rVal);
}
// Test rehash
- for (size_t i = 0; i < pImpl->maPoolItems.size(); ++i)
+ for (SfxPoolItemArray_Impl *pSlice : pImpl->maPoolItems)
{
- SfxPoolItemArray_Impl *pSlice = pImpl->maPoolItems[i];
if (pSlice)
pSlice->ReHash();
}
// Test removal.
- SfxVoidItem aRemoveThree(3);
- SfxVoidItem aNotherThree(3);
- const SfxPoolItem &rKeyThree = pPool->Put(aRemoveThree);
- pPool->Put(aNotherThree);
+ SfxVoidItem aRemoveFour(4);
+ SfxVoidItem aNotherFour(4);
+ const SfxPoolItem &rKeyFour = pPool->Put(aRemoveFour);
+ pPool->Put(aNotherFour);
CPPUNIT_ASSERT(pImpl->maPoolItems[3]->size() > 0);
CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 0);
- pPool->Remove(rKeyThree);
+ pPool->Remove(rKeyFour);
CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 1);
- pPool->Put(aNotherThree);
+ pPool->Put(aNotherFour);
CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 0);
}
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 2b3d9ff4685f..fc250c36914f 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -164,7 +164,7 @@ SfxBroadcaster& SfxItemPool::BC()
SfxItemPool::SfxItemPool
(
const OUString& rName, /* Pool name to identify in the file format */
- sal_uInt16 nStartWhich, /* First WhichId of the Pool */
+ sal_uInt16 nStartWhich, /* First WhichId of the Pool (must be > 0) */
sal_uInt16 nEndWhich, /* Last WhichId of the Pool */
const SfxItemInfo* pInfo, /* SID Map and Item flags */
SfxPoolItem** pDefaults, /* Pointer to static Defaults;