diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-01 14:53:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-11-01 17:11:35 +0100 |
commit | 2bd6876f0f4596eb4ffad1109ca0c2896f9bda84 (patch) | |
tree | 4d7b544b6c8968cd3c783e5667dc66744b107ea7 /cui | |
parent | 59372ead7ee158cdc6f2f08e4008c06697e91139 (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/+/124552
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
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 68550fe1b94f..3db4e5c20ca5 100644 --- a/cui/source/tabpages/align.cxx +++ b/cui/source/tabpages/align.cxx @@ -56,7 +56,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) @@ -78,14 +78,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 @@ -615,19 +620,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(); @@ -668,7 +697,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); |