diff options
Diffstat (limited to 'cui/source/tabpages/align.cxx')
-rw-r--r-- | cui/source/tabpages/align.cxx | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx index 3db4e5c20ca5..d5816158d70b 100644 --- a/cui/source/tabpages/align.cxx +++ b/cui/source/tabpages/align.cxx @@ -56,24 +56,23 @@ namespace { template<typename JustContainerType, typename JustEnumType> void lcl_MaybeResetAlignToDistro( - weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, sal_uInt16 nWhichAlign, sal_uInt16 nWhichJM, JustEnumType eBlock) + weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, TypedWhichId<SfxEnumItemInterface> nWhichAlign, TypedWhichId<SfxEnumItemInterface> nWhichJM, JustEnumType eBlock) { - const SfxPoolItem* pItem; - if (rCoreAttrs.GetItemState(nWhichAlign, true, &pItem) != SfxItemState::SET) + const SfxEnumItemInterface* p = rCoreAttrs.GetItemIfSet(nWhichAlign); + if (!p) // alignment not set. return; - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); JustContainerType eVal = static_cast<JustContainerType>(p->GetEnumValue()); if (eVal != eBlock) // alignment is not 'justify'. No need to go further. return; - if (rCoreAttrs.GetItemState(nWhichJM, true, &pItem) != SfxItemState::SET) + p = rCoreAttrs.GetItemIfSet(nWhichJM); + if (!p) // justification method is not set. return; - p = static_cast<const SfxEnumItemInterface*>(pItem); SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); if (eMethod == SvxCellJustifyMethod::Distribute) { @@ -124,7 +123,6 @@ AlignmentTabPage::AlignmentTabPage(weld::Container* pPage, weld::DialogControlle , m_xCbStacked(m_xBuilder->weld_check_button("checkVertStack")) , m_xCbAsianMode(m_xBuilder->weld_check_button("checkAsianMode")) // Properties - , m_xBoxDirection(m_xBuilder->weld_widget("boxDirection")) , m_xBtnWrap(m_xBuilder->weld_check_button("checkWrapTextAuto")) , m_xBtnHyphen(m_xBuilder->weld_check_button("checkHyphActive")) , m_xBtnShrink(m_xBuilder->weld_check_button("checkShrinkFitCellSize")) @@ -224,7 +222,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pIndentItem); std::unique_ptr<SfxUInt16Item> pNewIndentItem(pIndentItem->Clone()); pNewIndentItem->SetValue(m_xEdIndent->get_value(FieldUnit::TWIP)); - rSet->Put(*pNewIndentItem); + rSet->Put(std::move(pNewIndentItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -267,25 +265,25 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pAngleItem); std::unique_ptr<SdrAngleItem> pNewAngleItem(pAngleItem->Clone()); pNewAngleItem->SetValue(m_xCtrlDial->GetRotation()); - rSet->Put(*pNewAngleItem); + rSet->Put(std::move(pNewAngleItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) rSet->InvalidateItem(nWhich); - nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS); + TypedWhichId<SvxRotateModeItem> nWhichLockPos(GetWhich(SID_ATTR_ALIGN_LOCKPOS)); if (m_aVsRefEdge.IsValueChangedFromSaved()) { switch (m_aVsRefEdge.GetSelectedItemId()) { case IID_CELLLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhichLockPos)); break; case IID_TOPLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhichLockPos)); break; case IID_BOTTOMLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhichLockPos)); break; default: m_aVsRefEdge.SetNoSelection(); @@ -293,8 +291,8 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) } bChanged = true; } - else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) - rSet->InvalidateItem(nWhich); + else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhichLockPos, false)) + rSet->InvalidateItem(nWhichLockPos); nWhich = GetWhich(SID_ATTR_ALIGN_STACKED); if (m_xCbStacked->get_state_changed_from_saved()) @@ -304,7 +302,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pStackItem); std::unique_ptr<SfxBoolItem> pNewStackItem(pStackItem->Clone()); pNewStackItem->SetValue(m_xCbStacked->get_active()); - rSet->Put(*pNewStackItem); + rSet->Put(std::move(pNewStackItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -327,7 +325,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pWrapItem); std::unique_ptr<SfxBoolItem> pNewWrapItem(pWrapItem->Clone()); pNewWrapItem->SetValue(m_xBtnWrap->get_active()); - rSet->Put(*pNewWrapItem); + rSet->Put(std::move(pNewWrapItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -341,7 +339,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pHyphItem); std::unique_ptr<SfxBoolItem> pNewHyphItem(pHyphItem->Clone()); pNewHyphItem->SetValue(m_xBtnHyphen->get_active()); - rSet->Put(*pNewHyphItem); + rSet->Put(std::move(pNewHyphItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -355,7 +353,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pShrinkItem); std::unique_ptr<SfxBoolItem> pNewShrinkItem(pShrinkItem->Clone()); pNewShrinkItem->SetValue(m_xBtnShrink->get_active()); - rSet->Put(*pNewShrinkItem); + rSet->Put(std::move(pNewShrinkItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -376,12 +374,12 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) // Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification. - sal_uInt16 nWhichHorJM = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nWhichHorJM(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD)); lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED); if (!bChanged) bChanged = HasAlignmentChanged(*rSet, nWhichHorJM); - sal_uInt16 nWhichVerJM = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nWhichVerJM(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD)); lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichVerJM, *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED); if (!bChanged) bChanged = HasAlignmentChanged(*rSet, nWhichVerJM); @@ -404,7 +402,7 @@ namespace rBtn.set_sensitive(false); rTriState.bTriStateEnabled = false; break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: rBtn.set_state(TRISTATE_INDET); rTriState.bTriStateEnabled = true; break; @@ -441,7 +439,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbHorAlign->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbHorAlign->set_active(-1); break; case SfxItemState::DEFAULT: @@ -484,7 +482,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xEdIndent->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xEdIndent->set_text(""); break; case SfxItemState::DEFAULT: @@ -507,7 +505,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbVerAlign->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbVerAlign->set_active(-1); break; case SfxItemState::DEFAULT: @@ -548,7 +546,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) m_xNfRotate->set_sensitive(false); m_xCtrlDialWin->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xCtrlDial->SetNoRotation(); break; case SfxItemState::DEFAULT: @@ -570,7 +568,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xVsRefEdge->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aVsRefEdge.SetNoSelection(); break; case SfxItemState::DEFAULT: @@ -608,7 +606,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbFrameDir->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbFrameDir->set_active(-1); break; case SfxItemState::DEFAULT: @@ -622,7 +620,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification. - sal_uInt16 nHorJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nHorJustifyMethodWhich(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD)); SfxItemState eHorJustifyMethodState = pCoreAttrs->GetItemState(nHorJustifyMethodWhich); if (eHorJustifyMethodState == SfxItemState::UNKNOWN) { @@ -636,11 +634,11 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // feature known, e.g. calc lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>( *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), nHorJustifyMethodWhich, + TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY)), nHorJustifyMethodWhich, SvxCellHorJustify::Block); } - sal_uInt16 nVerJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nVerJustifyMethodWhich( GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD) ); SfxItemState eVerJustifyMethodState = pCoreAttrs->GetItemState(nVerJustifyMethodWhich); if (eVerJustifyMethodState == SfxItemState::UNKNOWN) { @@ -654,7 +652,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // feature known, e.g. calc lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>( *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), nVerJustifyMethodWhich, + TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY)), nVerJustifyMethodWhich, SvxCellVerJustify::Block); } @@ -736,21 +734,18 @@ void AlignmentTabPage::UpdateEnableControls() m_xNfRotate->set_sensitive(!bHorFill && !bStackedText); } -bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const +bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, TypedWhichId<SfxEnumItemInterface> nWhich ) const { const SfxItemSet& rOld = GetItemSet(); - const SfxPoolItem* pItem; SvxCellJustifyMethod eMethodOld = SvxCellJustifyMethod::Auto; SvxCellJustifyMethod eMethodNew = SvxCellJustifyMethod::Auto; - if (rOld.GetItemState(nWhich, true, &pItem) == SfxItemState::SET) + if (const SfxEnumItemInterface* p = rOld.GetItemIfSet(nWhich)) { - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); } - if (rNew.GetItemState(nWhich, true, &pItem) == SfxItemState::SET) + if (const SfxEnumItemInterface* p = rNew.GetItemIfSet(nWhich)) { - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); } |