swunolocking1: #i105557#: fix locking for SwXText:

add Impl struct, and use UnoImplPtr to lock destructor.
 move all implementation details out of header, into Impl struct.
 use new XUnoTunnel and XServiceInfo helpers.
 clean up the implementation a little.
This commit is contained in:
Michael Stahl 2010-01-08 17:13:56 +01:00
parent 456e9d587f
commit 817e682f25
11 changed files with 1200 additions and 1144 deletions

View file

@ -85,7 +85,7 @@ protected:
virtual ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextCursor >
createCursor()
CreateCursor()
throw (::com::sun::star::uno::RuntimeException);
virtual ~SwXFootnote();

View file

@ -186,12 +186,18 @@ class SwXTextFrame : public SwXTextFrameBaseClass,
protected:
virtual const SwStartNode *GetStartNode() const;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextCursor >
CreateCursor()
throw (::com::sun::star::uno::RuntimeException);
virtual ~SwXTextFrame();
public:
SwXTextFrame(SwDoc *pDoc);
SwXTextFrame(SwFrmFmt& rFmt);
// FIXME: EVIL HACK: make available for SwXFrame::attachToRange
void SetDoc(SwDoc *const pDoc) { SwXText::SetDoc(pDoc); };
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire( ) throw();

View file

@ -106,13 +106,15 @@ class SwXCell : public SwXCellBaseClass,
// table position where pBox was found last
sal_uInt16 nFndPos;
using SwXText::IsValid;
protected:
virtual const SwStartNode *GetStartNode() const;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException);
sal_Bool IsValid();
virtual ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextCursor >
CreateCursor()
throw (::com::sun::star::uno::RuntimeException);
bool IsValid() const;
virtual ~SwXCell();

View file

@ -40,8 +40,6 @@
#include <com/sun/star/text/XRelativeTextContentRemove.hpp>
#include <com/sun/star/text/XTextAppendAndConvert.hpp>
#include <tools/debug.hxx>
#include <unobaseclass.hxx>
@ -75,28 +73,24 @@ class SwXText
private:
SwDoc* pDoc;
BOOL bObjectValid;
CursorType eCrsrType;
const SfxItemPropertySet* m_pPropSet;
virtual ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextRange > SAL_CALL
finishOrAppendParagraph(
bool bFinish,
const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue >&
rCharacterAndParagraphProperties)
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
virtual void PrepareForAttach(
::com::sun::star::uno::Reference<
::com::sun::star::text::XTextRange > & xRange,
SwPaM const & rPam);
virtual bool CheckForOwnMemberMeta(
const SwPaM & rPam, const bool bAbsorb)
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
protected:
bool IsValid() const;
void Invalidate();
void SetDoc(SwDoc *const pDoc);
virtual ~SwXText();
public: /*not protected because C++ is retarded*/
@ -104,41 +98,16 @@ public: /*not protected because C++ is retarded*/
public:
SwXText(SwDoc* pDc, CursorType eType);
SwXText(SwDoc *const pDoc, const enum CursorType eType);
const SwDoc* GetDoc() const { return pDoc; }
SwDoc* GetDoc() { return pDoc; }
// SwDoc is set when SwXText is attached
void SetDoc(SwDoc* pDc) {
DBG_ASSERT(!pDoc || !pDc, "Doc schon gesetzt?");
pDoc = pDc;
bObjectValid = 0 != pDc;
}
void Invalidate() { bObjectValid = sal_False; }
BOOL IsValid() const { return bObjectValid; }
CursorType GetTextType() { return eCrsrType; }
const SwDoc* GetDoc() const;
SwDoc* GetDoc();
virtual ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextCursor > createCursor()
::com::sun::star::text::XTextCursor >
CreateCursor()
throw (::com::sun::star::uno::RuntimeException);
INT16 ComparePositions(
const ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextRange>& xPos1,
const ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextRange>& xPos2)
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
BOOL CheckForOwnMember(const SwXTextRange* pRange1,
const OTextCursorHelper* pCursor1)
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
virtual bool CheckForOwnMemberMeta(
const SwPaM & rPam, const bool bAbsorb)
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(

View file

@ -149,7 +149,7 @@ protected:
virtual const SwStartNode *GetStartNode() const;
virtual ::com::sun::star::uno::Reference<
::com::sun::star::text::XTextCursor >
createCursor()
CreateCursor()
throw (::com::sun::star::uno::RuntimeException);
virtual ~SwXHeadFootText();

View file

@ -2611,7 +2611,8 @@ const SwStartNode *SwXTextFrame::GetStartNode() const
return pSttNd;
}
uno::Reference< text::XTextCursor > SwXTextFrame::createCursor() throw ( uno::RuntimeException)
uno::Reference< text::XTextCursor >
SwXTextFrame::CreateCursor() throw (uno::RuntimeException)
{
return createTextCursor();
}

View file

@ -375,7 +375,8 @@ const SwStartNode *SwXFootnote::GetStartNode() const
return pSttNd;
}
uno::Reference< text::XTextCursor > SwXFootnote::createCursor() throw ( uno::RuntimeException)
uno::Reference< text::XTextCursor >
SwXFootnote::CreateCursor() throw (uno::RuntimeException)
{
return createTextCursor();
}

View file

@ -1164,7 +1164,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill,
if(pText)
{
const uno::Reference< text::XTextCursor > xTextCursor =
pText->createCursor();
pText->CreateCursor();
xTextCursor->gotoEnd(sal_True);
const uno::Reference<lang::XUnoTunnel> xCrsrTunnel(
xTextCursor, uno::UNO_QUERY);

View file

@ -594,11 +594,14 @@ private:
protected:
virtual const SwStartNode *GetStartNode() const;
virtual uno::Reference< text::XTextCursor >
createCursor() throw (uno::RuntimeException);
CreateCursor() throw (uno::RuntimeException);
public:
SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta);
/// make available for SwXMeta
void Invalidate() { SwXText::Invalidate(); };
// XInterface
virtual void SAL_CALL acquire() throw()
{ OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); }
@ -649,7 +652,7 @@ bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb)
return m_rMeta.CheckForOwnMemberMeta(rPam, bAbsorb);
}
uno::Reference< text::XTextCursor > SwXMetaText::createCursor()
uno::Reference< text::XTextCursor > SwXMetaText::CreateCursor()
throw (uno::RuntimeException)
{
uno::Reference< text::XTextCursor > xRet;
@ -680,7 +683,7 @@ SwXMetaText::getImplementationId() throw (uno::RuntimeException)
uno::Reference< text::XTextCursor > SAL_CALL
SwXMetaText::createTextCursor() throw (uno::RuntimeException)
{
return createCursor();
return CreateCursor();
}
uno::Reference< text::XTextCursor > SAL_CALL
@ -688,7 +691,7 @@ SwXMetaText::createTextCursorByRange(
const uno::Reference<text::XTextRange> & xTextPosition)
throw (uno::RuntimeException)
{
const uno::Reference<text::XTextCursor> xCursor( createCursor() );
const uno::Reference<text::XTextCursor> xCursor( CreateCursor() );
xCursor->gotoRange(xTextPosition, sal_False);
return xCursor;
}

View file

@ -893,25 +893,32 @@ const SwStartNode *SwXCell::GetStartNode() const
return pSttNd;
}
uno::Reference< text::XTextCursor > SwXCell::createCursor() throw (uno::RuntimeException)
uno::Reference< text::XTextCursor >
SwXCell::CreateCursor() throw (uno::RuntimeException)
{
return createTextCursor();
}
/*-- 11.12.98 10:56:24---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXCell::IsValid()
bool SwXCell::IsValid() const
{
// FIXME: this is now a const method, to make SwXText::IsValid invisible
// but the const_cast here are still ridiculous. TODO: find a better way.
SwFrmFmt* pTblFmt = pBox ? GetFrmFmt() : 0;
if(!pTblFmt)
pBox = 0;
{
const_cast<SwXCell*>(this)->pBox = 0;
}
else
{
SwTable* pTable = SwTable::FindTable( pTblFmt );
const SwTableBox* pFoundBox ;
pFoundBox = FindBox(pTable, pBox);
if(!pFoundBox)
pBox = 0;
SwTableBox const*const pFoundBox =
const_cast<SwXCell*>(this)->FindBox(pTable, pBox);
if (!pFoundBox)
{
const_cast<SwXCell*>(this)->pBox = 0;
}
}
return 0 != pBox;
}

File diff suppressed because it is too large Load diff