use rtl::Reference in SwDocFac
instead of manual acquire/release Change-Id: I40b4f6d2893fe0d4113032f638bce1793fc47cd7
This commit is contained in:
@@ -20,13 +20,14 @@
|
||||
#define INCLUDED_SW_INC_DOCFAC_HXX
|
||||
|
||||
#include <tools/solar.h>
|
||||
#include <rtl/ref.hxx>
|
||||
|
||||
class SwDoc;
|
||||
|
||||
class SW_DLLPUBLIC SwDocFac
|
||||
{
|
||||
protected:
|
||||
SwDoc* pDoc;
|
||||
rtl::Reference<SwDoc> mxDoc;
|
||||
|
||||
public:
|
||||
SwDocFac( SwDoc *pDoc = nullptr );
|
||||
|
@@ -25,28 +25,23 @@
|
||||
|
||||
|
||||
SwDocFac::SwDocFac( SwDoc *pDc )
|
||||
: pDoc( pDc )
|
||||
: mxDoc( pDc )
|
||||
{
|
||||
if( pDoc )
|
||||
pDoc->acquire();
|
||||
}
|
||||
|
||||
|
||||
SwDocFac::~SwDocFac()
|
||||
{
|
||||
if( pDoc && !pDoc->release() )
|
||||
delete pDoc;
|
||||
}
|
||||
|
||||
|
||||
SwDoc *SwDocFac::GetDoc()
|
||||
{
|
||||
if( !pDoc )
|
||||
if( !mxDoc.is() )
|
||||
{
|
||||
pDoc = new SwDoc;
|
||||
pDoc->acquire();
|
||||
mxDoc = new SwDoc;
|
||||
}
|
||||
return pDoc;
|
||||
return mxDoc.get();
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -88,11 +88,11 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
GetDoc();
|
||||
|
||||
// while reading, do not call OLE-Modified
|
||||
Link<bool,void> aOLELink( pDoc->GetOle2Link() );
|
||||
pDoc->SetOle2Link( Link<bool,void>() );
|
||||
Link<bool,void> aOLELink( mxDoc->GetOle2Link() );
|
||||
mxDoc->SetOle2Link( Link<bool,void>() );
|
||||
|
||||
pDoc->SetInReading( true );
|
||||
pDoc->SetInXMLImport( dynamic_cast< XMLReader* >(po) != nullptr );
|
||||
mxDoc->SetInReading( true );
|
||||
mxDoc->SetInXMLImport( dynamic_cast< XMLReader* >(po) != nullptr );
|
||||
|
||||
SwPaM *pPam;
|
||||
if( pCursor )
|
||||
@@ -100,13 +100,13 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
else
|
||||
{
|
||||
// if the Reader was not called by a Shell, create a PaM ourselves
|
||||
SwNodeIndex nNode( pDoc->GetNodes().GetEndOfContent(), -1 );
|
||||
SwNodeIndex nNode( mxDoc->GetNodes().GetEndOfContent(), -1 );
|
||||
pPam = new SwPaM( nNode );
|
||||
// For Web documents the default template was set already by InitNew,
|
||||
// unless the filter is not HTML,
|
||||
// or a SetTemplateName was called in ConvertFrom.
|
||||
if( !pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) || ReadHTML != po || !po->mxTemplate.is() )
|
||||
po->SetTemplate( *pDoc );
|
||||
if( !mxDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) || ReadHTML != po || !po->mxTemplate.is() )
|
||||
po->SetTemplate( *mxDoc );
|
||||
}
|
||||
|
||||
// Pams are connected like rings; stop when we return to the 1st element
|
||||
@@ -114,7 +114,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
SwUndoInsDoc* pUndo = nullptr;
|
||||
|
||||
bool bReadPageDescs = false;
|
||||
bool const bDocUndo = pDoc->GetIDocumentUndoRedo().DoesUndo();
|
||||
bool const bDocUndo = mxDoc->GetIDocumentUndoRedo().DoesUndo();
|
||||
bool bSaveUndo = bDocUndo && pCursor;
|
||||
if( bSaveUndo )
|
||||
{
|
||||
@@ -123,19 +123,19 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
if( bReadPageDescs )
|
||||
{
|
||||
bSaveUndo = false;
|
||||
pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
|
||||
mxDoc->GetIDocumentUndoRedo().DelAllUndoObj();
|
||||
}
|
||||
else
|
||||
{
|
||||
pDoc->GetIDocumentUndoRedo().ClearRedo();
|
||||
pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSDOKUMENT, nullptr );
|
||||
mxDoc->GetIDocumentUndoRedo().ClearRedo();
|
||||
mxDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSDOKUMENT, nullptr );
|
||||
}
|
||||
}
|
||||
pDoc->GetIDocumentUndoRedo().DoUndo(false);
|
||||
mxDoc->GetIDocumentUndoRedo().DoUndo(false);
|
||||
|
||||
SwNodeIndex aSplitIdx( pDoc->GetNodes() );
|
||||
SwNodeIndex aSplitIdx( mxDoc->GetNodes() );
|
||||
|
||||
RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
|
||||
RedlineFlags eOld = mxDoc->getIDocumentRedlineAccess().GetRedlineFlags();
|
||||
RedlineFlags ePostReadRedlineFlags( RedlineFlags::Ignore );
|
||||
|
||||
// Array of FlyFormats
|
||||
@@ -148,7 +148,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
if( bSaveUndo )
|
||||
pUndo = new SwUndoInsDoc( *pPam );
|
||||
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
|
||||
SwPaM* pUndoPam = nullptr;
|
||||
if( bDocUndo || pCursor )
|
||||
@@ -161,8 +161,8 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
// store for now all Fly's
|
||||
if( pCursor )
|
||||
{
|
||||
std::copy(pDoc->GetSpzFrameFormats()->begin(),
|
||||
pDoc->GetSpzFrameFormats()->end(), std::back_inserter(aFlyFrameArr));
|
||||
std::copy(mxDoc->GetSpzFrameFormats()->begin(),
|
||||
mxDoc->GetSpzFrameFormats()->end(), std::back_inserter(aFlyFrameArr));
|
||||
}
|
||||
|
||||
const sal_Int32 nSttContent = pPam->GetPoint()->nContent.GetIndex();
|
||||
@@ -172,21 +172,21 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
sal_Int32 nEndContent = pCNd ? pCNd->Len() - nSttContent : 0;
|
||||
SwNodeIndex aEndPos( pPam->GetPoint()->nNode, 1 );
|
||||
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
|
||||
nError = po->Read( *pDoc, sBaseURL, *pPam, aFileName );
|
||||
nError = po->Read( *mxDoc, sBaseURL, *pPam, aFileName );
|
||||
|
||||
// an ODF document may contain redline mode in settings.xml; save it!
|
||||
ePostReadRedlineFlags = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
|
||||
ePostReadRedlineFlags = mxDoc->getIDocumentRedlineAccess().GetRedlineFlags();
|
||||
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
|
||||
if( !IsError( nError )) // set the End position already
|
||||
{
|
||||
--aEndPos;
|
||||
pCNd = aEndPos.GetNode().GetContentNode();
|
||||
if( !pCNd && nullptr == ( pCNd = SwNodes::GoPrevious( &aEndPos ) ))
|
||||
pCNd = pDoc->GetNodes().GoNext( &aEndPos );
|
||||
pCNd = mxDoc->GetNodes().GoNext( &aEndPos );
|
||||
|
||||
pPam->GetPoint()->nNode = aEndPos;
|
||||
const sal_Int32 nLen = pCNd->Len();
|
||||
@@ -202,7 +202,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
SwTableBox* pBox = pTableBoxStart->GetTableBox();
|
||||
if ( pBox )
|
||||
{
|
||||
pDoc->ChkBoxNumFormat( *pBox, true );
|
||||
mxDoc->ChkBoxNumFormat( *pBox, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,9 +222,9 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
rNd.FindFooterStartNode();
|
||||
|
||||
// search all new Fly's, and store them as individual Undo Objects
|
||||
for( SwFrameFormats::size_type n = 0; n < pDoc->GetSpzFrameFormats()->size(); ++n )
|
||||
for( SwFrameFormats::size_type n = 0; n < mxDoc->GetSpzFrameFormats()->size(); ++n )
|
||||
{
|
||||
SwFrameFormat* pFrameFormat = (*pDoc->GetSpzFrameFormats())[ n ];
|
||||
SwFrameFormat* pFrameFormat = (*mxDoc->GetSpzFrameFormats())[ n ];
|
||||
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
|
||||
if( !aFlyFrameArr.Contains( pFrameFormat) )
|
||||
{
|
||||
@@ -245,7 +245,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
*pFrameAnchor,
|
||||
*pUndoPam->GetPoint(),
|
||||
*pUndoPam->GetMark(),
|
||||
pDoc)
|
||||
mxDoc.get())
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -257,20 +257,20 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
{
|
||||
// DrawObjects are not allowed in Headers/Footers!
|
||||
pFrameFormat->DelFrames();
|
||||
pDoc->DelFrameFormat( pFrameFormat );
|
||||
mxDoc->DelFrameFormat( pFrameFormat );
|
||||
--n;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( bSaveUndo )
|
||||
{
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
// UGLY: temp. enable undo
|
||||
pDoc->GetIDocumentUndoRedo().DoUndo(true);
|
||||
pDoc->GetIDocumentUndoRedo().AppendUndo(
|
||||
mxDoc->GetIDocumentUndoRedo().DoUndo(true);
|
||||
mxDoc->GetIDocumentUndoRedo().AppendUndo(
|
||||
new SwUndoInsLayFormat( pFrameFormat,0,0 ) );
|
||||
pDoc->GetIDocumentUndoRedo().DoUndo(false);
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
mxDoc->GetIDocumentUndoRedo().DoUndo(false);
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
}
|
||||
if( pFrameFormat->HasWriterListeners() )
|
||||
{
|
||||
@@ -286,7 +286,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
}
|
||||
else if( pCursor )
|
||||
{
|
||||
pDoc->SetContainsAtPageObjWithContentAnchor( true );
|
||||
mxDoc->SetContainsAtPageObjWithContentAnchor( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -298,22 +298,22 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
if( !aFlyFrameArr.empty() )
|
||||
aFlyFrameArr.clear();
|
||||
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
|
||||
pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, *pUndoPam ), true);
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
if( mxDoc->getIDocumentRedlineAccess().IsRedlineOn() )
|
||||
mxDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, *pUndoPam ), true);
|
||||
else
|
||||
pDoc->getIDocumentRedlineAccess().SplitRedline( *pUndoPam );
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
mxDoc->getIDocumentRedlineAccess().SplitRedline( *pUndoPam );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
}
|
||||
if( bSaveUndo )
|
||||
{
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
pUndo->SetInsertRange( *pUndoPam, false );
|
||||
// UGLY: temp. enable undo
|
||||
pDoc->GetIDocumentUndoRedo().DoUndo(true);
|
||||
pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo );
|
||||
pDoc->GetIDocumentUndoRedo().DoUndo(false);
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
mxDoc->GetIDocumentUndoRedo().DoUndo(true);
|
||||
mxDoc->GetIDocumentUndoRedo().AppendUndo( pUndo );
|
||||
mxDoc->GetIDocumentUndoRedo().DoUndo(false);
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
}
|
||||
|
||||
delete pUndoPam;
|
||||
@@ -338,25 +338,25 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
}
|
||||
}
|
||||
|
||||
pDoc->SetInReading( false );
|
||||
pDoc->SetInXMLImport( false );
|
||||
mxDoc->SetInReading( false );
|
||||
mxDoc->SetInXMLImport( false );
|
||||
|
||||
pDoc->InvalidateNumRules();
|
||||
pDoc->UpdateNumRule();
|
||||
pDoc->ChkCondColls();
|
||||
pDoc->SetAllUniqueFlyNames();
|
||||
pDoc->getIDocumentState().SetLoaded();
|
||||
mxDoc->InvalidateNumRules();
|
||||
mxDoc->UpdateNumRule();
|
||||
mxDoc->ChkCondColls();
|
||||
mxDoc->SetAllUniqueFlyNames();
|
||||
mxDoc->getIDocumentState().SetLoaded();
|
||||
// Clear unassigned cell styles, because they aren't needed anymore.
|
||||
pDoc->GetCellStyles().clear();
|
||||
mxDoc->GetCellStyles().clear();
|
||||
|
||||
pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
|
||||
mxDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
|
||||
if (!bReadPageDescs)
|
||||
{
|
||||
if( bSaveUndo )
|
||||
{
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSDOKUMENT, nullptr );
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
mxDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSDOKUMENT, nullptr );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,26 +368,26 @@ sal_uLong SwReader::Read( const Reader& rOptions )
|
||||
// #i42634# Moved common code of SwReader::Read() and
|
||||
// SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
|
||||
// ATM still with Update
|
||||
pDoc->getIDocumentLinksAdministration().UpdateLinks();
|
||||
mxDoc->getIDocumentLinksAdministration().UpdateLinks();
|
||||
|
||||
// not insert: set the redline mode read from settings.xml
|
||||
eOld = ePostReadRedlineFlags & ~RedlineFlags::Ignore;
|
||||
|
||||
pDoc->getIDocumentFieldsAccess().SetFieldsDirty(false, nullptr, 0);
|
||||
mxDoc->getIDocumentFieldsAccess().SetFieldsDirty(false, nullptr, 0);
|
||||
}
|
||||
|
||||
pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
pDoc->SetOle2Link( aOLELink );
|
||||
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
|
||||
mxDoc->SetOle2Link( aOLELink );
|
||||
|
||||
if( pCursor ) // das Doc ist jetzt modifiziert
|
||||
pDoc->getIDocumentState().SetModified();
|
||||
mxDoc->getIDocumentState().SetModified();
|
||||
// #i38810# - If links have been updated, the document
|
||||
// have to be modified. During update of links the OLE link at the document
|
||||
// isn't set. Thus, the document's modified state has to be set again after
|
||||
// the OLE link is restored - see above <pDoc->SetOle2Link( aOLELink )>.
|
||||
if ( pDoc->getIDocumentLinksAdministration().LinksUpdated() )
|
||||
// the OLE link is restored - see above <mxDoc->SetOle2Link( aOLELink )>.
|
||||
if ( mxDoc->getIDocumentLinksAdministration().LinksUpdated() )
|
||||
{
|
||||
pDoc->getIDocumentState().SetModified();
|
||||
mxDoc->getIDocumentState().SetModified();
|
||||
}
|
||||
|
||||
po->SetReadUTF8( false );
|
||||
|
Reference in New Issue
Block a user