summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJian Fang Zhang <zhangjf@apache.org>2012-09-14 12:26:29 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-05 11:35:52 +0100
commit6e426582ec76be20c08d71ad7399b1bd008dfc75 (patch)
tree64f9f66af1fd099845f6c1cf5167d0681fe40b6a
parent64672827c078a7fb679d7062da032ee910c265b1 (diff)
Resolves: #i113606# in SwDoc dtor release the cyclic reference...
between XFormModel and bindings/submissions Patch by: zhangjf Review by: zhangjf (cherry picked from commit adc0946638e8817d5e57b0003b414249ac481df0) Conflicts: sw/inc/doc.hxx sw/source/core/doc/docnew.cxx sw/source/core/doc/docxforms.cxx Change-Id: I3124daea8925b1efd8e151f3064582786d461718
-rw-r--r--sw/inc/doc.hxx8
-rw-r--r--sw/source/core/doc/docnew.cxx2
-rw-r--r--sw/source/core/doc/docxforms.cxx51
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: */