From f6328abe3fcd7fb2ec72779ba3754abe761f626b Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Fri, 3 Apr 2020 14:02:19 -0800 Subject: 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 --- sfx2/source/dialog/templdlg.cxx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 5389cd906044..8ec385bff416 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -2060,13 +2060,27 @@ void SfxCommonTemplateDialog_Impl::EnableDelete() 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 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 xFrame = pFrame->GetFrame().GetFrameInterface(); + if (vcl::CommandInfoProvider::GetModuleIdentifier(xFrame) == "com.sun.star.sheet.SpreadsheetDocument") + { + bEnableDelete = true; + } + } + } + } } EnableDel(bEnableDelete); } -- cgit