From 8d8450f0c14db26fb8eb44677c2887e619200904 Mon Sep 17 00:00:00 2001 From: Vert D Date: Mon, 24 May 2021 23:01:38 -0500 Subject: tdf#139647 refresh renamed items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *Update templates names after rename (faster than reload). *Fix some warnings. Change-Id: I47387af91964afae8de8753289d49d19e6080863 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119919 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sfx2/source/control/templatelocalview.cxx | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'sfx2/source/control/templatelocalview.cxx') diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 0ba60c0d758b..4d0571eeaca1 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -613,7 +613,41 @@ bool TemplateLocalView::renameItem(ThumbnailViewItem* pItem, const OUString& sNe nDocId = pDocItem->mnDocId; } - return mpDocTemplates->SetName( sNewTitle, nRegionId, nDocId ); + bool bRes = mpDocTemplates->SetName( sNewTitle, nRegionId, nDocId ); + if(bRes) + { + for (auto & pRegion : maRegions) + { + if (pRegion->mnId == nRegionId + 1 ) + { + for(auto & aTemplate : pRegion->maTemplates) + { + if(aTemplate.nId == nDocId + 1) + { + aTemplate.aName = sNewTitle; + break; + } + } + break; + } + } + OUString sRegionName; + for (auto & aTemplate : maAllTemplates) + { + if (aTemplate.nRegionId == nRegionId && aTemplate.nDocId == nDocId) + { + aTemplate.aName = sNewTitle; + sRegionName = aTemplate.aRegionName; + break; + } + } + + OUString sHelpText = SfxResId(STR_TEMPLATE_TOOLTIP); + sHelpText = (sHelpText.replaceFirst("$1", sNewTitle)).replaceFirst("$2", sRegionName); + pItem->setHelpText(sHelpText); + pItem->maTitle = sNewTitle; + } + return bRes; } void TemplateLocalView::insertItems(const std::vector &rTemplates, bool isRegionSelected, bool bShowCategoryInTooltip) -- cgit