diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-25 13:20:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-05-25 13:22:35 +0100 |
commit | fb5c25294efd2ef9138df61e82cd438ff07f4bf1 (patch) | |
tree | f52c6786cd5146608ed23146c91c82f5fade4784 | |
parent | 8607eca026061fbda4b7f89066813149c2230db9 (diff) |
Resolves: fdo#35937 temp ole docshell on dtor deletes SwDoc on 0 refcount
copy of ole objects creates a temp docshell, whose dtor on 0 ref count deletes
the SwDoc handle. So add an acquire/release pair.
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 0527ab95e7..6cc62a173a 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -1048,6 +1048,7 @@ void SwDoc::InitTOXTypes() SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const { SwDoc* pRet = new SwDoc; + //copy settings sal_uInt16 aRangeOfDefaults[] = { RES_FRMATR_BEGIN, RES_FRMATR_END-1, @@ -1058,22 +1059,24 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const 0 }; - SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults ); - - sal_uInt16 nWhich; - sal_uInt16 nRange = 0; - while( aRangeOfDefaults[nRange] != 0) { - for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich ) + SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults ); + + sal_uInt16 nWhich; + sal_uInt16 nRange = 0; + while( aRangeOfDefaults[nRange] != 0) { - const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); - if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) - aNewDefaults.Put( rSourceAttr ); + for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich ) + { + const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); + if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) + aNewDefaults.Put( rSourceAttr ); + } + nRange += 2; } - nRange += 2; + if( aNewDefaults.Count() ) + pRet->SetDefault( aNewDefaults ); } - if( aNewDefaults.Count() ) - pRet->SetDefault( aNewDefaults ); pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1; pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2; @@ -1117,12 +1120,16 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const pRetShell->DoInitNew(); } + pRet->acquire(); + //copy content pRet->Paste( *this ); // remove the temporary shell if it is there as it was done before pRet->SetTmpDocShell( (SfxObjectShell*)NULL ); + pRet->release(); + return pRetShell; } |