diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2019-08-09 18:43:36 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-08-10 12:38:08 +0200 |
commit | 3c367de9893b1e2d352585a42cbbd25052bb7376 (patch) | |
tree | 02045c4f68150560374b5e90a37d11fc0cf4de9b | |
parent | ba61c3174bc24bc03e3f72fbc8d102b3312b5ff6 (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>
-rw-r--r-- | sw/inc/shellio.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ascii/wrtasc.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/basflt/shellio.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/html/htmlflywriter.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/html/htmlftn.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/htmltabw.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/writer/writer.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexportfilter.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexportfilter.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 10 |
17 files changed, 72 insertions, 53 deletions
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index d9fca346a198..347b69a54af3 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -33,6 +33,7 @@ #include <o3tl/typed_flags_set.hxx> #include "swdllapi.h" #include "docfac.hxx" +#include "unocrsr.hxx" class SfxItemPool; class SfxItemSet; @@ -401,7 +402,7 @@ protected: public: SwDoc* m_pDoc; SwPaM* m_pOrigPam; // Last Pam that has to be processed. - SwPaM* m_pCurrentPam; + std::shared_ptr<SwUnoCursor> m_pCurrentPam; bool m_bWriteAll : 1; bool m_bShowProgress : 1; bool m_bWriteClipboardDoc : 1; @@ -448,7 +449,7 @@ public: std::vector< const ::sw::mark::IMark* >& rArr ); // Create new PaM at position. - static SwPaM * NewSwPaM(SwDoc & rDoc, + static std::shared_ptr<SwUnoCursor> NewUnoCursor(SwDoc & rDoc, sal_uLong const nStartIdx, sal_uLong const nEndIdx); // If applicable copy a local file into internet. diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx index c5f6f3fba971..6bae84aa980d 100644 --- a/sw/source/filter/ascii/wrtasc.cxx +++ b/sw/source/filter/ascii/wrtasc.cxx @@ -142,8 +142,7 @@ ErrCode SwASCWriter::WriteStream() const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if( pIdx ) { - delete m_pCurrentPam; - m_pCurrentPam = NewSwPaM( *m_pDoc, pIdx->GetIndex(), + m_pCurrentPam = NewUnoCursor(*m_pDoc, pIdx->GetIndex(), pIdx->GetNode().EndOfSectionIndex() ); m_pCurrentPam->Exchange(); continue; // reset while loop! diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 66c9d1d0ea7d..37426ccd1c40 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -730,6 +730,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa SwPauseThreadStarting aPauseThreadStarting; bool bHasMark = false; + std::shared_ptr<SwUnoCursor> pTempCursor; SwPaM * pPam; rtl::Reference<SwDoc> xDoc; @@ -796,7 +797,9 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa { // no Shell or write-everything -> create a Pam SwDoc* pOutDoc = xDoc.is() ? xDoc.get() : &rDoc; - pPam = new SwPaM( pOutDoc->GetNodes().GetEndOfContent() ); + pTempCursor = pOutDoc->CreateUnoCursor( + SwPosition(pOutDoc->GetNodes().GetEndOfContent()), false); + pPam = pTempCursor.get(); if( pOutDoc->IsClipBoard() ) { pPam->Move( fnMoveBackward, GoInDoc ); @@ -877,7 +880,6 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa } else { - delete pPam; // delete the created Pam // Everything was written successfully? Tell the document! if ( !nError.IsError() && !xDoc.is() ) { diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 6eca6c22fb7c..c50f46acaa8d 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -298,7 +298,8 @@ void SwHTMLWriter::CollectFlyFrames() OSL_ENSURE( HTML_CFG_MAX+1 == MAX_BROWSERS, "number of browser configurations has changed" ); - SwPosFlyFrames aFlyPos(m_pDoc->GetAllFlyFormats(m_bWriteAll ? nullptr : m_pCurrentPam, true)); + SwPosFlyFrames aFlyPos( + m_pDoc->GetAllFlyFormats(m_bWriteAll ? nullptr : m_pCurrentPam.get(), true)); for(const auto& rpItem : aFlyPos) { @@ -1639,7 +1640,7 @@ static Writer & OutHTML_FrameFormatAsMulticol( Writer& rWrt, pSttNd->EndOfSectionIndex(), true, &rFrameFormat ); rHTMLWrt.m_bOutFlyFrame = true; - rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam ); + rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() ); } rHTMLWrt.DecIndentLevel(); // indent the content of Multicol; @@ -1726,7 +1727,7 @@ static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt, pSttNd->EndOfSectionIndex(), true, &rFrameFormat ); rHTMLWrt.m_bOutFlyFrame = true; - rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam ); + rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() ); } rHTMLWrt.DecIndentLevel(); // indent the content of Multicol; @@ -2000,7 +2001,7 @@ Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat, else rHTMLWrt.m_bOutFooter = true; - rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam ); + rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() ); } if( bHeader && !aSpacer.isEmpty() ) diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx index f7c35ed61272..96534f4aa7d8 100644 --- a/sw/source/filter/html/htmlftn.cxx +++ b/sw/source/filter/html/htmlftn.cxx @@ -351,7 +351,7 @@ void SwHTMLWriter::OutFootEndNotes() { HTMLSaveData aSaveData( *this, pSttNdIdx->GetIndex()+1, pSttNdIdx->GetNode().EndOfSectionIndex(), false ); - Out_SwDoc( m_pCurrentPam ); + Out_SwDoc( m_pCurrentPam.get() ); } DecIndentLevel(); // indent content of <DIV> diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index dee54a39d77d..30a07fa45782 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -459,7 +459,7 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt, { HTMLSaveData aSaveData( rWrt, pSttNd->GetIndex()+1, pSttNd->EndOfSectionIndex() ); - rWrt.Out_SwDoc( rWrt.m_pCurrentPam ); + rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() ); } else { diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 114912975750..1357b828c5dd 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -769,7 +769,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd ) rHTMLWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex()+1, rSectNd.EndOfSectionIndex(), false, pFormat ); - rHTMLWrt.Out_SwDoc( rHTMLWrt.m_pCurrentPam ); + rHTMLWrt.Out_SwDoc( rHTMLWrt.m_pCurrentPam.get() ); } rHTMLWrt.m_pCurrentPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode(); @@ -1490,7 +1490,7 @@ HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt, { bOldWriteAll = rWrt.m_bWriteAll; - rWrt.m_pCurrentPam = Writer::NewSwPaM( *rWrt.m_pDoc, nStt, nEnd ); + rWrt.m_pCurrentPam = Writer::NewUnoCursor(*rWrt.m_pDoc, nStt, nEnd); // recognize table in special areas if( nStt != rWrt.m_pCurrentPam->GetMark()->nNode.GetIndex() ) @@ -1500,7 +1500,7 @@ HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt, rWrt.m_pCurrentPam->GetMark()->nNode = nStt; } - rWrt.SetEndPaM( rWrt.m_pCurrentPam ); + rWrt.SetEndPaM( rWrt.m_pCurrentPam.get() ); rWrt.m_pCurrentPam->Exchange( ); rWrt.m_bWriteAll = true; rWrt.m_nDefListLvl = 0; @@ -1527,7 +1527,7 @@ HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt, HTMLSaveData::~HTMLSaveData() { - delete rWrt.m_pCurrentPam; // delete PaM again + rWrt.m_pCurrentPam.reset(); // delete PaM again rWrt.m_pCurrentPam = pOldPam; rWrt.SetEndPaM( pOldEnd ); diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 98c9005fe095..805643817003 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -625,7 +625,8 @@ inline void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp, struct HTMLSaveData { SwHTMLWriter& rWrt; - SwPaM* pOldPam, *pOldEnd; + std::shared_ptr<SwUnoCursor> pOldPam; + SwPaM *pOldEnd; std::unique_ptr<SwHTMLNumRuleInfo> pOldNumRuleInfo; // Owner = this std::unique_ptr<SwHTMLNumRuleInfo> pOldNextNumRuleInfo; sal_uInt16 const nOldDefListLvl; 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; diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 9a3d37c47b5b..06ddb97be542 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1575,7 +1575,8 @@ void DocxExport::SetFS( ::sax_fastparser::FSHelperPtr const & pFS ) mpFS = pFS; } -DocxExport::DocxExport(DocxExportFilter* pFilter, SwDoc* pDocument, SwPaM* pCurrentPam, +DocxExport::DocxExport(DocxExportFilter* pFilter, SwDoc* pDocument, + std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM* pOriginalPam, bool bDocm, bool bTemplate) : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ), m_pFilter( pFilter ), diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index fb04593aea9c..396ea628ef61 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -271,7 +271,8 @@ public: void WriteMainText(); /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class. - DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM* pCurrentPam, SwPaM* pOriginalPam, + DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, + std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM* pOriginalPam, bool bDocm, bool bTemplate); /// Destructor. diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx index 6adb879e4e28..63f382a18481 100644 --- a/sw/source/filter/ww8/docxexportfilter.cxx +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -73,7 +73,9 @@ bool DocxExportFilter::exportDocument() aPam.SetMark(); aPam.Move( fnMoveBackward, GoInDoc ); - std::unique_ptr<SwPaM> pCurPam( new SwPaM( *aPam.End(), *aPam.Start() ) ); + std::shared_ptr<SwUnoCursor> pCurPam(pDoc->CreateUnoCursor(*aPam.End(), false)); + pCurPam->SetMark(); + *pCurPam->GetPoint() = *aPam.Start(); OUString aFilterName; getMediaDescriptor()[utl::MediaDescriptor::PROP_FILTERNAME()] >>= aFilterName; @@ -82,7 +84,7 @@ bool DocxExportFilter::exportDocument() // export the document // (in a separate block so that it's destructed before the commit) { - DocxExport aExport(this, pDoc, pCurPam.get(), &aPam, bDocm, isExportTemplate()); + DocxExport aExport(this, pDoc, pCurPam, &aPam, bDocm, isExportTemplate()); aExport.ExportDocument( true ); // FIXME support exporting selection only } diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index d06f1259c7ce..4ffcda747017 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1036,8 +1036,9 @@ void RtfExport::AppendSection(const SwPageDesc* pPageDesc, const SwSectionFormat AttrOutput().SectionBreak(msword::PageBreak, m_pSections->CurrentSectionInfo()); } -RtfExport::RtfExport(RtfExportFilter* pFilter, SwDoc* pDocument, SwPaM* pCurrentPam, - SwPaM* pOriginalPam, Writer* pWriter, bool bOutOutlineOnly) +RtfExport::RtfExport(RtfExportFilter* pFilter, SwDoc* pDocument, + std::shared_ptr<SwUnoCursor>& pCurrentPam, SwPaM* pOriginalPam, + Writer* pWriter, bool bOutOutlineOnly) : MSWordExportBase(pDocument, pCurrentPam, pOriginalPam) , m_pFilter(pFilter) , m_pWriter(pWriter) @@ -1460,8 +1461,10 @@ SwRTFWriter::SwRTFWriter(const OUString& rFilterName, const OUString& rBaseURL) ErrCode SwRTFWriter::WriteStream() { - SwPaM aPam(*m_pCurrentPam->End(), *m_pCurrentPam->Start()); - RtfExport aExport(nullptr, m_pDoc, &aPam, m_pCurrentPam, this, m_bOutOutlineOnly); + std::shared_ptr<SwUnoCursor> pCurPam(m_pDoc->CreateUnoCursor(*m_pCurrentPam->End(), false)); + pCurPam->SetMark(); + *pCurPam->GetPoint() = *m_pCurrentPam->Start(); + RtfExport aExport(nullptr, m_pDoc, pCurPam, m_pCurrentPam.get(), this, m_bOutOutlineOnly); aExport.ExportDocument(true); return ERRCODE_NONE; } diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 321b2168ef37..bdc349bec5cc 100644 --- a/sw/source/filter/ww8/rtfexport.hxx +++ b/sw/source/filter/ww8/rtfexport.hxx @@ -149,8 +149,8 @@ protected: public: /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class. - RtfExport(RtfExportFilter* pFilter, SwDoc* pDocument, SwPaM* pCurrentPam, SwPaM* pOriginalPam, - Writer* pWriter, bool bOutOutlineOnly = false); + RtfExport(RtfExportFilter* pFilter, SwDoc* pDocument, std::shared_ptr<SwUnoCursor>& pCurrentPam, + SwPaM* pOriginalPam, Writer* pWriter, bool bOutOutlineOnly = false); RtfExport(const RtfExport&) = delete; diff --git a/sw/source/filter/ww8/rtfexportfilter.cxx b/sw/source/filter/ww8/rtfexportfilter.cxx index 1fb29957c556..f8c28d9f9bc6 100644 --- a/sw/source/filter/ww8/rtfexportfilter.cxx +++ b/sw/source/filter/ww8/rtfexportfilter.cxx @@ -70,12 +70,14 @@ sal_Bool RtfExportFilter::filter(const uno::Sequence<beans::PropertyValue>& aDes aPam.SetMark(); aPam.Move(fnMoveBackward, GoInDoc); - auto pCurPam = std::make_unique<SwPaM>(*aPam.End(), *aPam.Start()); + std::shared_ptr<SwUnoCursor> pCurPam(pDoc->CreateUnoCursor(*aPam.End(), false)); + pCurPam->SetMark(); + *pCurPam->GetPoint() = *aPam.Start(); // export the document // (in a separate block so that it's destructed before the commit) { - RtfExport aExport(this, pDoc, pCurPam.get(), &aPam, nullptr); + RtfExport aExport(this, pDoc, pCurPam, &aPam, nullptr); aExport.ExportDocument(true); } diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 10f5eeb0f188..347cfe10facb 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -1825,7 +1825,7 @@ void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_u { sal_uInt8 nOldTyp = m_nTextTyp; m_nTextTyp = nTTyp; - SwPaM* pOldPam = m_pCurPam; //!! Simply shifting the PaM without restoring should do the job too + auto const pOldPam = m_pCurPam; //!! Simply shifting the PaM without restoring should do the job too sal_uLong nOldStart = m_nCurStart; sal_uLong nOldEnd = m_nCurEnd; SwPaM* pOldEnd = m_pOrigPam; @@ -1850,8 +1850,7 @@ void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_u m_pTableInfo = pOldTableInfo; m_bOutPageDescs = bOldPageDescs; - delete m_pCurPam; // delete Pam - m_pCurPam = pOldPam; + m_pCurPam = pOldPam; // delete Pam m_nCurStart = nOldStart; m_nCurEnd = nOldEnd; m_pOrigPam = pOldEnd; @@ -1904,7 +1903,7 @@ void MSWordExportBase::SetCurPam(sal_uLong nStt, sal_uLong nEnd) { m_nCurStart = nStt; m_nCurEnd = nEnd; - m_pCurPam = Writer::NewSwPaM( *m_pDoc, nStt, nEnd ); + m_pCurPam = Writer::NewUnoCursor( *m_pDoc, nStt, nEnd ); // Recognize tables in special cases if ( nStt != m_pCurPam->GetMark()->nNode.GetIndex() && @@ -1913,7 +1912,7 @@ void MSWordExportBase::SetCurPam(sal_uLong nStt, sal_uLong nEnd) m_pCurPam->GetMark()->nNode = nStt; } - m_pOrigPam = m_pCurPam; + m_pOrigPam = m_pCurPam.get(); // ??? m_pCurPam->Exchange(); } @@ -1953,7 +1952,6 @@ void MSWordExportBase::RestoreData() { MSWordSaveData &rData = m_aSaveData.top(); - delete m_pCurPam; m_pCurPam = rData.pOldPam; m_nCurStart = rData.nOldStart; m_nCurEnd = rData.nOldEnd; @@ -2711,7 +2709,7 @@ public: void MSWordExportBase::WriteText() { - TrackContentToExport aContentTracking(m_pCurPam, m_nCurStart, m_nCurEnd); + TrackContentToExport aContentTracking(m_pCurPam.get(), m_nCurStart, m_nCurEnd); while (aContentTracking.contentRemainsToExport(m_pTableInfo.get())) { SwNode& rNd = m_pCurPam->GetNode(); @@ -3194,7 +3192,7 @@ ErrCode MSWordExportBase::ExportDocument( bool bWriteAll ) } if ( !m_pOCXExp && m_pDoc->GetDocShell() ) - m_pOCXExp.reset(new SwMSConvertControls( m_pDoc->GetDocShell(), m_pCurPam )); + m_pOCXExp.reset(new SwMSConvertControls(m_pDoc->GetDocShell(), m_pCurPam.get())); // #i81405# - Collect anchored objects before changing the redline mode. m_aFrames = GetFrames( *m_pDoc, bWriteAll? nullptr : m_pOrigPam ); @@ -3234,7 +3232,7 @@ ErrCode MSWordExportBase::ExportDocument( bool bWriteAll ) // park m_pOrigPam as well, as needed for exporting abi9915-1.odt to doc m_pOrigPam->DeleteMark(); *m_pOrigPam->GetPoint() = SwPosition(m_pDoc->GetNodes().GetEndOfContent()); - *m_pCurPam = *m_pOrigPam; + static_cast<SwPaM&>(*m_pCurPam) = *m_pOrigPam; m_pDoc->getIDocumentRedlineAccess().SetRedlineFlags(m_nOrigRedlineFlags); @@ -3586,7 +3584,7 @@ ErrCode SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed, return nRet; } -MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ) +MSWordExportBase::MSWordExportBase( SwDoc *pDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM *pOriginalPam ) : m_aMainStg(sMainStream) , m_pISet(nullptr) , m_pPiece(nullptr) @@ -3663,7 +3661,7 @@ MSWordExportBase::~MSWordExportBase() } WW8Export::WW8Export( SwWW8Writer *pWriter, - SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, + SwDoc *pDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM *pOriginalPam, bool bDot ) : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ) , pTableStrm(nullptr) diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index a1bbfad23631..58e6dc06e456 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -434,7 +434,8 @@ struct MSWordSaveData Point* pOldFlyOffset; RndStdIds eOldAnchorType; std::unique_ptr<ww::bytes> pOOld; ///< WW8Export only - SwPaM* pOldPam, *pOldEnd; + std::shared_ptr<SwUnoCursor> pOldPam; + SwPaM* pOldEnd; sal_uLong nOldStart, nOldEnd; const ww8::Frame* pOldFlyFormat; const SwPageDesc* pOldPageDesc; @@ -566,7 +567,8 @@ public: SwDoc *m_pDoc; sal_uLong m_nCurStart, m_nCurEnd; - SwPaM *m_pCurPam, *m_pOrigPam; + std::shared_ptr<SwUnoCursor> & m_pCurPam; + SwPaM *m_pOrigPam; /// Stack to remember the nesting (see MSWordSaveData for more) std::stack< MSWordSaveData > m_aSaveData; @@ -890,7 +892,7 @@ protected: std::vector<const Graphic*> m_vecBulletPic; ///< Vector to record all the graphics of bullets public: - MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ); + MSWordExportBase( SwDoc *pDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM *pOriginalPam ); virtual ~MSWordExportBase(); // TODO move as much as possible here from WW8Export! ;-) @@ -1131,7 +1133,7 @@ public: /// Setup the exporter. WW8Export( SwWW8Writer *pWriter, - SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, + SwDoc *pDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM *pOriginalPam, bool bDot ); virtual ~WW8Export() override; |