include/svx/fmsrcimp.hxx | 7 +++---- svx/source/form/fmsrcimp.cxx | 23 ++++------------------- 2 files changed, 7 insertions(+), 23 deletions(-)
New commits: commit f83b97f7ae5597462c3b22fc273ca477b2e6fa35 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Tue Sep 19 17:46:22 2017 +0900 svx: Simplify FmSearchEngine's code with std::unique_ptr Change-Id: Ibda0f912c940091676889529224488846c91b50f Reviewed-on: https://gerrit.libreoffice.org/42456 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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 <osl/thread.hxx> #include <deque> +#include <memory> #include <vector> 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<svxform::ControlTextWrapper*> ControlTextSuppliers; - ControlTextSuppliers m_aControlTexts; + std::vector<std::unique_ptr<svxform::ControlTextWrapper>> + 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)); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits