summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJian Fang Zhang <zhangjf@apache.org>2012-09-14 12:26:29 +0000
committerJian Fang Zhang <zhangjf@apache.org>2012-09-14 12:26:29 +0000
commitadc0946638e8817d5e57b0003b414249ac481df0 (patch)
tree9a339aab3cdd57f3b5f41628e5cffcb5b809970f
parent65409fefdc76adab22868c276d345c599432beaa (diff)
#i113606#, in SwDoc dtor to release the cyclic reference between XFormModel and bindings/submissions
Patch by: zhangjf Review by: zhangjf
Notes
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/source/core/doc/docnew.cxx2
-rw-r--r--sw/source/core/doc/docxforms.cxx53
3 files changed, 55 insertions, 2 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index fdcdb880b540..8eeaf36faa96 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -2082,6 +2082,8 @@ public:
void initXForms( bool bCreateDefaultModel );
// <-- #i31958# access methods for XForms model(s)
+ void disposeXForms( ); // #i113606#, for disposing XForms
+
// --> OD 2006-03-21 #b6375613#
inline bool ApplyWorkaroundForB6375613() const
{
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index e255cc5351d0..a5f70416061f 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -683,6 +683,8 @@ SwDoc::~SwDoc()
maListStyleLists.clear();
// <--
+ disposeXForms(); // #i113606#, dispose the XForms objects
+
delete pPrtData;
delete pNumberFormatter;
delete pFtnInfo;
diff --git a/sw/source/core/doc/docxforms.cxx b/sw/source/core/doc/docxforms.cxx
index 70412aaeecb0..26138a4e6063 100644
--- a/sw/source/core/doc/docxforms.cxx
+++ b/sw/source/core/doc/docxforms.cxx
@@ -37,7 +37,7 @@
#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
#include <unotools/processfactory.hxx>
#include <tools/diagnose_ex.h>
-
+#include <com/sun/star/container/XIndexAccess.hpp>
using namespace ::com::sun::star;
@@ -51,7 +51,7 @@ using xforms::XModel;
using frame::XModule;
using xforms::XFormsUIHelper1;
using rtl::OUString;
-
+using com::sun::star::container::XIndexAccess;
Reference<XNameContainer> SwDoc::getXForms() const
{
@@ -117,3 +117,52 @@ void SwDoc::initXForms( bool bCreateDefaultModel )
DBG_UNHANDLED_EXCEPTION();
}
}
+
+//
+// #i113606#, to release the cyclic reference between XFormModel and bindings/submissions.
+//
+void SwDoc::disposeXForms( )
+{
+ // get XForms models
+ if( xXForms.is() )
+ {
+ // iterate over all models
+ uno::Sequence<OUString> aNames = xXForms->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_Int32 nNames = aNames.getLength();
+ for( sal_Int32 n = 0; (n < nNames); n++ )
+ {
+ Reference< xforms::XModel > xModel(
+ xXForms->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 ));
+ }
+ }
+ }
+ }
+}