sc/source/core/data/patattr.cxx | 32 +++++++++++++------------------- sc/source/ui/view/output2.cxx | 10 +--------- 2 files changed, 14 insertions(+), 28 deletions(-)
New commits: commit 0b9e0f20763f0e723d66f31aee85205deec9f6f8 Author: Eike Rathke <er...@redhat.com> AuthorDate: Sun Oct 27 00:25:28 2019 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Oct 30 18:04:18 2019 +0100 Resolves: tdf#117715 Conditional format takes precedence; reverts tdf#93300 This is a combination of 3 commits. Resolves: tdf#128403 Use ScPatternAttr::GetNumberFormat() ... it does or will do the right thing. See also https://bugs.documentfoundation.org/show_bug.cgi?id=117715#c12 Reviewed-on: https://gerrit.libreoffice.org/81548 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> (cherry picked from commit f357831478ca063190eedeef12635117b8360277) Related: tdf#117715 tdf#128403 Couple ATTR_LANGUAGE_FORMAT ATTR_VALUE_FORMAT Do not obtain ATTR_VALUE_FORMAT from hard attribute and ATTR_LANGUAGE_FORMAT from conditional format. Though it doesn't matter in the bugs' cases it's wrong. ATTR_LANGUAGE_FORMAT belongs to the ATTR_VALUE_FORMAT if set. Reviewed-on: https://gerrit.libreoffice.org/81547 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> (cherry picked from commit 4dfb22acfe30f9322ecc0ad9d01b17a3814c87a2) Resolves: tdf#117715 Conditional format takes precedence; reverts tdf#93300 Reviewed-on: https://gerrit.libreoffice.org/81550 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit 2b0626161d3ef7c4a51007018d13ec391d3a2b04) 4ecaa6be8b2358d4ea4d84655cde74dce5319c2a 9ec2d7523e22a40c3fe4a655fe9082ab6158c376 Change-Id: I635ca58961ae5ae315bdd77c4fff9f3f41bebd15 Reviewed-on: https://gerrit.libreoffice.org/81552 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index bf3d1dc115e2..92e91a42365c 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1253,31 +1253,25 @@ sal_uInt32 ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter, if (!pCondSet) return GetNumberFormat(pFormatter); - /* In the case of a conditional format we need to overwrite a cell style - * but leave a hard cell formatting alone. So check first if the number - * format is set in the cell format, then the conditional format and - * finally in the style. - * - * The style is represented here if the name is empty. - */ + // Conditional format takes precedence over style and even hard format. const SfxPoolItem* pFormItem; - sal_uLong nFormat = 0; - if (GetItemSet().GetItemState(ATTR_VALUE_FORMAT, false, &pFormItem) == SfxItemState::SET) - nFormat = static_cast<const SfxUInt32Item*>(pFormItem)->GetValue(); - else if (pCondSet->GetItemState(ATTR_VALUE_FORMAT, true, &pFormItem) == SfxItemState::SET ) - nFormat = getNumberFormatKey(*pCondSet); - else - nFormat = getNumberFormatKey(GetItemSet()); - + sal_uInt32 nFormat; const SfxPoolItem* pLangItem; LanguageType eLang; - if (GetItemSet().GetItemState(ATTR_LANGUAGE_FORMAT, false, &pLangItem) == SfxItemState::SET) - eLang = static_cast<const SvxLanguageItem*>(pLangItem)->GetLanguage(); - else if (pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT, true, &pLangItem) == SfxItemState::SET) - eLang = getLanguageType(*pCondSet); + if (pCondSet->GetItemState(ATTR_VALUE_FORMAT, true, &pFormItem) == SfxItemState::SET ) + { + nFormat = getNumberFormatKey(*pCondSet); + if (pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT, true, &pLangItem) == SfxItemState::SET) + eLang = getLanguageType(*pCondSet); + else + eLang = getLanguageType(GetItemSet()); + } else + { + nFormat = getNumberFormatKey(GetItemSet()); eLang = getLanguageType(GetItemSet()); + } return pFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLang); } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index a3cc7609e310..89eee7648b9c 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -459,15 +459,7 @@ void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxIt // number format sal_uLong nOld = nValueFormat; - const SfxPoolItem* pFormItem; - if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,true,&pFormItem) != SfxItemState::SET ) - pFormItem = &pPattern->GetItem(ATTR_VALUE_FORMAT); - const SfxPoolItem* pLangItem; - if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,true,&pLangItem) != SfxItemState::SET ) - pLangItem = &pPattern->GetItem(ATTR_LANGUAGE_FORMAT); - nValueFormat = pOutput->mpDoc->GetFormatTable()->GetFormatForLanguageIfBuiltIn( - static_cast<const SfxUInt32Item*>(pFormItem)->GetValue(), - static_cast<const SvxLanguageItem*>(pLangItem)->GetLanguage() ); + nValueFormat = pPattern->GetNumberFormat( pOutput->mpDoc->GetFormatTable(), pCondSet ); if (nValueFormat != nOld) maLastCell.clear(); // always reformat _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits