summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-12-03 22:15:10 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-12-04 07:09:12 +0100
commit9634a818e8a9432db52bc8fcd534e7437e6bacee (patch)
tree40f5e2e10deff130d7975a1b0b427376865a502f
parent8444bf1d7314f7ff2ea4d17da19b4d276c4086ae (diff)
Replace list by vector for mvPostItFields (sw)
Change-Id: I22009cd051a990cbc6e5f67a01958da889437840 Reviewed-on: https://gerrit.libreoffice.org/45759 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--sw/inc/PostItMgr.hxx4
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx19
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx5
3 files changed, 14 insertions, 14 deletions
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 8e60929ca4b7..f5e6f551e8c9 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -148,7 +148,7 @@ class SwPostItMgr: public SfxListener
SwView* mpView;
SwWrtShell* mpWrtShell;
VclPtr<SwEditWin> mpEditWin;
- std::list< SwSidebarItem*> mvPostItFields;
+ std::vector<SwSidebarItem*> mvPostItFields;
std::vector<SwPostItPageItem*> mPages;
ImplSVEvent * mnEventId;
bool mbWaitingForCalcRects;
@@ -196,7 +196,7 @@ class SwPostItMgr: public SfxListener
SwPostItMgr(SwView* aDoc);
virtual ~SwPostItMgr() override;
- typedef std::list< SwSidebarItem* >::const_iterator const_iterator;
+ typedef std::vector< SwSidebarItem* >::const_iterator const_iterator;
const_iterator begin() const { return mvPostItFields.begin(); }
const_iterator end() const { return mvPostItFields.end(); }
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 4e024c731b33..f7571ffb0398 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -243,13 +243,14 @@ SwPostItMgr::~SwPostItMgr()
void SwPostItMgr::CheckForRemovedPostIts()
{
bool bRemoved = false;
- for(auto i = mvPostItFields.begin(); i != mvPostItFields.end(); )
+ auto currentIt = mvPostItFields.begin();
+ while(currentIt != mvPostItFields.end())
{
- auto it = i++;
+ auto it = currentIt++;
if ( !(*it)->UseElement() )
{
SwSidebarItem* p = (*it);
- mvPostItFields.remove(*it);
+ currentIt = mvPostItFields.erase(std::remove(mvPostItFields.begin(), mvPostItFields.end(), *it), mvPostItFields.end());
if (GetActiveSidebarWin() == p->pPostIt)
SetActiveSidebarWin(nullptr);
p->pPostIt.disposeAndClear();
@@ -573,7 +574,7 @@ bool SwPostItMgr::CalcRects()
// show notes in right order in navigator
//prevent Anchors during layout to overlap, e.g. when moving a frame
if (mvPostItFields.size()>1 )
- mvPostItFields.sort(comp_pos);
+ std::stable_sort(mvPostItFields.begin(), mvPostItFields.end(), comp_pos);
// sort the items into the right page vector, so layout can be done by page
for (auto const& pItem : mvPostItFields)
@@ -1385,7 +1386,7 @@ public:
//Fields more than once.
class FieldDocWatchingStack : public SfxListener
{
- std::list<SwSidebarItem*>& l;
+ std::vector<SwSidebarItem*>& sidebarItemVector;
std::vector<const SwFormatField*> v;
SwDocShell& m_rDocShell;
FilterFunctor& m_rFilter;
@@ -1425,8 +1426,8 @@ class FieldDocWatchingStack : public SfxListener
}
public:
- FieldDocWatchingStack(std::list<SwSidebarItem*>& in, SwDocShell &rDocShell, FilterFunctor& rFilter)
- : l(in)
+ FieldDocWatchingStack(std::vector<SwSidebarItem*>& in, SwDocShell &rDocShell, FilterFunctor& rFilter)
+ : sidebarItemVector(in)
, m_rDocShell(rDocShell)
, m_rFilter(rFilter)
{
@@ -1437,8 +1438,8 @@ public:
{
EndListeningToAllFields();
v.clear();
- v.reserve(l.size());
- for (auto const& p : l)
+ v.reserve(sidebarItemVector.size());
+ for (auto const& p : sidebarItemVector)
{
const SwFormatField& rField = p->GetFormatField();
if (!m_rFilter(&rField))
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index a6431a67975f..7a734e61112a 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3266,10 +3266,9 @@ OUString SwXTextDocument::getPostIts()
{
SolarMutexGuard aGuard;
boost::property_tree::ptree aAnnotations;
- for (std::list<SwSidebarItem*>::const_iterator i = pDocShell->GetView()->GetPostItMgr()->begin();
- i != pDocShell->GetView()->GetPostItMgr()->end(); ++i )
+ for (auto const& sidebarItem : *pDocShell->GetView()->GetPostItMgr())
{
- sw::annotation::SwAnnotationWin* pWin = (*i)->pPostIt.get();
+ sw::annotation::SwAnnotationWin* pWin = sidebarItem->pPostIt.get();
const SwPostItField* pField = pWin->GetPostItField();
const SwRect& aRect = pWin->GetAnchorRect();