[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu Mar 31 16:31:01 UTC 2016
sc/source/core/data/patattr.cxx | 54 +++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 12 deletions(-)
New commits:
commit c1f94a5ea387551e9140cf43d4ed7ca5dcae8298
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Feb 3 20:28:40 2016 +0100
tdf#93300, handle hard formatting with cond format correct
For number formats we always applied the conditional format above the
hard formatting.
Now we handle styles, conditional formatting and hard formatting
correctly.
Reviewed-on: https://gerrit.libreoffice.org/22574
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
(cherry picked from commit 2c728b0ae7f52691b1a3d5ab555225f5e8ac95a5)
Conflicts:
sc/source/core/data/patattr.cxx
Change-Id: I52dbeeb848b982985d6b17dad920baedffb218e4
Reviewed-on: https://gerrit.libreoffice.org/23711
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index ea53285..fe70300 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1293,12 +1293,24 @@ bool ScPatternAttr::IsSymbolFont() const
return false;
}
+namespace {
+
+sal_uInt32 getNumberFormatKey(const SfxItemSet& rSet)
+{
+ return static_cast<const SfxUInt32Item&>(rSet.Get(ATTR_VALUE_FORMAT)).GetValue();
+}
+
+LanguageType getLanguageType(const SfxItemSet& rSet)
+{
+ return static_cast<const SvxLanguageItem&>(rSet.Get(ATTR_LANGUAGE_FORMAT)).GetLanguage();
+}
+
+}
+
sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const
{
- sal_uLong nFormat =
- static_cast<const SfxUInt32Item*>(&GetItemSet().Get( ATTR_VALUE_FORMAT ))->GetValue();
- LanguageType eLang =
- static_cast<const SvxLanguageItem*>(&GetItemSet().Get( ATTR_LANGUAGE_FORMAT ))->GetLanguage();
+ sal_uLong nFormat = getNumberFormatKey(GetItemSet());
+ LanguageType eLang = getLanguageType(GetItemSet());
if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM )
; // it remains as it is
else if ( pFormatter )
@@ -1311,19 +1323,37 @@ sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const
sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter,
const SfxItemSet* pCondSet ) const
{
- OSL_ENSURE(pFormatter,"GetNumberFormat without Formatter");
+ assert(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.
+ */
const SfxPoolItem* pFormItem;
- if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,true,&pFormItem) != SfxItemState::SET )
- pFormItem = &GetItemSet().Get(ATTR_VALUE_FORMAT);
+ 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());
const SfxPoolItem* pLangItem;
- if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,true,&pLangItem) != SfxItemState::SET )
- pLangItem = &GetItemSet().Get(ATTR_LANGUAGE_FORMAT);
+ 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);
+ else
+ eLang = getLanguageType(GetItemSet());
- return pFormatter->GetFormatForLanguageIfBuiltIn(
- static_cast<const SfxUInt32Item*>(pFormItem)->GetValue(),
- static_cast<const SvxLanguageItem*>(pLangItem)->GetLanguage() );
+ return pFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLang);
}
const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
More information about the Libreoffice-commits
mailing list