Kaydet (Commit) f83b97f7 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

svx: Simplify FmSearchEngine's code with std::unique_ptr

Change-Id: Ibda0f912c940091676889529224488846c91b50f
Reviewed-on: https://gerrit.libreoffice.org/42456Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a1eeccca
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <osl/thread.hxx> #include <osl/thread.hxx>
#include <deque> #include <deque>
#include <memory>
#include <vector> #include <vector>
enum class TransliterationFlags; enum class TransliterationFlags;
...@@ -171,8 +172,8 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC FmSearchEngine final ...@@ -171,8 +172,8 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC FmSearchEngine final
FieldCollection m_arrUsedFields; FieldCollection m_arrUsedFields;
sal_Int32 m_nCurrentFieldIndex; // the last parameter of RebuildUsedFields, it allows checks in FormatField sal_Int32 m_nCurrentFieldIndex; // the last parameter of RebuildUsedFields, it allows checks in FormatField
typedef std::vector<svxform::ControlTextWrapper*> ControlTextSuppliers; std::vector<std::unique_ptr<svxform::ControlTextWrapper>>
ControlTextSuppliers m_aControlTexts; m_aControlTexts;
CursorWrapper m_xOriginalIterator; CursorWrapper m_xOriginalIterator;
CursorWrapper m_xClonedIterator; CursorWrapper m_xClonedIterator;
...@@ -273,8 +274,6 @@ public: ...@@ -273,8 +274,6 @@ public:
const OUString& strVisibleFields, const OUString& strVisibleFields,
const InterfaceArray& arrFields); 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 /** the link will be called on every record and after the completion of the search, the parameter is a pointer to
a FmSearchProgress structure a FmSearchProgress structure
the handler should be in any case thread-safe the handler should be in any case thread-safe
......
...@@ -281,7 +281,7 @@ void FmSearchEngine::BuildAndInsertFieldInfo(const Reference< css::container::XI ...@@ -281,7 +281,7 @@ void FmSearchEngine::BuildAndInsertFieldInfo(const Reference< css::container::XI
OUString FmSearchEngine::FormatField(sal_Int32 nWhich) OUString FmSearchEngine::FormatField(sal_Int32 nWhich)
{ {
DBG_ASSERT((sal_uInt32)nWhich < m_aControlTexts.size(), "FmSearchEngine::FormatField(sal_Int32) : invalid position !"); 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 !"); DBG_ASSERT(m_aControlTexts[nWhich]->getControl().is(), "FmSearchEngine::FormatField : invalid control !");
if (m_nCurrentFieldIndex != -1) if (m_nCurrentFieldIndex != -1)
...@@ -592,13 +592,6 @@ FmSearchEngine::FmSearchEngine(const Reference< XComponentContext >& _rxContext, ...@@ -592,13 +592,6 @@ FmSearchEngine::FmSearchEngine(const Reference< XComponentContext >& _rxContext,
} }
FmSearchEngine::~FmSearchEngine()
{
clearControlTexts();
}
void FmSearchEngine::SetIgnoreWidthCJK(bool bSet) void FmSearchEngine::SetIgnoreWidthCJK(bool bSet)
{ {
if (bSet) if (bSet)
...@@ -631,14 +624,6 @@ bool FmSearchEngine::GetCaseSensitive() const ...@@ -631,14 +624,6 @@ bool FmSearchEngine::GetCaseSensitive() const
void FmSearchEngine::clearControlTexts() 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(); m_aControlTexts.clear();
} }
...@@ -655,21 +640,21 @@ void FmSearchEngine::fillControlTexts(const InterfaceArray& arrFields) ...@@ -655,21 +640,21 @@ void FmSearchEngine::fillControlTexts(const InterfaceArray& arrFields)
Reference< css::awt::XTextComponent > xAsText(xCurrent, UNO_QUERY); Reference< css::awt::XTextComponent > xAsText(xCurrent, UNO_QUERY);
if (xAsText.is()) if (xAsText.is())
{ {
m_aControlTexts.insert(m_aControlTexts.end(), new SimpleTextWrapper(xAsText)); m_aControlTexts.emplace_back(new SimpleTextWrapper(xAsText));
continue; continue;
} }
Reference< css::awt::XListBox > xAsListBox(xCurrent, UNO_QUERY); Reference< css::awt::XListBox > xAsListBox(xCurrent, UNO_QUERY);
if (xAsListBox.is()) if (xAsListBox.is())
{ {
m_aControlTexts.insert(m_aControlTexts.end(), new ListBoxWrapper(xAsListBox)); m_aControlTexts.emplace_back(new ListBoxWrapper(xAsListBox));
continue; continue;
} }
Reference< css::awt::XCheckBox > xAsCheckBox(xCurrent, UNO_QUERY); Reference< css::awt::XCheckBox > xAsCheckBox(xCurrent, UNO_QUERY);
DBG_ASSERT(xAsCheckBox.is(), "FmSearchEngine::fillControlTexts : invalid field interface (no supported type) !"); DBG_ASSERT(xAsCheckBox.is(), "FmSearchEngine::fillControlTexts : invalid field interface (no supported type) !");
// we don't have any more options ... // we don't have any more options ...
m_aControlTexts.insert(m_aControlTexts.end(), new CheckBoxWrapper(xAsCheckBox)); m_aControlTexts.emplace_back(new CheckBoxWrapper(xAsCheckBox));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment