From f83b97f7ae5597462c3b22fc273ca477b2e6fa35 Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Tue, 19 Sep 2017 17:46:22 +0900 Subject: svx: Simplify FmSearchEngine's code with std::unique_ptr Change-Id: Ibda0f912c940091676889529224488846c91b50f Reviewed-on: https://gerrit.libreoffice.org/42456 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/svx/fmsrcimp.hxx | 7 +++---- svx/source/form/fmsrcimp.cxx | 23 ++++------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/include/svx/fmsrcimp.hxx b/include/svx/fmsrcimp.hxx index 8e21cc92473d..112f4314abd8 100644 --- a/include/svx/fmsrcimp.hxx +++ b/include/svx/fmsrcimp.hxx @@ -36,6 +36,7 @@ #include #include +#include #include enum class TransliterationFlags; @@ -171,8 +172,8 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC FmSearchEngine final FieldCollection m_arrUsedFields; sal_Int32 m_nCurrentFieldIndex; // the last parameter of RebuildUsedFields, it allows checks in FormatField - typedef std::vector ControlTextSuppliers; - ControlTextSuppliers m_aControlTexts; + std::vector> + m_aControlTexts; CursorWrapper m_xOriginalIterator; CursorWrapper m_xClonedIterator; @@ -273,8 +274,6 @@ public: const OUString& strVisibleFields, const InterfaceArray& arrFields); - ~FmSearchEngine(); - /** the link will be called on every record and after the completion of the search, the parameter is a pointer to a FmSearchProgress structure the handler should be in any case thread-safe diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index eb05a3676639..596e942f2348 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -281,7 +281,7 @@ void FmSearchEngine::BuildAndInsertFieldInfo(const Reference< css::container::XI OUString FmSearchEngine::FormatField(sal_Int32 nWhich) { DBG_ASSERT((sal_uInt32)nWhich < m_aControlTexts.size(), "FmSearchEngine::FormatField(sal_Int32) : invalid position !"); - DBG_ASSERT(m_aControlTexts[nWhich] != nullptr, "FmSearchEngine::FormatField(sal_Int32) : invalid object in array !"); + DBG_ASSERT(m_aControlTexts[nWhich], "FmSearchEngine::FormatField(sal_Int32) : invalid object in array !"); DBG_ASSERT(m_aControlTexts[nWhich]->getControl().is(), "FmSearchEngine::FormatField : invalid control !"); if (m_nCurrentFieldIndex != -1) @@ -592,13 +592,6 @@ FmSearchEngine::FmSearchEngine(const Reference< XComponentContext >& _rxContext, } -FmSearchEngine::~FmSearchEngine() -{ - clearControlTexts(); - -} - - void FmSearchEngine::SetIgnoreWidthCJK(bool bSet) { if (bSet) @@ -631,14 +624,6 @@ bool FmSearchEngine::GetCaseSensitive() const void FmSearchEngine::clearControlTexts() { - ControlTextSuppliers::const_iterator aEnd = m_aControlTexts.end(); - for ( ControlTextSuppliers::iterator aIter = m_aControlTexts.begin(); - aIter != aEnd; - ++aIter - ) - { - delete *aIter; - } m_aControlTexts.clear(); } @@ -655,21 +640,21 @@ void FmSearchEngine::fillControlTexts(const InterfaceArray& arrFields) Reference< css::awt::XTextComponent > xAsText(xCurrent, UNO_QUERY); if (xAsText.is()) { - m_aControlTexts.insert(m_aControlTexts.end(), new SimpleTextWrapper(xAsText)); + m_aControlTexts.emplace_back(new SimpleTextWrapper(xAsText)); continue; } Reference< css::awt::XListBox > xAsListBox(xCurrent, UNO_QUERY); if (xAsListBox.is()) { - m_aControlTexts.insert(m_aControlTexts.end(), new ListBoxWrapper(xAsListBox)); + m_aControlTexts.emplace_back(new ListBoxWrapper(xAsListBox)); continue; } Reference< css::awt::XCheckBox > xAsCheckBox(xCurrent, UNO_QUERY); DBG_ASSERT(xAsCheckBox.is(), "FmSearchEngine::fillControlTexts : invalid field interface (no supported type) !"); // we don't have any more options ... - m_aControlTexts.insert(m_aControlTexts.end(), new CheckBoxWrapper(xAsCheckBox)); + m_aControlTexts.emplace_back(new CheckBoxWrapper(xAsCheckBox)); } } -- cgit