diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/ndole.hxx | 15 | ||||
-rw-r--r-- | sw/source/core/ole/ndole.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/basflt/shellio.cxx | 6 |
3 files changed, 32 insertions, 3 deletions
diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx index 852fffd84e3d..b413d5af187d 100644 --- a/sw/inc/ndole.hxx +++ b/sw/inc/ndole.hxx @@ -168,6 +168,21 @@ inline const SwOLENode *SwNode::GetOLENode() const return SwNodeType::Ole == m_nNodeType ? static_cast<const SwOLENode*>(this) : nullptr; } +namespace sw +{ + class DocumentSettingManager; +} + +class SW_DLLPUBLIC PurgeGuard +{ +private: + ::sw::DocumentSettingManager &m_rManager; + bool m_bOrigPurgeOle; +public: + PurgeGuard(const SwDoc& rDoc); + ~PurgeGuard(); +}; + #endif // _ INCLUDED_SW_INC_NDOLE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index c66ff319ac93..27af55bd915c 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -984,6 +984,18 @@ bool SwOLEObj::UnloadObject() return bRet; } +PurgeGuard::PurgeGuard(const SwDoc& rDoc) + : m_rManager(const_cast<SwDoc&>(rDoc).GetDocumentSettingManager()) + , m_bOrigPurgeOle(m_rManager.get(DocumentSettingId::PURGE_OLE)) +{ + m_rManager.set(DocumentSettingId::PURGE_OLE, false); +} + +PurgeGuard::~PurgeGuard() +{ + m_rManager.set(DocumentSettingId::PURGE_OLE, m_bOrigPurgeOle); +} + bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xObj, const SwDoc* pDoc, sal_Int64 nAspect ) { if ( !pDoc ) @@ -1010,6 +1022,8 @@ bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xO { uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY ); assert(xPers.is() && "Modified object without persistence in cache!"); + + PurgeGuard aGuard(*pDoc); xPers->storeOwn(); } diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 708e13c2535b..0839b1c14df6 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -56,6 +56,7 @@ #include <poolfmt.hxx> #include <fltini.hxx> #include <docsh.hxx> +#include <ndole.hxx> #include <ndtxt.hxx> #include <redline.hxx> #include <swerror.h> @@ -847,8 +848,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa pESh->StartAllAction(); } - const bool bOrigPurgeOle = pOutDoc->getIDocumentSettingAccess().get(DocumentSettingId::PURGE_OLE); - pOutDoc->getIDocumentSettingAccess().set(DocumentSettingId::PURGE_OLE, false); + auto xGuard = std::make_unique<PurgeGuard>(*pOutDoc); ErrCode nError = ERRCODE_NONE; if( pMedium ) @@ -858,7 +858,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa else if( xStg.is() ) nError = rxWriter->Write( *pPam, xStg, pRealFileName ); - pOutDoc->getIDocumentSettingAccess().set(DocumentSettingId::PURGE_OLE, bOrigPurgeOle ); + xGuard.reset(); if( pESh ) { |