diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-03-23 09:33:59 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-03-23 10:43:43 +0000 |
commit | 3aeea4b98514e3f5976f8d0af7cd08fa23372730 (patch) | |
tree | 45c2454bcaf37802b5d30988f3a3e4e0ca433dd9 | |
parent | 2479aec5d30cfdbcb24ef8bc2ace67a74c8f4e75 (diff) |
global uno::Sequences are very problematic at shutdown time
because the underlying uno infrastructure has been shutdown already,
we need to ensure their lifecycle more carefully.
-rwxr-xr-x | editeng/inc/editeng/unotext.hxx | 9 | ||||
-rwxr-xr-x | editeng/source/uno/unotext.cxx | 106 | ||||
-rwxr-xr-x | editeng/source/uno/unotext2.cxx | 98 |
3 files changed, 122 insertions, 91 deletions
diff --git a/editeng/inc/editeng/unotext.hxx b/editeng/inc/editeng/unotext.hxx index 73e43d219967..4fd80927518d 100755 --- a/editeng/inc/editeng/unotext.hxx +++ b/editeng/inc/editeng/unotext.hxx @@ -373,9 +373,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; sal_Bool mbPortion; -protected: - static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence; - public: SvxUnoTextRange( const SvxUnoTextBase& rParent, sal_Bool bPortion = sal_False ) throw(); virtual ~SvxUnoTextRange() throw(); @@ -406,7 +403,6 @@ class EDITENG_DLLPUBLIC SvxUnoTextBase : public SvxUnoTextRangeBase, { protected: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence; public: SvxUnoTextBase( ) throw(); @@ -541,8 +537,6 @@ private: bool mbDisposing; protected: - static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence; - using SvxUnoTextRangeBase::setPropertyValue; using SvxUnoTextRangeBase::getPropertyValue; @@ -630,9 +624,6 @@ class EDITENG_DLLPUBLIC SvxUnoTextCursor : public SvxUnoTextRangeBase, private: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > mxParentText; -protected: - static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence; - public: SvxUnoTextCursor( const SvxUnoTextBase& rText ) throw(); SvxUnoTextCursor( const SvxUnoTextCursor& rCursor ) throw(); diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 624345ac99ef..66ce712b08d0 100755 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -40,6 +40,7 @@ #include <svl/eitem.hxx> #include <rtl/uuid.h> #include <rtl/memory.h> +#include <rtl/instance.hxx> #include <editeng/fontitem.hxx> #include <editeng/tstpitem.hxx> @@ -1523,8 +1524,6 @@ sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference< // class SvxUnoTextRange // ==================================================================== -uno::Sequence< uno::Type > SvxUnoTextRange::maTypeSequence; - uno::Reference< uno::XInterface > SvxUnoTextRange_NewInstance() { SvxUnoText aText; @@ -1586,25 +1585,37 @@ void SAL_CALL SvxUnoTextRange::release() // XTypeProvider +namespace +{ + struct theSvxUnoTextRangeTypes : + public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextRangeTypes> + { + uno::Sequence<uno::Type> operator () () + { + uno::Sequence< uno::Type > aTypeSequence; + + aTypeSequence.realloc( 9 ); // !DANGER! keep this updated + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); + + return aTypeSequence; + } + }; +} + uno::Sequence< uno::Type > SAL_CALL SvxUnoTextRange::getTypes() throw (uno::RuntimeException) { - if( maTypeSequence.getLength() == 0 ) - { - maTypeSequence.realloc( 9 ); // !DANGER! keep this updated - uno::Type* pTypes = maTypeSequence.getArray(); - - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); - } - return maTypeSequence; + return theSvxUnoTextRangeTypes::get(); } uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId() @@ -1637,10 +1648,6 @@ OUString SAL_CALL SvxUnoTextRange::getImplementationName() // class SvxUnoText // ==================================================================== -// UNO3_GETIMPLEMENTATION2_IMPL( SvxUnoText, SvxUnoTextRangeBase ); - -uno::Sequence< uno::Type > SvxUnoTextBase::maTypeSequence; - SvxUnoTextBase::SvxUnoTextBase() throw() : SvxUnoTextRangeBase( NULL ) { @@ -1732,30 +1739,41 @@ uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType ) // XTypeProvider -uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getStaticTypes() throw() +namespace { - if( maTypeSequence.getLength() == 0 ) + struct theSvxUnoTextBaseTypes : + public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextBaseTypes> { - maTypeSequence.realloc( 15 ); // !DANGER! keep this updated - uno::Type* pTypes = maTypeSequence.getArray(); - - *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XParagraphAppend >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextPortionAppend >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); - } - return maTypeSequence; + uno::Sequence<uno::Type> operator () () + { + uno::Sequence< uno::Type > aTypeSequence; + + aTypeSequence.realloc( 15 ); // !DANGER! keep this updated + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XParagraphAppend >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextPortionAppend >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); + + return aTypeSequence; + } + }; +} +uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getStaticTypes() throw() +{ + return theSvxUnoTextBaseTypes::get(); } uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getTypes() diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx index afadbe1404dc..ade10370dc88 100755 --- a/editeng/source/uno/unotext2.cxx +++ b/editeng/source/uno/unotext2.cxx @@ -36,6 +36,7 @@ #include <rtl/uuid.h> #include <rtl/memory.h> +#include <rtl/instance.hxx> #include <editeng/eeitem.hxx> #include <editeng/flditem.hxx> @@ -113,7 +114,6 @@ uno::Any SvxUnoTextContentEnumeration::nextElement(void) throw( container::NoSuc // class SvxUnoTextContent // ==================================================================== uno::Reference< text::XText > xDummyText; -uno::Sequence< uno::Type > SvxUnoTextContent::maTypeSequence; static SvxUnoText* getDummyText() throw() { @@ -200,27 +200,39 @@ void SAL_CALL SvxUnoTextContent::release() throw( ) // XTypeProvider +namespace +{ + struct theSvxUnoTextContentTypes : + public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextContentTypes> + { + uno::Sequence<uno::Type> operator () () + { + uno::Sequence< uno::Type > aTypeSequence; + + aTypeSequence.realloc( 11 ); // !DANGER! keep this updated + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextContent >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); + + return aTypeSequence; + } + }; +} + uno::Sequence< uno::Type > SAL_CALL SvxUnoTextContent::getTypes() throw (uno::RuntimeException) { - if( maTypeSequence.getLength() == 0 ) - { - maTypeSequence.realloc( 11 ); // !DANGER! keep this updated - uno::Type* pTypes = maTypeSequence.getArray(); - - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextContent >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); - } - return maTypeSequence; + return theSvxUnoTextContentTypes::get(); } uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextContent::getImplementationId() @@ -487,8 +499,6 @@ uno::Any SAL_CALL SvxUnoTextRangeEnumeration::nextElement() // class SvxUnoTextCursor // ==================================================================== -uno::Sequence< uno::Type > SvxUnoTextCursor::maTypeSequence; - uno::Reference< uno::XInterface > SvxUnoTextCursor_NewInstance() { SvxUnoText aText; @@ -553,27 +563,39 @@ void SAL_CALL SvxUnoTextCursor::release() throw ( ) OWeakAggObject::release(); } +namespace +{ + struct theSvxUnoTextCursorTypes : + public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextCursorTypes> + { + uno::Sequence<uno::Type> operator () () + { + uno::Sequence< uno::Type > aTypeSequence; + + aTypeSequence.realloc( 10 ); // !DANGER! keep this updated + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCursor >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); + + return aTypeSequence; + } + }; +} + // XTypeProvider uno::Sequence< uno::Type > SAL_CALL SvxUnoTextCursor::getTypes() throw(uno::RuntimeException) { - if( maTypeSequence.getLength() == 0 ) - { - maTypeSequence.realloc( 10 ); // !DANGER! keep this updated - uno::Type* pTypes = maTypeSequence.getArray(); - - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCursor >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); - *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); - } - return maTypeSequence; + return theSvxUnoTextCursorTypes::get(); } uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextCursor::getImplementationId() |