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 <erack@redhat.com>
Tested-by: Eike Rathke <erack@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 <erack@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 <erack@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 <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index bf3d1dc..92e91a4 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 a3cc760..89eee76 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