summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-16 12:40:14 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-16 13:04:08 +0200
commit0a601a0cb14dc0f60e00eb46929f53eebe59a6af (patch)
treec18f39db92f2179c7d54da6cddfb1920196def11 /sw
parent529f5441a7633a76f0a393e9f6dcb83b0b2e408c (diff)
sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I3bfb0933d5233b89f24773500f07fdc92d0011e9
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ToxLinkProcessor.hxx7
-rw-r--r--sw/qa/core/test_ToxLinkProcessor.cxx24
-rw-r--r--sw/source/core/tox/ToxLinkProcessor.cxx25
3 files changed, 30 insertions, 26 deletions
diff --git a/sw/inc/ToxLinkProcessor.hxx b/sw/inc/ToxLinkProcessor.hxx
index 3887121e06dc..699c0ec9887e 100644
--- a/sw/inc/ToxLinkProcessor.hxx
+++ b/sw/inc/ToxLinkProcessor.hxx
@@ -13,7 +13,8 @@
#include "fmtinfmt.hxx"
#include "rtl/ustring.hxx"
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <memory>
+#include <vector>
class SwTextNode;
@@ -76,9 +77,9 @@ private:
sal_Int32 mEndTextPos;
};
- boost::ptr_vector<ClosedLink> mClosedLinks;
+ std::vector<std::unique_ptr<ClosedLink>> m_ClosedLinks;
- boost::ptr_vector<StartedLink> mStartedLinks;
+ std::vector<std::unique_ptr<StartedLink>> m_StartedLinks;
friend class ::ToxLinkProcessorTest;
};
diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx b/sw/qa/core/test_ToxLinkProcessor.cxx
index 660d7458a7f1..03c85505b027 100644
--- a/sw/qa/core/test_ToxLinkProcessor.cxx
+++ b/sw/qa/core/test_ToxLinkProcessor.cxx
@@ -81,8 +81,8 @@ ToxLinkProcessorTest::StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed(
sut.StartNewLink(0, STYLE_NAME_1);
sut.CloseLink(1, URL_1);
sut.CloseLink(1, URL_1);
- CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.mClosedLinks.size()));
- CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned>(sut.mClosedLinks.at(1).mEndTextPos));
+ CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.m_ClosedLinks.size()));
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned>(sut.m_ClosedLinks.at(1)->mEndTextPos));
}
void
@@ -93,8 +93,8 @@ ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks()
sut.StartNewLink(0, STYLE_NAME_2);
sut.CloseLink(1, URL_1);
sut.CloseLink(1, URL_2);
- CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.mClosedLinks.size()));
- CPPUNIT_ASSERT_MESSAGE("no links are open", sut.mStartedLinks.empty());
+ CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.m_ClosedLinks.size()));
+ CPPUNIT_ASSERT_MESSAGE("no links are open", sut.m_StartedLinks.empty());
}
class ToxLinkProcessorWithOverriddenObtainPoolId : public ToxLinkProcessor {
@@ -120,8 +120,8 @@ ToxLinkProcessorTest::LinkIsCreatedCorrectly()
sut.StartNewLink(0, STYLE_NAME_1);
sut.CloseLink(1, URL_1);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link", STYLE_NAME_1, sut.mClosedLinks.at(0).mINetFormat.GetVisitedFormat());
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link", URL_1, sut.mClosedLinks.at(0).mINetFormat.GetValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link", STYLE_NAME_1, sut.m_ClosedLinks.at(0)->mINetFormat.GetVisitedFormat());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link", URL_1, sut.m_ClosedLinks.at(0)->mINetFormat.GetValue());
}
void
@@ -138,18 +138,18 @@ ToxLinkProcessorTest::LinkSequenceIsPreserved()
// check first closed element
CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link",
- STYLE_NAME_2, sut.mClosedLinks.at(0).mINetFormat.GetVisitedFormat());
+ STYLE_NAME_2, sut.m_ClosedLinks.at(0)->mINetFormat.GetVisitedFormat());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Pool id is stored correctly in link",
- POOL_ID_2, sut.mClosedLinks.at(0).mINetFormat.GetINetFormatId());
+ POOL_ID_2, sut.m_ClosedLinks.at(0)->mINetFormat.GetINetFormatId());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link",
- URL_2, sut.mClosedLinks.at(0).mINetFormat.GetValue());
+ URL_2, sut.m_ClosedLinks.at(0)->mINetFormat.GetValue());
// check second closed element
CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link",
- STYLE_NAME_1, sut.mClosedLinks.at(1).mINetFormat.GetVisitedFormat());
+ STYLE_NAME_1, sut.m_ClosedLinks.at(1)->mINetFormat.GetVisitedFormat());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Pool id is stored correctly in link",
- POOL_ID_1, sut.mClosedLinks.at(1).mINetFormat.GetINetFormatId());
+ POOL_ID_1, sut.m_ClosedLinks.at(1)->mINetFormat.GetINetFormatId());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link",
- URL_1, sut.mClosedLinks.at(1).mINetFormat.GetValue());
+ URL_1, sut.m_ClosedLinks.at(1)->mINetFormat.GetValue());
}
// Put the test suite in the registry
diff --git a/sw/source/core/tox/ToxLinkProcessor.cxx b/sw/source/core/tox/ToxLinkProcessor.cxx
index bd2d6f8937e7..cbb7275ca42f 100644
--- a/sw/source/core/tox/ToxLinkProcessor.cxx
+++ b/sw/source/core/tox/ToxLinkProcessor.cxx
@@ -20,32 +20,34 @@ namespace sw {
void
ToxLinkProcessor::StartNewLink(sal_Int32 startPosition, const OUString& characterStyle)
{
- mStartedLinks.push_back(new StartedLink(startPosition, characterStyle));
+ m_StartedLinks.push_back(std::unique_ptr<StartedLink>(
+ new StartedLink(startPosition, characterStyle)));
}
void
ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url)
{
- StartedLink const startedLink( (mStartedLinks.empty())
+ StartedLink const startedLink( (m_StartedLinks.empty())
? StartedLink(0, SW_RES(STR_POOLCHR_TOXJUMP))
- : mStartedLinks.back() );
- if (!mStartedLinks.empty())
+ : *m_StartedLinks.back() );
+ if (!m_StartedLinks.empty())
{
- mStartedLinks.pop_back();
+ m_StartedLinks.pop_back();
}
if (url.isEmpty()) {
return;
}
- ClosedLink* closedLink = new ClosedLink(url, startedLink.mStartPosition, endPosition);
+ std::unique_ptr<ClosedLink> pClosedLink(
+ new ClosedLink(url, startedLink.mStartPosition, endPosition));
const OUString& characterStyle = startedLink.mCharacterStyle;
sal_uInt16 poolId = ObtainPoolId(characterStyle);
- closedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId);
- closedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId);
+ pClosedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId);
+ pClosedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId);
- mClosedLinks.push_back(closedLink);
+ m_ClosedLinks.push_back(std::move(pClosedLink));
}
sal_uInt16
@@ -63,8 +65,9 @@ ToxLinkProcessor::ObtainPoolId(const OUString& characterStyle) const
void
ToxLinkProcessor::InsertLinkAttributes(SwTextNode& node)
{
- for (ClosedLink& clink : mClosedLinks) {
- node.InsertItem(clink.mINetFormat, clink.mStartTextPos, clink.mEndTextPos);
+ for (auto const& clink : m_ClosedLinks)
+ {
+ node.InsertItem(clink->mINetFormat, clink->mStartTextPos, clink->mEndTextPos);
}
}