[Libreoffice-commits] core.git: Branch 'private/Sweetshark/mmunocrsrs' - 13 commits - sw/inc sw/qa sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Sat May 23 04:28:32 PDT 2015
sw/inc/doc.hxx | 9 -
sw/inc/docary.hxx | 6 -
sw/inc/unocrsr.hxx | 1
sw/inc/unotextcursor.hxx | 4
sw/inc/unotxdoc.hxx | 4
sw/qa/core/macros-test.cxx | 2
sw/source/core/access/accpara.cxx | 2
sw/source/core/doc/CntntIdxStore.cxx | 17 ---
sw/source/core/doc/DocumentContentOperationsManager.cxx | 2
sw/source/core/doc/doc.cxx | 16 ---
sw/source/core/doc/doccorr.cxx | 63 -------------
sw/source/core/doc/docnew.cxx | 4
sw/source/core/inc/unoport.hxx | 5 +
sw/source/core/unocore/unochart.cxx | 2
sw/source/core/unocore/unocrsr.cxx | 34 +------
sw/source/core/unocore/unoframe.cxx | 2
sw/source/core/unocore/unoftn.cxx | 4
sw/source/core/unocore/unoobj.cxx | 74 ++++++++--------
sw/source/core/unocore/unoobj2.cxx | 50 +++++++---
sw/source/core/unocore/unoparagraph.cxx | 2
sw/source/core/unocore/unoport.cxx | 26 +++--
sw/source/core/unocore/unoportenum.cxx | 34 ++++---
sw/source/core/unocore/unoredline.cxx | 8 -
sw/source/core/unocore/unotbl.cxx | 25 ++---
sw/source/core/unocore/unotext.cxx | 8 -
sw/source/filter/ww8/ww8par.cxx | 2
sw/source/uibase/shells/grfsh.cxx | 2
sw/source/uibase/uno/unotxdoc.cxx | 18 +--
sw/source/uibase/wrtsh/navmgr.cxx | 4
29 files changed, 172 insertions(+), 258 deletions(-)
New commits:
commit 4a283c72667c25848eb5fbee28ed3c4fa6bd942c
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 13:25:12 2015 +0200
remove the weak_ptrs on distruction too
Change-Id: I65f5867c41417539a70eef15754988d9931394a4
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index 501b676..e826f4e 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -23,6 +23,7 @@
#include <swtable.hxx>
#include <docary.hxx>
#include <rootfrm.hxx>
+#include <calbck.hxx>
IMPL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr )
@@ -39,7 +40,13 @@ SwUnoCrsr::~SwUnoCrsr()
SwDoc* pDoc = GetDoc();
if( !pDoc->IsInDtor() )
{
- //assert(!SwIterator<SwClient,SwUnoCrsr>(this).First());
+#ifdef DEBUG
+ SwIterator<SwClient, SwUnoCrsr> pClient(*this);
+ assert(!pClient.First());
+#endif
+ // remove the weak_ptr the document keeps to notify about document death
+ pDoc->mvUnoCrsrTbl.remove_if(
+ [this](const std::weak_ptr<SwUnoCrsr>& pWeakPtr) -> bool { return pWeakPtr.lock().get() == this; });
}
// delete the whole ring
commit 793816741bfeaa11796b6b6621e85d30d67233cf
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 12:44:07 2015 +0200
now rename the new CreateUnoCrsr2 to CreateUnoCrsr, as the old stuff is gone
Change-Id: I82f8ed0560750d4f7bec71ea8bd3c8089b884da7
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 1620231..e3cd70a 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1496,7 +1496,7 @@ public:
void SetOLEObjModified();
// Uno - Interfaces
- std::shared_ptr<SwUnoCrsr> CreateUnoCrsr2( const SwPosition& rPos, bool bTblCrsr = false );
+ std::shared_ptr<SwUnoCrsr> CreateUnoCrsr( const SwPosition& rPos, bool bTblCrsr = false );
// FeShell - Interfaces
// !!! These assume always an existing layout !!!
@@ -1670,7 +1670,7 @@ public:
void dumpAsXml(struct _xmlTextWriter* = 0) const;
std::set<Color> GetDocColors();
- std::list< std::weak_ptr<SwUnoCrsr> > mvUnoCrsrTbl2;
+ std::list< std::weak_ptr<SwUnoCrsr> > mvUnoCrsrTbl;
private:
// Copies master header to left / first one, if necessary - used by ChgPageDesc().
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 67ef345..d3313b8 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -409,7 +409,7 @@ void SwMacrosTest::testFindReplace()
SwDoc *const pDoc = pTxtDoc->GetDocShell()->GetDoc();
SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1);
// use a UnoCrsr so it will be corrected when deleting nodes
- auto pPaM(pDoc->CreateUnoCrsr2(SwPosition(aIdx), false));
+ auto pPaM(pDoc->CreateUnoCrsr(SwPosition(aIdx), false));
IDocumentContentOperations & rIDCO(pDoc->getIDocumentContentOperations());
rIDCO.InsertString(*pPaM, OUString("foo"));
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 2c7d0ac..103a5e1 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -640,7 +640,7 @@ SwXTextPortion* SwAccessibleParagraph::CreateUnoPortion(
SwTxtNode* pTxtNode = const_cast<SwTxtNode*>( GetTxtNode() );
SwIndex aIndex( pTxtNode, nStart );
SwPosition aStartPos( *pTxtNode, aIndex );
- auto pUnoCursor(pTxtNode->GetDoc()->CreateUnoCrsr2( aStartPos ));
+ auto pUnoCursor(pTxtNode->GetDoc()->CreateUnoCrsr( aStartPos ));
pUnoCursor->SetMark();
pUnoCursor->GetMark()->nContent = nEnd;
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index ad02e6e..0eab68d 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -379,7 +379,7 @@ void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto
void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
{
- for (auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl2)
+ for (auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
{
auto pUnoCrsr(pWeakUnoCrsr.lock());
if(!pUnoCrsr)
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index da404ee..a2faeb7 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4092,7 +4092,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
SwUndoCpyDoc* pUndo = 0;
// lcl_DeleteRedlines may delete the start or end node of the cursor when
// removing the redlines so use cursor that is corrected by PaMCorrAbs
- std::shared_ptr<SwUnoCrsr> const pCopyPam(pDoc->CreateUnoCrsr2(rPos));
+ std::shared_ptr<SwUnoCrsr> const pCopyPam(pDoc->CreateUnoCrsr(rPos));
SwTblNumFmtMerge aTNFM( m_rDoc, *pDoc );
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 40f258e..c2d68a1 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1675,7 +1675,7 @@ bool SwDoc::ContainsHiddenChars() const
return false;
}
-std::shared_ptr<SwUnoCrsr> SwDoc::CreateUnoCrsr2( const SwPosition& rPos, bool bTblCrsr )
+std::shared_ptr<SwUnoCrsr> SwDoc::CreateUnoCrsr( const SwPosition& rPos, bool bTblCrsr )
{
std::shared_ptr<SwUnoCrsr> pNew;
if( bTblCrsr )
@@ -1683,7 +1683,7 @@ std::shared_ptr<SwUnoCrsr> SwDoc::CreateUnoCrsr2( const SwPosition& rPos, bool b
else
pNew.reset(new SwUnoCrsr( rPos ));
- mvUnoCrsrTbl2.push_back( pNew );
+ mvUnoCrsrTbl.push_back( pNew );
return pNew;
}
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index c6d646a..e60791d 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -121,7 +121,7 @@ void PaMCorrAbs( const SwPaM& rRange,
}
}
{
- for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl2)
+ for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
{
auto pUnoCursor(pWeakUnoCrsr.lock());
if(!pUnoCursor)
@@ -275,7 +275,7 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
}
}
{
- for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl2)
+ for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl)
{
auto pUnoCrsr(pWeakUnoCrsr.lock());
if(!pUnoCrsr)
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index b45771b..b5803b4 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -425,7 +425,7 @@ SwDoc::~SwDoc()
getIDocumentRedlineAccess().GetExtraRedlineTbl().DeleteAndDestroyAll();
const sw::DocDisposingHint aHint;
- std::vector< std::weak_ptr<SwUnoCrsr> > vCursorsToKill(mvUnoCrsrTbl2.begin(), mvUnoCrsrTbl2.end());
+ std::vector< std::weak_ptr<SwUnoCrsr> > vCursorsToKill(mvUnoCrsrTbl.begin(), mvUnoCrsrTbl.end());
for(auto& pWeakCursor : vCursorsToKill)
{
auto pCursor(pWeakCursor.lock());
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 0b5d586..f217dce 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -413,7 +413,7 @@ static void GetFormatAndCreateCursorFromRangeRep(
SwPosition aPos(*pSttNd);
// set cursor to top left box of range
- auto pUnoCrsr = pTblFmt->GetDoc()->CreateUnoCrsr2(aPos, true);
+ auto pUnoCrsr = pTblFmt->GetDoc()->CreateUnoCrsr(aPos, true);
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index 7ca0659..501b676 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -53,7 +53,7 @@ SwUnoCrsr::~SwUnoCrsr()
std::shared_ptr<SwUnoCrsr> SwUnoTableCrsr::Clone() const
{
- auto pNewCrsr(GetDoc()->CreateUnoCrsr2(*GetPoint(), true));
+ auto pNewCrsr(GetDoc()->CreateUnoCrsr(*GetPoint(), true));
if(HasMark())
{
pNewCrsr->SetMark();
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index f2930e9..a5627e3 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -3262,7 +3262,7 @@ uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void)
if(!pFmt)
return nullptr;
SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode());
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(aPos, false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(aPos, false));
pUnoCursor->Move(fnMoveForward, fnGoNode);
return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME);
}
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index 40862b4..00d1330 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -478,7 +478,7 @@ SwXFootnote::createEnumeration() throw (uno::RuntimeException, std::exception)
SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn();
SwPosition aPos( *pTxtFtn->GetStartNode() );
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(aPos, false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(aPos, false));
pUnoCursor->Move(fnMoveForward, fnGoNode);
return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE);
}
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index a5c02d6..e2d62b5 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -670,7 +670,7 @@ public:
: m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
, m_eType(eType)
, m_xParentText(xParent)
- , m_pUnoCursor(rDoc.CreateUnoCrsr2(rPoint, false))
+ , m_pUnoCursor(rDoc.CreateUnoCrsr(rPoint, false))
{
m_pUnoCursor->Add(this);
if (pMark)
@@ -2051,7 +2051,7 @@ lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc,
// if we are reseting paragraph attributes, we need to select the full paragraph first
SwPosition aStart = *rPaM.Start();
SwPosition aEnd = *rPaM.End();
- auto pTemp ( rDoc.CreateUnoCrsr2(aStart, false) );
+ auto pTemp ( rDoc.CreateUnoCrsr(aStart, false) );
if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
{
pTemp->MovePara(fnParaCurr, fnParaStart);
@@ -3018,7 +3018,7 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException, std::exception)
throw uno::RuntimeException();
}
- auto pNewCrsr(rUnoCursor.GetDoc()->CreateUnoCrsr2(*rUnoCursor.GetPoint()) );
+ auto pNewCrsr(rUnoCursor.GetDoc()->CreateUnoCrsr(*rUnoCursor.GetPoint()) );
if (rUnoCursor.HasMark())
{
pNewCrsr->SetMark();
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index a4e3063..370f97f 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -601,7 +601,7 @@ throw (container::NoSuchElementException, lang::WrappedTargetException,
(CURSOR_SELECTION_IN_TABLE == m_eCursorType)))
{
SwPosition* pStart = pUnoCrsr->Start();
- auto aNewCrsr(pUnoCrsr->GetDoc()->CreateUnoCrsr2(*pStart, false));
+ auto aNewCrsr(pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, false));
// one may also go into tables here
if ((CURSOR_TBLTEXT != m_eCursorType) &&
(CURSOR_SELECTION_IN_TABLE != m_eCursorType))
@@ -1146,7 +1146,7 @@ SwXTextRange::CreateXTextRange(
{
const uno::Reference<text::XText> xParentText(
::sw::CreateParentXText(rDoc, rPos));
- const auto pNewCrsr(rDoc.CreateUnoCrsr2(rPos, false));
+ const auto pNewCrsr(rDoc.CreateUnoCrsr(rPos, false));
if(pMark)
{
pNewCrsr->SetMark();
@@ -1280,7 +1280,7 @@ throw (uno::RuntimeException, std::exception)
throw uno::RuntimeException();
}
const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent());
- const auto pNewCrsr(m_pImpl->m_rDoc.CreateUnoCrsr2(aPos, false));
+ const auto pNewCrsr(m_pImpl->m_rDoc.CreateUnoCrsr(aPos, false));
if (!GetPositions(*pNewCrsr))
{
throw uno::RuntimeException();
@@ -1301,7 +1301,7 @@ SwXTextRange::createEnumeration() throw (uno::RuntimeException, std::exception)
throw uno::RuntimeException();
}
const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent());
- auto pNewCrsr(m_pImpl->m_rDoc.CreateUnoCrsr2(aPos, false));
+ auto pNewCrsr(m_pImpl->m_rDoc.CreateUnoCrsr(aPos, false));
if (!GetPositions(*pNewCrsr))
{
throw uno::RuntimeException();
@@ -1513,7 +1513,7 @@ public:
{
if (pPaM)
{
- m_pUnoCursor = pPaM->GetDoc()->CreateUnoCrsr2(*pPaM->GetPoint());
+ m_pUnoCursor = pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint());
m_pUnoCursor->Add(this);
::sw::DeepCopyPaM(*pPaM, *GetCursor());
}
@@ -1701,7 +1701,7 @@ public:
::std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
Impl(SwPaM const & rPaM)
- : m_pUnoCursor(rPaM.GetDoc()->CreateUnoCrsr2(*rPaM.GetPoint(), false))
+ : m_pUnoCursor(rPaM.GetDoc()->CreateUnoCrsr(*rPaM.GetPoint(), false))
{
m_pUnoCursor->Add(this);
if (rPaM.HasMark())
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index 56fb120..7c53d4e 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1180,7 +1180,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
// to paragraph boundaries
SwPosition aStart( *aCursor.Start() );
SwPosition aEnd ( *aCursor.End() );
- auto pTemp( aCursor.GetDoc()->CreateUnoCrsr2(aStart, false) );
+ auto pTemp( aCursor.GetDoc()->CreateUnoCrsr(aStart, false) );
if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
{
pTemp->MovePara(fnParaCurr, fnParaStart);
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index e812b7f..1751a89 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -63,7 +63,7 @@ public:
void SwXTextPortion::init(const SwUnoCrsr* pPortionCursor)
{
- m_pUnoCursor = pPortionCursor->GetDoc()->CreateUnoCrsr2(*pPortionCursor->GetPoint());
+ m_pUnoCursor = pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint());
if (pPortionCursor->HasMark())
{
m_pUnoCursor->SetMark();
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 04f3a46..3c1ad35 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -363,7 +363,7 @@ SwXTextPortionEnumeration::SwXTextPortionEnumeration(
const sal_Int32 nEnd )
: m_Portions()
{
- m_pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr2(*rParaCrsr.GetPoint(), false);
+ m_pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), false);
m_pUnoCrsr->Add(this);
OSL_ENSURE(nEnd == -1 || (nStart <= nEnd &&
@@ -381,7 +381,7 @@ SwXTextPortionEnumeration::SwXTextPortionEnumeration(
TextRangeList_t const & rPortions )
: m_Portions( rPortions )
{
- m_pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr2(*rParaCrsr.GetPoint(), false);
+ m_pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), false);
m_pUnoCrsr->Add(this);
}
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index d9bf944..28dc08e 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -161,7 +161,7 @@ uno::Reference<container::XEnumeration> SwXRedlineText::createEnumeration(void)
SolarMutexGuard aGuard;
SwPaM aPam(aNodeIndex);
aPam.Move(fnMoveForward, fnGoNode);
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(*aPam.Start(), false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(*aPam.Start(), false));
return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE);
}
@@ -538,7 +538,7 @@ uno::Reference< container::XEnumeration > SwXRedline::createEnumeration(void) t
return nullptr;
SwPaM aPam(*pNodeIndex);
aPam.Move(fnMoveForward, fnGoNode);
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(*aPam.Start(), false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(*aPam.Start(), false));
return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE);
}
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index eee726c..47127d0 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1114,7 +1114,7 @@ uno::Reference<container::XEnumeration> SwXCell::createEnumeration(void) throw(
return uno::Reference<container::XEnumeration>();
const SwStartNode* pSttNd = pBox->GetSttNd();
SwPosition aPos(*pSttNd);
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(aPos, false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(aPos, false));
pUnoCursor->Move(fnMoveForward, fnGoNode);
// remember table and start node for later travelling
// (used in export of tables in tables)
@@ -1419,7 +1419,7 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) :
SwDoc* pDoc = pFmt->GetDoc();
const SwStartNode* pSttNd = pBox->GetSttNd();
SwPosition aPos(*pSttNd);
- m_pUnoCrsr = pDoc->CreateUnoCrsr2(aPos, true);
+ m_pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
m_pUnoCrsr->Move( fnMoveForward, fnGoNode );
m_pUnoCrsr->Add(&aCrsrDepend);
SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr.get());
@@ -1431,7 +1431,7 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor*
aCrsrDepend(this, 0),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
{
- m_pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr2(*pTableSelection->GetPoint(), true);
+ m_pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr(*pTableSelection->GetPoint(), true);
if(pTableSelection->HasMark())
{
m_pUnoCrsr->SetMark();
@@ -2205,7 +2205,7 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, S
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
- auto pUnoCrsr(pFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFmt->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection(false);
const SwTableBox* pBRBox(pTable->GetTblBox(rBRName));
@@ -2582,7 +2582,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to top left cell
- auto pUnoCrsr(pDoc->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pDoc->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
@@ -2771,7 +2771,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to top left cell
- auto pUnoCrsr(pDoc->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pDoc->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
@@ -3222,7 +3222,7 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor in the upper-left cell of the range
- auto pUnoCrsr(pFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFmt->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
const SwTableBox* pBRBox = pTable->GetTblBox( sBRName );
@@ -3997,7 +3997,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
UnoActionContext aAction(pFrmFmt->GetDoc());
- auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
{
// remove actions
@@ -4027,7 +4027,7 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
- auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection( false );
const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
@@ -4135,7 +4135,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
UnoActionContext aAction(pFrmFmt->GetDoc());
- auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
{
@@ -4168,7 +4168,7 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
- auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection(false);
const OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 035c413..76cb2e7 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -2552,7 +2552,7 @@ throw (uno::RuntimeException, std::exception)
SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
SwPosition aPos(rNode);
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(aPos, false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(aPos, false));
pUnoCursor->Move(fnMoveBackward, fnGoDoc);
return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY);
}
@@ -2814,7 +2814,7 @@ throw (uno::RuntimeException, std::exception)
const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt();
const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode();
SwPosition aPos(rNode);
- auto pUnoCursor(GetDoc()->CreateUnoCrsr2(aPos, false));
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr(aPos, false));
pUnoCursor->Move(fnMoveForward, fnGoNode);
return new SwXParagraphEnumeration(this, pUnoCursor,
(m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 391af14..068b84f 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4898,7 +4898,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
pDocShell->SetReadOnlyUI(true);
}
- mpCrsr = rDoc.CreateUnoCrsr2(rPos);
+ mpCrsr = rDoc.CreateUnoCrsr(rPos);
pPaM = mpCrsr.get();
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index f84a6f3..af40837 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -91,7 +91,7 @@ public:
SwExternalToolEdit(SwWrtShell *const pShell)
: m_pShell(pShell)
, m_pCursor( // need only Point, must point to SwGrfNode
- pShell->GetDoc()->CreateUnoCrsr2(
+ pShell->GetDoc()->CreateUnoCrsr(
*pShell->GetCurrentShellCursor().GetPoint()))
{
}
diff --git a/sw/source/uibase/wrtsh/navmgr.cxx b/sw/source/uibase/wrtsh/navmgr.cxx
index d843e37..6740fa5 100644
--- a/sw/source/uibase/wrtsh/navmgr.cxx
+++ b/sw/source/uibase/wrtsh/navmgr.cxx
@@ -162,7 +162,7 @@ bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
if (*m_entries.back()->GetPoint() != rPos)
{
- std::shared_ptr<SwUnoCrsr> pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr2(rPos));
+ std::shared_ptr<SwUnoCrsr> pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr(rPos));
m_entries.push_back(pCursor);
pCursor->Add(this);
}
@@ -170,7 +170,7 @@ bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
}
else {
if ( (!m_entries.empty() && *m_entries.back()->GetPoint() != rPos) || m_entries.empty() ) {
- auto pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr2(rPos));
+ auto pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr(rPos));
m_entries.push_back(pCursor);
pCursor->Add(this);
bRet = true;
commit 580b3fa5a658d98fa0df51ed84593558119bee42
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 12:04:30 2015 +0200
fixup! spurious SwUnoCrsrTbl
Change-Id: Ibd4e5ffd7a5ef2d2dd1f1d695d14836edffa1654
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 2333032..1620231 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -146,7 +146,6 @@ class SwTxtFmtColl;
class SwTxtFmtColls;
class SwURLStateChanged;
class SwUnoCrsr;
-class SwUnoCrsrTbl;
class SwViewShell;
class _SetGetExpFld;
class SwDrawContact;
commit ce6e81ef330276ae3c177769a6a935be540e7b83
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 12:01:03 2015 +0200
remove SaneOwnership distinction
Change-Id: I0639a960916ffa30d7eaf865755e407f706e9f13
diff --git a/sw/inc/unocrsr.hxx b/sw/inc/unocrsr.hxx
index f378f72..f3fcd05 100644
--- a/sw/inc/unocrsr.hxx
+++ b/sw/inc/unocrsr.hxx
@@ -37,7 +37,6 @@ private:
public:
SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing = 0 );
virtual ~SwUnoCrsr();
- bool m_bSaneOwnership;
protected:
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 49da5b9..40f258e 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1683,7 +1683,6 @@ std::shared_ptr<SwUnoCrsr> SwDoc::CreateUnoCrsr2( const SwPosition& rPos, bool b
else
pNew.reset(new SwUnoCrsr( rPos ));
- pNew->m_bSaneOwnership = true;
mvUnoCrsrTbl2.push_back( pNew );
return pNew;
}
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index 7816f53..7ca0659 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -32,7 +32,6 @@ SwUnoCrsr::SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing )
, m_bRemainInSection(true)
, m_bSkipOverHiddenSections(false)
, m_bSkipOverProtectSections(false)
- , m_bSaneOwnership(false)
{}
SwUnoCrsr::~SwUnoCrsr()
@@ -40,10 +39,7 @@ SwUnoCrsr::~SwUnoCrsr()
SwDoc* pDoc = GetDoc();
if( !pDoc->IsInDtor() )
{
- if(m_bSaneOwnership)
- {
- //assert(!SwIterator<SwClient,SwUnoCrsr>(this).First());
- }
+ //assert(!SwIterator<SwClient,SwUnoCrsr>(this).First());
}
// delete the whole ring
@@ -57,7 +53,6 @@ SwUnoCrsr::~SwUnoCrsr()
std::shared_ptr<SwUnoCrsr> SwUnoTableCrsr::Clone() const
{
- assert(m_bSaneOwnership);
auto pNewCrsr(GetDoc()->CreateUnoCrsr2(*GetPoint(), true));
if(HasMark())
{
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 03ebbf4..a5c02d6 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -720,7 +720,6 @@ void SwXTextCursor::Impl::SwClientNotify(const SwModify& rModify, const SfxHint&
SwClient::SwClientNotify(rModify, rHint);
if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
{
- assert(m_pUnoCursor->m_bSaneOwnership);
Invalidate();
}
}
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 37c4f23..a4e3063 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -486,13 +486,11 @@ protected:
void SwXParagraphEnumeration::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
{
- assert(m_pCrsr->m_bSaneOwnership);
ClientModify(this, pOld, pNew);
}
void SwXParagraphEnumeration::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- assert(m_pCrsr->m_bSaneOwnership);
SwClient::SwClientNotify(rModify, rHint);
if(m_pCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
{
@@ -1550,7 +1548,6 @@ void SwXTextRanges::Impl::SwClientNotify(const SwModify& rModify, const SfxHint&
SwClient::SwClientNotify(rModify, rHint);
if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
{
- assert(m_pUnoCursor->m_bSaneOwnership);
m_pUnoCursor->Remove(this);
m_pUnoCursor.reset();
}
@@ -1757,7 +1754,6 @@ void SwXParaFrameEnumeration::Impl::SwClientNotify(const SwModify& rModify, cons
SwClient::SwClientNotify(rModify, rHint);
if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
{
- assert(m_pUnoCursor->m_bSaneOwnership);
m_pUnoCursor->Remove(this);
m_pUnoCursor.reset();
}
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 0ca32bf..e812b7f 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -931,7 +931,6 @@ void SwXTextPortion::SwClientNotify(const SwModify& rModify, const SfxHint& rHin
SwClient::SwClientNotify(rModify, rHint);
if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
{
- assert(m_pUnoCursor->m_bSaneOwnership);
m_pUnoCursor->Remove(this);
m_pUnoCursor.reset();
}
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 01c814e..04f3a46 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -1411,7 +1411,6 @@ void SwXTextPortionEnumeration::SwClientNotify(const SwModify& rModify, const Sf
SwClient::SwClientNotify(rModify, rHint);
if(!GetRegisteredIn() || typeid(rHint) == typeid(sw::DocDisposingHint))
{
- assert(m_pUnoCrsr->m_bSaneOwnership);
m_pUnoCrsr->Remove(this);
m_pUnoCrsr.reset();
}
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 59d82af..eee726c 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1747,7 +1747,6 @@ void SwXTextTableCursor::SwClientNotify(const SwModify& rModify, const SfxHint&
SwClient::SwClientNotify(rModify, rHint);
if(m_pUnoCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
{
- assert(m_pUnoCrsr->m_bSaneOwnership);
m_pUnoCrsr->Remove(&aCrsrDepend);
m_pUnoCrsr.reset();
}
commit d55dd12e21075e5489029e7c96cf441e8db07b08
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 11:49:33 2015 +0200
remove old SwUnoCrsrTbl and CreateUnoCrsr
Change-Id: I91e4c7f0e0231b7783affdce63c6ab395a4e219b
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 07fd54e..2333032 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -336,8 +336,6 @@ class SW_DLLPUBLIC SwDoc :
// Hash map to find numrules by name
mutable std::unordered_map<OUString, SwNumRule *, OUStringHash> maNumRuleMap;
- SwUnoCrsrTbl *mpUnoCrsrTbl;
-
SwPagePreviewPrtData *mpPgPViewPrtData; //< Indenting / spacing for printing of page view.
SwPaM *mpExtInputRing;
@@ -1499,8 +1497,6 @@ public:
void SetOLEObjModified();
// Uno - Interfaces
- const SwUnoCrsrTbl& GetUnoCrsrTbl() const { return *mpUnoCrsrTbl; }
- SwUnoCrsr* CreateUnoCrsr( const SwPosition& rPos, bool bTblCrsr = false );
std::shared_ptr<SwUnoCrsr> CreateUnoCrsr2( const SwPosition& rPos, bool bTblCrsr = false );
// FeShell - Interfaces
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 93590f6..780c5ab 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -262,12 +262,6 @@ public:
bool DeleteTableCellRedline( SwDoc* pDoc, const SwTableBox& rTableBox, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
};
-class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> {
-public:
- /// the destructor will free all objects still in the set
- ~SwUnoCrsrTbl();
-};
-
typedef std::vector<SwOLENode*> SwOLENodes;
#endif // INCLUDED_SW_INC_DOCARY_HXX
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 5e20514..ad02e6e 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -379,21 +379,6 @@ void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto
void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
{
- for (const SwUnoCrsr* pUnoCrsr : pDoc->GetUnoCrsrTbl())
- {
- for(SwPaM& rPaM : (const_cast<SwUnoCrsr*>(pUnoCrsr))->GetRingContainer())
- {
- lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, rPaM);
- }
- const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
- if( pUnoTblCrsr )
- {
- for(SwPaM& rPaM : (&(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing())->GetRingContainer())
- {
- lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, rPaM);
- }
- }
- }
for (auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl2)
{
auto pUnoCrsr(pWeakUnoCrsr.lock());
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index c614489..49da5b9 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1675,17 +1675,6 @@ bool SwDoc::ContainsHiddenChars() const
return false;
}
-SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, bool bTblCrsr )
-{
- SwUnoCrsr* pNew;
- if( bTblCrsr )
- pNew = new SwUnoTableCrsr( rPos );
- else
- pNew = new SwUnoCrsr( rPos );
-
- mpUnoCrsrTbl->insert( pNew );
- return pNew;
-}
std::shared_ptr<SwUnoCrsr> SwDoc::CreateUnoCrsr2( const SwPosition& rPos, bool bTblCrsr )
{
std::shared_ptr<SwUnoCrsr> pNew;
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 0fb3cd8..c6d646a 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -121,47 +121,6 @@ void PaMCorrAbs( const SwPaM& rRange,
}
}
{
- SwUnoCrsrTbl& rTbl = const_cast<SwUnoCrsrTbl&>(pDoc->GetUnoCrsrTbl());
-
- for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
- {
- SwUnoCrsr *const pUnoCursor = *it;
-
- bool bChange = false; // has the UNO cursor been corrected?
-
- // determine whether the UNO cursor will leave it's designated
- // section
- bool const bLeaveSection =
- pUnoCursor->IsRemainInSection() &&
- ( lcl_FindUnoCrsrSection( aNewPos.nNode.GetNode() ) !=
- lcl_FindUnoCrsrSection(
- pUnoCursor->GetPoint()->nNode.GetNode() ) );
-
- for(SwPaM& rPaM : pUnoCursor->GetRingContainer())
- {
- bChange |= lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
- }
-
- SwUnoTableCrsr *const pUnoTblCrsr =
- dynamic_cast<SwUnoTableCrsr *>(*it);
- if( pUnoTblCrsr )
- {
- for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
- {
- bChange |=
- lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
- }
- }
-
- // if a UNO cursor leaves its designated section, we must inform
- // (and invalidate) said cursor
- if (bChange && bLeaveSection)
- {
- // the UNO cursor has left its section. We need to notify it!
- SwMsgPoolItem aHint( RES_UNOCURSOR_LEAVES_SECTION );
- pUnoCursor->ModifyNotification( &aHint, NULL );
- }
- }
for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl2)
{
auto pUnoCursor(pWeakUnoCrsr.lock());
@@ -316,24 +275,6 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
}
}
{
- SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
- for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
- {
- for(SwPaM& rPaM : (*it)->GetRingContainer())
- {
- lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
- }
-
- SwUnoTableCrsr* pUnoTblCrsr =
- dynamic_cast<SwUnoTableCrsr*>(*it);
- if( pUnoTblCrsr )
- {
- for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
- {
- lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
- }
- }
- }
for(auto pWeakUnoCrsr : pDoc->mvUnoCrsrTbl2)
{
auto pUnoCrsr(pWeakUnoCrsr.lock());
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 41feb4b..b45771b 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -251,7 +251,6 @@ SwDoc::SwDoc()
mpURLStateChgd( 0 ),
mpNumberFormatter( 0 ),
mpNumRuleTbl( new SwNumRuleTbl ),
- mpUnoCrsrTbl( new SwUnoCrsrTbl() ),
mpPgPViewPrtData( 0 ),
mpExtInputRing( 0 ),
mpStyleAccess( 0 ),
@@ -425,7 +424,6 @@ SwDoc::~SwDoc()
getIDocumentRedlineAccess().GetRedlineTbl().DeleteAndDestroyAll();
getIDocumentRedlineAccess().GetExtraRedlineTbl().DeleteAndDestroyAll();
- delete mpUnoCrsrTbl;
const sw::DocDisposingHint aHint;
std::vector< std::weak_ptr<SwUnoCrsr> > vCursorsToKill(mvUnoCrsrTbl2.begin(), mvUnoCrsrTbl2.end());
for(auto& pWeakCursor : vCursorsToKill)
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index 92bac9b..7816f53 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -44,15 +44,6 @@ SwUnoCrsr::~SwUnoCrsr()
{
//assert(!SwIterator<SwClient,SwUnoCrsr>(this).First());
}
- else
- {
- // then remove cursor from array
- SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
- if( !rTbl.erase( this ) )
- {
- OSL_ENSURE( false, "UNO Cursor nicht mehr im Array" );
- }
- }
}
// delete the whole ring
@@ -238,13 +229,4 @@ void SwUnoTableCrsr::MakeBoxSels()
}
}
-SwUnoCrsrTbl::~SwUnoCrsrTbl()
-{
- while (!empty())
- {
- delete *begin();
- erase( begin() );
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 53c4040e2eb005b496bc3715b0a1a332a7393a49
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 11:20:17 2015 +0200
use new unocrsrs for SwXParaFrameEnumeration
Change-Id: I0b02b32b0852cc97d4ffcbafdd0405da64b2a9af
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index cb9cd74..37c4f23 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -1701,10 +1701,12 @@ public:
// created by hasMoreElements
uno::Reference< text::XTextContent > m_xNextObject;
FrameDependList_t m_Frames;
+ ::std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
Impl(SwPaM const & rPaM)
- : SwClient(rPaM.GetDoc()->CreateUnoCrsr(*rPaM.GetPoint(), false))
+ : m_pUnoCursor(rPaM.GetDoc()->CreateUnoCrsr2(*rPaM.GetPoint(), false))
{
+ m_pUnoCursor->Add(this);
if (rPaM.HasMark())
{
GetCursor()->SetMark();
@@ -1714,7 +1716,6 @@ public:
virtual ~Impl() {
// Impl owns the cursor; delete it here: SolarMutex is locked
- delete GetRegisteredIn();
}
SwUnoCrsr * GetCursor() {
@@ -1725,6 +1726,7 @@ public:
protected:
// SwClient
virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
};
struct InvalidFrameDepend {
@@ -1750,6 +1752,17 @@ void SwXParaFrameEnumeration::Impl::Modify( const SfxPoolItem *pOld, const SfxPo
}
}
+void SwXParaFrameEnumeration::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ assert(m_pUnoCursor->m_bSaneOwnership);
+ m_pUnoCursor->Remove(this);
+ m_pUnoCursor.reset();
+ }
+}
+
static bool
lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr,
uno::Reference<text::XTextContent> & o_rNextObject,
commit 16ce5bd5d38c264471124425ab67a343381cdeca
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 11:19:37 2015 +0200
use new unocrsrs for SwXTextRanges
Change-Id: Id338cfff7bf266878f1287aa964f5e2674428e24
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 20d7f48..cb9cd74 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -1509,22 +1509,22 @@ class SwXTextRanges::Impl
{
public:
::std::vector< uno::Reference< text::XTextRange > > m_Ranges;
+ std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
Impl(SwPaM *const pPaM)
- : SwClient( (pPaM)
- ? pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint())
- : 0 )
{
if (pPaM)
{
+ m_pUnoCursor = pPaM->GetDoc()->CreateUnoCrsr2(*pPaM->GetPoint());
+ m_pUnoCursor->Add(this);
::sw::DeepCopyPaM(*pPaM, *GetCursor());
}
MakeRanges();
}
virtual ~Impl() {
- // Impl owns the cursor; delete it here: SolarMutex is locked
- delete GetRegisteredIn();
+ if(m_pUnoCursor)
+ m_pUnoCursor->Remove(this);
}
SwUnoCrsr * GetCursor() {
@@ -1537,6 +1537,7 @@ public:
protected:
// SwClient
virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
};
void SwXTextRanges::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
@@ -1544,6 +1545,17 @@ void SwXTextRanges::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pN
ClientModify(this, pOld, pNew);
}
+void SwXTextRanges::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ assert(m_pUnoCursor->m_bSaneOwnership);
+ m_pUnoCursor->Remove(this);
+ m_pUnoCursor.reset();
+ }
+}
+
void SwXTextRanges::Impl::MakeRanges()
{
if (GetCursor())
commit 45094c2e2fb4853b1c59bc2d3f21c51dd9b9700e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 11:12:23 2015 +0200
use new unocrsrs
Change-Id: I7d355e23209e94ce76961e15b6c77214a18edb4e
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 23290ef..20d7f48 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -603,8 +603,7 @@ throw (container::NoSuchElementException, lang::WrappedTargetException,
(CURSOR_SELECTION_IN_TABLE == m_eCursorType)))
{
SwPosition* pStart = pUnoCrsr->Start();
- const ::std::unique_ptr<SwUnoCrsr> aNewCrsr(
- pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, false) );
+ auto aNewCrsr(pUnoCrsr->GetDoc()->CreateUnoCrsr2(*pStart, false));
// one may also go into tables here
if ((CURSOR_TBLTEXT != m_eCursorType) &&
(CURSOR_SELECTION_IN_TABLE != m_eCursorType))
@@ -1149,8 +1148,7 @@ SwXTextRange::CreateXTextRange(
{
const uno::Reference<text::XText> xParentText(
::sw::CreateParentXText(rDoc, rPos));
- const ::std::unique_ptr<SwUnoCrsr> pNewCrsr(
- rDoc.CreateUnoCrsr(rPos, false));
+ const auto pNewCrsr(rDoc.CreateUnoCrsr2(rPos, false));
if(pMark)
{
pNewCrsr->SetMark();
@@ -1284,8 +1282,7 @@ throw (uno::RuntimeException, std::exception)
throw uno::RuntimeException();
}
const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent());
- const ::std::unique_ptr<SwUnoCrsr> pNewCrsr(
- m_pImpl->m_rDoc.CreateUnoCrsr(aPos, false));
+ const auto pNewCrsr(m_pImpl->m_rDoc.CreateUnoCrsr2(aPos, false));
if (!GetPositions(*pNewCrsr))
{
throw uno::RuntimeException();
commit 43e7da34833429906745d605c69536968c8272e2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri May 22 17:42:53 2015 +0200
new unocrsrs for SwXTextPortion
Change-Id: If2cb4ca0b650e0f5188350763e4b5bbbb4a0dbb8
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index 4b3faf1..aea3299 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -114,6 +114,7 @@ private:
::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyStyle;
::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust;
::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove;
+ std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
const SwDepend m_FrameDepend;
SwFrmFmt * m_pFrameFmt;
@@ -150,6 +151,8 @@ protected:
//SwClient
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
+
public:
SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType eType );
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 4381323..0ca32bf 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -63,14 +63,13 @@ public:
void SwXTextPortion::init(const SwUnoCrsr* pPortionCursor)
{
- SwUnoCrsr* pUnoCursor =
- pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint());
+ m_pUnoCursor = pPortionCursor->GetDoc()->CreateUnoCrsr2(*pPortionCursor->GetPoint());
if (pPortionCursor->HasMark())
{
- pUnoCursor->SetMark();
- *pUnoCursor->GetMark() = *pPortionCursor->GetMark();
+ m_pUnoCursor->SetMark();
+ *m_pUnoCursor->GetMark() = *pPortionCursor->GetMark();
}
- pUnoCursor->Add(this);
+ m_pUnoCursor->Add(this);
}
SwXTextPortion::SwXTextPortion(
@@ -138,12 +137,7 @@ SwXTextPortion::SwXTextPortion(
}
}
-SwXTextPortion::~SwXTextPortion()
-{
- SolarMutexGuard aGuard;
- SwUnoCrsr* pUnoCrsr = GetCursor();
- delete pUnoCrsr;
-}
+SwXTextPortion::~SwXTextPortion() {};
uno::Reference< text::XText > SwXTextPortion::getText()
throw( uno::RuntimeException, std::exception )
@@ -932,4 +926,15 @@ void SwXTextPortion::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
}
}
+void SwXTextPortion::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ assert(m_pUnoCursor->m_bSaneOwnership);
+ m_pUnoCursor->Remove(this);
+ m_pUnoCursor.reset();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 06403e61c85e8cc180adbf2dc9c3fdcfde6ed7d2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri May 22 16:42:23 2015 +0200
new unocrsrs for SwXTextCursor
Change-Id: I5932f75ee4814ca42f16d349094c7fa8bbb2ee63
diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx
index 8cfc15e..c86b072 100644
--- a/sw/inc/unotextcursor.hxx
+++ b/sw/inc/unotextcursor.hxx
@@ -91,8 +91,8 @@ public:
SwPaM const& rSourceCursor,
const enum CursorType eType = CURSOR_ALL);
- SwUnoCrsr * GetCursor();
- const SwUnoCrsr * GetCursor() const;
+ std::shared_ptr<SwUnoCrsr> GetCursor();
+ //const SwUnoCrsr* GetConstCursor() const;
bool IsAtEndOfMeta() const;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 22375eb..06125f5 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -427,8 +427,8 @@ public:
void InitNewDoc();
- SwUnoCrsr* CreateCursorForSearch(css::uno::Reference< css::text::XTextCursor > & xCrsr);
- SwUnoCrsr* FindAny(const css::uno::Reference< css::util::XSearchDescriptor > & xDesc,
+ std::shared_ptr<SwUnoCrsr> CreateCursorForSearch(css::uno::Reference< css::text::XTextCursor > & xCrsr);
+ std::shared_ptr<SwUnoCrsr> FindAny(const css::uno::Reference< css::util::XSearchDescriptor > & xDesc,
css::uno::Reference< css::text::XTextCursor > & xCrsr, bool bAll,
sal_Int32& nResult,
css::uno::Reference< css::uno::XInterface > xLastResult);
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index 40d2585..40862b4 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -431,7 +431,7 @@ SwXFootnote::createTextCursor() throw (uno::RuntimeException, std::exception)
SwPosition aPos( *pTxtFtn->GetStartNode() );
SwXTextCursor *const pXCursor =
new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos);
- SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
+ auto pUnoCrsr(pXCursor->GetCursor());
pUnoCrsr->Move(fnMoveForward, fnGoNode);
const uno::Reference< text::XTextCursor > xRet =
static_cast<text::XWordCursor*>(pXCursor);
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 84fb29f..03ebbf4 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -661,82 +661,83 @@ public:
const SfxItemPropertySet & m_rPropSet;
const enum CursorType m_eType;
const uno::Reference< text::XText > m_xParentText;
- bool m_bIsDisposed;
+ std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
Impl( SwDoc & rDoc,
const enum CursorType eType,
uno::Reference<text::XText> xParent,
SwPosition const& rPoint, SwPosition const*const pMark)
- : SwClient(rDoc.CreateUnoCrsr(rPoint, false))
- , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
+ : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
, m_eType(eType)
, m_xParentText(xParent)
- , m_bIsDisposed(false)
+ , m_pUnoCursor(rDoc.CreateUnoCrsr2(rPoint, false))
{
+ m_pUnoCursor->Add(this);
if (pMark)
{
GetCursor()->SetMark();
*GetCursor()->GetMark() = *pMark;
}
}
-
- virtual ~Impl() {
- // Impl owns the cursor; delete it here: SolarMutex is locked
- delete GetRegisteredIn();
+ virtual ~Impl()
+ {
+ Invalidate();
}
- SwUnoCrsr * GetCursor() {
- return (m_bIsDisposed) ? 0 :
- static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));
+ std::shared_ptr<SwUnoCrsr> GetCursor() {
+ return m_pUnoCursor;
}
-
- SwUnoCrsr & GetCursorOrThrow() {
- SwUnoCrsr *const pUnoCursor( GetCursor() );
- if (!pUnoCursor) {
+ SwUnoCrsr& GetCursorOrThrow() {
+ if(!m_pUnoCursor)
throw uno::RuntimeException("SwXTextCursor: disposed or invalid", 0);
- }
- return *pUnoCursor;
+ return *m_pUnoCursor.get();
}
void Invalidate() {
- m_bIsDisposed = true;
+ if(m_pUnoCursor)
+ {
+ if(GetRegisteredIn() == m_pUnoCursor.get())
+ m_pUnoCursor->Remove(this);
+ m_pUnoCursor.reset();
+ }
}
protected:
// SwClient
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
-
+ virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
};
void SwXTextCursor::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
{
ClientModify(this, pOld, pNew);
-
- if (!GetRegisteredIn() ||
- // if the cursor leaves its designated section, it becomes invalid
- ((pOld != NULL) && (pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)))
- {
+ // if the cursor leaves its designated section, it becomes invalid
+ if (((pOld != NULL) && (pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)))
Invalidate();
- }
}
-SwUnoCrsr const* SwXTextCursor::GetCursor() const
+void SwXTextCursor::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- return m_pImpl->GetCursor();
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ assert(m_pUnoCursor->m_bSaneOwnership);
+ Invalidate();
+ }
}
-SwUnoCrsr * SwXTextCursor::GetCursor()
+std::shared_ptr<SwUnoCrsr> SwXTextCursor::GetCursor()
{
return m_pImpl->GetCursor();
}
SwPaM const* SwXTextCursor::GetPaM() const
{
- return m_pImpl->GetCursor();
+ return m_pImpl->GetCursor().get();
}
SwPaM * SwXTextCursor::GetPaM()
{
- return m_pImpl->GetCursor();
+ return m_pImpl->GetCursor().get();
}
SwDoc const* SwXTextCursor::GetDoc() const
@@ -774,7 +775,7 @@ SwXTextCursor::~SwXTextCursor()
void SwXTextCursor::DeleteAndInsert(const OUString& rText,
const bool bForceExpandHints)
{
- SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor();
+ auto pUnoCrsr = m_pImpl->GetCursor();
if(pUnoCrsr)
{
// Start/EndAction
@@ -782,7 +783,7 @@ void SwXTextCursor::DeleteAndInsert(const OUString& rText,
UnoActionContext aAction(pDoc);
const sal_Int32 nTxtLen = rText.getLength();
pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
- SwCursor * pCurrent = pUnoCrsr;
+ SwCursor * pCurrent = pUnoCrsr.get();
do
{
if (pCurrent->HasMark())
@@ -802,7 +803,7 @@ void SwXTextCursor::DeleteAndInsert(const OUString& rText,
CRSR_SKIP_CHARS, false, false);
}
pCurrent = static_cast<SwCursor *>(pCurrent->GetNext());
- } while (pCurrent != pUnoCrsr);
+ } while (pCurrent != pUnoCrsr.get());
pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
}
}
@@ -857,7 +858,7 @@ bool SwXTextCursor::IsAtEndOfMeta() const
{
if (CURSOR_META == m_pImpl->m_eType)
{
- SwUnoCrsr const * const pCursor( m_pImpl->GetCursor() );
+ auto pCursor( m_pImpl->GetCursor() );
SwXMeta const*const pXMeta(
dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get()) );
OSL_ENSURE(pXMeta, "no meta?");
@@ -971,7 +972,7 @@ sal_Bool SAL_CALL SwXTextCursor::isCollapsed() throw (uno::RuntimeException, std
SolarMutexGuard aGuard;
bool bRet = true;
- SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor();
+ auto pUnoCrsr(m_pImpl->GetCursor());
if(pUnoCrsr && pUnoCrsr->GetMark())
{
bRet = (*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark());
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index dc58947..d9bf944 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -110,7 +110,7 @@ uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor(void)
SwPosition aPos(aNodeIndex);
SwXTextCursor *const pXCursor =
new SwXTextCursor(*GetDoc(), this, CURSOR_REDLINE, aPos);
- SwUnoCrsr *const pUnoCursor = pXCursor->GetCursor();
+ auto pUnoCursor(pXCursor->GetCursor());
pUnoCursor->Move(fnMoveForward, fnGoNode);
// #101929# prevent a newly created text cursor from running inside a table
@@ -567,7 +567,7 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u
SwPosition aPos(*pNodeIndex);
SwXTextCursor *const pXCursor =
new SwXTextCursor(*pDoc, this, CURSOR_REDLINE, aPos);
- SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
+ auto pUnoCrsr(pXCursor->GetCursor());
pUnoCrsr->Move(fnMoveForward, fnGoNode);
// is here a table?
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 15a09fa..59d82af 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -970,7 +970,7 @@ uno::Reference<text::XTextCursor> SwXCell::createTextCursor(void) throw( uno::Ru
SwPosition aPos(*pSttNd);
SwXTextCursor* const pXCursor =
new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, aPos);
- SwUnoCrsr* const pUnoCrsr = pXCursor->GetCursor();
+ auto pUnoCrsr(pXCursor->GetCursor());
pUnoCrsr->Move(fnMoveForward, fnGoNode);
return static_cast<text::XWordCursor*>(pXCursor);
}
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index f1dfcfc..035c413 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1383,7 +1383,7 @@ SwXText::insertTextPortion(
OUString sMessage;
m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
- SwUnoCrsr *const pCursor = pTextCursor->GetCursor();
+ auto pCursor(pTextCursor->GetCursor());
m_pImpl->m_pDoc->DontExpandFmt( *pCursor->Start() );
if (!rText.isEmpty())
@@ -2733,7 +2733,7 @@ SwXHeadFootText::createTextCursor() throw (uno::RuntimeException, std::exception
SwPosition aPos(rNode);
SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this,
(m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos);
- SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
+ auto pUnoCrsr(pXCursor->GetCursor());
pUnoCrsr->Move(fnMoveForward, fnGoNode);
// save current start node to be able to check if there is content
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 0dca9b0..e553eb3 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -703,7 +703,7 @@ Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(
return xRet;
}
-SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
+std::shared_ptr<SwUnoCrsr> SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
{
getText();
XText *const pText = xBodyText.get();
@@ -711,7 +711,7 @@ SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xC
SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
xCrsr.set( static_cast<text::XWordCursor*>(pXTextCursor) );
- SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor();
+ auto pUnoCrsr(pXTextCursor->GetCursor());
pUnoCrsr->SetRemainInSection(false);
return pUnoCrsr;
}
@@ -725,7 +725,7 @@ sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor >
throw RuntimeException();
Reference< XTextCursor > xCrsr;
- SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
+ auto pUnoCrsr(CreateCursorForSearch(xCrsr));
const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
@@ -800,7 +800,7 @@ Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(vo
// Used for findAll/First/Next
-SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
+std::shared_ptr<SwUnoCrsr> SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
Reference< XTextCursor > & xCrsr,
bool bAll,
sal_Int32& nResult,
@@ -810,7 +810,7 @@ SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
return 0;
- SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
+ std::shared_ptr<SwUnoCrsr> pUnoCrsr(CreateCursorForSearch(xCrsr));
const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
@@ -930,7 +930,7 @@ Reference< XIndexAccess >
Reference< XInterface > xTmp;
sal_Int32 nResult = 0;
Reference< XTextCursor > xCrsr;
- boost::scoped_ptr<SwUnoCrsr> pResultCrsr(FindAny(xDesc, xCrsr, true, nResult, xTmp));
+ auto pResultCrsr(FindAny(xDesc, xCrsr, true, nResult, xTmp));
if(!pResultCrsr)
throw RuntimeException();
Reference< XIndexAccess > xRet;
@@ -945,7 +945,7 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear
Reference< XInterface > xTmp;
sal_Int32 nResult = 0;
Reference< XTextCursor > xCrsr;
- SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, false, nResult, xTmp);
+ auto pResultCrsr(FindAny(xDesc, xCrsr, false, nResult, xTmp));
if(!pResultCrsr)
throw RuntimeException();
Reference< XInterface > xRet;
@@ -955,7 +955,6 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear
::sw::CreateParentXText(*pDocShell->GetDoc(),
*pResultCrsr->GetPoint());
xRet = *new SwXTextCursor(xParent, *pResultCrsr);
- delete pResultCrsr;
}
return xRet;
}
@@ -970,7 +969,7 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface >
Reference< XTextCursor > xCrsr;
if(!xStartAt.is())
throw RuntimeException();
- SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, false, nResult, xStartAt);
+ auto pResultCrsr(FindAny(xDesc, xCrsr, false, nResult, xStartAt));
if(!pResultCrsr)
throw RuntimeException();
Reference< XInterface > xRet;
@@ -981,7 +980,6 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface >
*pResultCrsr->GetPoint());
xRet = *new SwXTextCursor(xParent, *pResultCrsr);
- delete pResultCrsr;
}
return xRet;
}
commit ec4923dc3fb3f4ab2e52a3befb13491ec25878e8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri May 22 13:13:44 2015 +0200
new unocrsrs for SwXTextPortionEnumeration
Change-Id: Ie6863f30b26df8be78dcedb5157aa62ce2ec28ef
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 9de87d5..01c814e 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -1409,7 +1409,7 @@ void SwXTextPortionEnumeration::Modify( const SfxPoolItem* pOld, const SfxPoolIt
void SwXTextPortionEnumeration::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
SwClient::SwClientNotify(rModify, rHint);
- if(m_pUnoCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
+ if(!GetRegisteredIn() || typeid(rHint) == typeid(sw::DocDisposingHint))
{
assert(m_pUnoCrsr->m_bSaneOwnership);
m_pUnoCrsr->Remove(this);
commit 3779c62197b8fe056025862edac793d59669e0f9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu May 21 15:31:32 2015 +0200
new unocrsrs for SwXTextPortionEnumeration
Change-Id: I5c509d3e65a92824090930d10849b9b1b430971f
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index 9a82ca0..4b3faf1 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -251,6 +251,7 @@ class SwXTextPortionEnumeration
, public SwClient
{
TextRangeList_t m_Portions; // contains all portions, filled by ctor
+ std::shared_ptr<SwUnoCrsr> m_pUnoCrsr;
SwUnoCrsr* GetCursor() const
{return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
@@ -293,6 +294,7 @@ public:
protected:
//SwClient
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
};
class SwXRedlinePortion : public SwXTextPortion
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 80c1abd..9de87d5 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -363,18 +363,17 @@ SwXTextPortionEnumeration::SwXTextPortionEnumeration(
const sal_Int32 nEnd )
: m_Portions()
{
- SwUnoCrsr* pUnoCrsr =
- rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), false);
- pUnoCrsr->Add(this);
+ m_pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr2(*rParaCrsr.GetPoint(), false);
+ m_pUnoCrsr->Add(this);
OSL_ENSURE(nEnd == -1 || (nStart <= nEnd &&
- nEnd <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().getLength()),
+ nEnd <= m_pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().getLength()),
"start or end value invalid!");
// find all frames, graphics and OLEs that are bound AT character in para
FrameDependSortList_t frames;
- ::CollectFrameAtNode(*this, pUnoCrsr->GetPoint()->nNode, frames, true);
- lcl_CreatePortions(m_Portions, xParentText, pUnoCrsr, frames, nStart, nEnd);
+ ::CollectFrameAtNode(*this, m_pUnoCrsr->GetPoint()->nNode, frames, true);
+ lcl_CreatePortions(m_Portions, xParentText, m_pUnoCrsr.get(), frames, nStart, nEnd);
}
SwXTextPortionEnumeration::SwXTextPortionEnumeration(
@@ -382,17 +381,14 @@ SwXTextPortionEnumeration::SwXTextPortionEnumeration(
TextRangeList_t const & rPortions )
: m_Portions( rPortions )
{
- SwUnoCrsr* const pUnoCrsr =
- rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), false);
- pUnoCrsr->Add(this);
+ m_pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr2(*rParaCrsr.GetPoint(), false);
+ m_pUnoCrsr->Add(this);
}
SwXTextPortionEnumeration::~SwXTextPortionEnumeration()
{
- SolarMutexGuard aGuard;
-
- SwUnoCrsr* pUnoCrsr = GetCursor();
- delete pUnoCrsr;
+ if(m_pUnoCrsr)
+ m_pUnoCrsr->Remove(this);
}
sal_Bool SwXTextPortionEnumeration::hasMoreElements()
@@ -1405,9 +1401,20 @@ static void lcl_CreatePortions(
"CreatePortions: stack error" );
}
-void SwXTextPortionEnumeration::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
+void SwXTextPortionEnumeration::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
{
ClientModify(this, pOld, pNew);
}
+void SwXTextPortionEnumeration::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pUnoCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ assert(m_pUnoCrsr->m_bSaneOwnership);
+ m_pUnoCrsr->Remove(this);
+ m_pUnoCrsr.reset();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b203b82077ba804f298f9caaed1345fb8f93bbe2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu May 21 13:19:02 2015 +0200
use new unocrsrs in SwGrfShell
- propably this should listen for ~SwDoc killing the cursor
- but it didnt before, so leaving that out for now
Change-Id: I1addaba3c7cc339b1e1dae1569418deae142a7d6
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index effa9f4..f84a6f3 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -85,13 +85,13 @@ class SwGrfShell::SwExternalToolEdit
{
private:
SwWrtShell *const m_pShell;
- ::std::unique_ptr<SwUnoCrsr> const m_pCursor;
+ ::std::shared_ptr<SwUnoCrsr> const m_pCursor;
public:
SwExternalToolEdit(SwWrtShell *const pShell)
: m_pShell(pShell)
, m_pCursor( // need only Point, must point to SwGrfNode
- pShell->GetDoc()->CreateUnoCrsr(
+ pShell->GetDoc()->CreateUnoCrsr2(
*pShell->GetCurrentShellCursor().GetPoint()))
{
}
More information about the Libreoffice-commits
mailing list