diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-01 14:53:49 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-02 09:52:10 +0100 |
commit | 2c59baecb325211e5f01878b517265ce658de4fc (patch) | |
tree | 0e88583c7334787cbaa8a30b800fc8a7a05e5afb /cui | |
parent | 836e37bac767ce6eea4b0e0c9342976e8238cc46 (diff) |
tdf#138698 remove/ignore 'distributed' if feature is unknown
which it is in dbaccess. Its is a calc feature added at...
commit 755ad6834625488c5d31d4bacc9370eae7ffd8f3
Date: Tue Oct 5 11:15:56 2010 -0400
Ported calc-distributed-cell-text-*.diff from ooo-build.
Change-Id: I1e8856e2ab635d270a487f5a68ac5c386f46a080
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124473
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/tabpages/align.cxx | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx index 5937a2b28995..97226ccec1a4 100644 --- a/cui/source/tabpages/align.cxx +++ b/cui/source/tabpages/align.cxx @@ -58,7 +58,7 @@ namespace { template<typename JustContainerType, typename JustEnumType> void lcl_MaybeResetAlignToDistro( - weld::ComboBox& rLB, sal_uInt16 nListPos, const SfxItemSet& rCoreAttrs, sal_uInt16 nWhichAlign, sal_uInt16 nWhichJM, JustEnumType eBlock) + weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, sal_uInt16 nWhichAlign, sal_uInt16 nWhichJM, JustEnumType eBlock) { const SfxPoolItem* pItem; if (rCoreAttrs.GetItemState(nWhichAlign, true, &pItem) != SfxItemState::SET) @@ -80,14 +80,19 @@ void lcl_MaybeResetAlignToDistro( if (eMethod == SvxCellJustifyMethod::Distribute) { // Select the 'distribute' entry in the specified list box. - rLB.set_active(nListPos); + rLB.set_active_id(OUString::number(nListId)); } } -void lcl_SetJustifyMethodToItemSet(SfxItemSet& rSet, const SfxItemSet& rOldSet, sal_uInt16 nWhichJM, const weld::ComboBox& rLB, sal_uInt16 nListPos) +void lcl_SetJustifyMethodToItemSet(SfxItemSet& rSet, const SfxItemSet& rOldSet, sal_uInt16 nWhichJM, const weld::ComboBox& rLB, sal_uInt16 nListId) { + // tdf#138698 unsupported, e.g. dbaccess + if (rLB.find_id(OUString::number(nListId)) == -1) + return; + + // feature supported , e.g. calc SvxCellJustifyMethod eJM = SvxCellJustifyMethod::Auto; - if (rLB.get_active() == nListPos) + if (rLB.get_active_id().toInt32() == nListId) eJM = SvxCellJustifyMethod::Distribute; // tdf#129300 If it would create no change, don't force it @@ -617,19 +622,43 @@ 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); + SfxItemState eHorJustifyMethodState = pCoreAttrs->GetItemState(nHorJustifyMethodWhich); + if (eHorJustifyMethodState == SfxItemState::UNKNOWN) + { + // feature unknown, e.g. dbaccess, remove the option + int nDistribId = m_xLbHorAlign->find_id(OUString::number(ALIGNDLG_HORALIGN_DISTRIBUTED)); + if (nDistribId != -1) + m_xLbHorAlign->remove(nDistribId); + } + else + { + // feature known, e.g. calc + lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>( + *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, *pCoreAttrs, + GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), nHorJustifyMethodWhich, + SvxCellHorJustify::Block); + } - lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>( - *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD), - SvxCellHorJustify::Block); - - lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>( - *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD), - SvxCellVerJustify::Block); + sal_uInt16 nVerJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + SfxItemState eVerJustifyMethodState = pCoreAttrs->GetItemState(nVerJustifyMethodWhich); + if (eVerJustifyMethodState == SfxItemState::UNKNOWN) + { + // feature unknown, e.g. dbaccess, remove the option + int nDistribId = m_xLbVerAlign->find_id(OUString::number(ALIGNDLG_VERALIGN_DISTRIBUTED)); + if (nDistribId != -1) + m_xLbVerAlign->remove(nDistribId); + } + else + { + // feature known, e.g. calc + lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>( + *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, *pCoreAttrs, + GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), nVerJustifyMethodWhich, + SvxCellVerJustify::Block); + } m_xLbHorAlign->save_value(); m_xLbFrameDir->save_value(); @@ -670,7 +699,7 @@ void AlignmentTabPage::InitVsRefEgde() void AlignmentTabPage::UpdateEnableControls() { - const sal_Int32 nHorAlign = m_xLbHorAlign->get_active(); + const sal_Int32 nHorAlign = m_xLbHorAlign->get_active_id().toInt32(); bool bHorLeft = (nHorAlign == ALIGNDLG_HORALIGN_LEFT); bool bHorBlock = (nHorAlign == ALIGNDLG_HORALIGN_BLOCK); bool bHorFill = (nHorAlign == ALIGNDLG_HORALIGN_FILL); |