sw/source/ui/chrdlg/chardlg.cxx |   22 +++++-----
 sw/source/ui/chrdlg/numpara.cxx |   14 +++---
 sw/source/ui/config/optcomp.cxx |    5 --
 sw/source/ui/config/optload.cxx |   24 +++++------
 sw/source/ui/config/optpage.cxx |   87 +++++++++++++++-------------------------
 sw/source/ui/dbui/dbinsdlg.cxx  |    5 --
 6 files changed, 67 insertions(+), 90 deletions(-)

New commits:
commit a188ffa01616673c011c7bc1a392a6f6fa81f93b
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Mar 9 08:59:09 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Mar 11 11:40:31 2022 +0100

    use SfxItemSet::GetItemIfSet in sw/.../ui
    
    Change-Id: Ic6a15dfd159ee2e5d4aa0e0c3bc31cff1557a875
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131229
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/ui/chrdlg/chardlg.cxx b/sw/source/ui/chrdlg/chardlg.cxx
index d4d748fc4dab..b7564dc414a9 100644
--- a/sw/source/ui/chrdlg/chardlg.cxx
+++ b/sw/source/ui/chrdlg/chardlg.cxx
@@ -154,13 +154,15 @@ SwCharURLPage::SwCharURLPage(weld::Container* pPage, 
weld::DialogController* pCo
     m_xVisitedLB->set_size_request(nMaxWidth , -1);
     m_xNotVisitedLB->set_size_request(nMaxWidth , -1);
 
-    const SfxPoolItem* pItem;
-    SfxObjectShell* pShell;
-    if(SfxItemState::SET == rCoreSet.GetItemState(SID_HTML_MODE, false, 
&pItem) ||
-        ( nullptr != ( pShell = SfxObjectShell::Current()) &&
-                    nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
+    const SfxUInt16Item* pItem = rCoreSet.GetItemIfSet(SID_HTML_MODE, false);
+    if (!pItem)
     {
-        sal_uInt16 nHtmlMode = static_cast<const 
SfxUInt16Item*>(pItem)->GetValue();
+        if (SfxObjectShell* pShell = SfxObjectShell::Current())
+            pItem = pShell->GetItem(SID_HTML_MODE);
+    }
+    if (pItem)
+    {
+        sal_uInt16 nHtmlMode = pItem->GetValue();
         if (HTMLMODE_ON & nHtmlMode)
             m_xCharStyleContainer->hide();
     }
@@ -194,10 +196,8 @@ SwCharURLPage::~SwCharURLPage()
 
 void SwCharURLPage::Reset(const SfxItemSet* rSet)
 {
-    const SfxPoolItem* pItem;
-    if (SfxItemState::SET == rSet->GetItemState(RES_TXTATR_INETFMT, false, 
&pItem))
+    if (const SwFormatINetFormat* pINetFormat = 
rSet->GetItemIfSet(RES_TXTATR_INETFMT, false))
     {
-        const SwFormatINetFormat* pINetFormat = static_cast<const 
SwFormatINetFormat*>( pItem);
         m_xURLED->set_text(INetURLObject::decode(pINetFormat->GetValue(),
             INetURLObject::DecodeMechanism::Unambiguous));
         m_xURLED->save_value();
@@ -229,9 +229,9 @@ void SwCharURLPage::Reset(const SfxItemSet* rSet)
         if( pINetFormat->GetMacroTable() )
             m_oINetMacroTable = *pINetFormat->GetMacroTable();
     }
-    if (SfxItemState::SET == rSet->GetItemState(FN_PARAM_SELECTION, false, 
&pItem))
+    if (const SfxStringItem* pItem = rSet->GetItemIfSet(FN_PARAM_SELECTION, 
false))
     {
-        m_xTextED->set_text(static_cast<const 
SfxStringItem*>(pItem)->GetValue());
+        m_xTextED->set_text(pItem->GetValue());
         m_xTextFT->set_sensitive(false);
         m_xTextED->set_sensitive(false);
     }
diff --git a/sw/source/ui/chrdlg/numpara.cxx b/sw/source/ui/chrdlg/numpara.cxx
index 064439a1be15..f67627b2dad0 100644
--- a/sw/source/ui/chrdlg/numpara.cxx
+++ b/sw/source/ui/chrdlg/numpara.cxx
@@ -61,13 +61,15 @@ 
SwParagraphNumTabPage::SwParagraphNumTabPage(weld::Container* pPage, weld::Dialo
     m_xRestartParaCountCB->set_state(TRISTATE_FALSE);
     m_xEditNumStyleBtn->set_sensitive(false);
 
-    const SfxPoolItem* pItem;
-    SfxObjectShell* pObjSh;
-    if(SfxItemState::SET == rAttr.GetItemState(SID_HTML_MODE, false, &pItem) ||
-        ( nullptr != ( pObjSh = SfxObjectShell::Current()) &&
-          nullptr != (pItem = pObjSh->GetItem(SID_HTML_MODE))))
+    const SfxUInt16Item* pItem = rAttr.GetItemIfSet(SID_HTML_MODE, false);
+    if (!pItem)
     {
-        const sal_uInt16 nHtmlMode = static_cast<const 
SfxUInt16Item*>(pItem)->GetValue();
+        if (SfxObjectShell* pObjSh = SfxObjectShell::Current())
+            pItem = pObjSh->GetItem(SID_HTML_MODE);
+    }
+    if(pItem)
+    {
+        const sal_uInt16 nHtmlMode = pItem->GetValue();
 
         if (HTMLMODE_ON & nHtmlMode)
             m_xCountParaFram->hide();
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 071b2fa1c76c..848d424b6db0 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -187,10 +187,9 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
 {
     // init objectshell and detect document name
     OUString sDocTitle;
-    const SfxPoolItem* pItem = nullptr;
     SfxObjectShell* pObjShell = nullptr;
-    if ( SfxItemState::SET == rSet.GetItemState( FN_PARAM_WRTSHELL, false, 
&pItem ) )
-        m_pWrtShell = static_cast<SwWrtShell*>(static_cast<const 
SwPtrItem*>(pItem)->GetValue());
+    if ( const SwPtrItem* pItem = rSet.GetItemIfSet( FN_PARAM_WRTSHELL, false 
) )
+        m_pWrtShell = static_cast<SwWrtShell*>(pItem->GetValue());
     if ( m_pWrtShell )
     {
         pObjShell = m_pWrtShell->GetView().GetDocShell();
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index 33229f313884..9f0531b77a67 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -116,9 +116,8 @@ SwLoadOptPage::SwLoadOptPage(weld::Container* pPage, 
weld::DialogController* pCo
     }
     m_xMetricLB->connect_changed(LINK(this, SwLoadOptPage, MetricHdl));
 
-    const SfxPoolItem* pItem;
-    if (SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem)
-        && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
+    const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
+    if (pItem && pItem->GetValue() & HTMLMODE_ON)
     {
         m_xTabFT->hide();
         m_xTabMF->hide();
@@ -259,10 +258,10 @@ bool SwLoadOptPage::FillItemSet( SfxItemSet* rSet )
 void SwLoadOptPage::Reset( const SfxItemSet* rSet)
 {
     const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref(false);
-    const SfxPoolItem* pItem;
+    const SwPtrItem* pShellItem = rSet->GetItemIfSet(FN_PARAM_WRTSHELL, false);
 
-    if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_WRTSHELL, false, 
&pItem))
-        m_pWrtShell = static_cast<SwWrtShell*>(static_cast<const 
SwPtrItem*>(pItem)->GetValue());
+    if(pShellItem)
+        m_pWrtShell = static_cast<SwWrtShell*>(pShellItem->GetValue());
 
     SwFieldUpdateFlags eFieldFlags = AUTOUPD_GLOBALSETTING;
     m_nOldLinkMode = GLOBALSETTING;
@@ -305,9 +304,9 @@ void SwLoadOptPage::Reset( const SfxItemSet* rSet)
         ::SetFieldUnit(*m_xTabMF, eFieldUnit);
     }
     m_xMetricLB->save_value();
-    if(SfxItemState::SET == rSet->GetItemState(SID_ATTR_DEFTABSTOP, false, 
&pItem))
+    if(const SfxUInt16Item* pItem = rSet->GetItemIfSet(SID_ATTR_DEFTABSTOP, 
false))
     {
-        m_nLastTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+        m_nLastTab = pItem->GetValue();
         m_xTabMF->set_value(m_xTabMF->normalize(m_nLastTab), FieldUnit::TWIP);
     }
     m_xTabMF->save_value();
@@ -320,9 +319,9 @@ void SwLoadOptPage::Reset( const SfxItemSet* rSet)
         m_xUseSquaredPageMode->save_state();
     }
 
-    if(SfxItemState::SET == rSet->GetItemState(SID_ATTR_APPLYCHARUNIT, false, 
&pItem))
+    if(const SfxBoolItem* pItem = rSet->GetItemIfSet(SID_ATTR_APPLYCHARUNIT, 
false))
     {
-        bool bUseCharUnit = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+        bool bUseCharUnit = pItem->GetValue();
         m_xUseCharUnit->set_active(bUseCharUnit);
     }
     else
@@ -565,10 +564,9 @@ bool SwCaptionOptPage::FillItemSet( SfxItemSet* )
 
 void SwCaptionOptPage::Reset( const SfxItemSet* rSet)
 {
-    const SfxPoolItem* pItem;
-    if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem))
+    if(const SfxUInt16Item* pItem = rSet->GetItemIfSet(SID_HTML_MODE, false))
     {
-        bHTMLMode = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() 
& HTMLMODE_ON);
+        bHTMLMode = 0 != (pItem->GetValue() & HTMLMODE_ON);
     }
 
     DelUserData();
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index ee175236d000..f46bf5f0340a 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -119,9 +119,8 @@ SwContentOptPage::SwContentOptPage(weld::Container* pPage, 
weld::DialogControlle
     }
 
     /* This part is visible only with Writer/Web->View dialogue. */
-    const SfxPoolItem* pItem;
-    if (! (SfxItemState::SET == rCoreSet.GetItemState(SID_HTML_MODE, false, 
&pItem )
-           && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & 
HTMLMODE_ON))
+    const SfxUInt16Item* pItem = rCoreSet.GetItemIfSet(SID_HTML_MODE, false );
+    if (!pItem || !(pItem->GetValue() & HTMLMODE_ON))
     {
         m_xSettingsFrame->hide();
         m_xSettingsLabel->hide();
@@ -178,7 +177,7 @@ std::unique_ptr<SfxTabPage> SwContentOptPage::Create( 
weld::Container* pPage, we
     return std::make_unique<SwContentOptPage>(pPage, pController, *rAttrSet);
 }
 
-static void lcl_SelectMetricLB(weld::ComboBox& rMetric, sal_uInt16 nSID, const 
SfxItemSet& rSet)
+static void lcl_SelectMetricLB(weld::ComboBox& rMetric, 
TypedWhichId<SfxUInt16Item> nSID, const SfxItemSet& rSet)
 {
     const SfxPoolItem* pItem;
     if( rSet.GetItemState( nSID, false, &pItem ) >= SfxItemState::DEFAULT )
@@ -198,10 +197,7 @@ static void lcl_SelectMetricLB(weld::ComboBox& rMetric, 
sal_uInt16 nSID, const S
 
 void SwContentOptPage::Reset(const SfxItemSet* rSet)
 {
-    const SwElemItem* pElemAttr = nullptr;
-
-    rSet->GetItemState( FN_PARAM_ELEM , false,
-                                    reinterpret_cast<const 
SfxPoolItem**>(&pElemAttr) );
+    const SwElemItem* pElemAttr = rSet->GetItemIfSet( FN_PARAM_ELEM , false );
     if(pElemAttr)
     {
         m_xTableCB->set_active(pElemAttr->m_bTable);
@@ -335,9 +331,8 @@ SwAddPrinterTabPage::SwAddPrinterTabPage(weld::Container* 
pPage, weld::DialogCon
     m_xNoRB->connect_toggled( aLk );
     m_xFaxLB->connect_changed( LINK( this, SwAddPrinterTabPage, SelectHdl ) );
 
-    const SfxPoolItem* pItem;
-    if(SfxItemState::SET == rCoreSet.GetItemState(SID_HTML_MODE, false, &pItem 
)
-        && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
+    const SfxUInt16Item* pItem = rCoreSet.GetItemIfSet(SID_HTML_MODE, false );
+    if(pItem && pItem->GetValue() & HTMLMODE_ON)
     {
         m_xLeftPageCB->hide();
         m_xRightPageCB->hide();
@@ -411,10 +406,8 @@ bool    SwAddPrinterTabPage::FillItemSet( SfxItemSet* 
rCoreSet )
 void    SwAddPrinterTabPage::Reset( const SfxItemSet*  )
 {
     const   SfxItemSet&         rSet = GetItemSet();
-    const   SwAddPrinterItem*   pAddPrinterAttr = nullptr;
 
-    if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_ADDPRINTER , false,
-                                    reinterpret_cast<const 
SfxPoolItem**>(&pAddPrinterAttr) ))
+    if( const SwAddPrinterItem* pAddPrinterAttr = rSet.GetItemIfSet( 
FN_PARAM_ADDPRINTER , false ) )
     {
         m_xGrfCB->set_active(pAddPrinterAttr->m_bPrintGraphic || 
pAddPrinterAttr->m_bPrintDraw);
         m_xCtrlFieldCB->set_active(       pAddPrinterAttr->m_bPrintControl);
@@ -725,12 +718,11 @@ bool SwStdFontTabPage::FillItemSet( SfxItemSet* )
 
 void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
 {
-    const SfxPoolItem* pLang;
-    const sal_uInt16 nLangSlot = m_nFontGroup == FONT_GROUP_DEFAULT  ? 
SID_ATTR_LANGUAGE :
+    const TypedWhichId<SvxLanguageItem> nLangSlot = m_nFontGroup == 
FONT_GROUP_DEFAULT  ? SID_ATTR_LANGUAGE :
         FONT_GROUP_CJK == m_nFontGroup ? SID_ATTR_CHAR_CJK_LANGUAGE : 
SID_ATTR_CHAR_CTL_LANGUAGE;
 
-    if( SfxItemState::SET == rSet->GetItemState(nLangSlot, false, &pLang))
-        m_eLanguage = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
+    if( const SvxLanguageItem* pLang = rSet->GetItemIfSet(nLangSlot, false) )
+        m_eLanguage = pLang->GetValue();
 
     OUString sToReplace = m_sScriptWestern;
     if(FONT_GROUP_CJK == m_nFontGroup )
@@ -739,17 +731,15 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
         sToReplace = m_sScriptComplex;
     m_xLabelFT->set_label(m_xLabelFT->get_label().replaceFirst("%1", 
sToReplace));
 
-    const SfxPoolItem* pItem;
-
     if (m_bDisposePrinter)
     {
         m_pPrt.disposeAndClear();
         m_bDisposePrinter = false;
     }
 
-    if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_PRINTER, false, 
&pItem))
+    if(const SwPtrItem* pItem = rSet->GetItemIfSet(FN_PARAM_PRINTER, false))
     {
-        m_pPrt = static_cast<SfxPrinter*>(static_cast<const 
SwPtrItem*>(pItem)->GetValue());
+        m_pPrt = static_cast<SfxPrinter*>(pItem->GetValue());
     }
     else
     {
@@ -782,14 +772,14 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
             m_xIdxBox->append_text( rFontName );
         }
     }
-    if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_STDFONTS, false, 
&pItem))
+    if(const SwPtrItem* pItem = rSet->GetItemIfSet(FN_PARAM_STDFONTS, false))
     {
-         m_pFontConfig = static_cast<SwStdFontConfig*>(static_cast<const 
SwPtrItem*>(pItem)->GetValue());
+         m_pFontConfig = static_cast<SwStdFontConfig*>(pItem->GetValue());
     }
 
-    if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_WRTSHELL, false, 
&pItem))
+    if(const SwPtrItem* pItem = rSet->GetItemIfSet(FN_PARAM_WRTSHELL, false))
     {
-        m_pWrtShell = static_cast<SwWrtShell*>(static_cast<const 
SwPtrItem*>(pItem)->GetValue());
+        m_pWrtShell = static_cast<SwWrtShell*>(pItem->GetValue());
     }
     OUString sStdBackup;
     OUString sOutBackup;
@@ -1148,10 +1138,9 @@ void SwTableOptionsTabPage::Reset( const SfxItemSet* 
rSet)
         case TableChgMode::FixedWidthChangeProp:  
m_xFixPropRB->set_active(true); break;
         case TableChgMode::VarWidthChangeAbs:     m_xVarRB->set_active(true); 
break;
     }
-    const SfxPoolItem* pItem;
-    if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem))
+    if(const SfxUInt16Item* pItem = rSet->GetItemIfSet(SID_HTML_MODE, false))
     {
-        m_bHTMLMode = 0 != (static_cast<const 
SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
+        m_bHTMLMode = 0 != (pItem->GetValue() & HTMLMODE_ON);
     }
 
     // hide certain controls for html
@@ -1224,21 +1213,19 @@ 
SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, w
     , m_xDefaultAnchorType(m_xBuilder->weld_combo_box("cxDefaultAnchor"))
     , m_xMathBaselineAlignmentCB(m_xBuilder->weld_check_button("mathbaseline"))
 {
-    const SfxPoolItem* pItem = nullptr;
     SwFillMode eMode = SwFillMode::Tab;
     bool bIsOn = false;
 
-    if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_SHADOWCURSOR, false, 
&pItem ))
+    if( const SwShadowCursorItem* pItem = rSet.GetItemIfSet( 
FN_PARAM_SHADOWCURSOR, false ))
     {
-        auto& aOpt = *static_cast<const SwShadowCursorItem*>(pItem);
-        eMode = aOpt.GetMode();
-        bIsOn = aOpt.IsOn();
+        eMode = pItem->GetMode();
+        bIsOn = pItem->IsOn();
     }
     m_xOnOffCB->set_active( bIsOn );
 
     m_xDirectCursorFillMode->set_active( static_cast<int>(eMode) );
-    if(SfxItemState::SET != rSet.GetItemState(SID_HTML_MODE, false, &pItem )
-        || !(static_cast<const SfxUInt16Item*>(pItem)->GetValue() & 
HTMLMODE_ON))
+    const SfxUInt16Item* pHtmlModeItem = rSet.GetItemIfSet(SID_HTML_MODE, 
false);
+    if(!pHtmlModeItem || !(pHtmlModeItem->GetValue() & HTMLMODE_ON))
         return;
 
     m_xTabCB->hide();
@@ -1280,9 +1267,8 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* 
rSet )
     aOpt.SetMode( eMode );
 
     bool bRet = false;
-    const SfxPoolItem* pItem = nullptr;
-    if( SfxItemState::SET != rSet->GetItemState( FN_PARAM_SHADOWCURSOR, false, 
&pItem )
-        ||  static_cast<const SwShadowCursorItem&>(*pItem) != aOpt )
+    const SwShadowCursorItem* pShadowCursorItem = rSet->GetItemIfSet( 
FN_PARAM_SHADOWCURSOR, false );
+    if( !pShadowCursorItem || *pShadowCursorItem != aOpt )
     {
         rSet->Put( aOpt );
         bRet = true;
@@ -1323,15 +1309,13 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( 
SfxItemSet* rSet )
 
 void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
 {
-    const SfxPoolItem* pItem = nullptr;
     SwFillMode eMode = SwFillMode::Tab;
     bool bIsOn = false;
 
-    if( SfxItemState::SET == rSet->GetItemState( FN_PARAM_SHADOWCURSOR, false, 
&pItem ))
+    if( const SwShadowCursorItem* pItem = rSet->GetItemIfSet( 
FN_PARAM_SHADOWCURSOR, false ))
     {
-        auto& aOpt = *static_cast<const SwShadowCursorItem*>(pItem);
-        eMode = aOpt.GetMode();
-        bIsOn = aOpt.IsOn();
+        eMode = pItem->GetMode();
+        bIsOn = pItem->IsOn();
     }
     m_xOnOffCB->set_active( bIsOn );
 
@@ -1343,14 +1327,11 @@ void SwShdwCursorOptionsTabPage::Reset( const 
SfxItemSet* rSet )
         m_xMathBaselineAlignmentCB->hide();
     }
 
-    if( SfxItemState::SET == rSet->GetItemState( FN_PARAM_CRSR_IN_PROTECTED, 
false, &pItem ))
-        m_xCursorInProtCB->set_active(static_cast<const 
SfxBoolItem*>(pItem)->GetValue());
+    if( const SfxBoolItem* pItem = rSet->GetItemIfSet( 
FN_PARAM_CRSR_IN_PROTECTED, false ) )
+        m_xCursorInProtCB->set_active(pItem->GetValue());
     m_xCursorInProtCB->save_state();
 
-    const SwDocDisplayItem* pDocDisplayAttr = nullptr;
-
-    rSet->GetItemState( FN_PARAM_DOCDISP, false,
-                                    reinterpret_cast<const 
SfxPoolItem**>(&pDocDisplayAttr) );
+    const SwDocDisplayItem* pDocDisplayAttr = rSet->GetItemIfSet( 
FN_PARAM_DOCDISP, false );
     if(pDocDisplayAttr)
     {
         m_xParaCB->set_active( pDocDisplayAttr->m_bParagraphEnd );
@@ -2186,10 +2167,8 @@ bool    SwTestTabPage::FillItemSet( SfxItemSet* rCoreSet 
)
 void SwTestTabPage::Reset( const SfxItemSet* )
 {
     const SfxItemSet& rSet = GetItemSet();
-    const SwTestItem* pTestAttr = nullptr;
-
-    if( SfxItemState::SET != rSet.GetItemState( FN_PARAM_SWTEST , false,
-                                    reinterpret_cast<const 
SfxPoolItem**>(&pTestAttr) ))
+    const SwTestItem* pTestAttr = rSet.GetItemIfSet( FN_PARAM_SWTEST, false );
+    if(!pTestAttr)
         return;
 
     m_xTest1CBox->set_active(pTestAttr->m_bTest1);
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index c73a8aa2bed0..82839c6bf414 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1407,9 +1407,8 @@ void SwInsertDBColAutoPilot::SetTabSet()
                 pTableSet->ClearItem( i );
     }
 
-    if( SfxItemState::SET == pTableSet->GetItemState( FN_PARAM_TABLE_NAME, 
false,
-        &pItem ) && static_cast<const SfxStringItem*>(pItem)->GetValue() ==
-                    rSh.GetTableFormat()->GetName() )
+    const SfxStringItem* pTableNameItem = pTableSet->GetItemIfSet( 
FN_PARAM_TABLE_NAME, false);
+    if( pTableNameItem && pTableNameItem->GetValue() == 
rSh.GetTableFormat()->GetName() )
         pTableSet->ClearItem( FN_PARAM_TABLE_NAME );
 
     rSh.MoveTable( GotoCurrTable, fnTableStart );

Reply via email to