tdf#131190 Make custom page styles deletable again in Calc
Return the ability to delete custom page styles in Calc. This was lost
in commit 30c9bc76d0718f0c01d34f81845d88413645b42c
Change-Id: Iae402cc048fde7ffd3ca2696c08d5e54cc30d1be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91672
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 5389cd9..8ec385b 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -2060,13 +2060,27 @@
pStyleSheetPool->Find(aTemplName,eFam, pTreeBox->IsVisible()? SfxStyleSearchBits::All : nFilter);
OSL_ENSURE(pStyle, "Style not found");
// bIsCalcPageStyle is a hack to allow Calc page styles to be deleted
// remove when IsUsed is fixed for Calc page style
uno::Reference<frame::XFrame > xFrame = GetObjectShell()->GetFrame()->GetFrame().GetFrameInterface();
bool bIsCalcPageStyle = (vcl::CommandInfoProvider::GetModuleIdentifier(xFrame) == "com.sun.star.sheet.SpreadsheetDocument") &&
(pStyle->GetFamily() == SfxStyleFamily::Page);
if (pStyle && pStyle->IsUserDefined() && (bIsCalcPageStyle || pStyle->HasParentSupport() || !pStyle->IsUsed()))
bEnableDelete = true;
if (pStyle && pStyle->IsUserDefined())
{
if (pStyle->HasClearParentSupport() || !pStyle->IsUsed())
{
bEnableDelete = true;
}
else if (pStyle->GetFamily() == SfxStyleFamily::Page)
{
// Hack to allow Calc page styles to be deleted,
// remove when IsUsed is fixed for Calc page styles.
SfxViewFrame* pFrame = GetObjectShell()->GetFrame();
if (pFrame)
{
uno::Reference<frame::XFrame > xFrame = pFrame->GetFrame().GetFrameInterface();
if (vcl::CommandInfoProvider::GetModuleIdentifier(xFrame) == "com.sun.star.sheet.SpreadsheetDocument")
{
bEnableDelete = true;
}
}
}
}
}
EnableDel(bEnableDelete);
}