[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 13 06:17:18 UTC 2020
sw/inc/view.hxx | 4 +--
sw/source/uibase/uiview/view.cxx | 4 +--
sw/source/uibase/uiview/viewsrch.cxx | 44 +++++++++++++++++------------------
3 files changed, 26 insertions(+), 26 deletions(-)
New commits:
commit bbd598e62fe66352fc366c3e78c0aad753ea2ad7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 12 11:11:21 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 13 08:16:22 2020 +0200
use unique_ptr in SwView
Change-Id: I0aee92369627b18f8c6eabb756e0f409863e2a58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100617
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 2a7bc89ab7e3..85ab3f1c930f 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -158,8 +158,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
static bool s_bFound;
static bool s_bJustOpened;
- static SearchAttrItemList* s_pSearchList;
- static SearchAttrItemList* s_pReplaceList;
+ static std::unique_ptr<SearchAttrItemList> s_xSearchList;
+ static std::unique_ptr<SearchAttrItemList> s_xReplaceList;
Timer m_aTimer; // for delayed ChgLnks during an action
OUString m_sSwViewData,
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 94b400346895..5ee6f15b65a9 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -118,8 +118,8 @@ bool SwView::s_bExtra = false;
bool SwView::s_bFound = false;
bool SwView::s_bJustOpened = false;
-SearchAttrItemList* SwView::s_pSearchList = nullptr;
-SearchAttrItemList* SwView::s_pReplaceList = nullptr;
+std::unique_ptr<SearchAttrItemList> SwView::s_xSearchList;
+std::unique_ptr<SearchAttrItemList> SwView::s_xReplaceList;
SfxDispatcher &SwView::GetDispatcher()
{
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index c037f5394a5d..bc4ac9b353ff 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -164,8 +164,8 @@ void SwView::ExecSearch(SfxRequest& rReq)
delete s_pSrchItem;
s_pSrchItem = pArgs->Get(SID_SEARCH_ITEM).Clone();
- DELETEZ( s_pSearchList );
- DELETEZ( s_pReplaceList );
+ s_xSearchList.reset();
+ s_xReplaceList.reset();
SvxSearchDialog *const pSrchDlg(GetSearchDialog());
if (pSrchDlg)
@@ -173,11 +173,11 @@ void SwView::ExecSearch(SfxRequest& rReq)
// We will remember the search-/replace items.
const SearchAttrItemList* pList = pSrchDlg->GetSearchItemList();
if( nullptr != pList && pList->Count() )
- s_pSearchList = new SearchAttrItemList( *pList );
+ s_xSearchList.reset(new SearchAttrItemList( *pList ));
pList = pSrchDlg->GetReplaceItemList();
if (nullptr != pList && pList->Count())
- s_pReplaceList = new SearchAttrItemList( *pList );
+ s_xReplaceList.reset(new SearchAttrItemList( *pList ));
}
}
break;
@@ -194,16 +194,16 @@ void SwView::ExecSearch(SfxRequest& rReq)
SvxSearchDialog * pSrchDlg(GetSearchDialog());
if (pSrchDlg)
{
- DELETEZ( s_pSearchList );
- DELETEZ( s_pReplaceList );
+ s_xSearchList.reset();
+ s_xReplaceList.reset();
const SearchAttrItemList* pList = pSrchDlg->GetSearchItemList();
if( nullptr != pList && pList->Count() )
- s_pSearchList = new SearchAttrItemList( *pList );
+ s_xSearchList.reset(new SearchAttrItemList( *pList ));
pList = pSrchDlg->GetReplaceItemList();
if (nullptr != pList && pList->Count())
- s_pReplaceList = new SearchAttrItemList( *pList );
+ s_xReplaceList.reset(new SearchAttrItemList( *pList ));
}
if (nSlot == FN_REPEAT_SEARCH)
@@ -269,7 +269,7 @@ void SwView::ExecSearch(SfxRequest& rReq)
SvxSearchCmd nCmd = SvxSearchCmd::FIND;
if( !s_pSrchItem->GetReplaceString().isEmpty() ||
- !s_pReplaceList )
+ !s_xReplaceList )
{
// Prevent, that the replaced string will be found again
// if the replacement string is containing the search string.
@@ -293,7 +293,7 @@ void SwView::ExecSearch(SfxRequest& rReq)
m_pWrtShell->SwapPam();
}
}
- else if( s_pReplaceList )
+ else if( s_xReplaceList )
nCmd = SvxSearchCmd::REPLACE;
// 2) Search further (without replacing!)
@@ -420,16 +420,16 @@ void SwView::ExecSearch(SfxRequest& rReq)
{
nWhich = SID_SEARCH_REPLACESET;
- if ( s_pReplaceList )
+ if ( s_xReplaceList )
{
- s_pReplaceList->Get( aSet );
- DELETEZ( s_pReplaceList );
+ s_xReplaceList->Get( aSet );
+ s_xReplaceList.reset();
}
}
- else if ( s_pSearchList )
+ else if ( s_xSearchList )
{
- s_pSearchList->Get( aSet );
- DELETEZ( s_pSearchList );
+ s_xSearchList->Get( aSet );
+ s_xSearchList.reset();
}
rReq.SetReturnValue( SvxSetItem( nWhich, aSet ) );
}
@@ -685,11 +685,11 @@ void SwView::Replace()
bool bReplaced = m_pWrtShell->SwEditShell::Replace( s_pSrchItem->GetReplaceString(),
s_pSrchItem->GetRegExp());
- if( bReplaced && s_pReplaceList && s_pReplaceList->Count() && m_pWrtShell->HasSelection() )
+ if( bReplaced && s_xReplaceList && s_xReplaceList->Count() && m_pWrtShell->HasSelection() )
{
SfxItemSet aReplSet( m_pWrtShell->GetAttrPool(),
aTextFormatCollSetRange );
- if( s_pReplaceList->Get( aReplSet ).Count() )
+ if( s_xReplaceList->Get( aReplSet ).Count() )
{
::SfxToSwPageDescAttr( *m_pWrtShell, aReplSet );
m_pWrtShell->SwEditShell::SetAttrSet( aReplSet );
@@ -742,20 +742,20 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
0 };
SfxItemSet aSrchSet( m_pWrtShell->GetAttrPool(), aSearchAttrRange);
- if( s_pSearchList && s_pSearchList->Count() )
+ if( s_xSearchList && s_xSearchList->Count() )
{
- s_pSearchList->Get( aSrchSet );
+ s_xSearchList->Get( aSrchSet );
// -- Page break with page template
::SfxToSwPageDescAttr( *m_pWrtShell, aSrchSet );
}
std::unique_ptr<SfxItemSet> pReplSet;
- if( bDoReplace && s_pReplaceList && s_pReplaceList->Count() )
+ if( bDoReplace && s_xReplaceList && s_xReplaceList->Count() )
{
pReplSet.reset( new SfxItemSet( m_pWrtShell->GetAttrPool(),
aSearchAttrRange ) );
- s_pReplaceList->Get( *pReplSet );
+ s_xReplaceList->Get( *pReplSet );
// -- Page break with page template
::SfxToSwPageDescAttr( *m_pWrtShell, *pReplSet );
More information about the Libreoffice-commits
mailing list