tdf#154817 sw UI: no hatch/gradient name if not selected
This fixes a LO 7.2.0 regression caused by
commit 3f6797c29e9672eba354400f24a669244fd746c0.
A unique name was being created for gradients and hatches
every time the paragraph dialog box was OK'd,
even if the Area tab was not selected or natigated to.
Only create the name if the gradient or hatch is actually
selected as the fill type.
Change-Id: I088954db07d025570b0f5ecd5785020052c6f1f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150669
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index e331b29..b66772a 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -51,6 +51,7 @@
#include <svx/SmartTagItem.hxx>
#include <svx/xflgrit.hxx>
#include <svx/xflhtit.hxx>
#include <svx/xfillit0.hxx>
#include <fmtinfmt.hxx>
#include <wrtsh.hxx>
#include <wview.hxx>
@@ -1585,7 +1586,10 @@ void SwTextShell::Execute(SfxRequest &rReq)
pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
}
const XFillGradientItem* pTempGradItem = pSet->GetItem<XFillGradientItem>(XATTR_FILLGRADIENT);
const XFillStyleItem* pFS = pSet->GetItem<XFillStyleItem>(XATTR_FILLSTYLE);
bool bSet = pFS && pFS->GetValue() == drawing::FillStyle_GRADIENT;
const XFillGradientItem* pTempGradItem
= bSet ? pSet->GetItem<XFillGradientItem>(XATTR_FILLGRADIENT) : nullptr;
if (pTempGradItem && pTempGradItem->GetName().isEmpty())
{
// MigrateItemSet guarantees unique gradient names
@@ -1594,7 +1598,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
SdrModel::MigrateItemSet(&aMigrateSet, pSet, pDrawModel);
}
const XFillHatchItem* pTempHatchItem = pSet->GetItem<XFillHatchItem>(XATTR_FILLHATCH);
bSet = pFS && pFS->GetValue() == drawing::FillStyle_HATCH;
const XFillHatchItem* pTempHatchItem
= bSet ? pSet->GetItem<XFillHatchItem>(XATTR_FILLHATCH) : nullptr;
if (pTempHatchItem && pTempHatchItem->GetName().isEmpty())
{
SfxItemSetFixed<XATTR_FILLHATCH, XATTR_FILLHATCH> aMigrateSet(rWrtSh.GetView().GetPool());