[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Oct 5 11:49:51 UTC 2017
sw/inc/doc.hxx | 6 +
sw/inc/docsh.hxx | 6 -
sw/inc/viewsh.hxx | 4
sw/qa/extras/uiwriter/uiwriter.cxx | 34 +++----
sw/source/core/crsr/crsrsh.cxx | 22 ++--
sw/source/core/crsr/crstrvl.cxx | 12 +-
sw/source/core/crsr/trvltbl.cxx | 2
sw/source/core/doc/doc.cxx | 5 -
sw/source/core/doc/docnew.cxx | 22 ++--
sw/source/core/docnode/ndtbl.cxx | 20 +---
sw/source/core/edit/edattr.cxx | 12 +-
sw/source/core/edit/edfmt.cxx | 10 +-
sw/source/core/edit/editsh.cxx | 4
sw/source/core/edit/edlingu.cxx | 16 +--
sw/source/core/edit/ednumber.cxx | 4
sw/source/core/edit/edtox.cxx | 6 -
sw/source/core/edit/edws.cxx | 4
sw/source/core/frmedt/fecopy.cxx | 8 -
sw/source/core/frmedt/fefly1.cxx | 32 +++----
sw/source/core/frmedt/feshview.cxx | 4
sw/source/core/frmedt/fews.cxx | 4
sw/source/core/inc/SwXMLTextBlocks.hxx | 2
sw/source/core/inc/swblocks.hxx | 2
sw/source/core/swg/SwXMLTextBlocks.cxx | 30 ++----
sw/source/core/swg/SwXMLTextBlocks1.cxx | 6 -
sw/source/core/swg/swblocks.cxx | 8 -
sw/source/core/view/viewsh.cxx | 48 +++++-----
sw/source/core/view/vnew.cxx | 58 ++++++-------
sw/source/core/view/vprint.cxx | 8 -
sw/source/filter/html/swhtml.cxx | 2
sw/source/filter/xml/swxml.cxx | 4
sw/source/uibase/app/docsh.cxx | 128 ++++++++++++++--------------
sw/source/uibase/app/docsh2.cxx | 82 +++++++++---------
sw/source/uibase/app/docshini.cxx | 142 +++++++++++++++-----------------
sw/source/uibase/app/docst.cxx | 30 +++---
sw/source/uibase/wrtsh/wrtsh1.cxx | 12 +-
36 files changed, 389 insertions(+), 410 deletions(-)
New commits:
commit cc483d0470dbf0d01e4da818b148ff0b851c5187
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Oct 4 13:30:11 2017 +0200
tdf#112292 - fix memory leak and use more auto ref counting in sw
this bug was introduced in
commit a754294ac7a902fe96fbbd6b8b6824a360d6b248
use rtl::Reference in SwDocFac instead of manual acquire/release
fix it by using automatic ref-counting (i.e. rtl::Reference) everywhere.
Note that the logic in SwViewShell::~SwViewShell is somewhat
interesting.
From my reading of it, it was previously potentially calling
getIDocumentLayoutAccess on an SwDoc that had just been deleted.
So if there is a problem with this commit I would look there first.
Change-Id: I95b6b7e7523689c8b56063af642c3a84cbdcd331
Reviewed-on: https://gerrit.libreoffice.org/43131
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 281054bfd9ff..b12d2f8d821b 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -337,7 +337,7 @@ private:
sal_uInt32 mnRsid; //< current session ID of the document
sal_uInt32 mnRsidRoot; //< session ID when the document was created
- sal_Int32 mReferenceCount;
+ oslInterlockedCount mReferenceCount;
bool mbDtor : 1; /**< TRUE: is in SwDoc DTOR.
and unfortunately temporarily also in
@@ -446,6 +446,9 @@ public:
SwNodes & GetNodes() { return *m_pNodes; }
SwNodes const& GetNodes() const { return *m_pNodes; }
+private:
+ friend class ::rtl::Reference<SwDoc>;
+
/** Acquire a reference to an instance. A caller shall release
the instance by calling 'release' when it is no longer needed.
'acquire' and 'release' calls need to be balanced.
@@ -466,6 +469,7 @@ public:
/** Returns the current reference count. This method should be used for
debugging purposes. Using it otherwise is a signal of a design flaw.
*/
+public:
sal_Int32 getReferenceCount() const;
// IDocumentSettingAccess
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 62f4cf4e56d2..d917b6a5780b 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -64,7 +64,7 @@ class SW_DLLPUBLIC SwDocShell
: public SfxObjectShell
, public SfxListener
{
- SwDoc* m_pDoc; ///< Document.
+ rtl::Reference< SwDoc > m_xDoc; ///< Document.
rtl::Reference< SfxStyleSheetBasePool > m_xBasePool; ///< Passing through for formats.
FontList* m_pFontList; ///< Current Fontlist.
bool m_IsInUpdateFontList; ///< prevent nested calls of UpdateFontList
@@ -192,8 +192,8 @@ public:
void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = nullptr );
/// returns Doc. But be careful!
- SwDoc* GetDoc() { return m_pDoc; }
- const SwDoc* GetDoc() const { return m_pDoc; }
+ SwDoc* GetDoc() { return m_xDoc.get(); }
+ const SwDoc* GetDoc() const { return m_xDoc.get(); }
IDocumentDeviceAccess& getIDocumentDeviceAccess();
IDocumentChartDataProviderAccess& getIDocumentChartDataProviderAccess();
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 4a52059a5141..6688ff6cb0e9 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -183,7 +183,7 @@ protected:
static vcl::DeleteOnDeinit< VclPtr<vcl::Window> > mpCareWindow; ///< Avoid this window.
SwRect maVisArea; ///< The modern version of VisArea.
- SwDoc *mpDoc; ///< The document; never 0.
+ rtl::Reference<SwDoc> mxDoc; ///< The document; never 0.
sal_uInt16 mnStartAction; ///< != 0 if at least one Action is active.
sal_uInt16 mnLockPaint; ///< != 0 if Paint is locked.
@@ -286,7 +286,7 @@ public:
const Size GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const;
- SwDoc *GetDoc() const { return mpDoc; } //Never 0.
+ SwDoc *GetDoc() const { return mxDoc.get(); } //Never 0.
/** Provides access to the document setting interface
*/
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index ce7dbb16544f..f78125e3b8bf 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -812,15 +812,15 @@ void SwUiWriterTest::testExportRTF()
pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, /*bBasicCall=*/false);
// Create the clipboard document.
- std::shared_ptr<SwDoc> pClpDoc(new SwDoc());
- pClpDoc->SetClipBoard(true);
- pWrtShell->Copy(pClpDoc.get());
+ std::shared_ptr<SwDoc> xClpDoc(new SwDoc());
+ xClpDoc->SetClipBoard(true);
+ pWrtShell->Copy(xClpDoc.get());
// And finally export it as RTF.
WriterRef xWrt;
SwReaderWriter::GetWriter("RTF", OUString(), xWrt);
SvMemoryStream aStream;
- SwWriter aWrt(aStream, *pClpDoc);
+ SwWriter aWrt(aStream, *xClpDoc);
aWrt.Write(xWrt);
OString aData(static_cast<const sal_Char*>(aStream.GetBuffer()), aStream.GetSize());
@@ -2405,10 +2405,9 @@ void SwUiWriterTest::testTdf77342()
IDocumentFieldsAccess& rField(pDoc->getIDocumentFieldsAccess());
rField.UpdateExpFields(nullptr, true);
//creating new clipboard doc
- SwDoc* pClpDoc = new SwDoc();
- pClpDoc->acquire();
- pClpDoc->SetClipBoard(true);
- pClpDoc->getIDocumentFieldsAccess().LockExpFields();
+ rtl::Reference<SwDoc> xClpDoc(new SwDoc());
+ xClpDoc->SetClipBoard(true);
+ xClpDoc->getIDocumentFieldsAccess().LockExpFields();
//selecting reference field 2 and reference field 3 and footnote 1 and footnote 2
//selection is such that more than one and not all footnotes and ref fields are selected
pCursor->Move(fnMoveBackward);
@@ -2419,7 +2418,7 @@ void SwUiWriterTest::testTdf77342()
pCursor->Move(fnMoveForward);
pCursor->Move(fnMoveForward);
//copying the selection to clipboard
- pWrtShell->Copy(pClpDoc);
+ pWrtShell->Copy(xClpDoc.get());
//deleting selection mark after copy
pCursor->DeleteMark();
//checking that the footnotes reference fields have same values after copy operation
@@ -2449,7 +2448,7 @@ void SwUiWriterTest::testTdf77342()
//moving cursor to the end of the document
pWrtShell->EndDoc();
//pasting the copied selection at current cursor position
- pWrtShell->Paste(pClpDoc);
+ pWrtShell->Paste(xClpDoc.get());
//checking the fields, both new and old, for proper values
pWrtShell->SttDoc();
//old reference field 1
@@ -2521,7 +2520,7 @@ void SwUiWriterTest::testTdf77342()
//moving the cursor to the starting of document
pWrtShell->SttDoc();
//pasting the selection again at current cursor position
- pWrtShell->Paste(pClpDoc);
+ pWrtShell->Paste(xClpDoc.get());
//checking the fields, both new and old, for proper values
pWrtShell->SttDoc();
//new reference field 1
@@ -2659,10 +2658,9 @@ void SwUiWriterTest::testTdf63553()
IDocumentFieldsAccess& rField(pDoc->getIDocumentFieldsAccess());
rField.UpdateExpFields(nullptr, true);
//creating new clipboard doc
- SwDoc* pClpDoc = new SwDoc();
- pClpDoc->acquire();
- pClpDoc->SetClipBoard(true);
- pClpDoc->getIDocumentFieldsAccess().LockExpFields();
+ rtl::Reference<SwDoc> xClpDoc( new SwDoc() );
+ xClpDoc->SetClipBoard(true);
+ xClpDoc->getIDocumentFieldsAccess().LockExpFields();
//selecting reference field 2 and 3 and sequence field 1 and 2
//selection is such that more than one and not all sequence fields and reference fields are selected
//ref1-[ref2-ref3-seq1-seq2]-seq3
@@ -2675,7 +2673,7 @@ void SwUiWriterTest::testTdf63553()
pCursor->Move(fnMoveForward);
pCursor->Move(fnMoveForward);
//copying the selection to clipboard
- pWrtShell->Copy(pClpDoc);
+ pWrtShell->Copy(xClpDoc.get());
//deleting selection mark after copy
pCursor->DeleteMark();
//checking whether the sequence and reference fields have same values after copy operation
@@ -2720,7 +2718,7 @@ void SwUiWriterTest::testTdf63553()
//moving cursor to the end of the document
pWrtShell->EndDoc();
//pasting the copied selection at current cursor position
- pWrtShell->Paste(pClpDoc);
+ pWrtShell->Paste(xClpDoc.get());
//checking the fields, both new and old, for proper values
pWrtShell->SttDoc();
//now we have ref1-ref2-ref3-seq1-seq2-seq3-nref1-nref2-nseq1-nseq2
@@ -2786,7 +2784,7 @@ void SwUiWriterTest::testTdf63553()
//moving the cursor to the starting of document
pWrtShell->SttDoc();
//pasting the selection again at current cursor position
- pWrtShell->Paste(pClpDoc);
+ pWrtShell->Paste(xClpDoc.get());
//checking the fields, both new and old, for proper values
pWrtShell->SttDoc();
//now we have [nnref1-nnref2-nnseq1-nnseq2]-ref1-[ref2-ref3-seq1-seq2]-seq3-[nref1-nref2-nseq1-nseq2]
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 5689d1b1d8ad..c21719a27409 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -379,11 +379,11 @@ void SwCursorShell::MarkListLevel( const OUString& sListId,
nListLevel != m_nMarkedListLevel)
{
if ( !m_sMarkedListId.isEmpty() )
- mpDoc->MarkListLevel( m_sMarkedListId, m_nMarkedListLevel, false );
+ mxDoc->MarkListLevel( m_sMarkedListId, m_nMarkedListLevel, false );
if ( !sListId.isEmpty() )
{
- mpDoc->MarkListLevel( sListId, nListLevel, true );
+ mxDoc->MarkListLevel( sListId, nListLevel, true );
}
m_sMarkedListId = sListId;
@@ -1437,7 +1437,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
// then the table mode is active (also if it is already active: m_pTableCursor)
SwPaM* pTstCursor = getShellCursor( true );
if( pTstCursor->HasMark() && !m_pBlockCursor &&
- mpDoc->IsIdxInTable( pTstCursor->GetPoint()->nNode ) &&
+ mxDoc->IsIdxInTable( pTstCursor->GetPoint()->nNode ) &&
( m_pTableCursor ||
pTstCursor->GetNode().StartOfSectionNode() !=
pTstCursor->GetNode( false ).StartOfSectionNode() ) && !mbSelectAll)
@@ -1613,8 +1613,8 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
if( pSectNd && ( pSectNd->GetSection().IsHiddenFlag() ||
( !IsReadOnlyAvailable() &&
pSectNd->GetSection().IsProtectFlag() &&
- ( !mpDoc->GetDocShell() ||
- !mpDoc->GetDocShell()->IsReadOnly() || m_bAllProtect )) ) )
+ ( !mxDoc->GetDocShell() ||
+ !mxDoc->GetDocShell()->IsReadOnly() || m_bAllProtect )) ) )
{
if( !FindValidContentNode( !HasDrawView() ||
0 == Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount()))
@@ -1710,8 +1710,8 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
if( !IsReadOnlyAvailable() && pFrame->IsProtected() &&
( !Imp()->GetDrawView() ||
!Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() ) &&
- (!mpDoc->GetDocShell() ||
- !mpDoc->GetDocShell()->IsReadOnly() || m_bAllProtect ) )
+ (!mxDoc->GetDocShell() ||
+ !mxDoc->GetDocShell()->IsReadOnly() || m_bAllProtect ) )
{
// look for a valid position
bool bChgState = true;
@@ -2832,7 +2832,7 @@ bool SwCursorShell::FindValidContentNode( bool bOnlyText )
// first check for frames
SwNodeIndex& rNdIdx = m_pCurrentCursor->GetPoint()->nNode;
sal_uLong nNdIdx = rNdIdx.GetIndex(); // keep backup
- SwNodes& rNds = mpDoc->GetNodes();
+ SwNodes& rNds = mxDoc->GetNodes();
SwContentNode* pCNd = rNdIdx.GetNode().GetContentNode();
const SwContentFrame * pFrame;
@@ -2863,8 +2863,8 @@ bool SwCursorShell::FindValidContentNode( bool bOnlyText )
else if( bOnlyText && pCNd && pCNd->IsNoTextNode() )
{
// set to beginning of document
- rNdIdx = mpDoc->GetNodes().GetEndOfExtras();
- m_pCurrentCursor->GetPoint()->nContent.Assign( mpDoc->GetNodes().GoNext(
+ rNdIdx = mxDoc->GetNodes().GetEndOfExtras();
+ m_pCurrentCursor->GetPoint()->nContent.Assign( mxDoc->GetNodes().GoNext(
&rNdIdx ), 0 );
nNdIdx = rNdIdx.GetIndex();
}
@@ -3108,7 +3108,7 @@ SvxFrameDirection SwCursorShell::GetTextDirection( const Point* pPt ) const
GetLayout()->GetCursorOfst( &aPos, aPt, &aTmpState );
}
- return mpDoc->GetTextDirection( aPos, &aPt );
+ return mxDoc->GetTextDirection( aPos, &aPt );
}
bool SwCursorShell::IsInVerticalText( const Point* pPt ) const
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 26144d19c8b6..e4ae81d5b71d 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -667,7 +667,7 @@ bool SwCursorShell::MoveFieldType(
if( SwFieldIds::Input == pFieldType->Which() && bAddSetExpressionFieldsToInputFields )
{
// there are hidden input fields in the set exp. fields
- const SwFieldTypes& rFieldTypes = *mpDoc->getIDocumentFieldsAccess().GetFieldTypes();
+ const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
const size_t nSize = rFieldTypes.size();
for( size_t i=0; i < nSize; ++i )
{
@@ -681,7 +681,7 @@ bool SwCursorShell::MoveFieldType(
}
else
{
- const SwFieldTypes& rFieldTypes = *mpDoc->getIDocumentFieldsAccess().GetFieldTypes();
+ const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
const size_t nSize = rFieldTypes.size();
for( size_t i=0; i < nSize; ++i )
{
@@ -716,10 +716,10 @@ bool SwCursorShell::MoveFieldType(
{
// create dummy for the search
SwFormatField* pFormatField = new SwFormatField( SwDateTimeField(
- static_cast<SwDateTimeFieldType*>(mpDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DateTime ) ) ) );
+ static_cast<SwDateTimeFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DateTime ) ) ) );
pTextField = new SwTextField( *pFormatField, rPos.nContent.GetIndex(),
- mpDoc->IsClipBoard() );
+ mxDoc->IsClipBoard() );
pTextField->ChgTextNode( pTNd );
}
else
@@ -932,7 +932,7 @@ bool SwCursorShell::GotoOutline( const OUString& rName )
SwCursorSaveState aSaveState( *pCursor );
bool bRet = false;
- if( mpDoc->GotoOutline( *pCursor->GetPoint(), rName ) && !pCursor->IsSelOvr() )
+ if( mxDoc->GotoOutline( *pCursor->GetPoint(), rName ) && !pCursor->IsSelOvr() )
{
UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
bRet = true;
@@ -1819,7 +1819,7 @@ bool SwCursorShell::GotoINetAttr( const SwTextINetFormat& rAttr )
const SwFormatINetFormat* SwCursorShell::FindINetAttr( const OUString& rName ) const
{
- return mpDoc->FindINetAttr( rName );
+ return mxDoc->FindINetAttr( rName );
}
bool SwCursorShell::GetShadowCursorPos( const Point& rPt, SwFillMode eFillMode,
diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index 70b4000c46e8..fef5a4f4a78d 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -91,7 +91,7 @@ bool SwCursorShell::GoNextCell( bool bAppendLine )
// the document might change; w/o Action views would not be notified
static_cast<SwEditShell*>(this)->StartAllAction();
- bRet = mpDoc->InsertRow( SwTable::SelLineFromBox( pTableBox, aBoxes, false ));
+ bRet = mxDoc->InsertRow( SwTable::SelLineFromBox( pTableBox, aBoxes, false ));
static_cast<SwEditShell*>(this)->EndAllAction();
}
}
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 33211afdd558..9239aa5cf809 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -145,7 +145,10 @@ sal_Int32 SwDoc::acquire()
sal_Int32 SwDoc::release()
{
assert(mReferenceCount >= 1);
- return osl_atomic_decrement(&mReferenceCount);
+ auto x = osl_atomic_decrement(&mReferenceCount);
+ if (x == 0)
+ delete this;
+ return x;
}
sal_Int32 SwDoc::getReferenceCount() const
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 8fa20bd5df18..883fcbac9047 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -856,12 +856,12 @@ void SwDoc::ReplaceCompatibilityOptions(const SwDoc& rSource)
SfxObjectShell* SwDoc::CreateCopy( bool bCallInitNew, bool bEmpty ) const
{
SAL_INFO( "sw.pageframe", "(SwDoc::CreateCopy in" );
- SwDoc* pRet = new SwDoc;
+ rtl::Reference<SwDoc> xRet( new SwDoc );
// we have to use pointer here, since the callee has to decide whether
// SfxObjectShellLock or SfxObjectShellRef should be used sometimes the
// object will be returned with refcount set to 0 ( if no DoInitNew is done )
- SfxObjectShell* pRetShell = new SwDocShell( pRet, SfxObjectCreateMode::STANDARD );
+ SfxObjectShell* pRetShell = new SwDocShell( xRet.get(), SfxObjectCreateMode::STANDARD );
if( bCallInitNew )
{
// it could happen that DoInitNew creates model,
@@ -869,30 +869,26 @@ SfxObjectShell* SwDoc::CreateCopy( bool bCallInitNew, bool bEmpty ) const
pRetShell->DoInitNew();
}
- (void)pRet->acquire();
+ xRet->ReplaceDefaults(*this);
- pRet->ReplaceDefaults(*this);
+ xRet->ReplaceCompatibilityOptions(*this);
- pRet->ReplaceCompatibilityOptions(*this);
-
- pRet->ReplaceStyles(*this);
+ xRet->ReplaceStyles(*this);
if( !bEmpty )
{
#ifdef DBG_UTIL
SAL_INFO( "sw.createcopy", "CC-Nd-Src: " << CNTNT_DOC( this ) );
- SAL_INFO( "sw.createcopy", "CC-Nd: " << CNTNT_DOC( pRet ) );
+ SAL_INFO( "sw.createcopy", "CC-Nd: " << CNTNT_DOC( xRet ) );
#endif
- pRet->AppendDoc(*this, 0, bCallInitNew, 0, 0);
+ xRet->AppendDoc(*this, 0, bCallInitNew, 0, 0);
#ifdef DBG_UTIL
- SAL_INFO( "sw.createcopy", "CC-Nd: " << CNTNT_DOC( pRet ) );
+ SAL_INFO( "sw.createcopy", "CC-Nd: " << CNTNT_DOC( xRet ) );
#endif
}
// remove the temporary shell if it is there as it was done before
- pRet->SetTmpDocShell( nullptr );
-
- (void)pRet->release();
+ xRet->SetTmpDocShell( nullptr );
SAL_INFO( "sw.pageframe", "SwDoc::CreateCopy out)" );
return pRetShell;
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 4ffb751df908..5590071bd174 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4352,20 +4352,18 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
GetIDocumentUndoRedo().DoUndo(false);
}
- SwDoc* pCpyDoc = const_cast<SwDoc*>(pSrcTableNd->GetDoc());
- bool bDelCpyDoc = pCpyDoc == this;
+ rtl::Reference<SwDoc> xCpyDoc( const_cast<SwDoc*>(pSrcTableNd->GetDoc()) );
+ bool bDelCpyDoc = xCpyDoc == this;
if( bDelCpyDoc )
{
// Copy the Table into a temporary Doc
- pCpyDoc = new SwDoc;
- pCpyDoc->acquire();
+ xCpyDoc = new SwDoc;
- SwPosition aPos( SwNodeIndex( pCpyDoc->GetNodes().GetEndOfContent() ));
- if( !pSrcTableNd->GetTable().MakeCopy( pCpyDoc, aPos, rBoxes, true ))
+ SwPosition aPos( SwNodeIndex( xCpyDoc->GetNodes().GetEndOfContent() ));
+ if( !pSrcTableNd->GetTable().MakeCopy( xCpyDoc.get(), aPos, rBoxes, true ))
{
- if( pCpyDoc->release() == 0 )
- delete pCpyDoc;
+ xCpyDoc.clear();
if( pUndo )
{
@@ -4413,11 +4411,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
aNdIdx, pUndo );
}
- if( bDelCpyDoc )
- {
- if( pCpyDoc->release() == 0 )
- delete pCpyDoc;
- }
+ xCpyDoc.clear();
if( pUndo )
{
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index aad47d7f8b22..25d7368dc2d3 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -409,7 +409,7 @@ bool SwEditShell::SetCurFootnote( const SwFormatFootnote& rFillFootnote )
for(SwPaM& rCursor : GetCursor()->GetRingContainer())
{
bChgd |=
- mpDoc->SetCurFootnote( rCursor, rFillFootnote.GetNumStr(), rFillFootnote.GetNumber(), rFillFootnote.IsEndNote() );
+ mxDoc->SetCurFootnote( rCursor, rFillFootnote.GetNumStr(), rFillFootnote.GetNumber(), rFillFootnote.IsEndNote() );
}
@@ -419,7 +419,7 @@ bool SwEditShell::SetCurFootnote( const SwFormatFootnote& rFillFootnote )
bool SwEditShell::HasFootnotes( bool bEndNotes ) const
{
- const SwFootnoteIdxs &rIdxs = mpDoc->GetFootnoteIdxs();
+ const SwFootnoteIdxs &rIdxs = mxDoc->GetFootnoteIdxs();
for ( auto pIdx : rIdxs )
{
const SwFormatFootnote &rFootnote = pIdx->GetFootnote();
@@ -434,11 +434,11 @@ size_t SwEditShell::GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes )
{
rList.Clear();
- const size_t nFootnoteCnt = mpDoc->GetFootnoteIdxs().size();
+ const size_t nFootnoteCnt = mxDoc->GetFootnoteIdxs().size();
SwTextFootnote* pTextFootnote;
for( size_t n = 0; n < nFootnoteCnt; ++n )
{
- pTextFootnote = mpDoc->GetFootnoteIdxs()[ n ];
+ pTextFootnote = mxDoc->GetFootnoteIdxs()[ n ];
const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
if ( rFootnote.IsEndNote() != bEndNotes )
continue;
@@ -449,11 +449,11 @@ size_t SwEditShell::GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes )
SwNodeIndex aIdx( *pIdx, 1 );
SwTextNode* pTextNd = aIdx.GetNode().GetTextNode();
if( !pTextNd )
- pTextNd = static_cast<SwTextNode*>(mpDoc->GetNodes().GoNext( &aIdx ));
+ pTextNd = static_cast<SwTextNode*>(mxDoc->GetNodes().GoNext( &aIdx ));
if( pTextNd )
{
- OUString sText( rFootnote.GetViewNumStr( *mpDoc ));
+ OUString sText( rFootnote.GetViewNumStr( *mxDoc ));
if( !sText.isEmpty() )
sText += " ";
sText += pTextNd->GetExpandText();
diff --git a/sw/source/core/edit/edfmt.cxx b/sw/source/core/edit/edfmt.cxx
index c162358a1913..329a25d43b7f 100644
--- a/sw/source/core/edit/edfmt.cxx
+++ b/sw/source/core/edit/edfmt.cxx
@@ -91,7 +91,7 @@ void SwEditShell::FillByEx(SwCharFormat* pCharFormat)
else
nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
- SfxItemSet aSet( mpDoc->GetAttrPool(),
+ SfxItemSet aSet( mxDoc->GetAttrPool(),
pCharFormat->GetAttrSet().GetRanges() );
pTextNode->GetAttr( aSet, nStt, nEnd );
pCharFormat->SetFormatAttr( aSet );
@@ -140,22 +140,22 @@ SwPageDesc* SwEditShell::GetPageDescFromPool( sal_uInt16 nId )
bool SwEditShell::IsUsed( const SwModify& rModify ) const
{
- return mpDoc->IsUsed( rModify );
+ return mxDoc->IsUsed( rModify );
}
const SwFlyFrameFormat* SwEditShell::FindFlyByName( const OUString& rName ) const
{
- return mpDoc->FindFlyByName(rName);
+ return mxDoc->FindFlyByName(rName);
}
SwCharFormat* SwEditShell::FindCharFormatByName( const OUString& rName ) const
{
- return mpDoc->FindCharFormatByName( rName );
+ return mxDoc->FindCharFormatByName( rName );
}
SwTextFormatColl* SwEditShell::FindTextFormatCollByName( const OUString& rName ) const
{
- return mpDoc->FindTextFormatCollByName( rName );
+ return mxDoc->FindTextFormatCollByName( rName );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index cb3cf89d0088..492169cfa319 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -292,7 +292,7 @@ void SwEditShell::ReRead( const OUString& rGrfName, const OUString& rFltName,
const Graphic* pGraphic )
{
StartAllAction();
- mpDoc->getIDocumentContentOperations().ReRead( *GetCursor(), rGrfName, rFltName, pGraphic, nullptr );
+ mxDoc->getIDocumentContentOperations().ReRead( *GetCursor(), rGrfName, rFltName, pGraphic, nullptr );
EndAllAction();
}
@@ -570,7 +570,7 @@ OUString SwEditShell::Calculate()
sfx2::LinkManager& SwEditShell::GetLinkManager()
{
- return mpDoc->getIDocumentLinksAdministration().GetLinkManager();
+ return mxDoc->getIDocumentLinksAdministration().GetLinkManager();
}
void *SwEditShell::GetIMapInventor() const
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index d62d1cc118a3..c40d776b419a 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -966,10 +966,10 @@ bool SwEditShell::GetGrammarCorrection(
{
const OUString aText(pNode->GetText().copy(nBegin, nLen));
- uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( mpDoc->GetGCIterator() );
+ uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( mxDoc->GetGCIterator() );
if (xGCIterator.is())
{
- uno::Reference< lang::XComponent > xDoc( mpDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
+ uno::Reference< lang::XComponent > xDoc( mxDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
// Expand the string:
const ModelToViewHelper aConversionMap(*pNode);
@@ -1125,7 +1125,7 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
// iterate over the new portions, beginning at the end to take advantage of the previously
// saved content positions
- mpDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::UI_TEXT_CORRECTION, nullptr );
+ mxDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::UI_TEXT_CORRECTION, nullptr );
StartAction();
SwPaM *pCursor = GetCursor();
@@ -1179,11 +1179,11 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
if(aCurrentNewPortion->sText != aCurrentOldPortion->sText)
{
// change text ...
- mpDoc->getIDocumentContentOperations().DeleteAndJoin(*pCursor);
+ mxDoc->getIDocumentContentOperations().DeleteAndJoin(*pCursor);
// ... and apply language if necessary
if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) );
- mpDoc->getIDocumentContentOperations().InsertString(*pCursor, aCurrentNewPortion->sText);
+ mxDoc->getIDocumentContentOperations().InsertString(*pCursor, aCurrentNewPortion->sText);
}
else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
{
@@ -1213,7 +1213,7 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
pCursor->GetMark()->nContent = aCurrentEndPosition->nRight;
// delete the sentence completely
- mpDoc->getIDocumentContentOperations().DeleteAndJoin(*pCursor);
+ mxDoc->getIDocumentContentOperations().DeleteAndJoin(*pCursor);
svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.begin();
while(aCurrentNewPortion != rNewPortions.end())
{
@@ -1232,7 +1232,7 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage)
SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) );
// insert the new string
- mpDoc->getIDocumentContentOperations().InsertString(*pCursor, aCurrentNewPortion->sText);
+ mxDoc->getIDocumentContentOperations().InsertString(*pCursor, aCurrentNewPortion->sText);
// set the cursor to the end of the inserted string
*pCursor->Start() = *pCursor->End();
@@ -1255,7 +1255,7 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
// set continuation position for spell/grammar checking to the end of this sentence
g_pSpellIter->SetCurr( new SwPosition(*pCursor->Start()) );
- mpDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::UI_TEXT_CORRECTION, nullptr );
+ mxDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::UI_TEXT_CORRECTION, nullptr );
EndAction();
}
}
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index ef503f3187f4..d5c58b022cef 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -167,7 +167,7 @@ bool SwEditShell::SelectionHasNumber() const
}
for (sal_uInt32 nPos = nStt; nPos<=nEnd; nPos++)
{
- pTextNd = mpDoc->GetNodes()[nPos]->GetTextNode();
+ pTextNd = mxDoc->GetNodes()[nPos]->GetTextNode();
if (pTextNd && pTextNd->Len()!=0)
{
bResult = pTextNd->HasNumber();
@@ -213,7 +213,7 @@ bool SwEditShell::SelectionHasBullet() const
}
for (sal_uInt32 nPos = nStt; nPos<=nEnd; nPos++)
{
- pTextNd = mpDoc->GetNodes()[nPos]->GetTextNode();
+ pTextNd = mxDoc->GetNodes()[nPos]->GetTextNode();
if (pTextNd && pTextNd->Len()!=0)
{
bResult = pTextNd->HasBullet();
diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx
index ec4b672bf7a0..f6919179af0f 100644
--- a/sw/source/core/edit/edtox.cxx
+++ b/sw/source/core/edit/edtox.cxx
@@ -85,7 +85,7 @@ void SwEditShell::DeleteTOXMark( SwTOXMark const * pMark )
SET_CURR_SHELL( this );
StartAllAction();
- mpDoc->DeleteTOXMark( pMark );
+ mxDoc->DeleteTOXMark( pMark );
EndAllAction();
}
@@ -136,7 +136,7 @@ void SwEditShell::InsertTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet )
::SetProgressText( STR_STATSTR_TOX_INSERT, pDocSh );
// Insert listing
- const SwTOXBaseSection* pTOX = mpDoc->InsertTableOf(
+ const SwTOXBaseSection* pTOX = mxDoc->InsertTableOf(
*GetCursor()->GetPoint(), rTOX, pSet, true );
OSL_ENSURE(pTOX, "No current TOx");
@@ -210,7 +210,7 @@ bool SwEditShell::DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes )
const SwTOXType* SwEditShell::GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
{
- return mpDoc->GetTOXType(eTyp, nId);
+ return mxDoc->GetTOXType(eTyp, nId);
}
// manage keys for the alphabetical index
diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx
index 6e0b62b7950f..c19d373a8bfb 100644
--- a/sw/source/core/edit/edws.cxx
+++ b/sw/source/core/edit/edws.cxx
@@ -187,12 +187,12 @@ SwFrameFormat *SwEditShell::GetTableFormat() // fastest test on a table
// TODO: Why is this called 3x for a new document?
sal_uInt16 SwEditShell::GetTOXTypeCount(TOXTypes eTyp) const
{
- return mpDoc->GetTOXTypeCount(eTyp);
+ return mxDoc->GetTOXTypeCount(eTyp);
}
void SwEditShell::InsertTOXType(const SwTOXType& rTyp)
{
- mpDoc->InsertTOXType(rTyp);
+ mxDoc->InsertTOXType(rTyp);
}
void SwEditShell::DoUndo( bool bOn )
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 4e015c1df804..b6840d96460f 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -464,10 +464,10 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
pDestShell->GetDoc()->getIDocumentFieldsAccess().LockExpFields();
// Shift references
- bool bCopyIsMove = mpDoc->IsCopyIsMove();
+ bool bCopyIsMove = mxDoc->IsCopyIsMove();
if( bIsMove )
// set a flag in Doc, handled in TextNodes
- mpDoc->SetCopyIsMove( true );
+ mxDoc->SetCopyIsMove( true );
RedlineFlags eOldRedlMode = pDestShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
pDestShell->GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode | RedlineFlags::DeleteRedlines );
@@ -652,7 +652,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
}
pDestShell->GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode );
- mpDoc->SetCopyIsMove( bCopyIsMove );
+ mxDoc->SetCopyIsMove( bCopyIsMove );
// have new table formulas been inserted?
if( pTableFieldTyp->HasWriterListeners() )
@@ -1392,7 +1392,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
{
// store attributes, then set SdrObject
- SfxItemSet aFrameSet( mpDoc->GetAttrPool(),
+ SfxItemSet aFrameSet( mxDoc->GetAttrPool(),
svl::Items<RES_SURROUND, RES_ANCHOR>{} );
aFrameSet.Set( pFormat->GetAttrSet() );
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 067194ca14ff..8130b7df7bbb 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -888,7 +888,7 @@ void SwFEShell::InsertDrawObj( SdrObject& rDrawObj,
rDrawObj.SetLayer( getIDocumentDrawModelAccess().GetHeavenId() );
// find anchor position
- SwPaM aPam( mpDoc->GetNodes() );
+ SwPaM aPam( mxDoc->GetNodes() );
{
SwCursorMoveState aState( MV_SETONLYTEXT );
Point aTmpPt( rInsertPosition );
@@ -924,7 +924,7 @@ void SwFEShell::GetPageObjs( std::vector<SwFrameFormat*>& rFillArr )
{
rFillArr.clear();
- for( auto pFormat : *mpDoc->GetSpzFrameFormats() )
+ for( auto pFormat : *mxDoc->GetSpzFrameFormats() )
{
if (RndStdIds::FLY_AT_PAGE == pFormat->GetAnchor().GetAnchorId())
{
@@ -947,7 +947,7 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr )
bool bTmpAssert = false;
for( auto pFormat : rFillArr )
{
- if (mpDoc->GetSpzFrameFormats()->IsAlive(pFormat))
+ if (mxDoc->GetSpzFrameFormats()->IsAlive(pFormat))
{
// FlyFormat is still valid, therefore process
@@ -967,7 +967,7 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr )
bTmpAssert = true;
}
aNewAnchor.SetPageNum( sal_uInt16(nNewPage) );
- mpDoc->SetAttr( aNewAnchor, *pFormat );
+ mxDoc->SetAttr( aNewAnchor, *pFormat );
}
}
@@ -1379,11 +1379,11 @@ SwFrameFormat* SwFEShell::WizardGetFly()
{
// do not search the Fly via the layout. Now we can delete a frame
// without a valid layout. ( e.g. for the wizards )
- SwFrameFormats& rSpzArr = *mpDoc->GetSpzFrameFormats();
+ SwFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats();
if( !rSpzArr.empty() )
{
SwNodeIndex& rCursorNd = GetCursor()->GetPoint()->nNode;
- if( rCursorNd.GetIndex() > mpDoc->GetNodes().GetEndOfExtras().GetIndex() )
+ if( rCursorNd.GetIndex() > mxDoc->GetNodes().GetEndOfExtras().GetIndex() )
// Cursor is in the body area!
return nullptr;
@@ -1739,7 +1739,7 @@ bool SwFEShell::ReplaceSdrObj( const OUString& rGrfName, const Graphic* pGrf )
SwFrameFormat *pFormat = FindFrameFormat( pObj );
// store attributes, then set the graphic
- SfxItemSet aFrameSet( mpDoc->GetAttrPool(),
+ SfxItemSet aFrameSet( mxDoc->GetAttrPool(),
pFormat->GetAttrSet().GetRanges() );
aFrameSet.Set( pFormat->GetAttrSet() );
@@ -1813,21 +1813,21 @@ void SwFEShell::GetConnectableFrameFormats(SwFrameFormat & rFormat,
SwFrameFormat * pOldChainPrev = static_cast<SwFrameFormat *>(rChain.GetPrev());
if (pOldChainNext)
- mpDoc->Unchain(rFormat);
+ mxDoc->Unchain(rFormat);
if (pOldChainPrev)
- mpDoc->Unchain(*pOldChainPrev);
+ mxDoc->Unchain(*pOldChainPrev);
- const size_t nCnt = mpDoc->GetFlyCount(FLYCNTTYPE_FRM);
+ const size_t nCnt = mxDoc->GetFlyCount(FLYCNTTYPE_FRM);
/* potential successors resp. predecessors */
std::vector< const SwFrameFormat * > aTmpSpzArray;
- mpDoc->FindFlyByName(rReference);
+ mxDoc->FindFlyByName(rReference);
for (size_t n = 0; n < nCnt; ++n)
{
- const SwFrameFormat & rFormat1 = *(mpDoc->GetFlyNum(n, FLYCNTTYPE_FRM));
+ const SwFrameFormat & rFormat1 = *(mxDoc->GetFlyNum(n, FLYCNTTYPE_FRM));
/*
pFormat is a potential successor of rFormat if it is chainable after
@@ -1840,9 +1840,9 @@ void SwFEShell::GetConnectableFrameFormats(SwFrameFormat & rFormat,
SwChainRet nChainState;
if (bSuccessors)
- nChainState = mpDoc->Chainable(rFormat, rFormat1);
+ nChainState = mxDoc->Chainable(rFormat, rFormat1);
else
- nChainState = mpDoc->Chainable(rFormat1, rFormat);
+ nChainState = mxDoc->Chainable(rFormat1, rFormat);
if (nChainState == SwChainRet::OK)
{
@@ -1889,10 +1889,10 @@ void SwFEShell::GetConnectableFrameFormats(SwFrameFormat & rFormat,
}
if (pOldChainNext)
- mpDoc->Chain(rFormat, *pOldChainNext);
+ mxDoc->Chain(rFormat, *pOldChainNext);
if (pOldChainPrev)
- mpDoc->Chain(*pOldChainPrev, rFormat);
+ mxDoc->Chain(*pOldChainPrev, rFormat);
EndAction();
}
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index a44468719a36..5ed4bdae28a8 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -2459,7 +2459,7 @@ bool SwFEShell::GotoFly( const OUString& rName, FlyCntType eType, bool bSelFrame
/* FLYCNTTYPE_OLE */ SwNodeType::Ole
};
- const SwFlyFrameFormat* pFlyFormat = mpDoc->FindFlyByName( rName, aChkArr[ eType]);
+ const SwFlyFrameFormat* pFlyFormat = mxDoc->FindFlyByName( rName, aChkArr[ eType]);
if( pFlyFormat )
{
SET_CURR_SHELL( this );
@@ -2566,7 +2566,7 @@ FlyProtectFlags SwFEShell::IsSelObjProtected( FlyProtectFlags eType ) const
// set FlyProtectFlags::Pos if it is a Math object anchored 'as char' and baseline alignment is activated
const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
&& RndStdIds::FLY_AS_CHAR == pFly->GetFormat()->GetAnchor().GetAnchorId()
- && mpDoc->GetDocumentSettingManager().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT );
+ && mxDoc->GetDocumentSettingManager().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT );
if ((FlyProtectFlags::Pos & eType) && bProtectMathPos)
nChk |= FlyProtectFlags::Pos;
}
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 38b194f414ff..9208fea97229 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -565,7 +565,7 @@ bool SwFEShell::Sort(const SwSortOptions& rOpt)
}
// call sorting on document
- bRet = mpDoc->SortTable(aBoxes, rOpt);
+ bRet = mxDoc->SortTable(aBoxes, rOpt);
}
else
{
@@ -582,7 +582,7 @@ bool SwFEShell::Sort(const SwSortOptions& rOpt)
const sal_Int32 nCntStt = pStart->nContent.GetIndex();
// Sorting
- bRet = mpDoc->SortText(*pPam, rOpt);
+ bRet = mxDoc->SortText(*pPam, rOpt);
// put selection again
pPam->DeleteMark();
diff --git a/sw/source/core/inc/SwXMLTextBlocks.hxx b/sw/source/core/inc/SwXMLTextBlocks.hxx
index e4305c071c20..d164d5249554 100644
--- a/sw/source/core/inc/SwXMLTextBlocks.hxx
+++ b/sw/source/core/inc/SwXMLTextBlocks.hxx
@@ -88,7 +88,7 @@ public:
virtual bool PutMuchEntries( bool bOn ) override;
public:
- SwDoc* GetDoc() const { return m_pDoc; }
+ SwDoc* GetDoc() const { return m_xDoc.get(); }
//void SetDoc( SwDoc * pNewDoc);
ErrCode StartPutBlock( const OUString& rShort, const OUString& rPackageName );
ErrCode PutBlock();
diff --git a/sw/source/core/inc/swblocks.hxx b/sw/source/core/inc/swblocks.hxx
index d4fdf25a9ad9..77098f9c08aa 100644
--- a/sw/source/core/inc/swblocks.hxx
+++ b/sw/source/core/inc/swblocks.hxx
@@ -60,7 +60,7 @@ protected:
SwBlockNames m_aNames; // List of all Blocks
Date m_aDateModified; // For aligning the Actions
tools::Time m_aTimeModified;
- SwDoc* m_pDoc; // Document to be switched
+ rtl::Reference<SwDoc> m_xDoc; // Document to be switched
sal_uInt16 m_nCurrentIndex; // Current Index
bool m_bReadOnly : 1;
bool m_bInPutMuchBlocks : 1; // Put several block entries
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx
index 108c8473d309..87fdb2b3c40a 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -63,11 +63,10 @@ SwXMLTextBlocks::SwXMLTextBlocks( const OUString& rFile )
if( !pDocSh->DoInitNew() )
return;
m_bReadOnly = true;
- m_pDoc = pDocSh->GetDoc();
+ m_xDoc = pDocSh->GetDoc();
xDocShellRef = pDocSh;
- m_pDoc->SetOle2Link( Link<bool,void>() );
- m_pDoc->GetIDocumentUndoRedo().DoUndo(false);
- m_pDoc->acquire();
+ m_xDoc->SetOle2Link( Link<bool,void>() );
+ m_xDoc->GetIDocumentUndoRedo().DoUndo(false);
uno::Reference< embed::XStorage > refStg;
if( !m_aDateModified.GetDate() || !m_aTimeModified.GetTime() )
Touch(); // If it's created anew -> get a new timestamp
@@ -106,11 +105,10 @@ SwXMLTextBlocks::SwXMLTextBlocks( const uno::Reference < embed::XStorage >& rStg
if( !pDocSh->DoInitNew() )
return;
m_bReadOnly = false;
- m_pDoc = pDocSh->GetDoc();
+ m_xDoc = pDocSh->GetDoc();
xDocShellRef = pDocSh;
- m_pDoc->SetOle2Link( Link<bool,void>() );
- m_pDoc->GetIDocumentUndoRedo().DoUndo(false);
- m_pDoc->acquire();
+ m_xDoc->SetOle2Link( Link<bool,void>() );
+ m_xDoc->GetIDocumentUndoRedo().DoUndo(false);
InitBlockMode ( rStg );
ReadInfo();
@@ -125,17 +123,15 @@ SwXMLTextBlocks::~SwXMLTextBlocks()
if(xDocShellRef.is())
xDocShellRef->DoClose();
xDocShellRef = nullptr;
- if( m_pDoc && !m_pDoc->release() )
- delete m_pDoc;
}
void SwXMLTextBlocks::ClearDoc()
{
- SwDocShell * pDocShell = m_pDoc->GetDocShell();
+ SwDocShell * pDocShell = m_xDoc->GetDocShell();
pDocShell->InvalidateModel();
pDocShell->ReactivateModel();
- m_pDoc->ClearDoc();
+ m_xDoc->ClearDoc();
pDocShell->ClearEmbeddedObjects();
}
@@ -322,13 +318,13 @@ ErrCode SwXMLTextBlocks::PutBlock()
WriterRef xWrt;
::GetXMLWriter ( OUString(), GetBaseURL(), xWrt);
- SwWriter aWriter (xRoot, *m_pDoc );
+ SwWriter aWriter (xRoot, *m_xDoc );
xWrt->bBlock = true;
nRes = aWriter.Write ( xWrt );
xWrt->bBlock = false;
// Save OLE objects if there are some
- SwDocShell *pDocSh = m_pDoc->GetDocShell();
+ SwDocShell *pDocSh = m_xDoc->GetDocShell();
bool bHasChildren = pDocSh && pDocSh->GetEmbeddedObjectContainer().HasEmbeddedObjects();
if( !nRes && bHasChildren )
@@ -562,10 +558,10 @@ ErrCode SwXMLTextBlocks::PutText( const OUString& rShort, const OUString& rName,
void SwXMLTextBlocks::MakeBlockText( const OUString& rText )
{
- SwTextNode* pTextNode = m_pDoc->GetNodes()[ m_pDoc->GetNodes().GetEndOfContent().
+ SwTextNode* pTextNode = m_xDoc->GetNodes()[ m_xDoc->GetNodes().GetEndOfContent().
GetIndex() - 1 ]->GetTextNode();
- if( pTextNode->GetTextColl() == m_pDoc->GetDfltTextFormatColl() )
- pTextNode->ChgFormatColl( m_pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
+ if( pTextNode->GetTextColl() == m_xDoc->GetDfltTextFormatColl() )
+ pTextNode->ChgFormatColl( m_xDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
sal_Int32 nPos = 0;
do
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index c0315483159d..867a98129381 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -64,7 +64,7 @@ ErrCode SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx )
{
xRoot = xBlkRoot->openStorageElement( aFolderName, embed::ElementModes::READ );
xMedium = new SfxMedium( xRoot, GetBaseURL(), OUString( "writer8" ) );
- SwReader aReader( *xMedium, aFolderName, m_pDoc );
+ SwReader aReader( *xMedium, aFolderName, m_xDoc.get() );
ReadXML->SetBlockMode( true );
aReader.Read( *ReadXML );
ReadXML->SetBlockMode( false );
@@ -73,7 +73,7 @@ ErrCode SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx )
OUString sObjReplacements( "ObjectReplacements" );
if ( xRoot->hasByName( sObjReplacements ) )
{
- uno::Reference< document::XStorageBasedDocument > xDocStor( m_pDoc->GetDocShell()->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< document::XStorageBasedDocument > xDocStor( m_xDoc->GetDocShell()->GetModel(), uno::UNO_QUERY_THROW );
uno::Reference< embed::XStorage > xStr( xDocStor->getDocumentStorage() );
if ( xStr.is() )
{
@@ -513,7 +513,7 @@ ErrCode SwXMLTextBlocks::SetMacroTable(
// Get model
uno::Reference< lang::XComponent > xModelComp(
- m_pDoc->GetDocShell()->GetModel(), UNO_QUERY );
+ m_xDoc->GetDocShell()->GetModel(), UNO_QUERY );
OSL_ENSURE( xModelComp.is(), "XMLWriter::Write: got no model" );
if( !xModelComp.is() )
return ERR_SWG_WRITE_ERROR;
diff --git a/sw/source/core/swg/swblocks.cxx b/sw/source/core/swg/swblocks.cxx
index a0c3da4b8a04..079984ed9635 100644
--- a/sw/source/core/swg/swblocks.cxx
+++ b/sw/source/core/swg/swblocks.cxx
@@ -90,7 +90,7 @@ SwImpBlocks::SwImpBlocks( const OUString& rFile )
: m_aFile( rFile ),
m_aDateModified( Date::EMPTY ),
m_aTimeModified( tools::Time::EMPTY ),
- m_pDoc( nullptr ), m_nCurrentIndex( USHRT_MAX ),
+ m_nCurrentIndex( USHRT_MAX ),
m_bReadOnly( true ), m_bInPutMuchBlocks( false ),
m_bInfoChanged(false)
{
@@ -111,7 +111,7 @@ SwImpBlocks::~SwImpBlocks()
*/
void SwImpBlocks::ClearDoc()
{
- m_pDoc->ClearDoc();
+ m_xDoc->ClearDoc();
}
/**
@@ -119,7 +119,7 @@ void SwImpBlocks::ClearDoc()
*/
SwPaM* SwImpBlocks::MakePaM()
{
- SwPaM* pPam = new SwPaM( m_pDoc->GetNodes().GetEndOfContent() );
+ SwPaM* pPam = new SwPaM( m_xDoc->GetNodes().GetEndOfContent() );
pPam->Move( fnMoveBackward, GoInDoc );
pPam->SetMark();
pPam->Move( fnMoveForward, GoInDoc );
@@ -512,7 +512,7 @@ sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName,
SwDoc* SwTextBlocks::GetDoc()
{
if( pImp )
- return pImp->m_pDoc;
+ return pImp->m_xDoc.get();
return nullptr;
}
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index af10689e027f..951f8e04da57 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2060,7 +2060,7 @@ OutputDevice& SwViewShell::GetRefDev() const
const SwNodes& SwViewShell::GetNodes() const
{
- return mpDoc->GetNodes();
+ return mxDoc->GetNodes();
}
void SwViewShell::DrawSelChanged()
@@ -2133,7 +2133,7 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
if( mpOpt->IsShowHiddenField() != rOpt.IsShowHiddenField() )
{
- static_cast<SwHiddenTextFieldType*>(mpDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))->
+ static_cast<SwHiddenTextFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))->
SetHiddenFlag( !rOpt.IsShowHiddenField() );
bReformat = true;
}
@@ -2225,13 +2225,13 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
*mpOpt = rOpt; // First the options are taken.
mpOpt->SetUIOptions(rOpt);
- mpDoc->GetDocumentSettingManager().set(DocumentSettingId::HTML_MODE, 0 != ::GetHtmlMode(mpDoc->GetDocShell()));
+ mxDoc->GetDocumentSettingManager().set(DocumentSettingId::HTML_MODE, 0 != ::GetHtmlMode(mxDoc->GetDocShell()));
if( bBrowseModeChanged || bHideWhitespaceModeChanged )
{
// #i44963# Good occasion to check if page sizes in
// page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
- mpDoc->CheckDefaultPageFormat();
+ mxDoc->CheckDefaultPageFormat();
InvalidateLayout( true );
}
@@ -2360,7 +2360,7 @@ uno::Reference< css::accessibility::XAccessible > SwViewShell::CreateAccessible(
OSL_ENSURE( mpLayout, "no layout, no access" );
OSL_ENSURE( GetWin(), "no window, no access" );
- if( mpDoc->getIDocumentLayoutAccess().GetCurrentViewShell() && GetWin() )
+ if( mxDoc->getIDocumentLayoutAccess().GetCurrentViewShell() && GetWin() )
xAcc = Imp()->GetAccessibleMap().GetDocumentView();
return xAcc;
@@ -2556,36 +2556,36 @@ SwPostItMgr* SwViewShell::GetPostItMgr()
/*
* Document Interface Access
*/
-const IDocumentSettingAccess& SwViewShell::getIDocumentSettingAccess() const { return mpDoc->GetDocumentSettingManager(); }
-IDocumentSettingAccess& SwViewShell::getIDocumentSettingAccess() { return mpDoc->GetDocumentSettingManager(); }
-const IDocumentDeviceAccess& SwViewShell::getIDocumentDeviceAccess() const { return mpDoc->getIDocumentDeviceAccess(); }
-IDocumentDeviceAccess& SwViewShell::getIDocumentDeviceAccess() { return mpDoc->getIDocumentDeviceAccess(); }
-const IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() const { return mpDoc->getIDocumentMarkAccess(); }
-IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() { return mpDoc->getIDocumentMarkAccess(); }
-const IDocumentDrawModelAccess& SwViewShell::getIDocumentDrawModelAccess() const { return mpDoc->getIDocumentDrawModelAccess(); }
-IDocumentDrawModelAccess& SwViewShell::getIDocumentDrawModelAccess() { return mpDoc->getIDocumentDrawModelAccess(); }
-const IDocumentRedlineAccess& SwViewShell::getIDocumentRedlineAccess() const { return mpDoc->getIDocumentRedlineAccess(); }
-IDocumentRedlineAccess& SwViewShell::getIDocumentRedlineAccess() { return mpDoc->getIDocumentRedlineAccess(); }
-const IDocumentLayoutAccess& SwViewShell::getIDocumentLayoutAccess() const { return mpDoc->getIDocumentLayoutAccess(); }
-IDocumentLayoutAccess& SwViewShell::getIDocumentLayoutAccess() { return mpDoc->getIDocumentLayoutAccess(); }
-IDocumentContentOperations& SwViewShell::getIDocumentContentOperations() { return mpDoc->getIDocumentContentOperations(); }
-IDocumentStylePoolAccess& SwViewShell::getIDocumentStylePoolAccess() { return mpDoc->getIDocumentStylePoolAccess(); }
-const IDocumentStatistics& SwViewShell::getIDocumentStatistics() const { return mpDoc->getIDocumentStatistics(); }
+const IDocumentSettingAccess& SwViewShell::getIDocumentSettingAccess() const { return mxDoc->GetDocumentSettingManager(); }
+IDocumentSettingAccess& SwViewShell::getIDocumentSettingAccess() { return mxDoc->GetDocumentSettingManager(); }
+const IDocumentDeviceAccess& SwViewShell::getIDocumentDeviceAccess() const { return mxDoc->getIDocumentDeviceAccess(); }
+IDocumentDeviceAccess& SwViewShell::getIDocumentDeviceAccess() { return mxDoc->getIDocumentDeviceAccess(); }
+const IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() const { return mxDoc->getIDocumentMarkAccess(); }
+IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() { return mxDoc->getIDocumentMarkAccess(); }
+const IDocumentDrawModelAccess& SwViewShell::getIDocumentDrawModelAccess() const { return mxDoc->getIDocumentDrawModelAccess(); }
+IDocumentDrawModelAccess& SwViewShell::getIDocumentDrawModelAccess() { return mxDoc->getIDocumentDrawModelAccess(); }
+const IDocumentRedlineAccess& SwViewShell::getIDocumentRedlineAccess() const { return mxDoc->getIDocumentRedlineAccess(); }
+IDocumentRedlineAccess& SwViewShell::getIDocumentRedlineAccess() { return mxDoc->getIDocumentRedlineAccess(); }
+const IDocumentLayoutAccess& SwViewShell::getIDocumentLayoutAccess() const { return mxDoc->getIDocumentLayoutAccess(); }
+IDocumentLayoutAccess& SwViewShell::getIDocumentLayoutAccess() { return mxDoc->getIDocumentLayoutAccess(); }
+IDocumentContentOperations& SwViewShell::getIDocumentContentOperations() { return mxDoc->getIDocumentContentOperations(); }
+IDocumentStylePoolAccess& SwViewShell::getIDocumentStylePoolAccess() { return mxDoc->getIDocumentStylePoolAccess(); }
+const IDocumentStatistics& SwViewShell::getIDocumentStatistics() const { return mxDoc->getIDocumentStatistics(); }
IDocumentUndoRedo & SwViewShell::GetIDocumentUndoRedo()
-{ return mpDoc->GetIDocumentUndoRedo(); }
+{ return mxDoc->GetIDocumentUndoRedo(); }
IDocumentUndoRedo const& SwViewShell::GetIDocumentUndoRedo() const
-{ return mpDoc->GetIDocumentUndoRedo(); }
+{ return mxDoc->GetIDocumentUndoRedo(); }
// --> OD 2007-11-14 #i83479#
const IDocumentListItems* SwViewShell::getIDocumentListItemsAccess() const
{
- return &mpDoc->getIDocumentListItems();
+ return &mxDoc->getIDocumentListItems();
}
const IDocumentOutlineNodes* SwViewShell::getIDocumentOutlineNodesAccess() const
{
- return &mpDoc->getIDocumentOutlineNodes();
+ return &mxDoc->getIDocumentOutlineNodes();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index c8755a246d39..2998ffb131f8 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -73,8 +73,8 @@ void SwViewShell::Init( const SwViewOption *pNewOpt )
}
}
- SwDocShell* pDShell = mpDoc->GetDocShell();
- mpDoc->GetDocumentSettingManager().set(DocumentSettingId::HTML_MODE, 0 != ::GetHtmlMode( pDShell ) );
+ SwDocShell* pDShell = mxDoc->GetDocShell();
+ mxDoc->GetDocumentSettingManager().set(DocumentSettingId::HTML_MODE, 0 != ::GetHtmlMode( pDShell ) );
// set readonly flag at ViewOptions before creating layout. Otherwise,
// one would have to reformat again.
@@ -96,7 +96,7 @@ void SwViewShell::Init( const SwViewOption *pNewOpt )
// page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
if ( !bBrowseMode )
{
- mpDoc->CheckDefaultPageFormat();
+ mxDoc->CheckDefaultPageFormat();
}
SAL_INFO( "sw.core", "View::Init - after InitPrt" );
@@ -121,9 +121,9 @@ void SwViewShell::Init( const SwViewOption *pNewOpt )
if( !mpLayout )
{
// switched to two step construction because creating the layout in SwRootFrame needs a valid pLayout set
- mpLayout = SwRootFramePtr(new SwRootFrame(mpDoc->GetDfltFrameFormat(), this),
+ mpLayout = SwRootFramePtr(new SwRootFrame(mxDoc->GetDfltFrameFormat(), this),
&SwFrame::DestroyFrame);
- mpLayout->Init( mpDoc->GetDfltFrameFormat() );
+ mpLayout->Init( mxDoc->GetDfltFrameFormat() );
}
}
SizeChgNotify();
@@ -158,7 +158,7 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
mbHeaderFooterEdit( false ),
mpTargetPaintWindow(nullptr),
mpBufferedOut(nullptr),
- mpDoc( &rDocument ),
+ mxDoc( &rDocument ),
mnStartAction( 0 ),
mnLockPaint( 0 ),
mbSelectAll(false),
@@ -177,8 +177,7 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
// i#38810 Do not reset modified state of document,
// if it's already been modified.
- const bool bIsDocModified( mpDoc->getIDocumentState().IsModified() );
- mpDoc->acquire();
+ const bool bIsDocModified( mxDoc->getIDocumentState().IsModified() );
pOutput = mpOut;
Init( pNewOpt ); // may change the Outdev (InitPrt())
mpOut = pOutput;
@@ -193,14 +192,14 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
SET_CURR_SHELL( this );
- static_cast<SwHiddenTextFieldType*>(mpDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))->
+ static_cast<SwHiddenTextFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))->
SetHiddenFlag( !mpOpt->IsShowHiddenField() );
// In Init a standard FrameFormat is created.
- if ( !mpDoc->GetIDocumentUndoRedo().IsUndoNoResetModified()
+ if ( !mxDoc->GetIDocumentUndoRedo().IsUndoNoResetModified()
&& !bIsDocModified )
{
- mpDoc->getIDocumentState().ResetModified();
+ mxDoc->getIDocumentState().ResetModified();
}
// extend format cache.
@@ -231,7 +230,7 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
mbHeaderFooterEdit( false ),
mpTargetPaintWindow(nullptr),
mpBufferedOut(nullptr),
- mpDoc( rShell.GetDoc() ),
+ mxDoc( rShell.GetDoc() ),
mnStartAction( 0 ),
mnLockPaint( 0 ),
mbSelectAll(false),
@@ -253,8 +252,7 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
SET_CURR_SHELL( this );
- mpDoc->acquire();
- bool bModified = mpDoc->getIDocumentState().IsModified();
+ bool bModified = mxDoc->getIDocumentState().IsModified();
pOutput = mpOut;
Init( rShell.GetViewOptions() ); // might change Outdev (InitPrt())
@@ -263,13 +261,13 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
if ( mbPreview )
mpImp->InitPagePreviewLayout();
- static_cast<SwHiddenTextFieldType*>(mpDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))->
+ static_cast<SwHiddenTextFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))->
SetHiddenFlag( !mpOpt->IsShowHiddenField() );
// In Init a standard FrameFormat is created.
- if( !bModified && !mpDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() )
+ if( !bModified && !mxDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() )
{
- mpDoc->getIDocumentState().ResetModified();
+ mxDoc->getIDocumentState().ResetModified();
}
// extend format cache.
@@ -284,6 +282,8 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
SwViewShell::~SwViewShell()
{
+ IDocumentLayoutAccess * const pLayoutAccess = mxDoc.get() ? &mxDoc->getIDocumentLayoutAccess() : nullptr;
+
{
SET_CURR_SHELL( this );
mbPaintWorks = false;
@@ -291,9 +291,9 @@ SwViewShell::~SwViewShell()
// i#9684 Stopping the animated graphics is not
// necessary during printing or pdf export, because the animation
// has not been started in this case.
- if( mpDoc && GetWin() )
+ if( mxDoc.get() && GetWin() )
{
- SwNodes& rNds = mpDoc->GetNodes();
+ SwNodes& rNds = mxDoc->GetNodes();
SwStartNode *pStNd;
SwNodeIndex aIdx( *rNds.GetEndOfAutotext().StartOfSectionNode(), 1 );
@@ -322,14 +322,11 @@ SwViewShell::~SwViewShell()
delete mpImp; // Delete first, so that the LayoutViews are destroyed.
mpImp = nullptr; // Set to zero, because ~SwFrame relies on it.
- if ( mpDoc )
+ if ( mxDoc.get() )
{
- if( !mpDoc->release() )
- {
- delete mpDoc;
- mpDoc = nullptr;
- }
- else
+ auto x = mxDoc->getReferenceCount();
+ mxDoc.clear();
+ if( x > 1 )
GetLayout()->ResetNewLayout();
}
@@ -345,18 +342,17 @@ SwViewShell::~SwViewShell()
OSL_ENSURE( !mnStartAction, "EndAction() pending." );
}
- if ( mpDoc )
+ if ( pLayoutAccess )
{
GetLayout()->DeRegisterShell( this );
- auto& rLayoutAccess(mpDoc->getIDocumentLayoutAccess());
- if(rLayoutAccess.GetCurrentViewShell()==this)
+ if(pLayoutAccess->GetCurrentViewShell()==this)
{
- rLayoutAccess.SetCurrentViewShell(nullptr);
+ pLayoutAccess->SetCurrentViewShell(nullptr);
for(SwViewShell& rShell : GetRingContainer())
{
if(&rShell != this)
{
- rLayoutAccess.SetCurrentViewShell(&rShell);
+ pLayoutAccess->SetCurrentViewShell(&rShell);
break;
}
}
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 73dead50d7c1..06163ce864cf 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -625,10 +625,10 @@ void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintD
bool SwViewShell::IsAnyFieldInDoc() const
{
const SfxPoolItem* pItem;
- sal_uInt32 nMaxItems = mpDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD );
+ sal_uInt32 nMaxItems = mxDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD );
for( sal_uInt32 n = 0; n < nMaxItems; ++n )
{
- if( nullptr != (pItem = mpDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n )))
+ if( nullptr != (pItem = mxDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n )))
{
const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem);
const SwTextField* pTextField = pFormatField->GetTextField();
@@ -639,10 +639,10 @@ bool SwViewShell::IsAnyFieldInDoc() const
}
}
- nMaxItems = mpDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD );
+ nMaxItems = mxDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD );
for( sal_uInt32 n = 0; n < nMaxItems; ++n )
{
- if( nullptr != (pItem = mpDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n )))
+ if( nullptr != (pItem = mxDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n )))
{
const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem);
const SwTextField* pTextField = pFormatField->GetTextField();
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 2c947e3db384..94e5ba298b4e 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -211,7 +211,7 @@ ErrCode HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, co
}
// so nobody steals the document!
- rDoc.acquire();
+ rtl::Reference<SwDoc> aHoldRef(&rDoc);
ErrCode nRet = ERRCODE_NONE;
tools::SvRef<SwHTMLParser> xParser = new SwHTMLParser( &rDoc, rPam, *pStrm,
rName, rBaseURL, !bInsertMode, pMedium,
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index bd37e18b2634..bb42dffa51e6 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -739,7 +739,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
}
}
- (void)rDoc.acquire(); // prevent deletion
+ rtl::Reference<SwDoc> aHoldRef(&rDoc); // prevent deletion
ErrCode nRet = ERRCODE_NONE;
// save redline mode into import info property set
@@ -894,7 +894,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
if( pObjectHelper )
SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
xObjectResolver = nullptr;
- (void)rDoc.release();
+ aHoldRef.clear();
if ( !bOASIS )
{
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 82c3c8390f35..61ea3efbc2d9 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -192,7 +192,7 @@ Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
*ppRdr = pPaM ? new SwReader( rMedium, aFileName, *pPaM ) :
pCursorShell ?
new SwReader( rMedium, aFileName, *pCursorShell->GetCursor() )
- : new SwReader( rMedium, aFileName, m_pDoc );
+ : new SwReader( rMedium, aFileName, m_xDoc.get() );
}
else
return nullptr;
@@ -230,7 +230,7 @@ bool SwDocShell::ConvertFrom( SfxMedium& rMedium )
return false; // #129881# return if no reader is found
tools::SvRef<SotStorage> pStg=pRead->getSotStorageRef(); // #i45333# save sot storage ref in case of recursive calls
- m_pDoc->setDocAccTitle(OUString());
+ m_xDoc->setDocAccTitle(OUString());
SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this );
if (pFrame1)
{
@@ -253,24 +253,24 @@ bool SwDocShell::ConvertFrom( SfxMedium& rMedium )
pRdr->GetDoc()->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, dynamic_cast< const SwWebDocShell *>( this ) != nullptr);
// Restore the pool default if reading a saved document.
- m_pDoc->RemoveAllFormatLanguageDependencies();
+ m_xDoc->RemoveAllFormatLanguageDependencies();
ErrCode nErr = pRdr->Read( *pRead );
// Maybe put away one old Doc
- if (m_pDoc != pRdr->GetDoc())
+ if (m_xDoc.get() != pRdr->GetDoc())
{
RemoveLink();
- m_pDoc = pRdr->GetDoc();
+ m_xDoc = pRdr->GetDoc();
AddLink();
if (!m_xBasePool.is())
- m_xBasePool = new SwDocStyleSheetPool( *m_pDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
+ m_xBasePool = new SwDocStyleSheetPool( *m_xDoc, SfxObjectCreateMode::ORGANIZER == GetCreateMode() );
}
UpdateFontList();
- InitDrawModelAndDocShell(this, m_pDoc ? m_pDoc->getIDocumentDrawModelAccess().GetDrawModel() : nullptr);
+ InitDrawModelAndDocShell(this, m_xDoc ? m_xDoc->getIDocumentDrawModelAccess().GetDrawModel() : nullptr);
delete pRdr;
@@ -279,7 +279,7 @@ bool SwDocShell::ConvertFrom( SfxMedium& rMedium )
SetError(nErr);
bool bOk = !nErr.IsError();
- if (bOk && !m_pDoc->IsInLoadAsynchron())
+ if (bOk && !m_xDoc->IsInLoadAsynchron())
{
LoadingFinished();
}
@@ -300,11 +300,11 @@ bool SwDocShell::Save()
CalcLayoutForOLEObjects(); // format for OLE objects
// #i62875#
// reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible
- if (m_pWrtShell && m_pDoc &&
- m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
- docfunc::AllDrawObjsOnPage(*m_pDoc))
+ if (m_pWrtShell && m_xDoc.get() &&
+ m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
+ docfunc::AllDrawObjsOnPage(*m_xDoc))
{
- m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
+ m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
}
ErrCode nErr = ERR_SWG_WRITE_ERROR, nVBWarning = ERRCODE_NONE;
@@ -321,7 +321,7 @@ bool SwDocShell::Save()
WriterRef xWrt;
::GetXMLWriter( aEmptyOUStr, GetMedium()->GetBaseURL( true ), xWrt );
xWrt->SetOrganizerMode( true );
- SwWriter aWrt( *GetMedium(), *m_pDoc );
+ SwWriter aWrt( *GetMedium(), *m_xDoc );
nErr = aWrt.Write( xWrt );
xWrt->SetOrganizerMode( false );
}
@@ -335,11 +335,11 @@ bool SwDocShell::Save()
case SfxObjectCreateMode::STANDARD:
default:
{
- if (m_pDoc->ContainsMSVBasic())
+ if (m_xDoc->ContainsMSVBasic())
{
if( SvtFilterOptions::Get().IsLoadWordBasicStorage() )
nVBWarning = GetSaveWarningOfMSVBAStorage( static_cast<SfxObjectShell&>(*this) );
- m_pDoc->SetContainsMSVBasic( false );
+ m_xDoc->SetContainsMSVBasic( false );
}
// End TableBox Edit!
@@ -356,7 +356,7 @@ bool SwDocShell::Save()
m_pWrtShell->LockView( true ); //lock visible section
}
- SwWriter aWrt( *GetMedium(), *m_pDoc );
+ SwWriter aWrt( *GetMedium(), *m_xDoc );
nErr = aWrt.Write( xWrt );
if (m_pWrtShell)
@@ -393,8 +393,8 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
m_pView->GetPostItMgr()->UpdateDataOnActiveSidebarWin();
}
- if (m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT) &&
- !m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT_SAVE_LINKS))
+ if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT) &&
+ !m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::GLOBAL_DOCUMENT_SAVE_LINKS))
RemoveOLEObjects();
{
@@ -420,7 +420,7 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
CalcLayoutForOLEObjects(); // format for OLE objects
bool bURLChanged = !GetMedium() || GetMedium()->GetURLObject() != rMedium.GetURLObject();
- if (!m_pDoc->GetDBManager()->getEmbeddedName().isEmpty() && bURLChanged)
+ if (!m_xDoc->GetDBManager()->getEmbeddedName().isEmpty() && bURLChanged)
{
// We have an embedded data source definition, need to re-store it,
// otherwise relative references will break when the new file is in a
@@ -430,20 +430,20 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
const INetURLObject& rOldURLObject = GetMedium()->GetURLObject();
OUString aURL = "vnd.sun.star.pkg://";
aURL += INetURLObject::encode(rOldURLObject.GetMainURL(INetURLObject::DecodeMechanism::WithCharset), INetURLObject::PART_AUTHORITY, INetURLObject::EncodeMechanism::All);
- aURL += "/" + INetURLObject::encode(m_pDoc->GetDBManager()->getEmbeddedName(), INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
+ aURL += "/" + INetURLObject::encode(m_xDoc->GetDBManager()->getEmbeddedName(), INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
uno::Reference<sdb::XDocumentDataSource> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY);
uno::Reference<frame::XStorable> xStorable(xDataSource->getDatabaseDocument(), uno::UNO_QUERY);
- SwDBManager::StoreEmbeddedDataSource(xStorable, rMedium.GetOutputStorage(), m_pDoc->GetDBManager()->getEmbeddedName(), rMedium.GetName());
+ SwDBManager::StoreEmbeddedDataSource(xStorable, rMedium.GetOutputStorage(), m_xDoc->GetDBManager()->getEmbeddedName(), rMedium.GetName());
}
// #i62875#
// reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible
if (m_pWrtShell &&
- m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
- docfunc::AllDrawObjsOnPage(*m_pDoc))
+ m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
+ docfunc::AllDrawObjsOnPage(*m_xDoc))
{
- m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
+ m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
}
ErrCode nErr = ERR_SWG_WRITE_ERROR, nVBWarning = ERRCODE_NONE;
@@ -460,11 +460,11 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
xDocSh->DoClose();
}
- if (m_pDoc->ContainsMSVBasic())
+ if (m_xDoc->ContainsMSVBasic())
{
if( SvtFilterOptions::Get().IsLoadWordBasicStorage() )
nVBWarning = GetSaveWarningOfMSVBAStorage( static_cast<SfxObjectShell&>(*this) );
- m_pDoc->SetContainsMSVBasic( false );
+ m_xDoc->SetContainsMSVBasic( false );
}
// End TableBox Edit!
@@ -473,10 +473,10 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
// Remember and preserve Modified-Flag without calling the Link
// (for OLE; after Statement from MM)
- const bool bIsModified = m_pDoc->getIDocumentState().IsModified();
- m_pDoc->GetIDocumentUndoRedo().LockUndoNoModifiedPosition();
- Link<bool,void> aOldOLELnk( m_pDoc->GetOle2Link() );
- m_pDoc->SetOle2Link( Link<bool,void>() );
+ const bool bIsModified = m_xDoc->getIDocumentState().IsModified();
+ m_xDoc->GetIDocumentUndoRedo().LockUndoNoModifiedPosition();
+ Link<bool,void> aOldOLELnk( m_xDoc->GetOle2Link() );
+ m_xDoc->SetOle2Link( Link<bool,void>() );
// Suppress SfxProgress when we are Embedded
SW_MOD()->SetEmbeddedLoadSave(
@@ -492,7 +492,7 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
m_pWrtShell->LockView( true ); //lock visible section
}
- SwWriter aWrt( rMedium, *m_pDoc );
+ SwWriter aWrt( rMedium, *m_xDoc );
nErr = aWrt.Write( xWrt );
if (m_pWrtShell)
@@ -500,17 +500,17 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
if( bIsModified )
{
- m_pDoc->getIDocumentState().SetModified();
- m_pDoc->GetIDocumentUndoRedo().UnLockUndoNoModifiedPosition();
+ m_xDoc->getIDocumentState().SetModified();
+ m_xDoc->GetIDocumentUndoRedo().UnLockUndoNoModifiedPosition();
}
- m_pDoc->SetOle2Link( aOldOLELnk );
+ m_xDoc->SetOle2Link( aOldOLELnk );
SW_MOD()->SetEmbeddedLoadSave( false );
// Increase RSID
- m_pDoc->setRsid( m_pDoc->getRsid() );
+ m_xDoc->setRsid( m_xDoc->getRsid() );
- m_pDoc->cleanupUnoCursorTable();
+ m_xDoc->cleanupUnoCursorTable();
}
SetError(nErr ? nErr : nVBWarning);
@@ -554,7 +554,7 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium )
ErrCode nVBWarning = ERRCODE_NONE;
- if (m_pDoc->ContainsMSVBasic())
+ if (m_xDoc->ContainsMSVBasic())
{
bool bSave = pFlt->GetUserData() == "CWW8"
&& SvtFilterOptions::Get().IsLoadWordBasicStorage();
@@ -567,7 +567,7 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium )
{
nVBWarning = SaveOrDelMSVBAStorage( static_cast<SfxObjectShell&>(*this), *xStg, bSave, "Macros" );
xStg->Commit();
- m_pDoc->SetContainsMSVBasic( true );
+ m_xDoc->SetContainsMSVBasic( true );
}
}
}
@@ -606,16 +606,16 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium )
// #i76360# Update document statistics
if ( !rMedium.IsSkipImages() )
- m_pDoc->getIDocumentStatistics().UpdateDocStat( false, true );
+ m_xDoc->getIDocumentStatistics().UpdateDocStat( false, true );
CalcLayoutForOLEObjects(); // format for OLE objects
// #i62875#
// reset compatibility flag <DoNotCaptureDrawObjsOnPage>, if possible
if (m_pWrtShell &&
- m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
- docfunc::AllDrawObjsOnPage(*m_pDoc))
+ m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) &&
+ docfunc::AllDrawObjsOnPage(*m_xDoc))
{
- m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
+ m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
}
if( xWriter->IsStgWriter() &&
@@ -745,7 +745,7 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium )
}
else
{
- SwWriter aWrt( rMedium, *m_pDoc );
+ SwWriter aWrt( rMedium, *m_xDoc );
nErrno = aWrt.Write( xWriter, &aFileName );
}
}
@@ -767,9 +767,9 @@ bool SwDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor
{
// Do not decide until here, whether Saving was successful or not
if( IsModified() )
- m_pDoc->getIDocumentState().SetModified();
+ m_xDoc->getIDocumentState().SetModified();
else
- m_pDoc->getIDocumentState().ResetModified();
+ m_xDoc->getIDocumentState().ResetModified();
}
if (m_pOLEChildList)
@@ -810,10 +810,10 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
JobSetup *pOrig = nullptr;
if ( !rSetup.GetPrinterName().isEmpty() && ASPECT_THUMBNAIL != nAspect )
{
- pOrig = const_cast<JobSetup*>(m_pDoc->getIDocumentDeviceAccess().getJobsetup());
+ pOrig = const_cast<JobSetup*>(m_xDoc->getIDocumentDeviceAccess().getJobsetup());
if( pOrig ) // then we copy that
pOrig = new JobSetup( *pOrig );
- m_pDoc->getIDocumentDeviceAccess().setJobsetup( rSetup );
+ m_xDoc->getIDocumentDeviceAccess().setJobsetup( rSetup );
}
tools::Rectangle aRect( nAspect == ASPECT_THUMBNAIL ?
@@ -825,12 +825,12 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
pDev->SetBackground();
const bool bWeb = dynamic_cast< const SwWebDocShell *>( this ) != nullptr;
SwPrintData aOpts;
- SwViewShell::PrtOle2(m_pDoc, SW_MOD()->GetUsrPref(bWeb), aOpts, *pDev, aRect);
+ SwViewShell::PrtOle2(m_xDoc.get(), SW_MOD()->GetUsrPref(bWeb), aOpts, *pDev, aRect);
pDev->Pop();
if( pOrig )
{
- m_pDoc->getIDocumentDeviceAccess().setJobsetup( *pOrig );
+ m_xDoc->getIDocumentDeviceAccess().setJobsetup( *pOrig );
delete pOrig;
}
if ( bResetModified )
@@ -866,8 +866,8 @@ tools::Rectangle SwDocShell::GetVisArea( sal_uInt16 nAspect ) const
if ( nAspect == ASPECT_THUMBNAIL )
{
// Preview: set VisArea to the first page.
- SwNodeIndex aIdx( m_pDoc->GetNodes().GetEndOfExtras(), 1 );
- SwContentNode* pNd = m_pDoc->GetNodes().GoNext( &aIdx );
+ SwNodeIndex aIdx( m_xDoc->GetNodes().GetEndOfExtras(), 1 );
+ SwContentNode* pNd = m_xDoc->GetNodes().GoNext( &aIdx );
const SwRect aPageRect = pNd->FindPageFrameRect();
tools::Rectangle aRect(aPageRect.SVRect());
@@ -886,12 +886,12 @@ tools::Rectangle SwDocShell::GetVisArea( sal_uInt16 nAspect ) const
Printer *SwDocShell::GetDocumentPrinter()
{
- return m_pDoc->getIDocumentDeviceAccess().getPrinter( false );
+ return m_xDoc->getIDocumentDeviceAccess().getPrinter( false );
}
OutputDevice* SwDocShell::GetDocumentRefDev()
{
- return m_pDoc->getIDocumentDeviceAccess().getReferenceDevice( false );
+ return m_xDoc->getIDocumentDeviceAccess().getReferenceDevice( false );
}
void SwDocShell::OnDocumentPrinterChanged( Printer * pNewPrinter )
@@ -1029,7 +1029,7 @@ void SwDocShell::GetState(SfxItemSet& rSet)
case SID_ATTR_YEAR2000:
{
- const SvNumberFormatter* pFormatr = m_pDoc->GetNumberFormatter(false);
+ const SvNumberFormatter* pFormatr = m_xDoc->GetNumberFormatter(false);
rSet.Put( SfxUInt16Item( nWhich,
static_cast< sal_uInt16 >(
pFormatr ? pFormatr->GetYear2000()
@@ -1044,8 +1044,8 @@ void SwDocShell::GetState(SfxItemSet& rSet)
case SID_MAIL_PREPAREEXPORT:
{
//check if linked content or possibly hidden content is available
- //m_pDoc->UpdateFields( NULL, false );
- sfx2::LinkManager& rLnkMgr = m_pDoc->getIDocumentLinksAdministration().GetLinkManager();
+ //m_xDoc->UpdateFields( NULL, false );
+ sfx2::LinkManager& rLnkMgr = m_xDoc->getIDocumentLinksAdministration().GetLinkManager();
const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks();
bool bRet = false;
if( !rLnks.empty() )
@@ -1053,7 +1053,7 @@ void SwDocShell::GetState(SfxItemSet& rSet)
else
{
//sections with hidden flag, hidden character attribute, hidden paragraph/text or conditional text fields
- bRet = m_pDoc->HasInvisibleContent();
+ bRet = m_xDoc->HasInvisibleContent();
}
rSet.Put( SfxBoolItem( nWhich, bRet ) );
}
@@ -1126,7 +1126,7 @@ void SwDocShell::LoadingFinished()
// enables the document modification again.
// Thus, manual modify the document, if it's modified and its links are updated
// before <FinishedLoading(..)> is called.
- const bool bHasDocToStayModified( m_pDoc->getIDocumentState().IsModified() && m_pDoc->getIDocumentLinksAdministration().LinksUpdated() );
+ const bool bHasDocToStayModified( m_xDoc->getIDocumentState().IsModified() && m_xDoc->getIDocumentLinksAdministration().LinksUpdated() );
FinishedLoading();
SfxViewFrame* pVFrame = SfxViewFrame::GetFirst(this);
@@ -1138,9 +1138,9 @@ void SwDocShell::LoadingFinished()
}
// #i38810#
- if ( bHasDocToStayModified && !m_pDoc->getIDocumentState().IsModified() )
+ if ( bHasDocToStayModified && !m_xDoc->getIDocumentState().IsModified() )
{
- m_pDoc->getIDocumentState().SetModified();
+ m_xDoc->getIDocumentState().SetModified();
}
}
@@ -1162,7 +1162,7 @@ void SwDocShell::SetFormatSpecificCompatibilityOptions( const OUString& rFilterT
void SwDocShell::CancelTransfers()
{
// Cancel all links from LinkManager
- m_pDoc->getIDocumentLinksAdministration().GetLinkManager().CancelTransfers();
+ m_xDoc->getIDocumentLinksAdministration().GetLinkManager().CancelTransfers();
SfxObjectShell::CancelTransfers();
}
@@ -1178,7 +1178,7 @@ SwFEShell* SwDocShell::GetFEShell()
void SwDocShell::RemoveOLEObjects()
{
- SwIterator<SwContentNode,SwFormatColl> aIter( *m_pDoc->GetDfltGrfFormatColl() );
+ SwIterator<SwContentNode,SwFormatColl> aIter( *m_xDoc->GetDfltGrfFormatColl() );
for( SwContentNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
{
SwOLENode* pOLENd = pNd->GetOLENode();
@@ -1206,7 +1206,7 @@ void SwDocShell::CalcLayoutForOLEObjects()
if (!m_pWrtShell)
return;
- SwIterator<SwContentNode,SwFormatColl> aIter( *m_pDoc->GetDfltGrfFormatColl() );
+ SwIterator<SwContentNode,SwFormatColl> aIter( *m_xDoc->GetDfltGrfFormatColl() );
for( SwContentNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
{
SwOLENode* pOLENd = pNd->GetOLENode();
@@ -1278,7 +1278,7 @@ OUString SwDocShell::GetEventName( sal_Int32 nIndex )
const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const
{
- return m_pDoc ? &m_pDoc->GetXmlIdRegistry() : nullptr;
+ return m_xDoc.get() ? &m_xDoc->GetXmlIdRegistry() : nullptr;
}
bool SwDocShell::IsChangeRecording() const
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 3deb35e4690d..9e3f51b03c0f 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -195,7 +195,7 @@ void SwDocShell::ToggleLayoutMode(SwView* pView)
// update text fields on document properties changes
void SwDocShell::DoFlushDocInfo()
{
- if (!m_pDoc) return;
+ if (!m_xDoc.get()) return;
bool bUnlockView(true);
if (m_pWrtShell)
@@ -205,7 +205,7 @@ void SwDocShell::DoFlushDocInfo()
m_pWrtShell->StartAllAction();
}
- m_pDoc->getIDocumentStatistics().DocInfoChgd(IsEnableSetModified());
+ m_xDoc->getIDocumentStatistics().DocInfoChgd(IsEnableSetModified());
if (m_pWrtShell)
{
@@ -239,13 +239,13 @@ static void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVB
// Notification on DocInfo changes
void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- if (!m_pDoc)
+ if (!m_xDoc.get())
{
return ;
}
uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
- m_pDoc->GetVbaEventProcessor();
+ m_xDoc->GetVbaEventProcessor();
if( xVbaEvents.is() )
lcl_processCompatibleSfxHint( xVbaEvents, rHint );
@@ -278,7 +278,7 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
switch( nAction )
{
case 2:
- m_pDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Filename )->UpdateFields();
+ m_xDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Filename )->UpdateFields();
break;
// #i38126# - own action for event LOADFINISHED
// in order to avoid a modified document.
@@ -291,14 +291,14 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
if ( bResetModified )
EnableSetModified( false );
// #i41679#
- const bool bIsDocModified = m_pDoc->getIDocumentState().IsModified();
+ const bool bIsDocModified = m_xDoc->getIDocumentState().IsModified();
// TODO: is the ResetModified() below because of only the direct call from DocInfoChgd, or does UpdateFields() set it too?
- m_pDoc->getIDocumentStatistics().DocInfoChgd(false);
+ m_xDoc->getIDocumentStatistics().DocInfoChgd(false);
// #i41679#
if ( !bIsDocModified )
- m_pDoc->getIDocumentState().ResetModified();
+ m_xDoc->getIDocumentState().ResetModified();
if ( bResetModified )
EnableSetModified();
}
@@ -322,10 +322,10 @@ bool SwDocShell::PrepareClose( bool bUI )
if( bRet )
EndListening( *this );
- if (m_pDoc && IsInPrepareClose())
+ if (m_xDoc && IsInPrepareClose())
{
uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
- m_pDoc->GetVbaEventProcessor();
+ m_xDoc->GetVbaEventProcessor();
if( xVbaEvents.is() )
{
using namespace com::sun::star::script::vba::VBAEventId;
@@ -709,7 +709,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
xDocSh->DoInitNew();
bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich;
- m_pDoc->Summary( pSmryDoc, nLevel, nPara, bImpress );
+ m_xDoc->Summary( pSmryDoc, nLevel, nPara, bImpress );
if( bImpress )
{
WriterRef xWrt;
@@ -835,12 +835,12 @@ void SwDocShell::Execute(SfxRequest& rReq)
//pWrtShell is not set in page preview
if (m_pWrtShell)
m_pWrtShell->StartAllAction();
- m_pDoc->getIDocumentFieldsAccess().UpdateFields( false );
- m_pDoc->getIDocumentLinksAdministration().EmbedAllLinks();
+ m_xDoc->getIDocumentFieldsAccess().UpdateFields( false );
+ m_xDoc->getIDocumentLinksAdministration().EmbedAllLinks();
m_IsRemovedInvisibleContent
= officecfg::Office::Security::HiddenContent::RemoveHiddenContent::get();
if (m_IsRemovedInvisibleContent)
- m_pDoc->RemoveInvisibleContent();
+ m_xDoc->RemoveInvisibleContent();
if (m_pWrtShell)
m_pWrtShell->EndAllAction();
}
@@ -852,7 +852,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
m_pWrtShell->StartAllAction();
//try to undo the removal of invisible content
if (m_IsRemovedInvisibleContent)
- m_pDoc->RestoreInvisibleContent();
+ m_xDoc->RestoreInvisibleContent();
if (m_pWrtShell)
m_pWrtShell->EndAllAction();
}
@@ -962,7 +962,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
bool bOutline[MAXLEVEL] = {false};
- const SwOutlineNodes& rOutlNds = m_pDoc->GetNodes().GetOutLineNds();
+ const SwOutlineNodes& rOutlNds = m_xDoc->GetNodes().GetOutLineNds();
if( !rOutlNds.empty() )
{
for( size_t n = 0; n < rOutlNds.size(); ++n )
@@ -975,7 +975,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
}
}
- const sal_uInt16 nStyleCount = m_pDoc->GetTextFormatColls()->size();
+ const sal_uInt16 nStyleCount = m_xDoc->GetTextFormatColls()->size();
Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
OUString* pEntries = aListBoxEntries.getArray();
sal_Int32 nIdx = 0 ;
@@ -990,7 +990,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
OUString sStyle( SwResId(STR_FDLG_STYLE) );
for(sal_uInt16 i = 0; i < nStyleCount; ++i)
{
- SwTextFormatColl &rTextColl = *(*m_pDoc->GetTextFormatColls())[ i ];
+ SwTextFormatColl &rTextColl = *(*m_xDoc->GetTextFormatColls())[ i ];
if( !rTextColl.IsDefault() && rTextColl.IsAtDocNodeSet() )
{
pEntries[nIdx++] = sStyle + rTextColl.GetName();
@@ -1060,17 +1060,17 @@ void SwDocShell::Execute(SfxRequest& rReq)
if ( bCreateByOutlineLevel )
{
bDone = bCreateHtml
- ? m_pDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
- : m_pDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
+ ? m_xDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
+ : m_xDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
}
else
{
const SwTextFormatColl* pSplitColl = nullptr;
if ( !aTemplateName.isEmpty() )
- pSplitColl = m_pDoc->FindTextFormatCollByName(aTemplateName);
+ pSplitColl = m_xDoc->FindTextFormatCollByName(aTemplateName);
bDone = bCreateHtml
- ? m_pDoc->GenerateHTMLDoc( aFileName, pSplitColl )
- : m_pDoc->GenerateGlobalDoc( aFileName, pSplitColl );
+ ? m_xDoc->GenerateHTMLDoc( aFileName, pSplitColl )
+ : m_xDoc->GenerateGlobalDoc( aFileName, pSplitColl );
}
if( bDone )
{
@@ -1126,7 +1126,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
pViewShell = pVFrame ? pVFrame->GetViewShell() : nullptr;
pCurrView = dynamic_cast<SwView*>( pViewShell );
}
- m_pDoc->GetNumberFormatter()->SetYear2000(nYear2K);
+ m_xDoc->GetNumberFormatter()->SetYear2000(nYear2K);
}
break;
case FN_OPEN_FILE:
@@ -1250,27 +1250,27 @@ void SwDocShell::Execute(SfxRequest& rReq)
bool SwDocShell::DdeGetData( const OUString& rItem, const OUString& rMimeType,
uno::Any & rValue )
{
- return m_pDoc->getIDocumentLinksAdministration().GetData( rItem, rMimeType, rValue );
+ return m_xDoc->getIDocumentLinksAdministration().GetData( rItem, rMimeType, rValue );
}
bool SwDocShell::DdeSetData( const OUString& rItem, const OUString& rMimeType,
const uno::Any & rValue )
{
- return m_pDoc->getIDocumentLinksAdministration().SetData( rItem, rMimeType, rValue );
+ return m_xDoc->getIDocumentLinksAdministration().SetData( rItem, rMimeType, rValue );
}
#endif
::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const OUString& rItem )
{
- return m_pDoc->getIDocumentLinksAdministration().CreateLinkSource( rItem );
+ return m_xDoc->getIDocumentLinksAdministration().CreateLinkSource( rItem );
}
void SwDocShell::ReconnectDdeLink(SfxObjectShell& rServer)
{
- if (m_pDoc)
+ if (m_xDoc)
{
- ::sfx2::LinkManager& rLinkManager = m_pDoc->getIDocumentLinksAdministration().GetLinkManager();
+ ::sfx2::LinkManager& rLinkManager = m_xDoc->getIDocumentLinksAdministration().GetLinkManager();
rLinkManager.ReconnectDdeLink(rServer);
}
}
@@ -1297,7 +1297,7 @@ void SwDocShell::FillClass( SvGlobalName * pClassName,
}
// #FIXME check with new Event handling
#if 0
- uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper = m_pDoc->GetVbaEventsHelper();
+ uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper = m_xDoc->GetVbaEventsHelper();
if( xVbaEventsHelper.is() )
lcl_processCompatibleSfxHint( xVbaEventsHelper, rHint );
#endif
@@ -1312,20 +1312,20 @@ void SwDocShell::SetModified( bool bSet )
SfxObjectShell::SetModified( bSet );
if( IsEnableSetModified())
{
- if (!m_pDoc->getIDocumentState().IsInCallModified())
+ if (!m_xDoc->getIDocumentState().IsInCallModified())
{
EnableSetModified( false );
if( bSet )
{
- bool const bOld = m_pDoc->getIDocumentState().IsModified();
- m_pDoc->getIDocumentState().SetModified();
+ bool const bOld = m_xDoc->getIDocumentState().IsModified();
+ m_xDoc->getIDocumentState().SetModified();
if( !bOld )
{
- m_pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+ m_xDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
}
}
else
- m_pDoc->getIDocumentState().ResetModified();
+ m_xDoc->getIDocumentState().ResetModified();
EnableSetModified();
}
@@ -1416,7 +1416,7 @@ void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcVie
}
}
#endif
- bool bWasBrowseMode = m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
+ bool bWasBrowseMode = m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
RemoveLink();
// now also the UNO-Model has to be informed about the new Doc #51535#
@@ -1427,7 +1427,7 @@ void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcVie
AddLink();
//#116402# update font list when new document is created
UpdateFontList();
- m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::BROWSE_MODE, bWasBrowseMode);
+ m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::BROWSE_MODE, bWasBrowseMode);
pSrcView->SetPool(&GetPool());
const OUString& rMedname = GetMedium()->GetName();
@@ -1447,7 +1447,7 @@ void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcVie
// the base URL has to be set to the filename of the document <rMedname>
// and not to the base URL of the temporary file <aMed> in order to get
// the URLs of the linked graphics correctly resolved.
- SwReloadFromHtmlReader aReader( aMed, rMedname, m_pDoc );
+ SwReloadFromHtmlReader aReader( aMed, rMedname, m_xDoc.get() );
aReader.Read( *ReadHTML );
@@ -1469,7 +1469,7 @@ void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcVie
if(bModified && !IsReadOnly())
SetModified();
else
- m_pDoc->getIDocumentState().ResetModified();
+ m_xDoc->getIDocumentState().ResetModified();
}
ErrCode SwDocShell::LoadStylesFromFile( const OUString& rURL,
@@ -1525,7 +1525,7 @@ ErrCode SwDocShell::LoadStylesFromFile( const OUString& rURL,
// insert the styles!
if( bUnoCall )
{
- SwNodeIndex aIdx( m_pDoc->GetNodes().GetEndOfContent(), -1 );
+ SwNodeIndex aIdx( m_xDoc->GetNodes().GetEndOfContent(), -1 );
pPam.reset(new SwPaM( aIdx ));
pReader.reset(new SwReader( aMed, rURL, *pPam ));
}
@@ -1542,7 +1542,7 @@ ErrCode SwDocShell::LoadStylesFromFile( const OUString& rURL,
if( bUnoCall )
{
- UnoActionContext aAction( m_pDoc );
+ UnoActionContext aAction( m_xDoc.get() );
nErr = pReader->Read( *pRead );
}
else
diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx
index 844dcdc0bde1..983a8a8bc633 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -108,7 +108,7 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
bool bHTMLTemplSet = false;
if( bRet )
{
- AddLink(); // create m_pDoc / pIo if applicable
+ AddLink(); // create m_xDoc / pIo if applicable
bool bWeb = dynamic_cast< const SwWebDocShell *>( this ) != nullptr;
if ( bWeb )
@@ -132,13 +132,13 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
ForbiddenCharacters aForbidden;
aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine);
LanguageType eLang = LanguageTag::convertToLanguageType(pLocales[i]);
- m_pDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden);
+ m_xDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden);
}
}
- m_pDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION,
+ m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION,
!aAsian.IsKerningWesternTextOnly());
- m_pDoc->getIDocumentSettingAccess().setCharacterCompressionType(aAsian.GetCharDistanceCompression());
- m_pDoc->getIDocumentDeviceAccess().setPrintData(*SW_MOD()->GetPrtOptions(bWeb));
+ m_xDoc->getIDocumentSettingAccess().setCharacterCompressionType(aAsian.GetCharDistanceCompression());
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list