diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/cmdid.h | 4 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 53 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 9 | ||||
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/dialog/watermarkdialog.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageColumnControl.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageMarginControl.cxx | 21 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageOrientationControl.cxx | 16 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.cxx | 17 |
9 files changed, 63 insertions, 75 deletions
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 ); |