tdf#122945 - Set tab color directly to avoid sheet protection preventing import

Change-Id: I716bf2e09f9f07380499c0dbd9cfe85e19c3e047
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210644
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
DrRobotto
2026-09-11 02:09:28 +02:00
committed by Andreas Heinisch
parent 853bc4536b
commit 02ca891a8e
3 changed files with 28 additions and 1 deletions
+26
View File
@@ -1814,6 +1814,32 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testTdf66377)
CPPUNIT_ASSERT_EQUAL(Color(COL_TRANSPARENT), rColor);*/
}
CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testTdf122945TabColorProtectedSheet)
{
createScDoc("xlsx/tdf122945_TabColorProtectedSheet.xlsx");
ScDocument* pDoc = getScDoc();
CPPUNIT_ASSERT(pDoc->IsTabProtected(0));
// Without the fix in place, this test would have failed with
// - Expected: rgba[ff0000ff] (RED)
// - Actual : rgba[ffffff00] (COL_AUTO)
// i.e. the sheet protection prevented the import of the tab color
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), pDoc->GetTabBgColor(0));
saveAndReload(TestFilter::XLSX);
// check that the tab color was exported correctly
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
assertXPath(pSheet, "/x:worksheet/x:sheetPr/x:tabColor", "rgb", u"FFFF0000");
// check that sheet protection and tab color are still present after save and reload
pDoc = getScDoc();
CPPUNIT_ASSERT(pDoc->IsTabProtected(0));
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), pDoc->GetTabBgColor(0));
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+2 -1
View File
@@ -286,7 +286,8 @@ void WorksheetSettings::finalizeImport()
if( !maSheetSettings.maTabColor.isAuto() )
{
::Color nColor = maSheetSettings.maTabColor.getColor( getBaseFilter().getGraphicHelper() );
xSheet->setPropertyValue( u"TabColor"_ustr, Any(nColor) );
// tdf#122945 - set the color directly to avoid sheet protection preventing the import
getScDocument().SetTabBgColor(getSheetIndex(), nColor);
}
// Summary data below or above the contents