swunolocking1: #i105557#: fix locking for SwXTextSection:
replace SwXTextSectionClient with Impl struct, use UnoImplPtr to lock dtor. move all implementation details out of header, into Impl struct. remove ugly destruction of SwUnoCrsr via Application::PostUserEvent. replace broken SwClient iteration with a WeakReference in SwSectionFmt. add factory function CreateXTextSection. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little.
This commit is contained in:
parent
77ca8486db
commit
2fee7963e9
8 changed files with 1494 additions and 1279 deletions
|
@ -30,11 +30,14 @@
|
|||
#ifndef _FRMFMT_HXX
|
||||
#define _FRMFMT_HXX
|
||||
|
||||
#include <format.hxx>
|
||||
|
||||
// --> OD 2004-08-06 #i28749#
|
||||
#include <com/sun/star/text/PositionLayoutDir.hpp>
|
||||
// <--
|
||||
|
||||
#include <cppuhelper/weakref.hxx>
|
||||
|
||||
#include <format.hxx>
|
||||
|
||||
#include "swdllapi.h"
|
||||
|
||||
class SwFlyFrm;
|
||||
|
@ -51,8 +54,9 @@ class SW_DLLPUBLIC SwFrmFmt: public SwFmt
|
|||
{
|
||||
friend class SwDoc;
|
||||
friend class SwPageDesc; //darf den protected CTor rufen.
|
||||
// friend class SwSwgReader; // der SW2-Reader auch!
|
||||
// friend class Sw3IoImp; // der SW3-Reader auch!
|
||||
|
||||
::com::sun::star::uno::WeakReference<
|
||||
::com::sun::star::uno::XInterface> m_wXObject;
|
||||
|
||||
protected:
|
||||
SwFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
|
||||
|
@ -136,6 +140,13 @@ public:
|
|||
|
||||
virtual String GetDescription() const;
|
||||
|
||||
SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
|
||||
::com::sun::star::uno::XInterface> const& GetXObject() const
|
||||
{ return m_wXObject; }
|
||||
SW_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XInterface> const& xObject)
|
||||
{ m_wXObject = xObject; }
|
||||
|
||||
DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt)
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,11 @@
|
|||
#include <svtools/svarray.hxx>
|
||||
#include <frmfmt.hxx>
|
||||
|
||||
|
||||
namespace com { namespace sun { namespace star {
|
||||
namespace text { class XTextSection; }
|
||||
} } }
|
||||
|
||||
// Forward Deklaration
|
||||
class SwSectionFmt;
|
||||
class SwDoc;
|
||||
|
@ -230,6 +235,13 @@ class SW_DLLPUBLIC SwSectionFmt : public SwFrmFmt
|
|||
{
|
||||
friend class SwDoc;
|
||||
|
||||
/** why does this exist in addition to the m_wXObject in SwFrmFmt?
|
||||
in case of an index, both a SwXDocumentIndex and a SwXTextSection
|
||||
register at this SwSectionFmt, so we need to have two refs.
|
||||
*/
|
||||
::com::sun::star::uno::WeakReference<
|
||||
::com::sun::star::text::XTextSection> m_wXTextSection;
|
||||
|
||||
/* SW_DLLPUBLIC */ SwSection* _GetSection() const;
|
||||
SW_DLLPRIVATE void UpdateParent(); // Parent wurde veraendert
|
||||
|
||||
|
@ -271,6 +283,14 @@ public:
|
|||
|
||||
// ist die Section eine gueltige fuers GlobalDocument?
|
||||
const SwSection* GetGlobalDocSection() const;
|
||||
|
||||
SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
|
||||
::com::sun::star::text::XTextSection> const& GetXTextSection() const
|
||||
{ return m_wXTextSection; }
|
||||
SW_DLLPRIVATE void SetXTextSection(::com::sun::star::uno::Reference<
|
||||
::com::sun::star::text::XTextSection> const& xTextSection)
|
||||
{ m_wXTextSection = xTextSection; }
|
||||
|
||||
};
|
||||
|
||||
// -------------- inlines ---------------------------------
|
||||
|
|
|
@ -43,14 +43,9 @@
|
|||
|
||||
#include <cppuhelper/implbase7.hxx>
|
||||
|
||||
#include <tools/link.hxx>
|
||||
#include <tools/string.hxx>
|
||||
|
||||
#include <calbck.hxx>
|
||||
#include <unoevtlstnr.hxx>
|
||||
#include <unobaseclass.hxx>
|
||||
|
||||
|
||||
class SfxItemPropertySet;
|
||||
class SwSectionFmt;
|
||||
|
||||
|
||||
|
@ -58,51 +53,6 @@ class SwSectionFmt;
|
|||
|
||||
--------------------------------------------------*/
|
||||
|
||||
class SwXTextSection;
|
||||
|
||||
class SwXTextSectionClient
|
||||
: public SwClient
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
friend class SwXTextSection;
|
||||
|
||||
SwXTextSection * m_pSection;
|
||||
::com::sun::star::uno::WeakReference<
|
||||
::com::sun::star::text::XTextSection > m_xReference;
|
||||
|
||||
// SwClient
|
||||
virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew);
|
||||
|
||||
SwXTextSectionClient(
|
||||
SwSectionFmt& rFmt,
|
||||
SwXTextSection& rTextSection,
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::text::XTextSection > xSection);
|
||||
|
||||
virtual ~SwXTextSectionClient();
|
||||
|
||||
DECL_STATIC_LINK( SwXTextSectionClient, RemoveSectionClient_Impl,
|
||||
SwXTextSectionClient* );
|
||||
|
||||
public:
|
||||
|
||||
TYPEINFO();
|
||||
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection >
|
||||
GetXTextSection();
|
||||
|
||||
static ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::text::XTextSection >
|
||||
CreateXTextSection(SwSectionFmt* pFmt = 0, BOOL bIndexHeader = FALSE);
|
||||
static SwXTextSectionClient* Create(
|
||||
SwXTextSection& rSection,
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::text::XTextSection > xSection,
|
||||
SwSectionFmt& rFmt);
|
||||
};
|
||||
|
||||
|
||||
struct SwTextSectionProperties_Impl;
|
||||
|
||||
|
@ -122,57 +72,21 @@ class SwXTextSection
|
|||
|
||||
private:
|
||||
|
||||
friend class SwXTextSectionClient;
|
||||
class Impl;
|
||||
::sw::UnoImplPtr<Impl> m_pImpl;
|
||||
|
||||
SwEventListenerContainer aLstnrCntnr;
|
||||
const SfxItemPropertySet* m_pPropSet;
|
||||
|
||||
BOOL m_bIsDescriptor;
|
||||
BOOL m_bIndexHeader;
|
||||
String m_sName;
|
||||
SwTextSectionProperties_Impl* pProps;
|
||||
SwXTextSectionClient* m_pClient;
|
||||
|
||||
protected:
|
||||
|
||||
void SAL_CALL SetPropertyValues_Impl(
|
||||
const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
|
||||
rPropertyNames,
|
||||
const ::com::sun::star::uno::Sequence<
|
||||
::com::sun::star::uno::Any >& aValues)
|
||||
throw (::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::beans::PropertyVetoException,
|
||||
::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
|
||||
GetPropertyValues_Impl(
|
||||
const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
|
||||
rPropertyNames)
|
||||
throw (::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
|
||||
SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader = FALSE);
|
||||
SwXTextSection(SwSectionFmt *const pFmt, const bool bIndexHeader = false);
|
||||
|
||||
virtual ~SwXTextSection();
|
||||
|
||||
void ResetClient() { m_pClient = 0; }
|
||||
void SetClient(SwXTextSectionClient* pClient) { m_pClient = pClient; }
|
||||
|
||||
public:
|
||||
|
||||
void attachToRange(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::text::XTextRange > & xTextRange)
|
||||
throw (::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
|
||||
SwSectionFmt* GetFmt() const;
|
||||
|
||||
static SwXTextSection* GetImplementation(
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XInterface> xRef);
|
||||
static ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::text::XTextSection >
|
||||
CreateXTextSection(SwSectionFmt *const pFmt = 0,
|
||||
const bool bIndexHeader = false);
|
||||
|
||||
static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
|
||||
|
||||
|
|
|
@ -835,6 +835,11 @@ void SwSectionFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew )
|
|||
break;
|
||||
}
|
||||
SwFrmFmt::Modify( pOld, pNew );
|
||||
|
||||
if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
|
||||
{ // invalidate cached uno object
|
||||
SetXTextSection(uno::Reference<text::XTextSection>(0));
|
||||
}
|
||||
}
|
||||
|
||||
// erfrage vom Format Informationen
|
||||
|
|
|
@ -2480,6 +2480,11 @@ void SwFrmFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew )
|
|||
// wegen RESET_FMTWRITTEN.
|
||||
// if ( GetDepends() )
|
||||
SwFmt::Modify( pOld, pNew );
|
||||
|
||||
if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
|
||||
{ // invalidate cached uno object
|
||||
SetXObject(uno::Reference<uno::XInterface>(0));
|
||||
}
|
||||
}
|
||||
|
||||
//Vernichtet alle Frms, die in aDepend angemeldet sind.
|
||||
|
|
|
@ -447,7 +447,8 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16
|
|||
break;
|
||||
case SW_SERVICE_INDEX_HEADER_SECTION :
|
||||
case SW_SERVICE_TEXT_SECTION :
|
||||
xRet = SwXTextSectionClient::CreateXTextSection( 0, SW_SERVICE_INDEX_HEADER_SECTION == nObjectType);
|
||||
xRet = SwXTextSection::CreateXTextSection(0,
|
||||
(SW_SERVICE_INDEX_HEADER_SECTION == nObjectType));
|
||||
|
||||
break;
|
||||
case SW_SERVICE_REFERENCE_MARK :
|
||||
|
@ -1473,15 +1474,7 @@ sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException )
|
|||
-----------------------------------------------------------------------*/
|
||||
uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFmt& rFmt )
|
||||
{
|
||||
SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter( rFmt ).
|
||||
First( TYPE( SwXTextSectionClient ));
|
||||
uno::Reference< XTextSection > xRet;
|
||||
if( pClient )
|
||||
xRet = pClient->GetXTextSection();
|
||||
// it is possible that the client is still registered but the reference is already invalid
|
||||
if( !xRet.is() )
|
||||
xRet = SwXTextSectionClient::CreateXTextSection(&rFmt);
|
||||
return xRet;
|
||||
return SwXTextSection::CreateXTextSection(&rFmt);
|
||||
}
|
||||
|
||||
OUString SwXBookmarks::getImplementationName(void) throw( RuntimeException )
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -674,7 +674,10 @@ void SwXText::insertTextContentBefore(
|
|||
throw lang::IllegalArgumentException();
|
||||
|
||||
sal_Bool bRet = sal_False;
|
||||
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor );
|
||||
const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
|
||||
uno::UNO_QUERY);
|
||||
SwXTextSection *const pXSection =
|
||||
::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
|
||||
SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor );
|
||||
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
|
||||
SwTxtNode * pTxtNode = 0;
|
||||
|
@ -728,7 +731,10 @@ void SwXText::insertTextContentAfter(
|
|||
if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is())
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor );
|
||||
const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
|
||||
uno::UNO_QUERY);
|
||||
SwXTextSection *const pXSection =
|
||||
::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
|
||||
SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor );
|
||||
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
|
||||
sal_Bool bRet = sal_False;
|
||||
|
@ -779,7 +785,10 @@ void SwXText::removeTextContentBefore(
|
|||
}
|
||||
|
||||
sal_Bool bRet = sal_False;
|
||||
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor );
|
||||
const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
|
||||
uno::UNO_QUERY);
|
||||
SwXTextSection *const pXSection =
|
||||
::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
|
||||
SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor );
|
||||
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
|
||||
if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
|
||||
|
@ -826,7 +835,10 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>&
|
|||
}
|
||||
|
||||
sal_Bool bRet = sal_False;
|
||||
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor );
|
||||
const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
|
||||
uno::UNO_QUERY);
|
||||
SwXTextSection *const pXSection =
|
||||
::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
|
||||
SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor );
|
||||
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
|
||||
if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
|
||||
|
|
Loading…
Reference in a new issue