diff options
-rw-r--r-- | sw/inc/doc.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docxforms.cxx | 51 |
3 files changed, 56 insertions, 5 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index f0b97f068010..c41615b15b75 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -2036,12 +2036,14 @@ public: com::sun::star::uno::Reference< com::sun::star::linguistic2::XProofreadingIterator > GetGCIterator() const; - /// is this an XForms document? + /// #i31958# is this an XForms document? bool isXForms() const; - /// initialize XForms models; turn this into an XForms document + /// #i31958# initialize XForms models; turn this into an XForms document void initXForms( bool bCreateDefaultModel ); - // access methods for XForms model(s) + + /// #i113606# for disposing XForms + void disposeXForms( ); //Update all the page masters void SetDefaultPageMode(bool bSquaredPageMode); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 94ebfeade346..9835e6d4636a 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -673,6 +673,8 @@ SwDoc::~SwDoc() } maListStyleLists.clear(); + disposeXForms(); // #i113606#, dispose the XForms objects + delete mpPrtData; delete mpNumberFormatter; delete mpFtnInfo; diff --git a/sw/source/core/doc/docxforms.cxx b/sw/source/core/doc/docxforms.cxx index e3d9601d0df1..416bc2e9853b 100644 --- a/sw/source/core/doc/docxforms.cxx +++ b/sw/source/core/doc/docxforms.cxx @@ -29,7 +29,7 @@ #include <com/sun/star/xforms/XForms.hpp> #include <comphelper/processfactory.hxx> #include <tools/diagnose_ex.h> - +#include <com/sun/star/container/XIndexAccess.hpp> using namespace ::com::sun::star; @@ -42,7 +42,7 @@ using container::XNameContainer; using xforms::XModel2; using frame::XModule; using xforms::XFormsUIHelper1; - +using com::sun::star::container::XIndexAccess; Reference<XNameContainer> SwDoc::getXForms() const { @@ -94,4 +94,51 @@ void SwDoc::initXForms( bool bCreateDefaultModel ) } } +// #i113606#, to release the cyclic reference between XFormModel and bindings/submissions. +void SwDoc::disposeXForms( ) +{ + // get XForms models + if( mxXForms.is() ) + { + // iterate over all models + uno::Sequence<OUString> aNames = mxXForms->getElementNames(); + const OUString* pNames = aNames.getConstArray(); + sal_Int32 nNames = aNames.getLength(); + for( sal_Int32 n = 0; (n < nNames); n++ ) + { + Reference< xforms::XModel > xModel( + mxXForms->getByName( pNames[n] ), UNO_QUERY ); + + if( xModel.is() ) + { + // ask model for bindings + Reference< XIndexAccess > xBindings( + xModel->getBindings(), UNO_QUERY ); + + // + // Then release them one by one + // + int nCount = xBindings->getCount(); + for( int i = nCount-1; i >= 0; i-- ) + { + xModel->getBindings()->remove(xBindings->getByIndex( i )); + } + + // ask model for Submissions + Reference< XIndexAccess > xSubmissions( + xModel->getSubmissions(), UNO_QUERY ); + + // + // Then release them one by one + // + nCount = xSubmissions->getCount(); + for( int i = nCount-1; i >= 0; i-- ) + { + xModel->getSubmissions()->remove(xSubmissions->getByIndex( i )); + } + } + } + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |