summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei@libreoffice.org>2021-12-17 17:42:15 -0500
committerKohei Yoshida <kohei@libreoffice.org>2021-12-18 18:08:33 +0100
commit9547114247c09a90f283e42c4db947ae57e9529c (patch)
tree93020a403f0c9d42851c6e5848eaf775226cea82 /sc/qa
parentc4aa4b55e21915ca072daa7db93edabc043f26ab (diff)
tdf#103331: Add a test case for inherited font weight attributes.
Change-Id: I8ebca3ab492313a3f7aa9019533bbb7eee2e4a89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127019 Tested-by: Jenkins Reviewed-by: Kohei Yoshida <kohei@libreoffice.org>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xml/styles.xml16
-rw-r--r--sc/qa/unit/subsequent_filters_test.cxx40
2 files changed, 51 insertions, 5 deletions
diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml
index fa5cd2759ca2..eb402a0e5ce0 100644
--- a/sc/qa/unit/data/xml/styles.xml
+++ b/sc/qa/unit/data/xml/styles.xml
@@ -31,4 +31,20 @@
<style:table-cell-properties style:vertical-align="middle"/>
<style:paragraph-properties fo:text-align="end"/>
</style:style>
+
+ <style:style style:name="Accent" style:family="table-cell" style:parent-style-name="Default">
+ <style:text-properties fo:font-weight="bold"/>
+ </style:style>
+ <style:style style:name="Accent 1" style:family="table-cell" style:parent-style-name="Accent">
+ <style:table-cell-properties fo:background-color="#000000"/>
+ <style:text-properties fo:color="#ffffff"/>
+ </style:style>
+ <style:style style:name="Accent 2" style:family="table-cell" style:parent-style-name="Accent">
+ <style:table-cell-properties fo:background-color="#808080"/>
+ <style:text-properties fo:color="#ffffff"/>
+ </style:style>
+ <style:style style:name="Accent 3" style:family="table-cell" style:parent-style-name="Accent">
+ <style:table-cell-properties fo:background-color="#dddddd"/>
+ </style:style>
+
</office:styles>
diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx
index 3c4939b3e8e6..39bf4cd443f6 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -2914,7 +2914,8 @@ void ScFiltersTest::testOrcusODSStyleInterface()
CPPUNIT_ASSERT_MESSAGE("Style Name3 : Doesn't have Attribute Protection, but it should have.",
pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem));
- CPPUNIT_ASSERT_MESSAGE("Style Name 3 : Error with Protection attribute." ,bool(ScProtectionAttr(true, false, true, true) == *pItem));
+ CPPUNIT_ASSERT_MESSAGE("Style Name 3 : Error with Protection attribute.",
+ bool(ScProtectionAttr(true, false, true, true) == *pItem));
/* Test for Style "Name4"
* Hidden, protected and content is printed.
@@ -2923,20 +2924,22 @@ void ScFiltersTest::testOrcusODSStyleInterface()
CPPUNIT_ASSERT_MESSAGE("Style Name4 : Doesn't have Attribute Protection, but it should have.",
pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem));
- CPPUNIT_ASSERT_MESSAGE("Style Name 4 : Error with Protection attribute." ,bool(ScProtectionAttr(true, true, false, false) == *pItem));
+ CPPUNIT_ASSERT_MESSAGE("Style Name 4 : Error with Protection attribute.",
+ bool(ScProtectionAttr(true, true, false, false) == *pItem));
- /* Test for Style "Name3"
+ /* Test for Style "Name5"
* Hidden, protected and content is printed.
*/
pStyleSheet = pStyleSheetPool->FindCaseIns("Name5", SfxStyleFamily::Para);
CPPUNIT_ASSERT_MESSAGE("Style Name5 : Doesn't have Attribute Protection, but it should have.",
pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem));
- CPPUNIT_ASSERT_MESSAGE("Style Name 5 : Error with Protection attribute." ,bool(ScProtectionAttr(false, false, false, true) == *pItem));
+ CPPUNIT_ASSERT_MESSAGE("Style Name5 : Error with Protection attribute.",
+ bool(ScProtectionAttr(false, false, false, true) == *pItem));
CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute Border, but it shouldn't.",
!pStyleSheet->GetItemSet().HasItem(ATTR_BORDER, &pItem));
- CPPUNIT_ASSERT_MESSAGE("Style Name5: Has Attribute background, but it shouldn't.",
+ CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute background, but it shouldn't.",
!pStyleSheet->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem));
CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute font, but it shouldn't.",
!pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem));
@@ -3032,6 +3035,33 @@ void ScFiltersTest::testOrcusODSStyleInterface()
const SvxVerJustifyItem* pVerJustify = static_cast<const SvxVerJustifyItem*>(pItem);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name10 :Error with ver justify", SvxCellVerJustify::Center, pVerJustify->GetValue());
+ auto checkFontWeight = [pStyleSheetPool](const OUString& rName, FontWeight eExpected)
+ {
+ ScStyleSheet* pStyle = pStyleSheetPool->FindCaseIns(rName, SfxStyleFamily::Para);
+ CPPUNIT_ASSERT(pStyle);
+
+ const SfxPoolItem* p = nullptr;
+
+ {
+ std::ostringstream os;
+ os << "Style named '" << rName << "' does not have a font weight attribute.";
+ CPPUNIT_ASSERT_MESSAGE(os.str(), pStyle->GetItemSet().HasItem(ATTR_FONT_WEIGHT, &p));
+ }
+
+ const SvxWeightItem* pWeight = static_cast<const SvxWeightItem*>(p);
+ FontWeight eActual = pWeight->GetWeight();
+ {
+ std::ostringstream os;
+ os << "Wrong font weight value for style named '" << rName << "': expected="
+ << eExpected << "; actual=" << eActual;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(os.str(), eExpected, eActual);
+ }
+ };
+
+ checkFontWeight("Accent", WEIGHT_BOLD);
+ checkFontWeight("Accent 1", WEIGHT_BOLD); // inherits from 'Accent'
+ checkFontWeight("Accent 2", WEIGHT_BOLD); // inherits from 'Accent'
+ checkFontWeight("Accent 3", WEIGHT_BOLD); // inherits from 'Accent'
}
void ScFiltersTest::testLiteralInFormulaXLS()