diff options
33 files changed, 180 insertions, 206 deletions
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 8d274f83ce4c..ed43861d654b 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -1050,12 +1050,12 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) { - const SfxPoolItem* pItem = nullptr; + const SfxUInt16Item* pItem = nullptr; SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); // miscellaneous - Year2000 if( SfxItemState::DEFAULT <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) ) - pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, static_cast<const SfxUInt16Item*>(pItem)->GetValue() ) ); + pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, pItem->GetValue() ) ); else pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, officecfg::Office::Common::DateFormat::TwoDigitYear::get() ) ); } @@ -1100,28 +1100,17 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) { - const SfxPoolItem* pItem = nullptr; + const SvxLanguageItem* pLangItem = nullptr; SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_LANGUAGE)); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_CHAR_CJK_LANGUAGE)); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_CHAR_CTL_LANGUAGE)); + if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pLangItem)) + pRet->Put(*pLangItem, SID_ATTR_LANGUAGE); + if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pLangItem)) + pRet->Put(*pLangItem, SID_ATTR_CHAR_CJK_LANGUAGE); + if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pLangItem)) + pRet->Put(*pLangItem, SID_ATTR_CHAR_CTL_LANGUAGE); pRet->Put(aHyphen); + const SfxPoolItem* pItem = nullptr; if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem)) { pRet->Put(std::unique_ptr<SfxPoolItem>(pItem->Clone())); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0e1c47e9b5dc..c8fd1be5ce88 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -771,17 +771,17 @@ void ExecuteOrientationChange() mxUndoManager->enterUndoContext( "" ); - const SfxPoolItem* pItem; + const SvxSizeItem* pSizeItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pSizeItem); + std::unique_ptr<SvxSizeItem> pPageSizeItem(pSizeItem->Clone()); + const SvxLongLRSpaceItem* pLRSpaceItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem); + std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem(pLRSpaceItem->Clone()); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pItem); - std::unique_ptr<SvxSizeItem> pPageSizeItem(&pItem->Clone()->StaticWhichCast(SID_ATTR_PAGE_SIZE)); - - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pItem); - std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem(&pItem->Clone()->StaticWhichCast(SID_ATTR_PAGE_LRSPACE)); - - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pItem); - std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem(&pItem->Clone()->StaticWhichCast(SID_ATTR_PAGE_ULSPACE)); + const SvxLongULSpaceItem* pULSpaceItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem); + std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem(pULSpaceItem->Clone()); { bool bIsLandscape = false; diff --git a/include/editeng/editids.hrc b/include/editeng/editids.hrc index 92007573fe5d..a418a3f889b5 100644 --- a/include/editeng/editids.hrc +++ b/include/editeng/editids.hrc @@ -25,10 +25,14 @@ class SfxGrabBagItem; class SfxUInt16Item; class SvxBrushItem; class SvxFontItem; +class SvxKerningItem; class SvxLanguageItem; +class SvxLineSpacingItem; class SvxPageModelItem; class SvxPostureItem; class SvxTabStopItem; +class SvxUnderlineItem; +class SvxWeightItem; /* These SID_SVX_START entries came from include/svx/svxids.hrc, avoid @@ -44,16 +48,16 @@ class SvxTabStopItem; #define SID_ATTR_CHAR ( SID_SVX_START + 6 ) #define SID_ATTR_CHAR_FONT TypedWhichId<SvxFontItem>( SID_SVX_START + 7 ) #define SID_ATTR_CHAR_POSTURE TypedWhichId<SvxPostureItem>( SID_SVX_START + 8 ) -#define SID_ATTR_CHAR_WEIGHT ( SID_SVX_START + 9 ) +#define SID_ATTR_CHAR_WEIGHT TypedWhichId<SvxWeightItem>( SID_SVX_START + 9 ) #define SID_ATTR_CHAR_SHADOWED ( SID_SVX_START + 10 ) #define SID_ATTR_CHAR_WORDLINEMODE ( SID_SVX_START + 11 ) #define SID_ATTR_CHAR_CONTOUR ( SID_SVX_START + 12 ) #define SID_ATTR_CHAR_STRIKEOUT ( SID_SVX_START + 13 ) -#define SID_ATTR_CHAR_UNDERLINE ( SID_SVX_START + 14 ) +#define SID_ATTR_CHAR_UNDERLINE TypedWhichId<SvxUnderlineItem>( SID_SVX_START + 14 ) #define SID_ATTR_CHAR_FONTHEIGHT ( SID_SVX_START + 15 ) // free #define SID_ATTR_CHAR_COLOR ( SID_SVX_START + 17 ) -#define SID_ATTR_CHAR_KERNING ( SID_SVX_START + 18 ) +#define SID_ATTR_CHAR_KERNING TypedWhichId<SvxKerningItem>( SID_SVX_START + 18 ) #define SID_ATTR_CHAR_CASEMAP ( SID_SVX_START + 19 ) #define SID_ATTR_CHAR_LANGUAGE ( SID_SVX_START + 20 ) #define SID_ATTR_CHAR_ESCAPEMENT ( SID_SVX_START + 21 ) @@ -65,7 +69,7 @@ class SvxTabStopItem; #define SID_ATTR_PARA_ADJUST_RIGHT ( SID_SVX_START + 29 ) #define SID_ATTR_PARA_ADJUST_CENTER ( SID_SVX_START + 30 ) #define SID_ATTR_PARA_ADJUST_BLOCK ( SID_SVX_START + 31 ) -#define SID_ATTR_PARA_LINESPACE ( SID_SVX_START + 33 ) +#define SID_ATTR_PARA_LINESPACE TypedWhichId<SvxLineSpacingItem>( SID_SVX_START + 33 ) #define SID_ATTR_PARA_LINESPACE_10 ( SID_SVX_START + 34 ) #define SID_ATTR_PARA_LINESPACE_15 ( SID_SVX_START + 35 ) #define SID_ATTR_PARA_LINESPACE_115 ( SID_SVX_START + 26 ) diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx index 38104105088d..d058c939e4f9 100644 --- a/include/sfx2/bindings.hxx +++ b/include/sfx2/bindings.hxx @@ -141,6 +141,14 @@ public: * @param rpState the caller has to delete the pointer */ SfxItemState QueryState( sal_uInt16 nSID, std::unique_ptr<SfxPoolItem> &rpState ); + template<class T> + SfxItemState QueryState( TypedWhichId<T> nSID, std::unique_ptr<T> &rpState ) + { + std::unique_ptr<SfxPoolItem> tmp; + auto ret = QueryState(sal_uInt16(nSID), tmp); + rpState.reset(static_cast<T*>(tmp.release())); + return ret; + } void QueryControlState ( sal_uInt16 nSID, boost::property_tree::ptree& rState ); diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx index 3bfd3eab4074..ee445710b9c0 100644 --- a/include/sfx2/dispatch.hxx +++ b/include/sfx2/dispatch.hxx @@ -151,6 +151,11 @@ public: ToolbarId GetObjectBarId( sal_uInt16 nPos ) const; SfxItemState QueryState( sal_uInt16 nSID, const SfxPoolItem* &rpState ); + template<class T> + SfxItemState QueryState( TypedWhichId<T> nSID, const T* &rpState ) + { + return QueryState(sal_uInt16(nSID), reinterpret_cast<SfxPoolItem const*&>(rpState)); + } SfxItemState QueryState( sal_uInt16 nSID, css::uno::Any& rAny ); void SetDisableFlags( SfxDisableFlags nFlags ); diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 12ac2cd763a5..b48f827aec69 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -38,6 +38,7 @@ class SfxStringListItem; class SfxUInt16Item; class SfxUnoAnyItem; class SfxUnoFrameItem; +class SfxWatermarkItem; class SvxClipboardFormatItem; class SvxHyperlinkItem; class SvxLanguageItem; @@ -150,7 +151,7 @@ class SvxZoomItem; #define SID_FILE_FILTEROPTIONS TypedWhichId<SfxStringItem>(SID_SFX_START + 527) #define SID_RELOAD (SID_SFX_START + 508) #define SID_PRINTDOCDIRECT (SID_SFX_START + 509) -#define SID_DOC_REPAIR (SID_SFX_START + 510) +#define SID_DOC_REPAIR TypedWhichId<SfxBoolItem>(SID_SFX_START + 510) #define SID_DOC_SERVICE TypedWhichId<SfxStringItem>(SID_SFX_START + 511) #define SID_PLUGIN_MODE TypedWhichId<SfxUInt16Item>(SID_SFX_START + 827) #define SID_EXPORTDOC (SID_SFX_START + 829) @@ -342,7 +343,7 @@ class SvxZoomItem; #define SID_AUTOPILOTMENU (SID_SFX_START + 1381) // Floating Window Template -#define SID_STYLE_DESIGNER (SID_SFX_START + 539) +#define SID_STYLE_DESIGNER TypedWhichId<SfxBoolItem>(SID_SFX_START + 539) #define SID_SIDEBAR_DECK (SID_SFX_START + 850) @@ -384,7 +385,7 @@ class SvxZoomItem; #define SID_INSERT_OBJECT (SID_SFX_START + 561) #define SID_INSERT_FLOATINGFRAME (SID_SFX_START + 563) #define SID_CLASSIFICATION_APPLY (SID_SFX_START + 672) -#define SID_WATERMARK (SID_SFX_START + 676) +#define SID_WATERMARK TypedWhichId<SfxWatermarkItem>(SID_SFX_START + 676) #define SID_WATERMARK_FONT TypedWhichId<SfxStringItem>(SID_SFX_START + 677) #define SID_WATERMARK_TRANSPARENCY TypedWhichId<SfxInt16Item>(SID_SFX_START + 805) #define SID_WATERMARK_COLOR TypedWhichId<SfxUInt32Item>(SID_SFX_START + 806) @@ -408,7 +409,7 @@ class SvxZoomItem; #define SID_NEWWINDOW (SID_SFX_START + 620) #define SID_CLOSEWIN (SID_SFX_START + 621) #define SID_VIEWSHELL TypedWhichId<SfxUInt16Item>(SID_SFX_START + 623) -#define SID_WIN_FULLSCREEN (SID_SFX_START + 627) +#define SID_WIN_FULLSCREEN TypedWhichId<SfxBoolItem>(SID_SFX_START + 627) #define SID_VIEWSHELL0 (SID_SFX_START + 630) #define SID_VIEWSHELL1 (SID_SFX_START + 631) @@ -713,7 +714,7 @@ class SvxZoomItem; #define FN_EDIT2 (SID_SW_START + 1800) #define FN_REDLINE_PROTECT TypedWhichId<SfxBoolItem>(FN_EDIT2 + 23) -#define FN_REDLINE_ON (FN_EDIT2 + 25) +#define FN_REDLINE_ON TypedWhichId<SfxBoolItem>(FN_EDIT2 + 25) #define SID_HTML_MODE TypedWhichId<SfxUInt16Item>(SID_SVX_START + 414) @@ -730,8 +731,8 @@ class SvxZoomItem; #ifndef SC_VIEW_START #define SC_VIEW_START (SID_SC_START) #endif -#define FID_CHG_RECORD (EDIT_MENU_START + 18) -#define SID_CHG_PROTECT (SC_VIEW_START + 84) +#define FID_CHG_RECORD TypedWhichId<SfxBoolItem>(EDIT_MENU_START + 18) +#define SID_CHG_PROTECT TypedWhichId<SfxBoolItem>(SC_VIEW_START + 84) #endif // #ifndef INCLUDED_SFX2_SFXSIDS_HRC diff --git a/include/svx/rulritem.hxx b/include/svx/rulritem.hxx index a5600a6588c4..b45683d31970 100644 --- a/include/svx/rulritem.hxx +++ b/include/svx/rulritem.hxx @@ -38,8 +38,6 @@ class SVX_DLLPUBLIC SvxLongLRSpaceItem final : public SfxPoolItem MapUnit ePresMetric, OUString &rText, const IntlWrapper& ) const override; - virtual SvxLongLRSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override; - const SvxLongLRSpaceItem& operator=(const SvxLongLRSpaceItem &) = delete; public: @@ -48,6 +46,8 @@ public: SvxLongLRSpaceItem(); SvxLongLRSpaceItem(SvxLongLRSpaceItem const &) = default; + virtual SvxLongLRSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override; + tools::Long GetLeft() const { return mlLeft;} tools::Long GetRight() const { return mlRight;} void SetLeft(tools::Long lArgLeft); @@ -68,8 +68,6 @@ class SVX_DLLPUBLIC SvxLongULSpaceItem final : public SfxPoolItem MapUnit ePresMetric, OUString &rText, const IntlWrapper& ) const override; - virtual SvxLongULSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override; - const SvxLongULSpaceItem& operator=(const SvxLongULSpaceItem &) = delete; public: @@ -78,6 +76,8 @@ public: SvxLongULSpaceItem(); SvxLongULSpaceItem(SvxLongULSpaceItem const &) = default; + virtual SvxLongULSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override; + tools::Long GetUpper() const { return mlLeft;} tools::Long GetLower() const { return mlRight;} void SetUpper(tools::Long lArgLeft); diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index af1eddb8c226..4f4c07f2e2d5 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -592,7 +592,7 @@ class XFillGradientItem; #define SID_FM_DELETEROWS ( SID_SVX_START + 610 ) //FREE //FREE -#define SID_FM_CTL_PROPERTIES ( SID_SVX_START + 613 ) +#define SID_FM_CTL_PROPERTIES TypedWhichId<SfxBoolItem>( SID_SVX_START + 613 ) #define SID_FM_PROPERTIES ( SID_SVX_START + 614 ) #define SID_FM_TAB_DIALOG ( SID_SVX_START + 615 ) #define SID_FM_RECORD_FIRST ( SID_SVX_START + 616 ) @@ -1049,6 +1049,7 @@ class XFillGradientItem; #define SID_INSERT_TREECONTROL ( SID_SVX_START + 1206 ) #define SID_ATTR_VIEWLAYOUT TypedWhichId<SvxViewLayoutItem>( SID_SVX_START + 1207 ) #define SID_ATTR_ZOOMSLIDER TypedWhichId<SvxZoomSliderItem>( SID_SVX_START + 1208 ) +// Can be either SfxStringItem or SfxStringListItem #define SID_LANGUAGE_STATUS ( SID_SVX_START + 1209 ) #define SID_CHAR_DLG_FOR_PARAGRAPH ( SID_SVX_START + 1210 ) #define SID_SET_DOCUMENT_LANGUAGE TypedWhichId<SfxBoolItem>( SID_SVX_START + 1211 ) diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 9db6cd3a3ae3..5b84eef452b9 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1575,12 +1575,10 @@ void ScTiledRenderingTest::testDocumentRepair() int nView2 = SfxLokHelper::getView(); CPPUNIT_ASSERT(pView1 != pView2); { - 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()); + std::unique_ptr<SfxBoolItem> pItem1; + std::unique_ptr<SfxBoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT(pItem2); CPPUNIT_ASSERT_EQUAL(false, pItem1->GetValue()); @@ -1596,12 +1594,10 @@ void ScTiledRenderingTest::testDocumentRepair() pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); Scheduler::ProcessEventsToIdle(); { - 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()); + std::unique_ptr<SfxBoolItem> pItem1; + std::unique_ptr<SfxBoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT(pItem2); CPPUNIT_ASSERT_EQUAL(true, pItem1->GetValue()); diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index df62ac25a409..913915a20dc8 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -214,9 +214,8 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet ) case SID_STYLE_UPDATE_BY_EXAMPLE: { - std::unique_ptr<SfxPoolItem> pItem; - pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); bool bPage = pFamilyItem && SfxStyleFamily::Page == static_cast<SfxStyleFamily>(pFamilyItem->GetValue()); @@ -230,9 +229,8 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet ) case SID_STYLE_HIDE: case SID_STYLE_SHOW: { - std::unique_ptr<SfxPoolItem> pItem; - pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); bool bPage = pFamilyItem && SfxStyleFamily::Page == static_cast<SfxStyleFamily>(pFamilyItem->GetValue()); if ( bProtected && !bPage ) diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx index bf691f778a99..7607c8f71bfa 100644 --- a/sc/source/ui/view/viewutil.cxx +++ b/sc/source/ui/view/viewutil.cxx @@ -331,11 +331,11 @@ void ScViewUtil::ExecuteCharMap(const SvxFontItem& rOldFont, bool ScViewUtil::IsFullScreen( const SfxViewShell& rViewShell ) { SfxBindings& rBindings = rViewShell.GetViewFrame()->GetBindings(); - std::unique_ptr<SfxPoolItem> pItem; + std::unique_ptr<SfxBoolItem> pItem; bool bIsFullScreen = false; if (rBindings.QueryState( SID_WIN_FULLSCREEN, pItem ) >= SfxItemState::DEFAULT) - bIsFullScreen = static_cast< SfxBoolItem* >( pItem.get() )->GetValue(); + bIsFullScreen = pItem->GetValue(); return bIsFullScreen; } diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc index 97d43b1d1c06..875dc0cc3e75 100644 --- a/sd/inc/app.hrc +++ b/sd/inc/app.hrc @@ -137,7 +137,7 @@ // In svxids.hrc: SID_BEZIER_CONVERT (SID_SD_START+65) // In svxids.hrc: SID_BEZIER_EDGE (SID_SD_START+66) // In svxids.hrc: SID_BEZIER_SYMMTR (SID_SD_START+67) -#define SID_NOTES_MODE (SID_SD_START+69) +#define SID_NOTES_MODE TypedWhichId<SfxBoolItem>(SID_SD_START+69) #define SID_HANDOUT_MASTER_MODE (SID_SD_START+70) #define SID_LINEEND_POLYGON (SID_SD_START+71) #define SID_EXECUTE_ANIMATION_EFFECT (SID_SD_START+72) @@ -375,7 +375,7 @@ #define SID_SUMMARY_PAGE (SID_SD_START+344) #define SID_LEAVE_ALL_GROUPS (SID_SD_START+345) // FREE -#define SID_SLIDE_MASTER_MODE (SID_SD_START+348) +#define SID_SLIDE_MASTER_MODE TypedWhichId<SfxBoolItem>(SID_SD_START+348) // FREE #define SID_NOTES_MASTER_MODE (SID_SD_START+350) // FREE @@ -430,7 +430,7 @@ // FREE #define SID_NOTES_WINDOW (SID_SD_START+417) // FREE -#define SID_NORMAL_MULTI_PANE_GUI (SID_SD_START+420) +#define SID_NORMAL_MULTI_PANE_GUI TypedWhichId<SfxBoolItem>(SID_SD_START+420) #define SID_SLIDE_SORTER_MULTI_PANE_GUI (SID_SD_START+421) #define SID_SELECT_BACKGROUND (SID_SD_START+422) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 8a4da8dbf301..ebab87741847 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -2201,15 +2201,13 @@ void SdTiledRenderingTest::testDocumentRepair() CPPUNIT_ASSERT(pView1 != pView2); { - std::unique_ptr<SfxPoolItem> xItem1; - pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem1); - const SfxBoolItem* pItem1 = dynamic_cast<const SfxBoolItem*>(xItem1.get()); + std::unique_ptr<SfxBoolItem> pItem1; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT_EQUAL(false, pItem1->GetValue()); - std::unique_ptr<SfxPoolItem> xItem2; - pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem2); - const SfxBoolItem* pItem2 = dynamic_cast<const SfxBoolItem*>(xItem2.get()); + std::unique_ptr<SfxBoolItem> pItem2; + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); CPPUNIT_ASSERT(pItem2); CPPUNIT_ASSERT_EQUAL(false, pItem2->GetValue()); } @@ -2229,15 +2227,13 @@ void SdTiledRenderingTest::testDocumentRepair() CPPUNIT_ASSERT(!pViewShell2->GetView()->IsTextEdit()); { - std::unique_ptr<SfxPoolItem> xItem1; - pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem1); - const SfxBoolItem* pItem1 = dynamic_cast<const SfxBoolItem*>(xItem1.get()); + std::unique_ptr<SfxBoolItem> pItem1; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT_EQUAL(true, pItem1->GetValue()); - std::unique_ptr<SfxPoolItem> xItem2; - pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, xItem2); - const SfxBoolItem* pItem2 = dynamic_cast<const SfxBoolItem*>(xItem2.get()); + std::unique_ptr<SfxBoolItem> pItem2; + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); CPPUNIT_ASSERT(pItem2); CPPUNIT_ASSERT_EQUAL(true, pItem2->GetValue()); } @@ -2296,12 +2292,10 @@ void SdTiledRenderingTest::testDefaultView() SdXImpressDocument* pXImpressDocument = createDoc("notes-view.odp"); sd::ViewShell* pView = pXImpressDocument->GetDocShell()->GetViewShell(); { - std::unique_ptr<SfxPoolItem> xItem1; - std::unique_ptr<SfxPoolItem> xItem2; - pView->GetViewFrame()->GetBindings().QueryState(SID_NORMAL_MULTI_PANE_GUI, xItem1); - pView->GetViewFrame()->GetBindings().QueryState(SID_NOTES_MODE, xItem2); - const SfxBoolItem* pImpressView = dynamic_cast< const SfxBoolItem* >(xItem1.get()); - const SfxBoolItem* pNotesView = dynamic_cast< const SfxBoolItem* >(xItem2.get()); + std::unique_ptr<SfxBoolItem> pImpressView; + std::unique_ptr<SfxBoolItem> pNotesView; + pView->GetViewFrame()->GetBindings().QueryState(SID_NORMAL_MULTI_PANE_GUI, pImpressView); + pView->GetViewFrame()->GetBindings().QueryState(SID_NOTES_MODE, pNotesView); CPPUNIT_ASSERT(pImpressView); CPPUNIT_ASSERT(pNotesView); CPPUNIT_ASSERT_EQUAL(true, pImpressView->GetValue()); diff --git a/sd/source/ui/func/bulmaper.cxx b/sd/source/ui/func/bulmaper.cxx index 13bb404e4be9..67a6678918ea 100644 --- a/sd/source/ui/func/bulmaper.cxx +++ b/sd/source/ui/func/bulmaper.cxx @@ -74,7 +74,7 @@ void SdBulletMapper::MapFontsInNumRule( SvxNumRule& aNumRule, const SfxItemSet& static_cast<const SvxPostureItem&>(rSet.Get(GetWhich( sal_uInt16(SID_ATTR_CHAR_POSTURE) ))); aMyFont.SetItalic(rPItem.GetPosture()); - const SvxUnderlineItem& rUItem = static_cast<const SvxUnderlineItem&>(rSet.Get(GetWhich(SID_ATTR_CHAR_UNDERLINE))); + const SvxUnderlineItem& rUItem = rSet.Get(GetWhich(SID_ATTR_CHAR_UNDERLINE)); aMyFont.SetUnderline(rUItem.GetLineStyle()); const SvxOverlineItem& rOItem = static_cast<const SvxOverlineItem&>(rSet.Get(GetWhich(SID_ATTR_CHAR_OVERLINE))); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 8c705f2a48a4..6fbcf5263118 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2381,9 +2381,8 @@ bool SdXImpressDocument::isMasterViewMode() if (pViewSh->GetDispatcher()) { - const SfxPoolItem* xItem = nullptr; - pViewSh->GetDispatcher()->QueryState(SID_SLIDE_MASTER_MODE, xItem); - const SfxBoolItem* isMasterViewMode = dynamic_cast<const SfxBoolItem*>(xItem); + const SfxBoolItem* isMasterViewMode = nullptr; + pViewSh->GetDispatcher()->QueryState(SID_SLIDE_MASTER_MODE, isMasterViewMode); if (isMasterViewMode && isMasterViewMode->GetValue()) return true; } diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 25422d400f73..c80c6b3bbd5b 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -710,8 +710,8 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) case SID_ATTR_PARA_LINESPACE: if (pArgs) { - SvxLineSpacingItem aParaLineSP = static_cast<const SvxLineSpacingItem&>(pArgs->Get( - GetPool().GetWhich(SID_ATTR_PARA_LINESPACE))); + SvxLineSpacingItem aParaLineSP = pArgs->Get( + GetPool().GetWhich(SID_ATTR_PARA_LINESPACE)); SfxItemSetFixed<EE_PARA_SBL, EE_PARA_SBL> aEditAttr( GetPool() ); aParaLineSP.SetWhich( EE_PARA_SBL ); diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index 471d549cb12a..f23bd042ce23 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -529,9 +529,8 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_WATERCAN: { - std::unique_ptr<SfxPoolItem> pItem; - GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo) rSet.Put(SfxBoolItem(nWhich,false)); else @@ -544,9 +543,8 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_NEW: { - std::unique_ptr<SfxPoolItem> pItem; - GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo) { rSet.DisableItem(nWhich); @@ -556,9 +554,8 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_DRAGHIERARCHIE: { - std::unique_ptr<SfxPoolItem> pItem; - GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo) rSet.DisableItem(nWhich); } @@ -569,9 +566,8 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) // It is not possible to create PseudoStyleSheets 'by Example'; // normal style sheets need a selected object for that - std::unique_ptr<SfxPoolItem> pItem; - GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem) { if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo) diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index a24f3596b290..0eb351f915b0 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -1460,9 +1460,8 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_EDIT: { - std::unique_ptr<SfxPoolItem> pItem; - GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo) { SfxItemSetFixed<SID_STATUS_LAYOUT, SID_STATUS_LAYOUT> aSet(*rSet.GetPool()); diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 7441e47c1746..43ef5115908b 100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -44,18 +44,18 @@ namespace { enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; - bool QueryState( sal_uInt16 _nSlot, bool& _rValue ) + bool QueryState( TypedWhichId<SfxBoolItem> _nSlot, bool& _rValue ) { bool bRet = false; SfxViewShell* pViewSh = SfxViewShell::Current(); if (pViewSh) { - const SfxPoolItem* pItem; + const SfxBoolItem* pItem; SfxDispatcher* pDisp = pViewSh->GetDispatcher(); SfxItemState nState = pDisp->QueryState( _nSlot, pItem ); bRet = SfxItemState::DEFAULT <= nState; if (bRet) - _rValue = static_cast< const SfxBoolItem* >( pItem )->GetValue(); + _rValue = pItem->GetValue(); } return bRet; } @@ -66,7 +66,7 @@ namespace bool bRet = false; if (_eMode != RL_NONE) { - sal_uInt16 nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; + TypedWhichId<SfxBoolItem> nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; bRet = QueryState( nSlot, _rValue ); } return bRet; @@ -78,7 +78,7 @@ namespace bool bRet = false; if (_eMode != RL_NONE) { - sal_uInt16 nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; + TypedWhichId<SfxBoolItem> nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; bRet = QueryState( nSlot, _rValue ); } return bRet; @@ -246,11 +246,11 @@ void SfxSecurityPage_Impl::Reset_Impl() SfxViewShell* pViewSh = SfxViewShell::Current(); if (pViewSh) { - const SfxPoolItem* pItem; + const SfxUInt16Item* pItem; SfxDispatcher* pDisp = pViewSh->GetDispatcher(); if (SfxItemState::DEFAULT <= pDisp->QueryState( SID_HTML_MODE, pItem )) { - sal_uInt16 nMode = static_cast< const SfxUInt16Item* >( pItem )->GetValue(); + sal_uInt16 nMode = pItem->GetValue(); bIsHTMLDoc = ( ( nMode & HTMLMODE_ON ) != 0 ); } } diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx index 006b07cc0918..9bc87b222fd4 100644 --- a/svx/source/dialog/rubydialog.cxx +++ b/svx/source/dialog/rubydialog.cxx @@ -533,10 +533,9 @@ IMPL_LINK_NOARG(SvxRubyDialog, CloseHdl_Impl, weld::Button&, void) { Close(); } IMPL_LINK_NOARG(SvxRubyDialog, StylistHdl_Impl, weld::Button&, void) { - std::unique_ptr<SfxPoolItem> pState; + std::unique_ptr<SfxBoolItem> pState; SfxItemState eState = pBindings->QueryState(SID_STYLE_DESIGNER, pState); - if (eState <= SfxItemState::SET || !pState - || !static_cast<SfxBoolItem*>(pState.get())->GetValue()) + if (eState <= SfxItemState::SET || !pState || !pState->GetValue()) { pBindings->GetDispatcher()->Execute(SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 3906a6047258..762144002948 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -798,12 +798,12 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& rM // ask the bindings of the current view frame (which should be the one we're residing in) for the state if (pCurrentFrame) { - std::unique_ptr<SfxPoolItem> pItem; + std::unique_ptr<SfxBoolItem> pItem; SfxItemState eState = pCurrentFrame->GetBindings().QueryState(SID_FM_CTL_PROPERTIES, pItem); if (eState >= SfxItemState::DEFAULT && pItem != nullptr) { - bool bChecked = dynamic_cast<const SfxBoolItem*>( pItem.get()) != nullptr && static_cast<SfxBoolItem*>(pItem.get())->GetValue(); + bool bChecked = pItem && pItem->GetValue(); rMenu.set_active("column", bChecked); } } diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx index 9a7b69b1a51d..9ff16f340b15 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx @@ -82,10 +82,10 @@ ParaLineSpacingControl::ParaLineSpacingControl(SvxLineSpacingToolBoxControl* pCo mxLineDistAtMetricBox->connect_value_changed( aLink2 ); FieldUnit eUnit = FieldUnit::INCH; - const SfxPoolItem* pItem = nullptr; + const SfxUInt16Item* pItem = nullptr; SfxViewFrame* pCurrent = SfxViewFrame::Current(); if (pCurrent && pCurrent->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem) >= SfxItemState::DEFAULT) - eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); + eUnit = static_cast<FieldUnit>(pItem->GetValue()); else eUnit = SfxModule::GetCurrentFieldUnit(); @@ -122,7 +122,7 @@ ParaLineSpacingControl::~ParaLineSpacingControl() void ParaLineSpacingControl::Initialize() { - const SfxPoolItem* pItem(nullptr); + const SvxLineSpacingItem* pItem(nullptr); SfxViewFrame* pCurrent = SfxViewFrame::Current(); const bool bItemStateSet(nullptr != pCurrent); const SfxItemState eState(bItemStateSet @@ -133,7 +133,7 @@ void ParaLineSpacingControl::Initialize() if( bItemStateSet && (eState == SfxItemState::DEFAULT || eState == SfxItemState::SET) ) { - const SvxLineSpacingItem* currSPItem = static_cast<const SvxLineSpacingItem*>(pItem); + const SvxLineSpacingItem* currSPItem = pItem; MapUnit eUnit = pCurrent->GetPool().GetMetric(currSPItem->Which()); meLNSpaceUnit = eUnit; diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx index ba528d702282..0826434b79fb 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx +++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx @@ -106,10 +106,9 @@ TextCharacterSpacingControl::~TextCharacterSpacingControl() void TextCharacterSpacingControl::Initialize() { - const SfxPoolItem* pItem; - SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_KERNING, pItem); + const SvxKerningItem* pKerningItem; + SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_KERNING, pKerningItem); - const SvxKerningItem* pKerningItem = dynamic_cast<const SvxKerningItem*>(pItem); tools::Long nKerning = 0; if(pKerningItem) diff --git a/svx/source/sidebar/text/TextUnderlineControl.cxx b/svx/source/sidebar/text/TextUnderlineControl.cxx index 380389509865..9d79e924e877 100644 --- a/svx/source/sidebar/text/TextUnderlineControl.cxx +++ b/svx/source/sidebar/text/TextUnderlineControl.cxx @@ -99,10 +99,8 @@ namespace { Color GetUnderlineColor() { - const SfxPoolItem* pItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_UNDERLINE, pItem); - - const SvxUnderlineItem* pUnderlineItem = static_cast<const SvxUnderlineItem*>(pItem); + const SvxUnderlineItem* pUnderlineItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_UNDERLINE, pUnderlineItem); if(pUnderlineItem) return pUnderlineItem->GetColor(); diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 9d26cbe7197a..c42818d25fa5 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -281,8 +281,8 @@ class SwUINumRuleItem; #define FN_JAVAEDIT (FN_INSERT2 + 10) /* edit script field */ #define FN_TOOL_ANCHOR_AT_CHAR (FN_INSERT2 + 12) /* anchor object to character*/ -#define FN_INSERT_PAGEHEADER (FN_INSERT2 + 13) /* insert default header */ -#define FN_INSERT_PAGEFOOTER (FN_INSERT2 + 14) /* insert default footer */ +#define FN_INSERT_PAGEHEADER TypedWhichId<SfxStringListItem>(FN_INSERT2 + 13) /* insert default header */ +#define FN_INSERT_PAGEFOOTER TypedWhichId<SfxStringListItem>(FN_INSERT2 + 14) /* insert default footer */ #define FN_INSERT_ENDNOTE (FN_INSERT2 + 18) /* insert endnote*/ #define FN_INSERT_REGION TypedWhichId<SfxUInt16Item>(FN_INSERT2 + 19) /* Insert section */ diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index cc50ef8e9c83..a5083731c5a3 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -2243,12 +2243,10 @@ void SwTiledRenderingTest::testDocumentRepair() int nView2 = SfxLokHelper::getView(); CPPUNIT_ASSERT(pView1 != pView2); { - 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()); + std::unique_ptr<SfxBoolItem> pItem1; + std::unique_ptr<SfxBoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT(pItem2); CPPUNIT_ASSERT_EQUAL(false, pItem1->GetValue()); @@ -2261,12 +2259,10 @@ void SwTiledRenderingTest::testDocumentRepair() pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'u', 0); Scheduler::ProcessEventsToIdle(); { - 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()); + std::unique_ptr<SfxBoolItem> pItem1; + std::unique_ptr<SfxBoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); CPPUNIT_ASSERT(pItem1); CPPUNIT_ASSERT(pItem2); CPPUNIT_ASSERT_EQUAL(true, pItem1->GetValue()); @@ -2281,12 +2277,11 @@ void SwTiledRenderingTest::testDocumentRepair() namespace { - void checkPageHeaderOrFooter(const SfxViewShell* pViewShell, sal_uInt16 nWhich, bool bValue) + void checkPageHeaderOrFooter(const SfxViewShell* pViewShell, TypedWhichId<SfxStringListItem> nWhich, bool bValue) { uno::Sequence<OUString> aSeq; - const SfxPoolItem* pState = nullptr; - pViewShell->GetDispatcher()->QueryState(nWhich, pState); - const SfxStringListItem* pListItem = dynamic_cast<const SfxStringListItem*>(pState); + const SfxStringListItem* pListItem = nullptr; + pViewShell->GetDispatcher()->QueryState(nWhich, pListItem); CPPUNIT_ASSERT(pListItem); pListItem->GetStringList(aSeq); if (bValue) @@ -2474,9 +2469,8 @@ void SwTiledRenderingTest::testIMEFormattingAtEndOfParagraph() pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "a"); pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); - std::unique_ptr<SfxPoolItem> pItem; - pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); - auto pWeightItem = dynamic_cast<SvxWeightItem*>(pItem.get()); + std::unique_ptr<SvxWeightItem> pWeightItem; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pWeightItem); CPPUNIT_ASSERT(pWeightItem); CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_BOLD, pWeightItem->GetWeight()); @@ -2494,8 +2488,8 @@ void SwTiledRenderingTest::testIMEFormattingAtEndOfParagraph() pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "b"); pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); - pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); - auto pWeightItem2 = dynamic_cast<SvxWeightItem*>(pItem.get()); + std::unique_ptr<SvxWeightItem> pWeightItem2; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pWeightItem2); CPPUNIT_ASSERT(pWeightItem2); CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_NORMAL, pWeightItem2->GetWeight()); @@ -2510,8 +2504,8 @@ void SwTiledRenderingTest::testIMEFormattingAtEndOfParagraph() pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "a"); pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); - pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); - auto pWeightItem3 = dynamic_cast<SvxWeightItem*>(pItem.get()); + std::unique_ptr<SvxWeightItem> pWeightItem3; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pWeightItem3); CPPUNIT_ASSERT(pWeightItem3); CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_BOLD, pWeightItem3->GetWeight()); @@ -2522,8 +2516,8 @@ void SwTiledRenderingTest::testIMEFormattingAtEndOfParagraph() pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "b"); pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); - pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); - auto pWeightItem4 = dynamic_cast<SvxWeightItem*>(pItem.get()); + std::unique_ptr<SvxWeightItem> pWeightItem4; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pWeightItem4); CPPUNIT_ASSERT(pWeightItem4); CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_NORMAL, pWeightItem4->GetWeight()); @@ -2580,9 +2574,8 @@ void SwTiledRenderingTest::testIMEFormattingAfterHeader() pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); Scheduler::ProcessEventsToIdle(); - std::unique_ptr<SfxPoolItem> pItem; - pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); - auto pWeightItem = dynamic_cast<SvxWeightItem*>(pItem.get()); + std::unique_ptr<SvxWeightItem> pWeightItem; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pWeightItem); CPPUNIT_ASSERT(pWeightItem); CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_BOLD, pWeightItem->GetWeight()); @@ -2602,8 +2595,8 @@ void SwTiledRenderingTest::testIMEFormattingAfterHeader() // <h2>bb</h2>\n" // c" - pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); - auto pWeightItem2 = dynamic_cast<SvxWeightItem*>(pItem.get()); + std::unique_ptr<SvxWeightItem> pWeightItem2; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pWeightItem2); CPPUNIT_ASSERT(pWeightItem2); CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_NORMAL, pWeightItem2->GetWeight()); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 0fe486ee2232..0d872d4e958f 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -647,14 +647,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkDOCX) { SwDoc* const pDoc = createSwDoc(DATA_DIRECTORY, "watermark.docx"); SwDocShell* pDocShell = pDoc->GetDocShell(); - const SfxPoolItem* pItem; - SfxItemState eState = pDocShell->GetViewShell()->GetViewFrame()->GetDispatcher()->QueryState(SID_WATERMARK, pItem); + const SfxWatermarkItem* pWatermark; + SfxItemState eState = pDocShell->GetViewShell()->GetViewFrame()->GetDispatcher()->QueryState(SID_WATERMARK, pWatermark); CPPUNIT_ASSERT(eState >= SfxItemState::DEFAULT); - CPPUNIT_ASSERT(pItem); - CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(SID_WATERMARK), pItem->Which()); + CPPUNIT_ASSERT(pWatermark); + CPPUNIT_ASSERT_EQUAL(static_cast<unsigned short>(SID_WATERMARK), pWatermark->Which()); - const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>(pItem); CPPUNIT_ASSERT_EQUAL(OUString("CustomWatermark"), pWatermark->GetText()); CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Sans Light"), pWatermark->GetFont()); CPPUNIT_ASSERT_EQUAL(sal_Int16(45), pWatermark->GetAngle()); diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 42eeebf1bf70..b4456c3066dc 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -104,9 +104,8 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) else { SfxViewFrame* pFrame = pShell->GetView().GetViewFrame(); - std::unique_ptr<SfxPoolItem> pItem; - pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem) { nActualFamily = static_cast<SfxStyleFamily>(pFamilyItem->GetValue()); diff --git a/sw/source/uibase/dialog/watermarkdialog.cxx b/sw/source/uibase/dialog/watermarkdialog.cxx index 62dbe8711f23..3e9a914a2917 100644 --- a/sw/source/uibase/dialog/watermarkdialog.cxx +++ b/sw/source/uibase/dialog/watermarkdialog.cxx @@ -78,13 +78,12 @@ void SwWatermarkDialog::InitFields() m_xOKButton->connect_clicked(LINK(this, SwWatermarkDialog, OKButtonHdl)); // Get watermark properties - const SfxPoolItem* pItem; - SfxItemState eState = m_rBindings.GetDispatcher()->QueryState( SID_WATERMARK, pItem ); + const SfxWatermarkItem* pWatermark; + SfxItemState eState = m_rBindings.GetDispatcher()->QueryState( SID_WATERMARK, pWatermark ); - if( !(eState >= SfxItemState::DEFAULT && pItem && pItem->Which() == SID_WATERMARK)) + if( !(eState >= SfxItemState::DEFAULT && pWatermark && pWatermark->Which() == SID_WATERMARK)) return; - const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>( pItem ); const OUString& sText = pWatermark->GetText(); m_xTextInput->set_text(sText); OUString sFontName = pWatermark->GetFont(); diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx index adf10c4af58e..18d4ef4248d1 100644 --- a/sw/source/uibase/sidebar/PageColumnControl.cxx +++ b/sw/source/uibase/sidebar/PageColumnControl.cxx @@ -39,9 +39,9 @@ PageColumnControl::PageColumnControl(PageColumnPopup* pControl, weld::Widget* pP bool bLandscape = false; if ( SfxViewFrame::Current() ) { - const SfxPoolItem *pItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); - bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); + const SvxPageItem *pPageItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); + bLandscape = pPageItem->IsLandscape(); } if ( bLandscape ) diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index cd86320d7a77..632e94140e4f 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -54,11 +54,11 @@ namespace FieldUnit lcl_GetFieldUnit() { FieldUnit eUnit = FieldUnit::INCH; - const SfxPoolItem* pItem = nullptr; + const SfxUInt16Item* pItem = nullptr; SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem ); if ( pItem && eState >= SfxItemState::DEFAULT ) { - eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>( pItem )->GetValue()); + eUnit = static_cast<FieldUnit>(pItem->GetValue()); } else { @@ -132,16 +132,13 @@ PageMarginControl::PageMarginControl(PageMarginPopup* pControl, weld::Widget* pP const SvxLongULSpaceItem* pULItem = nullptr; if ( SfxViewFrame::Current() ) { - const SfxPoolItem* pItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); - bLandscape = static_cast<const SvxPageItem*>( pItem )->IsLandscape(); - m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SvxPageUsage::Mirror; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem ); - pSize = static_cast<const SvxSizeItem*>( pItem ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pItem ); - pLRItem = static_cast<const SvxLongLRSpaceItem*>( pItem ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pItem ); - pULItem = static_cast<const SvxLongULSpaceItem*>( pItem ); + const SvxPageItem* pPageItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); + bLandscape = pPageItem->IsLandscape(); + m_bMirrored = pPageItem->GetPageUsage() == SvxPageUsage::Mirror; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize ); + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pLRItem ); + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pULItem ); } if ( pLRItem ) diff --git a/sw/source/uibase/sidebar/PageOrientationControl.cxx b/sw/source/uibase/sidebar/PageOrientationControl.cxx index b6f8aa78fff0..7f512d25516a 100644 --- a/sw/source/uibase/sidebar/PageOrientationControl.cxx +++ b/sw/source/uibase/sidebar/PageOrientationControl.cxx @@ -100,9 +100,9 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape ) if ( mxUndoManager.is() ) mxUndoManager->enterUndoContext( "" ); - const SfxPoolItem* pItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pItem); - mpPageSizeItem.reset( static_cast<SvxSizeItem*>(pItem->Clone()) ); + const SvxSizeItem* pSizeItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pSizeItem); + mpPageSizeItem.reset( pSizeItem->Clone() ); // Prevent accidental toggling of page orientation if ((mpPageSizeItem->GetWidth() > mpPageSizeItem->GetHeight()) == bLandscape) @@ -112,11 +112,13 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape ) return; } - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pItem); - mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pItem->Clone()) ); + const SvxLongLRSpaceItem* pLRSpaceItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem); + mpPageLRMarginItem.reset( pLRSpaceItem->Clone() ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pItem); - mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pItem->Clone()) ); + const SvxLongULSpaceItem* pULSpaceItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem); + mpPageULMarginItem.reset( pULSpaceItem->Clone() ); { // set new page orientation diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index 7ccee9bd302e..85c41ae80689 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -46,11 +46,11 @@ namespace FieldUnit lcl_GetFieldUnit() { FieldUnit eUnit = FieldUnit::INCH; - const SfxPoolItem* pItem = nullptr; + const SfxUInt16Item* pItem = nullptr; SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem ); if ( pItem && eState >= SfxItemState::DEFAULT ) { - eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); + eUnit = static_cast<FieldUnit>(pItem->GetValue()); } else { @@ -122,11 +122,10 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent) const SvxSizeItem* pSize = nullptr; if ( SfxViewFrame::Current() ) { - const SfxPoolItem* pItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); - bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem ); - pSize = static_cast<const SvxSizeItem*>(pItem); + const SvxPageItem* pPageItem; + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); + bLandscape = pPageItem->IsLandscape(); + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize ); } const LocaleDataWrapper& localeDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); @@ -194,13 +193,13 @@ PageSizeControl::~PageSizeControl() void PageSizeControl::ExecuteSizeChange( const Paper ePaper ) { bool bLandscape = false; - const SfxPoolItem *pItem; + const SvxPageItem *pItem; MapUnit eUnit = lcl_GetUnit(); if ( !SfxViewFrame::Current() ) return; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); - bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); + bLandscape = pItem->IsLandscape(); SvxSizeItem aPageSizeItem(SID_ATTR_PAGE_SIZE); Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, eUnit ); |