use UnoCursorPointer in SwNavigationMgr
Change-Id: I7c7431edd79cf4527f97c7dc0695d49174b61e2c
This commit is contained in:
@@ -115,6 +115,13 @@ namespace sw
|
||||
{
|
||||
m_pCursor->Add(this);
|
||||
}
|
||||
UnoCursorPointer(const UnoCursorPointer& pOther)
|
||||
: SwClient(nullptr)
|
||||
, m_pCursor(pOther.m_pCursor)
|
||||
{
|
||||
if(m_pCursor)
|
||||
m_pCursor->Add(this);
|
||||
}
|
||||
virtual ~UnoCursorPointer() SAL_OVERRIDE
|
||||
{
|
||||
if(m_pCursor)
|
||||
@@ -132,6 +139,13 @@ namespace sw
|
||||
{ return *m_pCursor.get(); }
|
||||
SwUnoCrsr* operator->() const
|
||||
{ return m_pCursor.get(); }
|
||||
UnoCursorPointer& operator=(UnoCursorPointer aOther)
|
||||
{
|
||||
if(aOther.m_pCursor)
|
||||
aOther.m_pCursor->Add(this);
|
||||
m_pCursor = aOther.m_pCursor;
|
||||
return *this;
|
||||
}
|
||||
explicit operator bool() const
|
||||
{ return static_cast<bool>(m_pCursor); }
|
||||
void reset(std::shared_ptr<SwUnoCrsr> pNew)
|
||||
|
@@ -15,12 +15,13 @@
|
||||
#include "swtypes.hxx"
|
||||
#include "calbck.hxx"
|
||||
#include "unocrsr.hxx"
|
||||
#include "vcl/svapp.hxx"
|
||||
|
||||
class SwWrtShell;
|
||||
struct SwPosition;
|
||||
class SwUnoCrsr;
|
||||
|
||||
class SwNavigationMgr : SwClient
|
||||
class SwNavigationMgr
|
||||
{
|
||||
private:
|
||||
/*
|
||||
@@ -32,7 +33,7 @@ private:
|
||||
* (e.g. click a link, or double click an entry from the navigator).
|
||||
* Every use of the back/forward buttons results in moving the stack pointer within the navigation history
|
||||
*/
|
||||
typedef ::std::vector< std::shared_ptr<SwUnoCrsr> > Stack_t;
|
||||
typedef ::std::vector< sw::UnoCursorPointer > Stack_t;
|
||||
Stack_t m_entries;
|
||||
Stack_t::size_type m_nCurrent; /* Current position within the navigation history */
|
||||
SwWrtShell & m_rMyShell; /* The active shell within which the navigation occurs */
|
||||
@@ -44,11 +45,8 @@ public:
|
||||
SwNavigationMgr( SwWrtShell & rShell );
|
||||
virtual ~SwNavigationMgr()
|
||||
{
|
||||
for(auto pEntry : m_entries)
|
||||
{
|
||||
if(pEntry && GetRegisteredIn() == pEntry.get())
|
||||
pEntry->Remove(this);
|
||||
}
|
||||
SolarMutexGuard g;
|
||||
m_entries.clear();
|
||||
}
|
||||
/* Can we go back in the history ? */
|
||||
bool backEnabled() ;
|
||||
@@ -60,7 +58,6 @@ public:
|
||||
void goForward() ;
|
||||
/* The method that adds the position pPos to the navigation history */
|
||||
bool addEntry(const SwPosition& rPos);
|
||||
void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
|
||||
};
|
||||
#endif
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -162,17 +162,15 @@ bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
|
||||
|
||||
if (*m_entries.back()->GetPoint() != rPos)
|
||||
{
|
||||
std::shared_ptr<SwUnoCrsr> pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr(rPos));
|
||||
sw::UnoCursorPointer pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr(rPos));
|
||||
m_entries.push_back(pCursor);
|
||||
pCursor->Add(this);
|
||||
}
|
||||
bRet = true;
|
||||
}
|
||||
else {
|
||||
if ( (!m_entries.empty() && *m_entries.back()->GetPoint() != rPos) || m_entries.empty() ) {
|
||||
auto pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr(rPos));
|
||||
sw::UnoCursorPointer pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr(rPos));
|
||||
m_entries.push_back(pCursor);
|
||||
pCursor->Add(this);
|
||||
bRet = true;
|
||||
}
|
||||
if (m_entries.size() > 1 && *m_entries.back()->GetPoint() == rPos)
|
||||
@@ -216,14 +214,4 @@ bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void SwNavigationMgr::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
|
||||
{
|
||||
if(typeid(rHint) == typeid(sw::DocDisposingHint))
|
||||
{
|
||||
m_entries.clear();
|
||||
}
|
||||
else
|
||||
SwClient::SwClientNotify(rModify, rHint);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Reference in New Issue
Block a user