[Libreoffice-commits] core.git: 29 commits - sw/inc sw/qa sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Mon May 25 15:52:35 PDT 2015
sw/inc/doc.hxx | 7
sw/inc/docary.hxx | 6
sw/inc/unochart.hxx | 7
sw/inc/unocrsr.hxx | 13 +
sw/inc/unoparagraph.hxx | 2
sw/inc/unotbl.hxx | 14 -
sw/inc/unotextcursor.hxx | 4
sw/inc/unotxdoc.hxx | 4
sw/qa/core/macros-test.cxx | 2
sw/source/core/access/accpara.cxx | 5
sw/source/core/attr/calbck.cxx | 1
sw/source/core/attr/format.cxx | 1
sw/source/core/doc/CntntIdxStore.cxx | 13 -
sw/source/core/doc/DocumentContentOperationsManager.cxx | 2
sw/source/core/doc/doc.cxx | 12 -
sw/source/core/doc/doccorr.cxx | 32 +--
sw/source/core/doc/docnew.cxx | 11 +
sw/source/core/inc/unoport.hxx | 5
sw/source/core/unocore/unochart.cxx | 89 ++++-----
sw/source/core/unocore/unocrsr.cxx | 43 +---
sw/source/core/unocore/unoframe.cxx | 16 -
sw/source/core/unocore/unoftn.cxx | 9 -
sw/source/core/unocore/unoobj.cxx | 81 ++++-----
sw/source/core/unocore/unoobj2.cxx | 81 ++++++---
sw/source/core/unocore/unoparagraph.cxx | 3
sw/source/core/unocore/unoport.cxx | 26 +-
sw/source/core/unocore/unoportenum.cxx | 34 ++-
sw/source/core/unocore/unoredline.cxx | 24 +-
sw/source/core/unocore/unotbl.cxx | 144 +++++++---------
sw/source/core/unocore/unotext.cxx | 18 --
sw/source/filter/ww8/ww8par.cxx | 6
sw/source/filter/ww8/ww8par.hxx | 1
sw/source/uibase/inc/navmgr.hxx | 9 -
sw/source/uibase/shells/grfsh.cxx | 2
sw/source/uibase/uno/unotxdoc.cxx | 18 --
sw/source/uibase/wrtsh/navmgr.cxx | 37 ++--
36 files changed, 397 insertions(+), 385 deletions(-)
New commits:
commit 692c886f937c525d6bfcb541917a5114b085efa9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat May 23 13:25:12 2015 +0200
remove the weak_ptrs on destruction too
Change-Id: I65f5867c41417539a70eef15754988d9931394a4
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index 3d3c1d1..88c627e 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 DBG_UTIL
+ 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 1ef03cad1ac3d593b4ac361ef582b3fd4fc96677
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 51ee53a..656ebb5 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1490,7 +1490,7 @@ public:
void SetOLEObjModified();
// Uno - Interfaces
- std::shared_ptr<SwUnoCrsr> CreateUnoCrsr2( const SwPosition& rPos, bool bTableCrsr = false );
+ std::shared_ptr<SwUnoCrsr> CreateUnoCrsr( const SwPosition& rPos, bool bTableCrsr = false );
// FeShell - Interfaces
// !!! These assume always an existing layout !!!
@@ -1664,7 +1664,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 fde13f4..4887199 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -440,7 +440,7 @@ void SwMacrosTest::testFindReplace()
SwDoc *const pDoc = pTextDoc->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 8296c0f..efda517 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -640,7 +640,7 @@ SwXTextPortion* SwAccessibleParagraph::CreateUnoPortion(
SwTextNode* pTextNode = const_cast<SwTextNode*>( GetTextNode() );
SwIndex aIndex( pTextNode, nStart );
SwPosition aStartPos( *pTextNode, aIndex );
- auto pUnoCursor(pTextNode->GetDoc()->CreateUnoCrsr2( aStartPos ));
+ auto pUnoCursor(pTextNode->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 70ec055..ef7bab4 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -379,7 +379,7 @@ void ContentIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAu
void ContentIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nContent)
{
- 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 9b78238..bdf56b5 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4091,7 +4091,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));
SwTableNumFormatMerge aTNFM( m_rDoc, *pDoc );
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 89ae7bc..a25a641 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1679,7 +1679,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 )
@@ -1687,7 +1687,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 49a98f2..323e475 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 f546d87..ec44cb5 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -424,7 +424,7 @@ SwDoc::~SwDoc()
getIDocumentRedlineAccess().GetExtraRedlineTable().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 399db4b..969fdbc 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -412,7 +412,7 @@ static void GetFormatAndCreateCursorFromRangeRep(
SwPosition aPos(*pSttNd);
// set cursor to top left box of range
- auto pUnoCrsr = pTableFormat->GetDoc()->CreateUnoCrsr2(aPos, true);
+ auto pUnoCrsr = pTableFormat->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 0a534c6..3d3c1d1 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 9ab7f70..4ad4ef8 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -3289,7 +3289,7 @@ uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration() thr
if(!pFormat)
return nullptr;
SwPosition aPos(pFormat->GetContent().GetContentIdx()->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 e83b81c..12b4c4f 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)
SwTextFootnote const*const pTextFootnote = rFormat.GetTextFootnote();
SwPosition aPos( *pTextFootnote->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 f35d0d2..726e3c9 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)
@@ -2050,7 +2050,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);
@@ -3017,7 +3017,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 e558ae8..aa4ecaa 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 7c038e6..a745110 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1181,7 +1181,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 0a0f138..3ffb5cd 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 02fe76f..8b578ff 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 95fc457..2183994 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()
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() throw
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 845afcf..c698cd2 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1112,7 +1112,7 @@ uno::Reference<container::XEnumeration> SwXCell::createEnumeration() throw( uno:
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)
@@ -1417,7 +1417,7 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox* pBox)
SwDoc* pDoc = pFormat->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& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr.get());
@@ -1429,7 +1429,7 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat& rTableFormat, const SwTabl
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();
@@ -2202,7 +2202,7 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* p
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
- auto pUnoCrsr(pFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFormat->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection(false);
const SwTableBox* pBRBox(pTable->GetTableBox(rBRName));
@@ -2579,7 +2579,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 );
@@ -2768,7 +2768,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 );
@@ -3219,7 +3219,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(pFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFormat->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
const SwTableBox* pBRBox = pTable->GetTableBox( sBRName );
@@ -3994,7 +3994,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(pFrameFormat->GetDoc());
- auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
{
// remove actions
@@ -4024,7 +4024,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(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection( false );
const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
@@ -4132,7 +4132,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
UnoActionContext aAction(pFrameFormat->GetDoc());
- auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
{
@@ -4165,7 +4165,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(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
+ auto pUnoCrsr(pFrameFormat->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 e039b52..5f08022 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -2564,7 +2564,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);
}
@@ -2826,7 +2826,7 @@ throw (uno::RuntimeException, std::exception)
const SwFormatContent& rFlyContent = rHeadFootFormat.GetContent();
const SwNode& rNode = rFlyContent.GetContentIdx()->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 8df50e7..b4121b0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4900,7 +4900,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
pDocShell->SetReadOnlyUI(true);
}
- mpCrsr = m_rDoc.CreateUnoCrsr2(rPos);
+ mpCrsr = m_rDoc.CreateUnoCrsr(rPos);
m_pPaM = mpCrsr.get();
m_pCtrlStck = new SwWW8FltControlStack( &m_rDoc, m_nFieldFlags, *this );
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index 93fafb9..5504911 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 0509dbec0e3c9e9c64f5b487f5197ca4602838cc
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 e091cc0..bfc8ebc 100644
--- a/sw/inc/unocrsr.hxx
+++ b/sw/inc/unocrsr.hxx
@@ -40,7 +40,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 995aad9..89ae7bc 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1687,7 +1687,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 df918f4..0a534c6 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 b6cb124..f35d0d2 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 c4b9b1f..e558ae8 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 502a9dd..0a0f138 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 b33b1fe..02fe76f 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 c317ee0..845afcf 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1744,7 +1744,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();
}
@@ -3150,7 +3149,6 @@ SwXCellRange::SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrameFormat& rFra
, m_bFirstRowAsLabel(false)
, m_bFirstColumnAsLabel(false)
{
- assert(m_pTableCrsr->m_bSaneOwnership);
m_pTableCrsr->Add(&aCursorDepend);
aRgDesc.Normalize();
}
commit b23eb203cc696926c748cc81584dff38050224cd
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 0346079..51ee53a 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -145,7 +145,6 @@ class SwTextFormatColl;
class SwTextFormatColls;
class SwURLStateChanged;
class SwUnoCrsr;
-class SwUnoCrsrTable;
class SwViewShell;
class _SetGetExpField;
class SwDrawContact;
@@ -333,8 +332,6 @@ class SW_DLLPUBLIC SwDoc :
// Hash map to find numrules by name
mutable std::unordered_map<OUString, SwNumRule *, OUStringHash> maNumRuleMap;
- SwUnoCrsrTable *mpUnoCrsrTable;
-
SwPagePreviewPrtData *mpPgPViewPrtData; //< Indenting / spacing for printing of page view.
SwPaM *mpExtInputRing;
@@ -1493,8 +1490,6 @@ public:
void SetOLEObjModified();
// Uno - Interfaces
- const SwUnoCrsrTable& GetUnoCrsrTable() const { return *mpUnoCrsrTable; }
- SwUnoCrsr* CreateUnoCrsr( const SwPosition& rPos, bool bTableCrsr = false );
std::shared_ptr<SwUnoCrsr> CreateUnoCrsr2( const SwPosition& rPos, bool bTableCrsr = false );
// FeShell - Interfaces
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 2d2871f..5544dab 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 SwUnoCrsrTable : public std::set<SwUnoCrsr*> {
-public:
- /// the destructor will free all objects still in the set
- ~SwUnoCrsrTable();
-};
-
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 b9dc0e5..70ec055 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -379,21 +379,6 @@ void ContentIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAu
void ContentIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nContent)
{
- for (const SwUnoCrsr* pUnoCrsr : pDoc->GetUnoCrsrTable())
- {
- for(SwPaM& rPaM : (const_cast<SwUnoCrsr*>(pUnoCrsr))->GetRingContainer())
- {
- lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nContent, rPaM);
- }
- const SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
- if( pUnoTableCrsr )
- {
- for(SwPaM& rPaM : (&(const_cast<SwUnoTableCrsr*>(pUnoTableCrsr))->GetSelRing())->GetRingContainer())
- {
- lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nContent, 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 454ea0a..995aad9 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1679,17 +1679,6 @@ bool SwDoc::ContainsHiddenChars() const
return false;
}
-SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, bool bTableCrsr )
-{
- SwUnoCrsr* pNew;
- if( bTableCrsr )
- pNew = new SwUnoTableCrsr( rPos );
- else
- pNew = new SwUnoCrsr( rPos );
-
- mpUnoCrsrTable->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 7f75cd4..49a98f2 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -121,47 +121,6 @@ void PaMCorrAbs( const SwPaM& rRange,
}
}
{
- SwUnoCrsrTable& rTable = const_cast<SwUnoCrsrTable&>(pDoc->GetUnoCrsrTable());
-
- for( SwUnoCrsrTable::iterator it = rTable.begin(); it != rTable.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 pUnoTableCrsr =
- dynamic_cast<SwUnoTableCrsr *>(*it);
- if( pUnoTableCrsr )
- {
- for(SwPaM& rPaM : (&pUnoTableCrsr->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,
}
}
{
- SwUnoCrsrTable& rTable = (SwUnoCrsrTable&)pDoc->GetUnoCrsrTable();
- for( SwUnoCrsrTable::iterator it = rTable.begin(); it != rTable.end(); ++it )
- {
- for(SwPaM& rPaM : (*it)->GetRingContainer())
- {
- lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
- }
-
- SwUnoTableCrsr* pUnoTableCrsr =
- dynamic_cast<SwUnoTableCrsr*>(*it);
- if( pUnoTableCrsr )
- {
- for(SwPaM& rPaM : (&pUnoTableCrsr->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 379f844..f546d87 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -250,7 +250,6 @@ SwDoc::SwDoc()
mpURLStateChgd( 0 ),
mpNumberFormatter( 0 ),
mpNumRuleTable( new SwNumRuleTable ),
- mpUnoCrsrTable( new SwUnoCrsrTable() ),
mpPgPViewPrtData( 0 ),
mpExtInputRing( 0 ),
mpStyleAccess( 0 ),
@@ -424,7 +423,6 @@ SwDoc::~SwDoc()
getIDocumentRedlineAccess().GetRedlineTable().DeleteAndDestroyAll();
getIDocumentRedlineAccess().GetExtraRedlineTable().DeleteAndDestroyAll();
- delete mpUnoCrsrTable;
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 bfdb692..df918f4 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
- SwUnoCrsrTable& rTable = (SwUnoCrsrTable&)pDoc->GetUnoCrsrTable();
- if( !rTable.erase( this ) )
- {
- OSL_ENSURE( false, "UNO Cursor nicht mehr im Array" );
- }
- }
}
// delete the whole ring
@@ -238,13 +229,4 @@ void SwUnoTableCrsr::MakeBoxSels()
}
}
-SwUnoCrsrTable::~SwUnoCrsrTable()
-{
- while (!empty())
- {
- delete *begin();
- erase( begin() );
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6ab4c4f9c7b12c6058b08e44d35eb8b386348c55
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 a6b238e..c4b9b1f 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 9a949b9c404def205dc39f2f6068a67993c051ad
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 ce3c3e4..a6b238e 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 2d80fe10a8d59eca45bd8d1ec551fc58398779f9
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 3064ca6..ce3c3e4 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 9ebb551c85909952f8837c174c0e10400170df49
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 46a275a..4e66097 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;
SwFrameFormat * m_pFrameFormat;
@@ -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 54db643..502a9dd 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 50356872b9421303b9c7b4a3135b3cdcc3a0af50
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 90e7f02..c3a2f67 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -432,8 +432,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 c291523..e83b81c 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( *pTextFootnote->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 ce0254b..b6cb124 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 nTextLen = 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 a4254de..95fc457 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()
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() throw( uno::
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 7db370f..c317ee0 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -968,7 +968,7 @@ uno::Reference<text::XTextCursor> SwXCell::createTextCursor() throw( uno::Runtim
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 5b4d7b3..e039b52 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1382,7 +1382,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->DontExpandFormat( *pCursor->Start() );
if (!rText.isEmpty())
@@ -2745,7 +2745,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 8a61199..21e932e 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -711,7 +711,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();
@@ -719,7 +719,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;
}
@@ -733,7 +733,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()));
@@ -808,7 +808,7 @@ Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor()
// 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,
@@ -818,7 +818,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()));
@@ -938,7 +938,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;
@@ -953,7 +953,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;
@@ -963,7 +963,6 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear
::sw::CreateParentXText(*pDocShell->GetDoc(),
*pResultCrsr->GetPoint());
xRet = *new SwXTextCursor(xParent, *pResultCrsr);
- delete pResultCrsr;
}
return xRet;
}
@@ -978,7 +977,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;
@@ -989,7 +988,6 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface >
*pResultCrsr->GetPoint());
xRet = *new SwXTextCursor(xParent, *pResultCrsr);
- delete pResultCrsr;
}
return xRet;
}
commit 96898cd49830333d752b9aa56fe91a8e21c9dca8
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 4c35e00..46a275a 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 932ca27..b33b1fe 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().GetTextNode()->GetText().getLength()),
+ nEnd <= m_pUnoCrsr->Start()->nNode.GetNode().GetTextNode()->GetText().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(!GetRegisteredIn() || 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 99614f6a9a738989cca82c8bbd4532fc2d35c1cc
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 39e18fd..93fafb9 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()))
{
}
commit c844a15c7d39ee1c60d2fbf969d502f94a0cdfff
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Wed May 20 19:39:15 2015 +0200
use new unocrsrs in SwXTextTableCursor
Change-Id: I7389794f1ca493a1f7e04c7b24d650223443bf7e
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index ec15c45..405d1d4 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -213,8 +213,6 @@ class SW_DLLPUBLIC SwXTextTableCursor : public SwXTextTableCursor_Base
SwDepend aCrsrDepend;
const SfxItemPropertySet* m_pPropSet;
-protected:
- virtual ~SwXTextTableCursor();
public:
SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox* pBox);
SwXTextTableCursor(SwFrameFormat& rTableFormat,
@@ -265,7 +263,8 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
//SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
// ITextCursorHelper
virtual const SwPaM* GetPaM() const SAL_OVERRIDE;
@@ -275,6 +274,7 @@ public:
const SwUnoCrsr* GetCrsr() const;
SwUnoCrsr* GetCrsr();
+ std::shared_ptr<SwUnoCrsr> m_pUnoCrsr;
SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
};
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 59589a3..7db370f 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1417,10 +1417,10 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox* pBox)
SwDoc* pDoc = pFormat->GetDoc();
const SwStartNode* pSttNd = pBox->GetSttNd();
SwPosition aPos(*pSttNd);
- SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
- pUnoCrsr->Move( fnMoveForward, fnGoNode );
- pUnoCrsr->Add(&aCrsrDepend);
- SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
+ m_pUnoCrsr = pDoc->CreateUnoCrsr2(aPos, true);
+ m_pUnoCrsr->Move( fnMoveForward, fnGoNode );
+ m_pUnoCrsr->Add(&aCrsrDepend);
+ SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr.get());
rTableCrsr.MakeBoxSels();
}
@@ -1429,26 +1429,18 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat& rTableFormat, const SwTabl
aCrsrDepend(this, 0),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
{
- SwUnoCrsr* pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr(*pTableSelection->GetPoint(), true);
+ m_pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr2(*pTableSelection->GetPoint(), true);
if(pTableSelection->HasMark())
{
- pUnoCrsr->SetMark();
- *pUnoCrsr->GetMark() = *pTableSelection->GetMark();
+ m_pUnoCrsr->SetMark();
+ *m_pUnoCrsr->GetMark() = *pTableSelection->GetMark();
}
const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
- SwTableCursor& rTableCrsr = dynamic_cast<SwTableCursor&>(*pUnoCrsr);
+ SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr);
for(auto pBox : rBoxes)
rTableCrsr.InsertBox(*pBox);
- pUnoCrsr->Add(&aCrsrDepend);
- SwUnoTableCrsr& rUnoTableCursor = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr);
- rUnoTableCursor.MakeBoxSels();
-}
-
-SwXTextTableCursor::~SwXTextTableCursor()
-{
- SolarMutexGuard aGuard;
- SwUnoCrsr* pUnoCrsr = GetCrsr();
- delete pUnoCrsr;
+ m_pUnoCrsr->Add(&aCrsrDepend);
+ rTableCrsr.MakeBoxSels();
}
OUString SwXTextTableCursor::getRangeName()
@@ -1747,6 +1739,17 @@ void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropert
void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
{ ClientModify(this, pOld, pNew); }
+void SwXTextTableCursor::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(&aCrsrDepend);
+ m_pUnoCrsr.reset();
+ }
+}
+
class SwXTextTable::Impl
{
private:
commit 5f5e1568710f8a24af9f54be8bf05e30f6f4f66a
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Wed May 20 18:43:53 2015 +0200
use new unocrsrs in other writer tables
Change-Id: I0cc178da5ca2493cc50bf6582493790d6b4ba536
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index bebc119..59589a3 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2577,7 +2577,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to top left cell
- SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pDoc->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
@@ -2621,7 +2621,6 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
aSet.Put(aBoxInfo);
pDoc->SetTabBorders(rCrsr, aSet);
- delete pUnoCrsr;
}
break;
@@ -2767,7 +2766,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to top left cell
- SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pDoc->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
@@ -2828,7 +2827,6 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
aRet <<= aTableBorder;
}
- delete pUnoCrsr;
}
break;
commit 4020f9bbd92becd3662cdc3b24ad70b370307e5e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Wed May 20 18:33:26 2015 +0200
use new unocrsrs in other writer tables
Change-Id: I61d8956135d65676b449637beb9d588cdc83b7d8
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 99450ab..bebc119 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3995,14 +3995,13 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
UnoActionContext aAction(pFrameFormat->GetDoc());
- SwUnoCrsr* pUnoCrsr = pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
{
// remove actions
UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
pFrameFormat->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
- delete pUnoCrsr;
}
void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
@@ -4026,7 +4025,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
- SwUnoCrsr* pUnoCrsr = pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection( false );
const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
@@ -4036,12 +4035,12 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
pUnoCrsr->SetMark();
pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
pUnoCrsr->Move(fnMoveForward, fnGoNode);
- SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
pCrsr->MakeBoxSels();
{ // these braces are important
UnoActionContext aAction(pFrameFormat->GetDoc());
pFrameFormat->GetDoc()->DeleteRow(*pUnoCrsr);
- delete pUnoCrsr;
+ pUnoCrsr.reset();
}
{
// invalidate all actions
@@ -4134,7 +4133,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
UnoActionContext aAction(pFrameFormat->GetDoc());
- SwUnoCrsr* pUnoCrsr = pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
{
@@ -4143,7 +4142,6 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
}
pFrameFormat->GetDoc()->InsertCol(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
- delete pUnoCrsr;
}
///@see SwXTableRows::removeByIndex (TODO: seems to be copy and paste programming here)
@@ -4168,7 +4166,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
- SwUnoCrsr* pUnoCrsr = pFrameFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pFrameFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection(false);
const OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
@@ -4178,12 +4176,12 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
pUnoCrsr->SetMark();
pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd();
pUnoCrsr->Move(fnMoveForward, fnGoNode);
- SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
pCrsr->MakeBoxSels();
{ // these braces are important
UnoActionContext aAction(pFrameFormat->GetDoc());
pFrameFormat->GetDoc()->DeleteCol(*pUnoCrsr);
- delete pUnoCrsr;
+ pUnoCrsr.reset();
}
{
// invalidate all actions
commit a90df339dfcf491af30a3e3b3407c1d8a99453c8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Wed May 20 18:17:56 2015 +0200
use new unocrsrs in SwXCellRange
Change-Id: I8ab1c9c0329bdf3f6ac759012dbd0057f4463231
diff --git a/sw/inc/unocrsr.hxx b/sw/inc/unocrsr.hxx
index 66d8a70..e091cc0 100644
--- a/sw/inc/unocrsr.hxx
+++ b/sw/inc/unocrsr.hxx
@@ -95,7 +95,7 @@ public:
nsSwCursorSelOverFlags::SELOVER_TOGGLE |
nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )) SAL_OVERRIDE;
- SwUnoTableCrsr * Clone() const;
+ std::shared_ptr<SwUnoCrsr> Clone() const;
void MakeBoxSels();
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 11b30a3..ec15c45 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -457,7 +457,7 @@ class SwXCellRange : public cppu::WeakImplHelper
SwRangeDescriptor aRgDesc;
const SfxItemPropertySet* m_pPropSet;
- SwUnoCrsr* pTableCrsr;
+ std::shared_ptr<SwUnoCrsr> m_pTableCrsr;
bool m_bFirstRowAsLabel;
bool m_bFirstColumnAsLabel;
@@ -466,11 +466,10 @@ class SwXCellRange : public cppu::WeakImplHelper
void setLabelDescriptions(const css::uno::Sequence<OUString>& rDesc, bool bRow);
public:
- SwXCellRange(SwUnoCrsr* pCrsr, SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc);
+ SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc);
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
{ m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
std::vector< css::uno::Reference< css::table::XCell > > getCells();
- virtual ~SwXCellRange();
TYPEINFO_OVERRIDE();
@@ -536,7 +535,8 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
//SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
sal_uInt16 getRowCount();
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index cfc07b1..bfdb692 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -64,14 +64,11 @@ SwUnoCrsr::~SwUnoCrsr()
}
}
-SwUnoTableCrsr * SwUnoTableCrsr::Clone() const
+std::shared_ptr<SwUnoCrsr> SwUnoTableCrsr::Clone() const
{
- assert(!m_bSaneOwnership);
- SwUnoTableCrsr * pNewCrsr = dynamic_cast<SwUnoTableCrsr*>(
- GetDoc()->CreateUnoCrsr(
- *GetPoint(), true /* create SwUnoTableCrsr */ ) );
- OSL_ENSURE(pNewCrsr, "Clone: cannot create SwUnoTableCrsr?");
- if (pNewCrsr && HasMark())
+ assert(m_bSaneOwnership);
+ auto pNewCrsr(GetDoc()->CreateUnoCrsr2(*GetPoint(), true));
+ if(HasMark())
{
pNewCrsr->SetMark();
*pNewCrsr->GetMark() = *GetMark();
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 27faa44..99450ab 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2200,19 +2200,16 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* p
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range
- SwUnoCrsr* pUnoCrsr = pFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection(false);
const SwTableBox* pBRBox(pTable->GetTableBox(rBRName));
if(!pBRBox)
- {
- delete pUnoCrsr;
return nullptr;
- }
pUnoCrsr->SetMark();
pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
pUnoCrsr->Move( fnMoveForward, fnGoNode );
- SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
pCrsr->MakeBoxSels();
// pUnoCrsr will be provided and will not be deleted
return new SwXCellRange(pUnoCrsr, *pFormat, rDesc);
@@ -3141,18 +3138,19 @@ uno::Sequence<OUString> SwXCellRange::getSupportedServiceNames() throw( uno::Run
"com.sun.star.style.ParagraphPropertiesComplex" };
}
-SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrameFormat& rFrameFormat,
+SwXCellRange::SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrameFormat& rFrameFormat,
SwRangeDescriptor& rDesc)
: SwClient(&rFrameFormat)
- , aCursorDepend(this, pCrsr)
+ , aCursorDepend(this, nullptr)
, m_ChartListeners(m_Mutex)
- ,
- aRgDesc(rDesc),
- m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE)),
- pTableCrsr(pCrsr),
- m_bFirstRowAsLabel(false),
- m_bFirstColumnAsLabel(false)
-{
+ , aRgDesc(rDesc)
+ , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
+ , m_pTableCrsr(pCrsr)
+ , m_bFirstRowAsLabel(false)
+ , m_bFirstColumnAsLabel(false)
+{
+ assert(m_pTableCrsr->m_bSaneOwnership);
+ m_pTableCrsr->Add(&aCursorDepend);
aRgDesc.Normalize();
}
@@ -3169,12 +3167,6 @@ std::vector< uno::Reference< table::XCell > > SwXCellRange::getCells()
return vResult;
}
-SwXCellRange::~SwXCellRange()
-{
- SolarMutexGuard aGuard;
- delete pTableCrsr;
-}
-
uno::Reference< table::XCell > SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
throw( uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception )
{
@@ -3228,7 +3220,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
- SwUnoCrsr* pUnoCrsr = pFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+ auto pUnoCrsr(pFormat->GetDoc()->CreateUnoCrsr2(aPos, true));
pUnoCrsr->Move( fnMoveForward, fnGoNode );
pUnoCrsr->SetRemainInSection( false );
const SwTableBox* pBRBox = pTable->GetTableBox( sBRName );
@@ -3237,14 +3229,12 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
pUnoCrsr->SetMark();
pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
pUnoCrsr->Move( fnMoveForward, fnGoNode );
- SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
pCrsr->MakeBoxSels();
// pUnoCrsr will be provided and will not be deleted
SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFormat, aNewDesc);
aRet = pCellRange;
}
- else
- delete pUnoCrsr;
}
}
}
@@ -3296,21 +3286,21 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- SwDoc* pDoc = pTableCrsr->GetDoc();
+ SwDoc* pDoc = m_pTableCrsr->GetDoc();
{
// remove actions to enable box selection
UnoActionRemoveContext aRemoveContext(pDoc);
}
- SwUnoTableCrsr& rCrsr = dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr);
+ SwUnoTableCrsr& rCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pTableCrsr);
rCrsr.MakeBoxSels();
switch(pEntry->nWID )
{
case FN_UNO_TABLE_CELL_BACKGROUND:
{
SvxBrushItem aBrush( RES_BACKGROUND );
- SwDoc::GetBoxAttr( *pTableCrsr, aBrush );
+ pDoc->GetBoxAttr( *m_pTableCrsr, aBrush );
((SfxPoolItem&)aBrush).PutValue(aValue, pEntry->nMemberId);
- pDoc->SetBoxAttr( *pTableCrsr, aBrush );
+ pDoc->SetBoxAttr( *m_pTableCrsr, aBrush );
}
break;
@@ -3345,7 +3335,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
SvxBoxItem aBoxItem(static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX)));
((SfxPoolItem&)aBoxItem).PutValue(aValue, pEntry->nMemberId);
aSet.Put(aBoxItem);
- pDoc->SetTabBorders( *pTableCrsr, aSet );
+ pDoc->SetTabBorders( *m_pTableCrsr, aSet );
}
break;
case RES_BOXATR_FORMAT:
@@ -3416,20 +3406,20 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
case FN_UNO_TABLE_CELL_BACKGROUND:
{
SvxBrushItem aBrush( RES_BACKGROUND );
- if(SwDoc::GetBoxAttr( *pTableCrsr, aBrush ))
+ if(m_pTableCrsr->GetDoc()->GetBoxAttr( *m_pTableCrsr, aBrush ))
aBrush.QueryValue(aRet, pEntry->nMemberId);
}
break;
case RES_BOX :
{
- SwDoc* pDoc = pTableCrsr->GetDoc();
+ SwDoc* pDoc = m_pTableCrsr->GetDoc();
SfxItemSet aSet(pDoc->GetAttrPool(),
RES_BOX, RES_BOX,
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
0);
aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
- SwDoc::GetTabBorders(*pTableCrsr, aSet);
+ pDoc->GetTabBorders(*m_pTableCrsr, aSet);
const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX));
rBoxItem.QueryValue(aRet, pEntry->nMemberId);
}
@@ -3440,7 +3430,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
case FN_UNO_PARA_STYLE:
{
SwFormatColl *const pTmpFormat =
- SwUnoCursorHelper::GetCurTextFormatColl(*pTableCrsr, false);
+ SwUnoCursorHelper::GetCurTextFormatColl(*m_pTableCrsr, false);
OUString sRet;
if(pFormat)
sRet = pTmpFormat->GetName();
@@ -3455,13 +3445,13 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
break;
default:
{
- SfxItemSet aSet(pTableCrsr->GetDoc()->GetAttrPool(),
+ SfxItemSet aSet(m_pTableCrsr->GetDoc()->GetAttrPool(),
RES_CHRATR_BEGIN, RES_FRMATR_END -1,
RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
0L);
// first look at the attributes of the cursor
- SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTableCrsr);
+ SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(m_pTableCrsr.get());
SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), aSet);
m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
}
@@ -3574,7 +3564,7 @@ void SwXCellRange::GetDataSequence(
// from the text in the cell...
sal_uInt32 nFIndex;
- SvNumberFormatter* pNumFormatter = pTableCrsr->GetDoc()->GetNumberFormatter();
+ SvNumberFormatter* pNumFormatter = m_pTableCrsr->GetDoc()->GetNumberFormatter();
// look for SwTableBoxNumFormat value in parents as well
const SfxPoolItem* pItem;
@@ -3860,7 +3850,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD
SwFrameFormat* pFormat(GetFrameFormat());
if(pFormat && SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
{
- SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr);
+ SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pTableCrsr);
rTableCrsr.MakeBoxSels();
UnoActionContext aContext(pFormat->GetDoc());
pFormat->GetDoc()->SortTable(rTableCrsr.GetSelectedBoxes(), aSortOpt);
@@ -3876,7 +3866,7 @@ sal_uInt16 SwXCellRange::getRowCount()
const SwUnoCrsr* SwXCellRange::GetTableCrsr() const
{
SwFrameFormat* pFormat = GetFrameFormat();
- return pFormat ? pTableCrsr : nullptr;
+ return pFormat ? m_pTableCrsr.get() : nullptr;
}
void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
@@ -3890,7 +3880,7 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
* if(!aCursorDepend.GetRegisteredIn())
delete pTableCrsr;
*/
- pTableCrsr = 0;
+ m_pTableCrsr.reset();
lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_ChartListeners.disposeAndClear(ev);
}
@@ -3900,6 +3890,17 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
}
}
+void SwXCellRange::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ //assert(m_pTblCrsr->m_bSaneOwnership);
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pTableCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ m_pTableCrsr->Remove(&aCursorDepend);
+ m_pTableCrsr.reset();
+ }
+}
+
// SwXTableRows
OUString SwXTableRows::getImplementationName() throw( uno::RuntimeException, std::exception )
commit f7a3cc7af22a802322c92a84363676d114bb788e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Wed May 20 17:01:12 2015 +0200
kill faux polymophic SwUnoCrsr::Clone()
- SwUnoCrsr::Clone() is dead code that is never used
- SwUnoTblCrsr::Clone() is the only implemenation that is used, in a
context that assumes it to be a SwUnoTblCrsr anyway
=> make this non-virtual
Change-Id: I28ddf314eda3d234f2a383bf386dfbe251966038
diff --git a/sw/inc/unocrsr.hxx b/sw/inc/unocrsr.hxx
index 767c534..66d8a70 100644
--- a/sw/inc/unocrsr.hxx
+++ b/sw/inc/unocrsr.hxx
@@ -72,9 +72,6 @@ public:
void SetSkipOverHiddenSections( bool bFlag )
{ m_bSkipOverHiddenSections = bFlag; }
- // make copy of cursor
- virtual SwUnoCrsr * Clone() const;
-
DECL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr )
};
@@ -98,7 +95,7 @@ public:
nsSwCursorSelOverFlags::SELOVER_TOGGLE |
nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )) SAL_OVERRIDE;
- virtual SwUnoTableCrsr * Clone() const SAL_OVERRIDE;
+ SwUnoTableCrsr * Clone() const;
void MakeBoxSels();
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 3bfa98e..399db4b 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1947,7 +1947,7 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) :
aColLabelText( SW_RES(STR_CHART2_COL_LABEL_TEXT) ),
xDataProvider( rObj.pDataProvider ),
pDataProvider( rObj.pDataProvider ),
- pTableCrsr( rObj.pTableCrsr->Clone() ),
+ pTableCrsr( dynamic_cast<SwUnoTableCrsr*>(rObj.pTableCrsr.get())->Clone() ),
aCursorDepend( this, pTableCrsr.get() ),
_pPropSet( rObj._pPropSet )
{
@@ -2032,7 +2032,7 @@ uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
// keep original cursor and make copy of it that gets handed
// over to the SwXCellRange object which takes ownership and
// thus will destroy the copy later.
- SwXCellRange aRange( pTableCrsr->Clone(), *pTableFormat, aDesc );
+ SwXCellRange aRange( dynamic_cast<SwUnoTableCrsr*>(pTableCrsr.get())->Clone(), *pTableFormat, aDesc );
aRange.GetDataSequence( &aRes, 0, 0 );
}
}
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index 3ee3444..cfc07b1 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -64,18 +64,6 @@ SwUnoCrsr::~SwUnoCrsr()
}
}
-SwUnoCrsr * SwUnoCrsr::Clone() const
-{
- assert(!m_bSaneOwnership);
- SwUnoCrsr * pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() );
- if (HasMark())
- {
- pNewCrsr->SetMark();
- *pNewCrsr->GetMark() = *GetMark();
- }
- return pNewCrsr;
-}
-
SwUnoTableCrsr * SwUnoTableCrsr::Clone() const
{
assert(!m_bSaneOwnership);
commit 63536161c82c21d5574fc98e0d374517fbb1205b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun May 17 15:45:17 2015 +0200
use new unocrsrs in SwXParagraphEnumeration
Change-Id: Ia57a04e617b1d7301d098524ebb55acd1d0e60b3
diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx
index 5bca49d..0c8d87e 100644
--- a/sw/inc/unoparagraph.hxx
+++ b/sw/inc/unoparagraph.hxx
@@ -319,7 +319,7 @@ public:
SwXParagraphEnumeration(
::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
const & xParent,
- ::std::unique_ptr<SwUnoCrsr> && pCursor,
+ std::shared_ptr<SwUnoCrsr> pCursor,
const CursorType eType,
SwStartNode const*const pStartNode = 0,
SwTable const*const pTable = 0);
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 54a5b6b..9ab7f70 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -3285,17 +3285,13 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const
uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration() throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- uno::Reference< container::XEnumeration > aRef;
SwFrameFormat* pFormat = GetFrameFormat();
- if(pFormat)
- {
- SwPosition aPos(pFormat->GetContent().GetContentIdx()->GetNode());
- ::std::unique_ptr<SwUnoCrsr> pUnoCursor(
- GetDoc()->CreateUnoCrsr(aPos, false));
- pUnoCursor->Move(fnMoveForward, fnGoNode);
- aRef = new SwXParagraphEnumeration(this, std::move(pUnoCursor), CURSOR_FRAME);
- }
- return aRef;
+ if(!pFormat)
+ return nullptr;
+ SwPosition aPos(pFormat->GetContent().GetContentIdx()->GetNode());
+ auto pUnoCursor(GetDoc()->CreateUnoCrsr2(aPos, false));
+ pUnoCursor->Move(fnMoveForward, fnGoNode);
+ return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME);
}
uno::Type SwXTextFrame::getElementType() throw( uno::RuntimeException, std::exception )
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index 535603b..c291523 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -478,12 +478,9 @@ SwXFootnote::createEnumeration() throw (uno::RuntimeException, std::exception)
SwTextFootnote const*const pTextFootnote = rFormat.GetTextFootnote();
SwPosition aPos( *pTextFootnote->GetStartNode() );
- ::std::unique_ptr<SwUnoCrsr> pUnoCursor(
- GetDoc()->CreateUnoCrsr(aPos, false));
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list