From 148bc64fce5c7980e13de4743f67c0ef65412b7f Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 27 Jan 2019 19:54:58 +0100 Subject: Group common code Change-Id: Id836c9e4bce7ae36e3ebbfea2d84f1eb095bd298 Reviewed-on: https://gerrit.libreoffice.org/67311 Tested-by: Jenkins Reviewed-by: Matteo Casalin --- sw/source/ui/misc/glossary.cxx | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'sw/source/ui/misc/glossary.cxx') diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 43c616deece3..27c210083eaf 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -262,6 +262,22 @@ void SwGlossaryDlg::dispose() SvxStandardDialog::dispose(); } +namespace +{ + +OUString getCurrentGlossary() +{ + const OUString sTemp{ ::GetCurrGlosGroup() }; + + // the zeroth path is not being recorded! + if (sTemp.getToken(1, GLOS_DELIM).startsWith("0")) + return sTemp.getToken(0, GLOS_DELIM); + + return sTemp; +} + +} + // select new group IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox, void ) { @@ -299,11 +315,7 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox, void ) if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) ) { SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY ); - OUString sTemp(::GetCurrGlosGroup()); - // the zeroth path is not being recorded! - if (sTemp.getToken(1, GLOS_DELIM).startsWith("0")) - sTemp = sTemp.getToken(0, GLOS_DELIM); - aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp)); + aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, getCurrentGlossary())); aReq.Done(); } Invalidate(InvalidateFlags::Update); @@ -319,11 +331,7 @@ void SwGlossaryDlg::Apply() if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) ) { SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY ); - OUString sTemp(::GetCurrGlosGroup()); - // the zeroth path is not being recorded! - if (sTemp.getToken(1, GLOS_DELIM).startsWith("0")) - sTemp = sTemp.getToken(0, GLOS_DELIM); - aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp)); + aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, getCurrentGlossary())); aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName)); aReq.Done(); } @@ -474,11 +482,7 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn, bool ) if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) ) { SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY); - OUString sTemp(::GetCurrGlosGroup()); - // the zeroth path is not being recorded! - if (sTemp.getToken(1, GLOS_DELIM).startsWith("0")) - sTemp = sTemp.getToken(0, GLOS_DELIM); - aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp)); + aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, getCurrentGlossary())); aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName)); aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr)); aReq.Done(); -- cgit