diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-16 15:58:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-17 00:01:39 +0100 |
commit | e75b67c68ace40cc25ef525003d334fc56de6423 (patch) | |
tree | 4cc1f5c280f2b9a84eebe5cabe069ab640acc182 /sc | |
parent | 77da600bf3f0b2279a21680169dc3136bdc2639c (diff) |
coverity#1426171 Unchecked dynamic_cast
and
coverity#1426170 Unchecked dynamic_cast
coverity#1426164 Unchecked dynamic_cast
coverity#1426165 Unchecked dynamic_cast
and duplicated lines look like cnp gone wrong
Change-Id: I195204e9d0a4d591fbe210241203a17b22b25ec1
Reviewed-on: https://gerrit.libreoffice.org/46603
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 7d80d8349ded..0fe4d7a4b5c4 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1440,14 +1440,16 @@ void ScTiledRenderingTest::testDocumentRepair() int nView2 = SfxLokHelper::getView(); CPPUNIT_ASSERT(pView1 != pView2); { - std::unique_ptr<SfxPoolItem> pItem1; - std::unique_ptr<SfxPoolItem> pItem2; - pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); - pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); - CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get())); - CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get())); - CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue()); - CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); + std::unique_ptr<SfxPoolItem> xItem1; + std::unique_ptr<SfxPoolItem> xItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem2); + const SfxBoolItem* pItem1 = dynamic_cast< const SfxBoolItem* >(xItem1.get()); + const SfxBoolItem* pItem2 = dynamic_cast< const SfxBoolItem* >(xItem2.get()); + CPPUNIT_ASSERT(pItem1); + CPPUNIT_ASSERT(pItem2); + CPPUNIT_ASSERT_EQUAL(false, pItem1->GetValue()); + CPPUNIT_ASSERT_EQUAL(false, pItem2->GetValue()); } // Insert a character in the second view. @@ -1459,14 +1461,16 @@ void ScTiledRenderingTest::testDocumentRepair() pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); Scheduler::ProcessEventsToIdle(); { - std::unique_ptr<SfxPoolItem> pItem1; - std::unique_ptr<SfxPoolItem> pItem2; - pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); - pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); - CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get())); - CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get())); - CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue()); - CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); + std::unique_ptr<SfxPoolItem> xItem1; + std::unique_ptr<SfxPoolItem> xItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem2); + const SfxBoolItem* pItem1 = dynamic_cast< const SfxBoolItem* >(xItem1.get()); + const SfxBoolItem* pItem2 = dynamic_cast< const SfxBoolItem* >(xItem2.get()); + CPPUNIT_ASSERT(pItem1); + CPPUNIT_ASSERT(pItem2); + CPPUNIT_ASSERT_EQUAL(true, pItem1->GetValue()); + CPPUNIT_ASSERT_EQUAL(true, pItem2->GetValue()); } comphelper::LibreOfficeKit::setActive(false); @@ -1489,14 +1493,16 @@ void ScTiledRenderingTest::testLanguageStatus() CPPUNIT_ASSERT(pView1 != pView2); const OUString aLangBolivia("Spanish (Bolivia)"); { - std::unique_ptr<SfxPoolItem> pItem1; - std::unique_ptr<SfxPoolItem> pItem2; - pView1->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem1); - pView2->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem2); - CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem1.get())); - CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem2.get())); - CPPUNIT_ASSERT(!dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue().isEmpty()); - CPPUNIT_ASSERT(!dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue().isEmpty()); + std::unique_ptr<SfxPoolItem> xItem1; + std::unique_ptr<SfxPoolItem> xItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, xItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, xItem2); + const SfxStringItem* pItem1 = dynamic_cast<const SfxStringItem*>(xItem1.get()); + const SfxStringItem* pItem2 = dynamic_cast<const SfxStringItem*>(xItem2.get()); + CPPUNIT_ASSERT(pItem1); + CPPUNIT_ASSERT(pItem2); + CPPUNIT_ASSERT(!pItem1->GetValue().isEmpty()); + CPPUNIT_ASSERT(!pItem2->GetValue().isEmpty()); } { @@ -1506,14 +1512,16 @@ void ScTiledRenderingTest::testLanguageStatus() } { - std::unique_ptr<SfxPoolItem> pItem1; - std::unique_ptr<SfxPoolItem> pItem2; - pView1->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem1); - pView2->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem2); - CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem1.get())); - CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem2.get())); - CPPUNIT_ASSERT_EQUAL(aLangBolivia, dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue()); - CPPUNIT_ASSERT_EQUAL(aLangBolivia, dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue()); + std::unique_ptr<SfxPoolItem> xItem1; + std::unique_ptr<SfxPoolItem> xItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, xItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, xItem2); + const SfxStringItem* pItem1 = dynamic_cast<const SfxStringItem*>(xItem1.get()); + const SfxStringItem* pItem2 = dynamic_cast<const SfxStringItem*>(xItem2.get()); + CPPUNIT_ASSERT(pItem1); + CPPUNIT_ASSERT(pItem2); + CPPUNIT_ASSERT_EQUAL(aLangBolivia, pItem1->GetValue()); + CPPUNIT_ASSERT_EQUAL(aLangBolivia, pItem2->GetValue()); } } |