summaryrefslogtreecommitdiff
path: root/sw/source/filter/writer
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-08-09 18:43:36 +0200
committerCaolán McNamara <caolanm@redhat.com>2019-08-10 12:38:08 +0200
commit3c367de9893b1e2d352585a42cbbd25052bb7376 (patch)
tree02045c4f68150560374b5e90a37d11fc0cf4de9b /sw/source/filter/writer
parentba61c3174bc24bc03e3f72fbc8d102b3312b5ff6 (diff)
sw: fix ~SwIndexReg asserts on ODF export of ooo83072-1.odt
It is now possible that the stupid redline-moving code deletes the first node in the document, and there are 2 SwPaM that point to it, Writer::m_pCurrentPam and local pPam in SwWriter::Write(). So i thought it should be quite trivial to just use SwUnoCursors in these cases, but it required a bit more keyboard bashing than expected. (regression from beec1594587d0bf1ea2268f9a435c948b5580278, which i didn't really intend to push and am not sure if it's really a good idea but whatever...) Change-Id: Ia5c18d67af8760664517a4b7ee62ef3e4a417686 Reviewed-on: https://gerrit.libreoffice.org/77225 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter/writer')
-rw-r--r--sw/source/filter/writer/writer.cxx24
1 files changed, 15 insertions, 9 deletions
diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx
index b67f6b928056..49095288a18a 100644
--- a/sw/source/filter/writer/writer.cxx
+++ b/sw/source/filter/writer/writer.cxx
@@ -119,7 +119,7 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk)
Writer::Writer()
: m_pImpl(std::make_unique<Writer_Impl>())
- , m_pOrigFileName(nullptr), m_pDoc(nullptr), m_pOrigPam(nullptr), m_pCurrentPam(nullptr)
+ , m_pOrigFileName(nullptr), m_pDoc(nullptr), m_pOrigPam(nullptr)
, m_bHideDeleteRedlines(false)
{
m_bWriteAll = m_bShowProgress = m_bUCS2_WithStartChar = true;
@@ -148,9 +148,9 @@ void Writer::ResetWriter()
if( m_pCurrentPam )
{
- while( m_pCurrentPam->GetNext() != m_pCurrentPam )
+ while (m_pCurrentPam->GetNext() != m_pCurrentPam.get())
delete m_pCurrentPam->GetNext();
- delete m_pCurrentPam;
+ m_pCurrentPam.reset();
}
m_pCurrentPam = nullptr;
m_pOrigFileName = nullptr;
@@ -190,8 +190,8 @@ sal_Int32 Writer::FindPos_Bkmk(const SwPosition& rPos) const
return -1;
}
-SwPaM *
-Writer::NewSwPaM(SwDoc & rDoc, sal_uLong const nStartIdx, sal_uLong const nEndIdx)
+std::shared_ptr<SwUnoCursor>
+Writer::NewUnoCursor(SwDoc & rDoc, sal_uLong const nStartIdx, sal_uLong const nEndIdx)
{
SwNodes *const pNds = &rDoc.GetNodes();
@@ -202,7 +202,7 @@ Writer::NewSwPaM(SwDoc & rDoc, sal_uLong const nStartIdx, sal_uLong const nEndId
OSL_FAIL( "No more ContentNode at StartPos" );
}
- SwPaM* pNew = new SwPaM( aStt );
+ auto const pNew = rDoc.CreateUnoCursor(SwPosition(aStt), false);
pNew->SetMark();
aStt = nEndIdx;
pCNode = aStt.GetNode().GetContentNode();
@@ -264,7 +264,9 @@ ErrCode Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName )
m_pImpl->m_pStream = &rStrm;
// Copy PaM, so that it can be modified
- m_pCurrentPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ m_pCurrentPam = m_pDoc->CreateUnoCursor(*rPaM.End(), false);
+ m_pCurrentPam->SetMark();
+ *m_pCurrentPam->GetPoint() = *rPaM.Start();
// for comparison secure to the current Pam
m_pOrigPam = &rPaM;
@@ -499,7 +501,9 @@ ErrCode StgWriter::Write( SwPaM& rPaM, SotStorage& rStg, const OUString* pFName
m_pOrigFileName = pFName;
// Copy PaM, so that it can be modified
- m_pCurrentPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ m_pCurrentPam = m_pDoc->CreateUnoCursor(*rPaM.End(), false);
+ m_pCurrentPam->SetMark();
+ *m_pCurrentPam->GetPoint() = *rPaM.Start();
// for comparison secure to the current Pam
m_pOrigPam = &rPaM;
@@ -520,7 +524,9 @@ ErrCode StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >&
m_pOrigFileName = pFName;
// Copy PaM, so that it can be modified
- m_pCurrentPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ m_pCurrentPam = m_pDoc->CreateUnoCursor(*rPaM.End(), false);
+ m_pCurrentPam->SetMark();
+ *m_pCurrentPam->GetPoint() = *rPaM.Start();
// for comparison secure to the current Pam
m_pOrigPam = &rPaM;