From 865a5fa3a07d26ae43fd40df64b58e3965ea61b8 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:36 +0100 Subject: swunolocking1: #i107171#: fix crash caused by SwXParagraph::attachToText(): register at the text node, not at an uno cursor. --- sw/inc/unoobj.hxx | 2 +- sw/source/core/unocore/unoparagraph.cxx | 7 ++++--- sw/source/core/unocore/unotext.cxx | 24 ++++++++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index e2e8b02dde..4e9511647d 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -1283,7 +1283,7 @@ public: static SwXParagraph* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); //falls es mal als Service erzeugt werden kann //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 ); - void attachToText(SwXText* pParent, SwUnoCrsr* pCrsr); + void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); }; /* -----------------23.03.99 12:57------------------- * diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 812b81e928..c947c4181f 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -226,14 +226,15 @@ SwXParagraph::~SwXParagraph() /* -----------------------------11.07.00 14:48-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::attachToText(SwXText* pParent, SwUnoCrsr* pCrsr) +void +SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode) { DBG_ASSERT(m_bIsDescriptor, "Paragraph is not a descriptor"); if(m_bIsDescriptor) { m_bIsDescriptor = FALSE; - pCrsr->Add(this); - xParentText = pParent; + rTxtNode.Add(this); + xParentText = &rParent; if(m_sText.getLength()) { try { setString(m_sText); } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 0373d8877a..c654b5ec6f 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -662,7 +662,7 @@ void SwXText::insertTextContentBefore( SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; - SwUnoCrsr* pUnoCrsr = 0; + SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -671,7 +671,7 @@ void SwXText::insertTextContentBefore( SwNodeIndex aTblIdx( *pTblNode, -1 ); SwPosition aBefore(aTblIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aBefore, FALSE); + pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } else if(pXSection && pXSection->GetFmt() && @@ -683,13 +683,15 @@ void SwXText::insertTextContentBefore( SwNodeIndex aSectIdx( *pSectNode, -1 ); SwPosition aBefore(aSectIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aBefore, FALSE); + pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } - if(!bRet) + if (!bRet || !pTxtNode) + { throw lang::IllegalArgumentException(); + } else { - pPara->attachToText(this, pUnoCrsr); + pPara->attachToText(*this, *pTxtNode); } } @@ -708,11 +710,11 @@ void SwXText::insertTextContentAfter( if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) throw lang::IllegalArgumentException(); - SwUnoCrsr* pUnoCrsr = 0; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; sal_Bool bRet = sal_False; + SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -721,7 +723,7 @@ void SwXText::insertTextContentAfter( SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); SwPosition aTableEnd(*pTableEnd); bRet = GetDoc()->AppendTxtNode( aTableEnd ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aTableEnd, FALSE); + pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode(); } else if(pXSection && pXSection->GetFmt() && @@ -732,13 +734,15 @@ void SwXText::insertTextContentAfter( SwEndNode* pEnd = pSectNode->EndOfSectionNode(); SwPosition aEnd(*pEnd); bRet = GetDoc()->AppendTxtNode( aEnd ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aEnd, FALSE); + pTxtNode = aEnd.nNode.GetNode().GetTxtNode(); } - if(!bRet) + if (!bRet || !pTxtNode) + { throw lang::IllegalArgumentException(); + } else { - pPara->attachToText(this, pUnoCrsr); + pPara->attachToText(*this, *pTxtNode); } } /* -----------------------------10.07.00 15:40-------------------------------- -- cgit v1.2.3 From 034c7a711ca65234fd9995c8f02c86452824550b Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:36 +0100 Subject: swunolocking1: #i106930#: thints.cxx: tweak isNestedAny() a bit with the fix for i106930, inserting a nesting hint without extent never overrides an existing hint; but overriding is actually desirable in the corner case where the existing hint is _also_ empty. [the unoapi test sw.SwXTextTableCursor relies on this] --- sw/source/core/txtnode/thints.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index a09a7ccec5..ee2ac11a99 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -159,7 +159,8 @@ bool isNestedAny(const xub_StrLen nStart1, const xub_StrLen nEnd1, const xub_StrLen nStart2, const xub_StrLen nEnd2) { return ((nStart1 == nStart2) || (nEnd1 == nEnd2)) - ? (nStart1 != nEnd1) // same start/end: nested except if hint1 empty + // same start/end: nested except if hint1 empty and hint2 not empty + ? (nStart1 != nEnd1) || (nStart2 == nEnd2) : ((nStart1 < nStart2) ? (nEnd1 >= nEnd2) : (nEnd1 <= nEnd2)); } -- cgit v1.2.3 From 74de865de2ce48ba9df59f4604d8a7a3ad01df41 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:41 +0100 Subject: swunolocking1: swtypes.hxx: rename frame anchor types enum RndStdIds: rename frame anchor types (FLY_*) to be more intuitive. [note the completely ridiculous number of files that care about anchor types] --- sw/inc/dcontact.hxx | 10 +-- sw/inc/fmtanchr.hxx | 4 +- sw/inc/swtypes.hxx | 10 +-- sw/source/core/access/accframe.cxx | 6 +- sw/source/core/access/accfrmobj.cxx | 6 +- sw/source/core/doc/doc.cxx | 4 +- sw/source/core/doc/docbm.cxx | 33 +++++--- sw/source/core/doc/docdraw.cxx | 10 +-- sw/source/core/doc/docedt.cxx | 38 ++++----- sw/source/core/doc/docfly.cxx | 52 ++++++------ sw/source/core/doc/docglbl.cxx | 22 +++-- sw/source/core/doc/doclay.cxx | 98 ++++++++++++---------- sw/source/core/doc/docnew.cxx | 2 +- sw/source/core/doc/docsort.cxx | 19 ++--- sw/source/core/doc/poolfmt.cxx | 18 ++-- sw/source/core/doc/tblcpy.cxx | 12 +-- sw/source/core/docnode/ndcopy.cxx | 47 +++++------ sw/source/core/docnode/ndtbl.cxx | 19 +++-- sw/source/core/docnode/node.cxx | 6 +- sw/source/core/docnode/swbaslnk.cxx | 30 +++---- sw/source/core/draw/dcontact.cxx | 26 ++---- sw/source/core/draw/dview.cxx | 14 ++-- sw/source/core/edit/autofmt.cxx | 2 +- sw/source/core/fields/expfld.cxx | 15 ++-- sw/source/core/frmedt/fecopy.cxx | 73 ++++++++-------- sw/source/core/frmedt/fefly1.cxx | 84 +++++++++++-------- sw/source/core/frmedt/feshview.cxx | 24 +++--- sw/source/core/frmedt/fews.cxx | 18 ++-- sw/source/core/frmedt/tblsel.cxx | 9 +- sw/source/core/inc/flyfrm.hxx | 8 +- sw/source/core/layout/anchoreddrawobject.cxx | 16 ++-- sw/source/core/layout/anchoredobject.cxx | 12 +-- sw/source/core/layout/atrfrm.cxx | 75 +++++++++-------- sw/source/core/layout/calcmove.cxx | 6 +- sw/source/core/layout/flowfrm.cxx | 2 +- sw/source/core/layout/fly.cxx | 19 +++-- sw/source/core/layout/flycnt.cxx | 2 +- sw/source/core/layout/flylay.cxx | 9 +- sw/source/core/layout/flypos.cxx | 8 +- sw/source/core/layout/frmtool.cxx | 27 +++--- sw/source/core/layout/laycache.cxx | 11 ++- sw/source/core/layout/objectformatter.cxx | 2 +- sw/source/core/layout/objectformattertxtfrm.cxx | 6 +- sw/source/core/layout/pagechg.cxx | 12 ++- sw/source/core/layout/sortedobjsimpl.cxx | 41 +++++---- sw/source/core/layout/tabfrm.cxx | 8 +- sw/source/core/layout/wsfrm.cxx | 10 +-- .../tocntntanchoredobjectposition.cxx | 6 +- sw/source/core/text/EnhancedPDFExportHelper.cxx | 12 +-- sw/source/core/text/itratr.cxx | 6 +- sw/source/core/text/porfly.cxx | 5 +- sw/source/core/text/txtfly.cxx | 50 +++++------ sw/source/core/text/txtfrm.cxx | 20 ++--- sw/source/core/txtnode/atrflyin.cxx | 10 ++- sw/source/core/txtnode/thints.cxx | 8 +- sw/source/core/undo/rolbck.cxx | 2 +- sw/source/core/undo/unattr.cxx | 16 ++-- sw/source/core/undo/undel.cxx | 4 +- sw/source/core/undo/undobj.cxx | 6 +- sw/source/core/undo/undobj1.cxx | 91 ++++++++++++-------- sw/source/core/undo/undraw.cxx | 37 ++++---- sw/source/core/undo/untbl.cxx | 10 +-- sw/source/core/undo/untblk.cxx | 16 ++-- sw/source/core/unocore/unodraw.cxx | 46 ++++++---- sw/source/core/unocore/unoframe.cxx | 23 ++--- sw/source/core/unocore/unoobj2.cxx | 3 +- sw/source/core/view/vdraw.cxx | 9 +- sw/source/filter/basflt/shellio.cxx | 19 +++-- sw/source/filter/html/css1atr.cxx | 10 +-- sw/source/filter/html/htmlcss1.cxx | 13 +-- sw/source/filter/html/htmldraw.cxx | 14 ++-- sw/source/filter/html/htmlfly.cxx | 20 ++--- sw/source/filter/html/htmlforw.cxx | 7 +- sw/source/filter/html/htmlgrin.cxx | 30 +++---- sw/source/filter/html/htmlplug.cxx | 8 +- sw/source/filter/html/swhtml.cxx | 36 ++++---- sw/source/filter/inc/fltshell.hxx | 12 ++- sw/source/filter/rtf/rtfatr.cxx | 20 ++--- sw/source/filter/rtf/rtffly.cxx | 17 ++-- sw/source/filter/rtf/swparrtf.cxx | 28 ++----- sw/source/filter/rtf/wrtrtf.cxx | 7 +- sw/source/filter/ww1/fltshell.cxx | 13 ++- sw/source/filter/ww1/w1sprm.cxx | 10 +-- sw/source/filter/ww8/writerhelper.cxx | 2 +- sw/source/filter/ww8/wrtw8esh.cxx | 16 ++-- sw/source/filter/ww8/wrtw8nds.cxx | 13 +-- sw/source/filter/ww8/wrtww8.cxx | 2 +- sw/source/filter/ww8/wrtww8gr.cxx | 6 +- sw/source/filter/ww8/ww8atr.cxx | 8 +- sw/source/filter/ww8/ww8glsy.cxx | 13 ++- sw/source/filter/ww8/ww8graf.cxx | 20 ++--- sw/source/filter/ww8/ww8graf2.cxx | 8 +- sw/source/filter/ww8/ww8par.cxx | 2 +- sw/source/filter/ww8/ww8par2.cxx | 13 +-- sw/source/filter/ww8/ww8par4.cxx | 8 +- sw/source/filter/ww8/ww8par5.cxx | 8 +- sw/source/filter/ww8/ww8par6.cxx | 24 ++---- sw/source/filter/xml/xmltexti.cxx | 5 +- sw/source/ui/app/appenv.cxx | 20 +---- sw/source/ui/app/applab.cxx | 18 +--- sw/source/ui/dbui/mmlayoutpage.cxx | 6 +- sw/source/ui/dialog/regionsw.cxx | 23 +---- sw/source/ui/docvw/edtwin.cxx | 25 ++---- sw/source/ui/frmdlg/column.cxx | 2 +- sw/source/ui/frmdlg/frmmgr.cxx | 27 +++--- sw/source/ui/frmdlg/frmpage.cxx | 60 +++++++------ sw/source/ui/frmdlg/wrap.cxx | 54 +++++++----- sw/source/ui/ribbar/conrect.cxx | 11 +-- sw/source/ui/ribbar/drawbase.cxx | 3 +- sw/source/ui/shells/basesh.cxx | 58 +++++++------ sw/source/ui/shells/drwbassh.cxx | 12 ++- sw/source/ui/shells/textdrw.cxx | 6 -- sw/source/ui/shells/textidx.cxx | 6 +- sw/source/ui/shells/textsh.cxx | 12 +-- sw/source/ui/uiview/view2.cxx | 19 ----- sw/source/ui/uiview/viewtab.cxx | 4 +- sw/source/ui/utlui/attrdesc.cxx | 8 +- sw/source/ui/wrtsh/select.cxx | 6 -- 118 files changed, 1007 insertions(+), 1150 deletions(-) diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 8860f0e38f..0f5ca9b9b3 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -191,11 +191,11 @@ public: } RndStdIds GetAnchorId() const { return GetAnchorFmt().GetAnchorId(); } - bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_PAGE; } - bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; } - bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_CNTNT; } - bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AUTO_CNTNT; } - bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_IN_CNTNT; } + bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_AT_PAGE; } + bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; } + bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_PARA; } + bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AT_CHAR; } + bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_AS_CHAR; } const SwPosition& GetCntntAnchor() const { diff --git a/sw/inc/fmtanchr.hxx b/sw/inc/fmtanchr.hxx index 82841835db..80f35111ef 100644 --- a/sw/inc/fmtanchr.hxx +++ b/sw/inc/fmtanchr.hxx @@ -55,7 +55,7 @@ class SW_DLLPUBLIC SwFmtAnchor: public SfxPoolItem static sal_uInt32 mnOrderCounter; public: - SwFmtAnchor( RndStdIds eRnd = FLY_PAGE, USHORT nPageNum = 0 ); + SwFmtAnchor( RndStdIds eRnd = FLY_AT_PAGE, USHORT nPageNum = 0 ); SwFmtAnchor( const SwFmtAnchor &rCpy ); ~SwFmtAnchor(); @@ -86,7 +86,7 @@ public: }; inline const SwFmtAnchor &SwAttrSet::GetAnchor(BOOL bInP) const - { return (const SwFmtAnchor&)Get( RES_ANCHOR,bInP); } + { return static_cast(Get(RES_ANCHOR, bInP)); } inline const SwFmtAnchor &SwFmt::GetAnchor(BOOL bInP) const { return aSet.GetAnchor(bInP); } diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index 7bc90a4e76..70bebb09fe 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -166,11 +166,11 @@ const short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm //Schnittstellen Bedeutung haben (SwDoc). enum RndStdIds { - FLY_AT_CNTNT, //Absatzgebundener Rahmen - FLY_IN_CNTNT, //Zeichengebundener Rahmen - FLY_PAGE, //Seitengebundener Rahmen - FLY_AT_FLY, //Rahmengebundener Rahmen ( LAYER_IMPL ) - FLY_AUTO_CNTNT, //Automatisch positionierter, absatzgebundener Rahmen + FLY_AT_PARA, // anchored at paragraph + FLY_AS_CHAR, // anchored as character + FLY_AT_PAGE, // anchored at page + FLY_AT_FLY, // anchored at frame + FLY_AT_CHAR, // anchored at character //Der Rest wird nur fuer SS benutzt. RND_STD_HEADER, RND_STD_FOOTER, diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index ce6c2ad0e1..573383b7c7 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -438,7 +438,7 @@ const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, const SwFlyFrm *pFly = static_cast< const SwFlyFrm *>( pFrm ); if( pFly->IsFlyInCntFrm() ) { - // For FLY_IN_CNTNT the parent is the anchor + // For FLY_AS_CHAR the parent is the anchor aParent = pFly->GetAnchorFrm(); ASSERT( aParent.IsAccessible( bInPagePreview ), "parent is not accessible" ); @@ -471,9 +471,9 @@ const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, { const SwFrmFmt *pFrmFmt = pContact->GetFmt(); ASSERT( pFrmFmt, "frame format is missing" ); - if( pFrmFmt && FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + if (pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) { - // For FLY_IN_CNTNT the parent is the anchor + // For FLY_AS_CHAR the parent is the anchor aParent = pContact->GetAnchorFrm(); ASSERT( aParent.IsAccessible( bInPagePreview ), "parent is not accessible" ); diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index 3102cc958e..88b6b0e8b8 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -59,8 +59,10 @@ sal_Bool SwFrmOrObj::IsBoundAsChar() const else { const SwFrmFmt *pFrmFmt = pObj ? ::FindFrmFmt( pObj ) : 0; - return pFrmFmt ? static_cast(FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId()) - : sal_False; + return (pFrmFmt) + ? static_cast(FLY_AS_CHAR == + pFrmFmt->GetAnchor().GetAnchorId()) + : sal_False; } } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 252ab069c1..c52b387ba9 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -95,9 +95,7 @@ #include #include #include -#ifndef _CMDID_H #include // fuer den dflt - Printer in SetJob -#endif #ifndef _STATSTR_HRC #include // StatLine-String #endif @@ -923,7 +921,7 @@ SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, SwFlyFrmFmt *pFmt = 0; if( pNode ) { - pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_CNTNT, + pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA, pFlyAttrSet, pFrmFmt ); if( pGrfAttrSet ) pNode->SetAttr( *pGrfAttrSet ); diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 80973abeca..5af1944799 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1259,7 +1259,6 @@ void _SaveCntntIdx(SwDoc* pDoc, SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode(); if( pNode ) { - const SwPosition* pAPos; SwFrm* pFrm = pNode->GetFrm(); #if OSL_DEBUG_LEVEL > 1 @@ -1277,16 +1276,18 @@ void _SaveCntntIdx(SwDoc* pDoc, SwAnchoredObject* pObj = rDObj[ --n ]; const SwFrmFmt& rFmt = pObj->GetFrmFmt(); const SwFmtAnchor& rAnchor = rFmt.GetAnchor(); - if( ( ( nSaveFly && FLY_AT_CNTNT == rAnchor.GetAnchorId() ) || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - ( 0 != ( pAPos = rAnchor.GetCntntAnchor() ) ) ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if ( pAPos && + ( ( nSaveFly && + FLY_AT_PARA == rAnchor.GetAnchorId() ) || + ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) ) { aSave.SetType( 0x2000 ); aSave.SetContent( pAPos->nContent.GetIndex() ); OSL_ENSURE( nNode == pAPos->nNode.GetIndex(), "_SaveCntntIdx: Wrong Node-Index" ); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { if( nCntnt <= aSave.GetContent() ) { @@ -1321,14 +1322,14 @@ void _SaveCntntIdx(SwDoc* pDoc, continue; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) && - nNode == pAPos->nNode.GetIndex() ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) && + ( FLY_AT_PARA == rAnchor.GetAnchorId() || + FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) { aSave.SetType( 0x2000 ); aSave.SetContent( pAPos->nContent.GetIndex() ); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { if( nCntnt <= aSave.GetContent() ) { @@ -1444,11 +1445,15 @@ void _RestoreCntntIdx(SwDoc* pDoc, SwFmtAnchor aNew( rFlyAnchor ); SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() ); aNewPos.nNode = *pCNd; - if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() ) + { aNewPos.nContent.Assign( pCNd, aSave.GetContent() + nOffset ); + } else + { aNewPos.nContent.Assign( 0, 0 ); + } aNew.SetAnchor( &aNewPos ); pFrmFmt->SetFmtAttr( aNew ); } @@ -1608,11 +1613,15 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, SwFmtAnchor aNew( rFlyAnchor ); SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() ); aNewPos.nNode = rNd; - if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() ) + { aNewPos.nContent.Assign( pCNd, Min( aSave.GetContent(), nLen ) ); + } else + { aNewPos.nContent.Assign( 0, 0 ); + } aNew.SetAnchor( &aNewPos ); pFrmFmt->SetFmtAttr( aNew ); } diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index 3befc37ff3..a73f274b48 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include #include -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -46,22 +44,16 @@ #include #include -#ifndef _SVDOMEAS_HXX #include -#endif #include #include #include #include #include #include -#ifndef _SWHINTS_HXX #include -#endif #include -#ifndef _DOCSH_HXX #include -#endif #include //Damit der RootDtor gerufen wird. #include #include // fuer MakeDrawView @@ -481,7 +473,7 @@ BOOL SwDoc::DeleteSelection( SwDrawView& rDrawView ) SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj); SwDrawFrmFmt *pFrmFmt = (SwDrawFrmFmt*)pC->GetFmt(); if( pFrmFmt && - FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() ) { rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), TRUE ); --i; diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index f741f2fc04..3cde597133 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -220,17 +220,15 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx, void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ) { - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; SwSpzFrmFmts& rFmts = *rRg.aStart.GetNode().GetDoc()->GetSpzFrmFmts(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) { - pFmt = (SwFrmFmt*)rFmts[n]; - pAnchor = &pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwFrmFmt *const pFmt = static_cast(rFmts[n]); + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && rRg.aStart <= pAPos->nNode && pAPos->nNode < rRg.aEnd ) { _SaveFly aSave( pAPos->nNode.GetIndex() - rRg.aStart.GetIndex(), @@ -260,7 +258,6 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, pPos->nContent == rEndNdIdx.GetNode().GetCntntNode()->Len() )) ? 0 : 1; - const SwPosition* pAPos; const SwNodeIndex* pCntntIdx; for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) @@ -268,9 +265,10 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, sal_Bool bInsPos = sal_False; pFmt = (SwFrmFmt*)rFmts[n]; pAnchor = &pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && // nicht verschieben, wenn die InsPos im CntntBereich vom Fly ist ( 0 == ( pCntntIdx = pFmt->GetCntnt().GetCntntIdx() ) || !( *pCntntIdx < rInsPos && @@ -317,14 +315,14 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, SwDoc* pDoc = rMkNdIdx.GetNode().GetDoc(); SwSpzFrmFmts& rTbl = *pDoc->GetSpzFrmFmts(); - const SwPosition* pAPos; for ( sal_uInt16 i = rTbl.Count(); i; ) { SwFrmFmt *pFmt = rTbl[--i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if( ( rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT ) && - 0 != ( pAPos = rAnch.GetCntntAnchor() ) && + SwPosition const*const pAPos = rAnch.GetCntntAnchor(); + if (pAPos && + ((rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR)) && ( bDelFwrd ? rMkNdIdx < pAPos->nNode && pAPos->nNode <= rPtNdIdx : rPtNdIdx <= pAPos->nNode && pAPos->nNode < rMkNdIdx )) @@ -2620,14 +2618,14 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) // was ist mit Fly's ?? { // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aRg.aStart <= pAPos->nNode && pAPos->nNode <= aRg.aEnd ) { DelLayoutFmt( pFly ); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index e0645fcdc1..4f8f40af3e 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -181,7 +181,7 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, if( rDoc.GetRootFrm() ) switch( rAnch.GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( pFlyFmt && rAnch.GetCntntAnchor() ) { const SwFrm* pOld = ((SwFlyFrmFmt*)pFlyFmt)->GetFrm( &aRet, FALSE ); @@ -190,8 +190,8 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL if( rAnch.GetCntntAnchor() ) { const SwPosition *pPos = rAnch.GetCntntAnchor(); @@ -213,7 +213,7 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, } break; - case FLY_PAGE: + case FLY_AT_PAGE: { USHORT nPgNum = rAnch.GetPageNum(); const SwPageFrm *pPage = (SwPageFrm*)rDoc.GetRootFrm()->Lower(); @@ -249,9 +249,11 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms // ist der neue ein gueltiger Anker? if( !aNewAnch.GetCntntAnchor() && (FLY_AT_FLY == nNew || - FLY_AT_CNTNT == nNew || FLY_IN_CNTNT == nNew || - FLY_AUTO_CNTNT == nNew )) + (FLY_AT_PARA == nNew) || (FLY_AS_CHAR == nNew) || + (FLY_AT_CHAR == nNew) )) + { return IGNOREANCHOR; + } if( nOld == nNew ) return DONTMAKEFRMS; @@ -264,7 +266,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms //doppeltes hiden waere so eine art Show! rFmt.DelFrms(); - if( FLY_IN_CNTNT == nOld ) + if ( FLY_AS_CHAR == nOld ) { //Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet //werden. Leider reisst dies neben den Frms auch noch das Format mit @@ -295,7 +297,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms const SfxPoolItem* pItem; switch( nNew ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: //Wenn keine Positionsattribute hereinkommen, dann muss dafuer //gesorgt werden, das keine unerlaubte automatische Ausrichtung //bleibt. @@ -326,10 +328,10 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL case FLY_AT_FLY: // LAYER_IMPL - case FLY_PAGE: + case FLY_AT_PAGE: { //Wenn keine Positionsattribute hereinschneien korrigieren wir //die Position so, dass die Dokumentkoordinaten des Flys erhalten @@ -345,7 +347,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pItem || aOldH.GetPos() == ((SwFmtHoriOrient*)pItem)->GetPos() )) { - SwTwips nPos = FLY_IN_CNTNT == nOld ? 0 : aOldH.GetPos(); + SwTwips nPos = (FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos(); nPos += aOldAnchorPos.X() - aNewAnchorPos.X(); if( pItem ) @@ -367,7 +369,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pItem || aOldV.GetPos() == ((SwFmtVertOrient*)pItem)->GetPos() ) ) { - SwTwips nPos = FLY_IN_CNTNT == nOld ? 0 : aOldV.GetPos(); + SwTwips nPos = (FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos(); nPos += aOldAnchorPos.Y() - aNewAnchorPos.Y(); if( pItem ) { @@ -698,7 +700,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // xub_StrLen nIndx = STRING_NOTFOUND; const SwPosition* pOldAsCharAnchorPos( 0L ); const RndStdIds eOldAnchorType = pContact->GetAnchorId(); - if ( !_bSameOnly && eOldAnchorType == FLY_IN_CNTNT ) + if ( !_bSameOnly && eOldAnchorType == FLY_AS_CHAR ) { pOldAsCharAnchorPos = new SwPosition( pContact->GetCntntAnchor() ); } @@ -713,8 +715,8 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, switch ( _eAnchorType ) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { const Point aNewPoint = pOldAnchorFrm && ( pOldAnchorFrm->IsVertical() || @@ -768,10 +770,10 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, break; } - aNewAnch.SetType( FLY_PAGE ); + aNewAnch.SetType( FLY_AT_PAGE ); // no break } - case FLY_PAGE: + case FLY_AT_PAGE: { pNewAnchorFrm = GetRootFrm()->Lower(); while ( pNewAnchorFrm && !pNewAnchorFrm->Frm().IsInside( aPt ) ) @@ -782,7 +784,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, aNewAnch.SetPageNum( ((SwPageFrm*)pNewAnchorFrm)->GetPhyPageNum()); } break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( _bSameOnly ) // Positions/Groessenaenderung { if( !pOldAnchorFrm ) @@ -805,7 +807,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, bUnmark = ( 0 != i ); Point aPoint( aPt ); aPoint.X() -= 1; // nicht im DrawObj landen!! - aNewAnch.SetType( FLY_IN_CNTNT ); + aNewAnch.SetType( FLY_AS_CHAR ); SwPosition aPos( *((SwCntntFrm*)pNewAnchorFrm)->GetNode() ); if ( pNewAnchorFrm->Frm().IsInside( aPoint ) ) { @@ -839,7 +841,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, ASSERT( !this, "unexpected AnchorId." ); } - if ( (FLY_IN_CNTNT != _eAnchorType) && + if ( (FLY_AS_CHAR != _eAnchorType) && pNewAnchorFrm && ( !_bSameOnly || pNewAnchorFrm != pOldAnchorFrm ) ) { @@ -949,8 +951,8 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) const SwFmtAnchor& rAnchor = (*GetSpzFrmFmts())[ n ]->GetAnchor(); ULONG nTstSttNd; // OD 11.12.2003 #i20622# - to-frame anchored objects are allowed. - if ( ( rAnchor.GetAnchorId() == FLY_AT_CNTNT || - rAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) && + if ( ((rAnchor.GetAnchorId() == FLY_AT_PARA) || + (rAnchor.GetAnchorId() == FLY_AT_CHAR)) && 0 != rAnchor.GetCntntAnchor() && nFlySttNd <= ( nTstSttNd = rAnchor.GetCntntAnchor()->nNode.GetIndex() ) && @@ -971,9 +973,9 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) &rDstAnchor = rDest.GetAnchor(); ULONG nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex(); BOOL bAllowed = FALSE; - if( FLY_PAGE == rSrcAnchor.GetAnchorId() ) + if ( FLY_AT_PAGE == rSrcAnchor.GetAnchorId() ) { - if( FLY_PAGE == rDstAnchor.GetAnchorId() || + if ( (FLY_AT_PAGE == rDstAnchor.GetAnchorId()) || ( rDstAnchor.GetCntntAnchor() && rDstAnchor.GetCntntAnchor()->nNode.GetIndex() > nEndOfExtras )) bAllowed = TRUE; diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 1d39e35de2..a57b60c370 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -49,12 +49,8 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif -#ifndef _GLOBDOC_HXX #include -#endif #include #include // fuer die UndoIds #include @@ -371,14 +367,15 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE); // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = + pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aSIdx <= pAPos->nNode && pAPos->nNode < aEIdx ) { @@ -717,14 +714,15 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE); // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = + pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aSIdx <= pAPos->nNode && pAPos->nNode < aEIdx ) { diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index fe244d4957..a77487654b 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -68,9 +68,7 @@ #include #include #include -#ifndef _FRMCNCT_HXX //autogen #include -#endif #include #include #include @@ -85,9 +83,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -213,13 +209,12 @@ SwFrmFmt *SwDoc::MakeLayoutFmt( RndStdIds eRequest, const SfxItemSet* pSet ) break; #ifndef PRODUCT - case FLY_PAGE: - case FLY_AUTO_CNTNT: + case FLY_AT_PAGE: + case FLY_AT_CHAR: case FLY_AT_FLY: - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: - ASSERT( !this, - "neue Schnittstelle benutzen: SwDoc::MakeFlySection!" ); + case FLY_AT_PARA: + case FLY_AS_CHAR: + ASSERT( false, "use new interface instead: SwDoc::MakeFlySection!" ); break; #endif @@ -358,7 +353,7 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) // ggfs. bei Zeichengebundenen Flys das Zeichen loeschen const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() && rAnchor.GetCntntAnchor()) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor()) { const SwPosition* pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode(); @@ -422,9 +417,9 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, static_cast( rSource.FindContactObj() ); bMayNotCopy = - ( FLY_AT_CNTNT == rNewAnchor.GetAnchorId() || - FLY_AT_FLY == rNewAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rNewAnchor.GetAnchorId() ) && + ((FLY_AT_PARA == rNewAnchor.GetAnchorId()) || + (FLY_AT_FLY == rNewAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rNewAnchor.GetAnchorId())) && rNewAnchor.GetCntntAnchor() && IsInHeaderFooter( rNewAnchor.GetCntntAnchor()->nNode ) && pDrawContact != NULL && @@ -551,7 +546,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, } } - if( bSetTxtFlyAtt && FLY_IN_CNTNT == rNewAnchor.GetAnchorId() ) + if (bSetTxtFlyAtt && (FLY_AS_CHAR == rNewAnchor.GetAnchorId())) { const SwPosition* pPos = rNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pDest ); @@ -660,7 +655,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, RndStdIds eAnchorId = pAnchor ? pAnchor->GetAnchorId() : pFmt->GetAnchor().GetAnchorId(); if( !pAnchor || - (FLY_PAGE != pAnchor->GetAnchorId() && + ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && //Nur Page und nicht: // FLY_AT_CNTNT == pAnchor->GetAnchorId() || // FLY_IN_CNTNT == pAnchor->GetAnchorId() || @@ -670,7 +665,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, { // dann setze ihn, wird im Undo gebraucht SwFmtAnchor aAnch( pFmt->GetAnchor() ); - if( pAnchor && FLY_AT_FLY == pAnchor->GetAnchorId() ) + if (pAnchor && (FLY_AT_FLY == pAnchor->GetAnchorId())) { SwPosition aPos( *rAnchPos.nNode.GetNode().FindFlyStartNode() ); aAnch.SetAnchor( &aPos ); @@ -683,7 +678,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, aAnch.SetType( eRequestId ); eAnchorId = aAnch.GetAnchorId(); - if ( FLY_PAGE != eAnchorId ) + if ( FLY_AT_PAGE != eAnchorId ) //Nur Page und nicht: // if( FLY_AT_CNTNT == eAnchorId || FLY_IN_CNTNT == eAnchorId || // FLY_AT_FLY == eAnchorId || FLY_AUTO_CNTNT == eAnchorId ) @@ -694,7 +689,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, else eAnchorId = pFmt->GetAnchor().GetAnchorId(); - if( FLY_IN_CNTNT == eAnchorId ) + if ( FLY_AS_CHAR == eAnchorId ) { xub_StrLen nStt = rAnchPos.nContent.GetIndex(); SwTxtNode * pTxtNode = rAnchPos.nNode.GetNode().GetTxtNode(); @@ -751,7 +746,7 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, { SwFlyFrmFmt* pFmt = 0; sal_Bool bCallMake = sal_True; - if( !pAnchorPos && FLY_PAGE != eAnchorType ) + if ( !pAnchorPos && (FLY_AT_PAGE != eAnchorType) ) { const SwFmtAnchor* pAnch; if( (pFlySet && SFX_ITEM_SET == pFlySet->GetItemState( @@ -759,9 +754,14 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, ( pFrmFmt && SFX_ITEM_SET == pFrmFmt->GetItemState( RES_ANCHOR, sal_True, (const SfxPoolItem**)&pAnch )) ) { - if( FLY_PAGE != pAnch->GetAnchorId() && - 0 == ( pAnchorPos = pAnch->GetCntntAnchor() ) ) - bCallMake = sal_False; + if ( (FLY_AT_PAGE != pAnch->GetAnchorId()) ) + { + pAnchorPos = pAnch->GetCntntAnchor(); + if (pAnchorPos) + { + bCallMake = sal_False; + } + } } } @@ -944,7 +944,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, // Anker noch nicht gesetzt ? // DrawObjecte duerfen niemals in Kopf-/Fusszeilen landen. - sal_Bool bIsAtCntnt = FLY_PAGE != eAnchorId; + const bool bIsAtCntnt = (FLY_AT_PAGE != eAnchorId); // FLY_AT_CNTNT == eAnchorId || FLY_IN_CNTNT == eAnchorId || // FLY_AT_FLY == eAnchorId || FLY_AUTO_CNTNT == eAnchorId; @@ -966,7 +966,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, ::CheckControlLayer( &rDrawObj ) && IsInHeaderFooter( *pChkIdx ) ) { - pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId = FLY_PAGE ) ); + pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId = FLY_AT_PAGE ) ); } else if( !pAnchor || (bIsAtCntnt && !pAnchor->GetCntntAnchor() )) { @@ -981,10 +981,10 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, else { aAnch.SetAnchor( rRg.GetPoint() ); - if( FLY_PAGE == eAnchorId ) + if ( FLY_AT_PAGE == eAnchorId ) { eAnchorId = rDrawObj.ISA( SdrUnoObj ) - ? FLY_IN_CNTNT : FLY_AT_CNTNT; + ? FLY_AS_CHAR : FLY_AT_PARA; aAnch.SetType( eAnchorId ); } } @@ -992,7 +992,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, } // bei als Zeichen gebundenen Draws das Attribut im Absatz setzen - if( FLY_IN_CNTNT == eAnchorId ) + if ( FLY_AS_CHAR == eAnchorId ) { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); SwFmtFlyCnt aFmt( pFmt ); @@ -1063,7 +1063,7 @@ sal_Bool TstFlyRange( const SwPaM* pPam, const SwPosition* pFlyPos, const SwPosition* pPaMEnd = pTmp->End(); const sal_uInt32 nPamStartIndex = pPaMStart->nNode.GetIndex(); const sal_uInt32 nPamEndIndex = pPaMEnd->nNode.GetIndex(); - if(FLY_AT_CNTNT == nAnchorId) + if (FLY_AT_PARA == nAnchorId) bOk = (nPamStartIndex < nFlyIndex && nPamEndIndex > nFlyIndex) || (((nPamStartIndex == nFlyIndex) && (pPaMStart->nContent.GetIndex() == 0)) && (nPamEndIndex > nFlyIndex)); @@ -1091,7 +1091,6 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, const SwPaM* pCmpRange, sal_Bool bDrawAlso ) const { SwPosFlyFrm *pFPos = 0; - const SwPosition* pAPos; SwFrmFmt *pFly; // erstmal alle Absatzgebundenen einsammeln @@ -1103,10 +1102,11 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, if( bFlyFmt || bDrawFmt ) { const SwFmtAnchor& rAnchor = pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()))) { if( pCmpRange && !TstFlyRange( pCmpRange, pAPos, rAnchor.GetAnchorId() )) @@ -1140,9 +1140,9 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, continue; const SwFmtAnchor& rAnchor = pFly->GetAnchor(); - if( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AT_FLY != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_FLY != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId())) { const SwCntntFrm * pCntntFrm = pPage->FindFirstBodyCntnt(); if ( !pCntntFrm ) @@ -1387,7 +1387,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //loesen wir vorher die Verbindung zwischen Attribut und Format. const SwFmtAnchor& rAnchor = pNewFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnchor.GetAnchorId() ) { const SwPosition *pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); @@ -1433,7 +1433,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co pNewSet->Put( SvxULSpaceItem(RES_UL_SPACE) ); //Der Alte ist absatzgebunden, und zwar am Absatz im neuen. - SwFmtAnchor aAnch( FLY_AT_CNTNT ); + SwFmtAnchor aAnch( FLY_AT_PARA ); SwNodeIndex aAnchIdx( *pNewFmt->GetCntnt().GetCntntIdx(), 1 ); pNew = aAnchIdx.GetNode().GetTxtNode(); SwPosition aPos( aAnchIdx ); @@ -1684,7 +1684,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewFmt->SetFmtAttr( *pNewSet ); const SwFmtAnchor& rAnchor = pNewFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnchor.GetAnchorId() ) { const SwPosition *pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); @@ -1722,7 +1722,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewSet->Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ) ); //Der Alte ist absatzgebunden, und zwar am Absatz im neuen. - SwFmtAnchor aAnch( FLY_AT_CNTNT ); + SwFmtAnchor aAnch( FLY_AT_PARA ); SwNodeIndex aAnchIdx( *pNewFmt->GetCntnt().GetCntntIdx(), 1 ); pNew = aAnchIdx.GetNode().GetTxtNode(); SwPosition aPos( aAnchIdx ); @@ -2095,15 +2095,17 @@ void SwDoc::SetAllUniqueFlyNames() if( bLoadedFlag ) { const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor(); - if( ( FLY_PAGE == rAnchor.GetAnchorId() && - rAnchor.GetCntntAnchor() ) || + if (((FLY_AT_PAGE == rAnchor.GetAnchorId()) && + rAnchor.GetCntntAnchor()) || // oder werden DrawObjecte rel. zu irgendetwas ausgerichtet? ( RES_DRAWFRMFMT == pFlyFmt->Which() && ( SFX_ITEM_SET == pFlyFmt->GetItemState( RES_VERT_ORIENT )|| SFX_ITEM_SET == pFlyFmt->GetItemState( RES_HORI_ORIENT ))) ) + { bLoadedFlag = sal_False; + } } } @@ -2200,9 +2202,11 @@ sal_Bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const if( pIdx && pFlyNd == &pIdx->GetNode() ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() || + if ((FLY_AT_PAGE == rAnchor.GetAnchorId()) || !rAnchor.GetCntntAnchor() ) + { return sal_False; + } pNd = &rAnchor.GetCntntAnchor()->nNode.GetNode(); pFlyNd = pNd->FindFlyStartNode(); @@ -2247,10 +2251,12 @@ short SwDoc::GetTextDirection( const SwPosition& rPos, { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && - pAnchor->GetCntntAnchor() ) + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && + pAnchor->GetCntntAnchor()) + { pFlyFmt = pAnchor->GetCntntAnchor()->nNode. GetNode().GetFlyFmt(); + } else pFlyFmt = 0; } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index eb208db2e7..16d3bc4162 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -1415,7 +1415,7 @@ void SwDoc::Paste( const SwDoc& rSource ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { aAnchor.SetPageNum( aAnchor.GetPageNum() + /*nStartPageNumber - */1 ); } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 752b146b9f..7ceaffdbda 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -48,9 +48,7 @@ #include #include #include -#ifndef _DOCSORT_HXX #include -#endif #include #include #include @@ -341,18 +339,13 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End(); // Index auf den Start der Selektion - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; - USHORT n; - - for( n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for ( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { - pFmt = (SwFrmFmt*)(*GetSpzFrmFmts())[n]; - pAnchor = &pFmt->GetAnchor(); + SwFrmFmt *const pFmt = static_cast((*GetSpzFrmFmts())[n]); + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); - if( FLY_AT_CNTNT == pAnchor->GetAnchorId() && - 0 != (pAPos = pAnchor->GetCntntAnchor() ) && + if (pAPos && (FLY_AT_PARA == pAnchor->GetAnchorId()) && pStart->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) return FALSE; } @@ -444,7 +437,7 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) DoUndo( FALSE ); - for( n = 0; n < aSortArr.Count(); ++n ) + for ( USHORT n = 0; n < aSortArr.Count(); ++n ) { SwSortTxtElement* pBox = (SwSortTxtElement*)aSortArr[n]; aStart = nBeg + n; diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index a5419368d0..3067fc74a4 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -37,9 +37,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -55,9 +53,7 @@ #include #include #include -#ifndef _SVX_EMPHITEM_HXX #include -#endif #include #include #include @@ -1303,13 +1299,13 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) { if ( get(IDocumentSettingAccess::BROWSE_MODE) ) { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::LINE_CENTER, text::RelOrientation::PRINT_AREA ) ); aSet.Put( SwFmtSurround( SURROUND_NONE ) ); } else { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtSurround( SURROUND_PARALLEL ) ); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::PRINT_AREA ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) ); @@ -1330,7 +1326,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) case RES_POOLFRM_GRAPHIC: case RES_POOLFRM_OLE: { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); aSet.Put( SwFmtSurround( SURROUND_NONE )); @@ -1338,14 +1334,14 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) break; case RES_POOLFRM_FORMEL: { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) ); aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) ); } break; case RES_POOLFRM_MARGINAL: { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); aSet.Put( SwFmtSurround( SURROUND_PARALLEL )); @@ -1358,7 +1354,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) break; case RES_POOLFRM_WATERSIGN: { - aSet.Put( SwFmtAnchor( FLY_PAGE )); + aSet.Put( SwFmtAnchor( FLY_AT_PAGE )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SvxOpaqueItem( FALSE )); @@ -1368,7 +1364,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) case RES_POOLFRM_LABEL: { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) ); aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) ); diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 6bca094d3e..d41ac2ddbd 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -591,14 +591,14 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, } // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) { - SwFrmFmt* pFly = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwFrmFmt *const pFly = (*pDoc->GetSpzFrmFmts())[n]; + SwFmtAnchor const*const pAnchor = &pFly->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aInsIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx ) { pDoc->DelLayoutFmt( pFly ); diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 60b7fe6287..6adb15c039 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -552,20 +552,18 @@ void SwTxtNode::CopyCollFmt( SwTxtNode& rDestNd ) BOOL lcl_ChkFlyFly( SwDoc* pDoc, ULONG nSttNd, ULONG nEndNd, ULONG nInsNd ) { - const SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { - pFmt = rFrmFmtTbl[n]; - pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - ( FLY_IN_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || - FLY_AT_FLY == pAnchor->GetAnchorId() || - FLY_AT_CNTNT == pAnchor->GetAnchorId() ) && + SwFrmFmt const*const pFmt = rFrmFmtTbl[n]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AS_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_FLY == pAnchor->GetAnchorId()) || + (FLY_AT_PARA == pAnchor->GetAnchorId())) && nSttNd <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nEndNd ) { @@ -1398,18 +1396,17 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); _ZSortFlys aArr; USHORT nArrLen = GetSpzFrmFmts()->Count(); - USHORT n; - for( n = 0; n < nArrLen; ++n ) + for ( USHORT n = 0; n < nArrLen; ++n ) { - const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - bool bAtCntnt = pAnchor->GetAnchorId() == FLY_AT_CNTNT; - if ( ( bAtCntnt || - pAnchor->GetAnchorId() == FLY_AT_FLY || - pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFrmFmt const*const pFmt = (*GetSpzFrmFmts())[n]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + bool bAtCntnt = (pAnchor->GetAnchorId() == FLY_AT_PARA); + if ( pAPos && + ( bAtCntnt || + (pAnchor->GetAnchorId() == FLY_AT_FLY) || + (pAnchor->GetAnchorId() == FLY_AT_CHAR)) && (( bCopyFlyAtFly && FLY_AT_FLY == pAnchor->GetAnchorId() ) ? rRg.aStart <= pAPos->nNode.GetIndex() + 1 : ( IsRedlineMove() @@ -1470,7 +1467,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, //die Chains entsprechend aufgebaut werden koennen. SvPtrarr aNewArr( 10, 10 ); - for( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { const _ZSortFly& rZSortFly = aArr[ n ]; @@ -1485,8 +1482,8 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, // method . // Thus, the new anchor position in the destination document is found // by counting the text nodes. - if ( aAnchor.GetAnchorId() == FLY_AT_CNTNT || - aAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) + if ((aAnchor.GetAnchorId() == FLY_AT_PARA) || + (aAnchor.GetAnchorId() == FLY_AT_CHAR) ) { // First, determine number of anchor text node in the copied range. // Note: The anchor text node *have* to be inside the copied range. @@ -1552,7 +1549,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, } // <-- // die am Zeichen Flys wieder ans das vorgegebene Zeichen setzen - if ( FLY_AUTO_CNTNT == aAnchor.GetAnchorId() && + if ((FLY_AT_CHAR == aAnchor.GetAnchorId()) && pNewPos->nNode.GetNode().IsTxtNode() ) { pNewPos->nContent.Assign( (SwTxtNode*)&pNewPos->nNode.GetNode(), @@ -1592,7 +1589,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, ASSERT( aArr.Count() == aNewArr.Count(), "Missing new Flys" ); if ( aArr.Count() == aNewArr.Count() ) { - for ( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { const SwFrmFmt *pFmt = aArr[n].GetFmt(); const SwFmtChain &rChain = pFmt->GetChain(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index afab878b2f..18f1c50ae3 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -38,7 +38,6 @@ #endif #include - #include #include #include @@ -91,9 +90,7 @@ #include #endif #include "docsh.hxx" -#ifdef LINUX #include -#endif #include #include @@ -104,6 +101,9 @@ // --> OD 2005-12-05 #i27138# #include // <-- +#include + + #ifdef PRODUCT #define CHECK_TABLE(t) #else @@ -113,7 +113,6 @@ #define CHECK_TABLE(t) #endif #endif -#include using namespace ::com::sun::star; @@ -1684,17 +1683,19 @@ BOOL SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // #i28006# Fly frames have to be restored even if the table was // #alone in the section const SwSpzFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts(); - const SwPosition* pAPos; for( USHORT n = 0; n < rFlyArr.Count(); ++n ) { - SwFrmFmt* pFmt = (SwFrmFmt*)rFlyArr[n]; + SwFrmFmt *const pFmt = (SwFrmFmt*)rFlyArr[n]; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor() ) && + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && nStt <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nEnd ) + { pFmt->MakeFrms(); + } } return TRUE; diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 69a6f68d90..94afa3dba5 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -38,9 +38,7 @@ #include // <-- #include -#ifndef _COM_SUN_STAR_I18N_CHARACTERITERATORMODE_HDL_ #include -#endif #include #include #include @@ -609,7 +607,7 @@ const SwPageDesc* SwNode::FindPageDesc( BOOL bCalcLay, if( pFmt ) { const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pNd = &pAnchor->GetCntntAnchor()->nNode.GetNode(); @@ -631,7 +629,7 @@ const SwPageDesc* SwNode::FindPageDesc( BOOL bCalcLay, break; } pAnchor = &pFrmFmt->GetAnchor(); - if( FLY_PAGE == pAnchor->GetAnchorId() || + if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) || !pAnchor->GetCntntAnchor() ) { pFlyNd = 0; diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index 01711b931d..47961a47ea 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -31,14 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include -#ifndef _OSL_THREAD_HXX_ #include -#endif #include #include #include @@ -492,18 +489,23 @@ void SwBaseLink::Closed() const SwNode* SwBaseLink::GetAnchor() const { - SwFrmFmt* pFmt; - if( pCntntNode && 0 != ( pFmt = pCntntNode->GetFlyFmt()) ) + if (pCntntNode) { - const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - const SwPosition* pAPos; - if( 0 != ( pAPos = rAnchor.GetCntntAnchor()) && - ( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_AT_CNTNT == rAnchor.GetAnchorId() )) - return &pAPos->nNode.GetNode(); - return 0; + SwFrmFmt *const pFmt = pCntntNode->GetFlyFmt(); + if (pFmt) + { + const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AT_PARA == rAnchor.GetAnchorId()))) + { + return &pAPos->nNode.GetNode(); + } + return 0; + } } ASSERT( !this, "GetAnchor nicht ueberlagert" ); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 93f83256a9..589b745998 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -61,9 +61,7 @@ #include #include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif #include #include #include @@ -80,17 +78,9 @@ #include // AW: For VCOfDrawVirtObj and stuff -#ifndef _SDR_CONTACT_VIEWCONTACTOFVIRTOBJ_HXX #include -#endif - -#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX #include -#endif - -#ifndef _SDR_CONTACT_VIEWOBJECTCONTACTOFSDROBJ_HXX #include -#endif #include @@ -1958,7 +1948,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) switch ( pAnch->GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: { USHORT nPgNum = pAnch->GetPageNum(); SwPageFrm *pPage = static_cast(pRoot->Lower()); @@ -1978,12 +1968,12 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) } break; - case FLY_AUTO_CNTNT: - case FLY_AT_CNTNT: + case FLY_AT_CHAR: + case FLY_AT_PARA: case FLY_AT_FLY: - case FLY_IN_CNTNT: + case FLY_AS_CHAR: { - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { ClrContourCache( GetMaster() ); } @@ -2058,7 +2048,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) // OD 2004-01-20 #110582# - find correct follow for // as character anchored objects. - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT && + if ((pAnch->GetAnchorId() == FLY_AS_CHAR) && pFrm->IsTxtFrm() ) { pFrm = lcl_GetFlyInCntntAnchor( @@ -2076,7 +2066,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) { // append 'virtual' drawing object SwDrawVirtObj* pDrawVirtObj = AddVirtObj(); - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { ClrContourCache( pDrawVirtObj ); } @@ -2087,7 +2077,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) pDrawVirtObj->ActionChanged(); } - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { pFrm->InvalidatePrt(); } diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 08051aa33d..eb88a28f0e 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -34,9 +34,7 @@ #include "hintids.hxx" #include #include -#ifndef _FM_FMMODEL_HXX #include -#endif #include "swtypes.hxx" #include "pagefrm.hxx" @@ -62,8 +60,6 @@ #include -using namespace com::sun::star; - // OD 18.06.2003 #108784# //#ifndef _SVDVMARK_HXX //autogen //#include @@ -74,6 +70,10 @@ using namespace com::sun::star; #include // <-- + +using namespace com::sun::star; + + class SwSdrHdl : public SdrHdl { public: @@ -258,7 +258,7 @@ void SwDrawView::AddCustomHdl() const SwFmtAnchor &rAnchor = pFrmFmt->GetAnchor(); // <-- - if(FLY_IN_CNTNT == rAnchor.GetAnchorId()) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) return; const SwFrm* pAnch; @@ -267,7 +267,7 @@ void SwDrawView::AddCustomHdl() Point aPos(aAnchorPoint); - if ( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { // --> OD 2004-06-24 #i28701# - use last character rectangle saved at object // in order to avoid a format of the anchor frame @@ -1019,7 +1019,7 @@ void SwDrawView::CheckPossibilities() " - missing frame format" ); bProtect = TRUE; } - else if ( FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() && + else if ((FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) && rMrkList.GetMarkCount() > 1 ) { bProtect = TRUE; diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 114ae919a1..70395b2fe4 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -386,7 +386,7 @@ BOOL SwAutoFormat::HasObjects( const SwNode& rNd ) for( USHORT n = 0; n < rFmts.Count(); ++n ) { const SwFmtAnchor& rAnchor = rFmts[ n ]->GetAnchor(); - if( FLY_PAGE != rAnchor.GetAnchorId() && + if ((FLY_AT_PAGE != rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor() && &rAnchor.GetCntntAnchor()->nNode.GetNode() == &rNd ) { diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index d620ff9f5f..4083f8092f 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -64,9 +64,7 @@ #include #include #include -#ifndef _UNOFLDMID_H #include -#endif #include using namespace ::com::sun::star; @@ -187,17 +185,20 @@ const SwTxtNode* GetBodyTxtNode( const SwDoc& rDoc, SwPosition& rPos, pLayout = (SwLayoutFrm*)((SwFlyFrm*)pLayout)->GetAnchorFrm(); continue; } - else if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + else if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { ASSERT( rAnchor.GetCntntAnchor(), "keine gueltige Position" ); rPos = *rAnchor.GetCntntAnchor(); pTxtNode = rPos.nNode.GetNode().GetTxtNode(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() ) - ((SwTxtNode*)pTxtNode)->MakeStartIndex( &rPos.nContent ); + if ( FLY_AT_PARA == rAnchor.GetAnchorId() ) + { + const_cast(pTxtNode)->MakeStartIndex( + &rPos.nContent ); // oder doch besser das Ende vom (Anker-)TextNode nehmen ?? // ((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent ); + } // noch nicht abbrechen, kann ja auch noch im // Header/Footer/Footnote/Fly stehen !! diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index bc66235cde..faf212862b 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -151,14 +151,16 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) SwFrmFmt* pFlyFmt = pFly->GetFmt(); SwFmtAnchor aAnchor( pFlyFmt->GetAnchor() ); - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition aPos( aSttIdx ); - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) + { aPos.nContent.Assign( pTxtNd, 0 ); + } aAnchor.SetAnchor( &aPos ); } pFlyFmt = pClpDoc->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true ); @@ -175,7 +177,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) rSpzFrmFmts.Insert( pFlyFmt, 0 ); } - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) { // JP 13.02.99 Bug 61863: wenn eine Rahmenselektion ins Clipboard // gestellt wird, so muss beim Pasten auch wieder @@ -206,24 +208,25 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) { SfxItemSet aSet( pClpDoc->GetAttrPool(), aFrmFmtSetRange ); - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( &aPos ); aSet.Put( aAnchor ); - SdrObject* pNew = pClpDoc->CloneSdrObj( *pObj, FALSE, TRUE ); + SdrObject *const pNew = + pClpDoc->CloneSdrObj( *pObj, FALSE, TRUE ); SwPaM aTemp(aPos); - pClpDoc->Insert(aTemp, *pNew, &aSet, NULL); + pClpDoc->Insert(aTemp, *pNew, &aSet, NULL); } else { SwDrawContact *pContact = (SwDrawContact*)GetUserCall( pObj ); SwFrmFmt *pFmt = pContact->GetFmt(); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { aAnchor.SetAnchor( &aPos ); } @@ -269,7 +272,9 @@ BOOL lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly, SwCntntFrm* pTmpFrm = rNd.GetCntntNode()->GetFrm( &rInsPt, 0, FALSE ); SwFlyFrm *pTmpFly = pTmpFrm->FindFlyFrm(); if( pTmpFly && bCheckFlyRecur && pFly->IsUpperOf( *pTmpFly ) ) + { bRet = FALSE; + } else if ( FLY_AT_FLY == rAnchor.GetAnchorId() ) { if( pTmpFly ) @@ -281,7 +286,7 @@ BOOL lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly, } else { - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); rAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) ); const SwFrm *pPg = pTmpFrm->FindPageFrm(); rNewPos = pPg->Frm().Pos(); @@ -329,7 +334,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, // in die Gruppe einfuegen, wenns aus einer betretenen Gruppe // kommt oder das Object nicht zeichengebunden ist if( pSrcDrwView->IsGroupEntered() || - FLY_IN_CNTNT != rAnchor.GetAnchorId() ) + (FLY_AS_CHAR != rAnchor.GetAnchorId()) ) { SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove && @@ -345,10 +350,10 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, SwFmtAnchor aAnchor( rAnchor ); Point aNewAnch; - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { if ( this == pDestShell ) { @@ -378,7 +383,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, aNewAnch, FALSE ); } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) ); const SwRootFrm* pTmpRoot = pDestShell->GetLayout(); @@ -406,7 +411,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, if ( pFmt ) { SdrObject* pNew = pFmt->FindSdrObject(); - if( FLY_IN_CNTNT != aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR != aAnchor.GetAnchorId() ) { Point aPos( rInsPt ); aPos -= aNewAnch; @@ -496,10 +501,10 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, bRet = TRUE; Point aNewAnch; - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { if ( this == pDestShell ) { @@ -537,7 +542,7 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, aNewAnch, GetDoc() == pDestShell->GetDoc()); } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) ); const SwRootFrm* pTmpRoot = pDestShell->GetLayout(); @@ -554,7 +559,7 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, SwFrmFmt *pOldFmt = pFlyFmt; pFlyFmt = pDestShell->GetDoc()->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true ); - if( FLY_IN_CNTNT != aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR != aAnchor.GetAnchorId() ) { Point aPos( rInsPt ); aPos -= aNewAnch; @@ -918,7 +923,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( Imp()->GetDrawView()->IsGroupEntered() && RES_DRAWFRMFMT == rCpyFmt.Which() && - FLY_IN_CNTNT != rCpyFmt.GetAnchor().GetAnchorId() ) + (FLY_AS_CHAR != rCpyFmt.GetAnchor().GetAnchorId()) ) { const SdrObject* pSdrObj = rCpyFmt.FindSdrObject(); if( pSdrObj ) @@ -966,9 +971,9 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition* pPos = PCURCRSR->GetPoint(); // #108784# allow shapes (no controls) in header/footer @@ -979,7 +984,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aAnchor.SetAnchor( pPos ); } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( GetPhyPageNum() ); } @@ -1091,7 +1096,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 ); } @@ -1199,7 +1204,7 @@ BOOL SwFEShell::PastePages( SwFEShell& rToFill, USHORT nStartPage, USHORT nEndPa { const SwFrmFmt& rCpyFmt = *(*GetDoc()->GetSpzFrmFmts())[i]; SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() && + if ((FLY_AT_PAGE == aAnchor.GetAnchorId()) && aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage) { aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 640a49f13d..430962ff4e 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -113,7 +113,7 @@ sal_Bool lcl_SetNewFlyPos( const SwNode& rNode, SwFmtAnchor& rAnchor, const SwPageFrm *pPg = pCFrm ? pCFrm->FindPageFrm() : 0; rAnchor.SetPageNum( pPg ? pPg->GetPhyPageNum() : 1 ); - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); } return bRet; } @@ -130,9 +130,9 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, Point aTmpPnt( rPt ); switch( nNew ) { - case FLY_IN_CNTNT: // sollte der nicht auch mit hinein? - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AS_CHAR: // sollte der nicht auch mit hinein? + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL { //Ausgehend von der linken oberen Ecke des Fly den //dichtesten CntntFrm suchen. @@ -146,7 +146,7 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, } SwPosition aPos( *((SwCntntFrm*)pNewAnch)->GetNode() ); - if( FLY_AUTO_CNTNT == nNew || FLY_IN_CNTNT == nNew ) + if ((FLY_AT_CHAR == nNew) || (FLY_AS_CHAR == nNew)) { // es muss ein TextNode gefunden werden, denn nur in diesen // ist ein Inhaltsgebundene Frames zu verankern @@ -186,10 +186,10 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, } } - aNewAnch.SetType( nNew = FLY_PAGE ); + aNewAnch.SetType( nNew = FLY_AT_PAGE ); // no break - case FLY_PAGE: + case FLY_AT_PAGE: pNewAnch = rFrm.FindPageFrm(); aNewAnch.SetPageNum( pNewAnch->GetPhyPageNum() ); break; @@ -219,8 +219,8 @@ sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ) SwDoc* pDoc = (SwDoc*)rFmt.GetDoc(); #ifndef PRODUCT - ASSERT( !(nNew == FLY_PAGE && - (FLY_AT_CNTNT==nOld || FLY_AUTO_CNTNT==nOld || FLY_IN_CNTNT==nOld ) && + ASSERT( !(nNew == FLY_AT_PAGE && + (FLY_AT_PARA==nOld || FLY_AT_CHAR==nOld || FLY_AS_CHAR==nOld ) && pDoc->IsInHeaderFooter( rOldAnch.GetCntntAnchor()->nNode )), "Unerlaubter Ankerwechsel in Head/Foot." ); #endif @@ -441,7 +441,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId(); - if ( FLY_IN_CNTNT == nAnchorId ) + if ( FLY_AS_CHAR == nAnchorId ) return aRet; sal_Bool bFlyFrame = pObj->ISA(SwVirtFlyDrawObj); @@ -462,8 +462,10 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) pOldAnch = pFly->GetAnchorFrm(); if( !pOldAnch ) return aRet; - if( FLY_PAGE != nAnchorId ) + if ( FLY_AT_PAGE != nAnchorId ) + { pFooterOrHeader = pCntnt->FindFooterOrHeader(); + } } // OD 26.06.2003 #108784# - set also for drawing // objects, but not for control objects. @@ -489,14 +491,18 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) const SwFrm *pNewAnch; if( pTxtFrm ) { - if( FLY_PAGE == nAnchorId ) + if ( FLY_AT_PAGE == nAnchorId ) + { pNewAnch = pTxtFrm->FindPageFrm(); + } else { pNewAnch = ::FindAnchor( pTxtFrm, rAbsPos ); if( FLY_AT_FLY == nAnchorId ) // LAYER_IMPL + { pNewAnch = pNewAnch->FindFlyFrm(); + } } } else @@ -522,19 +528,19 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) { aRet = pNewAnch->GetFrmAnchorPos( ::HasWrap( pObj ) ); - if( bMoveIt || nAnchorId == FLY_AUTO_CNTNT ) + if ( bMoveIt || (nAnchorId == FLY_AT_CHAR) ) { SwFmtAnchor aAnch( rFmt.GetAnchor() ); switch ( nAnchorId ) { - case FLY_AT_CNTNT: + case FLY_AT_PARA: { SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); pPos->nNode = *pTxtFrm->GetNode(); pPos->nContent.Assign(0,0); break; } - case FLY_PAGE: + case FLY_AT_PAGE: { aAnch.SetPageNum( ((const SwPageFrm*)pNewAnch)-> GetPhyPageNum() ); @@ -547,7 +553,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) aAnch.SetAnchor( &aPos ); break; } - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: { SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); Point aTmpPnt( rAbsPos ); @@ -666,21 +672,25 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali RndStdIds eRndId = rAnch.GetAnchorId(); switch( eRndId ) { - case FLY_PAGE: + case FLY_AT_PAGE: if( !rAnch.GetPageNum() ) //HotFix: Bug in UpdateByExample rAnch.SetPageNum( 1 ); break; case FLY_AT_FLY: - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: + case FLY_AS_CHAR: if( !bAnchValid ) { if( FLY_AT_FLY != eRndId ) + { rAnch.SetAnchor( &rPos ); + } else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) ) - eRndId = FLY_PAGE; + { + eRndId = FLY_AT_PAGE; + } } break; @@ -698,7 +708,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali SwFmtVertOrient aOldV; SwFmtHoriOrient aOldH; - if( FLY_PAGE != eRndId ) + if ( FLY_AT_PAGE != eRndId ) { // erstmal als mit Seitenbindung, Absatz/Zeichenbindung erst wenn // alles verschoben ist. Dann ist die Position gueltig! @@ -706,7 +716,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali // umsetzen, damit diese beim Umanker NICHT // korrigiert wird pOldAnchor = new SwFmtAnchor( rAnch ); - ((SfxItemSet&)rSet).Put( SwFmtAnchor( FLY_PAGE, 1 ) ); + const_cast(rSet).Put( SwFmtAnchor( FLY_AT_PAGE, 1 ) ); const SfxPoolItem* pItem; if( SFX_ITEM_SET == rSet.GetItemState( RES_HORI_ORIENT, sal_False, &pItem ) @@ -741,8 +751,10 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali const SwFrm* pAnch = ::FindAnchor( GetLayout(), aPt, sal_False ); SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() ); - if( FLY_IN_CNTNT == eRndId ) + if ( FLY_AS_CHAR == eRndId ) + { aPos.nContent.Assign( ((SwCntntFrm*)pAnch)->GetNode(), 0 ); + } pOldAnchor->SetAnchor( &aPos ); // das verschieben von TabelleSelektion ist noch nicht @@ -818,9 +830,9 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; switch( pAnchor->GetAnchorId()) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL + case FLY_AS_CHAR: if( !pAnchor->GetCntntAnchor() ) { pAnchor->SetAnchor( pCursor->GetPoint() ); @@ -833,7 +845,7 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, *pAnchor, GetCrsrDocPos() ); } break; - case FLY_PAGE: + case FLY_AT_PAGE: if( !pAnchor->GetPageNum() ) { pAnchor->SetPageNum( pCursor->GetPageNum( @@ -912,10 +924,10 @@ void SwFEShell::Insert( SdrObject& rDrawObj, const SfxPoolItem* pItem; if( !pFlyAttrSet || !pFlyAttrSet->GetItemState( RES_ANCHOR, sal_False, &pItem ) || - FLY_PAGE != ((SwFmtAnchor*)pItem)->GetAnchorId() ) + (FLY_AT_PAGE != ((SwFmtAnchor*)pItem)->GetAnchorId())) { pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange ); - pSet->Put( SwFmtAnchor( FLY_AT_CNTNT )); + pSet->Put( SwFmtAnchor( FLY_AT_PARA )); pFlyAttrSet = pSet; } @@ -978,8 +990,10 @@ void SwFEShell::GetPageObjs( SvPtrarr& rFillArr ) for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) { pFmt = (const SwFrmFmt*)(*pDoc->GetSpzFrmFmts())[n]; - if( FLY_PAGE == pFmt->GetAnchor().GetAnchorId() ) + if (FLY_AT_PAGE == pFmt->GetAnchor().GetAnchorId()) + { rFillArr.Insert( (VoidPtr)pFmt, rFillArr.Count() ); + } } } @@ -1010,7 +1024,7 @@ void SwFEShell::SetPageObjsNewPage( SvPtrarr& rFillArr, int nOffset ) { // FlyFmt ist noch gueltig, also behandeln SwFmtAnchor aNewAnchor( pFmt->GetAnchor() ); - if( FLY_PAGE != aNewAnchor.GetAnchorId() || + if ((FLY_AT_PAGE != aNewAnchor.GetAnchorId()) || 0 >= ( nNewPage = aNewAnchor.GetPageNum() + nOffset ) ) // chaos::Anchor wurde veraendert oder ungueltige SeitenNummer, // also nicht veraendern !! @@ -1086,12 +1100,12 @@ sal_Bool SwFEShell::GetFlyFrmAttr( SfxItemSet &rSet ) const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; RndStdIds eType = pAnchor->GetAnchorId(); - if( FLY_PAGE != eType ) + if ( FLY_AT_PAGE != eType ) { // OD 12.11.2003 #i22341# - content anchor of anchor item is needed. // Thus, don't overwrite anchor item by default contructed anchor item. //rSet.Put( SwFmtAnchor( eType ) ); - if( FLY_IN_CNTNT == eType ) + if ( FLY_AS_CHAR == eType ) { rSet.ClearItem( RES_OPAQUE ); rSet.ClearItem( RES_SURROUND ); @@ -1828,7 +1842,7 @@ ObjCntType SwFEShell::GetObjCntType( const SdrObject& rObj ) const " - missing frame format" ); eType = OBJCNT_NONE; } - else if ( FLY_IN_CNTNT != pFrmFmt->GetAnchor().GetAnchorId() ) + else if ( FLY_AS_CHAR != pFrmFmt->GetAnchor().GetAnchorId() ) { eType = OBJCNT_GROUPOBJ; } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index e8c849cee0..d7e0e4e02e 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -326,7 +326,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); SwFmtAnchor aAnch( rFmt.GetAnchor() ); RndStdIds nAnchorId = aAnch.GetAnchorId(); - if ( FLY_IN_CNTNT == nAnchorId ) + if ( FLY_AS_CHAR == nAnchorId ) return sal_False; if( pOld->IsVertical() ) { @@ -348,7 +348,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } } switch ( nAnchorId ) { - case FLY_PAGE: + case FLY_AT_PAGE: { ASSERT( pOld->IsPageFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_UP == nDir ) @@ -362,7 +362,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } break; } - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: { ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_LEFT == nDir || SW_MOVE_RIGHT == nDir ) @@ -396,7 +396,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } } } // no break! - case FLY_AT_CNTNT: + case FLY_AT_PARA: { ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_UP == nDir ) @@ -1652,7 +1652,7 @@ BOOL SwFEShell::ImpEndCreate() if( bCharBound ) { - aAnch.SetType( FLY_IN_CNTNT ); + aAnch.SetType( FLY_AS_CHAR ); aAnch.SetAnchor( &aPos ); } } @@ -1719,7 +1719,7 @@ BOOL SwFEShell::ImpEndCreate() bAtPage = true; else { - aAnch.SetType( FLY_AT_CNTNT ); + aAnch.SetType( FLY_AT_PARA ); aAnch.SetAnchor( &aPos ); } } @@ -1728,7 +1728,7 @@ BOOL SwFEShell::ImpEndCreate() { pPage = pAnch->FindPageFrm(); - aAnch.SetType( FLY_PAGE ); + aAnch.SetType( FLY_AT_PAGE ); aAnch.SetPageNum( pPage->GetPhyPageNum() ); pAnch = pPage; // die Page wird jetzt zum Anker } @@ -1871,7 +1871,7 @@ BOOL SwFEShell::ImpEndCreate() // <-- if( bCharBound ) { - ASSERT( aAnch.GetAnchorId() == FLY_IN_CNTNT, "wrong AnchorType" ); + ASSERT( aAnch.GetAnchorId() == FLY_AS_CHAR, "wrong AnchorType" ); SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); SwFmtFlyCnt aFmt( pFmt ); pNd->InsertItem(aFmt, @@ -2256,7 +2256,7 @@ BOOL SwFEShell::IsGroupSelected() // --> FME 2004-12-08 #i38505# No ungroup allowed for 3d objects !pObj->Is3DObj() && // <-- - FLY_IN_CNTNT != ((SwDrawContact*)GetUserCall(pObj))-> + FLY_AS_CHAR != ((SwDrawContact*)GetUserCall(pObj))-> GetFmt()->GetAnchor().GetAnchorId() ) { return TRUE; @@ -2302,7 +2302,7 @@ bool SwFEShell::IsGroupAllowed() const " - missing frame format" ); bIsGroupAllowed = false; } - else if ( FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + else if ( FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() ) { bIsGroupAllowed = false; } @@ -2619,7 +2619,7 @@ BOOL SwFEShell::IsAlignPossible() const SdrObject *pO = Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); SwDrawContact *pC = (SwDrawContact*)GetUserCall(pO); //only as character bound drawings can be aligned - bRet = pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_IN_CNTNT; + bRet = (pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_AS_CHAR); } if ( bRet ) return Imp()->GetDrawView()->IsAlignPossible(); @@ -2664,7 +2664,7 @@ void SwFEShell::CheckUnboundObjects() { pAnch = ::FindAnchor( pPage, aPt, TRUE ); SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() ); - aAnch.SetType( FLY_AT_CNTNT ); + aAnch.SetType( FLY_AT_PARA ); aAnch.SetAnchor( &aPos ); ((SwRect&)GetCharRect()).Pos() = aPt; } diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index 4485ba99f6..fd2939fc27 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -31,11 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include -//#ifndef _SVDVMARK_HXX //autogen -//#include -//#endif #include #include #include @@ -71,8 +67,10 @@ // OD 2004-03-29 #i26791# #include + using namespace com::sun::star; + TYPEINIT1(SwFEShell,SwEditShell) /*********************************************************************** @@ -780,12 +778,12 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, BOOL bVertic = FALSE; BOOL bRTL = FALSE; - if( FLY_PAGE == _nAnchorId || FLY_AT_FLY == _nAnchorId ) // LAYER_IMPL + if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL { const SwFrm* pTmp = pFrm; // OD 06.11.2003 #i22305# - if ( FLY_PAGE == _nAnchorId || - ( FLY_AT_FLY == _nAnchorId && !_bFollowTextFlow ) ) + if ((FLY_AT_PAGE == _nAnchorId) || + ((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow)) { pFrm = pPage; } @@ -906,7 +904,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, aPos = (pFrm->Frm().*fnRect->fnGetPos)(); // OD 08.09.2003 #i17567#, #108749#, #110354# - allow negative positions // for fly frames anchor to paragraph/to character. - if ( _nAnchorId == FLY_AT_CNTNT || _nAnchorId == FLY_AUTO_CNTNT ) + if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR)) { // The rectangle, the fly frame can be positioned in, is determined // horizontally by the frame area of the horizontal environment @@ -985,7 +983,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // fly frame). Thus, assure this. const SwTxtFrm* pTxtFrm( dynamic_cast(pFrm) ); if ( pTxtFrm && - _nAnchorId == FLY_AUTO_CNTNT && + (_nAnchorId == FLY_AT_CHAR) && ( _eVertRelOrient == text::RelOrientation::CHAR || _eVertRelOrient == text::RelOrientation::TEXT_LINE ) ) { @@ -1032,7 +1030,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // position ( respectively ), if object is // anchored to character and horizontal aligned at character. if ( pTxtFrm && - _nAnchorId == FLY_AUTO_CNTNT && + (_nAnchorId == FLY_AT_CHAR) && _eHoriRelOrient == text::RelOrientation::CHAR ) { SwTwips nLeft = 0L; diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 26eed5bdf8..6979478c33 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -984,11 +985,11 @@ BOOL IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) for( USHORT n = 0; n < rFmts.Count(); ++n ) { - const SwPosition* pAPos; const SwFmtAnchor& rAnchor = rFmts[n]->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor() ) && + const SwPosition* pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && nSttIdx <= ( nIdx = pAPos->nNode.GetIndex() ) && nIdx < nEndIdx ) { diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index 8312125fc6..ed19901729 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -109,10 +109,10 @@ protected: //(CheckClip) nur das Format aufgerufen wird; //nicht aber die Breite anhand der Attribute //wieder bestimmt wird. - BOOL bInCnt :1; // FLY_IN_CNTNT, als Zeichen verankert - BOOL bAtCnt :1; // FLY_AT_CNTNT, am Absatz verankert - BOOL bLayout :1; // FLY_PAGE, FLY_AT_FLY, an Seite oder Rahmen - BOOL bAutoPosition :1; // FLY_AUTO_CNTNT, im Text verankerter Rahmen + BOOL bInCnt :1; // FLY_AS_CHAR, anchored as character + BOOL bAtCnt :1; // FLY_AT_PARA, anchored at paragraph + BOOL bLayout :1; // FLY_AT_PAGE, FLY_AT_FLY, at page or at frame + BOOL bAutoPosition :1; // FLY_AT_CHAR, anchored at character BOOL bNoShrink :1; // temporary forbud of shrinking to avoid loops BOOL bLockDeleteContent :1; // If the flag is set, the content of the // fly frame is not deleted if moved to diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index e2376f3d8e..7762216928 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -37,12 +37,8 @@ #include #include #include -#ifndef _TOCNTNTANCHOROBJECTPOSITION_HXX #include -#endif -#ifndef _TOLAYOUTANCHOROBJECTPOSITION_HXX #include -#endif #include #include // --> OD 2004-08-12 #i32795# @@ -357,7 +353,7 @@ void SwAnchoredDrawObject::MakeObjPos() // determine relative position of drawing object and set it switch ( pDrawContact->GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: { // indicate that position will be valid after positioning is performed mbValidPos = true; @@ -365,15 +361,15 @@ void SwAnchoredDrawObject::MakeObjPos() // during the format of its anchor frame - see } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { // --> OD 2004-08-12 #i32795# - move intrinsic positioning to // helper method <_MakeObjPosAnchoredAtPara()> _MakeObjPosAnchoredAtPara(); } break; - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: { // --> OD 2004-08-12 #i32795# - move intrinsic positioning to @@ -603,7 +599,7 @@ void SwAnchoredDrawObject::_InvalidatePage( SwPageFrm* _pPageFrm ) { // --> OD 2004-11-11 #i35007# - correct invalidation for as-character // anchored objects. - if ( GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if ( GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR ) { _pPageFrm->InvalidateFlyInCnt(); } @@ -645,7 +641,7 @@ void SwAnchoredDrawObject::InvalidateObjPos() // --> OD 2005-03-09 #i44559# - assure, that text hint is already // existing in the text frame if ( GetAnchorFrm()->ISA(SwTxtFrm) && - GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + (GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { SwTxtFrm* pAnchorTxtFrm( static_cast(AnchorFrm()) ); if ( pAnchorTxtFrm->GetTxtNode()->GetpSwpHints() && diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx index eed807f6f2..25aee1b555 100644 --- a/sw/source/core/layout/anchoredobject.cxx +++ b/sw/source/core/layout/anchoredobject.cxx @@ -306,7 +306,7 @@ void SwAnchoredObject::CheckCharRectAndTopOfLine( GetAnchorFrm()->IsTxtFrm() ) { const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT && + if ( (rAnch.GetAnchorId() == FLY_AT_CHAR) && rAnch.GetCntntAnchor() ) { // --> OD 2004-07-14 #117380# - if requested, assure that anchor frame, @@ -540,8 +540,8 @@ bool SwAnchoredObject::ConsiderObjWrapInfluenceOnObjPos() const // <-- { const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor(); - if ( ( rAnchor.GetAnchorId() == FLY_AUTO_CNTNT || - rAnchor.GetAnchorId() == FLY_AT_CNTNT ) && + if ( ((rAnchor.GetAnchorId() == FLY_AT_CHAR) || + (rAnchor.GetAnchorId() == FLY_AT_PARA)) && rObjFmt.GetSurround().GetSurround() != SURROUND_THROUGHT ) { // --> OD 2004-09-23 #i34520# - text also wraps around anchored @@ -792,7 +792,7 @@ void SwAnchoredObject::UpdateObjInSortedList() AnchorFrm()->GetDrawObjs()->Update( *this ); // update its position in the sorted object list of its page frame // note: as-character anchored object aren't registered at a page frame - if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR ) { GetPageFrm()->GetSortedObjs()->Update( *this ); } @@ -859,8 +859,8 @@ SwTxtFrm* SwAnchoredObject::FindAnchorCharFrm() if ( mpAnchorFrm ) { const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT || - rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if ((rAnch.GetAnchorId() == FLY_AT_CHAR) || + (rAnch.GetAnchorId() == FLY_AS_CHAR)) { pAnchorCharFrm = &(static_cast(AnchorFrm())-> GetFrmAtOfst( rAnch.GetCntntAnchor()->nContent.GetIndex() )); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index e327b0bbdf..011e62014e 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -51,9 +51,7 @@ #include #include #include -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include -#endif #include #include #include @@ -79,9 +77,7 @@ #include #include #include -#ifndef _FMTLINE_HXX #include -#endif #include #include #include @@ -110,18 +106,12 @@ #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _UNOMID_H #include -#endif #ifndef _COMCORE_HRC #include #endif -#ifndef _SVX_SVUNDO_HXX #include // #111827# -#endif // OD 2004-05-24 #i28701# #include // --> OD 2006-03-06 #125892# @@ -1484,9 +1474,11 @@ void SwFmtAnchor::SetAnchor( const SwPosition *pPos ) delete pCntntAnchor; pCntntAnchor = pPos ? new SwPosition( *pPos ) : 0; //AM Absatz gebundene Flys sollten nie in den Absatz hineinzeigen. - if ( pCntntAnchor && ( FLY_AT_CNTNT == nAnchorId || - FLY_AT_FLY == nAnchorId )) + if (pCntntAnchor && + ((FLY_AT_PARA == nAnchorId) || (FLY_AT_FLY == nAnchorId))) + { pCntntAnchor->nContent.Assign( 0, 0 ); + } } SwFmtAnchor& SwFmtAnchor::operator=(const SwFmtAnchor& rAnchor) @@ -1543,14 +1535,23 @@ BOOL SwFmtAnchor::QueryValue( uno::Any& rVal, BYTE nMemberId ) const case MID_ANCHOR_ANCHORTYPE: text::TextContentAnchorType eRet; - switch((sal_Int16)GetAnchorId()) + switch (GetAnchorId()) { - case FLY_AUTO_CNTNT : eRet = text::TextContentAnchorType_AT_CHARACTER;break; - case FLY_PAGE : eRet = text::TextContentAnchorType_AT_PAGE; break; - case FLY_AT_FLY : eRet = text::TextContentAnchorType_AT_FRAME; break; - case FLY_IN_CNTNT : eRet = text::TextContentAnchorType_AS_CHARACTER;break; - //case FLY_AT_CNTNT : - default: eRet = text::TextContentAnchorType_AT_PARAGRAPH; + case FLY_AT_CHAR: + eRet = text::TextContentAnchorType_AT_CHARACTER; + break; + case FLY_AT_PAGE: + eRet = text::TextContentAnchorType_AT_PAGE; + break; + case FLY_AT_FLY: + eRet = text::TextContentAnchorType_AT_FRAME; + break; + case FLY_AS_CHAR: + eRet = text::TextContentAnchorType_AS_CHARACTER; + break; + //case FLY_AT_PARA: + default: + eRet = text::TextContentAnchorType_AT_PARAGRAPH; } rVal <<= eRet; break; @@ -1591,10 +1592,10 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) switch( SWUnoHelper::GetEnumAsInt32( rVal ) ) { case text::TextContentAnchorType_AS_CHARACTER: - eAnchor = FLY_IN_CNTNT; + eAnchor = FLY_AS_CHAR; break; case text::TextContentAnchorType_AT_PAGE: - eAnchor = FLY_PAGE; + eAnchor = FLY_AT_PAGE; if( GetPageNum() > 0 && pCntntAnchor ) { // If the anchor type is page and a valid page number @@ -1608,11 +1609,11 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) eAnchor = FLY_AT_FLY; break; case text::TextContentAnchorType_AT_CHARACTER: - eAnchor = FLY_AUTO_CNTNT; + eAnchor = FLY_AT_CHAR; break; //case text::TextContentAnchorType_AT_PARAGRAPH: default: - eAnchor = FLY_AT_CNTNT; + eAnchor = FLY_AT_PARA; break; } SetType( eAnchor ); @@ -1624,7 +1625,7 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) if((rVal >>= nVal) && nVal > 0) { SetPageNum( nVal ); - if( FLY_PAGE == GetAnchorId() && pCntntAnchor ) + if ((FLY_AT_PAGE == GetAnchorId()) && pCntntAnchor) { // If the anchor type is page and a valid page number // is set, the content paoition has to be deleted to not @@ -2597,7 +2598,7 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const // dann mal ueber die Node-Positionen versuchen const SwFmtAnchor* pAnchor = &rFmt.GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && pAnchor->GetCntntAnchor() ) + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). @@ -2616,9 +2617,11 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const return sal_True; pAnchor = &pFmt->GetAnchor(); - if( FLY_PAGE == pAnchor->GetAnchorId() || + if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) || !pAnchor->GetCntntAnchor() ) + { return sal_False; + } pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). FindFlyStartNode(); @@ -2702,11 +2705,13 @@ void SwFlyFrmFmt::MakeFrms() SwFmtAnchor aAnchorAttr( GetAnchor() ); switch( aAnchorAttr.GetAnchorId() ) { - case FLY_IN_CNTNT: - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_PARA: + case FLY_AT_CHAR: if( aAnchorAttr.GetCntntAnchor() ) + { pModify = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); + } break; case FLY_AT_FLY: @@ -2739,7 +2744,7 @@ void SwFlyFrmFmt::MakeFrms() } break; - case FLY_PAGE: + case FLY_AT_PAGE: { sal_uInt16 nPgNum = aAnchorAttr.GetPageNum(); SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetRootFrm()->Lower(); @@ -2822,12 +2827,12 @@ void SwFlyFrmFmt::MakeFrms() pFly = new SwFlyLayFrm( this, pFrm ); break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: pFly = new SwFlyAtCntFrm( this, pFrm ); break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: pFly = new SwFlyInCntFrm( this, pFrm ); break; default: @@ -3026,8 +3031,8 @@ SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrmFmt& _rFlyFrmFmt, mbAnchorNodeChanged( false ) { const RndStdIds nNewAnchorType( _rNewAnchorFmt.GetAnchorId() ); - if ( ( nNewAnchorType == FLY_AT_CNTNT || - nNewAnchorType == FLY_AUTO_CNTNT ) && + if ( ((nNewAnchorType == FLY_AT_PARA) || + (nNewAnchorType == FLY_AT_CHAR)) && _rNewAnchorFmt.GetCntntAnchor() && _rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() ) { diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index bb73a85bbc..ac438bf36c 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -46,9 +46,7 @@ #include #include -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -1014,10 +1012,12 @@ BOOL SwCntntFrm::MakePrtArea( const SwBorderAttrs &rAttrs ) rFmt.GetFrmSize().GetWidthPercent() ) continue; - if ( FLY_IN_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + if ( FLY_AS_CHAR == rFmt.GetAnchor().GetAnchorId() ) + { nMinWidth = Max( nMinWidth, bFly ? rFmt.GetFrmSize().GetWidth() : pObj->GetObjRect().Width() ); + } // <-- } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 4968601e7a..1073421e01 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -366,7 +366,7 @@ BYTE SwFlowFrm::BwdMoveNecessary( const SwPageFrm *pPage, const SwRect &rRect ) //denn dann weiche ich ihm nicht aus. if ( ::IsFrmInSameKontext( pAnchor, &rThis ) ) { - if ( rFmt.GetAnchor().GetAnchorId() == FLY_AT_CNTNT ) + if ( rFmt.GetAnchor().GetAnchorId() == FLY_AT_PARA ) { // Den Index des anderen erhalten wir immer ueber das Ankerattr. ULONG nTmpIndex = rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex(); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 8899002e4e..cce759e58f 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -33,9 +33,7 @@ #include "hintids.hxx" #include #include -#ifndef _GRAPH_HXX //autogen #include -#endif #include #include #include @@ -1182,7 +1180,7 @@ void SwFlyFrm::ChgRelPos( const Point &rNewPos ) // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored // Writer fly frames const RndStdIds eAnchorType = GetFrmFmt().GetAnchor().GetAnchorId(); - if ( eAnchorType == FLY_PAGE ) + if ( eAnchorType == FLY_AT_PAGE ) { aVert.SetVertOrient( text::VertOrientation::NONE ); aVert.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); @@ -1235,7 +1233,7 @@ void SwFlyFrm::ChgRelPos( const Point &rNewPos ) SwFmtHoriOrient aHori( pFmt->GetHoriOrient() ); // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored // Writer fly frames - if ( eAnchorType == FLY_PAGE ) + if ( eAnchorType == FLY_AT_PAGE ) { aHori.SetHoriOrient( text::HoriOrientation::NONE ); aHori.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); @@ -1645,11 +1643,17 @@ void CalcCntnt( SwLayoutFrm *pLay, { // Bei autopositionierten hilft manchmal nur // noch, auf Durchlauf zu schalten - if( rFmt.GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT && - SURROUND_PARALLEL == aAttr.GetSurround() ) + if ((rFmt.GetAnchor().GetAnchorId() == + FLY_AT_CHAR) && + (SURROUND_PARALLEL == + aAttr.GetSurround())) + { aAttr.SetSurround( SURROUND_THROUGHT ); + } else + { aAttr.SetSurround( SURROUND_PARALLEL ); + } rFmt.LockModify(); rFmt.SetFmtAttr( aAttr ); rFmt.UnlockModify(); @@ -2313,7 +2317,8 @@ void SwFrm::InvalidateObjs( const bool _bInvaPosOnly, { SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i]; if ( _bNoInvaOfAsCharAnchoredObjs && - pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + (pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() + == FLY_AS_CHAR) ) { continue; } diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 1fadf0378f..ece6233db2 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -90,7 +90,7 @@ SwFlyAtCntFrm::SwFlyAtCntFrm( SwFlyFrmFmt *pFmt, SwFrm *pAnch ) : SwFlyFreeFrm( pFmt, pAnch ) { bAtCnt = TRUE; - bAutoPosition = FLY_AUTO_CNTNT == pFmt->GetAnchor().GetAnchorId(); + bAutoPosition = (FLY_AT_CHAR == pFmt->GetAnchor().GetAnchorId()); } // --> OD 2004-06-29 #i28701# diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 85d8ac89c1..b36cd2c176 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -600,7 +600,7 @@ void SwFlyLayFrm::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) SwPageFrm *pOldPage = GetPageFrm(); AnchorFrm()->RemoveFly( this ); - if( FLY_PAGE == pAnch->GetAnchorId() ) + if ( FLY_AT_PAGE == pAnch->GetAnchorId() ) { USHORT nPgNum = pAnch->GetPageNum(); SwRootFrm *pRoot = FindRootFrm(); @@ -955,7 +955,7 @@ void SwPageFrm::AppendDrawObjToPage( SwAnchoredObject& _rNewObj ) _rNewObj.DrawObj()->SetOrdNum( nNewNum ); } - if ( FLY_IN_CNTNT == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() ) + if ( FLY_AS_CHAR == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() ) { return; } @@ -999,7 +999,8 @@ void SwPageFrm::RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj ) } if ( GetUpper() ) { - if ( FLY_IN_CNTNT != _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId() ) + if (FLY_AS_CHAR != + _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId()) { ((SwRootFrm*)GetUpper())->SetSuperfluous(); InvalidatePage(); @@ -1333,7 +1334,7 @@ BOOL CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, BOOL bMove ) const SwDrawContact *pC = (const SwDrawContact*)GetUserCall(pSdrObj); const SwFrmFmt *pFmt = (const SwFrmFmt*)pC->GetFmt(); const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if ( FLY_IN_CNTNT == rAnch.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnch.GetAnchorId() ) { const SwFrm* pAnchorFrm = pC->GetAnchorFrm( pSdrObj ); if( !pAnchorFrm ) diff --git a/sw/source/core/layout/flypos.cxx b/sw/source/core/layout/flypos.cxx index 3800fcf03f..27571f6527 100644 --- a/sw/source/core/layout/flypos.cxx +++ b/sw/source/core/layout/flypos.cxx @@ -57,8 +57,10 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, { BOOL bFnd = FALSE; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) + { pNdIdx = new SwNodeIndex( rIdx ); + } else if( pFmt->GetDoc()->GetRootFrm() ) { SwClientIter aIter( (SwFmt&)*pFmt ); @@ -88,8 +90,10 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, SwPosFlyFrm::~SwPosFlyFrm() { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) + { delete pNdIdx; + } } BOOL SwPosFlyFrm::operator==( const SwPosFlyFrm& ) diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 756269cd03..6c89d2b20c 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1033,9 +1033,11 @@ SwCntntNotify::~SwCntntNotify() SwFrmFmt *pFmt = (*pTbl)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if ( FLY_PAGE != rAnch.GetAnchorId() && - FLY_AT_CNTNT != rAnch.GetAnchorId() ) + if ((FLY_AT_PAGE != rAnch.GetAnchorId()) && + (FLY_AT_PARA != rAnch.GetAnchorId())) + { continue; //#60878# nicht etwa zeichengebundene. + } BOOL bCheckPos = FALSE; if ( rAnch.GetCntntAnchor() ) @@ -1047,7 +1049,7 @@ SwCntntNotify::~SwCntntNotify() if ( rAnch.GetCntntAnchor()->nNode == *pIdx ) { bCheckPos = TRUE; - if ( FLY_PAGE == rAnch.GetAnchorId() ) + if (FLY_AT_PAGE == rAnch.GetAnchorId()) { ASSERT( false, " - to page anchored object with content position. Please inform OD." ); SwFmtAnchor aAnch( rAnch ); @@ -1097,7 +1099,7 @@ SwCntntNotify::~SwCntntNotify() { SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_AUTO_CNTNT ) + == FLY_AT_CHAR ) { pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrm->IsEmpty() ); } @@ -1135,11 +1137,11 @@ void AppendObjs( const SwSpzFrmFmts *pTbl, ULONG nIndex, // OD 23.06.2003 #108784# - append also drawing objects anchored // as character. const bool bDrawObjInCntnt = bSdrObj && - rAnch.GetAnchorId() == FLY_IN_CNTNT; + (rAnch.GetAnchorId() == FLY_AS_CHAR); if( bFlyAtFly || - rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT || + (rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR) || bDrawObjInCntnt ) { SdrObject* pSdrObj = 0; @@ -1227,7 +1229,7 @@ bool lcl_InHeaderOrFooter( SwFrmFmt& _rFmt ) const SwFmtAnchor& rAnch = _rFmt.GetAnchor(); - if ( rAnch.GetAnchorId() != FLY_PAGE ) + if (rAnch.GetAnchorId() != FLY_AT_PAGE) { bRetVal = _rFmt.GetDoc()->IsInHeaderFooter( rAnch.GetCntntAnchor()->nNode ); } @@ -1256,10 +1258,13 @@ void AppendAllObjs( const SwSpzFrmFmts *pTbl ) SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ USHORT(i) ]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); BOOL bRemove = FALSE; - if ( rAnch.GetAnchorId() == FLY_PAGE || rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if ((rAnch.GetAnchorId() == FLY_AT_PAGE) || + (rAnch.GetAnchorId() == FLY_AS_CHAR)) + { //Seitengebunde sind bereits verankert, zeichengebundene //will ich hier nicht. bRemove = TRUE; + } else if ( FALSE == (bRemove = ::lcl_ObjConnected( pFmt )) || ::lcl_InHeaderOrFooter( *pFmt ) ) { @@ -2578,7 +2583,7 @@ void MA_FASTCALL lcl_RemoveObjsFromPage( SwFrm* _pFrm ) // --> OD 2004-11-29 #115759# - remove also drawing objects from page else if ( pObj->ISA(SwAnchoredDrawObject) ) { - if ( pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR) { pObj->GetPageFrm()->RemoveDrawObjFromPage( *(static_cast(pObj)) ); @@ -2746,7 +2751,7 @@ void MA_FASTCALL lcl_AddObjsToPage( SwFrm* _pFrm, SwPageFrm* _pPage ) // --> OD 2004-11-29 #115759# - remove also drawing objects from page else if ( pObj->ISA(SwAnchoredDrawObject) ) { - if ( pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR) { pObj->InvalidateObjPos(); _pPage->AppendDrawObjToPage( diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index aff3c4e07e..c4038bc414 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -63,17 +63,16 @@ #include // --> OD 2006-03-22 #b6375613# #include -#ifndef _DOCSH_HXX #include -#endif #include #include +#include + + using namespace ::com::sun::star; // <-- -#include - SV_IMPL_PTRARR( SwPageFlyCache, SwFlyCachePtr ) /*-----------------28.5.2001 10:06------------------ @@ -696,8 +695,8 @@ bool lcl_HasTextFrmAnchoredObjs( SwTxtFrm* p_pTxtFrm ) SwFrmFmt *pFmt = (SwFrmFmt*)(*pSpzFrmFmts)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); if ( rAnch.GetCntntAnchor() && - ( rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT ) && + ((rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR)) && rAnch.GetCntntAnchor()->nNode.GetIndex() == p_pTxtFrm->GetTxtNode()->GetIndex() ) { diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx index ded11f9796..a89e2cd07e 100644 --- a/sw/source/core/layout/objectformatter.cxx +++ b/sw/source/core/layout/objectformatter.cxx @@ -338,7 +338,7 @@ void SwObjectFormatter::_FormatObj( SwAnchoredObject& _rAnchoredObj ) // check, if only as-character anchored object have to be formatted, and // check the anchor type if ( FormatOnlyAsCharAnchored() && - !_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { return; } diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 2967d8a97a..c1956e4b22 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -136,7 +136,7 @@ bool SwObjectFormatterTxtFrm::DoFormatObj( SwAnchoredObject& _rAnchoredObj, // check, if only as-character anchored object have to be formatted, and // check the anchor type if ( FormatOnlyAsCharAnchored() && - !_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { return true; } @@ -656,8 +656,8 @@ bool SwObjectFormatterTxtFrm::CheckMovedFwdCondition( // which will be on the next page. if ( !bAnchorIsMovedForward && _bAnchoredAtMasterBeforeFormatAnchor && - ( _rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT || - _rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CNTNT ) ) + ((_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) || + (_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_PARA))) { SwFrm* pAnchorFrm = _rAnchoredObj.GetAnchorFrmContainingAnchPos(); ASSERT( pAnchorFrm->IsTxtFrm(), diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index cf45cba307..c36cb678a5 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -46,9 +46,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include "viewimp.hxx" #include "pagefrm.hxx" @@ -408,7 +406,7 @@ void MA_FASTCALL lcl_MakeObjs( const SwSpzFrmFmts &rTbl, SwPageFrm *pPage ) { if( rAnch.GetCntntAnchor() ) { - if( FLY_PAGE == rAnch.GetAnchorId() ) + if (FLY_AT_PAGE == rAnch.GetAnchorId()) { SwFmtAnchor aAnch( rAnch ); aAnch.SetAnchor( 0 ); @@ -1659,7 +1657,7 @@ void SwRootFrm::AssertPageFlys( SwPageFrm *pPage ) SwFrmFmt& rFmt = (*pPage->GetSortedObjs())[i]->GetFrmFmt(); const SwFmtAnchor &rAnch = rFmt.GetAnchor(); const USHORT nPg = rAnch.GetPageNum(); - if ( rAnch.GetAnchorId() == FLY_PAGE && + if ((rAnch.GetAnchorId() == FLY_AT_PAGE) && nPg != pPage->GetPhyPageNum() ) { //Das er auf der falschen Seite steht muss noch nichts @@ -1834,11 +1832,11 @@ void SwRootFrm::ImplCalcBrowseWidth() long nWidth = 0; switch ( rFmt.GetAnchor().GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: nWidth = bFly ? rFmt.GetFrmSize().GetWidth() : pAnchoredObj->GetObjRect().Width(); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: { // --> FME 2004-09-13 #i33170# // Reactivated old code because @@ -2007,7 +2005,7 @@ void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset ) // all except from the as character anchored objects are moved // when processing the page frame: - const bool bAsChar = rAnchor.GetAnchorId() == FLY_IN_CNTNT; + const bool bAsChar = (rAnchor.GetAnchorId() == FLY_AS_CHAR); if ( !bPage && !bAsChar ) continue; diff --git a/sw/source/core/layout/sortedobjsimpl.cxx b/sw/source/core/layout/sortedobjsimpl.cxx index bd4e128dc4..024e35a355 100644 --- a/sw/source/core/layout/sortedobjsimpl.cxx +++ b/sw/source/core/layout/sortedobjsimpl.cxx @@ -41,17 +41,14 @@ #include #include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif + using namespace ::com::sun::star; typedef std::vector< SwAnchoredObject* >::iterator tIter; typedef std::vector< SwAnchoredObject* >::const_iterator tConstIter; -using namespace ::com::sun::star; - SwSortedObjsImpl::SwSortedObjsImpl() { @@ -96,36 +93,36 @@ struct ObjAnchorOrder const SwFmtAnchor* pAnchorNew = &(rFmtNew.GetAnchor()); // check for to-page anchored objects - if ( pAnchorListed->GetAnchorId() == FLY_PAGE && - pAnchorNew->GetAnchorId() != FLY_PAGE ) + if ((pAnchorListed->GetAnchorId() == FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() != FLY_AT_PAGE)) { return true; } - else if ( pAnchorListed->GetAnchorId() != FLY_PAGE && - pAnchorNew->GetAnchorId() == FLY_PAGE ) + else if ((pAnchorListed->GetAnchorId() != FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() == FLY_AT_PAGE)) { return false; } - else if ( pAnchorListed->GetAnchorId() == FLY_PAGE && - pAnchorNew->GetAnchorId() == FLY_PAGE ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() == FLY_AT_PAGE)) { return pAnchorListed->GetOrder() < pAnchorNew->GetOrder(); } // Both objects aren't anchored to page. // Thus, check for to-fly anchored objects - if ( pAnchorListed->GetAnchorId() == FLY_AT_FLY && - pAnchorNew->GetAnchorId() != FLY_AT_FLY ) + if ((pAnchorListed->GetAnchorId() == FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() != FLY_AT_FLY)) { return true; } - else if ( pAnchorListed->GetAnchorId() != FLY_AT_FLY && - pAnchorNew->GetAnchorId() == FLY_AT_FLY ) + else if ((pAnchorListed->GetAnchorId() != FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() == FLY_AT_FLY)) { return false; } - else if ( pAnchorListed->GetAnchorId() == FLY_AT_FLY && - pAnchorNew->GetAnchorId() == FLY_AT_FLY ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() == FLY_AT_FLY)) { return pAnchorListed->GetOrder() < pAnchorNew->GetOrder(); } @@ -144,21 +141,21 @@ struct ObjAnchorOrder // --> OD 2006-11-29 #???# - objects have to be ordered by anchor node position // Thus, compare content anchor node positions and anchor type, // if not anchored at-paragraph - if ( pAnchorListed->GetAnchorId() != FLY_AT_CNTNT && - pAnchorNew->GetAnchorId() != FLY_AT_CNTNT && + if ((pAnchorListed->GetAnchorId() != FLY_AT_PARA) && + (pAnchorNew ->GetAnchorId() != FLY_AT_PARA) && pCntntAnchorListed && pCntntAnchorNew ) { if ( pCntntAnchorListed->nContent != pCntntAnchorNew->nContent ) { return pCntntAnchorListed->nContent < pCntntAnchorNew->nContent; } - else if ( pAnchorListed->GetAnchorId() == FLY_AUTO_CNTNT && - pAnchorNew->GetAnchorId() == FLY_IN_CNTNT ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_CHAR) && + (pAnchorNew ->GetAnchorId() == FLY_AS_CHAR)) { return true; } - else if ( pAnchorListed->GetAnchorId() == FLY_IN_CNTNT && - pAnchorNew->GetAnchorId() == FLY_AUTO_CNTNT ) + else if ((pAnchorListed->GetAnchorId() == FLY_AS_CHAR) && + (pAnchorNew ->GetAnchorId() == FLY_AT_CHAR)) { return false; } diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 0ba077e799..a7459e4818 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -57,9 +57,7 @@ // --> collapsing borders FME 2005-05-27 #i29550# #include // <-- -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -340,7 +338,7 @@ void lcl_InvalidateLowerObjs( SwLayoutFrm& _rLayoutFrm, pAnchoredObj->ClearCharRectAndTopOfLine(); pAnchoredObj->SetCurrRelPos( Point( 0, 0 ) ); if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_IN_CNTNT ) + == FLY_AS_CHAR ) { pAnchoredObj->AnchorFrm() ->Prepare( PREP_FLY_ATTR_CHG, @@ -4194,7 +4192,7 @@ long MA_FASTCALL CalcHeightWidthFlys( const SwFrm *pFrm ) // the text flow have to be considered. const SwFrmFmt& rFrmFmt = pAnchoredObj->GetFrmFmt(); const bool bConsiderObj = - rFrmFmt.GetAnchor().GetAnchorId() != FLY_IN_CNTNT && + (rFrmFmt.GetAnchor().GetAnchorId() != FLY_AS_CHAR) && pAnchoredObj->GetObjRect().Top() != WEIT_WECH && rFrmFmt.GetFollowTextFlow().GetValue() && pAnchoredObj->GetPageFrm() == pTmp->FindPageFrm(); @@ -5222,7 +5220,7 @@ BOOL lcl_ArrangeLowers( SwLayoutFrm *pLay, long lYStart, BOOL bInva ) !( pTabFrm->IsFollow() && pTabFrm->FindMaster()->IsRebuildLastLine() ) && !pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_IN_CNTNT ) + == FLY_AS_CHAR ) { SwPageFrm* pPageFrm = pAnchoredObj->GetPageFrm(); SwPageFrm* pPageOfAnchor = pFrm->FindPageFrm(); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index d00d3e3459..07eb1d2410 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -35,9 +35,7 @@ #include #include #include -#ifndef _OUTDEV_HXX #include -#endif #include #include #include @@ -52,9 +50,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -81,8 +77,10 @@ // OD 2004-05-24 #i28701# #include + using namespace ::com::sun::star; + /************************************************************************* |* |* SwFrm::SwFrm() @@ -3999,8 +3997,8 @@ void SwRootFrm::InvalidateAllObjPos() { SwAnchoredObject* pAnchoredObj = rObjs[i]; const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() != FLY_AT_CNTNT && - rAnch.GetAnchorId() != FLY_AUTO_CNTNT ) + if ((rAnch.GetAnchorId() != FLY_AT_PARA) && + (rAnch.GetAnchorId() != FLY_AT_CHAR)) { // only to paragraph and to character anchored objects are considered. continue; diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index b052e2e652..f1e317dac4 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -47,13 +47,9 @@ #include #include #include -#ifndef _SVX_SVDOBJ_HXX #include -#endif #include -#ifndef _ENVIRONMENTOFANCHOREDOBJECT #include -#endif #include #include #include @@ -209,7 +205,7 @@ void SwToCntntAnchoredObjectPosition::CalcPosition() { // if object is at-character anchored, determine character-rectangle // and frame, position has to be oriented at. - mbAnchorToChar = FLY_AUTO_CNTNT == rFrmFmt.GetAnchor().GetAnchorId(); + mbAnchorToChar = (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId()); if ( mbAnchorToChar ) { const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor(); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index d6241c775f..77fd669521 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -31,15 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" #include -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include -#endif #include #include -#ifndef _OUTDEV_HXX #include -#endif #include #include #include @@ -370,9 +366,9 @@ bool SwTaggedPDFHelper::CheckReopenTag() { const SwFmtAnchor& rAnchor = static_cast(&rFrm)->GetFmt()->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_PAGE == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_PAGE == rAnchor.GetAnchorId())) { pKeyFrm = static_cast(rFrm).GetAnchorFrm(); bContinue = true; @@ -1814,7 +1810,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() // --> FME 2005-05-09 #i44368# Links in Header/Footer const SwFmtAnchor &rAnch = pFrmFmt->GetAnchor(); - if ( FLY_PAGE != rAnch.GetAnchorId() ) + if (FLY_AT_PAGE != rAnch.GetAnchorId()) { const SwPosition* pPosition = rAnch.GetCntntAnchor(); if ( pPosition && pDoc->IsInHeaderFooter( pPosition->nNode ) ) diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 09be2bd798..b02f0310e4 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -461,10 +461,8 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) const SwFmtAnchor& rFmtA = ((SwFrmFmt*)rpNd)->GetAnchor(); bool bCalculate = false; - if ( - (FLY_AT_CNTNT == rFmtA.GetAnchorId()) || - (FLY_AUTO_CNTNT == rFmtA.GetAnchorId()) - ) + if ((FLY_AT_PARA == rFmtA.GetAnchorId()) || + (FLY_AT_CHAR == rFmtA.GetAnchorId())) { bCalculate = true; } diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index f690c3064b..c8fba54dbc 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -39,9 +39,7 @@ #include "frmfmt.hxx" // SwFrmFmt #include "viewsh.hxx" -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -57,6 +55,7 @@ // OD 2004-05-24 #i28701# #include + /************************************************************************* * class SwFlyPortion * @@ -178,7 +177,7 @@ void SwTxtFrm::MoveFlyInCnt( SwTxtFrm *pNew, xub_StrLen nStart, xub_StrLen nEnd // entries SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if (rAnch.GetAnchorId() == FLY_AS_CHAR) { const SwPosition* pPos = rAnch.GetCntntAnchor(); xub_StrLen nIdx = pPos->nContent.GetIndex(); diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index f263deb90c..bea44790dc 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -31,12 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _OUTDEV_HXX //autogen #include -#endif -#ifndef _VIRDEV_HXX //autogen #include -#endif #include "viewsh.hxx" #include "pagefrm.hxx" @@ -61,14 +57,9 @@ #include "flyfrms.hxx" #include "fmtcnct.hxx" // SwFmtChain #include // SwMultiPortion -#ifdef VERT_DISTANCE -#include -#endif #include -#ifndef _TXTRANGE_HXX //autogen #include -#endif #include #include // --> OD 2004-06-16 #i28701# @@ -83,30 +74,26 @@ #include #include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif #include #include #include -#ifndef _TXTRANGE_HXX //autogen #include -#endif #include #include #include #include - +#include "doc.hxx" #ifndef PRODUCT #include "viewopt.hxx" // SwViewOptions, nur zum Testen (Test2) #endif -#include "doc.hxx" #ifdef VERT_DISTANCE #include #endif + using namespace ::com::sun::star; /***************************************************************************** @@ -1006,8 +993,8 @@ sal_Bool SwTxtFly::DrawTextOpaque( SwDrawTextInfo &rInf ) // --> OD 2006-08-15 #i68520# GetMaster() == pFly->GetAnchorFrm() || // <-- - ( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() + ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId()) ) ) && // --> OD 2006-08-15 #i68520# @@ -1176,7 +1163,7 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, const SwFrmFmt& rFrmFmt = _pAnchoredObj->GetFrmFmt(); const SwFmtAnchor& rNewA = rFrmFmt.GetAnchor(); // <-- - if ( FLY_PAGE == rNewA.GetAnchorId() ) + if (FLY_AT_PAGE == rNewA.GetAnchorId()) { if ( bInFtn ) return sal_False; @@ -1225,23 +1212,25 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // If is anchored as character, its content // does not wrap around pNew - if( FLY_IN_CNTNT == rCurrA.GetAnchorId() ) + if (FLY_AS_CHAR == rCurrA.GetAnchorId()) return sal_False; // If pNew is anchored to page and does not wrap around pNew // If both pNew and are anchored to page, we can do // some more checks - if( FLY_PAGE == rNewA.GetAnchorId() ) + if (FLY_AT_PAGE == rNewA.GetAnchorId()) { - if( FLY_PAGE == rCurrA.GetAnchorId() ) + if (FLY_AT_PAGE == rCurrA.GetAnchorId()) + { bEvade = sal_True; + } else return sal_False; } - else if( FLY_PAGE == rCurrA.GetAnchorId() ) + else if (FLY_AT_PAGE == rCurrA.GetAnchorId()) return sal_False; // Seitengebundene weichen nur seitengeb. aus - else if( FLY_AT_FLY == rNewA.GetAnchorId() ) + else if (FLY_AT_FLY == rNewA.GetAnchorId()) bEvade = sal_True; // Nicht seitengeb. weichen Rahmengeb. aus else if( FLY_AT_FLY == rCurrA.GetAnchorId() ) return sal_False; // Rahmengebundene weichen abs.geb. nicht aus @@ -1285,8 +1274,9 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // --> OD 2004-10-06 #i26945# const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor(); // <-- - ASSERT( FLY_IN_CNTNT != rNewA.GetAnchorId(), "Don't call GetTop with a FlyInCntFrm" ); - if( FLY_PAGE == rNewA.GetAnchorId() ) + ASSERT( FLY_AS_CHAR != rNewA.GetAnchorId(), + "Don't call GetTop with a FlyInCntFrm" ); + if (FLY_AT_PAGE == rNewA.GetAnchorId()) return sal_True; // Seitengebundenen wird immer ausgewichen. // Wenn absatzgebundene Flys in einem FlyCnt gefangen sind, so @@ -2015,8 +2005,8 @@ sal_Bool SwTxtFly::ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid // --> OD 2006-08-15 #i68520# GetMaster() == pAnchoredObj->GetAnchorFrm() || // <-- - ( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() ) ) ) + ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId())) ) ) || aRect.Top() == WEIT_WECH ) continue; } @@ -2442,9 +2432,11 @@ SwSurround SwTxtFly::_GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredO if( rFlyFmt.IsAnchorOnly() && pAnchoredObj->GetAnchorFrm() != GetMaster() ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) + { return SURROUND_NONE; + } } // Beim Durchlauf und Nowrap wird smart ignoriert. diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 8da2cbf4fb..aadb27e4b6 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -65,9 +65,7 @@ #include #include #include -#ifndef _FMTLINE_HXX #include -#endif #include // SwTxtFrm #include // SwSectFrm #include // DBG_LOOP @@ -76,9 +74,7 @@ #include #include // GetLineSpace benutzt pLastFont #include -#ifndef _LINEINFO_HXX #include -#endif #include // OD 2004-01-15 #110582# #include @@ -101,6 +97,7 @@ extern const sal_Char *GetPrepName( const enum PrepareHint ePrep ); #endif + TYPEINIT1( SwTxtFrm, SwCntntFrm ); // Switches width and height of the text frame @@ -487,7 +484,7 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, { bool bRet( true ); - if ( _eAnchorType == FLY_AUTO_CNTNT ) + if (_eAnchorType == FLY_AT_CHAR) { const IDocumentSettingAccess* pIDSA = _rFrm.GetTxtNode()->getIDocumentSettingAccess(); if ( !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) && @@ -560,8 +557,9 @@ void SwTxtFrm::HideAndShowObjects() // under certain conditions const RndStdIds eAnchorType( pContact->GetAnchorId() ); const xub_StrLen nObjAnchorPos = pContact->GetCntntAnchorIndex().GetIndex(); - if ( eAnchorType != FLY_AUTO_CNTNT || - lcl_HideObj( *this, eAnchorType, nObjAnchorPos, (*GetDrawObjs())[i] ) ) + if ((eAnchorType != FLY_AT_CHAR) || + lcl_HideObj( *this, eAnchorType, nObjAnchorPos, + (*GetDrawObjs())[i] )) { pContact->MoveObjToInvisibleLayer( pObj ); } @@ -588,12 +586,12 @@ void SwTxtFrm::HideAndShowObjects() const RndStdIds eAnchorType( pContact->GetAnchorId() ); // <-- - if ( eAnchorType == FLY_AT_CNTNT ) + if (eAnchorType == FLY_AT_PARA) { pContact->MoveObjToVisibleLayer( pObj ); } - else if ( eAnchorType == FLY_AUTO_CNTNT || - eAnchorType == FLY_IN_CNTNT ) + else if ((eAnchorType == FLY_AT_CHAR) || + (eAnchorType == FLY_AS_CHAR)) { xub_StrLen nHiddenStart; xub_StrLen nHiddenEnd; @@ -1704,7 +1702,7 @@ void SwTxtFrm::Prepare( const PrepareHint ePrep, const void* pVoid, // --> OD 2004-07-16 #i28701# - consider all // to-character anchored objects if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_AUTO_CNTNT ) + == FLY_AT_CHAR ) { bFormat = sal_True; break; diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index 92cbc614d6..e4c5d0f10a 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -124,8 +124,8 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) BOOL bUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); - if( FLY_PAGE != aAnchor.GetAnchorId() && - pDoc != pFmt->GetDoc() ) // Unterschiedliche Docs? + if ((FLY_AT_PAGE != aAnchor.GetAnchorId()) && + (pDoc != pFmt->GetDoc())) // different documents? { // JP 03.06.96: dann sorge dafuer, das der koperierte Anker auf // gueltigen Content zeigt! Die Umsetzung auf die @@ -137,8 +137,10 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) SwPosition* pPos = (SwPosition*)aAnchor.GetCntntAnchor(); pPos->nNode = aIdx; - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aAnchor.GetAnchorId()) + { pPos->nContent.Assign( pCNd, 0 ); + } else { pPos->nContent.Assign( 0, 0 ); @@ -181,7 +183,7 @@ void SwTxtFlyCnt::SetAnchor( const SwTxtNode *pNode ) else aPos.nNode = aAnchor.GetCntntAnchor()->nNode; - aAnchor.SetType( FLY_IN_CNTNT ); // defaulten !! + aAnchor.SetType( FLY_AS_CHAR ); // default! aAnchor.SetAnchor( &aPos ); // beim Ankerwechsel werden immer alle FlyFrms vom Attribut geloescht diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index ee2ac11a99..d0e13ea32c 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1270,11 +1270,15 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) InsertText( c, aIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; - if( pAnchor && FLY_IN_CNTNT == pAnchor->GetAnchorId() && + if (pAnchor && + (FLY_AS_CHAR == pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() && pAnchor->GetCntntAnchor()->nNode == *this && pAnchor->GetCntntAnchor()->nContent == aIdx ) - ((SwIndex&)pAnchor->GetCntntAnchor()->nContent)--; + { + const_cast( + pAnchor->GetCntntAnchor()->nContent)--; + } } pFly->SetAnchor( this ); diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 72da13fe5a..1ab0e90993 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -922,7 +922,7 @@ SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ) : SwHistoryHint( HSTRY_CHGFLYANCHOR ) , m_rFmt( rFmt ) , m_nOldNodeIndex( rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex() ) - , m_nOldContentIndex( ( FLY_AUTO_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + , m_nOldContentIndex( (FLY_AT_CHAR == rFmt.GetAnchor().GetAnchorId()) ? rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex() : STRING_MAXLEN ) { diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 512c7c1afe..6c5ca25ee4 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -462,10 +462,10 @@ void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt ) xub_StrLen nCntnt = 0; switch( rAnchor.GetAnchorId() ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; @@ -489,7 +489,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) static_cast( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() ); - if( FLY_PAGE != rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE != rAnchor.GetAnchorId()) { SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; @@ -505,8 +505,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) } SwPosition aPos( *pNd ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) { aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() ); if ( aPos.nContent.GetIndex() > @@ -549,7 +549,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor(); // --> OD 2006-03-13 #i54336# // Consider case, that as-character anchored object has moved its anchor position. - if ( FLY_IN_CNTNT == rOldAnch.GetAnchorId() ) + if (FLY_AS_CHAR == rOldAnch.GetAnchorId()) // <-- { //Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet @@ -613,7 +613,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); } - if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 1ebc3a084f..df8eaf2a0a 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -81,7 +81,7 @@ void lcl_MakeAutoFrms( const SwSpzFrmFmts& rSpzArr, ULONG nMovedIndex ) { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); - if( pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) + if (pAnchor->GetAnchorId() == FLY_AT_CHAR) { const SwPosition* pAPos = pAnchor->GetCntntAnchor(); if( pAPos && nMovedIndex == pAPos->nNode.GetIndex() ) @@ -632,7 +632,7 @@ void lcl_ReAnchorAtCntntFlyFrames( const SwSpzFrmFmts& rSpzArr, SwPosition &rPos { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); - if( pAnchor->GetAnchorId() == FLY_AT_CNTNT ) + if (pAnchor->GetAnchorId() == FLY_AT_PARA) { pAPos = pAnchor->GetCntntAnchor(); if( pAPos && nOldIdx == pAPos->nNode.GetIndex() ) diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 9338e5fbc5..71f98b82a5 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -593,7 +593,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, pAnchor = &pFmt->GetAnchor(); switch( pAnchor->GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( 0 != (pAPos = pAnchor->GetCntntAnchor() ) && (( nsDelCntntType::DELCNT_CHKNOCNTNT & nDelCntntType ) ? ( pStt->nNode <= pAPos->nNode && @@ -611,7 +611,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; } break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: { pAPos = pAnchor->GetCntntAnchor(); if( pAPos ) @@ -660,7 +660,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, } } break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: if( 0 != (pAPos = pAnchor->GetCntntAnchor() ) && ( pStt->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) ) { diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index d9ce9b12a8..bc5effe016 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -93,15 +93,19 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) SwFmtAnchor aAnchor( (RndStdIds)nRndId ); - if( FLY_PAGE == nRndId ) + if (FLY_AT_PAGE == nRndId) + { aAnchor.SetPageNum( (USHORT)nNdPgPos ); + } else { SwPosition aNewPos( *rUndoIter.pAktPam->GetPoint() ); aNewPos.nNode = nNdPgPos; - if( FLY_IN_CNTNT == nRndId || FLY_AUTO_CNTNT == nRndId ) + if ((FLY_AS_CHAR == nRndId) || (FLY_AT_CHAR == nRndId)) + { aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetCntntNode(), nCntPos ); + } aAnchor.SetAnchor( &aNewPos ); } @@ -119,7 +123,7 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) // vorhanden ist! Sonst wuerde das Layout den Fly vorher // formatieren, aber keine Inhalt finden; so geschene bei // Grafiken aus dem Internet - if( FLY_IN_CNTNT == nRndId ) + if (FLY_AS_CHAR == nRndId) { // es muss mindestens das Attribut im TextNode stehen SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); @@ -138,22 +142,22 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) switch( nRndId ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); nCntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); } break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); } break; - case FLY_PAGE: + case FLY_AT_PAGE: break; } bDelFmt = FALSE; @@ -193,7 +197,8 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); const SwPosition* pPos = rAnchor.GetCntntAnchor(); // die Positionen im Nodes-Array haben sich verschoben - if( FLY_IN_CNTNT == ( nRndId = static_cast(rAnchor.GetAnchorId()) ) ) + nRndId = static_cast(rAnchor.GetAnchorId()); + if (FLY_AS_CHAR == nRndId) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); @@ -210,15 +215,19 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) pTxtNd->EraseText( aIdx, 1 ); } } - else if( FLY_AUTO_CNTNT == nRndId ) + else if (FLY_AT_CHAR == nRndId) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); } - else if( FLY_AT_CNTNT == nRndId || FLY_AT_FLY == nRndId ) + else if ((FLY_AT_PARA == nRndId) || (FLY_AT_FLY == nRndId)) + { nNdPgPos = pPos->nNode.GetIndex(); + } else + { nNdPgPos = rAnchor.GetPageNum(); + } pFrmFmt->ResetFmtAttr( RES_ANCHOR ); // Anchor loeschen @@ -240,15 +249,15 @@ SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen bDelFmt = FALSE; switch( nRndId ) { - case FLY_PAGE: + case FLY_AT_PAGE: nNdPgPos = rAnchor.GetPageNum(); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: { const SwPosition* pPos = rAnchor.GetCntntAnchor(); nCntPos = pPos->nContent.GetIndex(); @@ -305,13 +314,15 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) SwDoc* pDoc = &rUndoIter.GetDoc(); // erfrage und setze den Anker neu SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition aPos( *rUndoIter.pAktPam->GetPoint() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() ) + if (FLY_AT_PARA == aAnchor.GetAnchorId()) + { aPos.nContent.Assign( 0, 0 ); + } aAnchor.SetAnchor( &aPos ); } else if( FLY_AT_FLY == aAnchor.GetAnchorId() ) @@ -328,7 +339,7 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) return ; } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { aAnchor.SetPageNum( pDoc->GetRootFrm()->GetCurrPage( rUndoIter.pAktPam )); @@ -482,7 +493,7 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, ULONG nNode, xub_StrLen nCntnt ) { RndStdIds nAnchorTyp = rAnchor.GetAnchorId(); - if( FLY_PAGE != nAnchorTyp ) + if (FLY_AT_PAGE != nAnchorTyp) { SwNode* pNd = pFrmFmt->GetDoc()->GetNodes()[ nNode ]; @@ -490,26 +501,34 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, ? ( !pNd->IsStartNode() || SwFlyStartNode != ((SwStartNode*)pNd)->GetStartNodeType() ) : !pNd->IsTxtNode() ) - pNd = 0; // ungueltige Position + { + pNd = 0; // invalid position + } else { SwPosition aPos( *pNd ); - if( FLY_IN_CNTNT == nAnchorTyp || - FLY_AUTO_CNTNT == nAnchorTyp ) + if ((FLY_AS_CHAR == nAnchorTyp) || + (FLY_AT_CHAR == nAnchorTyp)) { - if( nCntnt > ((SwTxtNode*)pNd)->GetTxt().Len() ) - pNd = 0; // ungueltige Position + if ( nCntnt > static_cast(pNd)->GetTxt().Len() ) + { + pNd = 0; // invalid position + } else - aPos.nContent.Assign( (SwTxtNode*)pNd, nCntnt ); + { + aPos.nContent.Assign(static_cast(pNd), nCntnt); + } } - if( pNd ) + if ( pNd ) + { rAnchor.SetAnchor( &aPos ); + } } if( !pNd ) { // ungueltige Position - setze auf 1. Seite - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); rAnchor.SetPageNum( 1 ); } } @@ -548,7 +567,7 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) if( bAnchorChgd ) { const SwFmtAnchor& rOldAnch = pFrmFmt->GetAnchor(); - if( FLY_IN_CNTNT == rOldAnch.GetAnchorId() ) + if (FLY_AS_CHAR == rOldAnch.GetAnchorId()) { // Bei InCntnt's wird es spannend: Das TxtAttribut muss // vernichtet werden. Leider reisst dies neben den Frms @@ -577,7 +596,7 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) GetAnchor( aNewAnchor, nOldNode, nOldCntnt ); pFrmFmt->SetFmtAttr( aNewAnchor ); - if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pFrmFmt ); @@ -629,10 +648,10 @@ void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem ) const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; switch( nOldAnchorTyp = static_cast(pAnchor->GetAnchorId()) ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nOldCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nOldNode = pAnchor->GetCntntAnchor()->nNode.GetIndex(); break; @@ -644,10 +663,10 @@ void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem ) pAnchor = (SwFmtAnchor*)&pFrmFmt->GetAnchor(); switch( nNewAnchorTyp = static_cast(pAnchor->GetAnchorId()) ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nNewCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nNewNode = pAnchor->GetCntntAnchor()->nNode.GetIndex(); break; diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 2b89cb1e7c..475c6dc6df 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -32,15 +32,9 @@ #include "precompiled_sw.hxx" #include - -#ifndef _RTL_MEMORY_H #include -#endif #include -#ifndef _RTL_STRING_H -#include -#endif #include #include #include @@ -61,6 +55,7 @@ #include #include + struct SwUndoGroupObjImpl { SwDrawFrmFmt* pFmt; @@ -142,15 +137,15 @@ void lcl_SendRemoveToUno( SwFmt& rFmt ) void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { rNodePos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); xub_StrLen nCntntPos = 0; - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); @@ -168,8 +163,10 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) pTxtNd->EraseText( aIdx, 1 ); } } - else if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + else if (FLY_AT_CHAR == rAnchor.GetAnchorId()) + { nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); + } pFmt->SetFmtAttr( SwFmtAnchor( rAnchor.GetAnchorId(), nCntntPos ) ); } @@ -178,10 +175,10 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { xub_StrLen nCntntPos = rAnchor.GetPageNum(); SwNodes& rNds = pFmt->GetDoc()->GetNodes(); @@ -190,13 +187,15 @@ void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) SwPosition aPos( aIdx ); SwFmtAnchor aTmp( rAnchor.GetAnchorId() ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) + { aPos.nContent.Assign( aIdx.GetNode().GetCntntNode(), nCntntPos ); + } aTmp.SetAnchor( &aPos ); pFmt->SetFmtAttr( aTmp ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode(); ASSERT( pTxtNd, "no Text Node" ); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index ab501f9558..7e18b59a7f 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -449,12 +449,12 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ) const SwSpzFrmFmts& rFrmFmtTbl = *pTblNd->GetDoc()->GetSpzFrmFmts(); for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { - const SwPosition* pAPos; SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - ( FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || - FLY_AT_CNTNT == pAnchor->GetAnchorId() ) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_PARA == pAnchor->GetAnchorId())) && nTblStt <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nTblEnd ) { diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index e6aad03906..fdbc7b74cf 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -69,10 +69,10 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) for( USHORT n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - if ( pAnchor->GetAnchorId() == FLY_AT_CNTNT && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + (pAnchor->GetAnchorId() == FLY_AT_PARA) && nSttNode == pAPos->nNode.GetIndex() ) { if( !pFrmFmts ) @@ -124,10 +124,10 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, for( USHORT n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - if( pAnchor->GetAnchorId() == FLY_AT_CNTNT && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + (pAnchor->GetAnchorId() == FLY_AT_PARA) && nSttNode == pAPos->nNode.GetIndex() ) { if( !pFrmFmts || diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index a88f0a26c0..bd592e4120 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -163,7 +163,9 @@ public: SwFmtAnchor* GetAnchor(sal_Bool bCreate = sal_False) { if(bCreate && !pAnchor) - pAnchor = new SwFmtAnchor(FLY_IN_CNTNT); + { + pAnchor = new SwFmtAnchor(FLY_AS_CHAR); + } return pAnchor; } SwFmtHoriOrient* GetHOrient(sal_Bool bCreate = sal_False) @@ -700,7 +702,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); sal_Bool bOpaque = sal_False; if( pDesc ) { @@ -781,14 +783,18 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) { if(FLY_AT_FLY == aAnchor.GetAnchorId() && !pInternalPam->GetNode()->FindFlyStartNode()) - aAnchor.SetType(FLY_IN_CNTNT); - else if(FLY_PAGE == aAnchor.GetAnchorId()) + { + aAnchor.SetType(FLY_AS_CHAR); + } + else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) + { aAnchor.SetAnchor(pInternalPam->Start()); + } } else throw uno::RuntimeException(); } - else if( aAnchor.GetAnchorId() != FLY_PAGE && pDoc->GetRootFrm() ) + else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetRootFrm()) { SwCrsrMoveState aState( MV_SETONLYTEXT ); Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y)); @@ -800,7 +806,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) } else { - aAnchor.SetType(FLY_PAGE); + aAnchor.SetType(FLY_AT_PAGE); // --> OD 2004-08-18 #i32349# - adjustment of vertical positioning // attributes no longer needed, because its already got a default. @@ -853,8 +859,11 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i ) { const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); - if ( FLY_IN_CNTNT == ::FindFrmFmt( (SdrObject*)pObj )->GetAnchor().GetAnchorId() ) + if (FLY_AS_CHAR == ::FindFrmFmt(const_cast( + pObj))->GetAnchor().GetAnchorId()) + { bFlyInCnt = sal_True; + } } if( bFlyInCnt ) throw uno::RuntimeException(); @@ -864,7 +873,9 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< pDoc->StartUndo( UNDO_START, NULL ); SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/, + pDoc->ChgAnchor( + pPage->GetDrawView()->GetMarkedObjectList(), + FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); pPage->GetDrawView()->UnmarkAll(); @@ -899,7 +910,8 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeG pDoc->StartUndo( UNDO_START, NULL ); pDoc->UnGroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/, + pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), + FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); pDoc->EndUndo( UNDO_END, NULL ); } @@ -1274,7 +1286,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A else if ( FN_TEXT_RANGE == pEntry->nWID ) { SwFmtAnchor aAnchor( static_cast(aSet.Get( RES_ANCHOR )) ); - if ( aAnchor.GetAnchorId() == FLY_PAGE ) + if (aAnchor.GetAnchorId() == FLY_AT_PAGE) { // set property not valid for to-page anchored shapes throw lang::IllegalArgumentException(); @@ -1287,7 +1299,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A aValue >>= xRg; if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) ) { - if(aAnchor.GetAnchorId() == FLY_IN_CNTNT) + if (aAnchor.GetAnchorId() == FLY_AS_CHAR) { //delete old SwFmtFlyCnt //With AnchorAsCharacter the current TxtAttribute has to be deleted. @@ -1375,7 +1387,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwFrmFmt *pFlyFmt = FindFrmFmt( pObj ); pFlyFmt->DelFrms(); if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor && - FLY_IN_CNTNT == eOldAnchorId ) + (FLY_AS_CHAR == eOldAnchorId)) { //With AnchorAsCharacter the current TxtAttribute has to be deleted. //Tbis removes the frame format too. @@ -1398,7 +1410,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx); } else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor && - FLY_PAGE == eOldAnchorId ) + (FLY_AT_PAGE == eOldAnchorId)) { SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) ); //if the fly has been anchored at page then it needs to be connected @@ -1421,7 +1433,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pFmt->SetFmtAttr(aSet); bSetAttr = false; if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor && - FLY_IN_CNTNT != eOldAnchorId ) + (FLY_AS_CHAR != eOldAnchorId)) { //the RES_TXTATR_FLYCNT needs to be added now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); @@ -1606,7 +1618,7 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName) else if ( FN_TEXT_RANGE == pEntry->nWID ) { const SwFmtAnchor aAnchor = pFmt->GetAnchor(); - if ( aAnchor.GetAnchorId() == FLY_PAGE ) + if (aAnchor.GetAnchorId() == FLY_AT_PAGE) { // return nothing, because property isn't // valid for to-page anchored shapes @@ -2180,7 +2192,7 @@ uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::Runtim const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); // return an anchor for non-page bound frames // and for page bound frames that have a page no == NULL and a content position - if( rAnchor.GetAnchorId() != FLY_PAGE || + if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); @@ -2224,7 +2236,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException ) pObj->IsInserted() ) // <-- { - if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 37f53ade45..0f3057533d 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -45,9 +45,7 @@ #include #include #include -#ifndef _DOCSH_HXX //autogen #include -#endif #include #include #include @@ -1402,7 +1400,8 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: aSet.Put(aAnchor); } } - else if(aAnchor.GetAnchorId() != FLY_PAGE && !aAnchor.GetCntntAnchor()) + else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && + !aAnchor.GetCntntAnchor()) { SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); SwPaM aPam(rNode); @@ -2023,7 +2022,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException ) ( pObj->GetUserCall() && !static_cast(pObj->GetUserCall())->IsInDTOR() ) ) ) { - if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); @@ -2049,7 +2048,7 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::Runtim const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); // return an anchor for non-page bound frames // and for page bound frames that have a page no == NULL and a content position - if( rAnchor.GetAnchorId() != FLY_PAGE || + if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); @@ -2128,7 +2127,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan } const SfxPoolItem* pItem; - RndStdIds eAnchorId = FLY_AT_CNTNT; + RndStdIds eAnchorId = FLY_AT_PARA; if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) ) { eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId(); @@ -2136,10 +2135,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan !aPam.GetNode()->FindFlyStartNode()) { //rahmengebunden geht nur dort, wo ein Rahmen ist! - SwFmtAnchor aAnchor(FLY_AT_CNTNT); + SwFmtAnchor aAnchor(FLY_AT_PARA); aFrmSet.Put(aAnchor); } - else if( FLY_PAGE == eAnchorId && + else if ((FLY_AT_PAGE == eAnchorId) && 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() ) { SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) ); @@ -2162,10 +2161,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan SwFmtAnchor* pAnchorItem = 0; // the frame is inserted bound to page // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text - if(eAnchorId != FLY_PAGE) + if (eAnchorId != FLY_AT_PAGE) { pAnchorItem = static_cast(aFrmSet.Get(RES_ANCHOR).Clone()); - aFrmSet.Put( SwFmtAnchor( FLY_PAGE, 1 )); + aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 )); } pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet, @@ -2183,8 +2182,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan DELETEZ( m_pCopySource ); } else - pFmt = pDoc->MakeFlySection( FLY_AT_CNTNT, aPam.GetPoint(), + { + pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(), &aFrmSet, pParentFrmFmt ); + } if(pFmt) { pFmt->Add(this); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 0cf7fe86d7..06415a36e5 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -163,7 +163,8 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, // gebunden sind SwDoc* pDoc = rIdx.GetNode().GetDoc(); - USHORT nChkType = static_cast< USHORT >(_bAtCharAnchoredObjs ? FLY_AUTO_CNTNT : FLY_AT_CNTNT); + USHORT nChkType = static_cast< USHORT >((_bAtCharAnchoredObjs) + ? FLY_AT_CHAR : FLY_AT_PARA); const SwCntntFrm* pCFrm; const SwCntntNode* pCNd; if( pDoc->GetRootFrm() && diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx index a0c6d78e37..94bc6beaa3 100644 --- a/sw/source/core/view/vdraw.cxx +++ b/sw/source/core/view/vdraw.cxx @@ -46,10 +46,8 @@ #include #ifndef PRODUCT -#ifndef _SVX_FMGLOB_HXX #include #endif -#endif #include "fesh.hxx" #include "pagefrm.hxx" @@ -62,9 +60,8 @@ #include "flyfrm.hxx" #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif + /************************************************************************* |* @@ -337,8 +334,10 @@ void SwViewImp::NotifySizeChg( const Size &rNewSz ) const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm(); if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() || !pAnchor->GetUpper() || !pAnchor->FindPageFrm() || - FLY_IN_CNTNT == pCont->GetFmt()->GetAnchor().GetAnchorId() ) + (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) ) + { continue; + } // OD 19.06.2003 #108784# - no move for drawing objects in header/footer if ( pAnchor->FindFooterOrHeader() ) diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 3e8ae6d726..95c0296551 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -34,9 +34,7 @@ #include #include #include -#ifndef SVTOOLS_FSTATHELPER_HXX #include -#endif #include #include #include @@ -60,9 +58,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include @@ -72,6 +68,7 @@ #include // <-- + using namespace ::com::sun::star; ////////////////////////////////////////////////////////////////////////// @@ -241,9 +238,9 @@ ULONG SwReader::Read( const Reader& rOptions ) { SwPosition const*const pFrameAnchor( rAnchor.GetCntntAnchor()); - if ( (FLY_PAGE == rAnchor.GetAnchorId()) + if ( (FLY_AT_PAGE == rAnchor.GetAnchorId()) || ( pFrameAnchor - && ( ( (FLY_AT_CNTNT == rAnchor.GetAnchorId()) + && ( ( (FLY_AT_PARA == rAnchor.GetAnchorId()) && ( (pUndoPam->GetPoint()->nNode == pFrameAnchor->nNode) || (pUndoPam->GetMark()->nNode == @@ -251,7 +248,7 @@ ULONG SwReader::Read( const Reader& rOptions ) ) ) // #i97570# also check frames anchored AT char - || ( (FLY_AUTO_CNTNT == rAnchor.GetAnchorId()) + || ( (FLY_AT_CHAR == rAnchor.GetAnchorId()) && !IsDestroyFrameAnchoredAtChar( *pFrameAnchor, *pUndoPam->GetPoint(), @@ -262,7 +259,7 @@ ULONG SwReader::Read( const Reader& rOptions ) ) { if( bChkHeaderFooter && - FLY_AT_CNTNT == rAnchor.GetAnchorId() && + (FLY_AT_PARA == rAnchor.GetAnchorId()) && RES_DRAWFRMFMT == pFrmFmt->Which() ) { // DrawObjecte in Kopf-/Fusszeilen ist nicht @@ -286,15 +283,19 @@ ULONG SwReader::Read( const Reader& rOptions ) pFrmFmt->DelFrms(); } - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) { if( !rAnchor.GetCntntAnchor() ) + { pFrmFmt->MakeFrms(); + } else if( pCrsr ) + { // seitengebundene Flys eingefuegt, dann schalte // die Optimierungs-Flags vom SwDoc ab. Sonst // werden die Flys nicht an der Position erzeugt. pDoc->SetLoaded( FALSE ); + } } else pFrmFmt->MakeFrms(); diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 38f82babb9..8bbfce70f7 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -35,9 +35,7 @@ #include "hintids.hxx" #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -2130,8 +2128,8 @@ void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor(); switch( rAnchor.GetAnchorId() ) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: if( text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() || text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() ) { @@ -2146,7 +2144,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, break; } - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: { // position @@ -2375,7 +2373,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt ) const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor(); RndStdIds eAnchorId = rAnchor.GetAnchorId(); const SwPosition *pAnchorPos = rAnchor.GetCntntAnchor(); - if( FLY_PAGE != eAnchorId && pAnchorPos ) + if (FLY_AT_PAGE != eAnchorId && pAnchorPos) { const SwNode& rNode = pAnchorPos->nNode.GetNode(); if( rNode.IsCntntNode() ) diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index ea7c9f0ff9..d1d729bf02 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -39,17 +39,12 @@ #include #include #include -#ifndef _APP_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SVX_BOXITEM_HXX //autogen - #include -#endif #include #include #include @@ -2094,7 +2089,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, } else { - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); aAnchor.SetPageNum( 1 ); } nHoriPos = rPropInfo.nLeft; @@ -2102,7 +2097,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::CHAR; @@ -2128,14 +2123,14 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex(); if( nCntnt ) { - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); pPam->Move( fnMoveBackward ); eVertOri = text::VertOrientation::CHAR_BOTTOM; eVertRel = text::RelOrientation::CHAR; } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::PRINT_AREA; } diff --git a/sw/source/filter/html/htmldraw.cxx b/sw/source/filter/html/htmldraw.cxx index e31acbabc0..4f7a281631 100644 --- a/sw/source/filter/html/htmldraw.cxx +++ b/sw/source/filter/html/htmldraw.cxx @@ -34,9 +34,7 @@ #include "hintids.hxx" #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -182,7 +180,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, aFrmSet.Put( aULItem ); } - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition && SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType && SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType ) @@ -198,7 +196,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, } else { - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); } // OD 2004-04-13 #i26791# - direct positioning for pNewDrawObj->SetRelativePos( Point(rCSS1PropInfo.nLeft + nLeftSpace, @@ -208,7 +206,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat || text::HoriOrientation::LEFT == eHoriOri ) { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aFrmSet.Put( SwFmtSurround(bHidden ? SURROUND_THROUGHT : SURROUND_RIGHT) ); // OD 2004-04-13 #i26791# - direct positioning for @@ -219,10 +217,14 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, aFrmSet.Put( SwFmtVertOrient( 0, eVertOri ) ); } - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == aAnchor.GetAnchorId()) + { aAnchor.SetPageNum( 1 ); + } else if( FLY_AT_FLY != aAnchor.GetAnchorId() ) + { aAnchor.SetAnchor( pPam->GetPoint() ); + } aFrmSet.Put( aAnchor ); pDoc->Insert( *pPam, *pNewDrawObj, &aFrmSet, NULL ); diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx index 880009e3a9..c1b7a20424 100644 --- a/sw/source/filter/html/htmlfly.cxx +++ b/sw/source/filter/html/htmlfly.cxx @@ -39,12 +39,8 @@ #include "hintids.hxx" #include #include -#ifndef _APP_HXX #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -338,12 +334,12 @@ void SwHTMLWriter::CollectFlyFrms() sal_Int16 eHoriRel = rFrmFmt.GetHoriOrient().GetRelationOrient(); switch( rAnchor.GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: nMode = aHTMLOutFrmPageFlyTable[eType][nExportMode]; break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: // Absatz-gebundene Rahmen werden nur dann vor den // Absatz geschrieben, wenn der Absatz einen Abstand // hat. @@ -362,7 +358,7 @@ void SwHTMLWriter::CollectFlyFrms() nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode]; break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel ) nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode]; else @@ -594,7 +590,7 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, const sal_Char *pStr = 0; RndStdIds eAnchorId = rFrmFmt.GetAnchor().GetAnchorId(); if( (nFrmOpts & HTML_FRMOPT_ALIGN) && - (FLY_AT_CNTNT == eAnchorId || FLY_AUTO_CNTNT == eAnchorId) ) + ((FLY_AT_PARA == eAnchorId) || (FLY_AT_CHAR == eAnchorId)) ) { // MIB 12.3.98: Ist es nicht schlauer, absatzgebundene // Rahmen notfalls links auszurichten als sie @@ -611,7 +607,7 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, } if( (nFrmOpts & HTML_FRMOPT_ALIGN) && !pStr && ( (nFrmOpts & HTML_FRMOPT_S_ALIGN) == 0 || - FLY_IN_CNTNT == eAnchorId ) && + (FLY_AS_CHAR == eAnchorId) ) && SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, TRUE, &pItem )) { switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() ) @@ -764,8 +760,8 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, // Umlauf fuer absatzgeb. Grafiken als
in den String // schreiben if( (nFrmOpts & HTML_FRMOPT_BRCLEAR) && - (FLY_AT_CNTNT== rFrmFmt.GetAnchor().GetAnchorId() || - FLY_AUTO_CNTNT== rFrmFmt.GetAnchor().GetAnchorId()) && + ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) || + (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId())) && SFX_ITEM_SET == rItemSet.GetItemState( RES_SURROUND, TRUE, &pItem )) { const SwFmtSurround* pSurround = (const SwFmtSurround*)pItem; @@ -1893,7 +1889,7 @@ SwHTMLPosFlyFrm::SwHTMLPosFlyFrm( const SwPosFlyFrm& rPosFly, nOutputMode( nOutMode ) { const SwFmtAnchor& rAnchor = rPosFly.GetFmt().GetAnchor(); - if( FLY_AUTO_CNTNT==rAnchor.GetAnchorId() && + if ((FLY_AT_CHAR == rAnchor.GetAnchorId()) && HTML_POS_INSIDE == GetOutPos() ) { // Auto-gebundene Rahmen werden ein Zeichen weiter hinten diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 972a3f6246..8d2d305c23 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -45,18 +45,14 @@ #include #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include #include #include #include "svtools/urihelper.hxx" -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include @@ -81,6 +77,7 @@ #include "htmlfly.hxx" #include "htmlform.hxx" + using namespace ::com::sun::star; using ::rtl::OUString; /* */ @@ -1427,7 +1424,7 @@ void SwHTMLWriter::GetControls() const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); const SwPosition *pPos = rAnchor.GetCntntAnchor(); - if( FLY_IN_CNTNT != rAnchor.GetAnchorId() || !pPos ) + if ((FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pPos) continue; const SdrObject *pSdrObj = diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 688ed149a5..cadc0f27ac 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -33,9 +33,7 @@ #include "hintids.hxx" #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -208,7 +206,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri, BOOL bDontAppend ) { BOOL bMoveBackward = FALSE; - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); sal_Int16 eVertRel = text::RelOrientation::FRAME; if( text::HoriOrientation::NONE != eHoriOri ) @@ -267,14 +265,14 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri, xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex(); if( nCntnt ) { - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); bMoveBackward = TRUE; eVertOri = text::VertOrientation::CHAR_BOTTOM; eVertRel = text::RelOrientation::CHAR; } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::PRINT_AREA; } @@ -301,7 +299,7 @@ void SwHTMLParser::RegisterFlyFrm( SwFrmFmt *pFlyFmt ) // automatisch verankerte Rahmen muessen noch um eine Position // nach vorne verschoben werden. if( RES_DRAWFRMFMT != pFlyFmt->Which() && - FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() && + (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId()) && SURROUND_THROUGHT == pFlyFmt->GetSurround().GetSurround() ) { aMoveFlyFrms.Insert( pFlyFmt, aMoveFlyFrms.Count() ); @@ -778,7 +776,7 @@ IMAGE_SETEVENT: aMacroItem.SetMacro( aEvents[ n ], *pMacro ); } - if( FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() && + if ((FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId()) && aAttrTab.pINetFmt->GetSttPara() == pPam->GetPoint()->nNode && aAttrTab.pINetFmt->GetSttCnt() == @@ -1342,20 +1340,16 @@ void SwHTMLParser::StripTrailingPara() { ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex(); - USHORT i; - - const SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - for( i=0; iGetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwFrmFmt const*const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == nNodeIdx ) return; // den Knoten duerfen wir nicht loeschen diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 27852b37ab..064866f2ca 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -33,8 +33,6 @@ #include #include - - #include "hintids.hxx" #include #define _SVSTDARR_ULONGS @@ -42,9 +40,7 @@ #include #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -465,7 +461,7 @@ void SwHTMLParser::InsertEmbed() } else { - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFrmSet.Put( aAnchor ); aFrmSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) ); @@ -1167,7 +1163,7 @@ Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt, sOut = '\"'; } - if( FLY_AT_CNTNT == rFrmFmt.GetAnchor().GetAnchorId() && + if ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) && SURROUND_THROUGHT == rFrmFmt.GetSurround().GetSurround() ) { // Das Plugin ist HIDDEN diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index a883fa4207..9868404cc1 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2837,7 +2837,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, SwFrmFmt *pFrmFmt = aMoveFlyFrms[ --n ]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - ASSERT( FLY_AT_CNTNT==rAnchor.GetAnchorId(), + ASSERT( FLY_AT_PARA == rAnchor.GetAnchorId(), "Nur Auto-Rahmen brauchen eine Spezialbehandlung" ); const SwPosition *pFlyPos = rAnchor.GetCntntAnchor(); ULONG nFlyParaIdx = pFlyPos->nNode.GetIndex(); @@ -2862,7 +2862,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->GetPoint()->nContent.Assign( pAttrPam->GetCntntNode(), aMoveFlyCnts[n] ); SwFmtAnchor aAnchor( rAnchor ); - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); aAnchor.SetAnchor( pAttrPam->GetPoint() ); pFrmFmt->SetFmtAttr( aAnchor ); @@ -4411,27 +4411,23 @@ BOOL SwHTMLParser::HasCurrentParaFlys( BOOL bNoSurroundOnly, // sonst: Der Absatz enthaelt irgendeinen Rahmen SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode; - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - USHORT i; BOOL bFound = FALSE; - for( i=0; iGetAnchor(); + SwFrmFmt *const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); // Ein Rahmen wurde gefunden, wenn // - er absatzgebunden ist, und // - im aktuellen Absatz verankert ist, und // - jeder absatzgebunene Rahmen zaehlt, oder // - (nur Rahmen oder umlauf zaehlen und ) der Rahmen keinen // Umlauf besitzt - - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == rNodeIdx ) { if( !(bNoSurroundOnly || bSurroundOnly) ) @@ -5073,18 +5069,16 @@ void SwHTMLParser::InsertLineBreak() SwTxtNode* pTxtNd = rNodeIdx.GetNode().GetTxtNode(); if( pTxtNd ) { - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); for( USHORT i=0; iGetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwFrmFmt *const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == rNodeIdx && pFmt->GetSurround().GetSurround() != SURROUND_NONE ) { diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index 463a4305c4..fbc2662c84 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -36,9 +36,7 @@ #include #include #include -#ifndef _KEYCOD_HXX //autogen #include -#endif #include #include #include @@ -150,12 +148,12 @@ class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem { SwFrmFmt* pFrmFmt; SwFltAnchorClient * pClient; - + public: SwFltAnchor(SwFrmFmt* pFlyFmt); SwFltAnchor(const SwFltAnchor&); virtual ~SwFltAnchor(); - + // "pure virtual Methoden" vom SfxPoolItem virtual int operator==(const SfxPoolItem&) const; virtual SfxPoolItem* Clone(SfxItemPool* = 0) const; @@ -167,10 +165,10 @@ public: class SwFltAnchorClient : public SwClient { SwFltAnchor * m_pFltAnchor; - + public: SwFltAnchorClient(SwFltAnchor * pFltAnchor); - + virtual void Modify (SfxPoolItem *pOld, SfxPoolItem *pNew); }; @@ -556,7 +554,7 @@ public: pOut->EndTable(); } // methoden zur verwaltung von Flys BOOL IsInFly() { return pOut->IsInFly(); } - BOOL BeginFly( RndStdIds eAnchor = FLY_AT_CNTNT, BOOL bAbsolutePos = FALSE ); + BOOL BeginFly( RndStdIds eAnchor = FLY_AT_PARA, BOOL bAbsolutePos = FALSE ); void SetFlyAnchor( RndStdIds eAnchor ) { pOut->SetFlyAnchor( eAnchor ); } void SetFlyXPos( short nXPos, sal_Int16 eHRel = com::sun::star::text::RelOrientation::FRAME, diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index 9b97984126..ad8a6e1199 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -38,9 +38,7 @@ */ #include -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include -#endif #include #include #include @@ -50,9 +48,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -72,16 +68,12 @@ #include #include #include -#ifndef _SVX_CNTRITEM_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SVX_EMPHITEM_HXX #include -#endif #include #include #include @@ -127,9 +119,7 @@ #include #include // fuer SwPageDesc ... #include // fuer SwPageDesc ... -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -3592,7 +3582,7 @@ static Writer& OutRTF_SwFmtVertOrient ( Writer& rWrt, const SfxPoolItem& rHt ) const char* pOrient; RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId(); sal_Int16 eOrient = rFlyVert.GetRelationOrient(); - if( FLY_PAGE == eAnchor ) + if (FLY_AT_PAGE == eAnchor) { if( text::RelOrientation::PAGE_FRAME == eOrient || text::RelOrientation::FRAME == eOrient ) pOrient = OOO_STRING_SVTOOLS_RTF_PVPG; @@ -3648,7 +3638,7 @@ static Writer& OutRTF_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt ) const char* pS; RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId(); sal_Int16 eOrient = rFlyHori.GetRelationOrient(); - if( FLY_PAGE == eAnchor ) + if (FLY_AT_PAGE == eAnchor) { if( text::RelOrientation::PAGE_FRAME == eOrient || text::RelOrientation::FRAME == eOrient ) pS = OOO_STRING_SVTOOLS_RTF_PHPG; @@ -3702,12 +3692,12 @@ static Writer& OutRTF_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt ) rRTFWrt.bOutFmtAttr = TRUE; switch( nId ) { - case FLY_PAGE: + case FLY_AT_PAGE: rWrt.Strm() << OOO_STRING_SVTOOLS_RTF_FLYPAGE; rWrt.OutULong( rAnchor.GetPageNum() ); break; - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AS_CHAR: rWrt.Strm() << OOO_STRING_SVTOOLS_RTF_FLYCNTNT; break; } diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index 706dc39b81..5c1f0debc0 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -64,15 +64,9 @@ #include #include #include -#ifndef __SGI_STL_DEQUE #include -#endif -#ifndef __SGI_STL_MAP #include -#endif -#ifndef __SGI_STL_UTILITY #include -#endif // --> OD 2004-06-30 #i27767# #include // <-- @@ -82,6 +76,7 @@ #include "dcontact.hxx" // <-- + using namespace ::com::sun::star; #define ANCHOR(p) ((SwFmtAnchor*)p) @@ -459,7 +454,7 @@ void SwRTFParser::SetFlysInDoc() SwFlyFrmFmt* pFmt = pDoc->MakeFlyFrmFmt( aEmptyStr, pParent ); pFmt->SetFmtAttr( pFlySave->aFlySet ); const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_IN_CNTNT != rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR != rAnchor.GetAnchorId()) { // korrigiere noch den Absatz, ist immer der vorhergehende ! // JP 20.09.95: wenn es diesen gibt! (DocAnfang!) @@ -568,7 +563,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) // RTF-Defaults setzen: // --> OD 2004-06-24 #i27767# - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); SwFmtHoriOrient aHori( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME ); SwFmtVertOrient aVert( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ); @@ -844,7 +839,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) switch( GetNextToken() ) { case RTF_FLY_PAGE: - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); aAnchor.SetPageNum( USHORT(nTokenValue)); aAnchor.SetAnchor( 0 ); break; @@ -854,7 +849,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) SwNodeIndex aIdx( pPam->GetPoint()->nNode ); pDoc->GetNodes().GoPrevious( &aIdx ); SwPosition aPos( aIdx ); - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aAnchor.SetAnchor( &aPos ); } break; @@ -1288,7 +1283,7 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf, RES_VERT_ORIENT,*/ RES_ANCHOR ); const SwPosition* pPos = pPam->GetPoint(); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); aAnchor.SetAnchor( pPos ); aFlySet.Put( aAnchor ); aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP )); diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 0cac44fb90..a698afb4cc 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -35,18 +35,14 @@ #include -#ifndef __RSC //autogen #include -#endif #include #include #include #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -82,18 +78,14 @@ #include #include #include -#ifndef _SECTIOM_HXX #include -#endif #include #include #include #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _STATSTR_HRC #include // ResId fuer Statusleiste #endif @@ -471,8 +463,8 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) for ( USHORT nI = pFrmFmts->Count(); nI; --nI ) { const SwFmtAnchor & rAnchor = (*pFrmFmts)[ nI - 1 ]->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) { const SwPosition * pObjPos = rAnchor.GetCntntAnchor(); if ( pObjPos && nNodeIdx == pObjPos->nNode.GetIndex() ) @@ -1270,14 +1262,7 @@ void SwRTFParser::ReadDrawingObject() sw::util::SetLayer aSetLayer(*pDoc); aSetLayer.SendObjectToHeaven(*pStroke); */ - /* - FLY_AT_CNTNT, //Absatzgebundener Rahmen - FLY_IN_CNTNT, //Zeichengebundener Rahmen - FLY_PAGE, //Seitengebundener Rahmen - FLY_AT_FLY, //Rahmengebundener Rahmen ( LAYER_IMPL ) - FLY_AUTO_CNTNT, //Automatisch positionierter, absatzgebundener Rahmen - */ - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFlySet.Put( aAnchor ); @@ -1343,7 +1328,7 @@ void SwRTFParser::InsertShpObject(SdrObject* pStroke, int _nZOrder) SwFmtFollowTextFlow aFollowTextFlow( FALSE ); aFlySet.Put( aFollowTextFlow ); - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFlySet.Put( aAnchor ); @@ -3710,8 +3695,9 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex(); SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); - pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR )); + pHdFtFmt = pDoc->MakeFlySection( FLY_AS_CHAR, + pPam->GetPoint(), &aSet ); pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ); diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx index 7f2179d3ec..275f421266 100644 --- a/sw/source/filter/rtf/wrtrtf.cxx +++ b/sw/source/filter/rtf/wrtrtf.cxx @@ -46,9 +46,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -85,6 +83,7 @@ #include #include + #if defined(UNX) const sal_Char SwRTFWriter::sNewLine = '\012'; #else @@ -1129,7 +1128,7 @@ bool ExportAsInline(const SwFlyFrmFmt& rFlyFrmFmt) { //if not an inline element (hack in our limitations here as to only //graphics like this!!!! - return rFlyFrmFmt.GetAnchor().GetAnchorId() == FLY_IN_CNTNT; + return rFlyFrmFmt.GetAnchor().GetAnchorId() == FLY_AS_CHAR; } void SwRTFWriter::OutRTFFlyFrms(const SwFlyFrmFmt& rFlyFrmFmt) @@ -1779,7 +1778,7 @@ short SwRTFWriter::TrueFrameDirection(const SwFrmFmt &rFlyFmt) const { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt2->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pFlyFmt2 = pAnchor->GetCntntAnchor()->nNode. diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index bf79021866..b1d19915f4 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -35,9 +35,7 @@ #include #include -#ifndef _GRAPH_HXX //autogen #include -#endif #include #include #include @@ -72,13 +70,12 @@ #include // class SwSection #include // class SwSelBoxes #include -#ifndef _DOCSH_HXX #include // class SwDocSh -#endif #include #include #include + #define MAX_FIELDLEN 64000 using namespace com::sun::star; @@ -437,7 +434,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* // Damit die Frames bei Einfuegen in existierendes Doc // erzeugt werden (erst nach Setzen des Ankers!): if(pDoc->GetRootFrm() - && FLY_AT_CNTNT == pFmt->GetAnchor().GetAnchorId()) + && (FLY_AT_PARA == pFmt->GetAnchor().GetAnchorId())) { pFmt->MakeFrms(); } @@ -1285,7 +1282,7 @@ SwFltOutBase::~SwFltOutBase() } SwFltOutBase::SwFltOutBase(SwDoc& rDocu) - : rDoc(rDocu), eFlyAnchor(FLY_AT_CNTNT), bFlyAbsPos(false) + : rDoc(rDocu), eFlyAnchor(FLY_AT_PARA), bFlyAbsPos(false) { } @@ -1702,8 +1699,8 @@ BOOL SwFltOutBase::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/, ASSERT( FALSE, "SetFlyAnchor() ohne Fly" ); return; } - if( eAnchor == FLY_IN_CNTNT ){ - ASSERT( FALSE, "SetFlyAnchor( FLY_IN_CNTNT ) nicht implementiert" ); + if ( eAnchor == FLY_AS_CHAR ){ + ASSERT( FALSE, "SetFlyAnchor( FLY_AS_CHAR ) nicht implementiert" ); return; } SwFmtAnchor& rAnchor = (SwFmtAnchor&)GetFlyFrmAttr( RES_ANCHOR ); diff --git a/sw/source/filter/ww1/w1sprm.cxx b/sw/source/filter/ww1/w1sprm.cxx index 8d3c5701b9..eceaca80dd 100644 --- a/sw/source/filter/ww1/w1sprm.cxx +++ b/sw/source/filter/ww1/w1sprm.cxx @@ -31,9 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - - #include #include @@ -46,10 +43,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif - #include #include @@ -595,13 +589,13 @@ void Ww1SingleSprmPpc::Start( sal_Int16 eVRel; // Seite oder Seitenrand switch ( ( nPpc & 0x30 ) >> 4 ){ // Y - Bindung bestimmt Sw-Bindung - case 0: eAnchor = FLY_AT_CNTNT; // Vert Margin + case 0: eAnchor = FLY_AT_PARA; // Vert Margin eVRel = text::RelOrientation::PRINT_AREA; // if( nYPos < 0 ) // nYPos = 0; // koennen wir nicht break; /* case 1:*/ // Vert. Seite - default:eAnchor = FLY_PAGE; // Vert Page oder unknown + default:eAnchor = FLY_AT_PAGE; // Vert Page oder unknown eVRel = text::RelOrientation::FRAME; break; // 2=Vert. Paragraph, 3=Use Default } diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 861587ff6e..2fe6b50663 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -190,7 +190,7 @@ namespace sw meWriterType(eTxtBox), mpStartFrameContent(0), // --> OD 2007-04-19 #i43447# - move to initialization list - mbIsInline( (rFmt.GetAnchor().GetAnchorId() == FLY_IN_CNTNT) ) + mbIsInline( (rFmt.GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) // <-- { switch (rFmt.Which()) diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index a23f68f813..7cb6aa1386 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -587,7 +587,7 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock USHORT nFlags=0; //If nFlags isn't 0x14 its overridden by the escher properties - if( FLY_PAGE == rFmt.GetAnchor().GetAnchorId()) + if (FLY_AT_PAGE == rFmt.GetAnchor().GetAnchorId()) nFlags = 0x0000; else nFlags = 0x0014; // x-rel to text, y-rel to text @@ -2117,7 +2117,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, { const RndStdIds eAnchor = _rFrmFmt.GetAnchor().GetAnchorId(); - if ( FLY_IN_CNTNT == eAnchor || FLY_AT_FLY == eAnchor ) + if ( (FLY_AS_CHAR == eAnchor) || (FLY_AT_FLY == eAnchor) ) { // no conversion for as-character or at frame anchored objects return false; @@ -2166,7 +2166,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, // the fact, that the object is anchored at a paragraph, which has a "column // break before" attribute bool bConvDueToAnchoredAtColBreakPara( false ); - if ( ( eAnchor == FLY_AT_CNTNT || eAnchor == FLY_AUTO_CNTNT ) && + if ( ( (eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR) ) && _rFrmFmt.GetAnchor().GetCntntAnchor() && _rFrmFmt.GetAnchor().GetCntntAnchor()->nNode.GetNode().IsTxtNode() ) { @@ -2403,7 +2403,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) { const RndStdIds eAnchor = rFmt.GetAnchor().GetAnchorId(); - mbInline = (eAnchor == FLY_IN_CNTNT); + mbInline = (eAnchor == FLY_AS_CHAR); SwFmtHoriOrient rHoriOri = rFmt.GetHoriOrient(); SwFmtVertOrient rVertOri = rFmt.GetVertOrient(); @@ -2487,13 +2487,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) case text::RelOrientation::FRAME: case text::RelOrientation::FRAME_LEFT: //:-( case text::RelOrientation::FRAME_RIGHT: //:-( - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnXRelTo = 1; else mnXRelTo = 2; break; case text::RelOrientation::PRINT_AREA: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnXRelTo = 0; else mnXRelTo = 2; @@ -2515,13 +2515,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) mnYRelTo = 1; break; case text::RelOrientation::PRINT_AREA: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnYRelTo = 0; else mnYRelTo = 2; break; case text::RelOrientation::FRAME: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnYRelTo = 1; else mnYRelTo = 2; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 7ef0640ed1..92da903191 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -376,7 +376,7 @@ xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) if (nPos >= nStartPos && nPos <= nMinPos) nMinPos = nPos; - if (maFlyIter->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT) + if (maFlyIter->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) { ++nPos; if (nPos >= nStartPos && nPos <= nMinPos) @@ -1301,7 +1301,7 @@ short MSWordExportBase::TrueFrameDirection( const SwFrmFmt &rFlyFmt ) const { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if ( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pFlyFmt = pAnchor->GetCntntAnchor()->nNode.GetNode().GetFlyFmt(); @@ -1359,7 +1359,7 @@ SvxBrushItem WW8Export::TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const { pRet = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if (FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { pFlyFmt = @@ -2497,12 +2497,13 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point aOffset -= aPageRect.Pos(); m_rWW8Export.pFlyOffset = &aOffset; - m_rWW8Export.eNewAnchorType = FLY_PAGE; + m_rWW8Export.eNewAnchorType = FLY_AT_PAGE; } m_rWW8Export.mpParentFrame = &rFmt; if ( - m_rWW8Export.bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && + m_rWW8Export.bIsInTable && + (FLY_AT_PAGE != rAnch.GetAnchorId()) && !m_rWW8Export.pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) { @@ -2534,7 +2535,7 @@ void AttributeOutputBase::OutputFlyFrame( const sw::Frame& rFmt ) Point* pLayPos; bool bValidNdPos = false, bValidPgPos = false; - if ( FLY_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId() ) + if (FLY_AT_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId()) { // get the Layout Node-Position. if ( !bValidPgPos ) diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 953f128751..9fc9d23efe 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2899,7 +2899,7 @@ void MSWordExportBase::ExportDocument( bool bWriteAll ) mpParentFrame = 0; pFlyOffset = 0; - eNewAnchorType = FLY_PAGE; + eNewAnchorType = FLY_AT_PAGE; nTxtTyp = TXT_MAINTEXT; // --> OD 2007-04-19 #i43447# - removed // nFlyWidth = nFlyHeight = 0; diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index ed3d1b3b7e..b8ed5cf3e3 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -404,7 +404,7 @@ void WW8Export::OutGrf(const sw::Frame &rFrame) const SwFrmFmt &rFlyFmt = rFrame.GetFrmFmt(); const RndStdIds eAn = rFlyFmt.GetAttrSet().GetAnchor(false).GetAnchorId(); - if( eAn == FLY_IN_CNTNT ) + if (eAn == FLY_AS_CHAR) { sal_Int16 eVert = rFlyFmt.GetVertOrient().GetVertOrient(); if ((eVert == text::VertOrientation::CHAR_CENTER) || (eVert == text::VertOrientation::LINE_CENTER)) @@ -465,8 +465,8 @@ void WW8Export::OutGrf(const sw::Frame &rFrame) // Otherwise, an additional paragraph is exported for a graphic, which is // forced to be treated as inline, because it's anchored inside another frame. if ( !rFrame.IsInline() && - ( ( eAn == FLY_AT_CNTNT && ( bWrtWW8 || !bIsInTable ) ) || - eAn == FLY_PAGE ) ) + ( ((eAn == FLY_AT_PARA) && ( bWrtWW8 || !bIsInTable )) || + (eAn == FLY_AT_PAGE)) ) // <-- { WriteChar( (char)0x0d ); // umgebenden Rahmen mit CR abschliessen diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index f9117f8c13..288a415223 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -4069,15 +4069,15 @@ void WW8AttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor ) BYTE nP = 0; switch ( rAnchor.GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: // Vert: Page | Horz: Page nP |= (1 << 4) | (2 << 6); break; // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!! case FLY_AT_FLY: - case FLY_AUTO_CNTNT: - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_CHAR: + case FLY_AT_PARA: + case FLY_AS_CHAR: // Vert: Page | Horz: Page nP |= (2 << 4) | (0 << 6); break; diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index fe7fb79e01..9c04cb7524 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -36,14 +36,10 @@ #include #include #include -#ifndef _NDTXT #include -#endif #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -51,6 +47,7 @@ #include "ww8glsy.hxx" #include "ww8par.hxx" + WW8Glossary::WW8Glossary(SvStorageStreamRef &refStrm, BYTE nVersion, SvStorage *pStg) : pGlossary(0), rStrm(refStrm), xStg(pStg), nStrings(0) @@ -82,10 +79,10 @@ bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex &rIdx) RES_DRAWFRMFMT != pFrmFmt->Which() ) continue; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - const SwPosition* pAPos; - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) && + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && rIdx == pAPos->nNode.GetIndex() ) { bRet=true; diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 4948ac5edd..cc17df6256 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -58,9 +58,7 @@ #include #include #include -#ifndef _SVX_CNTRITEM_HXX #include -#endif #include #include #include @@ -191,13 +189,13 @@ bool SwWW8ImplReader::ReadGrafStart(void* pData, short nDataSiz, } pStrm->Read(pData, nDataSiz); - RndStdIds eAnchor = (SVBT8ToByte(pDo->by) < 2) ? FLY_PAGE : FLY_AT_CNTNT; + RndStdIds eAnchor = (SVBT8ToByte(pDo->by) < 2) ? FLY_AT_PAGE : FLY_AT_PARA; rSet.Put(SwFmtAnchor(eAnchor)); nDrawXOfs2 = nDrawXOfs; nDrawYOfs2 = nDrawYOfs; - if( eAnchor == FLY_AT_CNTNT ) + if (eAnchor == FLY_AT_PARA) { if( SVBT8ToByte( pDo->bx ) == 1 ) // Pos: echt links nDrawXOfs2 = static_cast< short >(nDrawXOfs2 - maSectionManager.GetPageLeft()); @@ -2247,7 +2245,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, { ASSERT(pRecord || pFSPA, "give me something! to work with for anchoring"); if (!pRecord && !pFSPA) - return FLY_PAGE; + return FLY_AT_PAGE; SvxMSDffImportRec aRecordFromFSPA; if (!pRecord) @@ -2298,7 +2296,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, UINT32 nYRelTo = nCntRelTo > pRecord->nYRelTo ? pRecord->nYRelTo : 1; // --> OD 2005-03-03 #i43718# - RndStdIds eAnchor = IsInlineEscherHack() ? FLY_IN_CNTNT : FLY_AUTO_CNTNT; + RndStdIds eAnchor = IsInlineEscherHack() ? FLY_AS_CHAR : FLY_AT_CHAR; // <-- SwFmtAnchor aAnchor( eAnchor ); @@ -2462,7 +2460,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, if ( (pFSPA->nYaTop < 0) && (eVertOri == text::VertOrientation::NONE) && - ((eAnchor == FLY_AT_CNTNT) || (eAnchor == FLY_AUTO_CNTNT)) + ((eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR)) ) { maTracer.Log(sw::log::eNegativeVertPlacement); @@ -2845,7 +2843,7 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) SwFrmFmt *SwWW8ImplReader::AddAutoAnchor(SwFrmFmt *pFmt) { - if (pFmt && (pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT)) + if (pFmt && (pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR)) { sal_uInt16 nTextAreaWidth = static_cast< sal_uInt16 >( maSectionManager.GetPageWidth() - maSectionManager.GetPageRight() - maSectionManager.GetPageLeft()); @@ -2860,8 +2858,10 @@ SwFrmFmt *SwWW8ImplReader::AddAutoAnchor(SwFrmFmt *pFmt) * * Leave to later and set the correct location then. */ - if ((pFmt) && (pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT)) + if ((pFmt) && (pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR)) + { pAnchorStck->AddAnchor(*pPaM->GetPoint(), pFmt); + } return pFmt; } @@ -3234,7 +3234,7 @@ void SwWW8ImplReader::GrafikDtor() void SwWW8FltAnchorStack::AddAnchor(const SwPosition& rPos, SwFrmFmt *pFmt) { - ASSERT(pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT, + ASSERT(pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR, "Don't use fltanchors with inline frames, slap!"); NewAttr(rPos, SwFltAnchor(pFmt)); } diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index 0472567812..a6a19629f6 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -33,9 +33,7 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ -#ifndef __SGI_STL_ITERATOR #include -#endif #include #include #include @@ -415,7 +413,7 @@ SwFlyFrmFmt* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc& rPD, // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden: if (rDoc.GetRootFrm() && - (FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId())) + (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId())) { pFlyFmt->MakeFrms(); } @@ -548,9 +546,11 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, // it is anchored in content; because this anchor add // a character into the textnode. // IussueZilla task 2806 - if( FLY_IN_CNTNT == + if (FLY_AS_CHAR == pFlyFmtOfJustInsertedGraphic->GetAnchor().GetAnchorId() ) + { aFlySet.ClearItem( RES_ANCHOR ); + } pFlyFmtOfJustInsertedGraphic->SetFmtAttr( aFlySet ); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index c73394f7b4..9bb61645b4 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1648,7 +1648,7 @@ void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(long nStart, long nLen, pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1; pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0); - SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_CNTNT, pPaM->GetPoint()); + SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_PARA, pPaM->GetPoint()); pFrame->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, nPageWidth, MINLAY)); pFrame->SetFmtAttr(SwFmtSurround(SURROUND_THROUGHT)); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index b737fc1102..858fabd14a 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3473,7 +3473,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // --> OD 2005-03-21 #i45301# - anchor nested table inside Writer fly frame // only at-character, if absolute position object attributes are available. // Thus, default anchor type is as-character anchored. - RndStdIds eAnchor( FLY_IN_CNTNT ); + RndStdIds eAnchor( FLY_AS_CHAR ); // <-- if ( nInTable ) { @@ -3505,7 +3505,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // <-- // --> OD 2005-03-21 #i45301# - anchor nested table Writer fly // frame at-character - eAnchor = FLY_AUTO_CNTNT; + eAnchor = FLY_AT_CHAR; // <-- } } @@ -3523,7 +3523,8 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) "how could we be in a local apo and have no apo"); } - if ( eAnchor == FLY_AUTO_CNTNT && !maTableStack.empty() && !InEqualApo(nNewInTable) ) + if ((eAnchor == FLY_AT_CHAR) + && !maTableStack.empty() && !InEqualApo(nNewInTable) ) { pTableDesc->pParentPos = new SwPosition(*pPaM->GetPoint()); SfxItemSet aItemSet(rDoc.GetAttrPool(), @@ -3551,7 +3552,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) if ( pTableWFlyPara && pTableSFlyPara ) { WW8FlySet aFlySet( *this, pTableWFlyPara, pTableSFlyPara, false ); - SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_CHAR ); aAnchor.SetAnchor( pTableDesc->pParentPos ); aFlySet.Put( aAnchor ); pTableDesc->pFlyFmt->SetFmtAttr( aFlySet ); @@ -3606,8 +3607,8 @@ bool lcl_PamContainsFly(SwPaM & rPam) switch (pAnchor->GetAnchorId()) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { const SwPosition* pAPos = pAnchor->GetCntntAnchor(); diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index f36ebeda5d..0251f12081 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -35,12 +35,8 @@ #include "writerhelper.hxx" #include -#ifndef __SGI_STL_ALGORITHM #include -#endif -#ifndef __SGI_STL_FUNCTIONAL #include -#endif #include #include #include @@ -59,9 +55,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include // fuer Ole-Node -#endif #include // Progress #include #include @@ -296,7 +290,7 @@ SwFrmFmt* SwWW8ImplReader::ImportOle(const Graphic* pGrf, if (!mbNewDoc) Reader::ResetFrmFmtAttrs( *pTempSet ); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); aAnchor.SetAnchor( pPaM->GetPoint() ); pTempSet->Put( aAnchor ); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 3cded67e9f..df8df85699 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -45,17 +45,11 @@ #include #include -#ifndef _UCBHELPER_CONTENT_HXX_ #include -#endif -#ifndef _UCBHELPER_CONTENTBROKER_HXX_ #include -#endif #include -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include -#endif #include #include #include @@ -2216,7 +2210,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, String& rStr ) */ SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - aFlySet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aFlySet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); pFlyFmtOfJustInsertedGraphic = rDoc.Insert( *pPaM, aGrfName, diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 64143da9d8..202286bde1 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -44,9 +44,7 @@ #include #include #include -#ifndef _SVX_CNTRITEM_HXX //autogen #include -#endif #include #include #include @@ -65,19 +63,13 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include -#ifndef _SVX_EMPHITEM_HXX //autogen #include -#endif #include #include -#ifndef _SVX_SCRIPSPACEITEM_HXX #include -#endif #include #include #include @@ -1995,7 +1987,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM, nYBind = (( rWW.nSp29 & 0x30 ) >> 4); // --> OD 2005-08-24 #i53725# - absolute positioned objects have to be // anchored at-paragraph to assure its correct anchor position. - eAnchor = FLY_AT_CNTNT; + eAnchor = FLY_AT_PARA; // <-- switch (nYBind) { @@ -2287,7 +2279,7 @@ void WW8FlySet::Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM) Reader::ResetFrmFmtAttrs(*this); // Abstand/Umrandung raus Put(SvxLRSpaceItem(RES_LR_SPACE)); //inline writer ole2 objects start with 0.2cm l/r - SwFmtAnchor aAnchor(FLY_IN_CNTNT); + SwFmtAnchor aAnchor(FLY_AS_CHAR); aAnchor.SetAnchor(pPaM->GetPoint()); Put(aAnchor); @@ -2519,8 +2511,10 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, pWWZOrder->InsertTextLayerObject(pOurNewObject); } - if (FLY_IN_CNTNT != pSFlyPara->eAnchor) + if (FLY_AS_CHAR != pSFlyPara->eAnchor) + { pAnchorStck->AddAnchor(*pPaM->GetPoint(),pSFlyPara->pFlyFmt); + } // merke Pos im Haupttext pSFlyPara->pMainTextPos = new SwPosition( *pPaM->GetPoint() ); @@ -3206,7 +3200,7 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) subscripting to force the graphic into a centered position on the line, so we must check when applying sub/super to see if it the subscript range contains only a single graphic, and if that graphic is anchored as - FLY_IN_CNTNT and then we can change its anchoring to centered in the line. + FLY_AS_CHAR and then we can change its anchoring to centered in the line. */ SwFrmFmt *pRet=0; SwNodeIndex aBegin(rRegion.Start()->nNode); @@ -3223,8 +3217,8 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) { const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt(); SwFrmFmt *pFlyFmt = rFly.GetFrmFmt(); - if( pFlyFmt && - FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() ) + if (pFlyFmt && + (FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId())) { pRet = pFlyFmt; } @@ -3240,7 +3234,7 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement() subscripting to force the graphic into a centered position on the line, so we must check when applying sub/super to see if it the subscript range contains only a single graphic, and if that graphic is anchored as - FLY_IN_CNTNT and then we can change its anchoring to centered in the line. + FLY_AS_CHAR and then we can change its anchoring to centered in the line. */ bool bIsGraphicPlacementHack = false; USHORT nPos; diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 160aa2286a..72fe426da2 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -47,9 +47,7 @@ #include #include #include -#ifndef _XMLOFF_TXTPRMAP_HXX #include -#endif #include #include "unocrsr.hxx" #include "unoobj.hxx" @@ -76,6 +74,7 @@ #include #include + using ::rtl::OUString; using ::rtl::OUStringBuffer; using namespace ::com::sun::star; @@ -126,7 +125,7 @@ static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet, rItemSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) ); } - SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_CHAR ); rItemSet.Put( aAnchor ); if( pTwipWidth ) diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx index e300e0d322..b31b84e86d 100644 --- a/sw/source/ui/app/appenv.cxx +++ b/sw/source/ui/app/appenv.cxx @@ -43,18 +43,12 @@ #include #include -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -67,21 +61,13 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif -#ifndef _DOCSH_HXX #include -#endif #include #include #include -#ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED #include -#endif -#ifndef _DBMGR_HXX #include -#endif #include #include #include @@ -91,9 +77,7 @@ #include #include -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif @@ -478,7 +462,7 @@ static USHORT nTitleNo = 0; if (rItem.bSend) { pSh->SttEndDoc(TRUE); - aMgr.InsertFlyFrm(FLY_PAGE, + aMgr.InsertFlyFrm(FLY_AT_PAGE, Point(rItem.lSendFromLeft + lLeft, rItem.lSendFromTop + lUpper), Size (rItem.lAddrFromLeft - rItem.lSendFromLeft, 0)); @@ -494,7 +478,7 @@ static USHORT nTitleNo = 0; // Empfaenger pSh->SttEndDoc(TRUE); - aMgr.InsertFlyFrm(FLY_PAGE, + aMgr.InsertFlyFrm(FLY_AT_PAGE, Point(rItem.lAddrFromLeft + lLeft, rItem.lAddrFromTop + lUpper), Size (nPageW - rItem.lAddrFromLeft - 566, 0)); pSh->EnterSelFrmMode(); diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx index 889b131c14..a90c3beeaf 100644 --- a/sw/source/ui/app/applab.cxx +++ b/sw/source/ui/app/applab.cxx @@ -39,15 +39,9 @@ #include -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -71,21 +65,13 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif -#ifndef _DOCSH_HXX #include -#endif #include #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _DBMGR_HXX #include -#endif #include #include #include @@ -126,7 +112,7 @@ const SwFrmFmt *lcl_InsertBCText( SwWrtShell& rSh, const SwLabItem& rItem, sal_uInt16 nPhyPageNum, nVirtPageNum; rSh.GetPageNum( nPhyPageNum, nVirtPageNum ); - aSet.Put(SwFmtAnchor(bPage ? FLY_IN_CNTNT : FLY_PAGE, nPhyPageNum)); + aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum)); if (!bPage) { aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist, @@ -166,7 +152,7 @@ const SwFrmFmt *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& rItem, sal_uInt16 nPhyPageNum, nVirtPageNum; rSh.GetPageNum( nPhyPageNum, nVirtPageNum ); - aSet.Put(SwFmtAnchor(bPage ? FLY_IN_CNTNT : FLY_PAGE, nPhyPageNum)); + aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum)); if (!bPage) { aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist, diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index ea475f8bb6..c1f35143e8 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -42,9 +42,7 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif #include #include #include @@ -56,9 +54,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -325,7 +321,7 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame( RES_FRM_SIZE, RES_FRM_SIZE, RES_SURROUND, RES_SURROUND, 0 ); - aSet.Put(SwFmtAnchor(FLY_PAGE, 1)); + aSet.Put(SwFmtAnchor(FLY_AT_PAGE, 1)); if(bAlignLeft) aSet.Put(SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA )); else diff --git a/sw/source/ui/dialog/regionsw.cxx b/sw/source/ui/dialog/regionsw.cxx index abda1181f3..c674c1070a 100644 --- a/sw/source/ui/dialog/regionsw.cxx +++ b/sw/source/ui/dialog/regionsw.cxx @@ -36,37 +36,24 @@ #include #include #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include -#ifndef _PASSWD_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SVX_SIZEITEM_HXX //autogen - #include -#endif #include #include #include #include -#ifndef _BASESH_HXX #include -#endif -#ifndef _WDOCSH_HXX #include -#endif -#ifndef _VIEW_HXX #include -#endif #include #include #include // fuer Undo-Ids @@ -75,12 +62,8 @@ #include #include -#ifndef _HELPID_H #include -#endif -#ifndef _CMDID_H #include -#endif #ifndef _REGIONSW_HRC #include #endif @@ -118,7 +101,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) if (!pSet || pSet->Count()==0) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); @@ -154,7 +137,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) { SwFmtCol aCol; SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); USHORT nCol = ((SfxUInt16Item *)pItem)->GetValue(); @@ -232,7 +215,7 @@ IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSection*, pSect ) SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 0); SwRect aRect; - pThis->CalcBoundRect(aRect, FLY_IN_CNTNT); + pThis->CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 0f45470c91..4433f0ca88 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -50,16 +50,12 @@ #include #include #include -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SFX_CLIENTSH_HXX #include -#endif #include #include #include @@ -69,9 +65,6 @@ #include #include #include -//#ifndef _SVDVMARK_HXX //autogen -//#include -//#endif #include #include #include @@ -128,12 +121,8 @@ #include #include -#ifndef _HELPID_H #include -#endif -#ifndef _CMDID_H #include -#endif #ifndef _DOCVW_HRC #include #endif @@ -1019,7 +1008,7 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) default: ASSERT( TRUE, "ChangeFly: Unknown direction." ); } BOOL bSet = FALSE; - if( FLY_IN_CNTNT == eAnchorId && ( nDir % 2 ) ) + if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 )) { long aDiff = aTmp.Top() - aRefPoint.Y(); if( aDiff > 0 ) @@ -1064,7 +1053,8 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) aSet.Put( aVert ); bSet = TRUE; } - if( bWeb && FLY_AT_CNTNT == eAnchorId && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ) ) + if (bWeb && (FLY_AT_PARA == eAnchorId) + && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG )) { SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) ); sal_Int16 eNew; @@ -1091,11 +1081,13 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) rSh.StartAllAction(); if( bSet ) rSh.SetFlyFrmAttr( aSet ); - BOOL bSetPos = FLY_IN_CNTNT != eAnchorId; + BOOL bSetPos = (FLY_AS_CHAR != eAnchorId); if(bSetPos && bWeb) { - if(FLY_PAGE != eAnchorId) + if (FLY_AT_PAGE != eAnchorId) + { bSetPos = FALSE; + } else { bSetPos = (::GetHtmlMode(rView.GetDocShell()) & HTMLMODE_SOME_ABS_POS) ? @@ -1185,7 +1177,8 @@ void SwEditWin::ChangeDrawing( BYTE nDir ) BOOL bDummy; const bool bVertAnchor = rSh.IsFrmVertical( TRUE, bDummy ); const bool bHoriMove = !bVertAnchor == !( nDir % 2 ); - const bool bMoveAllowed = !bHoriMove || rSh.GetAnchorId() != FLY_IN_CNTNT; + const bool bMoveAllowed = + !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR); if ( bMoveAllowed ) { // <-- diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index 46969d633f..7e951d1b8e 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -125,7 +125,7 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) : FreeResource(); SwRect aRect; - rWrtShell.CalcBoundRect(aRect, FLY_IN_CNTNT); + rWrtShell.CalcBoundRect(aRect, FLY_AS_CHAR); nSelectionWidth = aRect.Width(); diff --git a/sw/source/ui/frmdlg/frmmgr.cxx b/sw/source/ui/frmdlg/frmmgr.cxx index 1d649e833a..91f05dc18d 100644 --- a/sw/source/ui/frmdlg/frmmgr.cxx +++ b/sw/source/ui/frmdlg/frmmgr.cxx @@ -31,12 +31,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "cmdid.h" #include "hintids.hxx" - #include #include #include @@ -212,11 +209,11 @@ void SwFlyFrmAttrMgr::InsertFlyFrm(RndStdIds eAnchorType, const Size &rSize, BOOL bAbs ) { - ASSERT( eAnchorType == FLY_PAGE || - eAnchorType == FLY_AT_CNTNT || - eAnchorType == FLY_AUTO_CNTNT || - eAnchorType == FLY_AT_FLY || - eAnchorType == FLY_IN_CNTNT, "Rahmentyp nicht erlaubt" ); + ASSERT( eAnchorType == FLY_AT_PAGE || + eAnchorType == FLY_AT_PARA || + eAnchorType == FLY_AT_CHAR || + eAnchorType == FLY_AT_FLY || + eAnchorType == FLY_AS_CHAR, "invalid frame type" ); if ( bAbs ) SetAbsPos( rPos ); @@ -238,8 +235,8 @@ void SwFlyFrmAttrMgr::SetAnchor( RndStdIds eId ) pOwnSh->GetPageNum( nPhyPageNum, nVirtPageNum ); aSet.Put( SwFmtAnchor( eId, nPhyPageNum ) ); - if( FLY_PAGE == eId || FLY_AT_CNTNT == eId || FLY_AUTO_CNTNT == eId - || FLY_AT_FLY == eId ) + if ((FLY_AT_PAGE == eId) || (FLY_AT_PARA == eId) || (FLY_AT_CHAR == eId) + || (FLY_AT_FLY == eId)) { SwFmtVertOrient aVertOrient( GetVertOrient() ); SwFmtHoriOrient aHoriOrient( GetHoriOrient() ); @@ -319,7 +316,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, rVal.nWidth = rVal.nHeight; rVal.nHeight = nTmp; } - if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY ) + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) { // MinimalPosition rVal.nMinHPos = aBoundRect.Left(); @@ -369,8 +366,8 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, } // OD 12.11.2003 #i22341# - handle to character anchored objects vertical // aligned at character or top of line in a special case - else if ( eAnchorType == FLY_AT_CNTNT || - ( eAnchorType == FLY_AUTO_CNTNT && + else if ((eAnchorType == FLY_AT_PARA) || + ((eAnchorType == FLY_AT_CHAR) && !(rVal.nVRelOrient == text::RelOrientation::CHAR) && !(rVal.nVRelOrient == text::RelOrientation::TEXT_LINE) ) ) { @@ -437,7 +434,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, // vertical aligned at character or top of line. // Note: (1) positive vertical values are positions above the top of line // (2) negative vertical values are positions below the top of line - else if ( eAnchorType == FLY_AUTO_CNTNT && + else if ( (eAnchorType == FLY_AT_CHAR) && ( rVal.nVRelOrient == text::RelOrientation::CHAR || rVal.nVRelOrient == text::RelOrientation::TEXT_LINE ) ) { @@ -484,7 +481,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, rVal.nMaxHeight = aBoundRect.Height(); } } - else if ( eAnchorType == FLY_IN_CNTNT ) + else if ( eAnchorType == FLY_AS_CHAR ) { rVal.nMinHPos = 0; rVal.nMaxHPos = 0; diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 881de1ba1e..264e0c51c9 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -37,12 +37,8 @@ #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _HELPID_H #include -#endif #include #include #include @@ -68,9 +64,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -881,10 +875,10 @@ void SwFrmPage::Reset( const SfxItemSet &rSet ) // Allgemeiner Initialisierungteil switch(rAnchor.GetAnchorId()) { - case FLY_PAGE: aAnchorAtPageRB.Check(); break; - case FLY_AT_CNTNT: aAnchorAtParaRB.Check(); break; - case FLY_AUTO_CNTNT: aAnchorAtCharRB.Check(); break; - case FLY_IN_CNTNT: aAnchorAsCharRB.Check(); break; + case FLY_AT_PAGE: aAnchorAtPageRB.Check(); break; + case FLY_AT_PARA: aAnchorAtParaRB.Check(); break; + case FLY_AT_CHAR: aAnchorAtCharRB.Check(); break; + case FLY_AS_CHAR: aAnchorAsCharRB.Check(); break; case FLY_AT_FLY: aAnchorAtFrameRB.Check();break; default:; //prevent warning } @@ -911,7 +905,7 @@ void SwFrmPage::Reset( const SfxItemSet &rSet ) } if( 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)) { - if(GetAnchor() == FLY_PAGE) + if (GetAnchor() == FLY_AT_PAGE) { aAnchorAtParaRB.Check(); } @@ -1048,8 +1042,10 @@ BOOL SwFrmPage::FillItemSet(SfxItemSet &rSet) // Vertikale Position // fuer zeichengebundene Rahmen Offset umrechenen SwTwips nY = static_cast< SwTwips >(aAtVertPosED.Denormalize(aAtVertPosED.GetValue(FUNIT_TWIP))); - if (eAnchorId == FLY_IN_CNTNT) + if (eAnchorId == FLY_AS_CHAR) + { nY *= -1; + } aVertOrient.SetPos( nY ); } pOldItem = GetOldItem(rSet, FN_VERT_ORIENT); @@ -1188,7 +1184,7 @@ void SwFrmPage::InitPos(RndStdIds eId, } BOOL bEnable = TRUE; - if ( eId == FLY_PAGE ) + if ( eId == FLY_AT_PAGE ) { pVMap = bHtmlMode ? aVPageHtmlMap : aVPageMap; pHMap = bHtmlMode ? aHPageHtmlMap : aHPageMap; @@ -1200,7 +1196,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pVMap = bHtmlMode ? aVFlyHtmlMap : aVFrameMap; pHMap = bHtmlMode ? aHFlyHtmlMap : aHFrameMap; } - else if ( eId == FLY_AT_CNTNT ) + else if ( eId == FLY_AT_PARA ) { if(bHtmlMode) { @@ -1213,7 +1209,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pHMap = aHParaMap; } } - else if ( eId == FLY_AUTO_CNTNT ) + else if ( eId == FLY_AT_CHAR ) { if(bHtmlMode) { @@ -1226,7 +1222,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pHMap = aHCharMap; } } - else if ( eId == FLY_IN_CNTNT ) + else if ( eId == FLY_AS_CHAR ) { pVMap = bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap; pHMap = 0; @@ -1257,7 +1253,7 @@ void SwFrmPage::InitPos(RndStdIds eId, FillRelLB(pVMap, nMapPos, nV, nVRel, aVertRelationLB, aVertRelationFT); // Edits init - bEnable = nH == text::HoriOrientation::NONE && eId != FLY_IN_CNTNT;//#61359# warum nicht in Formaten&& !bFormat; + bEnable = nH == text::HoriOrientation::NONE && eId != FLY_AS_CHAR; if (!bEnable) { aAtHorzPosED.SetValue( 0, FUNIT_TWIP ); @@ -1281,7 +1277,7 @@ void SwFrmPage::InitPos(RndStdIds eId, } else { - if ( eId == FLY_IN_CNTNT ) + if ( eId == FLY_AS_CHAR ) { if ( nY == LONG_MAX ) nY = 0; @@ -1608,15 +1604,23 @@ USHORT SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB ) RndStdIds SwFrmPage::GetAnchor() { - RndStdIds nRet = FLY_PAGE; + RndStdIds nRet = FLY_AT_PAGE; if(aAnchorAtParaRB.IsChecked()) - nRet = FLY_AT_CNTNT; + { + nRet = FLY_AT_PARA; + } else if(aAnchorAtCharRB.IsChecked()) - nRet = FLY_AUTO_CNTNT; + { + nRet = FLY_AT_CHAR; + } else if(aAnchorAsCharRB.IsChecked()) - nRet = FLY_IN_CNTNT; + { + nRet = FLY_AS_CHAR; + } else if(aAnchorAtFrameRB.IsChecked()) + { nRet = FLY_AT_FLY; + } return nRet; } @@ -1818,8 +1822,10 @@ IMPL_LINK( SwFrmPage, RangeModifyHdl, Edit *, EMPTYARG ) if ( aVal.nHPos != nAtHorzPosVal ) aAtHorzPosED.SetValue(aAtHorzPosED.Normalize(aVal.nHPos), FUNIT_TWIP); - SwTwips nUpperOffset = aVal.nAnchorType == FLY_IN_CNTNT ? nUpperBorder : 0; - SwTwips nLowerOffset = aVal.nAnchorType == FLY_IN_CNTNT ? nLowerBorder : 0; + const SwTwips nUpperOffset = (aVal.nAnchorType == FLY_AS_CHAR) + ? nUpperBorder : 0; + const SwTwips nLowerOffset = (aVal.nAnchorType == FLY_AS_CHAR) + ? nLowerBorder : 0; aAtVertPosED.SetMin(aAtVertPosED.Normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset), FUNIT_TWIP); aAtVertPosED.SetMax(aAtVertPosED.Normalize(aVal.nMaxVPos), FUNIT_TWIP); @@ -1905,7 +1911,7 @@ IMPL_LINK( SwFrmPage, PosHdl, ListBox *, pLB ) // Sonderbehandlung fuer HTML-Mode mit horz-vert-Abhaengigkeiten if(bHtmlMode && nHtmlMode&HTMLMODE_SOME_ABS_POS && - FLY_AUTO_CNTNT == (RndStdIds)GetAnchor()) + (FLY_AT_CHAR == GetAnchor())) { BOOL bSet = FALSE; if(bHori) @@ -1977,7 +1983,7 @@ IMPL_LINK( SwFrmPage, RelHdl, ListBox *, pLB ) else bAtVertPosModified = TRUE; - if(bHtmlMode && FLY_AUTO_CNTNT == (RndStdIds)GetAnchor()) // wieder Sonderbehandlung + if (bHtmlMode && (FLY_AT_CHAR == GetAnchor())) { if(bHori) { @@ -2219,7 +2225,7 @@ void SwFrmPage::Init(const SfxItemSet& rSet, BOOL bReset) nOldV = rVert.GetVertOrient(), nOldVRel = rVert.GetRelationOrient(); - if (eAnchorId == FLY_PAGE) + if (eAnchorId == FLY_AT_PAGE) { if (nOldHRel == text::RelOrientation::FRAME) nOldHRel = text::RelOrientation::PAGE_FRAME; diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx index f6ea1dd0db..36f6ed7a00 100644 --- a/sw/source/ui/frmdlg/wrap.cxx +++ b/sw/source/ui/frmdlg/wrap.cxx @@ -36,7 +36,6 @@ #endif - #include "hintids.hxx" #include #include @@ -141,7 +140,7 @@ SwWrapTabPage::SwWrapTabPage(Window *pParent, const SfxItemSet &rSet) : aWrapIL (SW_RES(IL_WRAP)), aWrapILH (SW_RES(ILH_WRAP)), - nAnchorId(FLY_AT_CNTNT), + nAnchorId(FLY_AT_PARA), nHtmlMode(0), pWrtSh(0), @@ -254,10 +253,15 @@ void SwWrapTabPage::Reset(const SfxItemSet &rSet) const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR); nAnchorId = rAnch.GetAnchorId(); - if ( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && nSur != SURROUND_NONE ) + if (((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) + && (nSur != SURROUND_NONE)) + { aWrapAnchorOnlyCB.Check( rSurround.IsAnchorOnly() ); + } else + { aWrapAnchorOnlyCB.Enable( FALSE ); + } BOOL bContour = rSurround.IsContour(); aWrapOutlineCB.Check( bContour ); @@ -452,7 +456,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) // Anchor const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR); nAnchorId = rAnch.GetAnchorId(); - BOOL bEnable = nAnchorId != FLY_IN_CNTNT; + BOOL bEnable = (nAnchorId != FLY_AS_CHAR); if (!bDrawMode) { @@ -521,7 +525,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) } else { - if (aVal.nAnchorType == FLY_IN_CNTNT) + if (aVal.nAnchorType == FLY_AS_CHAR) { nLeft = nRight; @@ -566,7 +570,8 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) sal_Int16 eHOrient = rHori.GetHoriOrient(); sal_Int16 eHRelOrient = rHori.GetRelationOrient(); aWrapOutlineCB.Hide(); - BOOL bAllHtmlModes = (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && + const bool bAllHtmlModes = + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT); aWrapAnchorOnlyCB.Enable( bAllHtmlModes && nSur != SURROUND_NONE ); aWrapOutsideCB.Hide(); @@ -574,17 +579,26 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) aWrapTransparentCB.Enable( FALSE ); - aNoWrapRB.Enable( FLY_AT_CNTNT == nAnchorId ); + aNoWrapRB.Enable( FLY_AT_PARA == nAnchorId ); aWrapParallelRB.Enable( FALSE ); - aWrapLeftRB .Enable( FLY_AT_CNTNT == nAnchorId || - (FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::RIGHT && eHRelOrient == text::RelOrientation::PRINT_AREA)); - aWrapRightRB .Enable( FLY_AT_CNTNT == nAnchorId || - ( FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::LEFT && eHRelOrient == text::RelOrientation::PRINT_AREA)); - - aWrapThroughRB.Enable( (FLY_PAGE == nAnchorId || - (FLY_AUTO_CNTNT == nAnchorId && eHRelOrient != text::RelOrientation::PRINT_AREA) || FLY_AT_CNTNT == nAnchorId ) - && bSomeAbsPos && - eHOrient != text::HoriOrientation::RIGHT); + aWrapLeftRB .Enable + ( (FLY_AT_PARA == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHOrient == text::HoriOrientation::RIGHT) + && (eHRelOrient == text::RelOrientation::PRINT_AREA))); + aWrapRightRB .Enable + ( (FLY_AT_PARA == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHOrient == text::HoriOrientation::LEFT) + && (eHRelOrient == text::RelOrientation::PRINT_AREA))); + + aWrapThroughRB.Enable + ( ( (FLY_AT_PAGE == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHRelOrient != text::RelOrientation::PRINT_AREA)) + || (FLY_AT_PARA == nAnchorId)) + && bSomeAbsPos + && (eHOrient != text::HoriOrientation::RIGHT)); if(aNoWrapRB.IsChecked() && !aNoWrapRB.IsEnabled()) { if(aWrapThroughRB.IsEnabled()) @@ -624,7 +638,8 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) aIdealWrapRB.Enable( bEnable ); aWrapThroughRB.Enable( bEnable ); aWrapParallelRB.Enable( bEnable ); - aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) + aWrapAnchorOnlyCB.Enable( + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && nSur != SURROUND_NONE ); } ContourHdl(0); @@ -693,10 +708,11 @@ IMPL_LINK( SwWrapTabPage, WrapTypeHdl, ImageRadioButton *, pBtn ) { BOOL bWrapThrough = (pBtn == &aWrapThroughRB); aWrapTransparentCB.Enable( bWrapThrough && !bHtmlMode ); - bWrapThrough |= ( nAnchorId == FLY_IN_CNTNT ); + bWrapThrough |= ( nAnchorId == FLY_AS_CHAR ); aWrapOutlineCB.Enable( !bWrapThrough && pBtn != &aNoWrapRB); aWrapOutsideCB.Enable( !bWrapThrough && aWrapOutlineCB.IsChecked() ); - aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && + aWrapAnchorOnlyCB.Enable( + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && (pBtn != &aNoWrapRB) ); ContourHdl(0); diff --git a/sw/source/ui/ribbar/conrect.cxx b/sw/source/ui/ribbar/conrect.cxx index 2bd57967d2..d676b8eaaf 100644 --- a/sw/source/ui/ribbar/conrect.cxx +++ b/sw/source/ui/ribbar/conrect.cxx @@ -43,21 +43,14 @@ #include #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _VIEW_HXX #include -#endif #include #include #include -#ifndef _DRAWBASE_HXX #include -#endif -#ifndef _CONRECT_HXX #include -#endif + /************************************************************************* |* @@ -119,7 +112,7 @@ BOOL ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt) case OBJ_TEXT: if( bMarquee ) { - m_pSh->ChgAnchor(FLY_IN_CNTNT); + m_pSh->ChgAnchor(FLY_AS_CHAR); if( pObj ) { diff --git a/sw/source/ui/ribbar/drawbase.cxx b/sw/source/ui/ribbar/drawbase.cxx index a9fe374f73..31c75c5699 100644 --- a/sw/source/ui/ribbar/drawbase.cxx +++ b/sw/source/ui/ribbar/drawbase.cxx @@ -344,7 +344,8 @@ BOOL SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt) if ( xRecorder.is() ) { SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME); - aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME, (USHORT)FLY_AT_CNTNT )); + aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME, + static_cast(FLY_AT_PARA) )); aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff())); aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize())); aReq.Done(); diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index a32d3e1f1b..ab0b64b41a 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -100,9 +100,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif @@ -1063,14 +1061,14 @@ void SwBaseShell::Execute(SfxRequest &rReq) case FN_TOOL_ANKER_FRAME: { RndStdIds eSet = nSlot == FN_TOOL_ANKER_PAGE - ? FLY_PAGE + ? FLY_AT_PAGE : nSlot == FN_TOOL_ANKER_PARAGRAPH - ? FLY_AT_CNTNT + ? FLY_AT_PARA : nSlot == FN_TOOL_ANKER_FRAME ? FLY_AT_FLY : nSlot == FN_TOOL_ANKER_CHAR - ? FLY_IN_CNTNT - : FLY_AUTO_CNTNT; + ? FLY_AS_CHAR + : FLY_AT_CHAR; rSh.StartUndo(); if( rSh.IsObjSelected() ) rSh.ChgAnchor( eSet ); @@ -1101,7 +1099,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) switch( eSet ) { case FLY_AT_FLY: - case FLY_PAGE: + case FLY_AT_PAGE: //Durchlauf, links oder von links, oben, von oben if(eSurround != SURROUND_THROUGHT) @@ -1114,7 +1112,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: //links, von links, rechts, oben, kein Uml, li+re Umlauf, if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT) aSet.Put(SwFmtSurround(SURROUND_LEFT)); @@ -1126,7 +1124,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: //links, von links, rechts, oben, Durchlauf if(eSurround != SURROUND_THROUGHT) aSet.Put(SwFmtSurround(SURROUND_THROUGHT)); @@ -1624,12 +1622,17 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) else rSh.GetFlyFrmAttr(aSet); RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId(); - BOOL bSet; - bSet = (nWhich == FN_TOOL_ANKER_PAGE && eSet == FLY_PAGE) || - (nWhich == FN_TOOL_ANKER_PARAGRAPH && eSet == FLY_AT_CNTNT) || - (nWhich == FN_TOOL_ANKER_FRAME && eSet == FLY_AT_FLY) || - (nWhich == FN_TOOL_ANKER_AT_CHAR && eSet == FLY_AUTO_CNTNT) || - (nWhich == FN_TOOL_ANKER_CHAR && eSet == FLY_IN_CNTNT); + const BOOL bSet = + ((nWhich == FN_TOOL_ANKER_PAGE) && + (eSet == FLY_AT_PAGE)) + || ((nWhich == FN_TOOL_ANKER_PARAGRAPH) && + (eSet == FLY_AT_PARA)) + || ((nWhich == FN_TOOL_ANKER_FRAME) && + (eSet == FLY_AT_FLY)) + || ((nWhich == FN_TOOL_ANKER_AT_CHAR) && + (eSet == FLY_AT_CHAR)) + || ((nWhich == FN_TOOL_ANKER_CHAR) && + (eSet == FLY_AS_CHAR)); if(nWhich != FN_TOOL_ANKER) { USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); @@ -1646,16 +1649,16 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) switch (eSet) { - case FLY_PAGE: + case FLY_AT_PAGE: nSlotId = FN_TOOL_ANKER_PAGE; break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: nSlotId = FN_TOOL_ANKER_PARAGRAPH; break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: nSlotId = FN_TOOL_ANKER_CHAR; break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: nSlotId = FN_TOOL_ANKER_AT_CHAR; break; case FLY_AT_FLY: @@ -1705,15 +1708,18 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) SwSurround nSurround = rWrap.GetSurround(); BOOL bSet = FALSE; - BOOL bDisable = nAnchorType == - 1 || nAnchorType == FLY_IN_CNTNT; - BOOL bHtmlMode = 0 != ::GetHtmlMode(GetView().GetDocShell()); + bool bDisable = + (nAnchorType == - 1) || (nAnchorType == FLY_AS_CHAR); + const bool bHtmlMode = + 0 != ::GetHtmlMode(GetView().GetDocShell()); switch( nWhich ) { case FN_FRAME_NOWRAP: bDisable |= - ( nAnchorType != FLY_AT_CNTNT && - nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE); + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE)); bSet = nSurround == SURROUND_NONE; break; case FN_FRAME_WRAP: @@ -1726,7 +1732,9 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) break; case FN_FRAME_WRAPTHRU: bDisable |= (bHtmlMode || - (nAnchorType != FLY_AT_CNTNT&& nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE)); + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE))); if(bObj) bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId(); else @@ -1766,7 +1774,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) break; case FN_WRAP_ANCHOR_ONLY: bDisable |= (bHtmlMode || - (nAnchorType != FLY_AT_CNTNT)); + (nAnchorType != FLY_AT_PARA)); bSet = rWrap.IsAnchorOnly(); break; case FN_FRAME_WRAP_LEFT: diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx index 75026e8d4e..7b3b812fc4 100644 --- a/sw/source/ui/shells/drwbassh.cxx +++ b/sw/source/ui/shells/drwbassh.cxx @@ -49,9 +49,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #include #include #include @@ -479,7 +477,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) { // Objekte nicht aneinander ausrichten USHORT nAnchor = pSh->GetAnchorId(); - if (nAnchor == FLY_IN_CNTNT) + if (nAnchor == FLY_AS_CHAR) { sal_Int16 nVertOrient = -1; @@ -509,7 +507,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) } break; } - if (nAnchor == FLY_AT_CNTNT) + if (nAnchor == FLY_AT_PARA) break; // Absatzverankerte Rahmen nicht ausrichten } @@ -855,7 +853,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nWidth = pValidation->nHeight; pValidation->nHeight = nTmp; } - if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY ) + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) { // MinimalPosition pValidation->nMinHPos = aBoundRect.Left(); @@ -903,7 +901,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight; pValidation->nMaxWidth = aBoundRect.Right() - nH; } - else if ( eAnchorType == FLY_AT_CNTNT || eAnchorType == FLY_AUTO_CNTNT ) + else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR)) { if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right()) { @@ -964,7 +962,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV; pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH; } - else if ( eAnchorType == FLY_IN_CNTNT ) + else if (eAnchorType == FLY_AS_CHAR) { pValidation->nMinHPos = 0; pValidation->nMaxHPos = 0; diff --git a/sw/source/ui/shells/textdrw.cxx b/sw/source/ui/shells/textdrw.cxx index 8031028cad..622a78e195 100644 --- a/sw/source/ui/shells/textdrw.cxx +++ b/sw/source/ui/shells/textdrw.cxx @@ -39,23 +39,17 @@ #include #include -#ifndef _VIEW_HXX #include -#endif #include #include #include -#ifndef _BASESH_HXX #include -#endif #ifndef _POOLFMT_HRC #include #endif -#ifndef _DOCSH_HXX #include -#endif #include #include #include diff --git a/sw/source/ui/shells/textidx.cxx b/sw/source/ui/shells/textidx.cxx index c3fb70f483..9804c49239 100644 --- a/sw/source/ui/shells/textidx.cxx +++ b/sw/source/ui/shells/textidx.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -55,6 +53,8 @@ #include "swabstdlg.hxx" #include #include + + // STATIC DATA ----------------------------------------------------------- void SwTextShell::ExecIdx(SfxRequest &rReq) @@ -136,7 +136,7 @@ void SwTextShell::ExecIdx(SfxRequest &rReq) 0 ); SwWrtShell& rSh = GetShell(); SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 965b0f5d32..9188b6f177 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -39,9 +39,7 @@ #include #include -#ifndef __RSC //autogen #include -#endif #include #include #include @@ -82,9 +80,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif @@ -112,9 +108,7 @@ #ifndef _POPUP_HRC #include #endif -#ifndef _SWERROR_H #include -#endif #include #include @@ -566,7 +560,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); aMgr.SetCol( aCol ); } - aMgr.InsertFlyFrm(FLY_AT_CNTNT, aStartPos, aSize); + aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize); GetShell().EndAllAction(); GetShell().UnlockPaint(); } @@ -600,7 +594,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) Size aSize(aMgr.GetSize()); aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width(); Point aPos = aMgr.GetPos(); - RndStdIds eAnchor = FLY_AT_CNTNT; + RndStdIds eAnchor = FLY_AT_PARA; if(pArgs->GetItemState(nSlot, FALSE, &pItem) == SFX_ITEM_SET) eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue(); if(pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem) == SFX_ITEM_SET) @@ -764,7 +758,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) SwFlyFrmAttrMgr aFrmMgr( TRUE, &rSh, FRMMGR_TYPE_GRF ); // am FrmMgr muessen die richtigen Parameter eingestellt werden - aFrmMgr.SetAnchor(FLY_IN_CNTNT); + aFrmMgr.SetAnchor(FLY_AS_CHAR); rSh.SplitNode( FALSE, FALSE ); rSh.SplitNode( FALSE, FALSE ); diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 493daabe92..82587eb23c 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -34,12 +34,6 @@ #include #include -// #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ -// #include -// #endif -// #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_ -// #include -// #endif #include #include #include @@ -49,9 +43,6 @@ #include #include -// #ifndef _FILTER_HXX -// #include -// #endif #include #include #include @@ -69,12 +60,8 @@ #include #include #include -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -94,9 +81,7 @@ #include #include #include -#ifndef __RSC //autogen #include -#endif #include #include #include @@ -148,10 +133,6 @@ #include #include -// #ifndef _FRMMGR_HXX -// #include -// #endif - #include //#outline level,added by zhaojianwei #include diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx index 04ff2c9047..b131190e8f 100644 --- a/sw/source/ui/uiview/viewtab.cxx +++ b/sw/source/ui/uiview/viewtab.cxx @@ -347,7 +347,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) if(aSize.GetWidthPercent()) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nPrtWidth = aRect.Width(); aSize.SetWidthPercent(BYTE((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth)); } @@ -472,7 +472,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) if(aSize.GetHeightPercent()) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nPrtHeight = aRect.Height(); aSize.SetHeightPercent(BYTE(nHeight * 100 /nPrtHeight)); } diff --git a/sw/source/ui/utlui/attrdesc.cxx b/sw/source/ui/utlui/attrdesc.cxx index ae8df6cde9..e528b954e9 100644 --- a/sw/source/ui/utlui/attrdesc.cxx +++ b/sw/source/ui/utlui/attrdesc.cxx @@ -53,9 +53,7 @@ #include #include #include -#ifndef _FMTLINE_HXX #include -#endif #include #include #include @@ -687,13 +685,13 @@ SfxItemPresentation SwFmtAnchor::GetPresentation USHORT nId = 0; switch ( GetAnchorId() ) { - case FLY_AT_CNTNT: //Absatzgebundener Rahmen + case FLY_AT_PARA: nId = STR_FLY_AT_CNTNT; break; - case FLY_IN_CNTNT: //Zeichengebundener Rahmen + case FLY_AS_CHAR: nId = STR_FLY_IN_CNTNT; break; - case FLY_PAGE: //Seitengebundener Rahmen + case FLY_AT_PAGE: nId = STR_FLY_PAGE; break; default:;//prevent warning diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index da9e898de6..583fc6a964 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -39,15 +39,9 @@ #include #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _VIEW_HXX #include -#endif -#ifndef _BASESH_HXX #include -#endif #include #include #include -- cgit v1.2.3 From 0c9c0896608beab01bca96d410b5c83043108fd5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:42 +0100 Subject: swunolocking1: calbck.hxx: SwClientIter constructor takes a const& parameter --- sw/inc/calbck.hxx | 5 ++--- sw/source/core/attr/calbck.cxx | 2 +- sw/source/core/inc/frmtool.hxx | 2 +- sw/source/core/layout/frmtool.cxx | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 1f44308ff4..3c9970bfe2 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -202,7 +202,7 @@ class SwClientIter friend SwClient* SwModify::_Remove(SwClient *); // fuer Ptr-Korrektur friend void SwModify::Add(SwClient *); // nur fuer ASSERT ! - SwModify& rRoot; + SwModify const& rRoot; SwClient *pAkt, *pDelNext; // fuers Updaten der aller Iteratoren beim Einfuegen/Loeschen von // Clients, wenn der Iterator gerade draufsteht. @@ -213,11 +213,10 @@ class SwClientIter TypeId aSrchId; // fuer First/Next - suche diesen Type public: - SW_DLLPUBLIC SwClientIter( SwModify& ); + SW_DLLPUBLIC SwClientIter( SwModify const& ); SW_DLLPUBLIC ~SwClientIter(); const SwModify& GetModify() const { return rRoot; } - SwModify& GetModify() { return rRoot; } #ifndef CFRONT SwClient* operator++(int); // zum Naechsten diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 344f11cbc2..b125f1f71c 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -463,7 +463,7 @@ BOOL SwDepend::GetInfo( SfxPoolItem& rInfo ) const /********************************************************************/ -SwClientIter::SwClientIter( SwModify& rModify ) +SwClientIter::SwClientIter( SwModify const& rModify ) : rRoot( rModify ) { // hinten einketten! diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 199be26f58..1cb76b9255 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -141,7 +141,7 @@ const SwFrm * MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage ); // JP 07.05.98: wird von SwCntntNode::GetFrm und von SwFlyFrm::GetFrm // gerufen -SwFrm* GetFrmOfModify( SwModify&, USHORT nFrmType, const Point* = 0, +SwFrm* GetFrmOfModify( SwModify const&, USHORT const nFrmType, const Point* = 0, const SwPosition *pPos = 0, const BOOL bCalcFrm = FALSE ); diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 6c89d2b20c..faa0122ba0 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -3519,8 +3519,8 @@ const SwFrm* MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage ) return pPage; } -SwFrm* GetFrmOfModify( SwModify& rMod, USHORT nFrmType, const Point* pPoint, - const SwPosition *pPos, const BOOL bCalcFrm ) +SwFrm* GetFrmOfModify( SwModify const& rMod, USHORT const nFrmType, + const Point* pPoint, const SwPosition *pPos, const BOOL bCalcFrm ) { SwFrm *pMinFrm = 0, *pTmpFrm; SwRect aCalcRect; -- cgit v1.2.3 From 892dc54c9e2bf28b429482050bfb7d3175b88f09 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:42 +0100 Subject: swunolocking1: swtable.hxx: SwTable::FindTable() takes a const parameter --- sw/inc/swtable.hxx | 2 +- sw/source/core/table/swtable.cxx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 92a04e4111..a49bcf6f61 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -299,7 +299,7 @@ public: virtual BOOL GetInfo( SfxPoolItem& ) const; // suche im Format nach der angemeldeten Tabelle - static SwTable* FindTable( SwFrmFmt* pFmt ); + static SwTable * FindTable( SwFrmFmt const*const pFmt ); // Struktur ein wenig aufraeumen void GCLines(); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index caffe6edbf..0c4d018c51 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2060,9 +2060,11 @@ BOOL SwTable::GetInfo( SfxPoolItem& rInfo ) const return TRUE; } -SwTable* SwTable::FindTable( SwFrmFmt* pFmt ) +SwTable * SwTable::FindTable( SwFrmFmt const*const pFmt ) { - return pFmt ? (SwTable*)SwClientIter( *pFmt ).First( TYPE(SwTable) ) : 0; + return (pFmt) + ? static_cast(SwClientIter(*pFmt).First( TYPE(SwTable) )) + : 0; } SwTableNode* SwTable::GetTableNode() const -- cgit v1.2.3 From 0d4542e529f449e4e73c54a743cead227baad16c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:42 +0100 Subject: swunolocking1: #i105557#: remove unnecessary includes of unoobj.hxx --- sw/inc/chpfld.hxx | 4 +++- sw/inc/unochart.hxx | 10 ++++++++-- sw/inc/unofield.hxx | 8 ++++++-- sw/inc/unoidx.hxx | 15 +++++++++++++-- sw/source/core/doc/docfld.cxx | 7 +------ sw/source/core/fields/expfld.cxx | 2 +- 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx index 2e53c66386..992c73dcfc 100644 --- a/sw/inc/chpfld.hxx +++ b/sw/inc/chpfld.hxx @@ -32,9 +32,11 @@ #include "fldbas.hxx" + class SwFrm; +class SwCntntNode; class SwTxtNode; -#include + enum SwChapterFormat { diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index 870b107bb6..a251851c31 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -32,6 +32,8 @@ #include #include + +#include #include #include #include @@ -48,8 +50,8 @@ #include #include #include - #include + #include //OMultiTypeInterfaceContainerHelper #include // helper for implementations #include // helper for implementations @@ -57,17 +59,21 @@ #include // helper for implementations #include +#include +#include +#include #include -#include +class SfxItemPropertySet; class SwDoc; class SwTable; class SwTableBox; class SwUnoCrsr; struct SwRangeDescriptor; class SwSelBoxes; +class SwFrmFmt; ////////////////////////////////////////////////////////////////////// diff --git a/sw/inc/unofield.hxx b/sw/inc/unofield.hxx index abbd3f9e8f..db14db8957 100644 --- a/sw/inc/unofield.hxx +++ b/sw/inc/unofield.hxx @@ -30,14 +30,18 @@ #ifndef _UNOFIELD_HXX #define _UNOFIELD_HXX -#include +#include #include #include +#include + +#include + #include -#include #include #include + class SwFieldType; class SwDoc; class SwFmtFld; diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 544399d544..b9a321f87b 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -30,15 +30,26 @@ #ifndef _UNOIDX_HXX #define _UNOIDX_HXX +#include +#include +#include +#include +#include #include #include -#include -#include + +#include + +#include #include #include + + +class SfxItemPropertySet; class SwTOXBaseSection; class SwTOXMark; class SwTOXType; + /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 05a3efac0e..fbe304a9a8 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -41,12 +41,8 @@ #define _SVSTDARR_ULONGS #include #endif -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _APP_HXX //autogen #include -#endif #include #include #include @@ -69,14 +65,13 @@ #include #include #include -#ifndef _DBMGR_HXX #include -#endif #include #include #include #include #include +#include #ifndef _POOLFMT_HRC #include // fuer InitFldTypes #endif diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 4083f8092f..311ad59135 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From fd85cba270698decca9fcf85a0f2af4dd4b5923a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:43 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unorefmark.hxx: move SwXReferenceMark from unoobj.hxx to new unorefmark.hxx. --- sw/inc/unoobj.hxx | 73 ------------ sw/inc/unorefmark.hxx | 199 +++++++++++++++++++++++++++++++ sw/source/core/unocore/unoclbck.cxx | 1 + sw/source/core/unocore/unocoll.cxx | 4 +- sw/source/core/unocore/unocrsrhelper.cxx | 2 +- sw/source/core/unocore/unoportenum.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 2 +- sw/source/core/unocore/unotext.cxx | 1 + 8 files changed, 206 insertions(+), 77 deletions(-) create mode 100644 sw/inc/unorefmark.hxx diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 4e9511647d..939fd7d222 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -99,7 +99,6 @@ class SwFmtFtn; -class SwFmtRefMark; class GetCurTxtFmtColl; @@ -1416,78 +1415,6 @@ public: //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); }; -/* -----------------27.08.98 15:11------------------- - * - * --------------------------------------------------*/ -typedef ::cppu::WeakImplHelper5 -< - ::com::sun::star::text::XTextContent, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel -> -SwRefMarkBaseClass; - -class SwXReferenceMark : public SwRefMarkBaseClass, - public SwClient -{ - SwEventListenerContainer aLstnrCntnr; - SwDoc* pDoc; - const SwFmtRefMark* pMark; - String sMarkName; - BOOL m_bIsDescriptor; - - BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); -public: - SwXReferenceMark(SwDoc* pDoc, const SwFmtRefMark* pMark); - ~SwXReferenceMark(); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - 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 ); - - const SwFmtRefMark* GetMark()const {return pMark;} - const String& GetMarkName() const {return sMarkName;} - SwDoc* GetDoc() const{return pDoc;} - void Invalidate(); -}; #endif - diff --git a/sw/inc/unorefmark.hxx b/sw/inc/unorefmark.hxx new file mode 100644 index 0000000000..8a37b5655e --- /dev/null +++ b/sw/inc/unorefmark.hxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOREFMARK_HXX +#define SW_UNOREFMARK_HXX + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + + +class SwDoc; +class SwPaM; +class SwFmtRefMark; +class SwXTextCursor; + + +/* -----------------27.08.98 15:11------------------- + * + * --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextContent +> SwXReferenceMark_Base; + +class SwXReferenceMark + : public SwXReferenceMark_Base + , public SwClient +{ + +private: + + SwEventListenerContainer aLstnrCntnr; + SwDoc* pDoc; + const SwFmtRefMark* pMark; + String sMarkName; + BOOL m_bIsDescriptor; + + BOOL IsValid() const {return 0 != GetRegisteredIn();} + void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); + + virtual ~SwXReferenceMark(); + +public: + + SwXReferenceMark(SwDoc * pDoc, const SwFmtRefMark * pMark); + + 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); + + const SwFmtRefMark* GetMark() const {return pMark;} + const String& GetMarkName() const {return sMarkName;} + SwDoc* GetDoc() const {return pDoc;} + void Invalidate(); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOREFMARK_HXX + diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 5936365594..66c0a9a2ed 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 06bbca43e0..b78e34798e 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -76,7 +75,8 @@ #include #include -#include "unometa.hxx" +#include +#include #include "docsh.hxx" diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 08c22ac8e6..07086e364d 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,10 +32,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 6809c389d1..49d2ca28be 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 752022c763..4a67199667 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -31,10 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index c654b5ec6f..e1ec2b9ba2 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From afa5e928c33d7fc88e6be3ca893bd5186df821af Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:43 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unobookmark.hxx: move SwXBookmark, SwXFieldmark from unoobj.hxx to new unobookmark.hxx. --- sw/inc/unobookmark.hxx | 248 +++++++++++++++++++++++++++++++++ sw/inc/unoobj.hxx | 113 +-------------- sw/source/core/crsr/bookmrk.cxx | 2 +- sw/source/core/unocore/unobkm.cxx | 18 ++- sw/source/core/unocore/unocoll.cxx | 1 + sw/source/core/unocore/unoportenum.cxx | 1 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + 8 files changed, 270 insertions(+), 115 deletions(-) create mode 100644 sw/inc/unobookmark.hxx diff --git a/sw/inc/unobookmark.hxx b/sw/inc/unobookmark.hxx new file mode 100644 index 0000000000..2b16d78280 --- /dev/null +++ b/sw/inc/unobookmark.hxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOBOOKMARK_HXX +#define SW_UNOBOOKMARK_HXX + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + + +class SwDoc; + + +typedef ::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextContent +> SwXBookmark_Base; + +class SwXBookmark + : public SwXBookmark_Base + , private SwClient +{ + +private: + + SwEventListenerContainer m_aLstnrCntnr; + SwDoc* m_pDoc; + String m_aName; + ::sw::mark::IMark* m_pRegisteredBookmark; + + void registerInMark(::sw::mark::IMark* const pBkmk); + +protected: + + virtual ~SwXBookmark(); + +public: + + SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); + + const ::sw::mark::IMark* GetBookmark() const + { return m_pRegisteredBookmark; } + ::sw::mark::IMark* GetBookmark() + { return m_pRegisteredBookmark; } + SwDoc* GetDoc() + { return m_pDoc; } + + void attachToRangeEx( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + IDocumentMarkAccess::MarkType eType) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual 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); + + TYPEINFO(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > GetModel(); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + +}; + +typedef cppu::ImplInheritanceHelper1< SwXBookmark, + ::com::sun::star::text::XFormField > SwXFieldmark_Base; + +class SwXFieldmark + : public SwXFieldmark_Base +{ + +private: + + bool isReplacementObject; + +public: + + SwXFieldmark(bool isReplacementObject, + ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0); + + virtual 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); + + virtual ::rtl::OUString SAL_CALL getDescription() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getType() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getRes() + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setDescription(const ::rtl::OUString& rDescription) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setType(::sal_Int16 fieldType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRes(::sal_Int16 res) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOBOOKMARK_HXX + diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 939fd7d222..af81696ca0 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -86,12 +86,11 @@ #include "TextCursorHelper.hxx" #include #include -#include #include #include -#include +#include #include #include @@ -569,116 +568,6 @@ public: }; */ -typedef ::cppu::ImplInheritanceHelper5 -< - ::sfx2::MetadatableMixin, - ::com::sun::star::text::XTextContent, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel -> -SwBookmarkBaseClass; - -class SwXBookmark - : public SwBookmarkBaseClass - , private SwClient -{ - private: - SwEventListenerContainer m_aLstnrCntnr; - SwDoc* m_pDoc; - String m_aName; - ::sw::mark::IMark* m_pRegisteredBookmark; - - void registerInMark(::sw::mark::IMark* const pBkmk) - { - if(pBkmk) - pBkmk->Add(this); - else if(m_pRegisteredBookmark) - { - m_aName = m_pRegisteredBookmark->GetName(); - m_pRegisteredBookmark->Remove(this); - } - m_pRegisteredBookmark = pBkmk; - } - - protected: - virtual ~SwXBookmark(); - public: - SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& rName) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - void attachToRangeEx(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange, IDocumentMarkAccess::MarkType eType) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual 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 ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); - - // MetadatableMixin - virtual ::sfx2::Metadatable* GetCoreObject(); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > GetModel(); - - const ::sw::mark::IMark* GetBookmark() const - { return m_pRegisteredBookmark; } - ::sw::mark::IMark* GetBookmark() - { return m_pRegisteredBookmark; } - SwDoc* GetDoc() - { return m_pDoc; } -}; - -typedef cppu::ImplInheritanceHelper1< SwXBookmark, ::com::sun::star::text::XFormField > SwXFieldmark_BASE; - -class SwXFieldmark : public SwXFieldmark_BASE -{ - private: - bool isReplacementObject; - public: - SwXFieldmark(bool isReplacementObject, ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0); - - virtual 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 ); - virtual ::rtl::OUString SAL_CALL getDescription(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::sal_Int16 SAL_CALL getType( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL getRes( ) throw (::com::sun::star::uno::RuntimeException); - - virtual void SAL_CALL setType( ::sal_Int16 fieldType ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRes( ::sal_Int16 res ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDescription( const ::rtl::OUString& description ) throw (::com::sun::star::uno::RuntimeException); -}; - /*-----------------23.02.98 10:45------------------- --------------------------------------------------*/ diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 8918058c31..b9b7a017fb 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 11ea44de5f..62ef29cf90 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - +#include #include #include #include @@ -74,6 +74,20 @@ namespace ******************************************************************/ TYPEINIT1(SwXBookmark, SwClient) +void SwXBookmark::registerInMark(::sw::mark::IMark* const pBkmk) +{ + if (pBkmk) + { + pBkmk->Add(this); + } + else if (m_pRegisteredBookmark) + { + m_aName = m_pRegisteredBookmark->GetName(); + m_pRegisteredBookmark->Remove(this); + } + m_pRegisteredBookmark = pBkmk; +} + const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() { static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); @@ -353,7 +367,7 @@ void SwXBookmark::removeVetoableChangeListener(const OUString& /*PropertyName*/, { } SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc) - : SwXFieldmark_BASE(pBkm, pDc) + : SwXFieldmark_Base(pBkm, pDc) , isReplacementObject(_isReplacementObject) { } diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index b78e34798e..030fa2a537 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include #include "docsh.hxx" diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 49d2ca28be..12c89e9c24 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index e1ec2b9ba2..c96b3b7275 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index de8bcd61ee..cbc9817217 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -77,6 +77,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 3425397152b30ff898aae071eb6cac444eab3bb5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:44 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unoparagraph.hxx: move SwXParagraph{,Enumeration} from unoobj.hxx to new unoparagraph.hxx. move enum CursorType to unobaseclass.hxx. --- sw/inc/unobaseclass.hxx | 21 ++ sw/inc/unoobj.hxx | 201 --------------- sw/inc/unoparagraph.hxx | 439 ++++++++++++++++++++++++++++++++ sw/source/core/txtnode/ndtxt.cxx | 1 + sw/source/core/unocore/unobkm.cxx | 2 + sw/source/core/unocore/unocoll.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 1 + sw/source/core/unocore/unoframe.cxx | 1 + sw/source/core/unocore/unoftn.cxx | 1 + sw/source/core/unocore/unoidx.cxx | 6 +- sw/source/core/unocore/unoobj2.cxx | 1 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoredline.cxx | 2 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unosect.cxx | 9 +- sw/source/core/unocore/unotbl.cxx | 7 +- sw/source/core/unocore/unotext.cxx | 3 + sw/source/ui/uno/unotxvw.cxx | 1 + 18 files changed, 484 insertions(+), 215 deletions(-) create mode 100644 sw/inc/unoparagraph.hxx diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 7bc5c3a19c..48c00de279 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -43,5 +43,26 @@ cppu::WeakImplHelper2 > SwSimpleEnumerationBaseClass; + +/* -----------------29.04.98 07:35------------------- + * + * --------------------------------------------------*/ +enum CursorType +{ + CURSOR_INVALID, + CURSOR_BODY, + CURSOR_FRAME, + CURSOR_TBLTEXT, + CURSOR_FOOTNOTE, + CURSOR_HEADER, + CURSOR_FOOTER, + CURSOR_REDLINE, + CURSOR_ALL, // for Search&Replace + CURSOR_SELECTION, // create a paragraph enumeration from + // a text range or cursor + CURSOR_SELECTION_IN_TABLE, + CURSOR_META, // meta/meta-field +}; + #endif diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index af81696ca0..29916ee710 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,6 @@ #include #include -#include #include #include @@ -115,25 +113,6 @@ typedef ::std::deque< FrameDependSortListEntry > typedef ::std::deque< ::boost::shared_ptr > FrameDependList_t; -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -enum CursorType -{ - CURSOR_INVALID, - CURSOR_BODY, - CURSOR_FRAME, - CURSOR_TBLTEXT, - CURSOR_FOOTNOTE, - CURSOR_HEADER, - CURSOR_FOOTER, - CURSOR_REDLINE, - CURSOR_ALL, // fuer Search&Replace - CURSOR_SELECTION, // create a paragraph enumeration from a text range or cursor - CURSOR_SELECTION_IN_TABLE, - CURSOR_META, // meta/meta-field -}; - /* -----------------26.06.98 16:18------------------- * @@ -993,186 +972,6 @@ public: void Invalidate(); }; -/*-----------------07.04.98 08:10------------------- - ---------------------------------------------------*/ -class SwXParagraphEnumeration : public SwSimpleEnumerationBaseClass, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xNextPara; - - const SwTable * pOwnTable; - const SwStartNode * pOwnStartNode; // start node of the cell the enumeration - // belongs to. - // Used to restrict the movement of the - // UNO cursor to the cell and its - // embedded tables. - sal_Int32 nFirstParaStart; - sal_Int32 nLastParaEnd; - ULONG nEndIndex; - CursorType eCursorType; - BOOL bFirstParagraph; - - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - -protected: - virtual ~SwXParagraphEnumeration(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > SAL_CALL NextElement_Impl(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - -public: - SwXParagraphEnumeration(SwXText* pParent, SwPosition& rPos, CursorType eType); - SwXParagraphEnumeration(SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); - - - - //XEnumeration - virtual BOOL SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - //non-Uno functions - - void SetOwnTable( const SwTable* pTable ) { pOwnTable = pTable; } - const SwTable* GetOwnTable() const { return pOwnTable; } - void SetOwnStartNode( const SwStartNode* pNode ) { pOwnStartNode = pNode; } - const SwStartNode* GetOwnStartNode() const { return pOwnStartNode; } -}; -/*-----------------07.04.98 08:15------------------- - ---------------------------------------------------*/ -class SwXParagraph : public cppu::ImplInheritanceHelper10 -< - ::sfx2::MetadatableMixin, - ::com::sun::star::beans::XTolerantMultiPropertySet, - ::com::sun::star::beans::XMultiPropertySet, - ::com::sun::star::text::XTextRange, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::text::XTextContent, - ::com::sun::star::container::XContentEnumerationAccess ->, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - rtl::OUString m_sText; - sal_Int32 nSelectionStartPos; - sal_Int32 nSelectionEndPos; - BOOL m_bIsDescriptor; - - -protected: - void SAL_CALL SetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, 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 >& aPropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL GetPropertyValuesTolerant_Impl( - const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames, - sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException); - - virtual ~SwXParagraph(); -public: - SwXParagraph(); - SwXParagraph(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTolerantMultiPropertySet - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); - - //XMultiPropertySet -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - war XTextPortionEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //MetadatableMixin - virtual ::sfx2::Metadatable* GetCoreObject(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - GetModel(); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - BOOL IsDescriptor() const {return m_bIsDescriptor;} - - const SwTxtNode * GetTxtNode() const; - SwTxtNode * GetTxtNode(); - - static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const rtl::OUString& rPropertyName, USHORT nWID = 0); - static SwXParagraph* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); - //falls es mal als Service erzeugt werden kann - //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 ); - void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); -}; /* -----------------23.03.99 12:57------------------- * * --------------------------------------------------*/ diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx new file mode 100644 index 0000000000..6ef62e00c1 --- /dev/null +++ b/sw/inc/unoparagraph.hxx @@ -0,0 +1,439 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOPARAGRAPH_HXX +#define SW_UNOPARAGRAPH_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + + +class SfxItemPropertySet; +struct SwPosition; +class SwUnoCrsr; +class SwStartNode; +class SwTxtNode; +class SwTable; +class SwXText; + + +/*-----------------07.04.98 08:15------------------- + +--------------------------------------------------*/ +typedef ::cppu::ImplInheritanceHelper10 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet +, ::com::sun::star::beans::XTolerantMultiPropertySet +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XTextRange +> SwXParagraph_Base; + +class SwXParagraph + : public SwXParagraph_Base + , public SwClient +{ + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; + SwEventListenerContainer aLstnrCntnr; + const SfxItemPropertySet* m_pPropSet; + ::rtl::OUString m_sText; + sal_Int32 nSelectionStartPos; + sal_Int32 nSelectionEndPos; + BOOL m_bIsDescriptor; + +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 >& rValues) + 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); + + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL + GetPropertyValuesTolerant_Impl( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + sal_Bool bDirectValuesOnly) + throw (::com::sun::star::uno::RuntimeException); + + virtual ~SwXParagraph(); + +public: + + SwXParagraph(); + SwXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const & i_xParent, + SwTxtNode * i_pTxtNode, + sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); + + BOOL IsDescriptor() const {return m_bIsDescriptor;} + + const SwTxtNode * GetTxtNode() const; + SwTxtNode * GetTxtNode(); + + static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); + static SwXParagraph* GetImplementation( + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface> xRef); + void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTolerantMultiPropertySet + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL + setPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL + getPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL + getDirectPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + +}; + + +/*-----------------07.04.98 08:10------------------- + +--------------------------------------------------*/ +class SwXParagraphEnumeration + : public SwSimpleEnumerationBaseClass + , public SwClient +{ + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + xParentText; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + xNextPara; + + const SwTable * pOwnTable; + /// Start node of the cell the enumeration belongs to. + /// Used to restrict the movement of the UNO cursor to the cell and its + /// embedded tables. + const SwStartNode * pOwnStartNode; + sal_Int32 nFirstParaStart; + sal_Int32 nLastParaEnd; + ULONG nEndIndex; + CursorType eCursorType; + BOOL bFirstParagraph; + + SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} + +protected: + + virtual ~SwXParagraphEnumeration(); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > SAL_CALL + NextElement_Impl() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +public: + + SwXParagraphEnumeration( + SwXText* pParent, SwPosition& rPos, CursorType eType); + SwXParagraphEnumeration( + SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); + + // non-Uno functions + + void SetOwnTable(const SwTable* pTable) + { pOwnTable = pTable; } + const SwTable* GetOwnTable() const + { return pOwnTable; } + void SetOwnStartNode(const SwStartNode* pNode) + { pOwnStartNode = pNode; } + const SwStartNode* GetOwnStartNode() const + { return pOwnStartNode; } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOPARAGRAPH_HXX + diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 3df01632b8..92aedfd2f9 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4972,6 +4972,7 @@ bool SwTxtNode::IsInContent() const return !GetDoc()->IsInHeaderFooter( SwNodeIndex(*this) ); } +#include #include ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 62ef29cf90..fbbaa5cbce 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,10 +31,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 030fa2a537..eeca6884f8 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index bd592e4120..31049e6a92 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 0f3057533d..9afdc7e011 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index d7a974bfb1..b97680ae79 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 41643101c1..cacad52afc 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -43,9 +43,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #include #include #include @@ -58,18 +56,18 @@ #include #include #include +#include #include #include #include #include #include #include -#ifndef _DOCSH_HXX //autogen #include -#endif #include #include + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 06415a36e5..a143ef1651 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index c947c4181f..5b28bfb68d 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index d3b85ff340..67704d98ab 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 4a67199667..0367831ee5 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 55b6fc7d0f..3ed9122c00 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -38,24 +38,21 @@ #include #include #include -#ifndef _SVX_XMLCNITEM_HXX #include -#endif #include #include #include #include #include #include +#include #include #include #include #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -65,13 +62,12 @@ #include #include #include -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include -#endif #include /* #109700# */ #include + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; @@ -80,6 +76,7 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::beans; using ::rtl::OUString; + TYPEINIT1(SwXTextSectionClient, SwClient); /*-- 20.12.2005 09:56:33--------------------------------------------------- diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 0adf9c79ac..17f9791d87 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -33,16 +33,12 @@ #include "precompiled_sw.hxx" - - // STL includes #include #include // for DBL_MIN #include -#ifndef _CMDID_H #include -#endif #include #include #include @@ -87,6 +83,7 @@ #include #include #include +#include #include // SvNumberFormatter #include #include @@ -103,9 +100,11 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; + //----------------------------------------------------------------------------- // from unoobj.cxx extern void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) throw (lang::IllegalArgumentException); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index c96b3b7275..aa17a553d6 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -70,9 +71,11 @@ #include + using namespace ::com::sun::star; using ::rtl::OUString; + const sal_Char cInvalidObject[] = "this object is invalid"; /****************************************************************** * SwXText diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index cbc9817217..4b940c2fc7 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 1ec6e9d8665c760588eddff9adb23bafc087d347 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:44 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unosection.hxx: move SwXTextSection from unoobj.hxx to new unosection.hxx. --- sw/inc/unoframe.hxx | 1 + sw/inc/unoobj.hxx | 126 ------------ sw/inc/unosection.hxx | 337 +++++++++++++++++++++++++++++++ sw/inc/unotbl.hxx | 1 + sw/source/core/unocore/unocoll.cxx | 1 + sw/source/core/unocore/unocrsrhelper.cxx | 2 + sw/source/core/unocore/unoidx.cxx | 1 + sw/source/core/unocore/unosect.cxx | 2 +- sw/source/core/unocore/unotbl.cxx | 1 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/filter/xml/xmltble.cxx | 5 +- 11 files changed, 348 insertions(+), 130 deletions(-) create mode 100644 sw/inc/unosection.hxx diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 2775db8690..338d5963d0 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -32,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 29916ee710..86bcbc2b19 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -58,9 +57,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -77,7 +74,6 @@ #include // helper for implementations #include // helper for implementations #include // helper for implementations -#include // helper for implementations #include #include #include @@ -754,128 +750,6 @@ public: const SwUnoCrsr* GetCursor() const { return (const SwUnoCrsr*)GetRegisteredIn(); } }; -/*-----------------09.03.98 13:57------------------- - ---------------------------------------------------*/ - -class SwXTextSection; -class SwXTextSectionClient : public SwClient -{ - 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; -class SwXTextSection : public cppu::WeakImplHelper7 -< - ::com::sun::star::text::XTextSection, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XMultiPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel ->/*, - public SwClient*/ -{ - friend class SwXTextSectionClient; - 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 >& aPropertyNames, 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 >& aPropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader = FALSE); - virtual ~SwXTextSection(); - void ResetClient() {m_pClient = 0;} - void SetClient( SwXTextSectionClient* pClient ){m_pClient = pClient;} - -public: - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextSection - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > SAL_CALL getParentSection(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > > SAL_CALL getChildSections(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XMultiPropertySet -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient -// virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - 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 ); -}; /*-----------------12.02.98 08:01------------------- --------------------------------------------------*/ diff --git a/sw/inc/unosection.hxx b/sw/inc/unosection.hxx new file mode 100644 index 0000000000..31d15d7010 --- /dev/null +++ b/sw/inc/unosection.hxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOSECTION_HXX +#define SW_UNOSECTION_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + + +class SfxItemPropertySet; +class SwSectionFmt; + + +/*-----------------09.03.98 13:57------------------- + +--------------------------------------------------*/ + +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; + +typedef ::cppu::WeakImplHelper7 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextSection +> SwXTextSection_Base; + +class SwXTextSection + : public SwXTextSection_Base +{ + +private: + + friend class SwXTextSectionClient; + + 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); + + 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 const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XTextSection + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > SAL_CALL + getParentSection() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > > SAL_CALL + getChildSections() + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOSECTION_HXX + diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 05983afdba..4f8e08a50a 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -31,6 +31,7 @@ #define _UNOTBL_HXX #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index eeca6884f8..840e66810e 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 07086e364d..34e73a0cf2 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,6 +32,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index cacad52afc..7fcde70176 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 3ed9122c00..c377e2cb3d 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include @@ -45,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 17f9791d87..188e378741 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index aa17a553d6..bc9343996f 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 933c31be23..04f654db61 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -31,10 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include #include #include -#include #include #include #include @@ -44,9 +45,7 @@ #include #include #include -#ifndef _SVX_FRAMEDIRITEM_HXX #include -#endif #include #include "swtable.hxx" -- cgit v1.2.3 From 89257fb5ea7c062c81379d3d05fa1c229067515a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:45 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unotextcursor.hxx: move SwXTextCursor from unoobj.hxx to new unotextcursor.hxx. move enum SwGetPropertyStatesCaller to unotextcursor.hxx. --- sw/inc/unoobj.hxx | 222 +----------- sw/inc/unotbl.hxx | 5 + sw/inc/unotextcursor.hxx | 461 ++++++++++++++++++++++++ sw/source/core/access/accpara.cxx | 3 +- sw/source/core/edit/editsh.cxx | 2 +- sw/source/core/unocore/unobkm.cxx | 1 + sw/source/core/unocore/unocrsrhelper.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 1 + sw/source/core/unocore/unofield.cxx | 1 + sw/source/core/unocore/unoframe.cxx | 1 + sw/source/core/unocore/unoftn.cxx | 1 + sw/source/core/unocore/unoidx.cxx | 1 + sw/source/core/unocore/unoobj.cxx | 2 + sw/source/core/unocore/unoobj2.cxx | 2 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoport.cxx | 1 + sw/source/core/unocore/unoportenum.cxx | 1 + sw/source/core/unocore/unoredline.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unosect.cxx | 1 + sw/source/core/unocore/unotbl.cxx | 2 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/filter/xml/XMLRedlineImportHelper.cxx | 1 + sw/source/filter/xml/xmlimp.cxx | 5 +- sw/source/filter/xml/xmltexti.cxx | 1 + sw/source/ui/uno/unoatxt.cxx | 5 +- sw/source/ui/uno/unotxdoc.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + sw/source/ui/utlui/unotools.cxx | 3 +- 29 files changed, 499 insertions(+), 231 deletions(-) create mode 100644 sw/inc/unotextcursor.hxx diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 86bcbc2b19..d26420749a 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -42,24 +42,16 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -77,13 +69,9 @@ #include #include #include -#include // helper for implementations -#include "TextCursorHelper.hxx" -#include #include #include -#include #include @@ -169,8 +157,8 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); /* -----------------03.12.98 12:22------------------- * * --------------------------------------------------*/ +class OTextCursorHelper; class SwXTextRange; -class SwXTextCursor; class SwXText : public ::com::sun::star::lang::XTypeProvider, public ::com::sun::star::text::XTextRangeCompare, public ::com::sun::star::text::XRelativeTextContentInsert, @@ -285,214 +273,6 @@ public: CursorType GetTextType() {return eCrsrType;} }; -/* -----------------03.12.98 12:16------------------- - * - * --------------------------------------------------*/ -enum SwGetPropertyStatesCaller -{ - SW_PROPERTY_STATE_CALLER_DEFAULT, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, - SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT -}; -#define CRSR_ATTR_MODE_TABLE 1 //attributes should be applied to a table selection -#define CRSR_ATTR_MODE_DONTREPLACE 2 //attributes should be added, not replaced - -typedef cppu::WeakImplHelper12< - ::com::sun::star::text::XSentenceCursor, - ::com::sun::star::text::XWordCursor, - ::com::sun::star::text::XParagraphCursor, - ::com::sun::star::text::XRedline, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::document::XDocumentInsertable, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::util::XSortable, - ::com::sun::star::container::XContentEnumerationAccess, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::beans::XMultiPropertyStates - > SwXTextCursor_Base; -class SwXTextCursor : public SwXTextCursor_Base, - public SwClient, - public OTextCursorHelper -{ - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwSortOptions* pLastSortOptions; - - CursorType eType; - - // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl - // user event has been posted. In this case we have to remove the user - // event in ~SwXTextCursor(). - ULONG mnUserEventId; - bool mbRemoveUserEvent; - // <-- - - DECL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XInterface>* ); - -protected: - virtual ~SwXTextCursor(); -public: - void DeleteAndInsert(const String& rText, const bool bForceExpandHints); - SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); - SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - DECLARE_XINTERFACE() - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextCursor - neu - virtual void SAL_CALL collapseToStart( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL collapseToEnd( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isCollapsed( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL goLeft( sal_Int16 nCount, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL goRight( sal_Int16 nCount, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoStart( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoEnd( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - - //XWordCursor - neu - virtual BOOL SAL_CALL isStartOfWord( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isEndOfWord( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoNextWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoPreviousWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoEndOfWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoStartOfWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - - //XSentenceCursor - neu - virtual BOOL SAL_CALL isStartOfSentence( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isEndOfSentence( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoNextSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoPreviousSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoStartOfSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoEndOfSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - - //ParagraphCursor - neu - virtual BOOL SAL_CALL isStartOfParagraph(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL isEndOfParagraph(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoStartOfParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoEndOfParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoNextParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoPreviousParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - - //XRedline - virtual void SAL_CALL makeRedline( const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - static void SetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const rtl::OUString& rPropertyName, - const ::com::sun::star::uno::Any& aValue, - USHORT nAttrMode = 0) - 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); - static ::com::sun::star::uno::Any GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > GetPropertyStates( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, SwGetPropertyStatesCaller eCaller = SW_PROPERTY_STATE_CALLER_DEFAULT) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::beans::PropertyState GetPropertyState( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static void SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XDocumentInsertable - neu - virtual void SAL_CALL insertDocumentFromURL(const rtl::OUString& rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aOptions) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ); - - //XSortable - neu - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL createSortDescriptor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL sort(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xDescriptor) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XMultiPropertyStates - //virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - virtual const SwPaM* GetPaM() const; - virtual SwPaM* GetPaM(); - virtual const SwDoc* GetDoc() const; - virtual SwDoc* GetDoc(); - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - const SwUnoCrsr* GetCrsr()const{return (SwUnoCrsr*)GetRegisteredIn();} - - static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAttrMode ); - // --> OD 2006-07-12 #i63870# - // split third parameter into new parameters - // and to get better control about resulting -// static void GetCrsrAttr(SwPaM& rPam, SfxItemSet& rSet, BOOL bCurrentAttrOnly = FALSE); - static void GetCrsrAttr( SwPaM& rPam, - SfxItemSet& rSet, - BOOL bOnlyTxtAttr = FALSE, - BOOL bGetFromChrFmt = TRUE ); - // <-- - static void getTextFromPam(SwPaM& aCrsr, rtl::OUString& rBuffer); - static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); - - static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); - static void SetString(SwCursor& rCrsr, const rtl::OUString& rString); - - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - createSortDescriptor(sal_Bool bFromTable); - static sal_Bool convertSortProperties( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor, - SwSortOptions& rSortOpt); - - // --> FME 2006-03-07 #126177# - void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } - // <-- - - bool IsAtEndOfMeta() const; -}; /*-----------------20.03.98 07:47------------------- --------------------------------------------------*/ diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 4f8e08a50a..050c3a1c97 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,10 @@ #include // helper for implementations #include // helper for implementations +#include +#include + + class SwTableBoxFmt; class SwTableLine; class SwTableCursor; diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx new file mode 100644 index 0000000000..ce91bd2952 --- /dev/null +++ b/sw/inc/unotextcursor.hxx @@ -0,0 +1,461 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTCURSOR_HXX +#define SW_UNOTEXTCURSOR_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +class SfxItemSet; +class SfxItemPropertySet; +class SwDoc; +struct SwPosition; +class SwCursor; +class SwUnoCrsr; +class SwFmtColl; +struct SwSortOptions; + + +/* -----------------03.12.98 12:16------------------- + * + * --------------------------------------------------*/ +enum SwGetPropertyStatesCaller +{ + SW_PROPERTY_STATE_CALLER_DEFAULT, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT +}; + +/// attributes should be applied to a table selection +#define CRSR_ATTR_MODE_TABLE 1 +/// attributes should be added, not replaced +#define CRSR_ATTR_MODE_DONTREPLACE 2 + +typedef ::cppu::WeakImplHelper12 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertyStates +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::util::XSortable +, ::com::sun::star::document::XDocumentInsertable +, ::com::sun::star::text::XSentenceCursor +, ::com::sun::star::text::XWordCursor +, ::com::sun::star::text::XParagraphCursor +, ::com::sun::star::text::XRedline +> SwXTextCursor_Base; + +class SwXTextCursor + : public SwXTextCursor_Base + , public SwClient + , public OTextCursorHelper +{ + +private: + + SwEventListenerContainer aLstnrCntnr; + const SfxItemPropertySet* m_pPropSet; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; + SwSortOptions* pLastSortOptions; + + CursorType eType; + + // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl + // user event has been posted. In this case we have to remove the user + // event in ~SwXTextCursor(). + ULONG mnUserEventId; + bool mbRemoveUserEvent; + // <-- + + DECL_STATIC_LINK(SwXTextCursor, RemoveCursor_Impl, + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>*); + +protected: + + virtual ~SwXTextCursor(); + +public: + + SwXTextCursor( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > xParent, + const SwPosition& rPos, + CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); + SwXTextCursor( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > xParent, + SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); + + SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} + const SwUnoCrsr* GetCrsr() const {return (SwUnoCrsr*)GetRegisteredIn();} + + // --> FME 2006-03-07 #126177# + void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } + // <-- + + bool IsAtEndOfMeta() const; + + void DeleteAndInsert(const String& rText, + const bool bForceExpandHints); + + static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, + USHORT nAttrMode); + static void GetCrsrAttr( SwPaM& rPam, SfxItemSet& rSet, + BOOL bOnlyTxtAttr = FALSE, BOOL bGetFromChrFmt = TRUE ); + static void getTextFromPam(SwPaM& aCrsr, ::rtl::OUString& rBuffer); + static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); + + static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); + static void SetString(SwCursor& rCrsr, const ::rtl::OUString& rString); + + static ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > + createSortDescriptor(sal_Bool bFromTable); + static sal_Bool convertSortProperties( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rDescriptor, + SwSortOptions& rSortOpt); + + static void SetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& aValue, + USHORT nAttrMode = 0) + 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); + static ::com::sun::star::uno::Any GetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > GetPropertyStates( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + SwGetPropertyStatesCaller eCaller=SW_PROPERTY_STATE_CALLER_DEFAULT) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::beans::PropertyState GetPropertyState( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + static void SetPropertyToDefault( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Any GetPropertyDefault( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + virtual const SwPaM* GetPaM() const; + virtual SwPaM* GetPaM(); + virtual const SwDoc* GetDoc() const; + virtual SwDoc* GetDoc(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + DECLARE_XINTERFACE() + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertyStates + virtual void SAL_CALL setAllPropertiesToDefault() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertiesToDefault( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyDefaults( + 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); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XSortable + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > SAL_CALL + createSortDescriptor() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL sort( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& xDescriptor) + throw (::com::sun::star::uno::RuntimeException); + + // XDocumentInsertable + virtual void SAL_CALL insertDocumentFromURL( + const ::rtl::OUString& rURL, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rOptions) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XTextCursor + virtual void SAL_CALL collapseToStart() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL collapseToEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCollapsed() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoStart(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoEnd(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xRange, + sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + + // XWordCursor + virtual sal_Bool SAL_CALL isStartOfWord() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfWord() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + + // XSentenceCursor + virtual sal_Bool SAL_CALL isStartOfSentence() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfSentence() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + + // XParagraphCursor + virtual sal_Bool SAL_CALL isStartOfParagraph() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfParagraph() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + + // XRedline + virtual void SAL_CALL makeRedline( + const ::rtl::OUString& rRedlineType, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& RedlineProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTCURSOR_HXX + diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index a48e36d134..57c5d9c57b 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -30,10 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include #include +#include #include #include #include "fesh.hxx" @@ -63,7 +65,6 @@ #include // for GetWordBoundary // for get/setCharacterAttribute(...) #include "unocrsr.hxx" -#include "unoobj.hxx" #include "unoport.hxx" #include "doc.hxx" #include "crsskip.hxx" diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 8e79603719..56df4dac76 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index fbbaa5cbce..ce3b47aaa0 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 34e73a0cf2..f83d0590da 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 31049e6a92..abac571c1e 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index f8dc8e5cce..79a7b4f5fd 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 9afdc7e011..cdc4929e6a 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index b97680ae79..0483785952 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 7fcde70176..f6fe36d371 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 5486a8a97f..3b133dad13 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -118,6 +119,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index a143ef1651..8e85bcef43 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,7 @@ #include // OD 2004-05-24 #i28701# #include +#include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 5b28bfb68d..0dfd59ee41 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index d59d33988b..d0ba4810ce 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 12c89e9c24..0922289eee 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 67704d98ab..e5147d8364 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 0367831ee5..14c2961fa7 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index c377e2cb3d..1064b7b88f 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 188e378741..b3c9d2297f 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #include #include // SvNumberFormatter #include @@ -99,6 +100,7 @@ #include #include #include +#include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index bc9343996f..ea9143ca12 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index ebecc1d1bd..89f2aad1c5 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -33,6 +33,7 @@ #include "XMLRedlineImportHelper.hxx" +#include #include "unoobj.hxx" #include #include "doc.hxx" diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 666a717bc1..4e29d2765c 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -38,18 +38,15 @@ #include #include #include -#ifndef _XMLOFF_TXTIMP_HXX #include -#endif #include -#ifndef _XMLOFF_XMLTEXTSHAPEIMPORTHELPER_HXX_ #include -#endif #include #include #include #include #include +#include #include #include "unocrsr.hxx" #include diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 72fe426da2..f40ce0a5a5 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -51,6 +51,7 @@ #include #include "unocrsr.hxx" #include "unoobj.hxx" +#include "TextCursorHelper.hxx" #include "unoframe.hxx" #include "doc.hxx" #include "unocoll.hxx" diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 4801259cd7..3586caaba7 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -34,10 +34,7 @@ #define _SVSTDARR_STRINGS - -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include -#endif #include #include #include @@ -53,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +66,7 @@ #include + SV_IMPL_REF ( SwDocShell ) using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 3f9e2b0b12..0bc2acd10b 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 4b940c2fc7..be53796ad2 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -79,6 +79,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/ui/utlui/unotools.cxx b/sw/source/ui/utlui/unotools.cxx index 1b23e3560e..a6cf3444a3 100644 --- a/sw/source/ui/utlui/unotools.cxx +++ b/sw/source/ui/utlui/unotools.cxx @@ -59,12 +59,13 @@ #include #include #include -#include +#include #include #include #include + using namespace ::com::sun::star; using ::rtl::OUString; -- cgit v1.2.3 From 0f11ef538ffc40a5b4a2a9ca15af0d8d6ff2e965 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:46 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unotextrange.hxx: move SwXTextRange, SwXTextRanges from unoobj.hxx to new unotextrange.hxx. move SwUnoInternalPaM to unotextrange.hxx. --- sw/inc/unoframe.hxx | 8 +- sw/inc/unoobj.hxx | 184 ----------- sw/inc/unotbl.hxx | 9 +- sw/inc/unotextrange.hxx | 376 +++++++++++++++++++++++ sw/source/core/access/accpara.cxx | 2 +- sw/source/core/crsr/crsrsh.cxx | 2 +- sw/source/core/txtnode/fmtatr2.cxx | 2 +- sw/source/core/txtnode/ndtxt.cxx | 2 +- sw/source/core/unocore/unobkm.cxx | 2 +- sw/source/core/unocore/unodraw.cxx | 1 + sw/source/core/unocore/unofield.cxx | 1 + sw/source/core/unocore/unoflatpara.cxx | 1 + sw/source/core/unocore/unoframe.cxx | 1 + sw/source/core/unocore/unoftn.cxx | 3 +- sw/source/core/unocore/unoidx.cxx | 1 + sw/source/core/unocore/unoobj.cxx | 1 + sw/source/core/unocore/unoobj2.cxx | 1 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoport.cxx | 1 + sw/source/core/unocore/unoredline.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unosect.cxx | 1 + sw/source/core/unocore/unotbl.cxx | 1 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/filter/html/htmlform.cxx | 9 +- sw/source/filter/ww8/ww8par3.cxx | 2 +- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 1 + sw/source/filter/xml/swxml.cxx | 2 +- sw/source/filter/xml/xmlimp.cxx | 1 + sw/source/filter/xml/xmltbli.cxx | 2 +- sw/source/ui/dialog/SwSpellDialogChildWindow.cxx | 6 +- sw/source/ui/uno/unoatxt.cxx | 1 + sw/source/ui/uno/unotxdoc.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + 34 files changed, 423 insertions(+), 207 deletions(-) create mode 100644 sw/inc/unotextrange.hxx diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 338d5963d0..cc87cc1ea7 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -31,7 +31,7 @@ #define _UNOFRAME_HXX #include -#include +#include #include #include #include @@ -43,8 +43,14 @@ #include */ +#include + +#include + + class SwDoc; class SfxItemPropertSet; + /*-----------------12.02.98 11:21------------------- --------------------------------------------------*/ diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index d26420749a..ec90265cec 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -35,46 +35,35 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include -#include #include #include #include -#include -#include #include -#include #include #include #include #include #include -#include #include #include // helper for factories #include // helper for implementations -#include // helper for implementations #include // helper for implementations #include // helper for implementations #include // helper for implementations -#include #include #include #include #include -#include - #include #include @@ -110,19 +99,6 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ); -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -class SwUnoInternalPaM : public SwPaM -{ - SwUnoInternalPaM( const SwUnoInternalPaM& ); -public: - SwUnoInternalPaM(SwDoc& rDoc); - ~SwUnoInternalPaM(); - - SwUnoInternalPaM& operator=(const SwPaM& rPaM); -}; - /*-----------------04.03.98 11:54------------------- Start/EndAction oder Start/EndAllAction --------------------------------------------------*/ @@ -149,8 +125,6 @@ class UnoActionRemoveContext /****************************************************************************** * ******************************************************************************/ -typedef com::sun::star::uno::Reference< com::sun::star::text::XTextRange > * XTextRangeRefPtr; -SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); @@ -371,164 +345,6 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > CreateTextCursor(BOOL bIgnoreTables = sal_False); }; -class SW_DLLPUBLIC SwXTextRange : public cppu::WeakImplHelper8 -< - ::com::sun::star::text::XTextRange, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XContentEnumerationAccess, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::text::XRedline ->, private SwClient -{ - friend class SwXText; - enum RangePosition - { - RANGE_IN_TEXT, // 'normaler' ::com::sun::star::text::TextRange - RANGE_IN_FRAME,// TextPosition wurde mit einem Rahmen angelegt, der kein Uno-Objekt besitzt - RANGE_IN_CELL, // TextPosition wurde mit einer Zelle angelegt, die kein Uno-Objekt besitzt - RANGE_IS_TABLE, // Anker einer Tabelle - RANGE_INVALID // von NewInstance erzeugt - } eRangePosition; - - SwDoc* pDoc; - SwTableBox* pBox; - const SwStartNode* pBoxStartNode; - SwDepend aObjectDepend; //Format der Tabelle oder des Rahmens anmelden - const SfxItemPropertySet* m_pPropSet; - //SwDepend aFrameDepend; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::sw::mark::IMark* pMark; - - void _CreateNewBookmark(SwPaM& rPam); - //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText, const bool bForceExpandHints) - throw( ::com::sun::star::uno::RuntimeException ); -protected: - virtual ~SwXTextRange(); - -public: - SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rxParent, enum RangePosition eRange = RANGE_IN_TEXT); - // only for RANGE_IS_TABLE - SwXTextRange(SwFrmFmt& rTblFmt); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XRedline - virtual void SAL_CALL makeRedline( const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - BOOL GetPositions(SwPaM& rToFill) const; - const SwDoc* GetDoc() const - { return pDoc; } - SwDoc* GetDoc() - { return pDoc; } - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } - - static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, - const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange); - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( - SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark); - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc* pDoc, - const SwPosition& rPos); -}; - -/* -----------------15.05.98 08:29------------------- - * - * --------------------------------------------------*/ -typedef cppu::WeakImplHelper3 -< - ::com::sun::star::container::XIndexAccess, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::lang::XServiceInfo -> -SwXTextRangesBaseClass; -class SwXTextRanges : public SwXTextRangesBaseClass, - public SwClient -{ - XTextRangeArr* pRangeArr; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - XTextRangeArr* GetRangesArray(); - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } -protected: - virtual ~SwXTextRanges(); -public: - SwXTextRanges(); - SwXTextRanges(SwPaM* pCrsr); - - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) - throw(::com::sun::star::uno::RuntimeException); - - - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - const SwUnoCrsr* GetCursor() const { return (const SwUnoCrsr*)GetRegisteredIn(); } -}; /*-----------------12.02.98 08:01------------------- diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 050c3a1c97..f1770f5341 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -41,11 +41,14 @@ #include #include #include -#include // helper for implementations -#include // helper for implementations -#include // helper for implementations + +#include +#include +#include +#include #include + #include diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx new file mode 100644 index 0000000000..a7d13daf48 --- /dev/null +++ b/sw/inc/unotextrange.hxx @@ -0,0 +1,376 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTRANGE_HXX +#define SW_UNOTEXTRANGE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + + +class String; +class SfxItemPropertySet; +class SwDoc; +class SwStartNode; +struct SwPosition; +class SwPaM; +class SwUnoCrsr; +class SwFrmFmt; +class SwTableBox; + +namespace sw { + namespace mark { + class IMark; + } +} + +/* -----------------29.04.98 07:35------------------- + * + * --------------------------------------------------*/ +class SwUnoInternalPaM + : public SwPaM +{ + +private: + SwUnoInternalPaM(const SwUnoInternalPaM&); + SwUnoInternalPaM& operator=(const SwPaM& rPaM); + +public: + SwUnoInternalPaM(SwDoc& rDoc); + virtual ~SwUnoInternalPaM(); + +}; + + +typedef ::cppu::WeakImplHelper8 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::text::XTextRange +, ::com::sun::star::text::XRedline +> SwXTextRange_Base; + +class SW_DLLPUBLIC SwXTextRange + : public SwXTextRange_Base + , private SwClient +{ + +private: + + friend class SwXText; + + enum RangePosition + { + RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange + RANGE_IN_FRAME, // position created with a frame that has no uno object + RANGE_IN_CELL, // position created with a cell that has no uno object + RANGE_IS_TABLE, // anchor of a table + RANGE_INVALID // created by NewInstance + } eRangePosition; + + SwDoc* pDoc; + SwTableBox* pBox; + const SwStartNode* pBoxStartNode; + SwDepend aObjectDepend; // register at format of table or frame + const SfxItemPropertySet* m_pPropSet; + //SwDepend aFrameDepend; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + xParentText; + ::sw::mark::IMark* pMark; + + void _CreateNewBookmark(SwPaM& rPam); + //TODO: new exception type for protected content + void DeleteAndInsert(const String& rText, const bool bForceExpandHints) + throw (::com::sun::star::uno::RuntimeException); + +protected: + + virtual ~SwXTextRange(); + +public: + + SwXTextRange(SwPaM& rPam, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > & xParent, + enum RangePosition eRange = RANGE_IN_TEXT); + // only for RANGE_IS_TABLE + SwXTextRange(SwFrmFmt& rTblFmt); + + BOOL GetPositions(SwPaM& rToFill) const; + const SwDoc* GetDoc() const + { return pDoc; } + SwDoc* GetDoc() + { return pDoc; } + const ::sw::mark::IMark * GetBookmark() const + { return pMark; } + + static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( + SwDoc* pDoc, + const SwPosition& rPos, const SwPosition* pMark); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateParentXText(SwDoc* pDoc, const SwPosition& rPos); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XRedline + virtual void SAL_CALL makeRedline( + const ::rtl::OUString& rRedlineType, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& RedlineProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +/* -----------------15.05.98 08:29------------------- + * + * --------------------------------------------------*/ +typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > * + XTextRangeRefPtr; +SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) + +typedef ::cppu::WeakImplHelper3 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XIndexAccess +> SwXTextRanges_Base; + +class SwXTextRanges + : public SwXTextRanges_Base + , public SwClient +{ + +private: + + XTextRangeArr* pRangeArr; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + xParentText; + XTextRangeArr* GetRangesArray(); + SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } + +protected: + + virtual ~SwXTextRanges(); + +public: + + SwXTextRanges(); + SwXTextRanges(SwPaM* pCrsr); + + const SwUnoCrsr* GetCursor() const { + return (const SwUnoCrsr*)(GetRegisteredIn()); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTRANGE_HXX + diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 57c5d9c57b..c9de2c74df 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 5c6fc9a21c..674b95634d 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -66,7 +66,7 @@ #include // ...Percent() #include #include // SMARTTAGS -#include // SMARTTAGS +#include // SMARTTAGS #include #include #include diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 3d0a043920..d1b2f35382 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -57,7 +57,7 @@ #include // for meta #include // for meta #include -#include // SwXTextRange +#include #include #include // GetNumberFormat diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 92aedfd2f9..4ed6861b54 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4973,7 +4973,7 @@ bool SwTxtNode::IsInContent() const } #include -#include +#include ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > SwTxtNode::MakeUnoObject() diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index ce3b47aaa0..bf52d0c0db 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,12 +31,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index abac571c1e..608e175722 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 79a7b4f5fd..cde0e276dd 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 68015384da..de481a867a 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index cdc4929e6a..da2fe60bdb 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 0483785952..689a73bafd 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -31,11 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include #include +#include #include #include #include @@ -48,6 +48,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index f6fe36d371..085848fcfb 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 3b133dad13..55586df381 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 8e85bcef43..26898f6c50 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 0dfd59ee41..bf1c52eb09 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index d0ba4810ce..b34a4579f0 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index e5147d8364..ceeb6ac051 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 14c2961fa7..48e6159d19 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 1064b7b88f..ce78e9f4f8 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index b3c9d2297f..2e119b7339 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include // SvNumberFormatter diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index ea9143ca12..fe0ff7b42b 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index 7a0449db96..0691f94fcf 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -34,22 +34,16 @@ #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include #include #include -#ifndef _SFXAPP_HXX #include -#endif #include #include #include @@ -84,13 +78,14 @@ #include #include #include -#include +#include #include "dcontact.hxx" #include "swcss1.hxx" #include "swhtml.hxx" #include "htmlform.hxx" + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 4e1ec2fcfd..aed92130ee 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -77,7 +77,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 89f2aad1c5..bd535912f6 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -35,6 +35,7 @@ #include "XMLRedlineImportHelper.hxx" #include #include "unoobj.hxx" +#include #include #include "doc.hxx" #include diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index db83d59eaf..8d964ac1d8 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -72,7 +72,7 @@ #include #include #include -#include +#include #include #include diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 4e29d2765c..39f1c022e7 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include "unocrsr.hxx" #include #include diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 20eb2e53ed..a50779bf1b 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -32,7 +32,6 @@ #include "precompiled_sw.hxx" - #include "hintids.hxx" #include @@ -58,6 +57,7 @@ #include "swtblfmt.hxx" #include "pam.hxx" #include "unotbl.hxx" +#include "unotextrange.hxx" #include "unocrsr.hxx" #include "cellatr.hxx" #include "swddetbl.hxx" diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index 8969beb163..f0e72323d2 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -50,21 +51,20 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include #include #include #include -#include +#include #ifndef _DIALOG_HXX #include #endif #include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 3586caaba7..d9e3a2fd3a 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 0bc2acd10b..8b04ca4038 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index be53796ad2..19f1aa0dea 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 6b2544de9e78c37bea8cc7c302e1447b326bcc78 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:47 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unotext.hxx etc.: move SwXText from unoobj.hxx to new unotext.hxx. move SwXBodyText, SwXHeadFootText from unoobj.hxx to new unotextbodyhf.hxx. move SwXFootnote from unoobj.hxx to new unofootnote.hxx. --- sw/inc/unofootnote.hxx | 246 ++++++++++++++++++++ sw/inc/unoframe.hxx | 18 +- sw/inc/unoobj.hxx | 326 --------------------------- sw/inc/unoredline.hxx | 4 +- sw/inc/unotbl.hxx | 13 +- sw/inc/unotext.hxx | 375 +++++++++++++++++++++++++++++++ sw/inc/unotextbodyhf.hxx | 218 ++++++++++++++++++ sw/source/core/doc/doclay.cxx | 3 +- sw/source/core/layout/atrfrm.cxx | 1 + sw/source/core/unocore/unoclbck.cxx | 2 +- sw/source/core/unocore/unocoll.cxx | 2 + sw/source/core/unocore/unocrsrhelper.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 2 + sw/source/core/unocore/unoftn.cxx | 14 +- sw/source/core/unocore/unoobj2.cxx | 2 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoredlines.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unostyle.cxx | 9 +- sw/source/core/unocore/unotext.cxx | 29 +-- sw/source/filter/xml/xmlexp.cxx | 4 +- sw/source/filter/xml/xmlfonte.cxx | 5 +- sw/source/filter/xml/xmlimp.cxx | 1 + sw/source/filter/xml/xmltexte.cxx | 5 +- sw/source/ui/uno/unoatxt.cxx | 1 + sw/source/ui/uno/unotxdoc.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + 27 files changed, 914 insertions(+), 372 deletions(-) create mode 100644 sw/inc/unofootnote.hxx create mode 100644 sw/inc/unotext.hxx create mode 100644 sw/inc/unotextbodyhf.hxx diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx new file mode 100644 index 0000000000..d1c869404d --- /dev/null +++ b/sw/inc/unofootnote.hxx @@ -0,0 +1,246 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOFOOTNOTE_HXX +#define SW_UNOFOOTNOTE_HXX + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + + +class SwDoc; +class SwFmtFtn; + + +/*-----------------12.02.98 08:01------------------- + +--------------------------------------------------*/ +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::text::XFootnote +> SwXFootnote_Base; + +class SwXFootnote + : public SwXFootnote_Base + , public SwXText + , public SwClient +{ + +private: + + friend class SwXFootnotes; + + SwEventListenerContainer aLstnrCntnr; + const SwFmtFtn* pFmtFtn; + BOOL m_bIsDescriptor; + String m_sLabel; + BOOL m_bIsEndnote; + +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 ~SwXFootnote(); + +public: + + SwXFootnote(BOOL bEndnote); + SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); + + 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); + + const SwFmtFtn* FindFmt() const { return GetDoc() ? pFmtFtn : 0; } + void Invalidate(); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XFootnote + virtual ::rtl::OUString SAL_CALL getLabel() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLabel(const ::rtl::OUString& rLabel) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOFOOTNOTE_HXX + diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index cc87cc1ea7..e48f029b00 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -30,26 +30,34 @@ #ifndef _UNOFRAME_HXX #define _UNOFRAME_HXX -#include #include #include +#include #include #include #include #include #include #include - /* -#include - */ +#include #include +#include #include +#include +#include +#include +#include + -class SwDoc; class SfxItemPropertSet; +class SdrObject; +class SwDoc; +class SwFmt; +class SwFlyFrmFmt; + /*-----------------12.02.98 11:21------------------- diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index ec90265cec..227a7c9859 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -36,28 +36,14 @@ #include #include #include -#include #include #include #include -#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include // helper for factories -#include // helper for implementations -#include // helper for implementations -#include // helper for implementations -#include // helper for implementations #include #include #include @@ -68,7 +54,6 @@ #include -class SwFmtFtn; class GetCurTxtFmtColl; @@ -128,124 +113,6 @@ class UnoActionRemoveContext void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); -/* -----------------03.12.98 12:22------------------- - * - * --------------------------------------------------*/ -class OTextCursorHelper; -class SwXTextRange; -class SwXText : public ::com::sun::star::lang::XTypeProvider, - public ::com::sun::star::text::XTextRangeCompare, - public ::com::sun::star::text::XRelativeTextContentInsert, - public ::com::sun::star::text::XRelativeTextContentRemove, - public ::com::sun::star::beans::XPropertySet, - public ::com::sun::star::lang::XUnoTunnel, - public ::com::sun::star::text::XTextAppendAndConvert -{ - 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 > & CharacterAndParagraphProperties ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - virtual void PrepareForAttach( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam); - -public: /*not protected because C++ is retarded*/ - virtual const SwStartNode *GetStartNode() const; - -public: - SwXText(SwDoc* pDc, CursorType eType); - virtual ~SwXText(); - - const SwDoc* GetDoc()const {return pDoc;} - SwDoc* GetDoc() {return pDoc;} - - // wenn ein SwXText attached wird, wird das Doc gesetzt - void SetDoc(SwDoc* pDc) - {DBG_ASSERT(!pDoc || !pDc, "Doc schon gesetzt?"); - pDoc = pDc; - bObjectValid = 0 != pDc; - } - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual void SAL_CALL insertString(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const rtl::OUString& aString, BOOL bAbsorb) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL insertControlCharacter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, sal_Int16 nControlCharacter, BOOL bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL insertTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent, BOOL bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextRangeCompare - sal_Int16 SAL_CALL compareRegionStarts( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR2 ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - sal_Int16 SAL_CALL compareRegionEnds( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR2 ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XRelativeTextContentInsert - virtual void SAL_CALL insertTextContentBefore(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xNewContent, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xSuccessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insertTextContentAfter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xNewContent, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xPredecessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XRelativeTextContentRemove - virtual void SAL_CALL removeTextContentBefore(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xSuccessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeTextContentAfter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xPredecessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XUnoTunnel - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XParagraphAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendParagraph( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL finishParagraph( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextPortionAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendTextPortion( const ::rtl::OUString& Text, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextContentAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& TextContent, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextConvert - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > SAL_CALL convertToTextFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& Start, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& End, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& FrameProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextTable > SAL_CALL convertToTable( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > > >& TableRanges, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > >& CellProperties, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& RowProperties, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& TableProperties - ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - - // - virtual ::com::sun::star::uno::Reference< ::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 SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - // - void Invalidate() {bObjectValid = sal_False;} - BOOL IsValid()const {return bObjectValid;} - - CursorType GetTextType() {return eCrsrType;} -}; /*-----------------20.03.98 07:47------------------- @@ -301,147 +168,6 @@ public: --------------------------------------------------*/ -typedef cppu::WeakAggImplHelper2 -< - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::lang::XServiceInfo -> SwXBodyTextBaseClass; -class SwXBodyText : public SwXBodyTextBaseClass, - public SwXText -{ -protected: - virtual ~SwXBodyText(); -public: - SwXBodyText(SwDoc* 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(){OWeakObject::acquire();} - virtual void SAL_CALL release( ) throw(){OWeakObject::release();} - - //XAggregation - virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > CreateTextCursor(BOOL bIgnoreTables = sal_False); -}; - - -/*-----------------12.02.98 08:01------------------- - ---------------------------------------------------*/ -typedef -cppu::WeakImplHelper5 -< - ::com::sun::star::text::XFootnote, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XUnoTunnel -> -SwXFootnoteBaseClass; -class SwXFootnote : public SwXFootnoteBaseClass, - public SwXText, - public SwClient -{ - friend class SwXFootnotes; - - SwEventListenerContainer aLstnrCntnr; - const SwFmtFtn* pFmtFtn; - BOOL m_bIsDescriptor; - String m_sLabel; - BOOL m_bIsEndnote; - -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 ~SwXFootnote(); -public: - SwXFootnote(BOOL bEndnote); - SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); - - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - 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(){SwXFootnoteBaseClass::acquire();} - virtual void SAL_CALL release( ) throw(){SwXFootnoteBaseClass::release();} - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XFootnote - virtual rtl::OUString SAL_CALL getLabel(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setLabel(const rtl::OUString& aLabel) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - 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 ); - - const SwFmtFtn* FindFmt() const {return GetDoc() ? pFmtFtn : 0;} - void Invalidate(); -}; - /* -----------------23.03.99 12:57------------------- * * --------------------------------------------------*/ @@ -521,58 +247,6 @@ public: void SetSortOptions(const SwSortOptions& rSortOpt); }; */ -/* -----------------25.08.98 11:02------------------- - * - * --------------------------------------------------*/ -typedef -cppu::WeakImplHelper2 -< - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XEnumerationAccess -> -SwXHeadFootTextBaseClass; -class SwXHeadFootText : public SwXHeadFootTextBaseClass, - public SwXText, - public SwClient -{ - SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } - BOOL bIsHeader; -protected: - virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); -public: - SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); - ~SwXHeadFootText(); - - TYPEINFO(); - - 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(){SwXHeadFootTextBaseClass::acquire();} - virtual void SAL_CALL release( ) throw(){SwXHeadFootTextBaseClass::release();} - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; #endif diff --git a/sw/inc/unoredline.hxx b/sw/inc/unoredline.hxx index 508bbb2a7a..a2449c6f0a 100644 --- a/sw/inc/unoredline.hxx +++ b/sw/inc/unoredline.hxx @@ -31,9 +31,11 @@ #define _UNOREDLINE_HXX #include -#include +#include + class SwRedline; + /* -----------------------------19.12.00 11:35-------------------------------- ---------------------------------------------------------------------------*/ diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index f1770f5341..53fa8fb8c5 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -30,8 +30,8 @@ #ifndef _UNOTBL_HXX #define _UNOTBL_HXX -#include #include +#include #include #include #include @@ -43,22 +43,27 @@ #include #include +#include #include #include #include #include +#include #include +#include +#include -class SwTableBoxFmt; +class SwUnoCrsr; +class SwTable; +class SwTableBox; class SwTableLine; class SwTableCursor; class SwTableBoxFmt; -class SwTableLine; -class SwTableCursor; class SwChartDataProvider; +class SwFrmFmt; /* -----------------------------22.09.00 11:10-------------------------------- diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx new file mode 100644 index 0000000000..499e0620da --- /dev/null +++ b/sw/inc/unotext.hxx @@ -0,0 +1,375 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXT_HXX +#define SW_UNOTEXT_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + + +namespace com { namespace sun { namespace star { + namespace text { + class XTextContent; + } +} } } + +class SfxItemPropertySet; +class SwDoc; +class SwStartNode; +class SwPaM; +class OTextCursorHelper; +class SwXTextRange; + + +/* -----------------03.12.98 12:22------------------- + * + * --------------------------------------------------*/ + +class SwXText + : public ::com::sun::star::lang::XTypeProvider + , public ::com::sun::star::lang::XUnoTunnel + , public ::com::sun::star::beans::XPropertySet + , public ::com::sun::star::text::XTextAppendAndConvert + , public ::com::sun::star::text::XTextRangeCompare + , public ::com::sun::star::text::XRelativeTextContentInsert + , public ::com::sun::star::text::XRelativeTextContentRemove +{ + +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); + + virtual void PrepareForAttach( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + SwXTextRange const * const pRange, SwPaM const * const pPam); + +protected: + + virtual ~SwXText(); + +public: /*not protected because C++ is retarded*/ + virtual const SwStartNode *GetStartNode() const; + +public: + + SwXText(SwDoc* pDc, 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; } + + virtual ::com::sun::star::uno::Reference< + ::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 SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual void SAL_CALL insertString( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::rtl::OUString& aString, sal_Bool bAbsorb) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertControlCharacter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XText + virtual void SAL_CALL insertTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent, + sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // XParagraphAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendParagraph( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + finishParagraph( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextPortionAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendTextPortion( + const ::rtl::OUString& rText, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextContentAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent >& xTextContent, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextConvert + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > SAL_CALL + convertToTextFrame( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xStart, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xEnd, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& xFrameProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextTable > SAL_CALL + convertToTable( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > > > > const& + rTableRanges, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > > > const& + rCellProperties, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > > const& + rRowProperties, + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > const& + rTableProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextRangeCompare + sal_Int16 SAL_CALL compareRegionStarts( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + sal_Int16 SAL_CALL compareRegionEnds( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XRelativeTextContentInsert + virtual void SAL_CALL insertTextContentBefore( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xNewContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xSuccessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertTextContentAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xNewContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xPredecessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XRelativeTextContentRemove + virtual void SAL_CALL removeTextContentBefore( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xSuccessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContentAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xPredecessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXT_HXX + diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx new file mode 100644 index 0000000000..8e7a64c186 --- /dev/null +++ b/sw/inc/unotextbodyhf.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTBODYHF_HXX +#define SW_UNOTEXTBODYHF_HXX + +#include +#include +#include + +#include + +#include +#include +#include + + +class SwDoc; +class SwFrmFmt; + + +typedef ::cppu::WeakAggImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +> SwXBodyText_Base; + +class SwXBodyText + : public SwXBodyText_Base + , public SwXText +{ + +protected: + + virtual ~SwXBodyText(); + +public: + + SwXBodyText(SwDoc* pDoc); + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > + CreateTextCursor(sal_Bool bIgnoreTables = sal_False); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XAggregation + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + + +/* -----------------25.08.98 11:02------------------- + * + * --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +> SwXHeadFootText_Base; + +class SwXHeadFootText + : public SwXHeadFootText_Base + , public SwXText + , public SwClient +{ + +private: + + SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } + BOOL bIsHeader; + +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 ~SwXHeadFootText(); + +public: + + SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTBODYHF_HXX + diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index a77487654b..7f52ac0115 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1880,7 +1880,8 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) BOOL bIsOnlineSpell = pSh->GetViewOptions()->IsOnlineSpell(); sal_Bool bIsAutoGrammar = sal_False; - SvtLinguConfig().GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; + SvtLinguConfig().GetProperty( ::rtl::OUString::createFromAscii( + UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; if (bIsOnlineSpell && bIsAutoGrammar) StartGrammarChecking( *this ); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 011e62014e..37c75c2f71 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -99,6 +99,7 @@ #include #include #include +#include #include /// OD 22.08.2002 #99657# /// include definition of class SvxBrushItem and GraphicObject diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 66c0a9a2ed..27510e63b3 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 840e66810e..cc9b47bbb7 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -66,7 +66,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index f83d0590da..b55017b76e 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 608e175722..d7163f7f00 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 689a73bafd..f6fc715203 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -147,7 +148,7 @@ SwXFootnote::~SwXFootnote() ---------------------------------------------------------------------------*/ uno::Sequence< uno::Type > SAL_CALL SwXFootnote::getTypes( ) throw(uno::RuntimeException) { - uno::Sequence< uno::Type > aFtnTypes = SwXFootnoteBaseClass::getTypes(); + uno::Sequence< uno::Type > aFtnTypes = SwXFootnote_Base::getTypes(); uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); long nIndex = aFtnTypes.getLength(); @@ -179,12 +180,13 @@ uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(un /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXFootnote::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException) +uno::Any SAL_CALL SwXFootnote::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXFootnoteBaseClass::queryInterface(aType); - if(aRet.getValueType() == ::getCppuVoidType() ) - aRet = SwXText::queryInterface(aType); - return aRet; + const uno::Any ret = SwXFootnote_Base::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXText::queryInterface(rType) + : ret; } /*-- 10.12.98 15:31:47--------------------------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 26898f6c50..44e2f82b44 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index bf1c52eb09..b85c457cd3 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index e70935b55b..44f554d581 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include "poolfmt.hxx" diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 48e6159d19..2c2b076d03 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -440,6 +440,7 @@ void SwXReferenceMark::removeVetoableChangeListener( #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 6033541f9d..24251fe230 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -62,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -74,16 +74,9 @@ #include #include #include -/* -#include -*/ #include -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include -#endif -#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPPP_ #include -#endif #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index fe0ff7b42b..8407089198 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include #include #include @@ -2272,7 +2274,7 @@ uno::Any SwXBodyText::queryAggregation( -----------------------------------------------------------------------*/ uno::Sequence< uno::Type > SwXBodyText::getTypes( ) throw(uno::RuntimeException) { - uno::Sequence< uno::Type > aTypes = SwXBodyTextBaseClass::getTypes(); + uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); long nIndex = aTypes.getLength(); aTypes.realloc(aTypes.getLength() + aTextTypes.getLength()); @@ -2301,13 +2303,13 @@ uno::Sequence< sal_Int8 > SwXBodyText::getImplementationId( ) throw(uno::Runtim -----------------------------------------------------------------------*/ uno::Any SAL_CALL - SwXBodyText::queryInterface( const uno::Type& rType ) - throw(uno::RuntimeException) +SwXBodyText::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXText::queryInterface( rType ); - if(aRet.getValueType() == ::getCppuVoidType()) - aRet = SwXBodyTextBaseClass::queryInterface( rType ); - return aRet; + const uno::Any ret = SwXText::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXBodyText_Base::queryInterface(rType) + : ret; } /* -----------------------------05.01.00 11:07-------------------------------- @@ -2504,7 +2506,7 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createCursor() throw(uno: ---------------------------------------------------------------------------*/ uno::Sequence< uno::Type > SwXHeadFootText::getTypes( ) throw(uno::RuntimeException) { - uno::Sequence< uno::Type > aHFTypes = SwXHeadFootTextBaseClass::getTypes(); + uno::Sequence< uno::Type > aHFTypes = SwXHeadFootText_Base::getTypes(); uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); long nIndex = aHFTypes.getLength(); @@ -2538,12 +2540,13 @@ uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::Ru /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SwXHeadFootText::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException) +uno::Any SwXHeadFootText::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXHeadFootTextBaseClass::queryInterface(aType); - if(aRet.getValueType() == ::getCppuVoidType() ) - aRet = SwXText::queryInterface(aType); - return aRet; + const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXText::queryInterface(rType) + : ret; } /*-- 11.12.98 10:14:50--------------------------------------------------- diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 25544a79c5..577d36e480 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -59,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +75,7 @@ #include // <-- + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::frame; diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx index 8ee621903f..b43419a399 100644 --- a/sw/source/filter/xml/xmlfonte.cxx +++ b/sw/source/filter/xml/xmlfonte.cxx @@ -31,15 +31,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include "hintids.hxx" #include #include #include -#include +//#include +#include #include #include + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::text; diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 39f1c022e7..49db3512b6 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include "unocrsr.hxx" #include diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index 254cae1f7f..40775b9f70 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -44,13 +43,12 @@ #include #include #include -#ifndef _XMLOFF_TXTPRMAP_HXX #include -#endif #include #include #include +#include #include #include #include @@ -65,6 +63,7 @@ #include #include + using ::rtl::OUString; using ::rtl::OUStringBuffer; using namespace ::com::sun::star; diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index d9e3a2fd3a..062246c88f 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 8b04ca4038..cc994acb9c 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 19f1aa0dea..be1b453633 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From 58e65878cc6edd5f05e6200ae81c19ebd9162b1e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:47 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unoparaframeenum.hxx: move SwXParaFrameEnumeration from unoobj.hxx to new unoparaframeenum.hxx. move FrameDependSortList_t, CollectFrameAtNode to unoparaframeenum.hxx. --- sw/inc/unoobj.hxx | 68 ---------------- sw/inc/unoparaframeenum.hxx | 138 ++++++++++++++++++++++++++++++++ sw/source/core/unocore/unoobj2.cxx | 2 +- sw/source/core/unocore/unoparagraph.cxx | 2 +- sw/source/core/unocore/unoport.cxx | 1 + sw/source/core/unocore/unoportenum.cxx | 1 + 6 files changed, 142 insertions(+), 70 deletions(-) create mode 100644 sw/inc/unoparaframeenum.hxx diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 227a7c9859..8806bf13eb 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -50,27 +50,10 @@ #include -#include -#include - class GetCurTxtFmtColl; -struct FrameDependSortListEntry { - xub_StrLen nIndex; - sal_uInt32 nOrder; - ::boost::shared_ptr pFrameDepend; - FrameDependSortListEntry (xub_StrLen const i_nIndex, - sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) - : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } -}; -typedef ::std::deque< FrameDependSortListEntry > - FrameDependSortList_t; - -typedef ::std::deque< ::boost::shared_ptr > - FrameDependList_t; - /* -----------------26.06.98 16:18------------------- * @@ -79,10 +62,6 @@ typedef ::std::deque< ::boost::shared_ptr > SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); ::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); -// OD 2004-05-07 #i28701# - adjust 4th parameter -void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - FrameDependSortList_t & rFrames, - const bool _bAtCharAnchoredObjs ); /*-----------------04.03.98 11:54------------------- Start/EndAction oder Start/EndAllAction @@ -168,53 +147,6 @@ public: --------------------------------------------------*/ -/* -----------------23.03.99 12:57------------------- - * - * --------------------------------------------------*/ -#define PARAFRAME_PORTION_PARAGRAPH 0 -#define PARAFRAME_PORTION_CHAR 1 -#define PARAFRAME_PORTION_TEXTRANGE 2 - -class SwXParaFrameEnumeration : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo ->, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - m_xNextObject; // created by hasMoreElements - FrameDependList_t m_Frames; - - SwUnoCrsr* GetCursor() const - {return static_cast(const_cast(GetRegisteredIn()));} - -public: - SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); - ~SwXParaFrameEnumeration(); - - // XEnumeration - virtual sal_Bool SAL_CALL hasMoreElements() - throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement() - throw( ::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException ); - - // XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName() - throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) - throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames() - throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; - /* -----------------29.09.98 09:01------------------- * diff --git a/sw/inc/unoparaframeenum.hxx b/sw/inc/unoparaframeenum.hxx new file mode 100644 index 0000000000..d05fccfed4 --- /dev/null +++ b/sw/inc/unoparaframeenum.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOPARAFRAMEENUM_HXX +#define SW_UNOPARAFRAMEENUM_HXX + +#include + +#include + +#include +#include +#include + +#include + +#include +#include + + +class SwNodeIndex; +class SwPaM; +class SwUnoCrsr; +class SwFrmFmt; + + +struct FrameDependSortListEntry +{ + xub_StrLen nIndex; + sal_uInt32 nOrder; + ::boost::shared_ptr pFrameDepend; + + FrameDependSortListEntry (xub_StrLen const i_nIndex, + sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) + : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } +}; + +typedef ::std::deque< FrameDependSortListEntry > + FrameDependSortList_t; + +typedef ::std::deque< ::boost::shared_ptr > + FrameDependList_t; + + +// OD 2004-05-07 #i28701# - adjust 4th parameter +void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, + FrameDependSortList_t & rFrames, + const bool _bAtCharAnchoredObjs ); + + +/* -----------------23.03.99 12:57------------------- + * + * --------------------------------------------------*/ + +#define PARAFRAME_PORTION_PARAGRAPH 0 +#define PARAFRAME_PORTION_CHAR 1 +#define PARAFRAME_PORTION_TEXTRANGE 2 + + +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumeration +> SwXParaFrameEnumeration_Base; + +class SwXParaFrameEnumeration + : public SwXParaFrameEnumeration_Base + , public SwClient +{ + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xNextObject; // created by hasMoreElements + FrameDependList_t m_Frames; + + SwUnoCrsr* GetCursor() const + {return static_cast(const_cast(GetRegisteredIn()));} + + virtual ~SwXParaFrameEnumeration(); + +public: + + SwXParaFrameEnumeration(const SwPaM& rPaM, + sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOPARAFRAMEENUM_HXX + diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 44e2f82b44..92a9fff1f0 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -78,6 +77,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index b85c457cd3..57f9679a24 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -31,10 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index b34a4579f0..54db4b2e7b 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 0922289eee..094671f97b 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From f5b430ddfdc01f33e06df017fbf6c21c3538a687 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:49 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: move misc stuff: move GetPageDescByName_Impl from unoobj.hxx to pagedesc.hxx. move UnoActionContext, UnoActionRemoveContext, ClientModify, CreateUnoTunnelId from unoobj.hxx to unobaseclass.hxx. move UnoActionContext, UnoActionRemoveContext from unoobj.cxx to unoobj2.cxx. --- sw/inc/pagedesc.hxx | 3 ++ sw/inc/unobaseclass.hxx | 52 +++++++++++++++++++--- sw/inc/unoobj.hxx | 26 ----------- sw/inc/unoparagraph.hxx | 2 +- sw/inc/unoredlines.hxx | 5 ++- sw/inc/unotbl.hxx | 1 + sw/source/core/unocore/TextCursorHelper.cxx | 4 +- sw/source/core/unocore/unobkm.cxx | 1 - sw/source/core/unocore/unochart.cxx | 3 +- sw/source/core/unocore/unocoll.cxx | 3 +- sw/source/core/unocore/unocrsrhelper.cxx | 1 - sw/source/core/unocore/unodraw.cxx | 4 +- sw/source/core/unocore/unofield.cxx | 1 - sw/source/core/unocore/unoflatpara.cxx | 2 +- sw/source/core/unocore/unoframe.cxx | 3 +- sw/source/core/unocore/unoftn.cxx | 3 +- sw/source/core/unocore/unoidx.cxx | 2 +- sw/source/core/unocore/unoobj.cxx | 45 ------------------- sw/source/core/unocore/unoobj2.cxx | 57 ++++++++++++++++++++++++- sw/source/core/unocore/unoparagraph.cxx | 1 - sw/source/core/unocore/unoport.cxx | 3 +- sw/source/core/unocore/unoportenum.cxx | 3 +- sw/source/core/unocore/unoredline.cxx | 9 ++-- sw/source/core/unocore/unoredlines.cxx | 8 ++-- sw/source/core/unocore/unorefmk.cxx | 3 +- sw/source/core/unocore/unosect.cxx | 4 +- sw/source/core/unocore/unosett.cxx | 5 --- sw/source/core/unocore/unosrch.cxx | 7 +-- sw/source/core/unocore/unostyle.cxx | 1 - sw/source/core/unocore/unotbl.cxx | 1 - sw/source/core/unocore/unotext.cxx | 8 ++-- sw/source/filter/html/htmlforw.cxx | 2 +- sw/source/filter/ww8/ww8atr.cxx | 4 +- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 1 - sw/source/filter/xml/xmlexp.cxx | 1 - sw/source/filter/xml/xmlfmt.cxx | 10 +---- sw/source/filter/xml/xmlfonte.cxx | 1 - sw/source/filter/xml/xmlimp.cxx | 2 +- sw/source/filter/xml/xmlmeta.cxx | 1 - sw/source/filter/xml/xmltble.cxx | 1 - sw/source/filter/xml/xmltexti.cxx | 2 +- sw/source/ui/app/docsh2.cxx | 35 ++------------- sw/source/ui/envelp/labelexp.cxx | 2 +- sw/source/ui/misc/glossary.cxx | 22 +--------- sw/source/ui/shells/drwtxtsh.cxx | 6 +-- sw/source/ui/shells/tabsh.cxx | 6 +-- sw/source/ui/table/chartins.cxx | 7 --- sw/source/ui/uno/SwXDocumentSettings.cxx | 6 +-- sw/source/ui/uno/unoatxt.cxx | 2 +- sw/source/ui/uno/unodispatch.cxx | 7 +-- sw/source/ui/uno/unomod.cxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 2 +- sw/source/ui/uno/unotxvw.cxx | 1 - sw/source/ui/utlui/swrenamexnameddlg.cxx | 1 - 54 files changed, 170 insertions(+), 225 deletions(-) diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index dd80b7f94f..3c734f4d5a 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -344,4 +344,7 @@ public: operator SwPageDesc() const; // #i7983# }; + +SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); + #endif //_PAGEDESC_HXX diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 48c00de279..43418f9585 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -30,18 +30,22 @@ #ifndef _UNOBASECLASS_HXX #define _UNOBASECLASS_HXX -#include #include #include + #include -typedef -cppu::WeakImplHelper2 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo + +class SfxPoolItem; +class SwClient; +class SwDoc; + + +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumeration > -SwSimpleEnumerationBaseClass; +SwSimpleEnumeration_Base; /* -----------------29.04.98 07:35------------------- @@ -64,5 +68,39 @@ enum CursorType CURSOR_META, // meta/meta-field }; +/*-----------------04.03.98 11:54------------------- + Start/EndAction or Start/EndAllAction + -------------------------------------------------- */ +class UnoActionContext +{ + private: + SwDoc * m_pDoc; + + public: + UnoActionContext(SwDoc *const pDoc); + ~UnoActionContext(); + + void InvalidateDocument() { m_pDoc = 0; } +}; + +/* -----------------07.07.98 12:03------------------- + interrupt Actions for a little while + -------------------------------------------------- */ +class UnoActionRemoveContext +{ + private: + SwDoc *const m_pDoc; + + public: + UnoActionRemoveContext(SwDoc *const pDoc); + ~UnoActionRemoveContext(); +}; + + +::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); + +/// helper function for implementing SwClient::Modify +void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); + #endif diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 8806bf13eb..98cf280617 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -59,38 +59,12 @@ class GetCurTxtFmtColl; * * --------------------------------------------------*/ -SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); -::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); -/*-----------------04.03.98 11:54------------------- - Start/EndAction oder Start/EndAllAction ---------------------------------------------------*/ -class UnoActionContext -{ - SwDoc* pDoc; - public: - UnoActionContext(SwDoc* pDoc); - ~UnoActionContext(); - - void InvalidateDocument() {pDoc = 0;} -}; -/* -----------------07.07.98 12:03------------------- - * Actions kurzfristig unterbrechen - * --------------------------------------------------*/ -class UnoActionRemoveContext -{ - SwDoc* pDoc; - public: - UnoActionRemoveContext(SwDoc* pDoc); - ~UnoActionRemoveContext(); -}; - /****************************************************************************** * ******************************************************************************/ -void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); /*-----------------20.03.98 07:47------------------- diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index 6ef62e00c1..984786b0d1 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -359,7 +359,7 @@ public: --------------------------------------------------*/ class SwXParagraphEnumeration - : public SwSimpleEnumerationBaseClass + : public SwSimpleEnumeration_Base , public SwClient { diff --git a/sw/inc/unoredlines.hxx b/sw/inc/unoredlines.hxx index 8f932617f4..f87ac44188 100644 --- a/sw/inc/unoredlines.hxx +++ b/sw/inc/unoredlines.hxx @@ -78,8 +78,9 @@ public: /* -----------------------------12.01.01 14:58-------------------------------- ---------------------------------------------------------------------------*/ -class SwXRedlineEnumeration : public SwSimpleEnumerationBaseClass, - public SwClient +class SwXRedlineEnumeration + : public SwSimpleEnumeration_Base + , public SwClient { SwDoc* pDoc; USHORT nCurrentIndex; diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 53fa8fb8c5..bc66e61c26 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -51,6 +51,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/TextCursorHelper.cxx b/sw/source/core/unocore/TextCursorHelper.cxx index b21587a155..6e8fb9efe4 100644 --- a/sw/source/core/unocore/TextCursorHelper.cxx +++ b/sw/source/core/unocore/TextCursorHelper.cxx @@ -30,8 +30,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include "TextCursorHelper.hxx" -#include "unoobj.hxx" +#include "unobaseclass.hxx" + using namespace ::com::sun::star; /* -----------------------------03.03.03 11:07-------------------------------- diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index bf52d0c0db..a22eb8a2b1 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 2c1cb1ceb5..ef7817ebb5 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -34,7 +34,6 @@ #include #include - #include #include #include @@ -51,7 +50,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index cc9b47bbb7..60b6897e88 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -874,7 +874,8 @@ namespace } template - class SwXFrameEnumeration : public SwSimpleEnumerationBaseClass + class SwXFrameEnumeration + : public SwSimpleEnumeration_Base { private: typedef ::std::slist< Any > frmcontainer_t; diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index b55017b76e..676c1839ad 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index d7163f7f00..67c7249571 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -443,7 +442,8 @@ uno::Reference< drawing::XShape > SwFmDrawPage::_CreateShape( SdrObject *pObj ) ****************************************************************************/ namespace { - class SwXShapesEnumeration : public SwSimpleEnumerationBaseClass + class SwXShapesEnumeration + : public SwSimpleEnumeration_Base { private: typedef ::std::slist< ::com::sun::star::uno::Any > shapescontainer_t; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index cde0e276dd..31f4659c22 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index de481a867a..c5055394cd 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index da2fe60bdb..f4d7ea34be 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -60,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index f6fc715203..7c0f8adbe3 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -34,7 +34,8 @@ #include #include #include -#include + +#include #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 085848fcfb..904e7dfcdb 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -55,8 +55,8 @@ #include #endif #include +#include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 55586df381..8b0f76bfbe 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -82,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -187,50 +186,6 @@ SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM) } return *this; } -/**************************************************************************** - ActionContext -****************************************************************************/ -UnoActionContext::UnoActionContext(SwDoc* pDc) : - pDoc(pDc) -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->StartAllAction(); -} -/*-----------------04.03.98 11:56------------------- - ---------------------------------------------------*/ -UnoActionContext::~UnoActionContext() -{ - //das Doc kann hier schon entfernt worden sein - if(pDoc) - { - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->EndAllAction(); - } -} - -/**************************************************************************** - ActionRemoveContext -****************************************************************************/ -UnoActionRemoveContext::UnoActionRemoveContext(SwDoc* pDc) : - pDoc(pDc) -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->UnoRemoveAllActions(); -} -/* -----------------07.07.98 12:05------------------- - * - * --------------------------------------------------*/ -UnoActionRemoveContext::~UnoActionRemoveContext() -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->UnoRestoreAllActions(); - -} /*-----------------09.03.98 08:29------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 92a9fff1f0..903e97f9bc 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -76,7 +76,6 @@ #include #include #include -#include #include #include #include @@ -100,6 +99,7 @@ #include #include #include +#include #include #include #include @@ -227,6 +227,60 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, } } +/**************************************************************************** + ActionContext +****************************************************************************/ +UnoActionContext::UnoActionContext(SwDoc *const pDoc) + : m_pDoc(pDoc) +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->StartAllAction(); + } +} + +/*-----------------04.03.98 11:56------------------- + +--------------------------------------------------*/ +UnoActionContext::~UnoActionContext() +{ + // Doc may already have been removed here + if (m_pDoc) + { + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->EndAllAction(); + } + } +} + +/**************************************************************************** + ActionRemoveContext +****************************************************************************/ +UnoActionRemoveContext::UnoActionRemoveContext(SwDoc *const pDoc) + : m_pDoc(pDoc) +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->UnoRemoveAllActions(); + } +} + +/* -----------------07.07.98 12:05------------------- + * + * --------------------------------------------------*/ +UnoActionRemoveContext::~UnoActionRemoveContext() +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->UnoRestoreAllActions(); + } +} + /*-- 09.12.98 14:18:58--------------------------------------------------- @@ -752,6 +806,7 @@ SwDoc* SwXTextCursor::GetDoc() return GetCrsr() ? GetCrsr()->GetDoc() : 0; } + /*-- 09.12.98 14:19:03--------------------------------------------------- -----------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 57f9679a24..c83920d101 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 54db4b2e7b..8ddb5a7f20 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -36,9 +36,9 @@ #include #include #include + #include #include -#include #include #include #include @@ -51,6 +51,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 094671f97b..07f27201f6 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index ceeb6ac051..bbd81aa140 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -31,15 +31,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include +#include #include #include + #include #include "poolfmt.hxx" #include #include #include -#include +#include #include #include #include @@ -49,9 +53,6 @@ #include #include #include -#include -#include -#include using namespace ::com::sun::star; diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index 44f554d581..05c70eb723 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -31,19 +31,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include #include #include + #include #include -#include -#include +#include #include #include "poolfmt.hxx" #include #include #include -#include + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 2c2b076d03..42ef834cbf 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -33,7 +33,8 @@ #include #include -#include + +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index ce78e9f4f8..c2b706250c 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include @@ -43,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -64,7 +64,7 @@ #include #include #include -#include +#include #include /* #109700# */ #include diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 4caa5a735e..4f20d516fe 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -61,20 +61,15 @@ #include #include #include -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include -#endif #include -#include #include #include #include #include #include #include -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx index 8ee8e3e141..dfb21c071c 100644 --- a/sw/source/core/unocore/unosrch.cxx +++ b/sw/source/core/unocore/unosrch.cxx @@ -30,13 +30,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include "unosrch.hxx" - +#include "unosrch.hxx" #include #include #include -#include +#include +#include + #include #include #include "svx/unolingu.hxx" diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 24251fe230..1108dcf71f 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 2e119b7339..e594ba50d6 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 8407089198..b758f9104b 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -34,12 +34,13 @@ #include #include +#include -#include #include #include #include -#include + +#include #include #include #include @@ -68,9 +69,10 @@ #include #include #include +#include #include #include -#include + #include #include diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 8d2d305c23..a0a2b7a862 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -63,7 +63,7 @@ #include #include #include -#include + #include #include #include diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 288a415223..d03bfa5eb7 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -128,9 +128,7 @@ #include -#if OSL_DEBUG_LEVEL > 1 -# include -#endif +#include #include "writerhelper.hxx" #include "writerwordglue.hxx" #include "wrtww8.hxx" diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index bd535912f6..3cabf2e49b 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -34,7 +34,6 @@ #include "XMLRedlineImportHelper.hxx" #include -#include "unoobj.hxx" #include #include #include "doc.hxx" diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 577d36e480..e4149fa60f 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index ec50718350..92fa625296 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -57,19 +56,11 @@ #include #include "xmlitem.hxx" #include -#ifndef _XMLOFF_TXTSTYLI_HXX #include -#endif -#ifndef _XMLOFF_TXTIMP_HXX #include -#endif -#ifndef _XMLOFF_FAMILIES_HXX #include -#endif #include -#ifndef _XMLOFF_XMLTEXTSHAPESTYLECONTEXT_HXX #include -#endif #include #include "xmlimp.hxx" #include "xmltbli.hxx" @@ -79,6 +70,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx index b43419a399..f2503ec54e 100644 --- a/sw/source/filter/xml/xmlfonte.cxx +++ b/sw/source/filter/xml/xmlfonte.cxx @@ -35,7 +35,6 @@ #include #include #include -//#include #include #include #include diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 49db3512b6..1039515a8d 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -47,7 +48,6 @@ #include #include #include -#include #include #include #include "unocrsr.hxx" diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx index 3bac5aa2b4..d6ebfb2d25 100644 --- a/sw/source/filter/xml/xmlmeta.cxx +++ b/sw/source/filter/xml/xmlmeta.cxx @@ -45,7 +45,6 @@ #include "docstat.hxx" #include "docsh.hxx" #include -#include #include "xmlimp.hxx" #include "xmlexp.hxx" diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 04f654db61..0b4783e2e4 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -61,7 +61,6 @@ #include #include #include // for cTokenSeperator -#include "unoobj.hxx" #include "unotbl.hxx" #include "xmltexte.hxx" #include "xmlexp.hxx" diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index f40ce0a5a5..3373bfa75d 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -50,13 +50,13 @@ #include #include #include "unocrsr.hxx" -#include "unoobj.hxx" #include "TextCursorHelper.hxx" #include "unoframe.hxx" #include "doc.hxx" #include "unocoll.hxx" #include #include +#include #include "xmlimp.hxx" #include "xmltbli.hxx" #include "xmltexti.hxx" diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 1b0a0c1c0e..050c0bacca 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -30,30 +30,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _COM_SUN_STAR_LANG_XMultiServiceFactory_HPP_ -#include -#endif -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include -#endif +#include #include +#include #include #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include -/* -#include -*/ #include #include #include @@ -90,51 +79,33 @@ #include #include #include -#ifndef _VIEW_HXX #include // fuer die aktuelle Sicht -#endif -#ifndef _DOCSH_HXX #include // Dokumenterzeugung -#endif #include #include #include -#ifndef _GLOBDOC_HXX #include -#endif #include -#ifndef _REDLNDLG_HXX #include -#endif #include #include #include #include -#ifndef _PVIEW_HXX #include -#endif -#ifndef _SRCVIEW_HXX #include -#endif #include #include -#ifndef _WDOCSH_HXX #include -#endif #include #include #include -#include +#include #include #include -#ifndef _CMDID_H #include -#endif #include -#ifndef _HELPID_H #include -#endif #ifndef _APP_HRC #include #endif diff --git a/sw/source/ui/envelp/labelexp.cxx b/sw/source/ui/envelp/labelexp.cxx index 21a9dcf599..0b0f557bbb 100644 --- a/sw/source/ui/envelp/labelexp.cxx +++ b/sw/source/ui/envelp/labelexp.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 89a37a86e7..787a04af90 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -30,25 +30,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #ifdef SW_DLLIMPLEMENTATION #undef SW_DLLIMPLEMENTATION #endif - - #define _SVSTDARR_STRINGSDTOR #define _SVSTDARR_STRINGS #include -#ifndef _MENU_HXX //autogen #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif -#ifndef _HELP_HXX //autogen #include -#endif #ifndef _SVSTDARR_HXX #include #endif @@ -64,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -75,12 +67,8 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif -#ifndef _BASESH_HXX #include -#endif #include #include #include @@ -88,20 +76,12 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include -#ifndef _CMDID_H #include -#endif -#ifndef _HELPID_H #include -#endif -#ifndef _SWERROR_H #include -#endif #ifndef _GLOBALS_HRC #include #endif diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index ad6ab1d2e7..7118acd7e7 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -53,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -67,12 +67,8 @@ #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _HELPID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx index 577ea95c64..014d0d460c 100644 --- a/sw/source/ui/shells/tabsh.cxx +++ b/sw/source/ui/shells/tabsh.cxx @@ -108,16 +108,12 @@ #ifndef _TABLE_HRC #include #endif -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif -#ifndef _HELPID_H #include -#endif -#include +#include #define SwTableShell #include diff --git a/sw/source/ui/table/chartins.cxx b/sw/source/ui/table/chartins.cxx index c8a836cc43..1032536616 100644 --- a/sw/source/ui/table/chartins.cxx +++ b/sw/source/ui/table/chartins.cxx @@ -33,9 +33,7 @@ #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -45,24 +43,19 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif #include #include #include #include #include -#include #include #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _CHARTINS_HRC #include #endif diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index 60474dff99..8389d9d2f9 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -30,16 +30,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include #include -#ifndef _COMPHELPER_MASTERPROPERTSETINFO_HXX_ #include -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include -#endif #include #include #include @@ -50,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 062246c88f..f9b672df97 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/uno/unodispatch.cxx b/sw/source/ui/uno/unodispatch.cxx index 44b82239b1..02e669d3b2 100644 --- a/sw/source/ui/uno/unodispatch.cxx +++ b/sw/source/ui/uno/unodispatch.cxx @@ -31,17 +31,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include + #include -#include +#include #include #include #include "wrtsh.hxx" #include "dbmgr.hxx" -#include + using namespace ::com::sun::star; using namespace rtl; diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index d5315fbd33..18cccf6d7b 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index cc994acb9c..5c2c3a7e52 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index be1b453633..19f1aa0dea 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/ui/utlui/swrenamexnameddlg.cxx b/sw/source/ui/utlui/swrenamexnameddlg.cxx index 288a51b7bc..d338cb6ebb 100644 --- a/sw/source/ui/utlui/swrenamexnameddlg.cxx +++ b/sw/source/ui/utlui/swrenamexnameddlg.cxx @@ -63,7 +63,6 @@ #include #include #include -#include #include #include "swrenamexnameddlg.hxx" -- cgit v1.2.3 From 106e60da5471448468698ef526d1f5b67eb3f234 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:49 +0100 Subject: swunolocking1: #i105557#: remove unoobj.hxx --- sw/inc/unoobj.hxx | 158 ------------------------------------------------------ 1 file changed, 158 deletions(-) delete mode 100644 sw/inc/unoobj.hxx diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx deleted file mode 100644 index 98cf280617..0000000000 --- a/sw/inc/unoobj.hxx +++ /dev/null @@ -1,158 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoobj.hxx,v $ - * - * $Revision: 1.49 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _UNOOBJ_HXX -#define _UNOOBJ_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // helper for factories - -#include -#include -#include - -#include - - -class GetCurTxtFmtColl; - - - -/* -----------------26.06.98 16:18------------------- - * - * --------------------------------------------------*/ - - - -/****************************************************************************** - * - ******************************************************************************/ - - - -/*-----------------20.03.98 07:47------------------- - ---------------------------------------------------*/ -/* das wird zunaechst nicht gebraucht - bisher fuer den XPropertySetCloner -class SwXPropertySet : public ::com::sun::star::beans::XPropertySet, - public UsrObject -{ - ::com::sun::star::uno::Sequence<::com::sun::star::uno::Any>* pAny; - ::com::sun::star::uno::Sequence< Property >* pInfo; - -public: - // Eigentumsuebergang der Pointer! - SwXPropertySet( ::com::sun::star::uno::Sequence<::com::sun::star::uno::Any>* pAny, - ::com::sun::star::uno::Sequence* pInfo ); - virtual ~SwXPropertySet(); - - SMART_UNO_DECLARATION( SwXPropertySet, UsrObject ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - -}; -*/ -/*-----------------20.03.98 08:26------------------- - ---------------------------------------------------*/ -/* das wird zunaechst nicht gebraucht - bisher fuer den XPropertySetCloner - -class SwXPropertySetInfo: public ::com::sun::star::beans::XPropertySetInfo, UsrObject -{ - ::com::sun::star::uno::Sequence< Property >* pSeq; - -public: - SwXPropertySetInfo( const ::com::sun::star::uno::Sequence& rInfo ); - virtual ~SwXPropertySetInfo(); - - SMART_UNO_DECLARATION( SwXPropertySetInfo, UsrObject ); - - virtual ::com::sun::star::uno::Sequence< Property > getProperties(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual Property getPropertyByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL hasPropertyByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); -}; -*/ - -/*-----------------23.02.98 10:45------------------- - ---------------------------------------------------*/ - - -/* -----------------29.09.98 09:01------------------- - * - * --------------------------------------------------*/ -/* os: 04.12.98 11:40 hier gibt es noch keine sinnvolle Definition -#define MAX_SORT_FIELDS 3 // das ist eher willkuerlich (wie im Dialog) -class SwXTextSortDescriptor : public XTextSortDescriptor, - public UsrObject -{ - SwSortOptions aSortOptions; - BOOL bUseHeader; -public: - SwXTextSortDescriptor(BOOL bUsedInTable); - virtual ~SwXTextSortDescriptor(); - - //XTextSortDescriptor - virtual sal_Unicode getTextColumnSeparator(void) const; - virtual void setTextColumnSeparator(sal_Unicode TextColumnSeparator_); - - //XSortDescriptor - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::SortField > getSortFields(void) const; - virtual void setSortFields(const ::com::sun::star::uno::Sequence< ::com::sun::star::util::SortField >& SortFields_); - virtual sal_uInt16 getMaxFieldCount(void) const; - virtual ColumnsOrRows getOrientation(void) const; - virtual void setOrientation(ColumnsOrRows Orientation_); - virtual BOOL getUseHeader(void) const; - virtual void setUseHeader(BOOL UseHeader_); - - const SwSortOptions& GetSortOptions() const {return aSortOptions;} - void SetSortOptions(const SwSortOptions& rSortOpt); -}; -*/ - -#endif - -- cgit v1.2.3 From b52a742c0e16ee38c397033100853b8b0feb4857 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:47 +0100 Subject: swunolocking1: #i105557#: unobaseclass.hxx: add UnoImplPtr: new smart pointer template UnoImplPtr: calls dtor with SolarMutex locked. --- sw/inc/unobaseclass.hxx | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 43418f9585..ddd8002d5c 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -27,8 +27,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _UNOBASECLASS_HXX -#define _UNOBASECLASS_HXX +#ifndef SW_UNOBASECLASS_HXX +#define SW_UNOBASECLASS_HXX #include #include @@ -102,5 +102,42 @@ class UnoActionRemoveContext /// helper function for implementing SwClient::Modify void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); -#endif + +#include +#include +#include +#include + +namespace sw { + + template class UnoImplPtr + : private ::boost::noncopyable + { + private: + T * m_p; + + public: + UnoImplPtr(T *const i_p) + : m_p(i_p) + { + OSL_ENSURE(i_p, "UnoImplPtr: null"); + } + + ~UnoImplPtr() + { + ::vos::OGuard g(Application::GetSolarMutex()); + delete m_p; // #i105557#: call dtor with locked solar mutex + m_p = 0; + } + + T & operator * () const { return *m_p; } + + T * operator ->() const { return m_p; } + + T * get () const { return m_p; } + }; + +} // namespace sw + +#endif // SW_UNOBASECLASS_HXX -- cgit v1.2.3 From 2343c63e83fd92513d09afb242e0eeac72804983 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:48 +0100 Subject: swunolocking1: #i105557#: unobaseclass.hxx: add UnoTunnel helpers: new template UnoTunnelImpl to implement XUnoTunnel::getSomething(). new template UnoTunnelGetImplementation to use XUnoTunnel::getSomething(). --- sw/inc/unobaseclass.hxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index ddd8002d5c..dd6391554f 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -30,6 +30,7 @@ #ifndef SW_UNOBASECLASS_HXX #define SW_UNOBASECLASS_HXX +#include #include #include @@ -137,6 +138,32 @@ namespace sw { T * get () const { return m_p; } }; + template< class C > C * + UnoTunnelGetImplementation( + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel) + { + if (!xUnoTunnel.is()) { return 0; } + C *const pC( reinterpret_cast< C* >( + ::sal::static_int_cast< sal_IntPtr >( + xUnoTunnel->getSomething(C::getUnoTunnelId())))); + return pC; + } + + template< class C > sal_Int64 + UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId, + C *const pThis) + { + if ((rId.getLength() == 16) && + (0 == rtl_compareMemory(C::getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16))) + { + return ::sal::static_int_cast< sal_Int64 >( + reinterpret_cast< sal_IntPtr >(pThis) ); + } + return 0; + } + } // namespace sw #endif // SW_UNOBASECLASS_HXX -- cgit v1.2.3 From 42576a9b4331120c4735a5d68e4779e61433a3bf Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:48 +0100 Subject: swunolocking1: #i105557#: unobaseclass.hxx: add XServiceInfo helpers: new functions GetSupportedServiceNamesImpl and SupportsServiceImpl. --- sw/inc/unobaseclass.hxx | 7 +++++++ sw/source/core/unocore/unoobj2.cxx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index dd6391554f..5c04700776 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -164,6 +164,13 @@ namespace sw { return 0; } + ::com::sun::star::uno::Sequence< ::rtl::OUString > + GetSupportedServiceNamesImpl( + size_t const nServices, char const*const pServices[]); + sal_Bool SupportsServiceImpl( + size_t const nServices, char const*const pServices[], + ::rtl::OUString const & rServiceName); + } // namespace sw #endif // SW_UNOBASECLASS_HXX diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 903e97f9bc..2f94bf2da6 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -146,6 +146,37 @@ using namespace ::com::sun::star::drawing; using ::rtl::OUString; +namespace sw { + +sal_Bool SupportsServiceImpl( + size_t const nServices, char const*const pServices[], + ::rtl::OUString const & rServiceName) +{ + for (size_t i = 0; i < nServices; ++i) + { + if (rServiceName.equalsAscii(pServices[i])) + { + return sal_True; + } + } + return sal_False; +} + +uno::Sequence< ::rtl::OUString > +GetSupportedServiceNamesImpl( + size_t const nServices, char const*const pServices[]) +{ + uno::Sequence< ::rtl::OUString > ret(nServices); + for (size_t i = 0; i < nServices; ++i) + { + ret[i] = C2U(pServices[i]); + } + return ret; +} + +} // namespace sw + + struct FrameDependSortListLess { bool operator() (FrameDependSortListEntry const& r1, -- cgit v1.2.3 From 7aebbae28405cfd42be4d2d681942ed395e4e2af Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:49 +0100 Subject: swunolocking1: refactor Meta registration at its text node. Meta will now be registered via SwTxtMeta::ChgTxtNode(), with additional workarounds necessary in SwFmtMeta::DoCopy(). --- sw/inc/fmtmeta.hxx | 8 +++-- sw/inc/txtatr.hxx | 2 +- .../complex/writer/TextPortionEnumerationTest.java | 2 +- sw/source/core/docnode/nodes.cxx | 11 +++++-- sw/source/core/txtnode/fmtatr2.cxx | 35 ++++++++++++++++++---- sw/source/core/txtnode/thints.cxx | 7 ++++- sw/source/core/txtnode/txtatr2.cxx | 10 +++++++ 7 files changed, 60 insertions(+), 15 deletions(-) diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index 952181d049..6d3f63ece4 100755 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -122,8 +122,8 @@ public: virtual SfxPoolItem * Clone( SfxItemPool *pPool = 0 ) const; // TYPEINFO(); - // notify clients registered at m_pMeta that this meta is being removed - void NotifyRemoval(); + /// notify clients registered at m_pMeta that this meta is being (re-)moved + void NotifyChangeTxtNode(SwTxtNode *const pTxtNode); static SwFmtMeta * CreatePoolDefault( const USHORT i_nWhich ); ::sw::Meta * GetMeta() { return m_pMeta.get(); } /// this method must be called when the hint is actually copied @@ -140,7 +140,7 @@ class Meta , public SwModify { protected: - friend class ::SwFmtMeta; // SetFmtMeta + friend class ::SwFmtMeta; // SetFmtMeta, NotifyChangeTxtNode friend class ::SwXMeta; // GetTxtNode, GetTxtAttr SwFmtMeta * m_pFmt; @@ -151,6 +151,8 @@ protected: SwFmtMeta * GetFmtMeta() const { return m_pFmt; } void SetFmtMeta( SwFmtMeta * const i_pFmt ) { m_pFmt = i_pFmt; }; + void NotifyChangeTxtNode(); + public: explicit Meta(SwFmtMeta * const i_pFmt = 0); virtual ~Meta(); diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 3af8e54bf6..e8163914eb 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -80,7 +80,7 @@ public: const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); virtual ~SwTxtMeta(); - void ChgTxtNode( SwTxtNode * const pNode ) { m_pTxtNode = pNode; } + void ChgTxtNode(SwTxtNode * const pNode); SwTxtNode * GetTxtNode() const { return m_pTxtNode; } }; diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index a07b3cccad..8110c82a6e 100755 --- a/sw/qa/complex/writer/TextPortionEnumerationTest.java +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java @@ -3097,7 +3097,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPortion); String type = (String) xPropSet.getPropertyValue("TextPortionType"); - assure("first: not text", type.equals("Text")); + assure("first: not text: " + type, type.equals("Text")); String txt = xPortion.getString(); assure("first: text differs: " + txt, "45".equals(txt)); } diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index dd5a91b2ba..4656d96a0b 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -350,8 +350,13 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - static_cast(pAttr->GetAttr()) - .NotifyRemoval(); + { + SwTxtMeta *const pTxtMeta( + static_cast(pAttr)); + // force removal of UNO object + pTxtMeta->ChgTxtNode(0); + pTxtMeta->ChgTxtNode(pTxtNd); + } break; default: diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index d1b2f35382..066817d5b0 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -650,19 +650,28 @@ void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) } } -void SwFmtMeta::NotifyRemoval() +void SwFmtMeta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode) { // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx, // where the hint is not deleted! ASSERT(m_pMeta, "NotifyRemoval: no meta ?"); if (m_pMeta) { - SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, - &static_cast(*m_pMeta) ); // cast to proper base class! - m_pMeta->Modify(&aMsgHint, &aMsgHint); + if (!pTxtNode) + { + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast(*m_pMeta) ); // cast to base class! + m_pMeta->Modify(&aMsgHint, &aMsgHint); + } + else + { // do not call Modify, that would call SwXMeta::Modify! + m_pMeta->NotifyChangeTxtNode(); + } } } +// UGLY: this really awful method fixes up an inconsistent state, +// and if it is not called when copying, total chaos will undoubtedly ensue void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) { ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); @@ -673,6 +682,8 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) // inserted via MakeTxtAttr! so fix it up to point at the original item // (maybe would be better to tell MakeTxtAttr that it creates a copy?) pOriginal->SetFmtMeta(&rOriginalMeta); + // force pOriginal to register in original text node! + pOriginal->NotifyChangeTxtNode(); if (RES_TXTATR_META == Which()) { m_pMeta.reset( new ::sw::Meta(this) ); @@ -685,7 +696,10 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); } + // this cannot be done in Clone: a Clone is not necessarily a copy! m_pMeta->RegisterAsCopyOf(*pOriginal); + // force copy Meta to register in target text node! + m_pMeta->NotifyChangeTxtNode(); } } @@ -718,14 +732,23 @@ SwTxtNode * Meta::GetTxtNode() const return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; } -// SwClient -void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +void Meta::NotifyChangeTxtNode() { SwTxtNode * const pTxtNode( GetTxtNode() ); if (pTxtNode && (GetRegisteredIn() != pTxtNode)) { pTxtNode->Add(this); } + else if (!pTxtNode && GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + } +} + +// SwClient +void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + NotifyChangeTxtNode(); SwModify::Modify(pOld, pNew); } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index d0e13ea32c..dfb147fbbe 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -114,6 +114,11 @@ struct TxtAttrDeleter TxtAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { } void operator() (SwTxtAttr * const pAttr) { + if (RES_TXTATR_META == pAttr->Which() || + RES_TXTATR_METAFIELD == pAttr->Which()) + { + static_cast(pAttr)->ChgTxtNode(0); // prevents ASSERT + } SwTxtAttr::Destroy( pAttr, m_rPool ); } }; @@ -1178,7 +1183,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - static_cast(pAttr->GetAttr()).NotifyRemoval(); + static_cast(pAttr)->ChgTxtNode(0); break; default: diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index d9d94b05b2..464af6183a 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -329,3 +329,13 @@ SwTxtMeta::~SwTxtMeta() } } +void SwTxtMeta::ChgTxtNode(SwTxtNode * const pNode) +{ + m_pTxtNode = pNode; // before Notify! + SwFmtMeta & rFmtMeta( static_cast(GetAttr()) ); + if (rFmtMeta.GetTxtAttr() == this) + { + rFmtMeta.NotifyChangeTxtNode(pNode); + } +} + -- cgit v1.2.3 From 1115bc8db0a08bd3bc99e20919f700d30f286664 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:49 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXMeta: move SwClient base to pImpl struct, and use UnoImplPtr to lock destructor. replace broken SwClient iteration with a WeakReference in sw::Meta. make constructor protected, and add factory function CreateXMeta. use new XUnoTunnel and XServiceInfo helpers. --- sw/inc/fmtmeta.hxx | 14 +- sw/source/core/inc/unometa.hxx | 193 +++++++++++++------------ sw/source/core/txtnode/fmtatr2.cxx | 31 +--- sw/source/core/unocore/unoportenum.cxx | 57 +++++--- sw/source/core/unocore/unorefmk.cxx | 251 ++++++++++++++++++++------------- 5 files changed, 311 insertions(+), 235 deletions(-) diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index 6d3f63ece4..792a7d8374 100755 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -31,6 +31,8 @@ #ifndef SW_FMTMETA_HXX #define SW_FMTMETA_HXX +#include + #include #include @@ -141,7 +143,10 @@ class Meta { protected: friend class ::SwFmtMeta; // SetFmtMeta, NotifyChangeTxtNode - friend class ::SwXMeta; // GetTxtNode, GetTxtAttr + friend class ::SwXMeta; // GetTxtNode, GetTxtAttr, Get/SetXMeta + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::rdf::XMetadatable> m_wXMeta; SwFmtMeta * m_pFmt; @@ -153,6 +158,13 @@ protected: void NotifyChangeTxtNode(); + ::com::sun::star::uno::WeakReference< + ::com::sun::star::rdf::XMetadatable> const& GetXMeta() const + { return m_wXMeta; } + void SetXMeta(::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable> const& xMeta) + { m_wXMeta = xMeta; } + public: explicit Meta(SwFmtMeta * const i_pFmt = 0); virtual ~Meta(); diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx index 1dc1985f7d..5568aa88b5 100755 --- a/sw/source/core/inc/unometa.hxx +++ b/sw/source/core/inc/unometa.hxx @@ -31,19 +31,21 @@ #ifndef SW_UNOMETA_HXX #define SW_UNOMETA_HXX -#include "calbck.hxx" - -#include -#include -#include +#include #include #include +#include #include #include #include -#include +#include +#include + +#include + +#include typedef ::std::deque< @@ -52,42 +54,78 @@ typedef ::std::deque< class SwXTextRange; class SwPaM; -class SwTxtMeta; +class SwTxtNode; + namespace sw { class Meta; class MetaField; } -typedef -::cppu::ImplInheritanceHelper5 -< ::sfx2::MetadatableMixin -, ::com::sun::star::lang::XUnoTunnel -, ::com::sun::star::lang::XServiceInfo -, ::com::sun::star::text::XTextContent -, ::com::sun::star::text::XText -, ::com::sun::star::container::XEnumerationAccess -> SwXMetaBaseClass; +typedef ::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XText +> SwXMeta_Base; class SwXMeta - : public SwXMetaBaseClass - , public SwClient + : public SwXMeta_Base , private ::boost::noncopyable { -private: - struct Impl; - ::std::auto_ptr m_pImpl; + +public: + + class Impl; protected: + + ::sw::UnoImplPtr m_pImpl; + + virtual void SAL_CALL AttachImpl( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + const USHORT nWhich) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ~SwXMeta(); -public: - SwXMeta(SwDoc *const pDoc, + /// @param pDoc and pMeta != 0, but not & because of ImplInheritanceHelper + SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + TextRangeList_t const*const pPortions); + +public: + SwXMeta(SwDoc *const pDoc); - TYPEINFO(); + static ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > + CreateXMeta( + ::sw::Meta & rMeta, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const& xParentText = 0, + ::std::auto_ptr pPortions = + ::std::auto_ptr(0)); + + /// init params with position of the attribute content (w/out CH_TXTATR) + bool SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + GetParentText() const; + + bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // MetadatableMixin + virtual ::sfx2::Metadatable * GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); @@ -118,6 +156,18 @@ public: ::com::sun::star::lang::XEventListener > & xListener) throw (::com::sun::star::uno::RuntimeException); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + // XTextContent virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference< @@ -180,72 +230,37 @@ public: throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - // XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType() - throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements() - throw (::com::sun::star::uno::RuntimeException); - - // XEnumerationAccess - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::container::XEnumeration > SAL_CALL - createEnumeration() - throw (::com::sun::star::uno::RuntimeException); - - // MetadatableMixin - virtual ::sfx2::Metadatable * GetCoreObject(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - GetModel(); - - // SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); - - /// init params with position of the attribute content (w/out CH_TXTATR) - bool SetContentRange( - SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - GetParentText() const; - - bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - -protected: - virtual void SAL_CALL AttachImpl( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange, - const USHORT nWhich) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException ); - -private: - inline const ::sw::Meta * GetMeta() const; - }; -typedef -::cppu::ImplInheritanceHelper2 -< SwXMeta -, ::com::sun::star::beans::XPropertySet -, ::com::sun::star::text::XTextField -> SwXMetaFieldBaseClass; +typedef ::cppu::ImplInheritanceHelper2 +< SwXMeta +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XTextField +> SwXMetaField_Base; class SwXMetaField - : public SwXMetaFieldBaseClass + : public SwXMetaField_Base { + private: + virtual ~SwXMetaField(); -private: - inline const ::sw::MetaField * GetMetaField() const; + friend ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > + SwXMeta::CreateXMeta(::sw::Meta &, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const&, + ::std::auto_ptr pPortions); -public: - SwXMetaField(SwDoc *const pDoc, + SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + TextRangeList_t const*const pPortions); + +public: + SwXMetaField(SwDoc *const pDoc); // XServiceInfo @@ -270,16 +285,6 @@ public: ::com::sun::star::lang::XEventListener > & xListener) throw (::com::sun::star::uno::RuntimeException); - // XTextContent - virtual void SAL_CALL attach( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() - throw (::com::sun::star::uno::RuntimeException); - // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL @@ -327,6 +332,16 @@ public: ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw ( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + // XTextField virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) throw (::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 066817d5b0..686b4a67af 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -57,7 +57,6 @@ #include // for meta #include // for meta #include -#include #include #include // GetNumberFormat @@ -750,6 +749,10 @@ void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) { NotifyChangeTxtNode(); SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXMeta(uno::Reference(0)); + } } // sw::Metadatable @@ -788,31 +791,7 @@ bool Meta::IsInContent() const ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > Meta::MakeUnoObject() { - // re-use existing SwXMeta - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXMeta ) ) ); - while (pClient) { - SwXMeta *const pMeta( dynamic_cast(pClient) ); - if (pMeta && pMeta->GetCoreObject() == this) { - return pMeta; - } - pClient = iter.Next(); - } - - // create new SwXMeta - SwTxtMeta * const pTxtAttr( GetTxtAttr() ); - OSL_ENSURE(pTxtAttr, "MakeUnoObject: no text attr?"); - if (!pTxtAttr) return 0; - SwTxtNode * const pTxtNode( pTxtAttr->GetTxtNode() ); - OSL_ENSURE(pTxtNode, "MakeUnoObject: no text node?"); - if (!pTxtNode) return 0; - const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); - const uno::Reference xParentText( - SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); - if (!xParentText.is()) return 0; - return (RES_TXTATR_META == m_pFmt->Which()) - ? new SwXMeta (pTxtNode->GetDoc(), xParentText, 0, pTxtAttr) - : new SwXMetaField(pTxtNode->GetDoc(), xParentText, 0, pTxtAttr); + return SwXMeta::CreateXMeta(*this); } /************************************************************************* diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 07f27201f6..2cff59cf41 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -492,6 +493,33 @@ lcl_CreateTOXMarkPortion( return pPortion; } +//----------------------------------------------------------------------------- +static uno::Reference +lcl_CreateMetaPortion( + uno::Reference const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwTxtAttr & rAttr, ::std::auto_ptr & pPortions) +{ + const uno::Reference xMeta( SwXMeta::CreateXMeta( + *static_cast(rAttr.GetAttr()).GetMeta(), + xParent, pPortions)); + SwXTextPortion * pPortion(0); + if (RES_TXTATR_META == rAttr.Which()) + { + const uno::Reference xContent(xMeta, + uno::UNO_QUERY); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_META); + pPortion->SetMeta(xContent); + } + else + { + const uno::Reference xField(xMeta, uno::UNO_QUERY); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD); + pPortion->SetTextField(xField); + } + return pPortion; +} + //----------------------------------------------------------------------------- static void lcl_ExportBookmark( @@ -692,30 +720,13 @@ lcl_ExportHints( } else { - TextRangeList_t *const pCurrentPortions(Top.first); + ::std::auto_ptr + pCurrentPortions(Top.first); rPortionStack.pop(); - SwXTextPortion * pPortion; - if (RES_TXTATR_META == nWhich) - { - SwXMeta * const pMeta = - new SwXMeta(pDoc, xParent, - pCurrentPortions, - static_cast(pAttr)); - pPortion = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_META); - pPortion->SetMeta(pMeta); - } - else - { - SwXMetaField * const pMeta = - new SwXMetaField(pDoc, xParent, - pCurrentPortions, - static_cast(pAttr)); - pPortion = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_FIELD); - pPortion->SetTextField(pMeta); - } - rPortionStack.top().first->push_back(pPortion); + const uno::Reference xPortion( + lcl_CreateMetaPortion(xParent, pUnoCrsr, + *pAttr, pCurrentPortions)); + rPortionStack.top().first->push_back(xPortion); } } break; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 42ef834cbf..18a72831f8 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -493,6 +493,8 @@ public: const uno::Reference< text::XTextRange > & xTextPosition) throw (uno::RuntimeException); + SwXMeta & GetXMeta() { return m_rMeta; } + }; SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta) @@ -598,8 +600,12 @@ SwXMetaText::createTextCursorByRange( // this list is created by SwXTextPortionEnumeration // the Meta listens at the SwTxtNode and throws away the cache when it changes -struct SwXMeta::Impl +class SwXMeta::Impl + : public SwClient { + +public: + SwEventListenerContainer m_ListenerContainer; ::std::auto_ptr m_pTextPortions; // 3 possible states: not attached, attached, disposed @@ -608,37 +614,132 @@ struct SwXMeta::Impl uno::Reference m_xParentText; SwXMetaText m_Text; - Impl(SwXMeta & rThis, SwDoc & rDoc, + Impl( SwXMeta & rThis, SwDoc & rDoc, + ::sw::Meta * const pMeta, uno::Reference const& xParentText, - TextRangeList_t const * const pPortions, - SwTxtMeta const * const pHint) - : m_ListenerContainer( - static_cast< ::cppu::OWeakObject* >(&rThis)) + TextRangeList_t const * const pPortions) + : SwClient(pMeta) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) , m_pTextPortions( pPortions ) , m_bIsDisposed( false ) - , m_bIsDescriptor( 0 == pHint ) + , m_bIsDescriptor(0 == pMeta) , m_xParentText(xParentText) , m_Text(rDoc, rThis) { } -}; -TYPEINIT1(SwXMeta, SwClient); + inline const ::sw::Meta * GetMeta() const; + // only for SwXMetaField! + inline const ::sw::MetaField * GetMetaField() const; + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); -inline const ::sw::Meta * SwXMeta::GetMeta() const +}; + +inline const ::sw::Meta * SwXMeta::Impl::GetMeta() const { return static_cast< const ::sw::Meta * >(GetRegisteredIn()); } +// SwModify +void SwXMeta::Impl::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) + + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + m_ListenerContainer.Disposing(); + m_bIsDisposed = true; + m_Text.Invalidate(); + } +} + uno::Reference SwXMeta::GetParentText() const { return m_pImpl->m_xParentText; } +SwXMeta::SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, + uno::Reference const& xParentText, + TextRangeList_t const*const pPortions) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, pMeta, xParentText, pPortions) ) +{ +} + +SwXMeta::SwXMeta(SwDoc *const pDoc) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) +{ +} + +SwXMeta::~SwXMeta() +{ +} + +uno::Reference +SwXMeta::CreateXMeta(::sw::Meta & rMeta, + uno::Reference const& i_xParent, + ::std::auto_ptr pPortions) +{ + // re-use existing SwXMeta + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference xMeta(rMeta.GetXMeta()); + if (xMeta.is()) + { + if (pPortions.get()) // set cache in the XMeta to the given portions + { + const uno::Reference xUT(xMeta, uno::UNO_QUERY); + SwXMeta *const pXMeta( + ::sw::UnoTunnelGetImplementation(xUT)); + OSL_ENSURE(pXMeta, "no pXMeta?"); + // NB: the meta must always be created with the complete content + // if SwXTextPortionEnumeration is created for a selection, + // it must be checked that the Meta is contained in the selection! + pXMeta->m_pImpl->m_pTextPortions = pPortions; + // ??? is this necessary? + if (pXMeta->m_pImpl->m_xParentText.get() != i_xParent.get()) + { + OSL_ENSURE(false, "SwXMeta with different parent?"); + pXMeta->m_pImpl->m_xParentText.set(i_xParent); + } + } + return xMeta; + } + + // create new SwXMeta + SwTxtNode * const pTxtNode( rMeta.GetTxtNode() ); + OSL_ENSURE(pTxtNode, "CreateXMeta: no text node?"); + if (!pTxtNode) { return 0; } + uno::Reference xParentText(i_xParent); + if (!xParentText.is()) + { + SwTxtMeta * const pTxtAttr( rMeta.GetTxtAttr() ); + OSL_ENSURE(pTxtAttr, "CreateXMeta: no text attr?"); + if (!pTxtAttr) { return 0; } + const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); + xParentText.set( + SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); + } + if (!xParentText.is()) { return 0; } + SwXMeta *const pXMeta( (RES_TXTATR_META == rMeta.GetFmtMeta()->Which()) + ? new SwXMeta (pTxtNode->GetDoc(), &rMeta, xParentText, + pPortions.release()) // temporarily un-auto_ptr :-( + : new SwXMetaField(pTxtNode->GetDoc(), &rMeta, xParentText, + pPortions.release())); + // this is why the constructor is private: need to acquire pXMeta here + xMeta.set(pXMeta); + // in order to initialize the weak pointer cache in the core object + rMeta.SetXMeta(xMeta); + return xMeta; +} + + bool SwXMeta::SetContentRange( SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const { - ::sw::Meta const * const pMeta( GetMeta() ); + ::sw::Meta const * const pMeta( m_pImpl->GetMeta() ); if (pMeta) { SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); @@ -657,23 +758,6 @@ bool SwXMeta::SetContentRange( return false; } -SwXMeta::SwXMeta(SwDoc *const pDoc, - uno::Reference const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint) - : m_pImpl( new SwXMeta::Impl(*this, *pDoc, xParentText, pPortions, pHint) ) -{ - if (pHint) - { - ::sw::Meta * const pMeta( - static_cast(pHint->GetAttr()).GetMeta() ); - ASSERT(pMeta, "SwXMeta: no meta?") - if (pMeta) - { - pMeta->Add(this); - } - } -} - bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, const SwPaM* const pPam, bool bAbsorb) throw (lang::IllegalArgumentException, uno::RuntimeException) @@ -744,16 +828,6 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, return bForceExpandHints; } - -SwXMeta::SwXMeta(SwDoc *const pDoc) - : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) -{ -} - -SwXMeta::~SwXMeta() -{ -} - const uno::Sequence< sal_Int8 > & SwXMeta::getUnoTunnelId() { static uno::Sequence< sal_Int8 > aSeq( ::CreateUnoTunnelId() ); @@ -765,14 +839,7 @@ sal_Int64 SAL_CALL SwXMeta::getSomething( const uno::Sequence< sal_Int8 > & i_rId ) throw (uno::RuntimeException) { - if ( i_rId.getLength() == 16 && - 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - i_rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(i_rId, this); } // XServiceInfo @@ -782,21 +849,26 @@ SwXMeta::getImplementationName() throw (uno::RuntimeException) return C2U("SwXMeta"); } +static char const*const g_ServicesMeta[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.InContentMetadata", +}; +static const size_t g_nServicesMeta( + sizeof(g_ServicesMeta)/sizeof(g_ServicesMeta[0])); + sal_Bool SAL_CALL SwXMeta::supportsService(const ::rtl::OUString& rServiceName) throw (uno::RuntimeException) { - return rServiceName.equalsAscii("com.sun.star.text.TextContent") - || rServiceName.equalsAscii("com.sun.star.text.InContentMetadata"); + return ::sw::SupportsServiceImpl( + g_nServicesMeta, g_ServicesMeta, rServiceName); } uno::Sequence< ::rtl::OUString > SAL_CALL SwXMeta::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(2); - aRet[0] = C2U("com.sun.star.text.TextContent"); - aRet[1] = C2U("com.sun.star.text.InContentMetadata"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl(g_nServicesMeta, g_ServicesMeta); } @@ -886,14 +958,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) C2S("SwXMeta::attach(): argument is no XUnoTunnel"), static_cast< ::cppu::OWeakObject* >(this), 0); } - SwXTextRange * const pRange( - reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( - SwXTextRange::getUnoTunnelId() ))) ); - OTextCursorHelper * const pCursor( pRange ? 0 : - reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( - OTextCursorHelper::getUnoTunnelId() ))) ); + SwXTextRange *const pRange( + ::sw::UnoTunnelGetImplementation(xRangeTunnel)); + OTextCursorHelper *const pCursor( (pRange) ? 0 : + ::sw::UnoTunnelGetImplementation(xRangeTunnel)); if (!pRange && !pCursor) { throw lang::IllegalArgumentException( @@ -945,7 +1013,8 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) static_cast< ::cppu::OWeakObject* >(this)); } - pMeta->Add(this); + pMeta->Add(m_pImpl.get()); + pMeta->SetXMeta(uno::Reference(this)); m_pImpl->m_xParentText = SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); @@ -1102,7 +1171,7 @@ SwXMeta::hasElements() throw (uno::RuntimeException) { vos::OGuard g(Application::GetSolarMutex()); - return GetRegisteredIn() ? sal_True : sal_False; + return m_pImpl->GetRegisteredIn() ? sal_True : sal_False; } // XEnumerationAccess @@ -1118,7 +1187,7 @@ SwXMeta::createEnumeration() throw (uno::RuntimeException) if (m_pImpl->m_bIsDescriptor) { throw uno::RuntimeException( - C2S("getAnchor(): not inserted"), + C2S("createEnumeration(): not inserted"), static_cast< ::cppu::OWeakObject* >(this)); } @@ -1147,12 +1216,12 @@ SwXMeta::createEnumeration() throw (uno::RuntimeException) // MetadatableMixin ::sfx2::Metadatable* SwXMeta::GetCoreObject() { - return const_cast< ::sw::Meta * >(GetMeta()); + return const_cast< ::sw::Meta * >(m_pImpl->GetMeta()); } uno::Reference SwXMeta::GetModel() { - ::sw::Meta const * const pMeta( GetMeta() ); + ::sw::Meta const * const pMeta( m_pImpl->GetMeta() ); if (pMeta) { SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() ); @@ -1165,42 +1234,27 @@ uno::Reference SwXMeta::GetModel() return 0; } -// SwModify -void SwXMeta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) -{ - m_pImpl->m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) - - ClientModify(this, pOld, pNew); - - if (!GetRegisteredIn()) // removed => dispose - { - m_pImpl->m_ListenerContainer.Disposing(); - m_pImpl->m_bIsDisposed = true; - m_pImpl->m_Text.Invalidate(); - } -} - /****************************************************************** * SwXMetaField ******************************************************************/ -inline const ::sw::MetaField * SwXMetaField::GetMetaField() const +inline const ::sw::MetaField * SwXMeta::Impl::GetMetaField() const { return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); } -SwXMetaField::SwXMetaField(SwDoc *const pDoc, +SwXMetaField::SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, uno::Reference const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint) - : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint) + TextRangeList_t const*const pPortions) + : SwXMetaField_Base(pDoc, pMeta, xParentText, pPortions) { - ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(), + ASSERT(pMeta && dynamic_cast< ::sw::MetaField* >(pMeta), "SwXMetaField created for wrong hint!"); } SwXMetaField::SwXMetaField(SwDoc *const pDoc) - : SwXMetaFieldBaseClass(pDoc) + : SwXMetaField_Base(pDoc) { } @@ -1215,23 +1269,28 @@ SwXMetaField::getImplementationName() throw (uno::RuntimeException) return C2U("SwXMetaField"); } +static char const*const g_ServicesMetaField[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.TextField", + "com.sun.star.text.textfield.MetadataField", +}; +static const size_t g_nServicesMetaField( + sizeof(g_ServicesMetaField)/sizeof(g_ServicesMetaField[0])); + sal_Bool SAL_CALL SwXMetaField::supportsService(const ::rtl::OUString& rServiceName) throw (uno::RuntimeException) { - return rServiceName.equalsAscii("com.sun.star.text.TextContent") - || rServiceName.equalsAscii("com.sun.star.text.TextField") - || rServiceName.equalsAscii("com.sun.star.text.textfield.MetadataField"); + return ::sw::SupportsServiceImpl( + g_nServicesMetaField, g_ServicesMetaField, rServiceName); } uno::Sequence< ::rtl::OUString > SAL_CALL SwXMetaField::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(3); - aRet[0] = C2U("com.sun.star.text.TextContent"); - aRet[1] = C2U("com.sun.star.text.TextField"); - aRet[2] = C2U("com.sun.star.text.textfield.MetadataField"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesMetaField, g_ServicesMetaField); } // XComponent @@ -1293,7 +1352,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, vos::OGuard g(Application::GetSolarMutex()); ::sw::MetaField * const pMeta( - const_cast< ::sw::MetaField * >(GetMetaField()) ); + const_cast< ::sw::MetaField * >(m_pImpl->GetMetaField()) ); if (!pMeta) throw lang::DisposedException(); @@ -1326,7 +1385,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, { vos::OGuard g(Application::GetSolarMutex()); - ::sw::MetaField const * const pMeta( GetMetaField() ); + ::sw::MetaField const * const pMeta( m_pImpl->GetMetaField() ); if (!pMeta) throw lang::DisposedException(); -- cgit v1.2.3 From 696b293fa817d394f92ad95ce6e9c49c01daee4f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:49 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXReferenceMark: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. disable broken SwClient iteration. add factory function CreateXReferenceMark. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unorefmark.hxx | 41 +-- sw/source/core/unocore/unoclbck.cxx | 16 +- sw/source/core/unocore/unocoll.cxx | 14 +- sw/source/core/unocore/unorefmk.cxx | 516 ++++++++++++++++++++++-------------- 4 files changed, 336 insertions(+), 251 deletions(-) diff --git a/sw/inc/unorefmark.hxx b/sw/inc/unorefmark.hxx index 8a37b5655e..61b6d09df0 100644 --- a/sw/inc/unorefmark.hxx +++ b/sw/inc/unorefmark.hxx @@ -40,16 +40,12 @@ #include -#include - -#include -#include +#include class SwDoc; -class SwPaM; +class SwModify; class SwFmtRefMark; -class SwXTextCursor; /* -----------------27.08.98 15:11------------------- @@ -65,41 +61,24 @@ typedef ::cppu::WeakImplHelper5 class SwXReferenceMark : public SwXReferenceMark_Base - , public SwClient { private: - SwEventListenerContainer aLstnrCntnr; - SwDoc* pDoc; - const SwFmtRefMark* pMark; - String sMarkName; - BOOL m_bIsDescriptor; - - BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXReferenceMark(); public: - SwXReferenceMark(SwDoc * pDoc, const SwFmtRefMark * pMark); - - 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); - - const SwFmtRefMark* GetMark() const {return pMark;} - const String& GetMarkName() const {return sMarkName;} - SwDoc* GetDoc() const {return pDoc;} - void Invalidate(); - - TYPEINFO(); + SwXReferenceMark(SwDoc *const pDoc, const SwFmtRefMark *const pMark); - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static SwXReferenceMark * + CreateXReferenceMark(SwDoc & rDoc, SwFmtRefMark const& rMarkFmt); + /// may return 0 + static SwXReferenceMark * + GetReferenceMark(SwModify const& rUnoCB, SwFmtRefMark const& rMarkFmt); static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 27510e63b3..693aaf9674 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -64,21 +64,9 @@ SwUnoCallBack::~SwUnoCallBack() ---------------------------------------------------------------------------*/ SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) { - SwClientIter aIter( *this ); - SwXReferenceMark* pxRefMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark )); - while(pxRefMark) - { - SwDoc* pDoc = pxRefMark->GetDoc(); - if(pDoc) - { - const SwFmtRefMark* pFmt = pDoc->GetRefMark(pxRefMark->GetMarkName()); - if(pFmt == &rMark) - return pxRefMark; - } - pxRefMark = (SwXReferenceMark*)aIter.Next( ); - } - return 0; + return SwXReferenceMark::GetReferenceMark(*this, rMark); } + /* -----------------------------05.09.00 12:38-------------------------------- ---------------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 60b6897e88..745d28165c 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1946,18 +1946,10 @@ sal_Bool SwXReferenceMarks::hasElements(void) throw( uno::RuntimeException ) SwXReferenceMark* SwXReferenceMarks::GetObject( SwDoc* pDoc, const SwFmtRefMark* pMark ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwClientIter aIter( *pDoc->GetUnoCallBack() ); - SwXReferenceMark* pxMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark )); - while(pxMark) - { - if(pxMark->GetMark() == pMark) - break; - pxMark = (SwXReferenceMark*)aIter.Next(); - } - if( !pxMark ) - pxMark = new SwXReferenceMark(pDoc, pMark); - return pxMark; + + return SwXReferenceMark::CreateXReferenceMark(*pDoc, *pMark); } + /****************************************************************** * ******************************************************************/ diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 18a72831f8..c1a59bddbb 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -47,6 +47,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; @@ -54,81 +55,191 @@ using ::rtl::OUString; * SwXReferenceMark ******************************************************************/ -/* -----------------------------13.03.00 12:15-------------------------------- +class SwXReferenceMark::Impl + : public SwClient +{ + +public: + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDoc * m_pDoc; + const SwFmtRefMark * m_pMarkFmt; + ::rtl::OUString m_sMarkName; + + Impl( SwXReferenceMark & rThis, + SwDoc *const pDoc, SwFmtRefMark const*const pRefMark) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pRefMark) + , m_pDoc(pDoc) + , m_pMarkFmt(pRefMark) + { + if (pRefMark) + { + m_sMarkName = pRefMark->GetRefName(); + } + } + + bool IsValid() const { return 0 != GetRegisteredIn(); } + void InsertRefMark( SwPaM & rPam, SwXTextCursor const*const pCursor ); + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------07.01.00 12:51-------------------------------- ---------------------------------------------------------------------------*/ -const uno::Sequence< sal_Int8 > & SwXReferenceMark::getUnoTunnelId() +void SwXReferenceMark::Impl::Invalidate() { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + if (IsValid()) + { + const_cast(GetRegisteredIn())->Remove(this); + } + m_ListenerContainer.Disposing(); + m_pDoc = 0; + m_pMarkFmt = 0; } -/* -----------------------------10.03.00 18:04-------------------------------- - ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXReferenceMark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +/*-- 11.12.98 10:28:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXReferenceMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_REFMARK_DELETED: + if (static_cast(m_pMarkFmt) == + static_cast(pOld)->pObject) + { + Invalidate(); + } + break; + } + } +} + + +/*-- 11.12.98 10:28:32--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXReferenceMark::SwXReferenceMark( + SwDoc *const pDoc, SwFmtRefMark const*const pRefMark) + : m_pImpl( new SwXReferenceMark::Impl(*this, pDoc, pRefMark) ) +{ +} + +/*-- 11.12.98 10:28:33--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXReferenceMark::~SwXReferenceMark() +{ +} + +SwXReferenceMark * +SwXReferenceMark::GetReferenceMark( + SwModify const& /*rUnoCB*/, SwFmtRefMark const& /*rMarkFmt*/) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXReferenceMark to register at the + // SwFmtRefMark directly, not at the unocallback +#if 0 + SwClientIter aIter( rUnoCB ); + SwXReferenceMark::Impl * pXMark = + static_cast( + aIter.First( TYPE( SwXReferenceMark::Impl ) )); + while (pXMark) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + if (pXMark->m_pMarkFmt == &rMarkFmt) + { + return &pXMark->m_rThis; + } + pXMark = static_cast(aIter.Next()); } +#endif return 0; } -/* -----------------------------06.04.00 16:41-------------------------------- + +SwXReferenceMark * +SwXReferenceMark::CreateXReferenceMark( + SwDoc & rDoc, SwFmtRefMark const& rMarkFmt) +{ + SwXReferenceMark *const pXMark( + GetReferenceMark(*rDoc.GetUnoCallBack(), rMarkFmt) ); + return (pXMark) + ? pXMark + : new SwXReferenceMark(&rDoc, &rMarkFmt); +} + +/* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXReferenceMark::getImplementationName(void) throw( uno::RuntimeException ) +const uno::Sequence< sal_Int8 > & SwXReferenceMark::getUnoTunnelId() { - return C2U("SwXReferenceMark"); + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -/* -----------------------------06.04.00 16:41-------------------------------- +/* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXReferenceMark::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +sal_Int64 SAL_CALL +SwXReferenceMark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - return !rServiceName.compareToAscii("com.sun.star.text.ReferenceMark")|| - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); + return ::sw::UnoTunnelImpl(rId, this); } /* -----------------------------06.04.00 16:41-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXReferenceMark::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXReferenceMark::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(2); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.ReferenceMark"); - pArray[1] = C2U("com.sun.star.text.TextContent"); - return aRet; + return C2U("SwXReferenceMark"); } -/*-- 11.12.98 10:28:32--------------------------------------------------- +/* -----------------------------06.04.00 16:41-------------------------------- - -----------------------------------------------------------------------*/ -TYPEINIT1(SwXReferenceMark, SwClient); + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesReferenceMark[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.ReferenceMark", +}; +static const size_t g_nServicesReferenceMark( + sizeof(g_ServicesReferenceMark)/sizeof(g_ServicesReferenceMark[0])); -SwXReferenceMark::SwXReferenceMark(SwDoc* pDc, const SwFmtRefMark* pRefMark) : - aLstnrCntnr( (text::XTextContent*)this), - pDoc(pDc), - pMark(pRefMark), - m_bIsDescriptor(0 == pRefMark) +sal_Bool SAL_CALL +SwXReferenceMark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - if(pRefMark) - sMarkName = pRefMark->GetRefName(); - if(pDoc) - pDoc->GetUnoCallBack()->Add(this); + return ::sw::SupportsServiceImpl( + g_nServicesReferenceMark, g_ServicesReferenceMark, rServiceName); } -/*-- 11.12.98 10:28:33--------------------------------------------------- +/* -----------------------------06.04.00 16:41-------------------------------- - -----------------------------------------------------------------------*/ -SwXReferenceMark::~SwXReferenceMark() + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXReferenceMark::getSupportedServiceNames() +throw (uno::RuntimeException) { - + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesReferenceMark, g_ServicesReferenceMark); } + /* -----------------03.11.99 14:14------------------- --------------------------------------------------*/ -void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) +void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam, + SwXTextCursor const*const pCursor) { //! in some cases when this function is called the pDoc pointer member may have become //! invalid/deleted thus we obtain the document pointer from rPaM where it should always @@ -136,12 +247,8 @@ void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) SwDoc *pDoc2 = rPam.GetDoc(); UnoActionContext aCont(pDoc2); - SwTxtAttr* pTxtAttr = 0; - SwFmtRefMark aRefMark(sMarkName); -// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); -// aSet.Put(aRefMark); + SwFmtRefMark aRefMark(m_sMarkName); sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark(); -// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); const bool bForceExpandHints( (!bMark && pCursor) ? pCursor->IsAtEndOfMeta() : false ); @@ -153,290 +260,309 @@ void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags ); if( bMark && *rPam.GetPoint() > *rPam.GetMark()) - rPam.Exchange(); - - if( bMark ) - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( - rPam.GetPoint()->nContent, RES_TXTATR_REFMARK ); - else { - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK ); + rPam.Exchange(); } + SwTxtAttr *const pTxtAttr = (bMark) + ? rPam.GetNode()->GetTxtNode()->GetTxtAttr( + rPam.GetPoint()->nContent, RES_TXTATR_REFMARK) + : rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + rPam.GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_REFMARK); + if(pTxtAttr) - pMark = &pTxtAttr->GetRefMark(); + { + m_pMarkFmt = &pTxtAttr->GetRefMark(); + } pDoc2->GetUnoCallBack()->Add(this); } -/* -----------------18.02.99 13:33------------------- - * - * --------------------------------------------------*/ -void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +/*-- 11.12.98 10:28:34--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL +SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); + } uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); } - SwDoc* pDocument = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDocument) + SwDoc *const pDocument = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDocument) { - SwUnoInternalPaM aPam(*pDocument); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - InsertRefMark(aPam, dynamic_cast(pCursor)); - m_bIsDescriptor = sal_False; - pDoc = pDocument; - pDoc->GetUnoCallBack()->Add(this); - } - else throw lang::IllegalArgumentException(); -} -/*-- 11.12.98 10:28:34--------------------------------------------------- + } - -----------------------------------------------------------------------*/ -void SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + SwUnoInternalPaM aPam(*pDocument); + //das muss jetzt sal_True liefern + SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + m_pImpl->InsertRefMark(aPam, dynamic_cast(pCursor)); + m_pImpl->m_bIsDescriptor = sal_False; + m_pImpl->m_pDoc = pDocument; + m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); } + /*-- 11.12.98 10:28:34--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXReferenceMark::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXReferenceMark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - if(IsValid()) + + if (m_pImpl->IsValid()) { - const SwFmtRefMark* pNewMark = pDoc->GetRefMark(sMarkName); - if(pNewMark && pNewMark == pMark) + SwFmtRefMark const*const pNewMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if (pNewMark && (pNewMark == m_pImpl->m_pMarkFmt)) { - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); - SwPaM* pPam = pTxtMark->GetEnd() ? - new SwPaM( rTxtNode, *pTxtMark->GetEnd(), - rTxtNode, *pTxtMark->GetStart()) : - new SwPaM( rTxtNode, *pTxtMark->GetStart()); - - - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pPam->Start(), pPam->End()); - delete pPam; + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); + const ::std::auto_ptr pPam( (pTxtMark->GetEnd()) + ? new SwPaM( rTxtNode, *pTxtMark->GetEnd(), + rTxtNode, *pTxtMark->GetStart()) + : new SwPaM( rTxtNode, *pTxtMark->GetStart()) ); + + return SwXTextRange::CreateTextRangeFromPosition( + m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); } } } - return xRet; + return 0; } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if (m_pImpl->IsValid()) { - const SwFmtRefMark* pNewMark = pDoc->GetRefMark(sMarkName); - if(pNewMark && pNewMark == pMark) + SwFmtRefMark const*const pNewMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if (pNewMark && (pNewMark == m_pImpl->m_pMarkFmt)) { - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); xub_StrLen nStt = *pTxtMark->GetStart(), nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); - pDoc->DeleteAndJoin( aPam ); + m_pImpl->m_pDoc->DeleteAndJoin( aPam ); } } } - else - throw uno::RuntimeException(); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->Invalidate(); + } } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->IsValid()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->IsValid() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } /*-- 11.12.98 10:28:36--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXReferenceMark::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXReferenceMark::getName() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid() || !pDoc->GetRefMark(sMarkName)) + if (!m_pImpl->IsValid() || + !m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName)) { throw uno::RuntimeException(); } - return sMarkName; + return m_pImpl->m_sMarkName; } /*-- 11.12.98 10:28:36--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(m_bIsDescriptor) - sMarkName = String(Name_); + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sMarkName = rName; + } else { - String sNewName(Name_); - if(!IsValid() || !pDoc->GetRefMark(sMarkName) || pDoc->GetRefMark(sNewName)) + if (!m_pImpl->IsValid() + || !m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName) + || m_pImpl->m_pDoc->GetRefMark(rName)) { throw uno::RuntimeException(); } - const SwFmtRefMark* pCurMark = pDoc->GetRefMark(sMarkName); - if(sNewName != sMarkName && pCurMark && pCurMark == pMark) + SwFmtRefMark const*const pCurMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if ((rName != m_pImpl->m_sMarkName) + && pCurMark && (pCurMark == m_pImpl->m_pMarkFmt)) { - UnoActionContext aCont(pDoc); - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + const UnoActionContext aCont(m_pImpl->m_pDoc); + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); xub_StrLen nStt = *pTxtMark->GetStart(), nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); - pDoc->DeleteAndJoin( aPam ); //! deletes the pDoc member in the SwXReferenceMark - //! The aPam will keep the correct and functional doc though + // deletes the m_pImpl->m_pDoc member in the SwXReferenceMark! + m_pImpl->m_pDoc->DeleteAndJoin( aPam ); + // The aPam will keep the correct and functional doc though - sMarkName = sNewName; + m_pImpl->m_sMarkName = rName; //create a new one - InsertRefMark( aPam, 0 ); - pDoc = aPam.GetDoc(); + m_pImpl->InsertRefMark( aPam, 0 ); + m_pImpl->m_pDoc = aPam.GetDoc(); } } } } -/* -----------------------------07.01.00 12:51-------------------------------- - - ---------------------------------------------------------------------------*/ -void SwXReferenceMark::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - aLstnrCntnr.Disposing(); - pDoc = 0; - pMark = 0; - } -} -/*-- 11.12.98 10:28:37--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXReferenceMark::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_REFMARK_DELETED: - if( (void*)pMark == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } -} /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXReferenceMark::getPropertySetInfo( ) throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXReferenceMark::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRef = - aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS)->getPropertySetInfo(); + aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS) + ->getPropertySetInfo(); return xRef; } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::setPropertyValue( +void SAL_CALL SwXReferenceMark::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { throw lang::IllegalArgumentException(); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXReferenceMark::getPropertyValue( const OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +uno::Any SAL_CALL +SwXReferenceMark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + // does not seem to need SolarMutex uno::Any aRet; if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + { throw beans::UnknownPropertyException(); + } return aRet; } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addPropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::addPropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::addPropertyChangeListener(): not implemented"); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removePropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::removePropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::removePropertyChangeListener(): not implemented"); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addVetoableChangeListener( const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::addVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::addVetoableChangeListener(): not implemented"); } /*-- 12.09.00 12:58:21--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removeVetoableChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::removeVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::removeVetoableChangeListener(): not implemented"); } #include -- cgit v1.2.3 From a6b0df979b785e88fad9a13b4827ebdfde5987b2 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:50 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXBookmark: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in sw::mark::MarkBase. make constructor protected, and add factory function CreateXBookmark. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. remove SwXBookmarks::GetObject(). --- sw/inc/unobookmark.hxx | 48 ++-- sw/inc/unocoll.hxx | 1 - sw/source/core/crsr/bookmrk.cxx | 30 +-- sw/source/core/inc/bookmrk.hxx | 24 +- sw/source/core/unocore/unobkm.cxx | 480 ++++++++++++++++++++++----------- sw/source/core/unocore/unocoll.cxx | 31 +-- sw/source/core/unocore/unoportenum.cxx | 15 +- sw/source/ui/uno/unotxvw.cxx | 17 +- 8 files changed, 399 insertions(+), 247 deletions(-) diff --git a/sw/inc/unobookmark.hxx b/sw/inc/unobookmark.hxx index 2b16d78280..46d0054551 100644 --- a/sw/inc/unobookmark.hxx +++ b/sw/inc/unobookmark.hxx @@ -41,12 +41,10 @@ #include -#include #include +#include #include -#include -#include class SwDoc; @@ -63,33 +61,15 @@ typedef ::cppu::ImplInheritanceHelper5 class SwXBookmark : public SwXBookmark_Base - , private SwClient { private: - SwEventListenerContainer m_aLstnrCntnr; - SwDoc* m_pDoc; - String m_aName; - ::sw::mark::IMark* m_pRegisteredBookmark; - - void registerInMark(::sw::mark::IMark* const pBkmk); + class Impl; + ::sw::UnoImplPtr m_pImpl; protected: - virtual ~SwXBookmark(); - -public: - - SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); - - const ::sw::mark::IMark* GetBookmark() const - { return m_pRegisteredBookmark; } - ::sw::mark::IMark* GetBookmark() - { return m_pRegisteredBookmark; } - SwDoc* GetDoc() - { return m_pDoc; } - void attachToRangeEx( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange, @@ -102,10 +82,26 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - TYPEINFO(); + const ::sw::mark::IMark* GetBookmark() const; - // SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + virtual ~SwXBookmark(); + + /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper + SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc); + +public: + + /// descriptor + SwXBookmark(); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> + CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark); + + /// @return IMark for this, but only if it lives in pDoc + static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel> & xUT); // MetadatableMixin virtual ::sfx2::Metadatable* GetCoreObject(); diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index a1d5139897..8a90e6541a 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -481,7 +481,6 @@ class SwXBookmarks : public SwCollectionBaseClass, virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - static SwXBookmark* GetObject( ::sw::mark::IMark& rBkm, SwDoc* pDoc); }; class SwXNumberingRulesCollection : public cppu::WeakImplHelper1 diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index b9b7a017fb..403daf4db3 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -49,6 +49,7 @@ SV_IMPL_REF( SwServerObject ) using namespace ::sw::mark; +using namespace ::com::sun::star; namespace { @@ -147,6 +148,16 @@ namespace sw { namespace mark return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear(); } + // SwClient + void MarkBase::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) + { + SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXBookmark(uno::Reference(0)); + } + } + NavigatorReminder::NavigatorReminder(const SwPaM& rPaM) : MarkBase(rPaM, our_sNamePrefix) @@ -240,24 +251,13 @@ namespace sw { namespace mark return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) ); } - ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > - Bookmark::MakeUnoObject() + uno::Reference< rdf::XMetadatable > Bookmark::MakeUnoObject() { - // re-use existing SwXBookmark - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXBookmark ) ) ); - while (pClient) { - SwXBookmark *const pBookmark( dynamic_cast(pClient) ); - if (pBookmark && pBookmark->GetCoreObject() == this) { - return pBookmark; - } - pClient = iter.Next(); - } - - // create new SwXBookmark SwDoc *const pDoc( GetMarkPos().GetDoc() ); OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); - return new SwXBookmark(this, pDoc); + const uno::Reference< rdf::XMetadatable> xMeta( + SwXBookmark::CreateXBookmark(*pDoc, *this), uno::UNO_QUERY); + return xMeta; } diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index 415deffa24..c281e69b18 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -31,12 +31,20 @@ #ifndef _BOOKMRK_HXX #define _BOOKMRK_HXX -#include +#include + #include #include #include +#include + + +namespace com { namespace sun { namespace star { + namespace text { class XTextContent; } +} } } + struct SwPosition; // fwd Decl. wg. UI class SwDoc; @@ -90,6 +98,17 @@ namespace sw { namespace mark {} virtual ~MarkBase(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + const ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> & GetXBookmark() const + { return m_wXBookmark; } + void SetXBookmark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> const& xBkmk) + { m_wXBookmark = xBkmk; } + protected: MarkBase(const SwPaM& rPaM, const ::rtl::OUString& rName); @@ -97,6 +116,9 @@ namespace sw { namespace mark ::boost::scoped_ptr m_pPos2; ::rtl::OUString m_aName; static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix); + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> m_wXBookmark; }; class NavigatorReminder diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index a22eb8a2b1..24d1ccd7d6 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -34,11 +34,13 @@ #include #include #include + #include #include #include #include #include +#include #include #include #include @@ -52,13 +54,8 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; using ::rtl::OUString; -using ::rtl::OUStringBuffer; + namespace { @@ -66,7 +63,7 @@ namespace { static const OUString sStart = OUString(String(SW_RES(STR_START_QUOTE))); static const OUString sEnd = OUString(String(SW_RES(STR_END_QUOTE))); - OUStringBuffer sBuf(64); + ::rtl::OUStringBuffer sBuf(64); return sBuf.append(sStart).append(rName).append(sEnd).makeStringAndClear(); } } @@ -74,184 +71,307 @@ namespace /****************************************************************** * SwXBookmark ******************************************************************/ -TYPEINIT1(SwXBookmark, SwClient) -void SwXBookmark::registerInMark(::sw::mark::IMark* const pBkmk) +class SwXBookmark::Impl + : public SwClient +{ + +public: + SwEventListenerContainer m_ListenerContainer; + SwDoc * m_pDoc; + ::sw::mark::IMark * m_pRegisteredBookmark; + ::rtl::OUString m_sMarkName; + + + Impl( SwXBookmark & rThis, + SwDoc *const pDoc, ::sw::mark::IMark *const /*pBookmark*/) + : SwClient() + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_pDoc(pDoc) + , m_pRegisteredBookmark(0) + { + // DO NOT regiserInMark here! (because SetXBookmark would delete rThis) + } + + void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXBookmark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) + { + m_pRegisteredBookmark = NULL; + m_pDoc = NULL; + m_ListenerContainer.Disposing(); + } +} + +void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis, + ::sw::mark::IMark *const pBkmk) { if (pBkmk) { pBkmk->Add(this); + ::sw::mark::MarkBase *const pMarkBase( + dynamic_cast< ::sw::mark::MarkBase * >(pBkmk)); + OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?"); + if (pMarkBase) + { + const uno::Reference xBookmark(& rThis); + pMarkBase->SetXBookmark(xBookmark); + } } else if (m_pRegisteredBookmark) { - m_aName = m_pRegisteredBookmark->GetName(); + m_sMarkName = m_pRegisteredBookmark->GetName(); m_pRegisteredBookmark->Remove(this); } m_pRegisteredBookmark = pBkmk; } -const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() + +const ::sw::mark::IMark* SwXBookmark::GetBookmark() const { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + return m_pImpl->m_pRegisteredBookmark; } -sal_Int64 SAL_CALL SwXBookmark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +SwXBookmark::SwXBookmark(::sw::mark::IMark *const pBkmk, SwDoc *const pDoc) + : m_pImpl( new SwXBookmark::Impl(*this, pDoc, pBkmk) ) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) +} + +SwXBookmark::SwXBookmark() + : m_pImpl( new SwXBookmark::Impl(*this, 0, 0) ) +{ +} + +SwXBookmark::~SwXBookmark() +{ +} + +uno::Reference +SwXBookmark::CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark) +{ + // #i105557#: do not iterate over the registered clients: race condition + ::sw::mark::MarkBase *const pMarkBase( + dynamic_cast< ::sw::mark::MarkBase * >(&rBookmark)); + OSL_ENSURE(pMarkBase, "CreateXBookmark: no MarkBase?"); + if (!pMarkBase) { return 0; } + uno::Reference xBookmark(pMarkBase->GetXBookmark()); + if (!xBookmark.is()) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + // FIXME: These belong in XTextFieldsSupplier + //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) + // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); + //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) + // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); + //else + OSL_ENSURE( + dynamic_cast< ::sw::mark::IBookmark* >(&rBookmark), + "" + "SwXBookmark requested for non-bookmark mark."); + SwXBookmark *const pXBookmark = new SwXBookmark(&rBookmark, &rDoc); + xBookmark.set(pXBookmark); + pXBookmark->m_pImpl->registerInMark(*pXBookmark, pMarkBase); + } + return xBookmark; +} + +::sw::mark::IMark const* SwXBookmark::GetBookmarkInDoc(SwDoc const*const pDoc, + const uno::Reference< lang::XUnoTunnel> & xUT) +{ + SwXBookmark *const pXBkm( + ::sw::UnoTunnelGetImplementation(xUT)); + if (pXBkm && (pDoc == pXBkm->m_pImpl->m_pDoc)) + { + return pXBkm->m_pImpl->m_pRegisteredBookmark; } return 0; } -SwXBookmark::SwXBookmark(::sw::mark::IMark* pBkmk, SwDoc* pDoc) - : m_aLstnrCntnr((text::XTextContent*)this) - , m_pDoc(pDoc) - , m_pRegisteredBookmark(NULL) +const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() { - registerInMark(pBkmk); + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -SwXBookmark::~SwXBookmark() -{ } +sal_Int64 SAL_CALL +SwXBookmark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + return ::sw::UnoTunnelImpl(rId, this); +} void SwXBookmark::attachToRangeEx( const uno::Reference< text::XTextRange > & xTextRange, IDocumentMarkAccess::MarkType eType) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(m_pRegisteredBookmark) + if (m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); + } - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + } - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId() ))); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ))); + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) + { + throw lang::IllegalArgumentException(); } - SwDoc* pDc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? - (SwDoc*)pCursor->GetDoc() : 0; - if(pDc) + m_pImpl->m_pDoc = pDoc; + SwUnoInternalPaM aPam(*m_pImpl->m_pDoc); + SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + UnoActionContext aCont(m_pImpl->m_pDoc); + if (!m_pImpl->m_sMarkName.getLength()) { - m_pDoc = pDc; - SwUnoInternalPaM aPam(*m_pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - UnoActionContext aCont(m_pDoc); - if(!m_aName.Len()) - m_aName = OUString::createFromAscii("Bookmark"); - if(eType == IDocumentMarkAccess::BOOKMARK && ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_aName)) - eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; - else if(eType == IDocumentMarkAccess::BOOKMARK && ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_aName)) - eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; - registerInMark(m_pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName, eType)); - // --> OD 2007-10-23 #i81002# - // Check, if bookmark has been created. - // E.g., the creation of a cross-reference bookmark is suppress, - // if the PaM isn't a valid one for cross-reference bookmarks. - if(!m_pRegisteredBookmark) - { - OSL_ENSURE(false, - "" - " - could not create Mark."); - throw lang::IllegalArgumentException(); - } - // <-- + m_pImpl->m_sMarkName = OUString::createFromAscii("Bookmark"); } - else + if ((eType == IDocumentMarkAccess::BOOKMARK) && + ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_pImpl->m_sMarkName)) + { + eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; + } + else if ((eType == IDocumentMarkAccess::BOOKMARK) && + ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_pImpl->m_sMarkName)) + { + eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; + } + m_pImpl->registerInMark(*this, + m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark( + aPam, m_pImpl->m_sMarkName, eType)); + // --> OD 2007-10-23 #i81002# + // Check, if bookmark has been created. + // E.g., the creation of a cross-reference bookmark is suppress, + // if the PaM isn't a valid one for cross-reference bookmarks. + if (!m_pImpl->m_pRegisteredBookmark) + { + OSL_ENSURE(false, + "" + " - could not create Mark."); throw lang::IllegalArgumentException(); + } + // <-- } -void SwXBookmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SwXBookmark::attachToRange( + const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { attachToRangeEx(xTextRange, IDocumentMarkAccess::BOOKMARK); } -void SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); attachToRange( xTextRange ); } -uno::Reference< text::XTextRange > SwXBookmark::getAnchor(void) - throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXBookmark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - if(m_pRegisteredBookmark) - aRet = SwXTextRange::CreateTextRangeFromPosition( - m_pDoc, - m_pRegisteredBookmark->GetMarkPos(), - m_pRegisteredBookmark->IsExpanded() ? &m_pRegisteredBookmark->GetOtherMarkPos() : NULL); - else + + if (!m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); - return aRet; + } + return SwXTextRange::CreateTextRangeFromPosition( + m_pImpl->m_pDoc, + m_pImpl->m_pRegisteredBookmark->GetMarkPos(), + (m_pImpl->m_pRegisteredBookmark->IsExpanded()) + ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL); } -void SwXBookmark::dispose(void) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(m_pRegisteredBookmark) - GetDoc()->getIDocumentMarkAccess()->deleteMark(m_pRegisteredBookmark); - else - throw uno::RuntimeException(); + if (m_pImpl->m_pRegisteredBookmark) + { + m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark( + m_pImpl->m_pRegisteredBookmark); + } } -void SwXBookmark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!m_pRegisteredBookmark) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); - m_aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } -void SwXBookmark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!m_pRegisteredBookmark || !m_aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_pRegisteredBookmark || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } -OUString SwXBookmark::getName(void) - throw(uno::RuntimeException) +OUString SAL_CALL SwXBookmark::getName() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - OUString sRet; - if(m_pRegisteredBookmark) - sRet = m_pRegisteredBookmark->GetName(); - else - sRet = m_aName; - return sRet; + + return (m_pImpl->m_pRegisteredBookmark) + ? m_pImpl->m_pRegisteredBookmark->GetName() + : m_pImpl->m_sMarkName; } -void SwXBookmark::setName(const OUString& rName) - throw(uno::RuntimeException) +void SAL_CALL SwXBookmark::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!m_pRegisteredBookmark) - m_aName = rName; - if(!m_pRegisteredBookmark || getName() == rName) + + if (!m_pImpl->m_pRegisteredBookmark) + { + m_pImpl->m_sMarkName = rName; + } + if (!m_pImpl->m_pRegisteredBookmark || (getName() == rName)) + { return; - IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess(); + } + IDocumentMarkAccess *const pMarkAccess = + m_pImpl->m_pDoc->getIDocumentMarkAccess(); if(pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd()) + { throw uno::RuntimeException(); + } - SwPaM aPam(m_pRegisteredBookmark->GetMarkPos()); - if(m_pRegisteredBookmark->IsExpanded()) + SwPaM aPam(m_pImpl->m_pRegisteredBookmark->GetMarkPos()); + if (m_pImpl->m_pRegisteredBookmark->IsExpanded()) { aPam.SetMark(); - *aPam.GetMark() = m_pRegisteredBookmark->GetOtherMarkPos(); + *aPam.GetMark() = m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos(); } SwRewriter aRewriter; @@ -259,114 +379,145 @@ void SwXBookmark::setName(const OUString& rName) aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS)); aRewriter.AddRule(UNDO_ARG3, lcl_QuoteName(rName)); - m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); - pMarkAccess->renameMark(m_pRegisteredBookmark, rName); - m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); + m_pImpl->m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); + pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName); + m_pImpl->m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); } -OUString SwXBookmark::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXBookmark::getImplementationName() throw (uno::RuntimeException) { return OUString::createFromAscii("SwXBookmark"); } -sal_Bool SwXBookmark::supportsService(const OUString& rServiceName) - throw( uno::RuntimeException ) +static char const*const g_ServicesBookmark[] = { - return !rServiceName.compareToAscii("com.sun.star.text.Bookmark") || - !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); -} - -uno::Sequence< OUString > SwXBookmark::getSupportedServiceNames(void) - throw( uno::RuntimeException ) + "com.sun.star.text.TextContent", + "com.sun.star.text.Bookmark", + "com.sun.star.document.LinkTarget", +}; +static const size_t g_nServicesBookmark( + sizeof(g_ServicesBookmark)/sizeof(g_ServicesBookmark[0])); + +sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(3); - aRet[0] = OUString::createFromAscii("com.sun.star.text.Bookmark"); - aRet[1] = OUString::createFromAscii("com.sun.star.document.LinkTarget"); - aRet[2] = OUString::createFromAscii("com.sun.star.text.TextContent"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesBookmark, g_ServicesBookmark, rServiceName); } -void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +uno::Sequence< OUString > SAL_CALL +SwXBookmark::getSupportedServiceNames() throw (uno::RuntimeException) { - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - { - m_pRegisteredBookmark = NULL; - m_pDoc = NULL; - m_aLstnrCntnr.Disposing(); - } + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesBookmark, g_ServicesBookmark); } // MetadatableMixin ::sfx2::Metadatable* SwXBookmark::GetCoreObject() { - return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() ); + return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark); } uno::Reference SwXBookmark::GetModel() { - if (GetDoc()) + if (m_pImpl->m_pDoc) { - SwDocShell const * const pShell( GetDoc()->GetDocShell() ); + SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() ); return (pShell) ? pShell->GetModel() : 0; } return 0; } -uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXBookmark::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > aRef; - if(!aRef.is()) - { - aRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK)->getPropertySetInfo(); - } - return aRef; + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef( + aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK) + ->getPropertySetInfo() ); + return xRef; } -void SwXBookmark::setPropertyValue(const OUString& PropertyName, const uno::Any& /*aValue*/) - throw( beans::UnknownPropertyException, - beans::PropertyVetoException, - lang::IllegalArgumentException, - lang::WrappedTargetException, - uno::RuntimeException ) +void SAL_CALL +SwXBookmark::setPropertyValue(const OUString& PropertyName, + const uno::Any& /*rValue*/) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { // nothing to set here - throw IllegalArgumentException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + PropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 ); + throw lang::IllegalArgumentException( ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + PropertyName, static_cast< cppu::OWeakObject * >(this), 0 ); } -uno::Any SwXBookmark::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXBookmark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + uno::Any aRet; if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) + { aRet <<= getName(); + } } return aRet; } -void SwXBookmark::addPropertyChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::addPropertyChangeListener(): not implemented"); +} -void SwXBookmark::removePropertyChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::removePropertyChangeListener(): not implemented"); +} -void SwXBookmark::addVetoableChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::addVetoableChangeListener(): not implemented"); +} -void SwXBookmark::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::removeVetoableChangeListener(): not implemented"); +} + +/****************************************************************** + * SwXFieldmark + ******************************************************************/ SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc) : SwXFieldmark_Base(pBkm, pDc) @@ -436,3 +587,4 @@ void SAL_CALL SwXFieldmark::setDescription( const ::rtl::OUString& description ) else throw uno::RuntimeException(); } + diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 745d28165c..3a471e133a 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1529,8 +1529,9 @@ uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex) uno::Any aRet; ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get(); - uno::Reference< XTextContent > xRef = GetObject(*pBkmk, GetDoc()); - aRet.setValue(&xRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), *pBkmk); + aRet <<= xRef; return aRet; } @@ -1547,8 +1548,9 @@ uno::Any SwXBookmarks::getByName(const rtl::OUString& rName) throw NoSuchElementException(); uno::Any aRet; - uno::Reference< XTextContent > xRef = SwXBookmarks::GetObject(*(ppBkmk->get()), GetDoc()); - aRet.setValue(&xRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), *(ppBkmk->get())); + aRet <<= xRef; return aRet; } @@ -1594,27 +1596,6 @@ sal_Bool SwXBookmarks::hasElements(void) return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0; } -SwXBookmark* SwXBookmarks::GetObject( ::sw::mark::IMark& rBkmk, SwDoc* pDoc) -{ - SwModify* const pModify = static_cast(&rBkmk); - SwXBookmark* pXBkmk = (SwXBookmark*)SwClientIter(*pModify).First(TYPE(SwXBookmark)); - if(!pXBkmk) - { - // FIXME: These belong in XTextFieldsSupplier - //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) - // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); - //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) - // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); - //else - OSL_ENSURE( - dynamic_cast< ::sw::mark::IBookmark* >(&rBkmk), - "" - "SwXBookmark requested for non-bookmark mark."); - pXBkmk = new SwXBookmark(&rBkmk, pDoc); - } - return pXBkmk; -} - /****************************************************************** * ******************************************************************/ diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 2cff59cf41..931038335d 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -100,8 +100,9 @@ namespace BYTE nBkmType; const SwPosition aPosition; - SwXBookmarkPortion_Impl( SwXBookmark* pXMark, BYTE nType, const SwPosition &rPosition ) - : xBookmark ( pXMark ) + SwXBookmarkPortion_Impl(uno::Reference const& xMark, + const BYTE nType, SwPosition const& rPosition) + : xBookmark ( xMark ) , nBkmType ( nType ) , aPosition ( rPosition ) { @@ -165,7 +166,9 @@ namespace { const BYTE nType = hasOther ? BKM_TYPE_START : BKM_TYPE_START_END; rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( - new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject(*pBkmk, &rDoc ), nType, rStartPos))); + new SwXBookmarkPortion_Impl( + SwXBookmark::CreateXBookmark(rDoc, *pBkmk), + nType, rStartPos))); } const SwPosition& rEndPos = pBkmk->GetMarkEnd(); @@ -183,8 +186,12 @@ namespace pEndPos = pCrossRefEndPos.get(); } if(pEndPos) + { rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( - new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject(*pBkmk, &rDoc ), BKM_TYPE_END, *pEndPos))); + new SwXBookmarkPortion_Impl( + SwXBookmark::CreateXBookmark(rDoc, *pBkmk), + BKM_TYPE_END, *pEndPos))); + } } } } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 19f1aa0dea..8d84296790 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -433,19 +433,14 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg if(xBkm.is() && xIfcTunnel.is()) { - SwXBookmark* pBkm = reinterpret_cast( - xIfcTunnel->getSomething(SwXBookmark::getUnoTunnelId())); - if(pBkm && pBkm->GetDoc() == pDoc) + ::sw::mark::IMark const*const pMark( + SwXBookmark::GetBookmarkInDoc(pDoc, xIfcTunnel) ); + if (pMark) { - IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); - IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(pBkm->getName()); - if( ppMark != pMarkAccess->getMarksEnd() ) - { - rSh.EnterStdMode(); - rSh.GotoMark( ppMark->get() ); - } - return sal_True; + rSh.EnterStdMode(); + rSh.GotoMark(pMark); } + return sal_True; } // IndexMark, Index, TextField, Draw, Section, Footnote, Paragraph // -- cgit v1.2.3 From b76a788b6b8891e51bfaed31d3ee605dc721d46c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:50 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXParagraph: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. make SwXParagraph instances reusable with a WeakReference in SwTxtNode. make constructor private, and add factory function CreateXParagraph. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/ndtxt.hxx | 20 +- sw/inc/unoparagraph.hxx | 75 +- sw/source/core/txtnode/ndtxt.cxx | 31 +- sw/source/core/unocore/unodraw.cxx | 4 +- sw/source/core/unocore/unoobj2.cxx | 16 +- sw/source/core/unocore/unoparagraph.cxx | 1163 +++++++++++++++++++------------ sw/source/core/unocore/unotext.cxx | 15 +- 7 files changed, 775 insertions(+), 549 deletions(-) diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 37aa87b202..635052103e 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -30,6 +30,8 @@ #ifndef _NDTXT_HXX #define _NDTXT_HXX +#include + #include "swdllapi.h" #include #include @@ -76,9 +78,12 @@ class SwScriptInfo; struct SwDocStat; struct SwParaIdleData_Impl; -namespace com { namespace sun { namespace star { namespace uno { - template < class > class Sequence; -}}}} +namespace com { namespace sun { namespace star { + namespace uno { + template < class > class Sequence; + } + namespace text { class XTextContent; } +} } } typedef std::set< xub_StrLen > SwSoftPageBreakList; @@ -132,6 +137,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable SwList* mpList; // <-- + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> m_wXParagraph; SW_DLLPRIVATE SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl, const SfxItemSet* pAutoAttr = 0 ); @@ -813,6 +820,13 @@ public: USHORT GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) const; + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> const& GetXParagraph() const + { return m_wXParagraph; } + SW_DLLPRIVATE void SetXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> const& xParagraph) + { m_wXParagraph = xParagraph; } + // sfx2::Metadatable virtual ::sfx2::IXmlIdRegistry& GetRegistry(); virtual bool IsInClipboard() const; diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index 984786b0d1..d5c5e2ed28 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -48,12 +48,11 @@ #include #include -#include #include -class SfxItemPropertySet; struct SwPosition; +class SwPaM; class SwUnoCrsr; class SwStartNode; class SwTxtNode; @@ -80,73 +79,41 @@ typedef ::cppu::ImplInheritanceHelper10 class SwXParagraph : public SwXParagraph_Base - , public SwClient { private: - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::rtl::OUString m_sText; - sal_Int32 nSelectionStartPos; - sal_Int32 nSelectionEndPos; - BOOL m_bIsDescriptor; - -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 >& rValues) - 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); - - ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL - GetPropertyValuesTolerant_Impl( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames, - sal_Bool bDirectValuesOnly) - throw (::com::sun::star::uno::RuntimeException); + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXParagraph(); + SwXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const & xParent, + SwTxtNode & rTxtNode, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1); + public: + /// descriptor SwXParagraph(); - SwXParagraph(::com::sun::star::uno::Reference< - ::com::sun::star::text::XText > const & i_xParent, - SwTxtNode * i_pTxtNode, - sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); - BOOL IsDescriptor() const {return m_bIsDescriptor;} + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> + CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const& xParentText = 0, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1); const SwTxtNode * GetTxtNode() const; - SwTxtNode * GetTxtNode(); - - static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const ::rtl::OUString& rPropertyName, USHORT nWID = 0); - static SwXParagraph* GetImplementation( - ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XInterface> xRef); + bool IsDescriptor() const; + /// make rPaM select the paragraph + bool SelectPaM(SwPaM & rPaM); + /// for SwXText void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); - TYPEINFO(); - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static bool getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); // MetadatableMixin virtual ::sfx2::Metadatable* GetCoreObject(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 4ed6861b54..713bc64f15 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -3623,6 +3623,12 @@ void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) } m_bNotifiable = bWasNotifiable; + + if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which())) + { // invalidate cached uno object + SetXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>(0)); + } } SwFmtColl* SwTxtNode::ChgFmtColl( SwFmtColl *pNewColl ) @@ -4973,27 +4979,14 @@ bool SwTxtNode::IsInContent() const } #include -#include -::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +using namespace ::com::sun::star; + +uno::Reference< rdf::XMetadatable > SwTxtNode::MakeUnoObject() { - // re-use existing SwXParagraph - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXParagraph ) ) ); - while (pClient) { - SwXParagraph *pPara( dynamic_cast(pClient) ); - if (pPara && pPara->GetCoreObject() == this ) { - return pPara; - } - pClient = iter.Next(); - } - - // create new SwXParagraph - SwPosition Pos( *this ); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent( - SwXTextRange::CreateParentXText( GetDoc(), Pos ) ); - SwXParagraph * pXPara( new SwXParagraph( xParent, this ) ); - return pXPara; + const uno::Reference xMeta( + SwXParagraph::CreateXParagraph(*GetDoc(), *this), uno::UNO_QUERY); + return xMeta; } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 67c7249571..06c1961c73 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2158,7 +2158,9 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) pDoc = pPortion->GetCursor()->GetDoc(); } else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) ) - pDoc = pParagraph->GetTxtNode( )->GetDoc( ); + { + pDoc = const_cast(pParagraph->GetTxtNode()->GetDoc()); + } } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 2f94bf2da6..342e078290 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1169,9 +1169,9 @@ uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Imp } else { - aRef = new SwXParagraph(static_cast(pText), - pStart->nNode.GetNode().GetTxtNode(), - nFirstContent, nLastContent); + aRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), + *pStart->nNode.GetNode().GetTxtNode(), + static_cast(pText), nFirstContent, nLastContent); } } } @@ -1528,15 +1528,7 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, { if (pPara) { - const SwTxtNode * pTxtNode( pPara->GetTxtNode() ); - - if (pTxtNode) { - bRet = sal_True; - *rToFill.GetPoint() = SwPosition( *pTxtNode ); - // set selection to the whole paragraph - rToFill.SetMark(); - rToFill.GetMark()->nContent = pTxtNode->GetTxt().Len(); - } + bRet = pPara->SelectPaM(rToFill); } else { diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index c83920d101..683366fc6d 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -31,13 +31,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include #include #include #include #include -#include #include #include #include @@ -60,6 +60,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; @@ -69,38 +70,38 @@ using ::rtl::OUString; ---------------------------------------------------------------------------*/ class SwParaSelection { - SwCursor* m_pCursor; + SwCursor & m_rCursor; public: - SwParaSelection(SwCursor* pPam); + SwParaSelection(SwCursor & rCursor); ~SwParaSelection(); }; -SwParaSelection::SwParaSelection(SwCursor* pCursor) - : m_pCursor(pCursor) +SwParaSelection::SwParaSelection(SwCursor & rCursor) + : m_rCursor(rCursor) { - if (m_pCursor->HasMark()) + if (m_rCursor.HasMark()) { - m_pCursor->DeleteMark(); + m_rCursor.DeleteMark(); } // is it at the start? - if (m_pCursor->GetPoint()->nContent != 0) + if (m_rCursor.GetPoint()->nContent != 0) { - m_pCursor->MovePara(fnParaCurr, fnParaStart); + m_rCursor.MovePara(fnParaCurr, fnParaStart); } // or at the end already? - if (m_pCursor->GetPoint()->nContent != m_pCursor->GetCntntNode()->Len()) + if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len()) { - m_pCursor->SetMark(); - m_pCursor->MovePara(fnParaCurr, fnParaEnd); + m_rCursor.SetMark(); + m_rCursor.MovePara(fnParaCurr, fnParaEnd); } } SwParaSelection::~SwParaSelection() { - if (m_pCursor->GetPoint()->nContent != 0) + if (m_rCursor.GetPoint()->nContent != 0) { - m_pCursor->DeleteMark(); - m_pCursor->MovePara(fnParaCurr, fnParaStart); + m_rCursor.DeleteMark(); + m_rCursor.MovePara(fnParaCurr, fnParaStart); } } @@ -114,25 +115,184 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) - throw( beans::UnknownPropertyException); + throw (beans::UnknownPropertyException); /****************************************************************** * SwXParagraph ******************************************************************/ -TYPEINIT1(SwXParagraph, SwClient); +class SwXParagraph::Impl + : public SwClient +{ -/* -----------------------------11.07.00 12:10-------------------------------- +public: + SwXParagraph & m_rThis; + SwEventListenerContainer m_ListenerContainer; + SfxItemPropertySet const& m_rPropSet; + bool m_bIsDescriptor; + sal_Int32 m_nSelectionStartPos; + sal_Int32 m_nSelectionEndPos; + ::rtl::OUString m_sText; + uno::Reference m_xParentText; + + Impl( SwXParagraph & rThis, + SwTxtNode *const pTxtNode = 0, + uno::Reference< text::XText > const & xParent = 0, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1) + : SwClient(pTxtNode) + , m_rThis(rThis) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)) + , m_bIsDescriptor(0 == pTxtNode) + , m_nSelectionStartPos(nSelStart) + , m_nSelectionEndPos(nSelEnd) + , m_xParentText(xParent) + { + } - ---------------------------------------------------------------------------*/ -SwXParagraph* SwXParagraph::GetImplementation(uno::Reference< XInterface> xRef ) + const SwTxtNode * GetTxtNode() const { + return static_cast(GetRegisteredIn()); + } + SwTxtNode * GetTxtNode() { + return static_cast(pRegisteredIn); + } + + SwTxtNode & GetTxtNodeOrThrow() { + SwTxtNode *const pTxtNode( GetTxtNode() ); + if (!pTxtNode) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXParagraph: disposed or invalid")), 0); + } + return *pTxtNode; + } + + bool IsDescriptor() const { return m_bIsDescriptor; } + + void SetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& rValues) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException); + + uno::Sequence< uno::Any > + GetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException); + + uno::Sequence< beans::GetDirectPropertyTolerantResult > + GetPropertyValuesTolerant_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + bool bDirectValuesOnly) + throw (uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 11.12.98 08:12:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXParagraph::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) + { + m_ListenerContainer.Disposing(); + } +} + +/*-- 11.12.98 08:12:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::SwXParagraph() + : m_pImpl( new SwXParagraph::Impl(*this) ) +{ +} + +/*-- 11.12.98 08:12:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::SwXParagraph( + uno::Reference< text::XText > const & xParent, + SwTxtNode & rTxtNode, + const sal_Int32 nSelStart, const sal_Int32 nSelEnd) + : m_pImpl( + new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd)) { - uno::Reference xParaTunnel( xRef, uno::UNO_QUERY); - if(xParaTunnel.is()) - return reinterpret_cast< SwXParagraph * >( - sal::static_int_cast< sal_IntPtr >( xParaTunnel->getSomething(SwXParagraph::getUnoTunnelId()) )); - return 0; } + +/*-- 11.12.98 08:12:48--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::~SwXParagraph() +{ +} + +const SwTxtNode * SwXParagraph::GetTxtNode() const +{ + return m_pImpl->GetTxtNode(); +} + +bool SwXParagraph::IsDescriptor() const +{ + return m_pImpl->IsDescriptor(); +} + +uno::Reference +SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, + uno::Reference< text::XText> const& i_xParent, + const sal_Int32 nSelStart, const sal_Int32 nSelEnd) +{ + // re-use existing SwXParagraph + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference xParagraph; + if ((-1 == nSelStart) && (-1 == nSelEnd)) // only use cache if no selection! + { + xParagraph.set(rTxtNode.GetXParagraph()); + } + if (xParagraph.is()) + { + return xParagraph; + } + + // create new SwXParagraph + uno::Reference xParentText(i_xParent); + if (!xParentText.is()) + { + SwPosition Pos( rTxtNode ); + xParentText.set(SwXTextRange::CreateParentXText( &rDoc, Pos )); + } + SwXParagraph *const pXPara( + new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) ); + // this is why the constructor is private: need to acquire pXPara here + xParagraph.set(pXPara); + // in order to initialize the weak pointer cache in the core object + if ((-1 == nSelStart) && (-1 == nSelEnd)) + { + rTxtNode.SetXParagraph(xParagraph); + } + return xParagraph; +} + +bool SwXParagraph::SelectPaM(SwPaM & rPaM) +{ + SwTxtNode const*const pTxtNode( GetTxtNode() ); + + if (!pTxtNode) + { + return false; + } + + *rPaM.GetPoint() = SwPosition( *pTxtNode ); + // set selection to the whole paragraph + rPaM.SetMark(); + rPaM.GetMark()->nContent = pTxtNode->GetTxt().Len(); + return true; +} + /* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ @@ -144,191 +304,176 @@ const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXParagraph::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } -/* -----------------------------06.04.00 16:37-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXParagraph::getImplementationName(void) throw( uno::RuntimeException ) -{ - return C2U("SwXParagraph"); -} /* -----------------------------06.04.00 16:37-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParagraph::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXParagraph::getImplementationName() throw (uno::RuntimeException) { - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextContent") || - sServiceName.EqualsAscii("com.sun.star.text.Paragraph") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex"); + return C2U("SwXParagraph"); } /* -----------------------------06.04.00 16:37-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXParagraph::getSupportedServiceNames(void) throw( uno::RuntimeException ) +static char const*const g_ServicesParagraph[] = { - uno::Sequence< OUString > aRet(8); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Paragraph"); - pArray[1] = C2U("com.sun.star.style.CharacterProperties"); - pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); - pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); - pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); - pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); - pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - pArray[7] = C2U("com.sun.star.text.TextContent"); - return aRet; -} -/*-- 11.12.98 08:12:47--------------------------------------------------- + "com.sun.star.text.TextContent", + "com.sun.star.text.Paragraph", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", +}; +static const size_t g_nServicesParagraph( + sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0])); - -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph() : - xParentText(0), - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), - nSelectionStartPos(-1), - nSelectionEndPos(-1), - m_bIsDescriptor(TRUE) +sal_Bool SAL_CALL +SwXParagraph::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesParagraph, g_ServicesParagraph, rServiceName); } +/* -----------------------------06.04.00 16:37-------------------------------- -/*-- 11.12.98 08:12:47--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph(uno::Reference< text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart, sal_Int32 nSelEnd) : - SwClient(i_pTxtNode), - xParentText(i_xParent), - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), - nSelectionStartPos(nSelStart), - nSelectionEndPos(nSelEnd), - m_bIsDescriptor(FALSE) + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParagraph, g_ServicesParagraph); } -/*-- 11.12.98 08:12:48--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXParagraph::~SwXParagraph() -{ -} /* -----------------------------11.07.00 14:48-------------------------------- ---------------------------------------------------------------------------*/ void SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode) { - DBG_ASSERT(m_bIsDescriptor, "Paragraph is not a descriptor"); - if(m_bIsDescriptor) + DBG_ASSERT(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor"); + if (m_pImpl->m_bIsDescriptor) { - m_bIsDescriptor = FALSE; - rTxtNode.Add(this); - xParentText = &rParent; - if(m_sText.getLength()) + m_pImpl->m_bIsDescriptor = false; + rTxtNode.Add(m_pImpl.get()); + rTxtNode.SetXParagraph(uno::Reference(this)); + m_pImpl->m_xParentText = &rParent; + if (m_pImpl->m_sText.getLength()) { - try { setString(m_sText); } + try { setString(m_pImpl->m_sText); } catch(...){} - m_sText = OUString(); + m_pImpl->m_sText = OUString(); } } } + /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXParagraph::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXParagraph::getPropertySetInfo() +throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xRef; } /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::setPropertyValue(const OUString& rPropertyName, + const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; uno::Sequence aValues(1); - aValues.getArray()[0] = aValue; - SetPropertyValues_Impl( aPropertyNames, aValues ); + aValues.getArray()[0] = rValue; + m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); } + /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraph::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any +SwXParagraph::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - uno::Sequence< uno::Any > aRet = GetPropertyValues_Impl(aPropertyNames ); + const uno::Sequence< uno::Any > aRet = + m_pImpl->GetPropertyValues_Impl(aPropertyNames); return aRet.getConstArray()[0]; } /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SAL_CALL SwXParagraph::SetPropertyValues_Impl( +void SwXParagraph::Impl::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - if (GetTxtNode()) + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + const uno::Any* pValues = rValues.getConstArray(); + SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); + SwParaSelection aParaSel( aCursor ); + for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { - SwPosition aPos( *GetTxtNode() ); - SwCursor aCursor( aPos, 0, false ); - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const uno::Any* pValues = rValues.getConstArray(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - SwParaSelection aParaSel( & aCursor ); - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pPropertyNames[nProp] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - else - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - - SwXTextCursor::SetPropertyValue(aCursor, *m_pPropSet, - pPropertyNames[nProp], pValues[nProp]); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); } + SwXTextCursor::SetPropertyValue(aCursor, m_rPropSet, + pPropertyNames[nProp], pValues[nProp]); } - else - throw uno::RuntimeException(); } -void SwXParagraph::setPropertyValues( +void SAL_CALL SwXParagraph::setPropertyValues( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) +throw (beans::PropertyVetoException, lang::IllegalArgumentException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); // workaround for bad designed API try { - SetPropertyValues_Impl( rPropertyNames, rValues ); + m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); } catch (beans::UnknownPropertyException &rException) { @@ -339,53 +484,57 @@ void SwXParagraph::setPropertyValues( throw aWExc; } } + /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( +uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl( const uno::Sequence< OUString > & rPropertyNames ) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); + uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + SwPosition aPos( rTxtNode ); + SwPaM aPam( aPos ); + uno::Any* pValues = aValues.getArray(); + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); + const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() ); + for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { - SwPosition aPos( *pTxtNode ); - SwPaM aPam( aPos ); - uno::Any* pValues = aValues.getArray(); - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - const SwAttrSet& rAttrSet( pTxtNode->GetSwAttrSet() ); - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pPropertyNames[nProp] ); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); + } + if (!SwXParagraph::getDefaultTextContentValue( + pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); - if(pEntry) + beans::PropertyState eTemp; + const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode ); + if (!bDone) { - if(!SwXParagraph::getDefaultTextContentValue( - pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) - { - BOOL bDone = FALSE; - beans::PropertyState eTemp; - bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, aPam, &(pValues[nProp]), eTemp, pTxtNode ); - if(!bDone) - m_pPropSet->getPropertyValue(*pEntry, rAttrSet, pValues[nProp]); - } + m_rPropSet.getPropertyValue( + *pEntry, rAttrSet, pValues[nProp]); } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); } } - else - throw uno::RuntimeException(); return aValues; } + /* -----------------------------04.11.03 11:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Any > SwXParagraph::getPropertyValues( - const uno::Sequence< OUString >& rPropertyNames ) - throw(uno::RuntimeException) +uno::Sequence< uno::Any > SAL_CALL +SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< uno::Any > aValues; @@ -393,67 +542,82 @@ uno::Sequence< uno::Any > SwXParagraph::getPropertyValues( // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); } catch (beans::UnknownPropertyException &) { - throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "Unknown property exception caught")), + static_cast(this)); } catch (lang::WrappedTargetException &) { - throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "WrappedTargetException caught")), + static_cast(this)); } return aValues; } + /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::addPropertiesChangeListener( +void SAL_CALL SwXParagraph::addPropertiesChangeListener( const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException) -{} +throw (uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXParagraph::addPropertiesChangeListener(): not implemented"); +} /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::removePropertiesChangeListener( +void SAL_CALL SwXParagraph::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException) -{} +throw (uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXParagraph::removePropertiesChangeListener(): not implemented"); +} /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::firePropertiesChangeEvent( +void SAL_CALL SwXParagraph::firePropertiesChangeEvent( const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(uno::RuntimeException) -{} +{ + OSL_ENSURE(false, + "SwXParagraph::firePropertiesChangeEvent(): not implemented"); +} /* -----------------------------25.09.03 11:09-------------------------------- ---------------------------------------------------------------------------*/ /* disabled for #i46921# */ -uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setPropertyValuesTolerant( +uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL +SwXParagraph::setPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); if (rPropertyNames.getLength() != rValues.getLength()) + { throw lang::IllegalArgumentException(); + } - const SwTxtNode * const pTxtNode( GetTxtNode() ); - if (!pTxtNode) - throw uno::RuntimeException(); + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet(); //USHORT nAttrCount = rAttrSet.Count(); - sal_Int32 nProps = rPropertyNames.getLength(); + const sal_Int32 nProps = rPropertyNames.getLength(); const OUString *pProp = rPropertyNames.getConstArray(); //sal_Int32 nVals = rValues.getLength(); @@ -464,31 +628,39 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray(); // get entry to start with - const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); + SfxItemPropertyMap const*const pPropMap = + m_pImpl->m_rPropSet.getPropertyMap(); OUString sTmp; - SwPosition aPos( *pTxtNode ); + SwPosition aPos( rTxtNode ); SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); for (sal_Int32 i = 0; i < nProps; ++i) { try { pFailed[ nFailed ].Name = pProp[i]; - const SfxItemPropertySimpleEntry* pEntry = pPropMap->getByName( pProp[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pPropMap->getByName( pProp[i] ); if (!pEntry) - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + { + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + } else { // set property value // (compare to SwXParagraph::setPropertyValues) if (pEntry->nFlags & beans::PropertyAttribute::READONLY) - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; + { + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::PROPERTY_VETO; + } else { SwXTextCursor::SetPropertyValue( - aCursor, *m_pPropSet, pProp[i], pValue[i] ); + aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]); } } } @@ -496,19 +668,23 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp { // should not occur because property was searched for before DBG_ERROR( "unexpected exception catched" ); - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; } catch (lang::IllegalArgumentException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; } catch (beans::PropertyVetoException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::PROPERTY_VETO; } catch (lang::WrappedTargetException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::WRAPPED_TARGET; } } @@ -517,52 +693,56 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp } -uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXParagraph::getPropertyValuesTolerant( +uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL +SwXParagraph::getPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames ) - throw (uno::RuntimeException) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( - GetPropertyValuesTolerant_Impl( rPropertyNames, sal_False ) ); - const beans::GetDirectPropertyTolerantResult *pTmpRes = aTmpRes.getConstArray(); + m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) ); + const beans::GetDirectPropertyTolerantResult *pTmpRes = + aTmpRes.getConstArray(); // copy temporary result to final result type - sal_Int32 nLen = aTmpRes.getLength(); + const sal_Int32 nLen = aTmpRes.getLength(); uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen ); beans::GetPropertyTolerantResult *pRes = aRes.getArray(); for (sal_Int32 i = 0; i < nLen; i++) + { *pRes++ = *pTmpRes++; + } return aRes; } -uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::getDirectPropertyValuesTolerant( +uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL +SwXParagraph::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames ) - throw (uno::RuntimeException) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); - return GetPropertyValuesTolerant_Impl( rPropertyNames, sal_True ); + + return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true ); } -uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::GetPropertyValuesTolerant_Impl( +uno::Sequence< beans::GetDirectPropertyTolerantResult > +SwXParagraph::Impl::GetPropertyValuesTolerant_Impl( const uno::Sequence< OUString >& rPropertyNames, - sal_Bool bDirectValuesOnly ) - throw (uno::RuntimeException) + bool bDirectValuesOnly ) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); - const SwTxtNode * const pTxtNode( GetTxtNode() ); - DBG_ASSERT( pTxtNode != NULL, "need text node" ); - if (!pTxtNode) - throw uno::RuntimeException(); + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); // #i46786# Use SwAttrSet pointer for determining the state. // Use the value SwAttrSet (from the paragraph OR the style) // for determining the actual value(s). - const SwAttrSet* pAttrSet = pTxtNode->GetpSwAttrSet(); - const SwAttrSet& rValueAttrSet = pTxtNode->GetSwAttrSet(); + const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet(); + const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet(); sal_Int32 nProps = rPropertyNames.getLength(); const OUString *pProp = rPropertyNames.getConstArray(); @@ -572,7 +752,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G sal_Int32 nIdx = 0; // get entry to start with - const SfxItemPropertyMap *pPropMap = m_pPropSet->getPropertyMap(); + SfxItemPropertyMap const*const pPropMap = m_rPropSet.getPropertyMap(); for (sal_Int32 i = 0; i < nProps; ++i) { @@ -583,23 +763,28 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G { rResult.Name = pProp[i]; - const SfxItemPropertySimpleEntry* pEntry = pPropMap->getByName( pProp[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pPropMap->getByName( pProp[i] ); if (!pEntry) // property available? - rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + { + rResult.Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + } else { // get property state // (compare to SwXParagraph::getPropertyState) sal_Bool bAttrSetFetched = sal_True; beans::PropertyState eState = lcl_SwXParagraph_getPropertyState( - *pTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); + rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); rResult.State = eState; // if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState) // rResult.Result = beans::TolerantPropertySetResultType::NO_DIRECT_VALUE; // else rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; - if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == eState) + if (!bDirectValuesOnly || + (beans::PropertyState_DIRECT_VALUE == eState)) { // get property value // (compare to SwXParagraph::getPropertyValue(s)) @@ -607,18 +792,21 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G if (!SwXParagraph::getDefaultTextContentValue( aValue, pProp[i], pEntry->nWID ) ) { - SwPosition aPos( *pTxtNode ); + SwPosition aPos( rTxtNode ); SwPaM aPam( aPos ); // handle properties that are not part of the attribute // and thus only pretendend to be paragraph attributes - BOOL bDone = FALSE; beans::PropertyState eTemp; - bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, aPam, &aValue, eTemp, pTxtNode ); + const bool bDone = + SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, aPam, &aValue, eTemp, &rTxtNode ); // if not found try the real paragraph attributes... if (!bDone) - m_pPropSet->getPropertyValue( *pEntry, rValueAttrSet, aValue ); + { + m_rPropSet.getPropertyValue( + *pEntry, rValueAttrSet, aValue ); + } } rResult.Value = aValue; @@ -661,7 +849,8 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G /* -----------------------------12.09.00 11:09-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParagraph::getDefaultTextContentValue(uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) +bool SwXParagraph::getDefaultTextContentValue( + uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) { if(!nWID) { @@ -694,35 +883,59 @@ BOOL SwXParagraph::getDefaultTextContentValue(uno::Any& rAny, const OUString& rP /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addPropertyChangeListener( - const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::addPropertyChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::removePropertyChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::addVetoableChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::removeVetoableChangeListener(): not implemented"); } + //----------------------------------------------------------------------------- beans::PropertyState lcl_SwXParagraph_getPropertyState( // SwUnoCrsr& rUnoCrsr, @@ -730,7 +943,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) - throw( beans::UnknownPropertyException) +throw (beans::UnknownPropertyException) { beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; @@ -786,348 +999,393 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( /*-- 05.03.99 11:37:30--------------------------------------------------- -----------------------------------------------------------------------*/ -beans::PropertyState SwXParagraph::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +beans::PropertyState SAL_CALL +SwXParagraph::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - const SwTxtNode * const pTxtNode( GetTxtNode() ); - if (pTxtNode) + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + const SwAttrSet* pSet = 0; + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - const SwAttrSet* pSet = 0; - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - sal_Bool bDummy = sal_False; - eRet = lcl_SwXParagraph_getPropertyState( *pTxtNode, &pSet, *pEntry, - bDummy ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); } - else - throw uno::RuntimeException(); + sal_Bool bDummy = sal_False; + const beans::PropertyState eRet = + lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy); return eRet; } /*-- 05.03.99 11:37:32--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( +uno::Sequence< beans::PropertyState > SAL_CALL +SwXParagraph::getPropertyStates( const uno::Sequence< OUString >& PropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + const OUString* pNames = PropertyNames.getConstArray(); uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); + SfxItemPropertyMap const*const pMap = m_pImpl->m_rPropSet.getPropertyMap(); + const SwAttrSet* pSet = 0; + sal_Bool bAttrSetFetched = sal_False; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; + ++i, ++pStates, ++pNames) { - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - const SwAttrSet* pSet = 0; - sal_Bool bAttrSetFetched = sal_False; - for(sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++,++pStates,++pNames ) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( *pNames ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( *pNames ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + *pNames, static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + *pNames, + static_cast(this)); + } - if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) - { - *pStates = beans::PropertyState_DEFAULT_VALUE; - } - else - { - *pStates = lcl_SwXParagraph_getPropertyState( - *pTxtNode, &pSet, *pEntry, bAttrSetFetched ); - } + if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) + { + *pStates = beans::PropertyState_DEFAULT_VALUE; + } + else + { + *pStates = lcl_SwXParagraph_getPropertyState( + rTxtNode, &pSet, *pEntry, bAttrSetFetched ); } } - else - throw uno::RuntimeException(); return aRet; } + /*-- 05.03.99 11:37:33--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || - rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || - rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) - return; + return; + } - // select paragraph - SwParaSelection aParaSel( & aCursor ); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(pEntry) - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw uno::RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only:" ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + // select paragraph + SwParaSelection aParaSel( aCursor ); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( rPropertyName ); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } - if(pEntry->nWID < RES_FRMATR_END) + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast(this)); + } + + if (pEntry->nWID < RES_FRMATR_END) + { + SvUShortsSort aWhichIds; + aWhichIds.Insert(pEntry->nWID); + if (pEntry->nWID < RES_PARATR_BEGIN) + { + aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); + } + else + { + // for paragraph attributes the selection must be extended + // to paragraph boundaries + SwPosition aStart( *aCursor.Start() ); + SwPosition aEnd ( *aCursor.End() ); + ::std::auto_ptr pTemp( + aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); + if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) { - SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); - if(pEntry->nWID < RES_PARATR_BEGIN) - { - aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); - } - else - { - // for paragraph attributes the selection must be extended - // to paragraph boundaries - SwPosition aStart( *aCursor.Start() ); - SwPosition aEnd ( *aCursor.End() ); - std::auto_ptr pTemp( - aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); - if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) - { - pTemp->MovePara(fnParaCurr, fnParaStart); - } - pTemp->SetMark(); - *pTemp->GetPoint() = aEnd; - //pTemp->Exchange(); - SwXTextCursor::SelectPam(*pTemp, sal_True); - if(!SwUnoCursorHelper::IsEndOfPara(*pTemp)) - { - pTemp->MovePara(fnParaCurr, fnParaEnd); - } - pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); - } + pTemp->MovePara(fnParaCurr, fnParaStart); } - else + pTemp->SetMark(); + *pTemp->GetPoint() = aEnd; + //pTemp->Exchange(); + SwXTextCursor::SelectPam(*pTemp, sal_True); + if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) { - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + pTemp->MovePara(fnParaCurr, fnParaEnd); } + pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); } else - throw uno::RuntimeException(); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + } } + /*-- 05.03.99 11:37:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXParagraph::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + uno::Any aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + if (SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) { - if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) - return aRet; + return aRet; + } - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(pEntry) - { - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = - pTxtNode->GetDoc()->GetAttrPool().GetDefaultItem( - pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } - } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } + + if (pEntry->nWID < RES_FRMATR_END) + { + const SfxPoolItem& rDefItem = + rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } - else - throw uno::RuntimeException(); return aRet; } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // SwXParagraph will only created in order to be inserteb by + // SwXParagraph will only created in order to be inserted by // 'insertTextContentBefore' or 'insertTextContentAfter' therefore // they cannot be attached throw uno::RuntimeException(); } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - // select paragraph - SwParaSelection aParaSel( & aCursor ); - aRet = new SwXTextRange(aCursor, xParentText); - } - else - throw uno::RuntimeException(); - return aRet; + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + // select paragraph + SwParaSelection aParaSel( aCursor ); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aCursor, m_pImpl->m_xParentText); + return xRet; } + /*-- 11.12.98 08:12:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTxtNode * pTxtNode( GetTxtNode() ); + + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); if (pTxtNode) { SwCursor aCursor( SwPosition( *pTxtNode ), 0, false ); // select paragraph { - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); pTxtNode->GetDoc()->DelFullPara(aCursor); } - aLstnrCntnr.Disposing(); + m_pImpl->m_ListenerContainer.Disposing(); } - else - throw uno::RuntimeException(); } + /*-- 11.12.98 08:12:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetTxtNode()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 11.12.98 08:12:53--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetTxtNode() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /*-- 11.12.98 08:12:53--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXParagraph::createEnumeration(void) throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXParagraph::createEnumeration() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwPaM aPam ( aPos ); - aRef = new SwXTextPortionEnumeration(aPam, xParentText, - nSelectionStartPos, nSelectionEndPos); - } - else - throw uno::RuntimeException(); - return aRef; + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwPaM aPam ( aPos ); + const uno::Reference< container::XEnumeration > xRef = + new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText, + m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos); + return xRef; } + /*-- 11.12.98 08:12:54--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXParagraph::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /*-- 11.12.98 08:12:54--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParagraph::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); return (GetTxtNode()) ? sal_True : sal_False; } + /*-- 11.12.98 08:12:55--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXParagraph::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXParagraph::getText() throw (uno::RuntimeException) { - return xParentText; + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->m_xParentText; } + /*-- 11.12.98 08:12:55--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( &aCursor ); - SwPaM aPam( *aCursor.Start() ); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else - throw uno::RuntimeException(); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( aCursor ); + SwPaM aPam( *aCursor.Start() ); + uno::Reference< text::XText > xParent = getText(); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 08:12:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( &aCursor ); - SwPaM aPam( *aCursor.End() ); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else - throw uno::RuntimeException(); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( aCursor ); + SwPaM aPam( *aCursor.End() ); + uno::Reference< text::XText > xParent = getText(); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xParent); return xRet; } + /*-- 11.12.98 08:12:56--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); OUString aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode const*const pTxtNode( GetTxtNode() ); if (pTxtNode) { SwPosition aPos( *pTxtNode ); SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); SwXTextCursor::getTextFromPam(aCursor, aRet); } - else if(IsDescriptor()) - aRet = m_sText; + else if (m_pImpl->IsDescriptor()) + { + aRet = m_pImpl->m_sText; + } else + { throw uno::RuntimeException(); + } return aRet; } /*-- 11.12.98 08:12:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::setString(const OUString& aString) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode const*const pTxtNode( GetTxtNode() ); if (pTxtNode) { SwPosition aPos( *pTxtNode ); @@ -1142,23 +1400,33 @@ void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeExcepti SwXTextCursor::SetString(aCursor, aString); SwXTextCursor::SelectPam(aCursor, sal_False); } - else if(IsDescriptor()) - m_sText = aString; + else if (m_pImpl->IsDescriptor()) + { + m_pImpl->m_sText = aString; + } else + { throw uno::RuntimeException(); - + } } + /* -----------------23.03.99 12:49------------------- * * --------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeration(const OUString& rServiceName) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXParagraph::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) { - const SwTxtNode * pTxtNode( GetTxtNode() ); - if(!pTxtNode || !rServiceName.equalsAscii("com.sun.star.text.TextContent")) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) + { throw uno::RuntimeException(); + } - SwPosition aPos( *pTxtNode ); + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); SwPaM aPam( aPos ); uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH); @@ -1167,50 +1435,31 @@ uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeratio /* -----------------23.03.99 12:49------------------- * * --------------------------------------------------*/ -uno::Sequence< OUString > SwXParagraph::getAvailableServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException) { uno::Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextContent"); return aRet; } -/*-- 11.12.98 08:12:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXParagraph::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); -} - -const SwTxtNode * SwXParagraph::GetTxtNode() const -{ - return static_cast(GetRegisteredIn()); -} -SwTxtNode * SwXParagraph::GetTxtNode() -{ - return static_cast(pRegisteredIn); -} +// MetadatableMixin ::sfx2::Metadatable* SwXParagraph::GetCoreObject() { - SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); return pTxtNode; } uno::Reference SwXParagraph::GetModel() { - SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); if (pTxtNode) { - const SwDocShell * pShell( pTxtNode->GetDoc()->GetDocShell() ); + SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() ); return (pShell) ? pShell->GetModel() : 0; } - else - { - return 0; - } + return 0; } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index b758f9104b..d81664310a 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -666,7 +666,10 @@ void SwXText::insertTextContentBefore( throw aRuntime; } - SwXParagraph* pPara = SwXParagraph::GetImplementation(xNewContent); + const uno::Reference xParaTunnel(xNewContent, + uno::UNO_QUERY); + SwXParagraph *const pPara = + ::sw::UnoTunnelGetImplementation(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) throw lang::IllegalArgumentException(); @@ -718,7 +721,10 @@ void SwXText::insertTextContentAfter( vos::OGuard aGuard(Application::GetSolarMutex()); if(!GetDoc()) throw uno::RuntimeException(); - SwXParagraph* pPara = SwXParagraph::GetImplementation(xNewContent); + const uno::Reference xParaTunnel(xNewContent, + uno::UNO_QUERY); + SwXParagraph *const pPara = + ::sw::UnoTunnelGetImplementation(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) throw lang::IllegalArgumentException(); @@ -1414,7 +1420,10 @@ uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( } SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); OSL_ENSURE(pTxtNode, "no SwTxtNode?"); - xRet = new SwXParagraph(this, pTxtNode); + if (pTxtNode) + { + xRet.set(SwXParagraph::CreateXParagraph(*pDoc, *pTxtNode, this), uno::UNO_QUERY); + } } return xRet; -- cgit v1.2.3 From 6018f5f979b4f375fa4141c8e8f6a0e936befb9e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:51 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXParagraphEnumeration: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoparagraph.hxx | 56 +---- sw/source/core/unocore/unoframe.cxx | 7 +- sw/source/core/unocore/unoftn.cxx | 8 +- sw/source/core/unocore/unoobj2.cxx | 445 ++++++++++++++++++++-------------- sw/source/core/unocore/unoredline.cxx | 8 +- sw/source/core/unocore/unotbl.cxx | 13 +- sw/source/core/unocore/unotext.cxx | 15 +- 7 files changed, 303 insertions(+), 249 deletions(-) diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index d5c5e2ed28..b14aeb7dc3 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -32,6 +32,8 @@ #ifndef SW_UNOPARAGRAPH_HXX #define SW_UNOPARAGRAPH_HXX +#include + #include #include #include @@ -47,16 +49,13 @@ #include -#include #include struct SwPosition; class SwPaM; class SwUnoCrsr; -class SwStartNode; class SwTxtNode; -class SwTable; class SwXText; @@ -327,60 +326,23 @@ public: --------------------------------------------------*/ class SwXParagraphEnumeration : public SwSimpleEnumeration_Base - , public SwClient { private: - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - xNextPara; - - const SwTable * pOwnTable; - /// Start node of the cell the enumeration belongs to. - /// Used to restrict the movement of the UNO cursor to the cell and its - /// embedded tables. - const SwStartNode * pOwnStartNode; - sal_Int32 nFirstParaStart; - sal_Int32 nLastParaEnd; - ULONG nEndIndex; - CursorType eCursorType; - BOOL bFirstParagraph; - - SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} - -protected: + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXParagraphEnumeration(); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextContent > SAL_CALL - NextElement_Impl() - throw (::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - public: + /// takes ownership of cursor SwXParagraphEnumeration( - SwXText* pParent, SwPosition& rPos, CursorType eType); - SwXParagraphEnumeration( - SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); - - // non-Uno functions - - void SetOwnTable(const SwTable* pTable) - { pOwnTable = pTable; } - const SwTable* GetOwnTable() const - { return pOwnTable; } - void SetOwnStartNode(const SwStartNode* pNode) - { pOwnStartNode = pNode; } - const SwStartNode* GetOwnStartNode() const - { return pOwnStartNode; } - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const & xParent, + ::std::auto_ptr pCursor, + const CursorType eType); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index f4d7ea34be..5457e7d0f5 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2700,14 +2700,15 @@ uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void) if(pFmt) { SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode()); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); // // no Cursor in protected sections // SwCrsrSaveState aSave( *pUnoCrsr ); // if(pUnoCrsr->IsInProtectTable( sal_True ) || // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS )) // throw uno::RuntimeException() ); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_FRAME); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME); } return aRef; } diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 7c0f8adbe3..4f07cebed1 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -439,10 +439,10 @@ uno::Reference< container::XEnumeration > SwXFootnote::createEnumeration() thro { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor* pXCrsr = new SwXTextCursor(this, aPos, CURSOR_FOOTNOTE, GetDoc()); - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_FOOTNOTE); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); } return aRef; } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 342e078290..23f4a043a5 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -699,28 +699,22 @@ uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( Ru sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); } DBG_ASSERT(pParentText, "parent is not a SwXText"); + if (!pParentText) + { + throw uno::RuntimeException(); + } - SwUnoCrsr* pNewCrsr = pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()); + ::std::auto_ptr pNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); if(pUnoCrsr->HasMark()) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); } - CursorType eSetType = eType == CURSOR_TBLTEXT ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - SwXParagraphEnumeration *pEnum = + const CursorType eSetType = (CURSOR_TBLTEXT == eType) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); - uno::Reference< XEnumeration > xRet = pEnum; - if (eType == CURSOR_TBLTEXT) - { - // for import of tables in tables we have to remember the actual - // table and start node of the current position in the enumeration. - SwTableNode *pStartN = pUnoCrsr->GetPoint()->nNode.GetNode().FindTableNode(); - if (pStartN) - { - pEnum->SetOwnTable( &pStartN->GetTable() ); - pEnum->SetOwnStartNode( pStartN ); - } - } return xRet; } @@ -959,103 +953,180 @@ void SwXTextCursor::GetCrsrAttr( SwPaM& rPam, /****************************************************************** * SwXParagraphEnumeration ******************************************************************/ -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXParagraphEnumeration::getImplementationName(void) throw( RuntimeException ) +static SwStartNode * +lcl_InitStartNode(const CursorType eType, SwUnoCrsr *const pCursor) { - return C2U("SwXParagraphEnumeration"); + switch (eType) + { + case CURSOR_TBLTEXT: // table cell: pCursor points at first paragraph + return pCursor->Start()->nNode.GetNode().StartOfSectionNode(); + case CURSOR_SELECTION_IN_TABLE: // table + return pCursor->Start()->nNode.GetNode().FindTableNode(); + default: + return 0; + } } -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXParagraphEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +static SwTable const* +lcl_InitTable(const CursorType eType, SwStartNode const*const pStartNode) { - return C2U("com.sun.star.text.ParagraphEnumeration") == rServiceName; -} -/* -----------------------------06.04.00 16:33-------------------------------- + switch (eType) + { + case CURSOR_TBLTEXT: // table cell + return & pStartNode->FindTableNode()->GetTable(); + case CURSOR_SELECTION_IN_TABLE: // table + return & static_cast(pStartNode)->GetTable(); + default: + return 0; + } +} + +class SwXParagraphEnumeration::Impl + : public SwClient +{ + +public: + + uno::Reference< text::XText > const m_xParentText; + const CursorType m_eCursorType; + /// Start node of the cell _or_ table the enumeration belongs to. + /// Used to restrict the movement of the UNO cursor to the cell and its + /// embedded tables. + SwStartNode const*const m_pOwnStartNode; + SwTable const*const m_pOwnTable; + const ULONG m_nEndIndex; + sal_Int32 m_nFirstParaStart; + sal_Int32 m_nLastParaEnd; + bool m_bFirstParagraph; + uno::Reference< text::XTextContent > m_xNextPara; + + Impl( uno::Reference< text::XText > const& xParent, + ::std::auto_ptr pCursor, + const CursorType eType) + : SwClient( pCursor.release() ) + , m_xParentText( xParent ) + , m_eCursorType( eType ) + // remember table and start node for later travelling + // (used in export of tables in tables) + , m_pOwnStartNode( lcl_InitStartNode(eType, GetCursor()) ) + // for import of tables in tables we have to remember the actual + // table and start node of the current position in the enumeration. + , m_pOwnTable( lcl_InitTable(eType, m_pOwnStartNode) ) + , m_nEndIndex( GetCursor()->End()->nNode.GetIndex() ) + , m_nFirstParaStart( -1 ) + , m_nLastParaEnd( -1 ) + , m_bFirstParagraph( true ) + { + OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?"); + OSL_ENSURE(GetRegisteredIn(), "SwXParagraphEnumeration: no cursor?"); - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParagraphEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.ParagraphEnumeration"); - return aRet; -} -/*-- 10.12.98 11:52:12--------------------------------------------------- + if ((CURSOR_SELECTION == m_eCursorType) || + (CURSOR_SELECTION_IN_TABLE == m_eCursorType)) + { + SwUnoCrsr & rCursor = *GetCursor(); + rCursor.Normalize(); + m_nFirstParaStart = rCursor.GetPoint()->nContent.GetIndex(); + m_nLastParaEnd = rCursor.GetMark()->nContent.GetIndex(); + rCursor.DeleteMark(); + } + } - -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::SwXParagraphEnumeration(SwXText* pParent, - SwPosition& rPos, - CursorType eType) : - xParentText(pParent), - nFirstParaStart(-1), - nLastParaEnd(-1), - nEndIndex(rPos.nNode.GetIndex()), - eCursorType(eType), - bFirstParagraph(sal_True) -{ - pOwnTable = 0; - pOwnStartNode = 0; - SwUnoCrsr* pUnoCrsr = pParent->GetDoc()->CreateUnoCrsr(rPos, sal_False); - pUnoCrsr->Add(this); + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast( + const_cast(GetRegisteredIn())); + } + + uno::Reference< text::XTextContent > NextElement_Impl() + throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXParagraphEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); } /*-- 10.12.98 11:52:12--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::SwXParagraphEnumeration(SwXText* pParent, - SwUnoCrsr* pCrsr, - CursorType eType) : - SwClient(pCrsr), - xParentText(pParent), - nFirstParaStart(-1), - nLastParaEnd(-1), - nEndIndex(pCrsr->End()->nNode.GetIndex()), - eCursorType(eType), - bFirstParagraph(sal_True) -{ - pOwnTable = 0; - pOwnStartNode = 0; - if(CURSOR_SELECTION == eCursorType || CURSOR_SELECTION_IN_TABLE == eCursorType) - { - if(*pCrsr->GetPoint() > *pCrsr->GetMark()) - pCrsr->Exchange(); - nFirstParaStart = pCrsr->GetPoint()->nContent.GetIndex(); - nLastParaEnd = pCrsr->GetMark()->nContent.GetIndex(); - if(pCrsr->HasMark()) - pCrsr->DeleteMark(); - } +SwXParagraphEnumeration::SwXParagraphEnumeration( + uno::Reference< text::XText > const& xParent, + ::std::auto_ptr pCursor, + const CursorType eType) + : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType) ) +{ } /*-- 10.12.98 11:52:12--------------------------------------------------- -----------------------------------------------------------------------*/ SwXParagraphEnumeration::~SwXParagraphEnumeration() { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - delete pUnoCrsr; +} + +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXParagraphEnumeration::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXParagraphEnumeration"); +} +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesParagraphEnum[] = +{ + "com.sun.star.text.ParagraphEnumeration", +}; +static const size_t g_nServicesParagraphEnum( + sizeof(g_ServicesParagraphEnum)/sizeof(g_ServicesParagraphEnum[0])); +sal_Bool SAL_CALL +SwXParagraphEnumeration::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesParagraphEnum, g_ServicesParagraphEnum, rServiceName); } +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParagraphEnumeration::getSupportedServiceNames() +throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParagraphEnum, g_ServicesParagraphEnum); +} + /*-- 10.12.98 11:52:13--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParagraphEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXParagraphEnumeration::hasMoreElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - return bFirstParagraph ? sal_True : xNextPara.is(); + + return (m_pImpl->m_bFirstParagraph) ? sal_True : m_pImpl->m_xNextPara.is(); } /*-- 14.08.03 13:10:14--------------------------------------------------- -----------------------------------------------------------------------*/ //!! compare to SwShellTableCrsr::FillRects() in viscrs.cxx -SwTableNode * lcl_FindTopLevelTable( - /*SwUnoCrsr* pUnoCrsr ,*/ - SwTableNode *pTblNode, - const SwTable *pOwnTable ) +static SwTableNode * +lcl_FindTopLevelTable( + SwTableNode *const pTblNode, SwTable const*const pOwnTable) { // find top-most table in current context (section) level @@ -1070,14 +1141,14 @@ SwTableNode * lcl_FindTopLevelTable( } -BOOL lcl_CursorIsInSection( - const SwUnoCrsr *pUnoCrsr, - const SwStartNode *pOwnStartNode ) +static bool +lcl_CursorIsInSection( + SwUnoCrsr const*const pUnoCrsr, SwStartNode const*const pOwnStartNode) { // returns true if the cursor is in the section (or in a sub section!) // represented by pOwnStartNode - BOOL bRes = TRUE; + bool bRes = true; if (pUnoCrsr && pOwnStartNode) { const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode(); @@ -1088,124 +1159,134 @@ BOOL lcl_CursorIsInSection( } -uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Impl(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Reference< text::XTextContent > +SwXParagraphEnumeration::Impl::NextElement_Impl() +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { - uno::Reference< XTextContent > aRef; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr *const pUnoCrsr = GetCursor(); + if (!pUnoCrsr) { - // check for exceeding selections - if(!bFirstParagraph && - (CURSOR_SELECTION == eCursorType || CURSOR_SELECTION_IN_TABLE == eCursorType)) + throw uno::RuntimeException(); + } + + // check for exceeding selections + if (!m_bFirstParagraph && + ((CURSOR_SELECTION == m_eCursorType) || + (CURSOR_SELECTION_IN_TABLE == m_eCursorType))) + { + SwPosition* pStart = pUnoCrsr->Start(); + const ::std::auto_ptr aNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) ); + // one may also go into tables here + if ((CURSOR_TBLTEXT != m_eCursorType) && + (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) { - SwPosition* pStart = pUnoCrsr->Start(); - ::std::auto_ptr aNewCrsr( pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) ); - //man soll hier auch in Tabellen landen duerfen - if(CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) - aNewCrsr->SetRemainInSection( sal_False ); - - // os 2005-01-14: This part is only necessary to detect movements out of a selection - // if there is no selection we don't have to care - SwTableNode* pTblNode = aNewCrsr->GetNode()->FindTableNode(); - if((CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) && pTblNode) - { - aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); - aNewCrsr->Move(fnMoveForward, fnGoNode); - } - else - aNewCrsr->MovePara(fnParaNext, fnParaStart); - if(nEndIndex < aNewCrsr->Start()->nNode.GetIndex()) - return aRef; // empty reference + aNewCrsr->SetRemainInSection( sal_False ); } - XText* pText = xParentText.get(); - sal_Bool bInTable = sal_False; - if(!bFirstParagraph) + // os 2005-01-14: This part is only necessary to detect movements out + // of a selection; if there is no selection we don't have to care + SwTableNode *const pTblNode = aNewCrsr->GetNode()->FindTableNode(); + if (((CURSOR_TBLTEXT != m_eCursorType) && + (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) && pTblNode) { - //man soll hier auch in Tabellen landen duerfen - //if(CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) - { - //BOOL bRemain = sal_False; - //pUnoCrsr->SetRemainInSection( bRemain ); - pUnoCrsr->SetRemainInSection( sal_False ); - //was mache ich, wenn ich schon in einer Tabelle stehe? - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - pTblNode = lcl_FindTopLevelTable( /*pUnoCrsr,*/ pTblNode, pOwnTable ); - if(pTblNode && &pTblNode->GetTable() != pOwnTable) - { - // wir haben es mit einer fremden Tabelle zu tun - also ans Ende - pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); - if(!pUnoCrsr->Move(fnMoveForward, fnGoNode)) - return aRef; - else - bInTable = sal_True; - - } - } + aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); + aNewCrsr->Move(fnMoveForward, fnGoNode); } + else + { + aNewCrsr->MovePara(fnParaNext, fnParaStart); + } + if (m_nEndIndex < aNewCrsr->Start()->nNode.GetIndex()) + { + return 0; + } + } - // the cursor must remain in the current section or a subsection - // before AND after the movement... - if( lcl_CursorIsInSection( pUnoCrsr, pOwnStartNode ) && - (bFirstParagraph || bInTable || - (pUnoCrsr->MovePara(fnParaNext, fnParaStart) && - lcl_CursorIsInSection( pUnoCrsr, pOwnStartNode ) ) ) ) + sal_Bool bInTable = sal_False; + if (!m_bFirstParagraph) + { + pUnoCrsr->SetRemainInSection( sal_False ); + // what to do if already in a table? + SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable ); + if (pTblNode && (&pTblNode->GetTable() != m_pOwnTable)) { - SwPosition* pStart = pUnoCrsr->Start(); - sal_Int32 nFirstContent = bFirstParagraph ? nFirstParaStart : -1; - sal_Int32 nLastContent = nEndIndex == pStart->nNode.GetIndex() ? nLastParaEnd : -1; - //steht man nun in einer Tabelle, oder in einem einfachen Absatz? - - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - pTblNode = lcl_FindTopLevelTable( /*pUnoCrsr,*/ pTblNode, pOwnTable ); - if(/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */ - pTblNode && &pTblNode->GetTable() != pOwnTable) + // this is a foreign table: go to end + pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); + if (!pUnoCrsr->Move(fnMoveForward, fnGoNode)) { - // wir haben es mit einer fremden Tabelle zu tun - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - XTextTable* pTable = SwXTextTables::GetObject( *pTableFmt ); - aRef = (XTextContent*)(SwXTextTable*)pTable; - } - else - { - aRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), - *pStart->nNode.GetNode().GetTxtNode(), - static_cast(pText), nFirstContent, nLastContent); + return 0; } + bInTable = sal_True; } } - else - throw uno::RuntimeException(); - return aRef; + uno::Reference< text::XTextContent > xRef; + // the cursor must remain in the current section or a subsection + // before AND after the movement... + if (lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode ) && + (m_bFirstParagraph || bInTable || + (pUnoCrsr->MovePara(fnParaNext, fnParaStart) && + lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode )))) + { + SwPosition* pStart = pUnoCrsr->Start(); + const sal_Int32 nFirstContent = + (m_bFirstParagraph) ? m_nFirstParaStart : -1; + const sal_Int32 nLastContent = + (m_nEndIndex == pStart->nNode.GetIndex()) ? m_nLastParaEnd : -1; + + // position in a table, or in a simple paragraph? + SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable ); + if (/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */ + pTblNode && (&pTblNode->GetTable() != m_pOwnTable)) + { + // this is a foreign table + SwFrmFmt* pTableFmt = + static_cast(pTblNode->GetTable().GetFrmFmt()); + text::XTextTable *const pTable = + SwXTextTables::GetObject( *pTableFmt ); + xRef = static_cast( + static_cast(pTable)); + } + else + { + text::XText *const pText = m_xParentText.get(); + xRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), + *pStart->nNode.GetNode().GetTxtNode(), + static_cast(pText), nFirstContent, nLastContent); + } + } + + return xRef; } /*-- 10.12.98 11:52:14--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraphEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXParagraphEnumeration::nextElement() +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextContent > aRef; - if (bFirstParagraph) + if (m_pImpl->m_bFirstParagraph) { - xNextPara = NextElement_Impl(); - bFirstParagraph = sal_False; + m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl(); + m_pImpl->m_bFirstParagraph = false; } - aRef = xNextPara; - if (!aRef.is()) + const uno::Reference< text::XTextContent > xRef = m_pImpl->m_xNextPara; + if (!xRef.is()) + { throw container::NoSuchElementException(); - xNextPara = NextElement_Impl(); + } + m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl(); - uno::Any aRet(&aRef, ::getCppuType((uno::Reference*)0)); + uno::Any aRet; + aRet <<= xRef; return aRet; } -void SwXParagraphEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} /****************************************************************** * SwXTextRange @@ -1727,7 +1808,7 @@ uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( Runt ::sw::mark::IMark const * const pBkmk = GetBookmark(); if(!pBkmk) throw RuntimeException(); const SwPosition& rPoint = pBkmk->GetMarkPos(); - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPoint, FALSE); + ::std::auto_ptr pNewCrsr(pDoc->CreateUnoCrsr(rPoint, sal_False)); if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) { pNewCrsr->SetMark(); @@ -1741,8 +1822,14 @@ uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( Runt sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); } DBG_ASSERT(pParentText, "parent is not a SwXText"); - CursorType eSetType = RANGE_IN_CELL == eRangePosition ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - uno::Reference< XEnumeration > xRet = + if (!pParentText) + { + throw uno::RuntimeException(); + } + + const CursorType eSetType = (RANGE_IN_CELL == eRangePosition) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); return xRet; } diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index bbd81aa140..6f7ee5ff68 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -198,7 +198,9 @@ uno::Reference SwXRedlineText::createEnumeration(void) vos::OGuard aGuard(Application::GetSolarMutex()); SwPaM aPam(aNodeIndex); aPam.Move(fnMoveForward, fnGoNode); - return new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(*aPam.Start(), sal_False)); + return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE); } /* --------------------------------------------------------------------------- @@ -681,7 +683,9 @@ uno::Reference< container::XEnumeration > SwXRedline::createEnumeration(void) t { SwPaM aPam(*pNodeIndex); aPam.Move(fnMoveForward, fnGoNode); - xRet = new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(*aPam.Start(), sal_False)); + xRet = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE); } return xRet; } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e594ba50d6..049f2c5662 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1214,15 +1214,12 @@ uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) thro { const SwStartNode* pSttNd = pBox->GetSttNd(); SwPosition aPos(*pSttNd); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); - SwXParagraphEnumeration *pEnum = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_TBLTEXT); - const SwTableNode* pTblNode = pSttNd->FindTableNode(); - // remember table and start node for later travelling - // (used in export of tables in tables) - pEnum->SetOwnTable( &pTblNode->GetTable() ); - pEnum->SetOwnStartNode( pSttNd ); + SwXParagraphEnumeration *const pEnum = + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT); aRef = pEnum; // // no Cursor in protected sections diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index d81664310a..6a669499e7 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2412,9 +2412,10 @@ uno::Reference< container::XEnumeration > SwXBodyText::createEnumeration(void) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_BODY); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveBackward, fnGoDoc); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); } else { @@ -2653,9 +2654,11 @@ uno::Reference< container::XEnumeration > SwXHeadFootText::createEnumeration(vo const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); SwPosition aPos(rNode); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); } else { -- cgit v1.2.3 From 6fb8fe3272621a26de9d81f3cc15b5e335a166f0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:51 +0100 Subject: 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. --- sw/inc/frmfmt.hxx | 19 +- sw/inc/section.hxx | 20 + sw/inc/unosection.hxx | 102 +- sw/source/core/docnode/section.cxx | 5 + sw/source/core/layout/atrfrm.cxx | 5 + sw/source/core/unocore/unocoll.cxx | 13 +- sw/source/core/unocore/unosect.cxx | 2427 ++++++++++++++++++++---------------- sw/source/core/unocore/unotext.cxx | 20 +- 8 files changed, 1413 insertions(+), 1198 deletions(-) diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 12ef87e948..9b77c79991 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -30,11 +30,14 @@ #ifndef _FRMFMT_HXX #define _FRMFMT_HXX -#include - // --> OD 2004-08-06 #i28749# #include // <-- + +#include + +#include + #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) }; diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 4d883e8464..47633d4208 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -41,6 +41,11 @@ #include #include + +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 --------------------------------- diff --git a/sw/inc/unosection.hxx b/sw/inc/unosection.hxx index 31d15d7010..6f3eb1794c 100644 --- a/sw/inc/unosection.hxx +++ b/sw/inc/unosection.hxx @@ -43,14 +43,9 @@ #include -#include -#include +#include -#include -#include - -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; - - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; + class Impl; + ::sw::UnoImplPtr m_pImpl; - 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(); diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 23dffa13ac..2d92d0e5b7 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -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(0)); + } } // erfrage vom Format Informationen diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 37c75c2f71..cd834bacd7 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -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(0)); + } } //Vernichtet alle Frms, die in aDepend angemeldet sind. diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 3a471e133a..d62b7837cc 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -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 ) diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index c2b706250c..c47a3aef13 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -71,182 +72,171 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; using ::rtl::OUString; -TYPEINIT1(SwXTextSectionClient, SwClient); -/*-- 20.12.2005 09:56:33--------------------------------------------------- +/****************************************************************** + * + ******************************************************************/ +struct SwTextSectionProperties_Impl +{ + uno::Sequence m_Password; + ::rtl::OUString m_sCondition; + ::rtl::OUString m_sLinkFileName; + ::rtl::OUString m_sSectionFilter; + ::rtl::OUString m_sSectionRegion; + + ::std::auto_ptr m_pColItem; + ::std::auto_ptr m_pBrushItem; + ::std::auto_ptr m_pFtnItem; + ::std::auto_ptr m_pEndItem; + ::std::auto_ptr m_pXMLAttr; + ::std::auto_ptr m_pNoBalanceItem; + ::std::auto_ptr m_pFrameDirItem; + ::std::auto_ptr m_pLRSpaceItem; // #109700# + + bool m_bDDE; + bool m_bHidden; + bool m_bCondHidden; + bool m_bProtect; + // --> FME 2004-06-22 #114856# edit in readonly sections + bool m_bEditInReadonly; + // <-- + bool m_bUpdateType; - -----------------------------------------------------------------------*/ -SwXTextSectionClient::SwXTextSectionClient( - SwSectionFmt& rFmt, - SwXTextSection& rTextSection, - uno::Reference< text::XTextSection > xSection ) : - SwClient(&rFmt), - m_pSection( &rTextSection ), - m_xReference( xSection ) + SwTextSectionProperties_Impl() + : m_bDDE(false) + , m_bHidden(false) + , m_bCondHidden(false) + , m_bProtect(false) + // --> FME 2004-06-22 #114856# edit in readonly sections + , m_bEditInReadonly(false) + // <-- + , m_bUpdateType(true) + { + } -{ - m_pSection->SetClient( this ); -} -/*-- 20.12.2005 09:56:33--------------------------------------------------- +}; - -----------------------------------------------------------------------*/ -SwXTextSectionClient::~SwXTextSectionClient() + +class SwXTextSection::Impl + : public SwClient { - uno::Reference< text::XTextSection > xSection( m_xReference ); - if(xSection.is()) + +public: + + SwXTextSection & m_rThis; + const SfxItemPropertySet & m_rPropSet; + SwEventListenerContainer m_ListenerContainer; + const bool m_bIndexHeader; + bool m_bIsDescriptor; + ::rtl::OUString m_sName; + ::std::auto_ptr m_pProps; + + Impl( SwXTextSection & rThis, + SwSectionFmt *const pFmt, const bool bIndexHeader) + : SwClient(pFmt) + , m_rThis(rThis) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIndexHeader(bIndexHeader) + , m_bIsDescriptor(0 == pFmt) + , m_pProps((pFmt) ? 0 : new SwTextSectionProperties_Impl()) { - m_pSection->SetClient( 0 ); } -} -/*-- 20.12.2005 09:56:35--------------------------------------------------- - -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSectionClient::GetXTextSection() -{ - return uno::Reference< text::XTextSection >( m_xReference ); -} + SwSectionFmt * GetSectionFmt() const + { + return static_cast(const_cast( + GetRegisteredIn())); + } -/*-- 29.12.2005 11:29:30--------------------------------------------------- + SwSectionFmt & GetSectionFmtOrThrow() const { + SwSectionFmt *const pFmt( GetSectionFmt() ); + if (!pFmt) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXTextSection: disposed or invalid")), 0); + } + return *pFmt; + } - -----------------------------------------------------------------------*/ -/*SwXTextSection* SwXTextSectionClient::GetSwTextSection() -{ - if( m_xReference.is() ) - return m_pSection;; -} */ + void SAL_CALL SetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& aValues) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException); + uno::Sequence< uno::Any > SAL_CALL + GetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; /*-- 10.12.98 14:42:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSectionClient::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SwXTextSection::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT && - (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - ((SwModify*)GetRegisteredIn())->Remove(this); - else - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) { - uno::Reference< text::XTextSection > xSection( m_xReference ); - if(xSection.is()) - { - m_pSection->SetClient( 0 ); - m_pSection->aLstnrCntnr.Disposing(); - m_xReference = uno::Reference< text::XTextSection >(); - - Application::PostUserEvent( - STATIC_LINK( this, SwXTextSectionClient, RemoveSectionClient_Impl ), this ); - } + m_ListenerContainer.Disposing(); } } -/*-- 29.12.2005 13:04:57--------------------------------------------------- +/*-- 20.12.2005 10:27:33--------------------------------------------------- -----------------------------------------------------------------------*/ -IMPL_STATIC_LINK_NOINSTANCE( SwXTextSectionClient, RemoveSectionClient_Impl, - SwXTextSectionClient*, pClient ) +SwSectionFmt * SwXTextSection::GetFmt() const { - delete pClient; - return 0; + return m_pImpl->GetSectionFmt(); } /*-- 20.12.2005 09:56:36--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSectionClient::CreateXTextSection( - SwSectionFmt* pFmt, BOOL bIndexHeader ) +uno::Reference< text::XTextSection > +SwXTextSection::CreateXTextSection( + SwSectionFmt *const pFmt, const bool bIndexHeader) { - SwXTextSection* pNew; - uno::Reference< text::XTextSection > xSection = pNew = new SwXTextSection( pFmt != 0, bIndexHeader ); - if(pFmt) - new SwXTextSectionClient( *pFmt, *pNew, xSection ); + // re-use existing SwXTextSection + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XTextSection > xSection; + if (pFmt) + { + xSection.set(pFmt->GetXTextSection()); + } + if ( !xSection.is() ) + { + SwXTextSection *const pNew = new SwXTextSection(pFmt, bIndexHeader); + xSection.set(pNew); + if (pFmt) + { + pFmt->SetXTextSection(xSection); + } + } return xSection; } -/*-- 29.12.2005 10:23:37--------------------------------------------------- +/*-- 10.12.98 14:47:05--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXTextSectionClient* SwXTextSectionClient::Create(SwXTextSection& rSection, - uno::Reference< text::XTextSection >xSection, SwSectionFmt& rFmt ) +SwXTextSection::SwXTextSection( + SwSectionFmt *const pFmt, const bool bIndexHeader) + : m_pImpl( new SwXTextSection::Impl(*this, pFmt, bIndexHeader) ) { - return new SwXTextSectionClient( rFmt, rSection, xSection ); } -/****************************************************************** - * - ******************************************************************/ -struct SwTextSectionProperties_Impl -{ - - String sCondition; - String sLinkFileName; - String sSectionFilter; - String sSectionRegion; - uno::Sequence aPassword; - - SwFmtCol* pColItem; - SvxBrushItem* pBrushItem; - SwFmtFtnAtTxtEnd* pFtnItem; - SwFmtEndAtTxtEnd* pEndItem; - SvXMLAttrContainerItem *pXMLAttr; - SwFmtNoBalancedColumns *pNoBalanceItem; - SvxFrameDirectionItem *pFrameDirItem; - SvxLRSpaceItem *pLRSpaceItem; // #109700# - sal_Bool bDDE; - sal_Bool bHidden; - sal_Bool bCondHidden; - sal_Bool bProtect; - // --> FME 2004-06-22 #114856# edit in readonly sections - sal_Bool bEditInReadonly; - // <-- - sal_Bool bUpdateType; - - SwTextSectionProperties_Impl() : - pColItem(0), - pBrushItem(0), - pFtnItem(0), - pEndItem(0), - pXMLAttr(0), - pNoBalanceItem(0), - pFrameDirItem(0), - pLRSpaceItem(0), // #109700# - bDDE(0), - bHidden(0), - bCondHidden(0), - bProtect(0), - // --> FME 2004-06-22 #114856# edit in readonly sections - bEditInReadonly(0), - // <-- - bUpdateType(sal_True){} - ~SwTextSectionProperties_Impl() - { - delete pColItem; - delete pBrushItem; - delete pFtnItem; - delete pEndItem; - delete pXMLAttr; - delete pNoBalanceItem; - delete pFrameDirItem; - delete pLRSpaceItem; // #109700# - } -}; -/* -----------------------------11.07.00 12:10-------------------------------- +/*-- 10.12.98 14:47:07--------------------------------------------------- - ---------------------------------------------------------------------------*/ -SwXTextSection* SwXTextSection::GetImplementation(uno::Reference< XInterface> xRef ) + -----------------------------------------------------------------------*/ +SwXTextSection::~SwXTextSection() { - uno::Reference xTunnel( xRef, uno::UNO_QUERY); - if(xTunnel.is()) - return reinterpret_cast< SwXTextSection * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextSection::getUnoTunnelId()) )); - return 0; } /* -----------------------------13.03.00 12:15-------------------------------- @@ -260,258 +250,230 @@ const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextSection::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); - } - return 0; -} -/*-- 10.12.98 14:47:05--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXTextSection::SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader) : -// SwClient(pFmt), - aLstnrCntnr( (text::XTextContent*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)), - m_bIsDescriptor(!bWithFormat), - m_bIndexHeader(bIndexHeader), - pProps(bWithFormat ? 0 : new SwTextSectionProperties_Impl()), - m_pClient( 0 ) +sal_Int64 SAL_CALL +SwXTextSection::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - + return ::sw::UnoTunnelImpl(rId, this); } -/*-- 10.12.98 14:47:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXTextSection::~SwXTextSection() -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - delete m_pClient; - delete pProps; -} /*-- 10.12.98 14:47:08--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSection::getParentSection(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextSection > SAL_CALL +SwXTextSection::getParentSection() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextSection > aRef; - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) - { - SwSectionFmt* pParentFmt = pSectFmt->GetParent(); - if(pParentFmt) - { - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pParentFmt). - First(TYPE(SwXTextSectionClient)); - if(pClient) - aRef = pClient->GetXTextSection(); - else - aRef = SwXTextSectionClient::CreateXTextSection(pParentFmt); - } - } - else - throw uno::RuntimeException(); - return aRef; + + SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); + + SwSectionFmt *const pParentFmt = rSectionFmt.GetParent(); + const uno::Reference< text::XTextSection > xRet = + (pParentFmt) ? CreateXTextSection(pParentFmt) : 0; + return xRet; } + /*-- 10.12.98 14:47:08--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< uno::Reference< text::XTextSection > > SwXTextSection::getChildSections(void) - throw( uno::RuntimeException ) +uno::Sequence< uno::Reference< text::XTextSection > > SAL_CALL +SwXTextSection::getChildSections() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Sequence > aSeq; - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) - { - SwSections aChildren; - pSectFmt->GetChildSections(aChildren, SORTSECT_NOT, sal_False); - aSeq.realloc(aChildren.Count()); - uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); - for(sal_uInt16 i = 0; i < aChildren.Count(); i++) - { - SwSectionFmt* pChild = aChildren.GetObject(i)->GetFmt(); - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pChild). - First(TYPE(SwXTextSectionClient)); - if(pClient) - pArray[i] = pClient->GetXTextSection(); - else - pArray[i] = SwXTextSectionClient::CreateXTextSection(pChild); - } + SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); + + SwSections aChildren; + rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False); + uno::Sequence > aSeq(aChildren.Count()); + uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); + for (sal_uInt16 i = 0; i < aChildren.Count(); i++) + { + SwSectionFmt *const pChild = aChildren.GetObject(i)->GetFmt(); + pArray[i] = CreateXTextSection(pChild); } return aSeq; - } + /* -----------------18.02.99 13:31------------------- * * --------------------------------------------------*/ -void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); + } uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDoc) + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) { - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - UnoActionContext aCont(pDoc); - pDoc->StartUndo( UNDO_INSSECTION, NULL ); - - SwSection* pRet = 0; - if(!m_sName.Len()) - m_sName = C2S("TextSection"); - SectionType eType = pProps->bDDE ? DDE_LINK_SECTION : - pProps->sLinkFileName.Len() || pProps->sSectionRegion.Len() ? FILE_LINK_SECTION : - CONTENT_SECTION; - // index header section? - if(m_bIndexHeader) + throw lang::IllegalArgumentException(); + } + + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + UnoActionContext aCont(pDoc); + pDoc->StartUndo( UNDO_INSSECTION, NULL ); + + if (!m_pImpl->m_sName.getLength()) + { + m_pImpl->m_sName = C2U("TextSection"); + } + SectionType eType = (m_pImpl->m_pProps->m_bDDE) + ? DDE_LINK_SECTION + : ((m_pImpl->m_pProps->m_sLinkFileName.getLength() || + m_pImpl->m_pProps->m_sSectionRegion.getLength()) + ? FILE_LINK_SECTION : CONTENT_SECTION); + // index header section? + if (m_pImpl->m_bIndexHeader) + { + // caller wants an index header section, but will only + // give him one if a) we are inside an index, and b) said + // index doesn't yet have a header section. + const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(*aPam.Start()); + + // are we inside an index? + if (pBase) { - // caller wants an index header section, but will only - // give him one if a) we are inside an index, and b) said - // index doesn't yet have a header section. - const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX( - *aPam.Start() ); - - // are we inside an index? - if (pBase) + // get all child sections + SwSections aSectionsArr; + static_cast(pBase)->GetFmt()-> + GetChildSections(aSectionsArr); + + // and search for current header section + const sal_uInt16 nCount = aSectionsArr.Count(); + sal_Bool bHeaderPresent = sal_False; + for(sal_uInt16 i = 0; i < nCount; i++) { - // get all child sections - SwSections aSectionsArr; - ((SwTOXBaseSection*)pBase)->GetFmt()-> - GetChildSections(aSectionsArr); - - // and search for current header section - sal_uInt16 nCount = aSectionsArr.Count(); - sal_Bool bHeaderPresent = sal_False; - for(sal_uInt16 i = 0; i < nCount; i++) - { - bHeaderPresent |= - (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); - } - if (! bHeaderPresent) - { - eType = TOX_HEADER_SECTION; - } + bHeaderPresent |= + (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); + } + if (! bHeaderPresent) + { + eType = TOX_HEADER_SECTION; } } + } - SwSection aSect(eType, pDoc->GetUniqueSectionName(&m_sName)); - aSect.SetCondition(pProps->sCondition); - String sLinkName(pProps->sLinkFileName); - sLinkName += sfx2::cTokenSeperator; - sLinkName += pProps->sSectionFilter; - sLinkName += sfx2::cTokenSeperator; - sLinkName += pProps->sSectionRegion; - aSect.SetLinkFileName(sLinkName); - - aSect.SetHidden(pProps->bHidden); - aSect.SetProtect(pProps->bProtect); - // --> FME 2004-06-22 #114856# edit in readonly sections - aSect.SetEditInReadonly(pProps->bEditInReadonly); - // <-- + String tmp(m_pImpl->m_sName); + SwSection aSect(eType, pDoc->GetUniqueSectionName(&tmp)); + aSect.SetCondition(m_pImpl->m_pProps->m_sCondition); + ::rtl::OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName); + sLinkNameBuf.append(sfx2::cTokenSeperator); + sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionFilter); + sLinkNameBuf.append(sfx2::cTokenSeperator); + sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionRegion); + aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear()); + + aSect.SetHidden(m_pImpl->m_pProps->m_bHidden); + aSect.SetProtect(m_pImpl->m_pProps->m_bProtect); + // --> FME 2004-06-22 #114856# edit in readonly sections + aSect.SetEditInReadonly(m_pImpl->m_pProps->m_bEditInReadonly); + // <-- - SfxItemSet aSet(pDoc->GetAttrPool(), - RES_COL, RES_COL, - RES_BACKGROUND, RES_BACKGROUND, - RES_FTN_AT_TXTEND, RES_FRAMEDIR, - RES_LR_SPACE, RES_LR_SPACE, // #109700# - RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, - 0); - if(pProps->pBrushItem) - aSet.Put(*pProps->pBrushItem); - if(pProps->pColItem) - aSet.Put(*pProps->pColItem); - if(pProps->pFtnItem) - aSet.Put(*pProps->pFtnItem); - if(pProps->pEndItem) - aSet.Put(*pProps->pEndItem); - if(pProps->pXMLAttr) - aSet.Put(*pProps->pXMLAttr); - if(pProps->pNoBalanceItem) - aSet.Put(*pProps->pNoBalanceItem); - if(pProps->pFrameDirItem) - aSet.Put(*pProps->pFrameDirItem); - /* #109700# */ - if(pProps->pLRSpaceItem) - aSet.Put(*pProps->pLRSpaceItem); - - // section password - if (pProps->aPassword.getLength() > 0) - aSect.SetPasswd(pProps->aPassword); - - pRet = pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); - // now create the client - m_refCount++; - // keep block to remove Reference before the refcount is decremented - { - uno::Reference< text::XTextSection> xSection( this ); - m_pClient = SwXTextSectionClient::Create(*this, xSection, *pRet->GetFmt()); - } - m_refCount--; + SfxItemSet aSet(pDoc->GetAttrPool(), + RES_COL, RES_COL, + RES_BACKGROUND, RES_BACKGROUND, + RES_FTN_AT_TXTEND, RES_FRAMEDIR, + RES_LR_SPACE, RES_LR_SPACE, // #109700# + RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, + 0); + if (m_pImpl->m_pProps->m_pBrushItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pBrushItem); + } + if (m_pImpl->m_pProps->m_pColItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pColItem); + } + if (m_pImpl->m_pProps->m_pFtnItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pFtnItem); + } + if (m_pImpl->m_pProps->m_pEndItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pEndItem); + } + if (m_pImpl->m_pProps->m_pXMLAttr.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pXMLAttr); + } + if (m_pImpl->m_pProps->m_pNoBalanceItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pNoBalanceItem); + } + if (m_pImpl->m_pProps->m_pFrameDirItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pFrameDirItem); + } + /* #109700# */ + if (m_pImpl->m_pProps->m_pLRSpaceItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pLRSpaceItem); + } + // section password + if (m_pImpl->m_pProps->m_Password.getLength() > 0) + { + aSect.SetPasswd(m_pImpl->m_pProps->m_Password); + } - // #97450# XML import must hide sections depending on their old - // condition status - if( pProps->sCondition.Len() != 0 ) - pRet->SetCondHidden(pProps->bCondHidden); + SwSection *const pRet = + pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); + pRet->GetFmt()->Add(m_pImpl.get()); + pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); - // set update type if DDE link (and connect, if necessary) - if (pProps->bDDE) + // #97450# XML import must hide sections depending on their old + // condition status + if (m_pImpl->m_pProps->m_sCondition.getLength() != 0) + { + pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden); + } + + // set update type if DDE link (and connect, if necessary) + if (m_pImpl->m_pProps->m_bDDE) + { + if (! pRet->IsConnected()) { - if (! pRet->IsConnected()) - { - pRet->CreateLink(CREATE_CONNECT); - } - pRet->SetUpdateType( static_cast< USHORT >(pProps->bUpdateType ? - sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + pRet->CreateLink(CREATE_CONNECT); } - - // Undo-Klammerung hier beenden - pDoc->EndUndo( UNDO_INSSECTION, NULL ); - DELETEZ(pProps); - m_bIsDescriptor = sal_False; + pRet->SetUpdateType( static_cast< USHORT >( + (m_pImpl->m_pProps->m_bUpdateType) ? + sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); } - else - throw lang::IllegalArgumentException(); -} -/*-- 10.12.98 14:47:09--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + // Undo-Klammerung hier beenden + pDoc->EndUndo( UNDO_INSSECTION, NULL ); + m_pImpl->m_pProps.reset(); + m_pImpl->m_bIsDescriptor = false; } /*-- 10.12.98 14:47:09--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextSection::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Reference< text::XTextRange > xRet; - SwSectionFmt* pSectFmt = GetFmt(); + SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); if(pSectFmt) { const SwSection* pSect; @@ -535,677 +497,858 @@ uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno:: /*-- 10.12.98 14:47:09--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) + + SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); + if (pSectFmt) + { pSectFmt->GetDoc()->DelSectionFmt( pSectFmt ); - else - throw uno::RuntimeException(); + } } /*-- 10.12.98 14:47:10--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetFmt()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetSectionFmt()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 10.12.98 14:47:10--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetFmt() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetSectionFmt() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } /*-- 10.12.98 14:47:11--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextSection::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextSection::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static const uno::Reference< beans::XPropertySetInfo > aRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return aRef; } -/* -----------------------------12.02.01 10:29-------------------------------- - ---------------------------------------------------------------------------*/ -struct SwSectItemSet_Impl -{ - - SfxItemSet* pItemSet; - SwSectItemSet_Impl() : - pItemSet(0){} - ~SwSectItemSet_Impl() - {delete pItemSet;} -}; /* -----------------------------12.02.01 10:45-------------------------------- ---------------------------------------------------------------------------*/ -void SAL_CALL SwXTextSection::SetPropertyValues_Impl( +void SwXTextSection::Impl::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, - const uno::Sequence< Any >& rValues ) - throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, - WrappedTargetException, RuntimeException) + const uno::Sequence< uno::Any >& rValues) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - SwSectionFmt* pFmt = GetFmt(); if(rPropertyNames.getLength() != rValues.getLength()) - throw IllegalArgumentException(); - if(pFmt || m_bIsDescriptor) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - if(pFmt) - aSection = *pSect; - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const Any* pValues = rValues.getConstArray(); - SwSectItemSet_Impl aItemSet; - - sal_Bool bLinkModeChanged = sal_False; - sal_Bool bLinkMode = sal_False; - for(sal_Int16 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++) + throw lang::IllegalArgumentException(); + } + SwSectionFmt *const pFmt = GetSectionFmt(); + if (!pFmt && !m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + SwSection aSection(CONTENT_SECTION, aEmptyStr); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + if (pFmt) + { + aSection = *pSect; + } + OUString const*const pPropertyNames = rPropertyNames.getConstArray(); + uno::Any const*const pValues = rValues.getConstArray(); + ::std::auto_ptr pItemSet; + sal_Bool bLinkModeChanged = sal_False; + sal_Bool bLinkMode = sal_False; + + for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); + nProperty++) + { + SfxItemPropertySimpleEntry const*const pEntry = + m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty] ); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); - else + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProperty], + static_cast(& m_rThis)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + pPropertyNames[nProperty], + static_cast(& m_rThis)); + } + switch (pEntry->nWID) + { + case WID_SECT_CONDITION: + { + OUString uTmp; + pValues[nProperty] >>= uTmp; + if (m_bIsDescriptor) + { + m_pProps->m_sCondition = uTmp; + } + else + { + aSection.SetCondition(uTmp); + } + } + break; + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + OUString uTmp; + pValues[nProperty] >>= uTmp; + String sTmp(uTmp); + if (m_bIsDescriptor) { - case WID_SECT_CONDITION: + if (!m_pProps->m_bDDE) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - if(m_bIsDescriptor) - pProps->sCondition = String(uTmp); - else - aSection.SetCondition(uTmp); + ::rtl::OUStringBuffer buf; + buf.append(sfx2::cTokenSeperator); + buf.append(sfx2::cTokenSeperator); + m_pProps->m_sLinkFileName = buf.makeStringAndClear(); + m_pProps->m_bDDE = true; + } + String sLinkFileName(m_pProps->m_sLinkFileName); + sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, sTmp); + m_pProps->m_sLinkFileName = sLinkFileName; + } + else + { + String sLinkFileName(aSection.GetLinkFileName()); + if (aSection.GetType() != DDE_LINK_SECTION) + { + sLinkFileName = sfx2::cTokenSeperator; + sLinkFileName += sfx2::cTokenSeperator; + aSection.SetType(DDE_LINK_SECTION); + } + sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, sTmp); + aSection.SetLinkFileName(sLinkFileName); + } + } + break; + case WID_SECT_DDE_AUTOUPDATE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bUpdateType = bVal; + } + else + { + bLinkModeChanged = sal_True; + bLinkMode = bVal; + } + } + break; + case WID_SECT_LINK: + { + text::SectionFileLink aLink; + if (!(pValues[nProperty] >>= aLink)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bDDE = sal_False; + m_pProps->m_sLinkFileName = aLink.FileURL; + m_pProps->m_sSectionFilter = aLink.FilterName; + } + else + { + if (aSection.GetType() != FILE_LINK_SECTION && + aLink.FileURL.getLength()) + { + aSection.SetType(FILE_LINK_SECTION); + } + ::rtl::OUStringBuffer sFileNameBuf; + if (aLink.FileURL.getLength()) + { + sFileNameBuf.append( URIHelper::SmartRel2Abs( + pFmt->GetDoc()->GetDocShell()->GetMedium() + ->GetURLObject(), + aLink.FileURL, URIHelper::GetMaybeFileHdl())); } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : + sFileNameBuf.append(sfx2::cTokenSeperator); + sFileNameBuf.append(aLink.FilterName); + sFileNameBuf.append(sfx2::cTokenSeperator); + sFileNameBuf.append( + aSection.GetLinkFileName().GetToken(2, + sfx2::cTokenSeperator)); + const ::rtl::OUString sFileName( + sFileNameBuf.makeStringAndClear()); + aSection.SetLinkFileName(sFileName); + if (sFileName.getLength() < 3) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sTmp(uTmp); - if(m_bIsDescriptor) + aSection.SetType(CONTENT_SECTION); + } + } + } + break; + case WID_SECT_REGION: + { + OUString sLink; + pValues[nProperty] >>= sLink; + if (m_bIsDescriptor) + { + m_pProps->m_bDDE = sal_False; + m_pProps->m_sSectionRegion = sLink; + } + else + { + if (aSection.GetType() != FILE_LINK_SECTION && + sLink.getLength()) + { + aSection.SetType(FILE_LINK_SECTION); + } + String sSectLink(aSection.GetLinkFileName()); + while (3 < sSectLink.GetTokenCount(sfx2::cTokenSeperator)) + { + sSectLink += sfx2::cTokenSeperator; + } + sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); + aSection.SetLinkFileName(sSectLink); + if (sSectLink.Len() < 3) + { + aSection.SetType(CONTENT_SECTION); + } + } + } + break; + case WID_SECT_VISIBLE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bHidden = !bVal; + } + else + { + aSection.SetHidden(!bVal); + } + } + break; + case WID_SECT_CURRENTLY_VISIBLE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bCondHidden = !bVal; + } + else + { + if (aSection.GetCondition().Len() != 0) + { + aSection.SetCondHidden(!bVal); + } + } + } + break; + case WID_SECT_PROTECTED: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bProtect = bVal; + } + else + { + aSection.SetProtect(bVal); + } + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bEditInReadonly = bVal; + } + else + { + aSection.SetEditInReadonly(bVal); + } + } + // <-- + break; + case WID_SECT_PASSWORD: + { + uno::Sequence aSeq; + pValues[nProperty] >>= aSeq; + if (m_bIsDescriptor) + { + m_pProps->m_Password = aSeq; + } + else + { + aSection.SetPasswd(aSeq); + } + } + break; + default: + { + if (pFmt) + { + const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); + pItemSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), + pEntry->nWID, pEntry->nWID, 0)); + pItemSet->Put(rOldAttrSet); + m_rPropSet.setPropertyValue(*pEntry, + pValues[nProperty], *pItemSet); + } + else + { + SfxPoolItem* pPutItem = 0; + if (RES_COL == pEntry->nWID) + { + if (!m_pProps->m_pColItem.get()) { - if(!pProps->bDDE) - { - pProps->sLinkFileName = sfx2::cTokenSeperator; - pProps->sLinkFileName += sfx2::cTokenSeperator; - pProps->bDDE = sal_True; - } - pProps->sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator,sTmp); + m_pProps->m_pColItem.reset(new SwFmtCol); } - else + pPutItem = m_pProps->m_pColItem.get(); + } + else if (RES_BACKGROUND == pEntry->nWID) + { + if (!m_pProps->m_pBrushItem.get()) { - String sLinkFileName(aSection.GetLinkFileName()); - if(aSection.GetType() != DDE_LINK_SECTION) - { - sLinkFileName = sfx2::cTokenSeperator; - sLinkFileName += sfx2::cTokenSeperator; - aSection.SetType(DDE_LINK_SECTION); - } - sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator, sTmp); - aSection.SetLinkFileName(sLinkFileName); + m_pProps->m_pBrushItem.reset( + new SvxBrushItem(RES_BACKGROUND)); } + pPutItem = m_pProps->m_pBrushItem.get(); } - break; - case WID_SECT_DDE_AUTOUPDATE: + else if (RES_FTN_AT_TXTEND == pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) + if (!m_pProps->m_pFtnItem.get()) { - pProps->bUpdateType = bVal; + m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); } - else + pPutItem = m_pProps->m_pFtnItem.get(); + } + else if (RES_END_AT_TXTEND == pEntry->nWID) + { + if (!m_pProps->m_pEndItem.get()) { - bLinkModeChanged = sal_True; - bLinkMode = bVal; + m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); } + pPutItem = m_pProps->m_pEndItem.get(); } - break; - case WID_SECT_LINK : + else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) { - text::SectionFileLink aLink; - if(pValues[nProperty] >>= aLink) + if (!m_pProps->m_pXMLAttr.get()) { - if(m_bIsDescriptor) - { - pProps->bDDE = sal_False; - pProps->sLinkFileName = String(aLink.FileURL); - pProps->sSectionFilter = String(aLink.FilterName); - } - else - { - if(aSection.GetType() != FILE_LINK_SECTION && - aLink.FileURL.getLength()) - aSection.SetType(FILE_LINK_SECTION); - String sFileName; - if(aLink.FileURL.getLength()) - { - sFileName += URIHelper::SmartRel2Abs( - pFmt->GetDoc()->GetDocShell()->GetMedium()->GetURLObject(), - aLink.FileURL, - URIHelper::GetMaybeFileHdl()); - } - sFileName += sfx2::cTokenSeperator; - sFileName += String(aLink.FilterName); - sFileName += sfx2::cTokenSeperator; - sFileName += aSection.GetLinkFileName().GetToken( 2, sfx2::cTokenSeperator ); - aSection.SetLinkFileName(sFileName); - if(sFileName.Len() < 3) - aSection.SetType(CONTENT_SECTION); - } + m_pProps->m_pXMLAttr.reset( + new SvXMLAttrContainerItem( + RES_UNKNOWNATR_CONTAINER)); } - else - throw lang::IllegalArgumentException(); + pPutItem = m_pProps->m_pXMLAttr.get(); } - break; - case WID_SECT_REGION : + else if (RES_COLUMNBALANCE== pEntry->nWID) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sLink(uTmp); - if(m_bIsDescriptor) + if (!m_pProps->m_pNoBalanceItem.get()) { - pProps->bDDE = sal_False; - pProps->sSectionRegion = sLink; + m_pProps->m_pNoBalanceItem.reset( + new SwFmtNoBalancedColumns(RES_COLUMNBALANCE)); } - else + pPutItem = m_pProps->m_pNoBalanceItem.get(); + } + else if (RES_FRAMEDIR == pEntry->nWID) + { + if (!m_pProps->m_pFrameDirItem.get()) { - if(aSection.GetType() != FILE_LINK_SECTION && - sLink.Len()) - aSection.SetType(FILE_LINK_SECTION); - String sSectLink(aSection.GetLinkFileName()); - while( 3 < sSectLink.GetTokenCount( sfx2::cTokenSeperator )) - { - sSectLink += sfx2::cTokenSeperator; - } - sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); - aSection.SetLinkFileName(sSectLink); - if(sSectLink.Len() < 3) - aSection.SetType(CONTENT_SECTION); + m_pProps->m_pFrameDirItem.reset( + new SvxFrameDirectionItem( + FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); } + pPutItem = m_pProps->m_pFrameDirItem.get(); } - break; - case WID_SECT_VISIBLE : + else if (RES_LR_SPACE == pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bHidden = !bVal; - else - aSection.SetHidden(!bVal); + // #109700# + if (!m_pProps->m_pLRSpaceItem.get()) + { + m_pProps->m_pLRSpaceItem.reset( + new SvxLRSpaceItem( RES_LR_SPACE )); + } + pPutItem = m_pProps->m_pLRSpaceItem.get(); } - break; - case WID_SECT_CURRENTLY_VISIBLE: + if (pPutItem) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bCondHidden = !bVal; - else - if( aSection.GetCondition().Len() != 0 ) - aSection.SetCondHidden(!bVal); + pPutItem->PutValue(pValues[nProperty], + pEntry->nMemberId); } - break; - case WID_SECT_PROTECTED: + } + } + } + } + + if (pFmt) + { + SwDoc* pDoc = pFmt->GetDoc(); + const SwSectionFmts& rFmts = pDoc->GetSections(); + UnoActionContext aContext(pDoc); + for (sal_uInt16 i = 0; i < rFmts.Count(); i++) + { + if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) + { + pDoc->ChgSection(i, aSection, pItemSet.get(), + pDoc->IsInReading()); + { + // temporarily remove actions to allow cursor update + UnoActionRemoveContext aRemoveContext( pDoc ); + } + + //SwSection* pSect = pFmt->GetSection(); + if (bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION) + { + // set update type; needs an established link + if (!pSect->IsConnected()) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bProtect = bVal; - else - aSection.SetProtect(bVal); + pSect->CreateLink(CREATE_CONNECT); } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: + pSect->SetUpdateType( static_cast< USHORT >((bLinkMode) ? + sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + } + // section found and processed: break from loop + break; + } + } + } +} + +void SAL_CALL +SwXTextSection::setPropertyValues( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& rValues) +throw (beans::PropertyVetoException, lang::IllegalArgumentException, + lang::WrappedTargetException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + // workaround for bad designed API + try + { + m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); + } + catch (beans::UnknownPropertyException &rException) + { + // wrap the original (here not allowed) exception in + // a WrappedTargetException that gets thrown instead. + lang::WrappedTargetException aWExc; + aWExc.TargetException <<= rException; + throw aWExc; + } +} +/*-- 10.12.98 14:47:11--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXTextSection::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException ) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + uno::Sequence< ::rtl::OUString > aPropertyNames(1); + aPropertyNames.getArray()[0] = rPropertyName; + uno::Sequence< uno::Any > aValues(1); + aValues.getArray()[0] = rValue; + m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); +} + +/* -----------------------------12.02.01 10:43-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< uno::Any > +SwXTextSection::Impl::GetPropertyValues_Impl( + const uno::Sequence< OUString > & rPropertyNames ) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + SwSectionFmt *const pFmt = GetSectionFmt(); + if (!pFmt && !m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); + uno::Any* pRet = aRet.getArray(); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + + for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); + nProperty++) + { + SfxItemPropertySimpleEntry const*const pEntry = + m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProperty], + static_cast(& m_rThis)); + } + switch(pEntry->nWID) + { + case WID_SECT_CONDITION: + { + OUString uTmp( (m_bIsDescriptor) + ? m_pProps->m_sCondition + : ::rtl::OUString(pSect->GetCondition())); + pRet[nProperty] <<= uTmp; + } + break; + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: + { + ::rtl::OUString sRet; + if (m_bIsDescriptor) + { + if (m_pProps->m_bDDE) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bEditInReadonly = bVal; - else - aSection.SetEditInReadonly(bVal); + sRet = m_pProps->m_sLinkFileName; } - // <-- - break; - case WID_SECT_PASSWORD: + } + else if (DDE_LINK_SECTION == pSect->GetType()) + { + sRet = pSect->GetLinkFileName(); + } + sal_Int32 nDummy(0); + sRet = sRet.getToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, nDummy); + pRet[nProperty] <<= sRet; + } + break; + case WID_SECT_DDE_AUTOUPDATE: + { + // GetUpdateType() returns .._ALWAYS or .._ONCALL + if (pSect && pSect->IsLinkType() && pSect->IsConnected()) // lijian i73247 + { + const sal_Bool bTemp = + (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); + pRet[nProperty] <<= bTemp; + } + } + break; + case WID_SECT_LINK : + { + text::SectionFileLink aLink; + if (m_bIsDescriptor) + { + if (!m_pProps->m_bDDE) { - uno::Sequence aSeq; - pValues[nProperty] >>= aSeq; - if (m_bIsDescriptor) - pProps->aPassword = aSeq; - else - aSection.SetPasswd(aSeq); + aLink.FileURL = m_pProps->m_sLinkFileName; + aLink.FilterName = m_pProps->m_sSectionFilter; } - break; - default: - if(pFmt) - { - const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); - aItemSet.pItemSet = new SfxItemSet(*rOldAttrSet.GetPool(), - pEntry->nWID, pEntry->nWID, 0); - aItemSet.pItemSet->Put(rOldAttrSet); - m_pPropSet->setPropertyValue(*pEntry, pValues[nProperty], *aItemSet.pItemSet); - } - else - { - SfxPoolItem* pPutItem = 0; - if(RES_COL == pEntry->nWID) - { - if(!pProps->pColItem) - pProps->pColItem = new SwFmtCol; - pPutItem = pProps->pColItem; - } - else if(RES_BACKGROUND == pEntry->nWID) - { - if(!pProps->pBrushItem) - pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND); - pPutItem = pProps->pBrushItem; - } - else if(RES_FTN_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pFtnItem) - pProps->pFtnItem = new SwFmtFtnAtTxtEnd; - pPutItem = pProps->pFtnItem; - } - else if(RES_END_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pEndItem) - pProps->pEndItem = new SwFmtEndAtTxtEnd; - pPutItem = pProps->pEndItem; - } - else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID) - { - if(!pProps->pXMLAttr) - pProps->pXMLAttr= new SvXMLAttrContainerItem( RES_UNKNOWNATR_CONTAINER ); - pPutItem = pProps->pXMLAttr; - } - else if(RES_COLUMNBALANCE== pEntry->nWID) - { - if(!pProps->pNoBalanceItem) - pProps->pNoBalanceItem= new SwFmtNoBalancedColumns( RES_COLUMNBALANCE ); - pPutItem = pProps->pNoBalanceItem; - } - else if(RES_FRAMEDIR == pEntry->nWID) - { - if(!pProps->pFrameDirItem) - pProps->pFrameDirItem = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR ); - pPutItem = pProps->pFrameDirItem; - } - else if(RES_LR_SPACE == pEntry->nWID) - { - // #109700# - if(!pProps->pLRSpaceItem) - pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE ); - pPutItem = pProps->pLRSpaceItem; - } - if(pPutItem) - pPutItem->PutValue(pValues[nProperty], pEntry->nMemberId); - } } + else if (FILE_LINK_SECTION == pSect->GetType()) + { + ::rtl::OUString sRet( pSect->GetLinkFileName() ); + sal_Int32 nIndex(0); + aLink.FileURL = + sRet.getToken(0, sfx2::cTokenSeperator, nIndex); + aLink.FilterName = + sRet.getToken(0, sfx2::cTokenSeperator, nIndex); + } + pRet[nProperty] <<= aLink; } - } - if(pFmt) - { - SwDoc* pDoc = pFmt->GetDoc(); - const SwSectionFmts& rFmts = pDoc->GetSections(); - UnoActionContext aContext(pDoc); - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + break; + case WID_SECT_REGION : + { + ::rtl::OUString sRet; + if (m_bIsDescriptor) + { + sRet = m_pProps->m_sSectionRegion; + } + else if (FILE_LINK_SECTION == pSect->GetType()) + { + sRet = pSect->GetLinkFileName().GetToken(2, + sfx2::cTokenSeperator); + } + pRet[nProperty] <<= sRet; + } + break; + case WID_SECT_VISIBLE : + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? !m_pProps->m_bHidden : !pSect->IsHidden(); + pRet[nProperty] <<= bTemp; + } + break; + case WID_SECT_CURRENTLY_VISIBLE: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? !m_pProps->m_bCondHidden : !pSect->IsCondHidden(); + pRet[nProperty] <<= bTemp; + } + break; + case WID_SECT_PROTECTED: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? m_pProps->m_bProtect : pSect->IsProtect(); + pRet[nProperty] <<= bTemp; + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? m_pProps->m_bEditInReadonly : pSect->IsEditInReadonly(); + pRet[nProperty] <<= bTemp; + } + break; + // <-- + case FN_PARAM_LINK_DISPLAY_NAME: + { + if (pFmt) + { + pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName()); + } + } + break; + case WID_SECT_DOCUMENT_INDEX: + { + // search enclosing index + SwSection* pEnclosingSection = pSect; + while ((pEnclosingSection != NULL) && + (TOX_CONTENT_SECTION != pEnclosingSection->GetType())) + { + pEnclosingSection = pEnclosingSection->GetParent(); + } + if (pEnclosingSection) + { + // convert section to TOXBase and get SwXDocumentIndex + SwTOXBaseSection *const pTOXBaseSect = + PTR_CAST(SwTOXBaseSection, pEnclosingSection); + const uno::Reference xIndex = + SwXDocumentIndexes::GetObject(pTOXBaseSect); + pRet[nProperty] <<= xIndex; + } + // else: no enclosing index found -> empty return value + } + break; + case WID_SECT_IS_GLOBAL_DOC_SECTION: + { + const sal_Bool bRet = (NULL == pFmt) ? sal_False : + static_cast(NULL != pFmt->GetGlobalDocSection()); + pRet[nProperty] <<= bRet; + } + break; + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + SwXParagraph::getDefaultTextContentValue( + pRet[nProperty], OUString(), pEntry->nWID); + break; + case FN_UNO_REDLINE_NODE_START: + case FN_UNO_REDLINE_NODE_END: { - if(rFmts[i]->GetSection()->GetName() == pSect->GetName()) + if (!pFmt) + break; // lijian i73247 + SwNode* pSectNode = pFmt->GetSectionNode(); + if (FN_UNO_REDLINE_NODE_END == pEntry->nWID) { - pDoc->ChgSection( i, aSection, aItemSet.pItemSet, pDoc->IsInReading()); - - { - // temporarily remove actions to allow cursor update - UnoActionRemoveContext aRemoveContext( pDoc ); - } - - //SwSection* pSect = pFmt->GetSection(); - if( bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION) + pSectNode = pSectNode->EndOfSectionNode(); + } + const SwRedlineTbl& rRedTbl = + pFmt->GetDoc()->GetRedlineTbl(); + for (USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++) + { + const SwRedline* pRedline = rRedTbl[nRed]; + SwNode const*const pRedPointNode = pRedline->GetNode(TRUE); + SwNode const*const pRedMarkNode = pRedline->GetNode(FALSE); + if ((pRedPointNode == pSectNode) || + (pRedMarkNode == pSectNode)) { - // set update type; needs an established link - if(!pSect->IsConnected()) - { - pSect->CreateLink(CREATE_CONNECT); - } - pSect->SetUpdateType( static_cast< USHORT >(bLinkMode ? - sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + SwNode const*const pStartOfRedline = + (SwNodeIndex(*pRedPointNode) <= + SwNodeIndex(*pRedMarkNode)) + ? pRedPointNode : pRedMarkNode; + const bool bIsStart = (pStartOfRedline == pSectNode); + pRet[nProperty] <<= + SwXRedlinePortion::CreateRedlineProperties( + *pRedline, bIsStart); + break; } - // section found and processed: break from loop - break; } } - } - } - else - throw uno::RuntimeException(); -} - -void SwXTextSection::setPropertyValues( - const Sequence< ::rtl::OUString >& rPropertyNames, - const Sequence< Any >& rValues ) - throw(PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, RuntimeException) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - - // workaround for bad designed API - try - { - SetPropertyValues_Impl( rPropertyNames, rValues ); - } - catch (UnknownPropertyException &rException) - { - // wrap the original (here not allowed) exception in - // a WrappedTargetException that gets thrown instead. - WrappedTargetException aWExc; - aWExc.TargetException <<= rException; - throw aWExc; - } -} -/*-- 10.12.98 14:47:11--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextSection::setPropertyValue( - const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, - uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< ::rtl::OUString > aPropertyNames(1); - aPropertyNames.getArray()[0] = rPropertyName; - Sequence< Any > aValues(1); - aValues.getArray()[0] = aValue; - SetPropertyValues_Impl( aPropertyNames, aValues ); -} -/* -----------------------------12.02.01 10:43-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Sequence< Any > SAL_CALL SwXTextSection::GetPropertyValues_Impl( - const uno::Sequence< OUString > & rPropertyNames ) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) -{ - Sequence< Any > aRet(rPropertyNames.getLength()); - Any* pRet = aRet.getArray(); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) - { - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - for(sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++) - { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty]); - if(pEntry) + break; + case WID_SECT_PASSWORD: { - switch(pEntry->nWID) + pRet[nProperty] <<= (m_bIsDescriptor) + ? m_pProps->m_Password : pSect->GetPasswd(); + } + break; + default: + { + if (pFmt) { - case WID_SECT_CONDITION: - { - OUString uTmp( - m_bIsDescriptor ? pProps->sCondition : pSect->GetCondition()); - pRet[nProperty] <<= uTmp; - } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : + m_rPropSet.getPropertyValue(*pEntry, + pFmt->GetAttrSet(), pRet[nProperty]); + } + else + { + const SfxPoolItem* pQueryItem = 0; + if (RES_COL == pEntry->nWID) { - String sRet; - if(m_bIsDescriptor) - { - if(pProps->bDDE) - sRet = pProps->sLinkFileName; - } - else if( DDE_LINK_SECTION == pSect->GetType() ) + if (!m_pProps->m_pColItem.get()) { - sRet = pSect->GetLinkFileName(); + m_pProps->m_pColItem.reset(new SwFmtCol); } - sRet = sRet.GetToken(pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeperator); - pRet[nProperty] <<= OUString(sRet); + pQueryItem = m_pProps->m_pColItem.get(); } - break; - case WID_SECT_DDE_AUTOUPDATE: + else if (RES_BACKGROUND == pEntry->nWID) { - // GetUpdateType() returns .._ALWAYS or .._ONCALL - if ( pSect && pSect->IsLinkType() && pSect->IsConnected() ) // lijian i73247 + if (!m_pProps->m_pBrushItem.get()) { - sal_Bool bTemp = - (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); + m_pProps->m_pBrushItem.reset( + new SvxBrushItem(RES_BACKGROUND)); } + pQueryItem = m_pProps->m_pBrushItem.get(); } - break; - case WID_SECT_LINK : + else if (RES_FTN_AT_TXTEND == pEntry->nWID) { - text::SectionFileLink aLink; - if(m_bIsDescriptor) - { - if(!pProps->bDDE) - { - aLink.FileURL = pProps->sLinkFileName; - aLink.FilterName = pProps->sSectionFilter; - } - } - else if( FILE_LINK_SECTION == pSect->GetType() ) + if (!m_pProps->m_pFtnItem.get()) { - String sRet( pSect->GetLinkFileName() ); - aLink.FileURL = sRet.GetToken(0, sfx2::cTokenSeperator ); - aLink.FilterName = sRet.GetToken(1, sfx2::cTokenSeperator ); + m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); } - pRet[nProperty].setValue(&aLink, ::getCppuType((text::SectionFileLink*)0)); + pQueryItem = m_pProps->m_pFtnItem.get(); } - break; - case WID_SECT_REGION : + else if (RES_END_AT_TXTEND == pEntry->nWID) { - String sRet; - if(m_bIsDescriptor) + if (!m_pProps->m_pEndItem.get()) { - sRet = pProps->sSectionRegion; + m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); } - else if( FILE_LINK_SECTION == pSect->GetType() ) - sRet = pSect->GetLinkFileName().GetToken(2, sfx2::cTokenSeperator); - pRet[nProperty] <<= OUString(sRet); - } - break; - case WID_SECT_VISIBLE : - { - sal_Bool bTemp = m_bIsDescriptor ? !pProps->bHidden : !pSect->IsHidden(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - case WID_SECT_CURRENTLY_VISIBLE: - { - sal_Bool bTmp = m_bIsDescriptor ? !pProps->bCondHidden : !pSect->IsCondHidden(); - pRet[nProperty].setValue( &bTmp, ::getCppuBooleanType()); - } - break; - case WID_SECT_PROTECTED: - { - sal_Bool bTemp = m_bIsDescriptor ? pProps->bProtect : pSect->IsProtect(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: - { - sal_Bool bTemp = m_bIsDescriptor ? pProps->bEditInReadonly : pSect->IsEditInReadonly(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - // <-- - case FN_PARAM_LINK_DISPLAY_NAME: - { - if(pFmt) - pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName()); + pQueryItem = m_pProps->m_pEndItem.get(); } - break; - case WID_SECT_DOCUMENT_INDEX: + else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) { - // search enclosing index - SwSection* pEnclosingSection = pSect; - while ( (pEnclosingSection != NULL) && - (TOX_CONTENT_SECTION != - pEnclosingSection->GetType()) ) + if (!m_pProps->m_pXMLAttr.get()) { - pEnclosingSection = pEnclosingSection->GetParent(); + m_pProps->m_pXMLAttr.reset( + new SvXMLAttrContainerItem); } - if (pEnclosingSection) + pQueryItem = m_pProps->m_pXMLAttr.get(); + } + else if (RES_COLUMNBALANCE== pEntry->nWID) + { + if (!m_pProps->m_pNoBalanceItem.get()) { - // convert section to TOXBase and get SwXDocumentIndex - SwTOXBaseSection* pTOXBaseSect = - PTR_CAST(SwTOXBaseSection, pEnclosingSection); - uno::Reference xIndex = - SwXDocumentIndexes::GetObject(pTOXBaseSect); - pRet[nProperty] <<= xIndex; + m_pProps->m_pNoBalanceItem.reset( + new SwFmtNoBalancedColumns); } - // else: no enclosing index found -> empty return value + pQueryItem = m_pProps->m_pNoBalanceItem.get(); } - break; - case WID_SECT_IS_GLOBAL_DOC_SECTION: + else if (RES_FRAMEDIR == pEntry->nWID) { - sal_Bool bRet = (NULL == pFmt) ? sal_False : - static_cast< sal_Bool >(NULL != pFmt->GetGlobalDocSection()); - pRet[nProperty].setValue( &bRet, ::getCppuBooleanType()); + if (!m_pProps->m_pFrameDirItem.get()) + { + m_pProps->m_pFrameDirItem.reset( + new SvxFrameDirectionItem( + FRMDIR_ENVIRONMENT, RES_FRAMEDIR)); + } + pQueryItem = m_pProps->m_pFrameDirItem.get(); } - break; - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(pRet[nProperty], OUString(), pEntry->nWID); - break; - case FN_UNO_REDLINE_NODE_START: - case FN_UNO_REDLINE_NODE_END: + /* -> #109700# */ + else if (RES_LR_SPACE == pEntry->nWID) { - if(!pFmt) - break; // lijian i73247 - SwNode* pSectNode = pFmt->GetSectionNode(); - if(FN_UNO_REDLINE_NODE_END == pEntry->nWID) - pSectNode = pSectNode->EndOfSectionNode(); - const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->GetRedlineTbl(); - for(USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++) + if (!m_pProps->m_pLRSpaceItem.get()) { - const SwRedline* pRedline = rRedTbl[nRed]; - const SwNode* pRedPointNode = pRedline->GetNode(TRUE); - const SwNode* pRedMarkNode = pRedline->GetNode(FALSE); - if(pRedPointNode == pSectNode || pRedMarkNode == pSectNode) - { - const SwNode* pStartOfRedline = SwNodeIndex(*pRedPointNode) <= SwNodeIndex(*pRedMarkNode) ? - pRedPointNode : pRedMarkNode; - BOOL bIsStart = pStartOfRedline == pSectNode; - pRet[nProperty] <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart); - break; - } + m_pProps->m_pLRSpaceItem.reset( + new SvxLRSpaceItem( RES_LR_SPACE )); } + pQueryItem = m_pProps->m_pLRSpaceItem.get(); } - break; - case WID_SECT_PASSWORD: + /* <- #109700# */ + if (pQueryItem) { - pRet[nProperty] <<= m_bIsDescriptor ? pProps->aPassword : pSect->GetPasswd(); + pQueryItem->QueryValue(pRet[nProperty], + pEntry->nMemberId); } - break; - default: - if(pFmt) - m_pPropSet->getPropertyValue(*pEntry, pFmt->GetAttrSet(), pRet[nProperty]); - else - { - const SfxPoolItem* pQueryItem = 0; - if(RES_COL == pEntry->nWID) - { - if(!pProps->pColItem) - pProps->pColItem = new SwFmtCol; - pQueryItem = pProps->pColItem; - } - else if(RES_BACKGROUND == pEntry->nWID) - { - if(!pProps->pBrushItem) - pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND); - pQueryItem = pProps->pBrushItem; - } - else if(RES_FTN_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pFtnItem) - pProps->pFtnItem = new SwFmtFtnAtTxtEnd; - pQueryItem = pProps->pFtnItem; - } - else if(RES_END_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pEndItem) - pProps->pEndItem = new SwFmtEndAtTxtEnd; - pQueryItem = pProps->pEndItem; - } - else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID) - { - if(!pProps->pXMLAttr) - pProps->pXMLAttr= new SvXMLAttrContainerItem ; - pQueryItem = pProps->pXMLAttr; - } - else if(RES_COLUMNBALANCE== pEntry->nWID) - { - if(!pProps->pNoBalanceItem) - pProps->pNoBalanceItem= new SwFmtNoBalancedColumns; - pQueryItem = pProps->pNoBalanceItem; - } - else if(RES_FRAMEDIR == pEntry->nWID) - { - if(!pProps->pFrameDirItem) - pProps->pFrameDirItem = new SvxFrameDirectionItem(FRMDIR_ENVIRONMENT, RES_FRAMEDIR); - pQueryItem = pProps->pFrameDirItem; - } - /* -> #109700# */ - else if(RES_LR_SPACE == pEntry->nWID) - { - if(!pProps->pLRSpaceItem) - pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE ); - pQueryItem = pProps->pLRSpaceItem; - } - /* <- #109700# */ - if(pQueryItem) - pQueryItem->QueryValue(pRet[nProperty], pEntry->nMemberId); - } } } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); } } - else - throw uno::RuntimeException(); return aRet; } + /* -----------------------------04.11.03 10:43-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< Any > SwXTextSection::getPropertyValues( - const Sequence< ::rtl::OUString >& rPropertyNames ) - throw(RuntimeException) +uno::Sequence< uno::Any > SAL_CALL +SwXTextSection::getPropertyValues( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< Any > aValues; + uno::Sequence< uno::Any > aValues; // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); } - catch (UnknownPropertyException &) + catch (beans::UnknownPropertyException &) { - throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString( + RTL_CONSTASCII_USTRINGPARAM("Unknown property exception caught")), + static_cast(this)); } - catch (WrappedTargetException &) + catch (lang::WrappedTargetException &) { - throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString( + RTL_CONSTASCII_USTRINGPARAM("WrappedTargetException caught")), + static_cast(this)); } return aValues; @@ -1213,279 +1356,373 @@ Sequence< Any > SwXTextSection::getPropertyValues( /*-- 10.12.98 14:47:12--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextSection::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextSection::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< ::rtl::OUString > aPropertyNames(1); + + uno::Sequence< ::rtl::OUString > aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; + return m_pImpl->GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; } /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::addPropertiesChangeListener( - const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, - const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(RuntimeException) +void SAL_CALL SwXTextSection::addPropertiesChangeListener( + const uno::Sequence< OUString >& /*aPropertyNames*/, + const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) +throw (uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addPropertiesChangeListener(): not implemented"); } + /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::removePropertiesChangeListener( +void SAL_CALL SwXTextSection::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(RuntimeException) +throw (uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removePropertiesChangeListener(): not implemented"); } + /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::firePropertiesChangeEvent( - const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, +void SAL_CALL SwXTextSection::firePropertiesChangeEvent( + const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(RuntimeException) + throw(uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::firePropertiesChangeEvent(): not implemented"); } + /*-- 10.12.98 14:47:13--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addPropertyChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:13--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removePropertyChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:14--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addVetoableChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:14--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removeVetoableChangeListener(): not implemented"); } /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -PropertyState SwXTextSection::getPropertyState( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SAL_CALL +SwXTextSection::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< OUString > aNames(1); + + uno::Sequence< OUString > aNames(1); aNames.getArray()[0] = rPropertyName; return getPropertyStates(aNames).getConstArray()[0]; } /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -Sequence< PropertyState > SwXTextSection::getPropertyStates( - const Sequence< OUString >& rPropertyNames ) - throw(UnknownPropertyException, RuntimeException) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextSection::getPropertyStates( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< PropertyState > aStates(rPropertyNames.getLength()); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + if (!pFmt && !m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + uno::Sequence< beans::PropertyState > aStates(rPropertyNames.getLength()); + beans::PropertyState *const pStates = aStates.getArray(); + const OUString* pNames = rPropertyNames.getConstArray(); + for (sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) { - PropertyState* pStates = aStates.getArray(); - const OUString* pNames = rPropertyNames.getConstArray(); - for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i]); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], static_cast< cppu::OWeakObject* >(this)); + } + switch (pEntry->nWID) { - pStates[i] = PropertyState_DEFAULT_VALUE; - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pNames[i]); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + case WID_SECT_CONDITION: + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: + case WID_SECT_DDE_AUTOUPDATE: + case WID_SECT_LINK: + case WID_SECT_REGION : + case WID_SECT_VISIBLE: + case WID_SECT_PROTECTED: + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + // <-- + case FN_PARAM_LINK_DISPLAY_NAME: + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + pStates[i] = beans::PropertyState_DIRECT_VALUE; + break; + default: { - case WID_SECT_CONDITION: - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : - case WID_SECT_DDE_AUTOUPDATE: - case WID_SECT_LINK : - case WID_SECT_REGION : - case WID_SECT_VISIBLE : - case WID_SECT_PROTECTED: - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: - // <-- - case FN_PARAM_LINK_DISPLAY_NAME: - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - pStates[i] = PropertyState_DIRECT_VALUE; - break; - default: - if(pFmt) - pStates[i] = m_pPropSet->getPropertyState(pNames[i], pFmt->GetAttrSet()); - else + if (pFmt) + { + pStates[i] = m_pImpl->m_rPropSet.getPropertyState( + pNames[i], pFmt->GetAttrSet()); + } + else + { + if (RES_COL == pEntry->nWID) + { + if (!m_pImpl->m_pProps->m_pColItem.get()) + { + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } + else + { + pStates[i] = beans::PropertyState_DIRECT_VALUE; + } + } + else //if(RES_BACKGROUND == pEntry->nWID) { - if(RES_COL == pEntry->nWID) + if (!m_pImpl->m_pProps->m_pBrushItem.get()) { - if(!pProps->pColItem) - pStates[i] = PropertyState_DEFAULT_VALUE; - else - pStates[i] = PropertyState_DIRECT_VALUE; + pStates[i] = beans::PropertyState_DEFAULT_VALUE; } - else //if(RES_BACKGROUND == pEntry->nWID) + else { - if(!pProps->pBrushItem) - pStates[i] = PropertyState_DEFAULT_VALUE; - else - pStates[i] = PropertyState_DIRECT_VALUE; + pStates[i] = beans::PropertyState_DIRECT_VALUE; } } + } } } } - else - throw RuntimeException(); return aStates; } + /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::setPropertyToDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +void SAL_CALL +SwXTextSection::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + if (!pFmt && !m_pImpl->m_bIsDescriptor) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - if(pFmt) - aSection = *pSect; - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SfxItemSet* pNewAttrSet = 0; - switch(pEntry->nWID) + throw uno::RuntimeException(); + } + + SwSection aSection(CONTENT_SECTION, aEmptyStr); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + if (pFmt) + { + aSection = *pSect; + } + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast< cppu::OWeakObject* >(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertyToDefault: property is read-only: ")) + + rPropertyName, + static_cast(this)); + } + + ::std::auto_ptr pNewAttrSet; + switch (pEntry->nWID) + { + case WID_SECT_CONDITION: { - case WID_SECT_CONDITION: + if (m_pImpl->m_bIsDescriptor) { - if(m_bIsDescriptor) - pProps->sCondition = aEmptyStr; - else - aSection.SetCondition(aEmptyStr); + m_pImpl->m_pProps->m_sCondition = aEmptyStr; } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : - case WID_SECT_LINK : - case WID_SECT_REGION : - aSection.SetType(CONTENT_SECTION); - break; - case WID_SECT_DDE_AUTOUPDATE: - aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); - break; - case WID_SECT_VISIBLE : + else { - if(m_bIsDescriptor) - pProps->bHidden = FALSE; - else - aSection.SetHidden(FALSE); + aSection.SetCondition(aEmptyStr); } - break; - case WID_SECT_PROTECTED: + } + break; + case WID_SECT_DDE_TYPE : + case WID_SECT_DDE_FILE : + case WID_SECT_DDE_ELEMENT : + case WID_SECT_LINK : + case WID_SECT_REGION : + aSection.SetType(CONTENT_SECTION); + break; + case WID_SECT_DDE_AUTOUPDATE: + aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); + break; + case WID_SECT_VISIBLE : + { + if (m_pImpl->m_bIsDescriptor) { - if(m_bIsDescriptor) - pProps->bProtect = FALSE; - else - aSection.SetProtect(FALSE); + m_pImpl->m_pProps->m_bHidden = false; } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: + else { - if(m_bIsDescriptor) - pProps->bEditInReadonly = FALSE; - else - aSection.SetEditInReadonly(FALSE); + aSection.SetHidden(FALSE); } - break; - // <-- + } + break; + case WID_SECT_PROTECTED: + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->m_bProtect = false; + } + else + { + aSection.SetProtect(FALSE); + } + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->m_bEditInReadonly = false; + } + else + { + aSection.SetEditInReadonly(FALSE); + } + } + break; + // <-- - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - break; - default: - if(pEntry->nWID <= SFX_WHICH_MAX) + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + break; + default: + { + if (pEntry->nWID <= SFX_WHICH_MAX) + { + if (pFmt) + { + const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); + pNewAttrSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), + pEntry->nWID, pEntry->nWID, 0)); + pNewAttrSet->ClearItem(pEntry->nWID); + } + else { - if(pFmt) + if (RES_COL == pEntry->nWID) { - const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); - pNewAttrSet = new SfxItemSet(*rOldAttrSet.GetPool(), - pEntry->nWID, pEntry->nWID, 0); - pNewAttrSet->ClearItem(pEntry->nWID); + m_pImpl->m_pProps->m_pColItem.reset(); } - else + else if (RES_BACKGROUND == pEntry->nWID) { - if(RES_COL == pEntry->nWID) - DELETEZ(pProps->pColItem); - else if(RES_BACKGROUND == pEntry->nWID) - DELETEZ(pProps->pBrushItem); + m_pImpl->m_pProps->m_pBrushItem.reset(); } } + } } - if(pFmt) + } + + if (pFmt) + { + SwDoc *const pDoc = pFmt->GetDoc(); + const SwSectionFmts& rFmts = pDoc->GetSections(); + UnoActionContext aContext(pDoc); + for (sal_uInt16 i = 0; i < rFmts.Count(); i++) { - SwDoc* pDoc = pFmt->GetDoc(); - const SwSectionFmts& rFmts = pDoc->GetSections(); - UnoActionContext aContext(pDoc); - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) { - if(rFmts[i]->GetSection()->GetName() == pSect->GetName()) + pDoc->ChgSection(i, aSection, pNewAttrSet.get(), + pDoc->IsInReading()); { - pDoc->ChgSection( i, aSection, pNewAttrSet, pDoc->IsInReading()); - - { - // temporarily remove actions to allow cursor update - UnoActionRemoveContext aRemoveContext( pDoc ); - } - - break; + // temporarily remove actions to allow cursor update + UnoActionRemoveContext aRemoveContext( pDoc ); } + break; } - delete pNewAttrSet; } } - else - throw RuntimeException(); } + /*-- 08.11.00 10:47:56--------------------------------------------------- -----------------------------------------------------------------------*/ -Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextSection::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - SwSectionFmt* pFmt = GetFmt(); - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( rPropertyName ); + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } switch(pEntry->nWID) { @@ -1498,7 +1735,7 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) aRet <<= OUString(); break; case WID_SECT_LINK : - aRet <<= SectionFileLink(); + aRet <<= text::SectionFileLink(); break; case WID_SECT_DDE_AUTOUPDATE: case WID_SECT_VISIBLE : @@ -1524,7 +1761,7 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) default: if(pFmt && pEntry->nWID <= SFX_WHICH_MAX) { - SwDoc* pDoc = pFmt->GetDoc(); + SwDoc *const pDoc = pFmt->GetDoc(); const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); rDefItem.QueryValue(aRet, pEntry->nMemberId); @@ -1532,33 +1769,43 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) } return aRet; } + /*-- 10.12.98 14:47:15--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextSection::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextSection::getName() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - String sRet; - const SwSectionFmt* pFmt = GetFmt(); + + ::rtl::OUString sRet; + SwSectionFmt const*const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) + { sRet = pFmt->GetSection()->GetName(); - else if(m_bIsDescriptor) - sRet = m_sName; + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sName; + } else + { throw uno::RuntimeException(); + } return sRet; } /*-- 10.12.98 14:47:16--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pFmt = GetFmt(); + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) { SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt->GetSection(); + SwSection *const pSect = pFmt->GetSection(); aSection = *pSect; String sNewName(rName); aSection.SetName(sNewName); @@ -1568,9 +1815,13 @@ void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) { if(rFmts[i]->GetSection() == pSect) + { nApplyPos = i; + } else if(sNewName == rFmts[i]->GetSection()->GetName()) + { throw uno::RuntimeException(); + } } if(nApplyPos != USHRT_MAX) { @@ -1584,46 +1835,50 @@ void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException } } } - else if(m_bIsDescriptor) - m_sName = String(rName); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sName = rName; + } else + { throw uno::RuntimeException(); + } } /* -----------------02.11.99 11:30------------------- --------------------------------------------------*/ -OUString SwXTextSection::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXTextSection::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXTextSection"); } + /* -----------------02.11.99 11:30------------------- --------------------------------------------------*/ -sal_Bool SwXTextSection::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesTextSection[] = { - return !rServiceName.compareToAscii("com.sun.star.text.TextSection") || - !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); -} -/* -----------------02.11.99 11:30------------------- + "com.sun.star.text.TextContent", + "com.sun.star.text.TextSection", + "com.sun.star.document.LinkTarget", +}; +static const size_t g_nServicesTextSection( + sizeof(g_ServicesTextSection)/sizeof(g_ServicesTextSection[0])); - --------------------------------------------------*/ -uno::Sequence< OUString > SwXTextSection::getSupportedServiceNames(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextSection::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(3); - OUString* pArr = aRet.getArray(); - pArr[0] = C2U("com.sun.star.text.TextSection"); - pArr[1] = C2U("com.sun.star.document.LinkTarget"); - pArr[2] = C2U("com.sun.star.text.TextContent"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesTextSection, g_ServicesTextSection, rServiceName); } -/*-- 20.12.2005 10:27:33--------------------------------------------------- +/* -----------------02.11.99 11:30------------------- - -----------------------------------------------------------------------*/ -SwSectionFmt* SwXTextSection::GetFmt()const + --------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextSection::getSupportedServiceNames() throw (uno::RuntimeException) { - return m_pClient ? - const_cast(static_cast< const SwSectionFmt* >(m_pClient->GetRegisteredIn())) - : 0; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextSection, g_ServicesTextSection); } + diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 6a669499e7..937e31710a 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -674,7 +674,10 @@ void SwXText::insertTextContentBefore( throw lang::IllegalArgumentException(); sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); + const uno::Reference xSuccTunnel(xSuccessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(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 xPredTunnel(xPredecessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(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 xSuccTunnel(xSuccessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(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 xPredTunnel(xPredecessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(xPredTunnel); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) -- cgit v1.2.3 From 68a096a220703d302073c492cffdb3ac87eff26d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:51 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXTextRanges: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. use new XServiceInfo helpers. replace SvWeirdArray with STL vector. clean up the implementation a little. --- sw/inc/unotextrange.hxx | 33 ++--- sw/source/core/unocore/unoobj2.cxx | 285 ++++++++++++++++++++----------------- sw/source/ui/uno/unotxdoc.cxx | 5 +- sw/source/ui/uno/unotxvw.cxx | 20 +-- 4 files changed, 169 insertions(+), 174 deletions(-) diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index a7d13daf48..94d4996b46 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -45,10 +45,9 @@ #include #include -#include - #include #include +#include class String; @@ -85,6 +84,13 @@ public: }; +namespace sw { + + void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget); + +} // namespace sw + + typedef ::cppu::WeakImplHelper8 < ::com::sun::star::lang::XUnoTunnel , ::com::sun::star::lang::XServiceInfo @@ -300,9 +306,6 @@ public: /* -----------------15.05.98 08:29------------------- * * --------------------------------------------------*/ -typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > * - XTextRangeRefPtr; -SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) typedef ::cppu::WeakImplHelper3 < ::com::sun::star::lang::XUnoTunnel @@ -312,32 +315,20 @@ typedef ::cppu::WeakImplHelper3 class SwXTextRanges : public SwXTextRanges_Base - , public SwClient { private: - XTextRangeArr* pRangeArr; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - xParentText; - XTextRangeArr* GetRangesArray(); - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } - -protected: + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXTextRanges(); public: - SwXTextRanges(); - SwXTextRanges(SwPaM* pCrsr); + SwXTextRanges(SwPaM *const pCrsr); - const SwUnoCrsr* GetCursor() const { - return (const SwUnoCrsr*)(GetRegisteredIn()); - } - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + const SwUnoCrsr* GetCursor() const; static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 23f4a043a5..53ee80c600 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -177,6 +177,29 @@ GetSupportedServiceNamesImpl( } // namespace sw +namespace sw { + +void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget) +{ + rTarget = rSource; + + if (rSource.GetNext() != &rSource) + { + SwPaM *pPam = static_cast(rSource.GetNext()); + do + { + // create new PaM + SwPaM *const pNew = new SwPaM(*pPam); + // insert into ring + pNew->MoveTo(&rTarget); + pPam = static_cast(pPam->GetNext()); + } + while (pPam != &rSource); + } +} + +} // namespace sw + struct FrameDependSortListLess { bool operator() (FrameDependSortListEntry const& r1, @@ -1971,6 +1994,96 @@ void SwXTextRange::makeRedline( /****************************************************************** * SwXTextRanges ******************************************************************/ + +class SwXTextRanges::Impl + : public SwClient +{ + +public: + + ::std::vector< uno::Reference< text::XTextRange > > m_Ranges; + + Impl(SwPaM *const pPaM) + : SwClient( (pPaM) + ? pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint()) + : 0 ) + { + if (pPaM) + { + ::sw::DeepCopyPaM(*pPaM, *GetCursor()); + } + MakeRanges(); + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast( + const_cast(GetRegisteredIn())); + } + + void MakeRanges(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 10.12.98 13:57:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXTextRanges::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); +} + +/* -----------------10.12.98 14:25------------------- + * + * --------------------------------------------------*/ +void SwXTextRanges::Impl::MakeRanges() +{ + SwUnoCrsr *const pCursor = GetCursor(); + if (pCursor) + { + SwPaM *pTmpCursor = pCursor; + do { + const uno::Reference< text::XTextRange > xRange( + SwXTextRange::CreateTextRangeFromPosition( + pTmpCursor->GetDoc(), + *pTmpCursor->GetPoint(), pTmpCursor->GetMark())); + if (xRange.is()) + { + m_Ranges.push_back(xRange); + } + pTmpCursor = static_cast(pTmpCursor->GetNext()); + } + while (pTmpCursor != pCursor); + } +} + +const SwUnoCrsr* SwXTextRanges::GetCursor() const +{ + return m_pImpl->GetCursor(); +} + +/*-- 10.12.98 13:57:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextRanges::SwXTextRanges(SwPaM *const pPaM) + : m_pImpl( new SwXTextRanges::Impl(pPaM) ) +{ +} + +/*-- 10.12.98 13:57:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextRanges::~SwXTextRanges() +{ +} + /* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ @@ -1982,188 +2095,98 @@ const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextRanges::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXTextRanges::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast (this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } + /**************************************************************************** * Text positions * Bis zum ersten Zugriff auf eine TextPosition wird ein SwCursor gehalten, * danach wird ein Array mit uno::Reference< XTextPosition > angelegt * ****************************************************************************/ -SV_IMPL_PTRARR(XTextRangeArr, XTextRangeRefPtr); /* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXTextRanges::getImplementationName(void) throw( RuntimeException ) +OUString SAL_CALL +SwXTextRanges::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXTextRanges"); } /* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXTextRanges::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - return C2U("com.sun.star.text.TextRanges") == rServiceName; -} -/* -----------------------------06.04.00 16:36-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXTextRanges::getSupportedServiceNames(void) throw( RuntimeException ) +static char const*const g_ServicesTextRanges[] = { - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.TextRanges"); - return aRet; -} -/*-- 10.12.98 13:57:20--------------------------------------------------- + "com.sun.star.text.TextRanges", +}; +static const size_t g_nServicesTextRanges( + sizeof(g_ServicesTextRanges)/sizeof(g_ServicesTextRanges[0])); - -----------------------------------------------------------------------*/ -SwXTextRanges::SwXTextRanges() : - pRangeArr(0) +sal_Bool SAL_CALL SwXTextRanges::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - + return ::sw::SupportsServiceImpl( + g_nServicesTextRanges, g_ServicesTextRanges, rServiceName); } -/*-- 10.12.98 13:57:22--------------------------------------------------- +/* -----------------------------06.04.00 16:36-------------------------------- - -----------------------------------------------------------------------*/ -SwXTextRanges::SwXTextRanges(SwPaM* pCrsr) : - pRangeArr(0) + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextRanges::getSupportedServiceNames() throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = pCrsr->GetDoc()->CreateUnoCrsr(*pCrsr->GetPoint()); - if(pCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pCrsr->GetMark(); - } - if(pCrsr->GetNext() != pCrsr) - { - SwPaM *_pStartCrsr = (SwPaM *)pCrsr->GetNext(); - do - { - //neuen PaM erzeugen - SwPaM* pPaM = _pStartCrsr->HasMark() ? - new SwPaM(*_pStartCrsr->GetMark(), *_pStartCrsr->GetPoint()) : - new SwPaM(*_pStartCrsr->GetPoint()); - //und in den Ring einfuegen - pPaM->MoveTo(pUnoCrsr); - - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != pCrsr ); - } - - pUnoCrsr->Add(this); + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextRanges, g_ServicesTextRanges); } -/*-- 10.12.98 13:57:22--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXTextRanges::~SwXTextRanges() -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pCrsr = GetCrsr(); - delete pCrsr; - if(pRangeArr) - { - pRangeArr->DeleteAndDestroy(0, pRangeArr->Count()); - delete pRangeArr; - } -} /*-- 10.12.98 13:57:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL SwXTextRanges::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nRet = 0; - SwUnoCrsr* pCrsr = GetCrsr(); - if(pCrsr) - { - SwPaM *pTmpCrsr = pCrsr; - do { - nRet++; - pTmpCrsr = static_cast(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != pCrsr ); - } - else if(pRangeArr) - nRet = pRangeArr->Count(); - return nRet; + + return static_cast(m_pImpl->m_Ranges.size()); } /*-- 10.12.98 13:57:25--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextRanges::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXTextRanges::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > aRef; - XTextRangeArr* pArr = ((SwXTextRanges*)this)->GetRangesArray(); - if(pArr && 0 <= nIndex && nIndex < pArr->Count()) + + if ((nIndex < 0) || + (static_cast(nIndex) >= m_pImpl->m_Ranges.size())) { - XTextRangeRefPtr pRef = pArr->GetObject( USHORT( nIndex )); - aRef = *pRef; - } - else throw lang::IndexOutOfBoundsException(); - uno::Any aRet(&aRef, ::getCppuType((uno::Reference*)0)); - return aRet; + } + uno::Any ret; + ret <<= (m_pImpl->m_Ranges.at(nIndex)); + return ret; } + /*-- 10.12.98 13:57:25--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXTextRanges::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXTextRanges::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /*-- 10.12.98 13:57:26--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextRanges::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextRanges::hasElements() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + // no mutex necessary: getCount() does locking return getCount() > 0; } -/* -----------------10.12.98 14:25------------------- - * - * --------------------------------------------------*/ -XTextRangeArr* SwXTextRanges::GetRangesArray() -{ - SwUnoCrsr* pCrsr = GetCrsr(); - if(!pRangeArr && pCrsr) - { - pRangeArr = new XTextRangeArr(); - SwPaM *pTmpCrsr = pCrsr; - do { - - uno::Reference< XTextRange >* pPtr = - new uno::Reference( - SwXTextRange::CreateTextRangeFromPosition( - pTmpCrsr->GetDoc(), - *pTmpCrsr->GetPoint(), pTmpCrsr->GetMark())); -// new uno::Reference( SwXTextRange::createTextRangeFromPaM(*pTmpCrsr, xParentText)); - if(pPtr->is()) - pRangeArr->Insert(pPtr, pRangeArr->Count()); - - pTmpCrsr = static_cast(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != pCrsr ); - pCrsr->Remove( this ); - } - return pRangeArr; -} -/*-- 10.12.98 13:57:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextRanges::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} /* -----------------11.12.98 10:07------------------- * diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 5c2c3a7e52..1d9b3f1f82 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -971,10 +971,7 @@ Reference< XIndexAccess > if(!pResultCrsr) throw RuntimeException(); Reference< XIndexAccess > xRet; - if(nResult) - xRet = new SwXTextRanges(pResultCrsr); - else - xRet = new SwXTextRanges(); + xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 ); delete pResultCrsr; return xRet; } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 8d84296790..9a352aa5ee 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -108,24 +108,8 @@ SV_IMPL_PTRARR( SelectionChangeListenerArr, XSelectionChangeListenerPtr ); * --------------------------------------------------*/ SwPaM* lcl_createPamCopy(const SwPaM& rPam) { - SwPaM* pRet = new SwPaM(*rPam.GetPoint()); - if(rPam.HasMark()) - { - pRet->SetMark(); - *pRet->GetMark() = *rPam.GetMark(); - } - if(rPam.GetNext() != (const Ring*)&rPam) - { - SwPaM *_pStartCrsr = (SwPaM *)rPam.GetNext(); - do - { - //neuen PaM erzeugen - SwPaM* pPaM = new SwPaM(*_pStartCrsr); - //und in den Ring einfuegen - pPaM->MoveTo(pRet); - - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != rPam.GetNext() ); - } + SwPaM *const pRet = new SwPaM(*rPam.GetPoint()); + ::sw::DeepCopyPaM(rPam, *pRet); return pRet; } /****************************************************************** -- cgit v1.2.3 From bbcb60bb7c1720f0af75e330021a8d23a718e0c5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:52 +0100 Subject: swunolocking1: #i105557#: SwXTextRange: try to hide the implementation detail that SwXTextRange registers at a bookmark from its clients by using SwXTextRange::GetPositions(). --- sw/inc/unotext.hxx | 5 +- sw/inc/unotextrange.hxx | 6 +- sw/source/core/inc/unometa.hxx | 4 +- sw/source/core/unocore/unoobj.cxx | 87 ++++++++---------------- sw/source/core/unocore/unoobj2.cxx | 8 +-- sw/source/core/unocore/unorefmk.cxx | 63 +++++------------- sw/source/core/unocore/unotext.cxx | 128 ++++++++++++++---------------------- sw/source/ui/uno/unoatxt.cxx | 48 ++++++-------- sw/source/ui/uno/unotxvw.cxx | 9 ++- 9 files changed, 130 insertions(+), 228 deletions(-) diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx index 499e0620da..97a45ece73 100644 --- a/sw/inc/unotext.hxx +++ b/sw/inc/unotext.hxx @@ -93,7 +93,7 @@ private: virtual void PrepareForAttach( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, - SwXTextRange const * const pRange, SwPaM const * const pPam); + SwPaM const & rPam); protected: @@ -136,8 +136,7 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual bool CheckForOwnMemberMeta( - const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) + const SwPaM & rPam, const bool bAbsorb) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 94d4996b46..079296d2a4 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -130,7 +130,9 @@ private: xParentText; ::sw::mark::IMark* pMark; - void _CreateNewBookmark(SwPaM& rPam); + const ::sw::mark::IMark * GetBookmark() const + { return pMark; } + void SetPositions(SwPaM const& rPam); //TODO: new exception type for protected content void DeleteAndInsert(const String& rText, const bool bForceExpandHints) throw (::com::sun::star::uno::RuntimeException); @@ -153,8 +155,6 @@ public: { return pDoc; } SwDoc* GetDoc() { return pDoc; } - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, const ::com::sun::star::uno::Reference< diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx index 5568aa88b5..39f81caa90 100755 --- a/sw/source/core/inc/unometa.hxx +++ b/sw/source/core/inc/unometa.hxx @@ -52,7 +52,6 @@ typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > TextRangeList_t; -class SwXTextRange; class SwPaM; class SwTxtNode; @@ -117,8 +116,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > GetParentText() const; - bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) + bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 8b0f76bfbe..f923fcf1ae 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1181,17 +1181,26 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B const SwStartNode* pOwnStartNode = pOwnCursor->GetNode()-> FindSttNodeByType(eSearchNodeType); - const SwNode* pSrcNode = 0; - if(pCursor && pCursor->GetPaM()) + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) { - pSrcNode = pCursor->GetPaM()->GetNode(); + pPam = pCursor->GetPaM(); } - else if(pRange && pRange->GetBookmark()) + else if (pRange) { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); + if (pRange->GetPositions(aPam)) + { + pPam = & aPam; + } + } + + if (!pPam) + { + throw uno::RuntimeException(); } - const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0; + const SwStartNode* pTmp = + pPam->GetNode()->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) @@ -1209,16 +1218,9 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B if (CURSOR_META == eType) { - const SwPosition & rPoint( (pRange) - ? pRange->GetBookmark()->GetMarkPos() - : *pCursor->GetPaM()->GetPoint() ); - const SwPosition & rMark ( (pRange) - ? ((pRange->GetBookmark()->IsExpanded()) - ? pRange->GetBookmark()->GetOtherMarkPos() : rPoint) - : *pCursor->GetPaM()->GetMark() ); - SwPaM aPam(rPoint, rMark); + SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint()); const bool bNotForced( - lcl_ForceIntoMeta(aPam, xParentText, META_CHECK_BOTH) ); + lcl_ForceIntoMeta(CopyPam, xParentText, META_CHECK_BOTH) ); if (!bNotForced) { throw uno::RuntimeException( @@ -1241,26 +1243,9 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B aOwnLeft = aOwnRight; aOwnRight = aTmp; } - SwPosition* pParamLeft; - SwPosition* pParamRight; - if(pCursor) - { - const SwPaM* pTmp2 = pCursor->GetPaM(); - pParamLeft = new SwPosition(*pTmp2->GetPoint()); - pParamRight = new SwPosition(pTmp2->HasMark() ? *pTmp2->GetMark() : *pParamLeft); - } - else - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pParamLeft = new SwPosition(pBkmk->GetMarkPos()); - pParamRight = new SwPosition(pBkmk->IsExpanded() ? pBkmk->GetOtherMarkPos() : *pParamLeft); - } - if(*pParamRight < *pParamLeft) - { - SwPosition* pTmp2 = pParamLeft; - pParamLeft = pParamRight; - pParamRight = pTmp2; - } + SwPosition const* pParamLeft = pPam->Start(); + SwPosition const* pParamRight = pPam->End(); + // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche? if(aOwnRight > *pParamRight) *pOwnCursor->GetPoint() = aOwnRight; @@ -1271,35 +1256,19 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B *pOwnCursor->GetMark() = aOwnLeft; else *pOwnCursor->GetMark() = *pParamLeft; - delete pParamLeft; - delete pParamRight; } else { - //der Cursor soll dem uebergebenen Range entsprechen - if(pCursor) + // cursor should be the given range + *pOwnCursor->GetPoint() = *pPam->GetPoint(); + if (pPam->HasMark()) { - const SwPaM* pTmp2 = pCursor->GetPaM(); - *pOwnCursor->GetPoint() = *pTmp2->GetPoint(); - if(pTmp2->HasMark()) - { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = *pTmp2->GetMark(); - } - else - pOwnCursor->DeleteMark(); + pOwnCursor->SetMark(); + *pOwnCursor->GetMark() = *pPam->GetMark(); } else { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - *pOwnCursor->GetPoint() = pBkmk->GetMarkPos(); - if(pBkmk->IsExpanded()) - { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = pBkmk->GetOtherMarkPos(); - } - else - pOwnCursor->DeleteMark(); + pOwnCursor->DeleteMark(); } } } @@ -1923,7 +1892,7 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept const bool bForceExpandHints( (CURSOR_META != eType) ? false : dynamic_cast(xParentText.get())->CheckForOwnMemberMeta( - 0, GetPaM(), true) ); + *GetPaM(), true) ); DeleteAndInsert(aString, bForceExpandHints); } /* -----------------------------03.05.00 12:56-------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 53ee80c600..4bd21c4122 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1377,7 +1377,7 @@ SwXTextRange::SwXTextRange(SwPaM& rPam, xParentText(rxParent), pMark(NULL) { - _CreateNewBookmark(rPam); + SetPositions(rPam); } SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : @@ -1394,7 +1394,7 @@ SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : SwPosition aPosition( *pTblNode ); SwPaM aPam( aPosition ); - _CreateNewBookmark( aPam ); + SetPositions( aPam ); } SwXTextRange::~SwXTextRange() @@ -1405,7 +1405,7 @@ SwXTextRange::~SwXTextRange() pDoc->getIDocumentMarkAccess()->deleteMark(pBkmk); } -void SwXTextRange::_CreateNewBookmark(SwPaM& rPam) +void SwXTextRange::SetPositions(const SwPaM& rPam) { IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); @@ -1452,7 +1452,7 @@ void SwXTextRange::DeleteAndInsert( SwXTextCursor::SelectPam(aNewCrsr, sal_True); aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); } - _CreateNewBookmark(aNewCrsr); + SetPositions(aNewCrsr); pDoc->EndUndo(UNDO_INSERT, NULL); } } diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index c1a59bddbb..fa8acbf631 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -586,12 +586,10 @@ private: SwXMeta & m_rMeta; virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam); + const SwPaM & rPam); - virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + virtual bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException); protected: virtual const SwStartNode *GetStartNode() const; @@ -637,41 +635,18 @@ const SwStartNode *SwXMetaText::GetStartNode() const } void SwXMetaText::PrepareForAttach( uno::Reference & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam) + const SwPaM & rPam) { - SwPosition const* pPoint(0); - SwPosition const* pMark (0); - if (pRange) - { - ::sw::mark::IMark const& rIMark(*pRange->GetBookmark()); - pMark = &rIMark.GetMarkPos(); - if (rIMark.IsExpanded()) - { - pMark = &rIMark.GetOtherMarkPos(); - } - } - else if (pPam) - { - pPoint = pPam->GetPoint(); - if (pPam->HasMark()) - { - pMark = pPam->GetMark(); - } - } // create a new cursor to prevent modifying SwXTextRange - if (pPoint) - { - xRange = static_cast( - new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark)); - } + xRange = static_cast( + new SwXTextCursor(&m_rMeta, *rPam.GetPoint(), CURSOR_META, + GetDoc(), (rPam.HasMark()) ? rPam.GetMark() : 0)); } -bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException) { - return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb); + return m_rMeta.CheckForOwnMemberMeta(rPam, bAbsorb); } uno::Reference< text::XTextCursor > SwXMetaText::createCursor() @@ -884,11 +859,9 @@ bool SwXMeta::SetContentRange( return false; } -bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) +bool SwXMeta::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) throw (lang::IllegalArgumentException, uno::RuntimeException) { - ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range"); SwTxtNode * pTxtNode; xub_StrLen nMetaStart; xub_StrLen nMetaEnd; @@ -896,9 +869,8 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, ASSERT(bSuccess, "no pam?"); if (!bSuccess) throw lang::DisposedException(); - SwPosition const * const pStartPos( (pPam) - ? pPam->Start() - : &pRange->GetBookmark()->GetMarkStart() ); + + SwPosition const * const pStartPos( rPam.Start() ); if (&pStartPos->nNode.GetNode() != pTxtNode) { throw lang::IllegalArgumentException( @@ -921,14 +893,9 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, { bForceExpandHints = true; } - const bool bHasEnd( (pPam) - ? pPam->HasMark() - : pRange->GetBookmark()->IsExpanded()); - if (bHasEnd && bAbsorb) + if (rPam.HasMark() && bAbsorb) { - SwPosition const * const pEndPos( (pPam) - ? pPam->End() - : &pRange->GetBookmark()->GetMarkEnd() ); + SwPosition const * const pEndPos( rPam.End() ); if (&pEndPos->nNode.GetNode() != pTxtNode) { throw lang::IllegalArgumentException( diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 937e31710a..1600bbbb7a 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -91,16 +91,13 @@ const sal_Char cInvalidObject[] = "this object is invalid"; -----------------------------------------------------------------------*/ -void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > &, - const SwXTextRange* const, const SwPaM * const) +void +SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) { } -bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const, - const SwPaM* const, bool) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool) + throw (lang::IllegalArgumentException, uno::RuntimeException) { ASSERT(CURSOR_META != eCrsrType, "should not be called!"); return false; @@ -285,35 +282,43 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, if(pRange && pRange->GetDoc() == GetDoc() || pCursor && pCursor->GetDoc() == GetDoc()) { - const SwStartNode* pOwnStartNode = GetStartNode(); - if(pCursor) + const SwStartNode *const pOwnStartNode = GetStartNode(); + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) { - const SwStartNode* pTmp = pCursor->GetPaM()->GetNode()->StartOfSectionNode(); - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - if( !pOwnStartNode || pOwnStartNode != pTmp) + pPam = pCursor->GetPaM(); + } + else // pRange + { + if (pRange->GetPositions(aPam)) { - throw uno::RuntimeException(); + pPam = &aPam; } } - else //dann pRange + if (!pPam) { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - const SwStartNode* pTmp = pBkmk->GetMarkPos().nNode.GetNode().StartOfSectionNode(); - while(pTmp && pTmp->IsSectionNode()) + throw uno::RuntimeException(); + } + else + { + const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); + while (pTmp && pTmp->IsSectionNode()) + { pTmp = pTmp->StartOfSectionNode(); - if(!pOwnStartNode || pOwnStartNode != pTmp) + } + if (!pOwnStartNode || (pOwnStartNode != pTmp)) + { throw uno::RuntimeException(); + } } + bool bForceExpandHints( false ); if (CURSOR_META == eCrsrType) { try { - bForceExpandHints = CheckForOwnMemberMeta( - pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb); + bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); } catch (lang::IllegalArgumentException & iae) { @@ -348,10 +353,7 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, //hier wird ein PaM angelegt, der vor dem Parameter-PaM liegt, damit der //Text davor eingefuegt wird UnoActionContext aContext(GetDoc()); - const SwPosition* pPos = pCursor - ? pCursor->GetPaM()->Start() - : &pRange->GetBookmark()->GetMarkStart(); - SwPaM aInsertPam(*pPos); + SwPaM aInsertPam(*pPam->Start()); const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); GetDoc()->DoGroupUndo(sal_False); @@ -382,8 +384,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & SwUnoInternalPaM aPam(*GetDoc()); if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) { - const bool bForceExpandHints( - CheckForOwnMemberMeta( 0, &aPam, bAbsorb) ); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); const enum IDocumentContentOperations::InsertFlags nInsertFlags = (bForceExpandHints) @@ -424,7 +425,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & } if(pRange) { - pRange->_CreateNewBookmark(aTmp); + pRange->SetPositions(aTmp); } else if(pCursor) { @@ -462,7 +463,9 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); //hier muss der uebergebene PaM umgesetzt werden: if(pRange) - pRange->_CreateNewBookmark(aCrsr); + { + pRange->SetPositions(aCrsr); + } else { SwPaM* pUnoCrsr = pCursor->GetPaM(); @@ -541,33 +544,8 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang ; } - const SwNode* pSrcNode = 0; - if(pCursor && pCursor->GetPaM()) - { - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else if (pRange && pRange->GetBookmark()) - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); - } - else if (pPortion && pPortion->GetCursor()) - { - pSrcNode = pPortion->GetCursor()->GetNode(); - } - else if (pText) - { - uno::Reference xTextCursor = pText->createCursor(); - xTextCursor->gotoEnd(sal_True); - uno::Reference xCrsrTunnel( xTextCursor, uno::UNO_QUERY ); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else - throw lang::IllegalArgumentException(); - - const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); + const SwStartNode* pTmp = + aPam.GetNode()->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) @@ -587,8 +565,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang throw aRunException; } - const bool bForceExpandHints( CheckForOwnMemberMeta( - pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) ); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden // Bookmarks, IndexEntry @@ -627,8 +604,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang if (bForceExpandHints) { // if necessary, replace xTempRange with a new SwXTextCursor - PrepareForAttach(xTempRange, pRange, - (pCursor) ? pCursor->GetPaM() : 0); + PrepareForAttach(xTempRange, aPam); } xContent->attach(xTempRange); } @@ -1047,13 +1023,19 @@ sal_Bool SwXText::CheckForOwnMember( } const SwNode* pSrcNode; - if(pCursor) + if (pCursor) + { pSrcNode = pCursor->GetPaM()->GetNode(); - else //dann pRange + } + else // pRange { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); + SwPaM aPam(pRange->GetDoc()->GetNodes().GetEndOfContent()); + if (pRange->GetPositions(aPam)) + { + pSrcNode = aPam.GetNode(); + } } + if (!pSrcNode) { return sal_False; } const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen @@ -1107,18 +1089,8 @@ sal_Int16 SwXText::ComparePositions( if(CheckForOwnMember(pRange1, pCursor1) && CheckForOwnMember( pRange2, pCursor2)) { - const SwPosition *pStart1 = 0; - const SwPosition *pStart2 = 0; - - if(pRange1) - pStart1 = pRange1->GetBookmark() ? &(pRange1->GetBookmark()->GetMarkStart()) : 0; - else - pStart1 = pCursor1->GetPaM() ? pCursor1->GetPaM()->Start() : 0; - - if(pRange2) - pStart2 = pRange2->GetBookmark() ? &(pRange2->GetBookmark()->GetMarkStart()) : 0; - else - pStart2 = pCursor2->GetPaM() ? pCursor2->GetPaM()->Start() : 0; + SwPosition const*const pStart1 = aPam1.Start(); + SwPosition const*const pStart2 = aPam2.Start(); if(pStart1 && pStart2) { diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index f9b672df97..481d366f4e 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -411,25 +411,25 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR SwCntntNode * pNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() )); - sal_Bool bRet = sal_False; + bool bRet = false; pInsDoc->LockExpFlds(); { + SwDoc *const pDoc((pxCursor) ? pxCursor->GetDoc() : pxRange->GetDoc()); + SwPaM aPam(pDoc->GetNodes()); + SwPaM * pPam(0); if(pxCursor) { - SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet = pxCursor->GetDoc()->CopyRange( *pUnoCrsr, aPos, false ) - || bRet; + pPam = pxCursor->GetPaM(); } else { - const ::sw::mark::IMark* const pBkmk = pxRange->GetBookmark(); - if(pBkmk && pBkmk->IsExpanded()) + if (pxRange->GetPositions(aPam)) { - SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - bRet = pxRange->GetDoc()->CopyRange(aTmp, aPos, false) - || bRet; + pPam = & aPam; } } + if (!pPam) { return false; } + bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet; } pInsDoc->UnlockExpFlds(); @@ -1113,7 +1113,7 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR } SwDoc* pDoc = 0; - if ( pRange && pRange->GetBookmark()) + if (pRange) pDoc = pRange->GetDoc(); else if ( pCursor ) pDoc = pCursor->GetDoc(); @@ -1131,29 +1131,23 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR if(!pDoc) throw uno::RuntimeException(); - SwPaM* pInsertPaM = 0; - if(pRange) + + SwPaM InsertPaM(pDoc->GetNodes()); + if (pRange) { - const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); - if(pBkmk->IsExpanded()) - pInsertPaM = new SwPaM(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - else - pInsertPaM = new SwPaM(pBkmk->GetMarkPos()); + if (!pRange->GetPositions(InsertPaM)) + { + throw uno::RuntimeException(); + } } else { - SwPaM* pCrsr = pCursor->GetPaM(); - if(pCrsr->HasMark()) - pInsertPaM = new SwPaM(*pCrsr->GetPoint(), *pCrsr->GetMark()); - else - pInsertPaM = new SwPaM(*pCrsr->GetPoint()); + InsertPaM = *pCursor->GetPaM(); } - SwTextBlocks* pBlock = pGlossaries->GetGroupDoc(sGroupName); - sal_Bool bResult = pBlock && !pBlock->GetError() && - pDoc->InsertGlossary( *pBlock, sEntryName, *pInsertPaM); - delete pBlock; - delete pInsertPaM; + ::std::auto_ptr pBlock(pGlossaries->GetGroupDoc(sGroupName)); + const bool bResult = pBlock.get() && !pBlock->GetError() + && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM); if(!bResult) throw uno::RuntimeException(); diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 9a352aa5ee..e314b306e9 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -1418,10 +1418,13 @@ void SwXTextViewCursor::gotoRange( { pSrcNode = pCursor->GetPaM()->GetNode(); } - else if(pRange && pRange->GetBookmark()) + else if (pRange) { - const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); - pSrcNode = &(pBkmk->GetMarkPos().nNode.GetNode()); + SwPaM aPam(pRange->GetDoc()->GetNodes()); + if (pRange->GetPositions(aPam)) + { + pSrcNode = aPam.GetNode(); + } } else if (pPara && pPara->GetTxtNode()) { -- cgit v1.2.3 From 9b80f003bbccd42794138744d3568cf41cda7568 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:52 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXTextRange: 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. --- sw/inc/unotextrange.hxx | 54 +--- sw/source/core/unocore/unoobj2.cxx | 645 ++++++++++++++++++++++--------------- sw/source/core/unocore/unotext.cxx | 14 +- 3 files changed, 400 insertions(+), 313 deletions(-) diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 079296d2a4..8b34ce7f94 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -45,26 +45,15 @@ #include #include -#include #include #include -class String; -class SfxItemPropertySet; class SwDoc; -class SwStartNode; struct SwPosition; class SwPaM; class SwUnoCrsr; class SwFrmFmt; -class SwTableBox; - -namespace sw { - namespace mark { - class IMark; - } -} /* -----------------29.04.98 07:35------------------- * @@ -104,13 +93,15 @@ typedef ::cppu::WeakImplHelper8 class SW_DLLPUBLIC SwXTextRange : public SwXTextRange_Base - , private SwClient { private: friend class SwXText; + class Impl; + ::sw::UnoImplPtr m_pImpl; + enum RangePosition { RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange @@ -118,26 +109,14 @@ private: RANGE_IN_CELL, // position created with a cell that has no uno object RANGE_IS_TABLE, // anchor of a table RANGE_INVALID // created by NewInstance - } eRangePosition; - - SwDoc* pDoc; - SwTableBox* pBox; - const SwStartNode* pBoxStartNode; - SwDepend aObjectDepend; // register at format of table or frame - const SfxItemPropertySet* m_pPropSet; - //SwDepend aFrameDepend; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - xParentText; - ::sw::mark::IMark* pMark; - - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } + }; + void SetPositions(SwPaM const& rPam); //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText, const bool bForceExpandHints) + void DeleteAndInsert( + const ::rtl::OUString& rText, const bool bForceExpandHints) throw (::com::sun::star::uno::RuntimeException); - -protected: + void Invalidate(); virtual ~SwXTextRange(); @@ -146,31 +125,26 @@ public: SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & xParent, - enum RangePosition eRange = RANGE_IN_TEXT); + const enum RangePosition eRange = RANGE_IN_TEXT); // only for RANGE_IS_TABLE SwXTextRange(SwFrmFmt& rTblFmt); - BOOL GetPositions(SwPaM& rToFill) const; - const SwDoc* GetDoc() const - { return pDoc; } - SwDoc* GetDoc() - { return pDoc; } + const SwDoc* GetDoc() const; + SwDoc* GetDoc(); + bool GetPositions(SwPaM & rToFill) const; static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc* pDoc, const SwPosition& rPos); - TYPEINFO(); - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); // XUnoTunnel diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 4bd21c4122..71061001d6 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1314,83 +1314,97 @@ throw (container::NoSuchElementException, lang::WrappedTargetException, /****************************************************************** * SwXTextRange ******************************************************************/ -TYPEINIT1(SwXTextRange, SwClient); -const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId() +class SwXTextRange::Impl + : public SwClient { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} -//XUnoTunnel -sal_Int64 SAL_CALL SwXTextRange::getSomething( - const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) +public: + + const SfxItemPropertySet & m_rPropSet; + const enum RangePosition m_eRangePosition; + SwDoc & m_rDoc; + uno::Reference m_xParentText; + SwDepend m_ObjectDepend; // register at format of table or frame + ::sw::mark::IMark * m_pMark; + + Impl( SwDoc & rDoc, const enum RangePosition eRange, + SwFrmFmt *const pTblFmt = 0, + const uno::Reference< text::XText > & xParent = 0) + : SwClient() + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) + , m_eRangePosition(eRange) + , m_rDoc(rDoc) + , m_xParentText(xParent) + , m_ObjectDepend(this, pTblFmt) + , m_pMark(0) + { + } + + ~Impl() + { + // Impl owns the bookmark; delete it here: SolarMutex is locked + Invalidate(); + } + + void Invalidate() + { + if (m_pMark) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast (this) ); + m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark); + m_pMark = 0; } - return 0; -} + } -OUString SwXTextRange::getImplementationName(void) throw( RuntimeException ) -{ - return OUString::createFromAscii("SwXTextRange"); -} + const ::sw::mark::IMark * GetBookmark() const { return m_pMark; } -BOOL SwXTextRange::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextRange") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex"); -} + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); -Sequence< OUString > SwXTextRange::getSupportedServiceNames(void) throw( RuntimeException ) +}; + +void SwXTextRange::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - Sequence< OUString > aRet(7); - aRet[0] = OUString::createFromAscii("com.sun.star.text.TextRange"); - aRet[1] = OUString::createFromAscii("com.sun.star.style.CharacterProperties"); - aRet[2] = OUString::createFromAscii("com.sun.star.style.CharacterPropertiesAsian"); - aRet[3] = OUString::createFromAscii("com.sun.star.style.CharacterPropertiesComplex"); - aRet[4] = OUString::createFromAscii("com.sun.star.style.ParagraphProperties"); - aRet[5] = OUString::createFromAscii("com.sun.star.style.ParagraphPropertiesAsian"); - aRet[6] = OUString::createFromAscii("com.sun.star.style.ParagraphPropertiesComplex"); - return aRet; + const bool bAlreadyRegistered = 0 != GetRegisteredIn(); + ClientModify(this, pOld, pNew); + if (m_ObjectDepend.GetRegisteredIn()) + { + ClientModify(&m_ObjectDepend, pOld, pNew); + // if the depend was removed then the range must be removed too + if (!m_ObjectDepend.GetRegisteredIn() && GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + } + // or if the range has been removed but the depend ist still + // connected then the depend must be removed + else if (bAlreadyRegistered && !GetRegisteredIn() && + m_ObjectDepend.GetRegisteredIn()) + { + const_cast(m_ObjectDepend.GetRegisteredIn()) + ->Remove(& m_ObjectDepend); + } + } + if (!GetRegisteredIn()) + { + m_pMark = 0; + } } + SwXTextRange::SwXTextRange(SwPaM& rPam, - const uno::Reference< XText > & rxParent, enum RangePosition eRange) : - eRangePosition(eRange), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, 0), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(rxParent), - pMark(NULL) + const uno::Reference< text::XText > & xParent, + const enum RangePosition eRange) + : m_pImpl( new SwXTextRange::Impl(*rPam.GetDoc(), eRange, 0, xParent) ) { SetPositions(rPam); } -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : - eRangePosition(RANGE_IS_TABLE), - pDoc(rTblFmt.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) +SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) + : m_pImpl( + new SwXTextRange::Impl(*rTblFmt.GetDoc(), RANGE_IS_TABLE, &rTblFmt) ) { - SwTable* pTable = SwTable::FindTable( &rTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode( ); + SwTable *const pTable = SwTable::FindTable( &rTblFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); SwPosition aPosition( *pTblNode ); SwPaM aPam( aPosition ); @@ -1399,181 +1413,221 @@ SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : SwXTextRange::~SwXTextRange() { - vos::OGuard aGuard(Application::GetSolarMutex()); - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) - pDoc->getIDocumentMarkAccess()->deleteMark(pBkmk); } -void SwXTextRange::SetPositions(const SwPaM& rPam) +const SwDoc * SwXTextRange::GetDoc() const { - IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); + return & m_pImpl->m_rDoc; +} - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) - pMarkAccess->deleteMark(pBkmk); - pMark = pMarkAccess->makeMark(rPam, ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK); - pMark->Add(this); +SwDoc * SwXTextRange::GetDoc() +{ + return & m_pImpl->m_rDoc; +} + + +void SwXTextRange::Invalidate() +{ + m_pImpl->Invalidate(); +} + +void SwXTextRange::SetPositions(const SwPaM& rPam) +{ + m_pImpl->Invalidate(); + IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess(); + m_pImpl->m_pMark = pMA->makeMark(rPam, ::rtl::OUString(), + IDocumentMarkAccess::UNO_BOOKMARK); + m_pImpl->m_pMark->Add(m_pImpl.get()); } void SwXTextRange::DeleteAndInsert( - const String& rText, const bool bForceExpandHints) - throw(uno::RuntimeException) + const ::rtl::OUString& rText, const bool bForceExpandHints) +throw (uno::RuntimeException) { - if (RANGE_IS_TABLE == eRangePosition) + if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { // setString on table not allowed throw uno::RuntimeException(); } - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + SwCursor aCursor(aPos, 0, false); + if (GetPositions(aCursor)) { - const SwPosition& rPoint = pBkmk->GetMarkStart(); - SwCursor aNewCrsr(rPoint, 0, false); - if(pBkmk->IsExpanded()) - { - aNewCrsr.SetMark(); - const SwPosition& rMark = pBkmk->GetMarkEnd(); - *aNewCrsr.GetMark() = rMark; - } - UnoActionContext aAction(pDoc); - pDoc->StartUndo(UNDO_INSERT, NULL); - if(aNewCrsr.HasMark()) + UnoActionContext aAction(& m_pImpl->m_rDoc); + m_pImpl->m_rDoc.StartUndo(UNDO_INSERT, NULL); + if (aCursor.HasMark()) { - pDoc->DeleteAndJoin(aNewCrsr); + m_pImpl->m_rDoc.DeleteAndJoin(aCursor); } - if(rText.Len()) + if (rText.getLength()) { SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, aNewCrsr, rText, bForceExpandHints); + m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints); - SwXTextCursor::SelectPam(aNewCrsr, sal_True); - aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); + SwXTextCursor::SelectPam(aCursor, sal_True); + aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } - SetPositions(aNewCrsr); - pDoc->EndUndo(UNDO_INSERT, NULL); + SetPositions(aCursor); + m_pImpl->m_rDoc.EndUndo(UNDO_INSERT, NULL); } } -uno::Reference< XText > SwXTextRange::getText(void) throw( uno::RuntimeException ) +const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; +} + +// XUnoTunnel +sal_Int64 SAL_CALL +SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + return ::sw::UnoTunnelImpl(rId, this); +} + +OUString SAL_CALL +SwXTextRange::getImplementationName() throw (uno::RuntimeException) +{ + return OUString::createFromAscii("SwXTextRange"); +} + +static char const*const g_ServicesTextRange[] = +{ + "com.sun.star.text.TextRange", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", +}; +static const size_t g_nServicesTextRange( + sizeof(g_ServicesTextRange)/sizeof(g_ServicesTextRange[0])); + +sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesTextRange, g_ServicesTextRange, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXTextRange::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextRange, g_ServicesTextRange); +} + +uno::Reference< text::XText > SAL_CALL +SwXTextRange::getText() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!xParentText.is()) + + if (!m_pImpl->m_xParentText.is()) { - if (eRangePosition == RANGE_IS_TABLE && - aObjectDepend.GetRegisteredIn() ) - { - SwFrmFmt* pTblFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); - SwTable* pTable = SwTable::FindTable( pTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwPosition aPosition( *pTblNode ); - uno::Reference< XTextRange > xRange = - SwXTextRange::CreateTextRangeFromPosition(pDoc, aPosition, 0); - xParentText = xRange->getText(); - } - else + if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE && + m_pImpl->m_ObjectDepend.GetRegisteredIn()) { - OSL_ENSURE(false, "SwXTextRange::getText: no text"); + SwFrmFmt const*const pTblFmt = static_cast( + m_pImpl->m_ObjectDepend.GetRegisteredIn()); + SwTable const*const pTable = SwTable::FindTable( pTblFmt ); + SwTableNode const*const pTblNode = pTable->GetTableNode(); + const SwPosition aPosition( *pTblNode ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateTextRangeFromPosition( + &m_pImpl->m_rDoc, aPosition, 0); + m_pImpl->m_xParentText = xRange->getText(); } } - return xParentText; + OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text"); + return m_pImpl->m_xParentText; } -uno::Reference< XTextRange > SwXTextRange::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextRange::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!xParentText.is()) + uno::Reference< text::XTextRange > xRet; + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); + if (!m_pImpl->m_xParentText.is()) + { getText(); + } if(pBkmk) { SwPaM aPam(pBkmk->GetMarkStart()); - xRet = new SwXTextRange(aPam, xParentText); + xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText); } - else if(eRangePosition == RANGE_IS_TABLE) + else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { - //start and end are this, if its a table + // start and end are this, if its a table xRet = this; } else + { throw uno::RuntimeException(); + } return xRet; } -uno::Reference< XTextRange > SwXTextRange::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextRange::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!xParentText.is()) + + uno::Reference< text::XTextRange > xRet; + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); + if (!m_pImpl->m_xParentText.is()) + { getText(); + } if(pBkmk) { SwPaM aPam(pBkmk->GetMarkEnd()); - xRet = new SwXTextRange(aPam, xParentText); + xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText); } - else if(eRangePosition == RANGE_IS_TABLE) + else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { - //start and end are this, if its a table + // start and end are this, if its a table xRet = this; } else + { throw uno::RuntimeException(); + } return xRet; } -OUString SwXTextRange::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextRange::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + OUString sRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); // for tables there is no bookmark, thus also no text // one could export the table as ASCII here maybe? - if(pBkmk && pBkmk->IsExpanded()) + SwPaM aPaM(GetDoc()->GetNodes()); + if (GetPositions(aPaM) && aPaM.HasMark()) { - const SwPosition& rPoint = pBkmk->GetMarkPos(); - const SwPosition& rMark = pBkmk->GetOtherMarkPos(); - SwPaM aCrsr(rMark, rPoint); - SwXTextCursor::getTextFromPam(aCrsr, sRet); + SwXTextCursor::getTextFromPam(aPaM, sRet); } return sRet; } -void SwXTextRange::setString(const OUString& aString) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextRange::setString(const OUString& rString) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - DeleteAndInsert(aString, false); -} -void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - sal_Bool bAlreadyRegisterred = 0 != GetRegisteredIn(); - ClientModify(this, pOld, pNew); - if(aObjectDepend.GetRegisteredIn()) - { - ClientModify(&aObjectDepend, pOld, pNew); - // if the depend was removed then the range must be removed too - if(!aObjectDepend.GetRegisteredIn() && GetRegisteredIn()) - ((SwModify*)GetRegisteredIn())->Remove(this); - // or if the range has been removed but the depend ist still - // connected then the depend must be removed - else if(bAlreadyRegisterred && !GetRegisteredIn() && - aObjectDepend.GetRegisteredIn()) - ((SwModify*)aObjectDepend.GetRegisteredIn())->Remove(&aObjectDepend); - } - if(!GetRegisteredIn()) - pMark = NULL; + DeleteAndInsert(rString, false); } -sal_Bool SwXTextRange::GetPositions(SwPaM& rToFill) const +bool SwXTextRange::GetPositions(SwPaM& rToFill) const { - sal_Bool bRet = sal_False; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); if(pBkmk) { *rToFill.GetPoint() = pBkmk->GetMarkPos(); @@ -1583,10 +1637,12 @@ sal_Bool SwXTextRange::GetPositions(SwPaM& rToFill) const *rToFill.GetMark() = pBkmk->GetOtherMarkPos(); } else + { rToFill.DeleteMark(); - bRet = sal_True; + } + return true; } - return bRet; + return false; } sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, @@ -1806,187 +1862,248 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, return xParentText; } -uno::Reference< XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration( - const OUString& rServiceName) - throw(RuntimeException) +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextRange::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) { - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if( !pBkmk || COMPARE_EQUAL != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) - throw RuntimeException(); + vos::OGuard g(Application::GetSolarMutex()); - const SwPosition& rPoint = pBkmk->GetMarkPos(); - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPoint, FALSE); - if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = pBkmk->GetOtherMarkPos(); + throw uno::RuntimeException(); } - uno::Reference< XEnumeration > xRet = new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE); - delete pNewCrsr; + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + const ::std::auto_ptr pNewCrsr( + m_pImpl->m_rDoc.CreateUnoCrsr(aPos, FALSE)); + if (!GetPositions(*pNewCrsr)) + { + throw uno::RuntimeException(); + } + + const uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE); return xRet; } -uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextRange::createEnumeration() throw (uno::RuntimeException) { - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!pBkmk) throw RuntimeException(); - const SwPosition& rPoint = pBkmk->GetMarkPos(); - ::std::auto_ptr pNewCrsr(pDoc->CreateUnoCrsr(rPoint, sal_False)); - if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) + vos::OGuard g(Application::GetSolarMutex()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = pBkmk->GetOtherMarkPos(); + throw uno::RuntimeException(); } - uno::Reference xTunnel(xParentText, UNO_QUERY); - SwXText* pParentText = 0; - if(xTunnel.is()) + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + ::std::auto_ptr pNewCrsr( + m_pImpl->m_rDoc.CreateUnoCrsr(aPos, FALSE)); + if (!GetPositions(*pNewCrsr)) { - pParentText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + throw uno::RuntimeException(); } - DBG_ASSERT(pParentText, "parent is not a SwXText"); - if (!pParentText) + if (!m_pImpl->m_xParentText.is()) { - throw uno::RuntimeException(); + getText(); } - const CursorType eSetType = (RANGE_IN_CELL == eRangePosition) + const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition) ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - const uno::Reference< XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration(m_pImpl->m_xParentText, pNewCrsr, eSetType); return xRet; } -uno::Type SwXTextRange::getElementType(void) throw( RuntimeException ) +uno::Type SAL_CALL SwXTextRange::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } -sal_Bool SwXTextRange::hasElements(void) throw( RuntimeException ) +sal_Bool SAL_CALL SwXTextRange::hasElements() throw (uno::RuntimeException) { return sal_True; } -Sequence< OUString > SAL_CALL SwXTextRange::getAvailableServiceNames(void) throw( RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXTextRange::getAvailableServiceNames() throw (uno::RuntimeException) { - Sequence< OUString > aRet(1); + uno::Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); return aRet; } -uno::Reference< XPropertySetInfo > SAL_CALL SwXTextRange::getPropertySetInfo( ) throw(RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextRange::getPropertySetInfo() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - static uno::Reference< XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + + static uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xRef; } -void SAL_CALL SwXTextRange::setPropertyValue( - const OUString& rPropertyName, const Any& rValue ) - throw(UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException) +void SAL_CALL +SwXTextRange::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } SwPaM aPaM(GetDoc()->GetNodes()); - SwXTextRange::GetPositions(aPaM); - SwXTextCursor::SetPropertyValue(aPaM, *m_pPropSet, rPropertyName, rValue); + GetPositions(aPaM); + SwXTextCursor::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, + rPropertyName, rValue); } -Any SAL_CALL SwXTextRange::getPropertyValue( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextRange::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyValue(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SAL_CALL SwXTextRange::addPropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::addPropertyChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::removePropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::removePropertyChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::addVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::addVetoableChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::removeVetoableChangeListener(): not implemented"); } -PropertyState SAL_CALL SwXTextRange::getPropertyState( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SAL_CALL +SwXTextRange::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyState(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyState(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -Sequence< PropertyState > SAL_CALL SwXTextRange::getPropertyStates( - const Sequence< OUString >& rPropertyName ) throw(UnknownPropertyException, RuntimeException) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyStates(aPaM, *m_pPropSet, rPropertyName); + vos::OGuard g(Application::GetSolarMutex()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SAL_CALL SwXTextRange::setPropertyToDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - SwXTextCursor::SetPropertyToDefault(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + SwXTextCursor::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -Any SAL_CALL SwXTextRange::getPropertyDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextRange::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyDefault(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SwXTextRange::makeRedline( - const ::rtl::OUString& rRedlineType, - const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::makeRedline( + const ::rtl::OUString& rRedlineType, + const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); SwXTextRange::GetPositions(aPaM); SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties ); } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 1600bbbb7a..98c81df1f4 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1594,17 +1594,13 @@ uno::Reference< text::XTextContent > SwXText::convertToTextFrame( //bookmarks have to be removed before the referenced text node is deleted in DelFullPara if(pStartRange) { - ::sw::mark::IMark const * const pStartBookmark = pStartRange->GetBookmark(); - if(pStartBookmark) - pDoc->getIDocumentMarkAccess()->deleteMark(pStartBookmark); - } + pStartRange->Invalidate(); + } if(pEndRange) { - ::sw::mark::IMark const * const pEndBookmark = pEndRange->GetBookmark(); - if(pEndBookmark) - pDoc->getIDocumentMarkAccess()->deleteMark(pEndBookmark); - } - + pEndRange->Invalidate(); + } + pDoc->StartUndo( UNDO_START, NULL ); bool bIllegalException = false; bool bRuntimeException = false; -- cgit v1.2.3 From f1bb18796899fe48e916b7b92ef99c394febf07e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:53 +0100 Subject: swunolocking1: #i105557#: SwXTextRange: move static methods to namespace sw. clean up the implementation a little. --- sw/inc/unotextrange.hxx | 22 ++- sw/source/core/access/accpara.cxx | 6 +- sw/source/core/crsr/crsrsh.cxx | 4 +- sw/source/core/unocore/unobkm.cxx | 6 +- sw/source/core/unocore/unodraw.cxx | 12 +- sw/source/core/unocore/unofield.cxx | 6 +- sw/source/core/unocore/unoflatpara.cxx | 8 +- sw/source/core/unocore/unoframe.cxx | 8 +- sw/source/core/unocore/unoftn.cxx | 7 +- sw/source/core/unocore/unoidx.cxx | 6 +- sw/source/core/unocore/unoobj2.cxx | 175 +++++++++++++---------- sw/source/core/unocore/unoparagraph.cxx | 2 +- sw/source/core/unocore/unoredline.cxx | 7 +- sw/source/core/unocore/unorefmk.cxx | 17 +-- sw/source/core/unocore/unosect.cxx | 4 +- sw/source/core/unocore/unotbl.cxx | 5 +- sw/source/core/unocore/unotext.cxx | 20 +-- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 4 +- sw/source/filter/xml/swxml.cxx | 5 +- sw/source/filter/xml/xmlimp.cxx | 6 +- sw/source/filter/xml/xmltbli.cxx | 4 +- sw/source/ui/dialog/SwSpellDialogChildWindow.cxx | 9 +- sw/source/ui/uno/unotxdoc.cxx | 18 ++- sw/source/ui/uno/unotxvw.cxx | 14 +- 24 files changed, 198 insertions(+), 177 deletions(-) diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 8b34ce7f94..c3c3d362db 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -77,6 +77,13 @@ namespace sw { void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget); + bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange); + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateParentXText(SwDoc & rDoc, const SwPosition& rPos); + } // namespace sw @@ -105,10 +112,8 @@ private: enum RangePosition { RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange - RANGE_IN_FRAME, // position created with a frame that has no uno object RANGE_IN_CELL, // position created with a cell that has no uno object RANGE_IS_TABLE, // anchor of a table - RANGE_INVALID // created by NewInstance }; void SetPositions(SwPaM const& rPam); @@ -133,17 +138,10 @@ public: SwDoc* GetDoc(); bool GetPositions(SwPaM & rToFill) const; - static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange); - static ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( - SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark); - - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - CreateParentXText(SwDoc* pDoc, const SwPosition& rPos); + ::com::sun::star::text::XTextRange > CreateXTextRange( + SwDoc & rDoc, + const SwPosition& rPos, const SwPosition *const pMark); static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index c9de2c74df..eac4a4fdaf 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2105,8 +2105,10 @@ sal_Bool SwAccessibleParagraph::replaceText( aEndPos.nContent = nEnd; // now create XTextRange as helper and set string - SwXTextRange::CreateTextRangeFromPosition( - pNode->GetDoc(), aStartPos, &aEndPos)->setString(sReplacement); + const uno::Reference xRange( + SwXTextRange::CreateXTextRange( + *pNode->GetDoc(), aStartPos, &aEndPos)); + xRange->setString(sReplacement); // delete portion data ClearPortionData(); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 674b95634d..ec0a07b306 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -3372,8 +3372,8 @@ void lcl_FillTextRange( uno::Reference& rRange, SwPosition aEndPos( aStartPos ); aEndPos.nContent = nBegin + nLen; - uno::Reference xRange = - SwXTextRange::CreateTextRangeFromPosition( rNode.GetDoc(), aStartPos, &aEndPos); + const uno::Reference xRange = + SwXTextRange::CreateXTextRange(*rNode.GetDoc(), aStartPos, &aEndPos); rRange = xRange; } diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 24d1ccd7d6..561f145473 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -237,7 +237,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) m_pImpl->m_pDoc = pDoc; SwUnoInternalPaM aPam(*m_pImpl->m_pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(m_pImpl->m_pDoc); if (!m_pImpl->m_sMarkName.getLength()) { @@ -294,8 +294,8 @@ SwXBookmark::getAnchor() throw (uno::RuntimeException) { throw uno::RuntimeException(); } - return SwXTextRange::CreateTextRangeFromPosition( - m_pImpl->m_pDoc, + return SwXTextRange::CreateXTextRange( + *m_pImpl->m_pDoc, m_pImpl->m_pRegisteredBookmark->GetMarkPos(), (m_pImpl->m_pRegisteredBookmark->IsExpanded()) ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL); diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 06c1961c73..00e129efc4 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -784,7 +784,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) if( pDesc && (xRg = pDesc->GetTextRange()).is() ) { pInternalPam = new SwUnoInternalPaM(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg)) + if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg)) { if(FLY_AT_FLY == aAnchor.GetAnchorId() && !pInternalPam->GetNode()->FindFlyStartNode()) @@ -1302,7 +1302,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A new SwUnoInternalPaM( *(pFmt->GetDoc()) ); uno::Reference< text::XTextRange > xRg; aValue >>= xRg; - if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) ) + if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) ) { if (aAnchor.GetAnchorId() == FLY_AS_CHAR) { @@ -1634,9 +1634,9 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName) { if ( aAnchor.GetCntntAnchor() ) { - uno::Reference< text::XTextRange > xTextRange = - SwXTextRange::CreateTextRangeFromPosition( - pFmt->GetDoc(), + const uno::Reference< text::XTextRange > xTextRange + = SwXTextRange::CreateXTextRange( + *pFmt->GetDoc(), *aAnchor.GetCntntAnchor(), 0L ); aRet.setValue(&xTextRange, ::getCppuType((uno::Reference*)0)); @@ -2203,7 +2203,7 @@ uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::Runtim (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); - aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0); + aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); } } else diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 31f4659c22..161a71136b 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1305,7 +1305,7 @@ void SwXTextField::attachToRange( { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); SwField* pFld = 0; switch(m_nServiceId) { @@ -1880,8 +1880,8 @@ uno::Reference< text::XTextRange > SwXTextField::getAnchor(void) throw( uno::Ru SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart()); - aRef = SwXTextRange::CreateTextRangeFromPosition(m_pDoc, - *aPam.GetPoint(), aPam.GetMark()); + aRef = SwXTextRange::CreateXTextRange( + *m_pDoc, *aPam.GetPoint(), aPam.GetMark()); } return aRef; diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index c5055394cd..d45125c2d2 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -218,7 +218,9 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c UnoActionContext aAction( mpTxtNode->GetDoc() ); - uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition( mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateXTextRange( + *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { @@ -246,7 +248,9 @@ void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 n UnoActionContext aAction( mpTxtNode->GetDoc() ); - uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition( mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateXTextRange( + *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 5457e7d0f5..841465009f 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2056,7 +2056,7 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::Runtim (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); - aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0); + aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); } } else @@ -2098,7 +2098,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan { SwUnoInternalPaM aIntPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aIntPam, xTextRange); + ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); SwPaM aPam(rNode); @@ -2430,7 +2430,7 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) } SwDoc* pDoc = pFmt->GetDoc(); SwUnoInternalPaM aIntPam(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(aIntPam, xTextRange)) + if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) { SfxItemSet aSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR ); @@ -2672,7 +2672,7 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextCursor > aRef; SwFrmFmt* pFmt = GetFrmFmt(); SwUnoInternalPaM aPam(*GetDoc()); - if(pFmt && SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); #if OSL_DEBUG_LEVEL > 1 diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 4f07cebed1..26333dd73d 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -251,7 +251,7 @@ void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xText { SwUnoInternalPaM aPam(*pNewDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(pNewDoc); SwTxtAttr* pTxtAttr = 0; @@ -315,7 +315,8 @@ uno::Reference< text::XTextRange > SwXFootnote::getAnchor(void) throw( uno::Run SwPosition aMark( *aPam.Start() ); aPam.SetMark(); aPam.GetMark()->nContent++; - aRef = SwXTextRange::CreateTextRangeFromPosition((SwDoc*)GetDoc(), *aPam.Start(), aPam.End()); + aRef = SwXTextRange::CreateXTextRange( + *GetDoc(), *aPam.Start(), aPam.End()); } else throw uno::RuntimeException(); @@ -412,7 +413,7 @@ uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( throw uno::RuntimeException(); uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); const SwNode* pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 904e7dfcdb..5cfaf16fc5 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1030,7 +1030,7 @@ void SwXDocumentIndex::attachToRange(const uno::Reference< text::XTextRange > & { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); if(!pOld) @@ -1092,7 +1092,7 @@ uno::Reference< text::XTextRange > SwXDocumentIndex::getAnchor(void) throw( uno aPaM.SetMark(); aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); aPaM.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateTextRangeFromPosition(pSectFmt->GetDoc(), + xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), *aPaM.GetMark(), aPaM.GetPoint()); } } @@ -1469,7 +1469,7 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); SwTOXMark aMark (pTOXType); if(sAltText.Len()) aMark.SetAlternativeText(sAltText); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 71061001d6..36afe319cb 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1536,10 +1536,8 @@ SwXTextRange::getText() throw (uno::RuntimeException) SwTable const*const pTable = SwTable::FindTable( pTblFmt ); SwTableNode const*const pTblNode = pTable->GetTableNode(); const SwPosition aPosition( *pTblNode ); - const uno::Reference< text::XTextRange > xRange = - SwXTextRange::CreateTextRangeFromPosition( - &m_pImpl->m_rDoc, aPosition, 0); - m_pImpl->m_xParentText = xRange->getText(); + m_pImpl->m_xParentText = + ::sw::CreateParentXText(m_pImpl->m_rDoc, aPosition); } } OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text"); @@ -1645,10 +1643,12 @@ bool SwXTextRange::GetPositions(SwPaM& rToFill) const return false; } -sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, - const uno::Reference< XTextRange > & xTextRange) +namespace sw { + +bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, + const uno::Reference< text::XTextRange > & xTextRange) { - sal_Bool bRet = sal_False; + bool bRet = false; uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; @@ -1658,27 +1658,26 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, SwXParagraph* pPara = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pPortion = reinterpret_cast< SwXTextPortion * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) )); - pText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) )); - pPara = reinterpret_cast< SwXParagraph * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pPortion= + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pText = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pPara = ::sw::UnoTunnelGetImplementation(xRangeTunnel); } - //if it's a text cursor then create a temporary cursor there and re-use the pCursor variable - uno::Reference< XTextCursor > xTextCursor; + // if it's a text then create a temporary cursor there and re-use + // the pCursor variable if(pText) { - xTextCursor = pText->createCursor(); + const uno::Reference< text::XTextCursor > xTextCursor = + pText->createCursor(); xTextCursor->gotoEnd(sal_True); - uno::Reference xCrsrTunnel( xTextCursor, UNO_QUERY); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + const uno::Reference xCrsrTunnel( + xTextCursor, uno::UNO_QUERY); + pCursor = + ::sw::UnoTunnelGetImplementation(xCrsrTunnel); } if(pRange && pRange->GetDoc() == rToFill.GetDoc()) { @@ -1698,8 +1697,9 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, : ((pPortion) ? pPortion->GetCursor() : 0); if (pUnoCrsr && pDoc == rToFill.GetDoc()) { - DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); - bRet = sal_True; + DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, + "what to do about rings?"); + bRet = true; *rToFill.GetPoint() = *pUnoCrsr->GetPoint(); if (pUnoCrsr->HasMark()) { @@ -1714,53 +1714,65 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, return bRet; } -sal_Bool lcl_IsStartNodeInFormat(sal_Bool bHeader, SwStartNode* pSttNode, - const SwFrmFmt* pFrmFmt, SwFrmFmt*& rpFormat) +static bool +lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode *const pSttNode, + SwFrmFmt const*const pFrmFmt, SwFrmFmt*& rpFormat) { - sal_Bool bRet = sal_False; + bool bRet = false; const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); const SfxPoolItem* pItem; - SwFrmFmt* pHeadFootFmt; - if(SFX_ITEM_SET == rSet.GetItemState( static_cast< USHORT >(bHeader ? RES_HEADER : RES_FOOTER), sal_True, &pItem) && - 0 != (pHeadFootFmt = bHeader ? - ((SwFmtHeader*)pItem)->GetHeaderFmt() : - ((SwFmtFooter*)pItem)->GetFooterFmt())) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - const SwStartNode* pCurSttNode = rNode.FindSttNodeByType( - bHeader ? SwHeaderStartNode : SwFooterStartNode); - if(pCurSttNode && pCurSttNode == pSttNode) + if (SFX_ITEM_SET == rSet.GetItemState( + static_cast(bHeader ? RES_HEADER : RES_FOOTER), + sal_True, &pItem)) + { + SfxPoolItem *const pItemNonConst(const_cast(pItem)); + SwFrmFmt *const pHeadFootFmt = (bHeader) ? + static_cast(pItemNonConst)->GetHeaderFmt() : + static_cast(pItemNonConst)->GetFooterFmt(); + if (pHeadFootFmt) { - bRet = sal_True; - rpFormat = pHeadFootFmt; + const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType( + (bHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (pCurSttNode && (pCurSttNode == pSttNode)) + { + rpFormat = pHeadFootFmt; + bRet = true; + } } } return bRet; } -uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition( - SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark) +} // namespace sw + +uno::Reference< text::XTextRange > +SwXTextRange::CreateXTextRange( + SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark) { - uno::Reference< XText > xParentText( CreateParentXText(pDoc, rPos) ); - std::auto_ptr pNewCrsr( pDoc->CreateUnoCrsr(rPos, sal_False) ); + const uno::Reference xParentText( + ::sw::CreateParentXText(rDoc, rPos)); + const ::std::auto_ptr pNewCrsr( + rDoc.CreateUnoCrsr(rPos, sal_False)); if(pMark) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pMark; } - bool isCell( dynamic_cast(xParentText.get()) ); - uno::Reference< XTextRange > xRet( + const bool isCell( dynamic_cast(xParentText.get()) ); + const uno::Reference< text::XTextRange > xRet( new SwXTextRange(*pNewCrsr, xParentText, isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) ); return xRet; - } -uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, - const SwPosition& rPos) +namespace sw { + +uno::Reference< text::XText > +CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) { - uno::Reference< XText > xParentText; + uno::Reference< text::XText > xParentText; SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode(); while(pSttNode && pSttNode->IsSectionNode()) { @@ -1771,18 +1783,19 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, { case SwTableBoxStartNode: { - const SwTableNode* pTblNode = pSttNode->FindTableNode(); - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - SwTableBox* pBox = pSttNode->GetTblBox(); + SwTableNode const*const pTblNode = pSttNode->FindTableNode(); + SwFrmFmt *const pTableFmt = + static_cast(pTblNode->GetTable().GetFrmFmt()); + SwTableBox *const pBox = pSttNode->GetTblBox(); - xParentText = pBox + xParentText = (pBox) ? SwXCell::CreateXCell( pTableFmt, pBox ) : new SwXCell( pTableFmt, *pSttNode ); } break; case SwFlyStartNode: { - SwFrmFmt* pFmt = pSttNode->GetFlyFmt(); + SwFrmFmt *const pFmt = pSttNode->GetFlyFmt(); if (0 != pFmt) { SwXTextFrame* pFrame( static_cast( @@ -1794,18 +1807,23 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, case SwHeaderStartNode: case SwFooterStartNode: { - sal_Bool bHeader = SwHeaderStartNode == eType; - sal_uInt16 nPDescCount = pDoc->GetPageDescCnt(); + const bool bHeader = (SwHeaderStartNode == eType); + const sal_uInt16 nPDescCount = rDoc.GetPageDescCnt(); for(sal_uInt16 i = 0; i < nPDescCount; i++) { - const SwPageDesc& rDesc = const_cast(pDoc) - ->GetPageDesc( i ); + const SwPageDesc& rDesc = + // C++ is retarded + const_cast(rDoc).GetPageDesc( i ); const SwFrmFmt* pFrmFmtMaster = &rDesc.GetMaster(); const SwFrmFmt* pFrmFmtLeft = &rDesc.GetLeft(); SwFrmFmt* pHeadFootFmt = 0; - if(!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster, pHeadFootFmt)) - lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft, pHeadFootFmt); + if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster, + pHeadFootFmt)) + { + lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft, + pHeadFootFmt); + } if(pHeadFootFmt) { @@ -1813,7 +1831,10 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, First( TYPE( SwXHeadFootText )); xParentText = pxHdFt; if(!pxHdFt) - xParentText = new SwXHeadFootText(*pHeadFootFmt, bHeader); + { + xParentText = + new SwXHeadFootText(*pHeadFootFmt, bHeader); + } break; } } @@ -1821,15 +1842,16 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, break; case SwFootnoteStartNode: { - sal_uInt16 n, nFtnCnt = pDoc->GetFtnIdxs().Count(); - uno::Reference< XFootnote > xRef; - for( n = 0; n < nFtnCnt; ++n ) + const sal_uInt16 nFtnCnt = rDoc.GetFtnIdxs().Count(); + uno::Reference< text::XFootnote > xRef; + for (sal_uInt16 n = 0; n < nFtnCnt; ++n ) { - const SwTxtFtn* pTxtFtn = pDoc->GetFtnIdxs()[ n ]; + const SwTxtFtn* pTxtFtn = rDoc.GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); pTxtFtn = rFtn.GetTxtFtn(); #if OSL_DEBUG_LEVEL > 1 - const SwStartNode* pTmpSttNode = pTxtFtn->GetStartNode()->GetNode(). + const SwStartNode* pTmpSttNode = + pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode); (void)pTmpSttNode; #endif @@ -1837,11 +1859,12 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { - xParentText = ((SwUnoCallBack*)pDoc->GetUnoCallBack())-> + xParentText = + static_cast(rDoc.GetUnoCallBack())-> GetFootnote(rFtn); if (!xParentText.is()) { - xParentText = new SwXFootnote(pDoc, rFtn); + xParentText = new SwXFootnote(&rDoc, rFtn); } break; } @@ -1851,9 +1874,9 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, default: { // then it is the body text - uno::Reference xModel = - pDoc->GetDocShell()->GetBaseModel(); - uno::Reference< XTextDocument > xDoc( + const uno::Reference xModel = + rDoc.GetDocShell()->GetBaseModel(); + const uno::Reference< text::XTextDocument > xDoc( xModel, uno::UNO_QUERY); xParentText = xDoc->getText(); } @@ -1862,6 +1885,8 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, return xParentText; } +} // namespace sw + uno::Reference< container::XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration(const OUString& rServiceName) throw (uno::RuntimeException) @@ -2168,8 +2193,8 @@ void SwXTextRanges::Impl::MakeRanges() SwPaM *pTmpCursor = pCursor; do { const uno::Reference< text::XTextRange > xRange( - SwXTextRange::CreateTextRangeFromPosition( - pTmpCursor->GetDoc(), + SwXTextRange::CreateXTextRange( + *pTmpCursor->GetDoc(), *pTmpCursor->GetPoint(), pTmpCursor->GetMark())); if (xRange.is()) { diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 683366fc6d..ee6af202af 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -263,7 +263,7 @@ SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, if (!xParentText.is()) { SwPosition Pos( rTxtNode ); - xParentText.set(SwXTextRange::CreateParentXText( &rDoc, Pos )); + xParentText.set(::sw::CreateParentXText( rDoc, Pos )); } SwXParagraph *const pXPara( new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) ); diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 6f7ee5ff68..04162db925 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -591,11 +591,8 @@ uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName ) pPoint = pRedline->GetPoint(); else pPoint = pRedline->GetMark(); - SwPaM aTmp(*pPoint); - uno::Reference xTmpParent; -// uno::Reference< text::XTextRange > xRange = SwXTextRange::createTextRangeFromPaM(aTmp); - uno::ReferencexRange = - SwXTextRange::CreateTextRangeFromPosition( pDoc, *pPoint, 0 ); + const uno::Reference xRange = + SwXTextRange::CreateXTextRange(*pDoc, *pPoint, 0); xRet = xRange.get(); } break; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index fa8acbf631..c8b4927b09 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -309,7 +309,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) SwUnoInternalPaM aPam(*pDocument); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); m_pImpl->InsertRefMark(aPam, dynamic_cast(pCursor)); m_pImpl->m_bIsDescriptor = sal_False; m_pImpl->m_pDoc = pDocument; @@ -342,8 +342,8 @@ SwXReferenceMark::getAnchor() throw (uno::RuntimeException) rTxtNode, *pTxtMark->GetStart()) : new SwPaM( rTxtNode, *pTxtMark->GetStart()) ); - return SwXTextRange::CreateTextRangeFromPosition( - m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); + return SwXTextRange::CreateXTextRange( + *m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); } } } @@ -820,8 +820,7 @@ SwXMeta::CreateXMeta(::sw::Meta & rMeta, OSL_ENSURE(pTxtAttr, "CreateXMeta: no text attr?"); if (!pTxtAttr) { return 0; } const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); - xParentText.set( - SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); + xParentText.set( ::sw::CreateParentXText(*pTxtNode->GetDoc(), aPos) ); } if (!xParentText.is()) { return 0; } SwXMeta *const pXMeta( (RES_TXTATR_META == rMeta.GetFmtMeta()->Which()) @@ -1072,7 +1071,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } SwUnoInternalPaM aPam(*pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange); + ::sw::XTextRangeToSwPaM(aPam, i_xTextRange); UnoActionContext aContext(pDoc); @@ -1109,8 +1108,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) pMeta->Add(m_pImpl.get()); pMeta->SetXMeta(uno::Reference(this)); - m_pImpl->m_xParentText = - SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); + m_pImpl->m_xParentText = ::sw::CreateParentXText(*pDoc, *aPam.GetPoint()); m_pImpl->m_bIsDescriptor = false; } @@ -1153,8 +1151,7 @@ SwXMeta::getAnchor() throw (uno::RuntimeException) const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR const SwPosition end(*pTxtNode, nMetaEnd); - return SwXTextRange::CreateTextRangeFromPosition( - pTxtNode->GetDoc(), start, &end); + return SwXTextRange::CreateXTextRange(*pTxtNode->GetDoc(), start, &end); } // XTextRange diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index c47a3aef13..d9d6bafa31 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -328,7 +328,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(pDoc); pDoc->StartUndo( UNDO_INSSECTION, NULL ); @@ -488,7 +488,7 @@ SwXTextSection::getAnchor() throw (uno::RuntimeException) const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode(); SwPaM aEnd(*pEndNode); aEnd.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateTextRangeFromPosition(pSectFmt->GetDoc(), + xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), *aPaM.Start(), aEnd.Start()); } } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 049f2c5662..497f09fa8d 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1062,7 +1062,8 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno: vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if((pStartNode || IsValid()) && SwXTextRange::XTextRangeToSwPaM(aPam, xTextPosition)) + if ((pStartNode || IsValid()) + && ::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd(); //skip sections @@ -2468,7 +2469,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); { UnoActionContext aCont( pDoc ); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 98c81df1f4..fb4e04b236 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -382,7 +382,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & if (GetDoc()) { SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) + if (::sw::XTextRangeToSwPaM(aPam, xTextRange)) { const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); @@ -504,7 +504,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang if(xRange.is() && xContent.is()) { SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xRange)) + if (::sw::XTextRangeToSwPaM(aPam, xRange)) { uno::Reference xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; @@ -1060,8 +1060,8 @@ sal_Int16 SwXText::ComparePositions( SwUnoInternalPaM aPam2(*GetDoc()); BOOL bExcept = FALSE; - if(SwXTextRange::XTextRangeToSwPaM(aPam1, xPos1) && - SwXTextRange::XTextRangeToSwPaM(aPam2, xPos2)) + if (::sw::XTextRangeToSwPaM(aPam1, xPos1) && + ::sw::XTextRangeToSwPaM(aPam2, xPos2)) { uno::Reference xRangeTunnel1( xPos1, uno::UNO_QUERY); SwXTextRange* pRange1 = 0; @@ -1582,8 +1582,8 @@ uno::Reference< text::XTextContent > SwXText::convertToTextFrame( uno::Reference< text::XTextContent > xRet; SwUnoInternalPaM aStartPam(*GetDoc()); std::auto_ptr < SwUnoInternalPaM > pEndPam( new SwUnoInternalPaM(*GetDoc())); - if(SwXTextRange::XTextRangeToSwPaM(aStartPam, xStart) && - SwXTextRange::XTextRangeToSwPaM(*pEndPam, xEnd) ) + if (::sw::XTextRangeToSwPaM(aStartPam, xStart) && + ::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) { uno::Reference xStartRangeTunnel( xStart, uno::UNO_QUERY); SwXTextRange* pStartRange = reinterpret_cast< SwXTextRange * >( @@ -1826,8 +1826,8 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! - if(!SwXTextRange::XTextRangeToSwPaM(aStartCellPam, xStartRange) || - !SwXTextRange::XTextRangeToSwPaM(aEndCellPam, xEndRange) ) + if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || + !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) throw lang::IllegalArgumentException(); /** check the nodes between start and end it is allowed to have pairs of StartNode/EndNodes @@ -2361,7 +2361,7 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( throw aRuntime; } SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); @@ -2603,7 +2603,7 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( uno::Reference< text::XTextCursor > xRet; SwFrmFmt* pHeadFootFmt = GetFmt(); SwUnoInternalPaM aPam(*GetDoc()); - if(pHeadFootFmt && SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (pHeadFootFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = pHeadFootFmt->GetCntnt().GetCntntIdx()->GetNode(); SwPosition aPos(rNode); diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 3cabf2e49b..b28c444f26 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -162,7 +162,7 @@ void XTextRangeOrNodeIndexPosition::SetAsNodeIndex( #ifdef DBG_UTIL sal_Bool bSuccess = #endif - SwXTextRange::XTextRangeToSwPaM( aPaM, rRange); + ::sw::XTextRangeToSwPaM(aPaM, rRange); DBG_ASSERT(bSuccess, "illegal range"); // PaM -> Index @@ -180,7 +180,7 @@ void XTextRangeOrNodeIndexPosition::CopyPositionInto(SwPosition& rPos) #ifdef DBG_UTIL sal_Bool bSuccess = #endif - SwXTextRange::XTextRangeToSwPaM(aUnoPaM, xRange); + ::sw::XTextRangeToSwPaM(aUnoPaM, xRange); DBG_ASSERT(bSuccess, "illegal range"); rPos = *aUnoPaM.GetPoint(); diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 8d964ac1d8..986c76b229 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -788,9 +788,8 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S } else if( bInsertMode ) { - uno::Reference xInsertTextRange = - SwXTextRange::CreateTextRangeFromPosition( &rDoc, *rPaM.GetPoint(), - 0 ); + const uno::Reference xInsertTextRange = + SwXTextRange::CreateXTextRange(rDoc, *rPaM.GetPoint(), 0); OUString sTextInsertModeRange( RTL_CONSTASCII_USTRINGPARAM("TextInsertModeRange")); xInfoSet->setPropertyValue( sTextInsertModeRange, diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 1039515a8d..42815039db 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -713,9 +713,9 @@ void SwXMLImport::startDocument( void ) } if( pCrsrSh ) { - Reference xInsertTextRange( - SwXTextRange::CreateTextRangeFromPosition( - pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); + const uno::Reference xInsertTextRange( + SwXTextRange::CreateXTextRange( + *pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); setTextInsertMode( xInsertTextRange ); xTextCursor = GetTextImport()->GetCursor(); pTxtCrsr = 0; diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index a50779bf1b..95cf0ddfda 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -2926,8 +2926,8 @@ const SwStartNode *SwXMLTableContext::InsertTableSection( SwPosition aPos( *pCNd ); aPos.nContent.Assign( pCNd, 0U ); - Reference < XTextRange > xTextRange = - SwXTextRange::CreateTextRangeFromPosition( pDoc, aPos, 0 ); + const uno::Reference< text::XTextRange > xTextRange = + SwXTextRange::CreateXTextRange( *pDoc, aPos, 0 ); Reference < XText > xText = xTextRange->getText(); Reference < XTextCursor > xTextCursor = xText->createTextCursorByRange( xTextRange ); diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index f0e72323d2..a5d9c75b39 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -258,8 +258,10 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) //mark the start position only if not at start of doc if(!pWrtShell->IsStartOfDoc()) { - m_pSpellState->m_xStartRange = SwXTextRange::CreateTextRangeFromPosition( - pWrtShell->GetDoc(), *pCrsr->Start(), pCrsr->End()); + m_pSpellState->m_xStartRange = + SwXTextRange::CreateXTextRange( + *pWrtShell->GetDoc(), + *pCrsr->Start(), pCrsr->End()); } pWrtShell->SpellStart( DOCPOS_START, DOCPOS_END, DOCPOS_CURR, FALSE ); } @@ -390,7 +392,8 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) if(RET_YES == nRet) { SwUnoInternalPaM aPam(*pWrtShell->GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, m_pSpellState->m_xStartRange)) + if (::sw::XTextRangeToSwPaM(aPam, + m_pSpellState->m_xStartRange)) { pWrtShell->SetSelection(aPam); pWrtShell->SpellStart(DOCPOS_START, DOCPOS_CURR, DOCPOS_START); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 1d9b3f1f82..4b6e67a8d7 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -991,11 +991,10 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear Reference< XInterface > xRet; if(nResult) { - Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition( - pDocShell->GetDoc(), - *pResultCrsr->GetPoint(), - pResultCrsr->GetMark()); - xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr); + const uno::Reference< text::XText > xParent = + ::sw::CreateParentXText(*pDocShell->GetDoc(), + *pResultCrsr->GetPoint()); + xRet = *new SwXTextCursor(xParent, pResultCrsr); delete pResultCrsr; } return xRet; @@ -1019,12 +1018,11 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > Reference< XInterface > xRet; if(nResult) { - Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition( - pDocShell->GetDoc(), - *pResultCrsr->GetPoint(), - pResultCrsr->GetMark()); + const uno::Reference< text::XText > xParent = + ::sw::CreateParentXText(*pDocShell->GetDoc(), + *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr); + xRet = *new SwXTextCursor(xParent, pResultCrsr); delete pResultCrsr; } return xRet; diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index e314b306e9..3645be8506 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -334,7 +334,7 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg else if(!pFrame && !pCell && xPos.is()) { SwUnoInternalPaM aPam(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xPos)) + if (::sw::XTextRangeToSwPaM(aPam, xPos)) { pPam = lcl_createPamCopy(aPam); } @@ -1362,7 +1362,7 @@ void SwXTextViewCursor::gotoRange( throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); - if(!SwXTextRange::XTextRangeToSwPaM( rDestPam, xRange)) + if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) throw IllegalArgumentException(); ShellModes eSelMode = m_pView->GetShellMode(); @@ -1699,9 +1699,7 @@ uno::Reference< text::XText > SwXTextViewCursor::getText(void) throw( uno::Runt SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - uno::Reference< text::XTextRange > xRg = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->Start(), 0); - xRet = xRg->getText(); + xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start()); } else throw uno::RuntimeException(); @@ -1722,8 +1720,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getStart(void) throw( uno SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->Start(), 0); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0); } else throw uno::RuntimeException(); @@ -1744,8 +1741,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd(void) throw( uno:: SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->End(), 0); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0); } else throw uno::RuntimeException(); -- cgit v1.2.3 From 47b2dc4fec279f53321a29c231fd9ad76e6b41aa Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:54 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXParaFrameEnumeration: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace PARAFRAME_PORTION_ macros with an enum. use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoparaframeenum.hxx | 29 ++-- sw/source/core/unocore/unoobj2.cxx | 271 +++++++++++++++++++++---------------- 2 files changed, 165 insertions(+), 135 deletions(-) diff --git a/sw/inc/unoparaframeenum.hxx b/sw/inc/unoparaframeenum.hxx index d05fccfed4..7e5b43f1e6 100644 --- a/sw/inc/unoparaframeenum.hxx +++ b/sw/inc/unoparaframeenum.hxx @@ -42,13 +42,12 @@ #include -#include -#include +#include +class SwDepend; class SwNodeIndex; class SwPaM; -class SwUnoCrsr; class SwFrmFmt; @@ -80,10 +79,12 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, * * --------------------------------------------------*/ -#define PARAFRAME_PORTION_PARAGRAPH 0 -#define PARAFRAME_PORTION_CHAR 1 -#define PARAFRAME_PORTION_TEXTRANGE 2 - +enum ParaFrameMode +{ + PARAFRAME_PORTION_PARAGRAPH, + PARAFRAME_PORTION_CHAR, + PARAFRAME_PORTION_TEXTRANGE, +}; typedef ::cppu::WeakImplHelper2 < ::com::sun::star::lang::XServiceInfo @@ -92,27 +93,19 @@ typedef ::cppu::WeakImplHelper2 class SwXParaFrameEnumeration : public SwXParaFrameEnumeration_Base - , public SwClient { private: - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - m_xNextObject; // created by hasMoreElements - FrameDependList_t m_Frames; - - SwUnoCrsr* GetCursor() const - {return static_cast(const_cast(GetRegisteredIn()));} + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXParaFrameEnumeration(); public: SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + const enum ParaFrameMode eParaFrameMode, SwFrmFmt *const pFmt = 0); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 36afe319cb..0e7f33b456 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -2359,6 +2359,68 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) * SwXParaFrameEnumeration ******************************************************************/ +class SwXParaFrameEnumeration::Impl + : public SwClient +{ + +public: + + // created by hasMoreElements + uno::Reference< text::XTextContent > m_xNextObject; + FrameDependList_t m_Frames; + + Impl(SwPaM const & rPaM) + : SwClient(rPaM.GetDoc()->CreateUnoCrsr(*rPaM.GetPoint(), sal_False)) + { + if (rPaM.HasMark()) + { + GetCursor()->SetMark(); + *GetCursor()->GetMark() = *rPaM.GetMark(); + } + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast( + const_cast(GetRegisteredIn())); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 23.03.99 13:22:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ + +struct InvalidFrameDepend { + bool operator() (::boost::shared_ptr const & rEntry) + { return !rEntry->GetRegisteredIn(); } +}; + +void SwXParaFrameEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if(!GetRegisteredIn()) + { + m_Frames.clear(); + m_xNextObject = 0; + } + else + { + // check if any frame went away... + FrameDependList_t::iterator const iter = + ::std::remove_if(m_Frames.begin(), m_Frames.end(), + InvalidFrameDepend()); + m_Frames.erase(iter, m_Frames.end()); + } +} + /* -----------------23.03.99 13:38------------------- * * --------------------------------------------------*/ @@ -2370,7 +2432,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, if (!i_rFrames.size()) return sal_False; - SwFrmFmt* pFormat = static_cast(const_cast( + SwFrmFmt *const pFormat = static_cast(const_cast( i_rFrames.front()->GetRegisteredIn())); i_rFrames.pop_front(); // the format should be valid here, otherwise the client @@ -2391,7 +2453,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, { const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); DBG_ASSERT(pIdx, "where is the index?"); - const SwNode* pNd = + SwNode const*const pNd = i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM @@ -2410,11 +2472,12 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, and fill the frame into the array ---------------------------------------------------------------------------*/ static void -lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, +lcl_FillFrame(SwClient & rEnum, SwUnoCrsr& rUnoCrsr, FrameDependList_t & rFrames) { // search for objects at the cursor - anchored at/as char - const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( + SwTxtAttr const*const pTxtAttr = + rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); if (pTxtAttr) { @@ -2425,93 +2488,64 @@ lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, } } -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -OUString SwXParaFrameEnumeration::getImplementationName() -throw( RuntimeException ) -{ - return C2U("SwXParaFrameEnumeration"); -} -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) -throw( RuntimeException ) -{ - return C2U("com.sun.star.util.ContentEnumeration") == rServiceName; -} -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames() -throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.util.ContentEnumeration"); - return aRet; -} /*-- 23.03.99 13:22:29--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, - SwFrmFmt* pFmt) +SwXParaFrameEnumeration::SwXParaFrameEnumeration( + const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, + SwFrmFmt *const pFmt) + : m_pImpl( new SwXParaFrameEnumeration::Impl(rPaM) ) { - SwDoc* pDoc = rPaM.GetDoc(); - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rPaM.GetPoint(), sal_False); - if (rPaM.HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *rPaM.GetMark(); - } - pUnoCrsr->Add(this); - - if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) + if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode) { FrameDependSortList_t frames; - ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false ); + ::CollectFrameAtNode(*m_pImpl.get(), rPaM.GetPoint()->nNode, + frames, false); ::std::transform(frames.begin(), frames.end(), - ::std::back_inserter(m_Frames), + ::std::back_inserter(m_pImpl->m_Frames), ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1)); } else if (pFmt) { - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFmt); - m_Frames.push_back( ::boost::shared_ptr(pNewDepend) ); + // create SwDepend for frame and insert into array + SwDepend *const pNewDepend = new SwDepend(m_pImpl.get(), pFmt); + m_pImpl->m_Frames.push_back(::boost::shared_ptr(pNewDepend)); } - else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) || - (PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode)) + else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) || + (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)) { - if(PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode) + if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode) { SwPosFlyFrms aFlyFrms; //get all frames that are bound at paragraph or at character - pDoc->GetAllFlyFmts(aFlyFrms, pUnoCrsr);//, bDraw); + rPaM.GetDoc()->GetAllFlyFmts(aFlyFrms, m_pImpl->GetCursor()); for(USHORT i = 0; i < aFlyFrms.Count(); i++) { SwPosFlyFrm* pPosFly = aFlyFrms[i]; - SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt(); - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - m_Frames.push_back( ::boost::shared_ptr(pNewDepend) ); + SwFrmFmt *const pFrmFmt = + const_cast(&pPosFly->GetFmt()); + // create SwDepend for frame and insert into array + SwDepend *const pNewDepend = + new SwDepend(m_pImpl.get(), pFrmFmt); + m_pImpl->m_Frames.push_back( + ::boost::shared_ptr(pNewDepend) ); } //created from any text range - if(pUnoCrsr->HasMark()) + if (m_pImpl->GetCursor()->HasMark()) { - if(pUnoCrsr->Start() != pUnoCrsr->GetPoint()) - pUnoCrsr->Exchange(); + m_pImpl->GetCursor()->Normalize(); do { - lcl_FillFrame(*this, *pUnoCrsr, m_Frames); - pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), + m_pImpl->m_Frames); + m_pImpl->GetCursor()->Right( + 1, CRSR_SKIP_CHARS, FALSE, FALSE); } - while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()); + while (*m_pImpl->GetCursor()->GetPoint() < + *m_pImpl->GetCursor()->GetMark()); } } - lcl_FillFrame(*this, *pUnoCrsr, m_Frames); + lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), m_pImpl->m_Frames); } } /*-- 23.03.99 13:22:30--------------------------------------------------- @@ -2519,89 +2553,92 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, -----------------------------------------------------------------------*/ SwXParaFrameEnumeration::~SwXParaFrameEnumeration() { - vos::OGuard aGuard(Application::GetSolarMutex()); - - SwUnoCrsr* pUnoCrsr = GetCursor(); - delete pUnoCrsr; } /*-- 23.03.99 13:22:32--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::hasMoreElements() -throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXParaFrameEnumeration::hasMoreElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!GetCursor()) + if (!m_pImpl->GetCursor()) throw uno::RuntimeException(); - return m_xNextObject.is() ? sal_True : - lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); + return (m_pImpl->m_xNextObject.is()) + ? sal_True + : lcl_CreateNextObject(*m_pImpl->GetCursor(), + m_pImpl->m_xNextObject, m_pImpl->m_Frames); } /*-- 23.03.99 13:22:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParaFrameEnumeration::nextElement() - throw( container::NoSuchElementException, - lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXParaFrameEnumeration::nextElement() +throw (container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!GetCursor()) + if (!m_pImpl->GetCursor()) + { throw uno::RuntimeException(); + } - if (!m_xNextObject.is() && m_Frames.size()) + if (!m_pImpl->m_xNextObject.is() && m_pImpl->m_Frames.size()) { - lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); + lcl_CreateNextObject(*m_pImpl->GetCursor(), + m_pImpl->m_xNextObject, m_pImpl->m_Frames); } - if(!m_xNextObject.is()) + if (!m_pImpl->m_xNextObject.is()) + { throw container::NoSuchElementException(); - uno::Any aRet(&m_xNextObject, - ::getCppuType((uno::Reference*)0)); - m_xNextObject = 0; + } + uno::Any aRet; + aRet <<= m_pImpl->m_xNextObject; + m_pImpl->m_xNextObject = 0; return aRet; } -struct InvalidFrameDepend { - bool operator() (::boost::shared_ptr const & rEntry) - { return !rEntry->GetRegisteredIn(); } -}; +/* -----------------------------06.04.00 16:39-------------------------------- -/*-- 23.03.99 13:22:37--------------------------------------------------- + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXParaFrameEnumeration::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXParaFrameEnumeration"); +} - -----------------------------------------------------------------------*/ -void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +/* -----------------------------06.04.00 16:39-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesParaFrameEnum[] = { - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - ((SwModify*)GetRegisteredIn())->Remove(this); - break; + "com.sun.star.util.ContentEnumeration", +}; +static const size_t g_nServicesParaFrameEnum( + sizeof(g_ServicesParaFrameEnum)/sizeof(g_ServicesParaFrameEnum[0])); - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - ((SwModify*)GetRegisteredIn())->Remove(this); - break; - } - if(!GetRegisteredIn()) - { - m_Frames.clear(); - m_xNextObject = 0; - } - else - { - // check if any frame went away... - FrameDependList_t::iterator iter = - ::std::remove_if(m_Frames.begin(), m_Frames.end(), - InvalidFrameDepend()); - m_Frames.erase(iter, m_Frames.end()); - } +sal_Bool SAL_CALL +SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesParaFrameEnum, g_ServicesParaFrameEnum, rServiceName); +} + +/* -----------------------------06.04.00 16:39-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParaFrameEnumeration::getSupportedServiceNames() +throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParaFrameEnum, g_ServicesParaFrameEnum); } + + // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) -- cgit v1.2.3 From cfc15a4cf1a5e2b5208f772e1e321b2bb648915d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:54 +0100 Subject: swunolocking1: #i105557#: SwXTextCursor: move implementation of all non-static methods into unoobj.cxx. --- sw/source/core/unocore/unoobj.cxx | 603 +++++++++++++++++++++++++++++++++++++ sw/source/core/unocore/unoobj2.cxx | 512 ------------------------------- 2 files changed, 603 insertions(+), 512 deletions(-) diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index f923fcf1ae..5deb85dd2a 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -31,9 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include +#include #include #include #include @@ -115,6 +117,7 @@ #define _SVSTDARR_USHORTSSORT #include #include +#include #include #include #include @@ -122,6 +125,8 @@ #include #include #include +#include +#include using namespace ::com::sun::star; @@ -708,6 +713,96 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) * SwXTextCursor ******************************************************************/ +/*-- 09.12.98 14:19:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, + uno::Reference< XInterface >*, EMPTYARG ) +{ + ASSERT( pThis != NULL, "no reference?" ); + //ASSERT( pArg != NULL, "no reference?" ); + + // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event + // has been executed. It is not necessary to remove the user event in + // ~SwXTextCursor + pThis->DoNotRemoveUserEvent(); + // <-- + + SwUnoCrsr* pCursor = pThis->GetCrsr(); + if( pCursor != NULL ) + { + pCursor->Remove( pThis ); + delete pCursor; + } + + // --> FME 2006-03-07 #126177# + //delete pArg; + // <-- + + return 0; +} + +void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + // if the cursor leaves its designated section, it becomes invalid + if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) + { + // --> FME 2006-03-07 #126177# We don't need to create a reference + // to the SwXTextCursor to prevent its deletion. If the destructor + // of the SwXTextCursor is called before the user event is executed, + // the user event will be removed. This is necessary, because an other + // thread might be currently waiting in ~SwXTextCursor. In this case + // the pRef = new ... stuff did not work! + + // create reference to this object to prevent deletion before + // the STATIC_LINK is executed. The link will delete the + // reference. + //uno::Reference* pRef = + //new uno::Reference( static_cast( this ) ); + + mbRemoveUserEvent = true; + // <-- + + mnUserEventId = Application::PostUserEvent( + STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); + } + + if(!GetRegisteredIn()) + aLstnrCntnr.Disposing(); + +} + +/*-- 09.12.98 14:19:01--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const SwPaM* SwXTextCursor::GetPaM() const +{ + return GetCrsr() ? GetCrsr() : 0; +} + +SwPaM* SwXTextCursor::GetPaM() +{ + return GetCrsr() ? GetCrsr() : 0; +} + +/*-- 09.12.98 14:19:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const SwDoc* SwXTextCursor::GetDoc()const +{ + return GetCrsr() ? GetCrsr()->GetDoc() : 0; +} +/* -----------------22.07.99 13:52------------------- + + --------------------------------------------------*/ +SwDoc* SwXTextCursor::GetDoc() +{ + return GetCrsr() ? GetCrsr()->GetDoc() : 0; +} + + /*-- 09.12.98 14:19:19--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -2447,3 +2542,511 @@ void SwXTextCursor::makeRedline( else throw uno::RuntimeException(); } + +/*-- 09.12.98 14:18:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL, + const uno::Sequence< beans::PropertyValue >& rOptions) +throw (lang::IllegalArgumentException, io::IOException, + uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + { + throw uno::RuntimeException(); + } + SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); +} + +/* -----------------------------15.12.00 14:01-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > +SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) +{ + uno::Sequence< beans::PropertyValue > aRet(5); + beans::PropertyValue* pArray = aRet.getArray(); + + uno::Any aVal; + aVal.setValue( &bFromTable, ::getCppuBooleanType()); + pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + String sSpace(String::CreateFromAscii(" ")); + sal_Unicode uSpace = sSpace.GetChar(0); + + aVal <<= uSpace; + pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= (sal_Bool) sal_False; + pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= (sal_Int32) 3; + pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + uno::Sequence< table::TableSortField > aFields(3); + table::TableSortField* pFields = aFields.getArray(); + + Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); + // get collator algorithm to be used for the locale + uno::Sequence< OUString > aSeq( + GetAppCollator().listCollatorAlgorithms( aLang ) ); + INT32 nLen = aSeq.getLength(); + DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); + OUString aCollAlg; + if (nLen > 0) + aCollAlg = aSeq.getConstArray()[0]; + +#if OSL_DEBUG_LEVEL > 1 + const OUString *pTxt = aSeq.getConstArray(); + (void)pTxt; +#endif + + pFields[0].Field = 1; + pFields[0].IsAscending = sal_True; + pFields[0].IsCaseSensitive = sal_False; + pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[0].CollatorLocale = aLang; + pFields[0].CollatorAlgorithm = aCollAlg; + + pFields[1].Field = 1; + pFields[1].IsAscending = sal_True; + pFields[1].IsCaseSensitive = sal_False; + pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[1].CollatorLocale = aLang; + pFields[1].CollatorAlgorithm = aCollAlg; + + pFields[2].Field = 1; + pFields[2].IsAscending = sal_True; + pFields[2].IsCaseSensitive = sal_False; + pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[2].CollatorLocale = aLang; + pFields[2].CollatorAlgorithm = aCollAlg; + + aVal <<= aFields; + pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + return aRet; +} + +/*-- 09.12.98 14:18:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > SAL_CALL +SwXTextCursor::createSortDescriptor() throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return SwXTextCursor::createSortDescriptor(sal_False); +} + +/* -----------------------------15.12.00 14:06-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SwXTextCursor::convertSortProperties( + const uno::Sequence< beans::PropertyValue >& rDescriptor, + SwSortOptions& rSortOpt) +{ + sal_Bool bRet = sal_True; + const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); + + rSortOpt.bTable = sal_False; + rSortOpt.cDeli = ' '; + rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !! + + SwSortKey* pKey1 = new SwSortKey; + pKey1->nColumnId = USHRT_MAX; + pKey1->bIsNumeric = TRUE; + pKey1->eSortOrder = SRT_ASCENDING; + + SwSortKey* pKey2 = new SwSortKey; + pKey2->nColumnId = USHRT_MAX; + pKey2->bIsNumeric = TRUE; + pKey2->eSortOrder = SRT_ASCENDING; + + SwSortKey* pKey3 = new SwSortKey; + pKey3->nColumnId = USHRT_MAX; + pKey3->bIsNumeric = TRUE; + pKey3->eSortOrder = SRT_ASCENDING; + SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3}; + + sal_Bool bOldSortdescriptor(sal_False); + sal_Bool bNewSortdescriptor(sal_False); + + for (int n = 0; n < rDescriptor.getLength(); ++n) + { + uno::Any aValue( pProperties[n].Value ); +// String sPropName = pProperties[n].Name; + const OUString& rPropName = pProperties[n].Name; + + // old and new sortdescriptor + if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) + { + if (aValue.getValueType() == ::getBooleanCppuType()) + { + rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) + { + sal_Unicode uChar = sal_Unicode(); + if (aValue >>= uChar) + { + rSortOpt.cDeli = uChar; + } + else + { + bRet = sal_False; + } + } + // old sortdescriptor + else if (COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) + { + bOldSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) + { + bOldSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.bIgnoreCase = !bTemp; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) + { + bOldSortdescriptor = sal_True; + Locale aLocale; + if (aValue >>= aLocale) + { + rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", + 17) && + rPropName.getLength() == 18 && + (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[17]; + nIndex -= '0'; + OUString aTxt; + if ((aValue >>= aTxt) && nIndex < 3) + { + aKeys[nIndex]->sSortType = aTxt; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", + 17) && + rPropName.getLength() == 18 && + (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[17]; + nIndex -= '0'; + sal_Int16 nCol = -1; + if (aValue.getValueType() == ::getCppuType((const sal_Int16*)0) + && nIndex < 3) + { + aValue >>= nCol; + } + if (nCol >= 0) + { + aKeys[nIndex]->nColumnId = nCol; + } + else + { + bRet = sal_False; + } + } + else if (0 == rPropName.indexOf(C2U("IsSortNumeric")) && + rPropName.getLength() == 14 && + (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[13]; + nIndex = nIndex - '0'; + if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + aKeys[nIndex]->bIsNumeric = bTemp; + } + else + { + bRet = sal_False; + } + } + else if (0 == rPropName.indexOf(C2U("IsSortAscending")) && + rPropName.getLength() == 16 && + (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[15]; + nIndex -= '0'; + if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + aKeys[nIndex]->eSortOrder = (bTemp) + ? SRT_ASCENDING : SRT_DESCENDING; + } + else + { + bRet = sal_False; + } + } + // new sortdescriptor + else if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) + { + bNewSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) + { + bNewSortdescriptor = sal_True; + uno::Sequence < table::TableSortField > aFields; + if (aValue >>= aFields) + { + sal_Int32 nCount(aFields.getLength()); + if (nCount <= 3) + { + table::TableSortField* pFields = aFields.getArray(); + for (sal_Int32 i = 0; i < nCount; ++i) + { + rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive; + rSortOpt.nLanguage = + SvxLocaleToLanguage( pFields[i].CollatorLocale ); + aKeys[i]->sSortType = pFields[i].CollatorAlgorithm; + aKeys[i]->nColumnId = + static_cast(pFields[i].Field); + aKeys[i]->bIsNumeric = (pFields[i].FieldType == + table::TableSortFieldType_NUMERIC); + aKeys[i]->eSortOrder = (pFields[i].IsAscending) + ? SRT_ASCENDING : SRT_DESCENDING; + } + } + else + { + bRet = sal_False; + } + } + else + { + bRet = sal_False; + } + } + } + + if (bNewSortdescriptor && bOldSortdescriptor) + { + DBG_ERROR("someone tried to set the old deprecated and " + "the new sortdescriptor"); + bRet = sal_False; + } + + if (pKey1->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); + } + if (pKey2->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); + } + if (pKey3->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); + } + + return bRet && rSortOpt.aKeys.Count() > 0; +} + +/*-- 09.12.98 14:19:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL +SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) +throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwSortOptions aSortOpt; + SwUnoCrsr* pUnoCrsr = GetCrsr(); + + if (!pUnoCrsr) + { + throw uno::RuntimeException(); + } + + if (pUnoCrsr->HasMark()) + { + if (!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + { + throw uno::RuntimeException(); + } + UnoActionContext aContext( pUnoCrsr->GetDoc() ); + + SwPosition* pStart = pUnoCrsr->Start(); + SwPosition* pEnd = pUnoCrsr->End(); + + SwNodeIndex aPrevIdx( pStart->nNode, -1 ); + ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); + xub_StrLen nCntStt = pStart->nContent.GetIndex(); + + pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); + + // Selektion wieder setzen + pUnoCrsr->DeleteMark(); + pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); + xub_StrLen nLen = pCNd->Len(); + if (nLen > nCntStt) + { + nLen = nCntStt; + } + pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); + pUnoCrsr->SetMark(); + + pUnoCrsr->GetPoint()->nNode += nOffset; + pCNd = pUnoCrsr->GetCntntNode(); + pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + } +} + +/* -----------------------------03.04.00 09:11-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextCursor::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr || + 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent")) + { + throw uno::RuntimeException(); + } + + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); + return xRet; +} + +/* -----------------------------07.03.01 14:53-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextCursor::createEnumeration() throw (uno::RuntimeException) +{ + SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + { + throw uno::RuntimeException(); + } + uno::Reference xTunnel(xParentText, UNO_QUERY); + SwXText* pParentText = 0; + if (xTunnel.is()) + { + pParentText = reinterpret_cast< SwXText *>( + sal::static_int_cast< sal_IntPtr >( + xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + } + DBG_ASSERT(pParentText, "parent is not a SwXText"); + if (!pParentText) + { + throw uno::RuntimeException(); + } + + ::std::auto_ptr pNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); + if (pUnoCrsr->HasMark()) + { + pNewCrsr->SetMark(); + *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); + } + const CursorType eSetType = (CURSOR_TBLTEXT == eType) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< XEnumeration > xRet = + new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + + return xRet; +} + +/* -----------------------------07.03.01 15:43-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Type SAL_CALL +SwXTextCursor::getElementType() throw (uno::RuntimeException) +{ + return ::getCppuType((uno::Reference*)0); +} + +/* -----------------------------07.03.01 15:43-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SAL_CALL SwXTextCursor::hasElements() throw (uno::RuntimeException) +{ + return sal_True; +} + +/* -----------------------------03.04.00 09:11-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextCursor::getAvailableServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); + return aRet; +} + +// --------------------------------------------------------------------------- +IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) + +uno::Any SAL_CALL +SwXTextCursor::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) +{ + return (rType == lang::XUnoTunnel::static_type()) + ? OTextCursorHelper::queryInterface(rType) + : SwXTextCursor_Base::queryInterface(rType); +} + diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 0e7f33b456..1bdd873ff9 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -94,7 +94,6 @@ #include #include #include -#include #include #include #include @@ -106,8 +105,6 @@ #include #include #include -#include -#include #include #include #include @@ -336,342 +333,6 @@ UnoActionRemoveContext::~UnoActionRemoveContext() } -/*-- 09.12.98 14:18:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextCursor::insertDocumentFromURL(const OUString& rURL, - const uno::Sequence< beans::PropertyValue >& rOptions) - throw( lang::IllegalArgumentException, io::IOException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); - } - else - throw uno::RuntimeException(); -} -/* -----------------------------15.12.00 14:01-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) -{ - uno::Sequence< beans::PropertyValue > aRet(5); - beans::PropertyValue* pArray = aRet.getArray(); - - uno::Any aVal; - aVal.setValue( &bFromTable, ::getCppuBooleanType()); - pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - String sSpace(String::CreateFromAscii(" ")); - sal_Unicode uSpace = sSpace.GetChar(0); - - aVal <<= uSpace; - pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - aVal <<= (sal_Bool) sal_False; - pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - aVal <<= (sal_Int32) 3; - pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - uno::Sequence< table::TableSortField > aFields(3); - table::TableSortField* pFields = aFields.getArray(); - - Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); - // get collator algorithm to be used for the locale - Sequence < OUString > aSeq( GetAppCollator().listCollatorAlgorithms( aLang ) ); - INT32 nLen = aSeq.getLength(); - DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); - OUString aCollAlg; - if (nLen > 0) - aCollAlg = aSeq.getConstArray()[0]; - -#if OSL_DEBUG_LEVEL > 1 - const OUString *pTxt = aSeq.getConstArray(); - (void)pTxt; -#endif - - pFields[0].Field = 1; - pFields[0].IsAscending = sal_True; - pFields[0].IsCaseSensitive = sal_False; - pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[0].CollatorLocale = aLang; - pFields[0].CollatorAlgorithm = aCollAlg; - - pFields[1].Field = 1; - pFields[1].IsAscending = sal_True; - pFields[1].IsCaseSensitive = sal_False; - pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[1].CollatorLocale = aLang; - pFields[1].CollatorAlgorithm = aCollAlg; - - pFields[2].Field = 1; - pFields[2].IsAscending = sal_True; - pFields[2].IsCaseSensitive = sal_False; - pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[2].CollatorLocale = aLang; - pFields[2].CollatorAlgorithm = aCollAlg; - - aVal <<= aFields; - pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - return aRet; -} - -/*-- 09.12.98 14:18:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(void) throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_False); -} -/* -----------------------------15.12.00 14:06-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::convertSortProperties( - const uno::Sequence< beans::PropertyValue >& rDescriptor, SwSortOptions& rSortOpt) -{ - sal_Bool bRet = sal_True; - const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); - - rSortOpt.bTable = sal_False; - rSortOpt.cDeli = ' '; - rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !! - - SwSortKey* pKey1 = new SwSortKey; - pKey1->nColumnId = USHRT_MAX; - pKey1->bIsNumeric = TRUE; - pKey1->eSortOrder = SRT_ASCENDING; - - SwSortKey* pKey2 = new SwSortKey; - pKey2->nColumnId = USHRT_MAX; - pKey2->bIsNumeric = TRUE; - pKey2->eSortOrder = SRT_ASCENDING; - - SwSortKey* pKey3 = new SwSortKey; - pKey3->nColumnId = USHRT_MAX; - pKey3->bIsNumeric = TRUE; - pKey3->eSortOrder = SRT_ASCENDING; - SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3}; - - sal_Bool bOldSortdescriptor(sal_False); - sal_Bool bNewSortdescriptor(sal_False); - - for( int n = 0; n < rDescriptor.getLength(); ++n ) - { - uno::Any aValue( pProperties[n].Value ); -// String sPropName = pProperties[n].Name; - const OUString& rPropName = pProperties[n].Name; - - // old and new sortdescriptor - if( COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) - { - if ( aValue.getValueType() == ::getBooleanCppuType() ) - rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) - { - sal_Unicode uChar = sal_Unicode(); - if( aValue >>= uChar ) - rSortOpt.cDeli = uChar; - else - bRet = sal_False; - } - // old sortdescriptor - else if(COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) - { - bOldSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; - } - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) - { - bOldSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.bIgnoreCase = !bTemp; - } - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) - { - bOldSortdescriptor = sal_True; - Locale aLocale; - if (aValue >>= aLocale) - rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", 17) && - rPropName.getLength() == 18 && - (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[17]; - nIndex -= '0'; - OUString aTxt; - if ((aValue >>= aTxt) && nIndex < 3) - aKeys[nIndex]->sSortType = aTxt; - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", 17) && - rPropName.getLength() == 18 && - (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[17]; - nIndex -= '0'; - sal_Int16 nCol = -1; - if( aValue.getValueType() == ::getCppuType((const sal_Int16*)0) && nIndex < 3) - aValue >>= nCol; - if( nCol >= 0 ) - aKeys[nIndex]->nColumnId = nCol; - else - bRet = sal_False; - } - else if(0 == rPropName.indexOf(C2U("IsSortNumeric")) && - rPropName.getLength() == 14 && - (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[13]; - nIndex = nIndex - '0'; - if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - aKeys[nIndex]->bIsNumeric = bTemp; - } - else - bRet = sal_False; - } - else if(0 == rPropName.indexOf(C2U("IsSortAscending")) && - rPropName.getLength() == 16 && - (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[15]; - nIndex -= '0'; - if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - aKeys[nIndex]->eSortOrder = bTemp ? SRT_ASCENDING : SRT_DESCENDING; - } - else - bRet = sal_False; - } - // new sortdescriptor - else if(COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) - { - bNewSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; - } - else - bRet = sal_False; - } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) - { - bNewSortdescriptor = sal_True; - uno::Sequence < table::TableSortField > aFields; - if ( aValue >>= aFields ) - { - sal_Int32 nCount(aFields.getLength()); - if (nCount <= 3) - { - table::TableSortField* pFields = aFields.getArray(); - for (sal_Int32 i = 0; i < nCount; ++i) - { - rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive; - rSortOpt.nLanguage = SvxLocaleToLanguage( pFields[i].CollatorLocale ); - aKeys[i]->sSortType = pFields[i].CollatorAlgorithm; - aKeys[i]->nColumnId = static_cast< USHORT >(pFields[i].Field); - aKeys[i]->bIsNumeric = (pFields[i].FieldType == table::TableSortFieldType_NUMERIC); - aKeys[i]->eSortOrder = pFields[i].IsAscending ? SRT_ASCENDING : SRT_DESCENDING; - } - } - else - bRet = sal_False; - } - else - bRet = sal_False; - } - } - - if (bNewSortdescriptor && bOldSortdescriptor) - { - DBG_ERROR("someone tried to set the old deprecated and the new sortdescriptor"); - bRet = sal_False; - } - - if(pKey1->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); - if(pKey2->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); - if(pKey3->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); - - return bRet && rSortOpt.aKeys.Count() > 0; -} -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) - throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwSortOptions aSortOpt; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - - if(pUnoCrsr) - { - if(pUnoCrsr->HasMark()) - { - if(!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) - throw uno::RuntimeException(); - UnoActionContext aContext( pUnoCrsr->GetDoc() ); - - SwPosition* pStart = pUnoCrsr->Start(); - SwPosition* pEnd = pUnoCrsr->End(); - - SwNodeIndex aPrevIdx( pStart->nNode, -1 ); - ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); - xub_StrLen nCntStt = pStart->nContent.GetIndex(); - - pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); - - // Selektion wieder setzen - pUnoCrsr->DeleteMark(); - pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); - SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); - xub_StrLen nLen = pCNd->Len(); - if( nLen > nCntStt ) - nLen = nCntStt; - pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); - pUnoCrsr->SetMark(); - - pUnoCrsr->GetPoint()->nNode += nOffset; - pCNd = pUnoCrsr->GetCntntNode(); - pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - } - } - else - throw uno::RuntimeException(); -} /*-- 10.12.98 11:52:15--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -694,166 +355,6 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew) } } -/* -----------------------------03.04.00 09:11-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Reference< XEnumeration > SAL_CALL SwXTextCursor::createContentEnumeration(const OUString& rServiceName) throw( RuntimeException ) -{ - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr || 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) - throw RuntimeException(); - - uno::Reference< XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); - return xRet; -} -/* -----------------------------07.03.01 14:53-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( RuntimeException ) -{ - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr ) - throw RuntimeException(); - uno::Reference xTunnel(xParentText, UNO_QUERY); - SwXText* pParentText = 0; - if(xTunnel.is()) - { - pParentText = reinterpret_cast< SwXText *>( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); - } - DBG_ASSERT(pParentText, "parent is not a SwXText"); - if (!pParentText) - { - throw uno::RuntimeException(); - } - - ::std::auto_ptr pNewCrsr( - pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); - if(pUnoCrsr->HasMark()) - { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); - } - const CursorType eSetType = (CURSOR_TBLTEXT == eType) - ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - const uno::Reference< XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); - - return xRet; -} -/* -----------------------------07.03.01 15:43-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Type SwXTextCursor::getElementType(void) throw( RuntimeException ) -{ - return ::getCppuType((uno::Reference*)0); -} -/* -----------------------------07.03.01 15:43-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::hasElements(void) throw( RuntimeException ) -{ - return sal_True; -} -/* -----------------------------03.04.00 09:11-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SAL_CALL SwXTextCursor::getAvailableServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); - return aRet; -} -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ - -IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - uno::Reference< XInterface >*, EMPTYARG ) -{ - ASSERT( pThis != NULL, "no reference?" ); - //ASSERT( pArg != NULL, "no reference?" ); - - // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event - // has been executed. It is not necessary to remove the user event in - // ~SwXTextCursor - pThis->DoNotRemoveUserEvent(); - // <-- - - SwUnoCrsr* pCursor = pThis->GetCrsr(); - if( pCursor != NULL ) - { - pCursor->Remove( pThis ); - delete pCursor; - } - - // --> FME 2006-03-07 #126177# - //delete pArg; - // <-- - - return 0; -} - -void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); - - // if the cursor leaves its designated section, it becomes invalid - if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) - { - // --> FME 2006-03-07 #126177# We don't need to create a reference - // to the SwXTextCursor to prevent its deletion. If the destructor - // of the SwXTextCursor is called before the user event is executed, - // the user event will be removed. This is necessary, because an other - // thread might be currently waiting in ~SwXTextCursor. In this case - // the pRef = new ... stuff did not work! - - // create reference to this object to prevent deletion before - // the STATIC_LINK is executed. The link will delete the - // reference. - //uno::Reference* pRef = - //new uno::Reference( static_cast( this ) ); - - mbRemoveUserEvent = true; - // <-- - - mnUserEventId = Application::PostUserEvent( - STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); - } - - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); - -} -/*-- 09.12.98 14:19:01--------------------------------------------------- - - -----------------------------------------------------------------------*/ -const SwPaM* SwXTextCursor::GetPaM() const -{ - return GetCrsr() ? GetCrsr() : 0; -} -// ----------------------------------------------------------------------------- -SwPaM* SwXTextCursor::GetPaM() -{ - return GetCrsr() ? GetCrsr() : 0; -} - -/*-- 09.12.98 14:19:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -const SwDoc* SwXTextCursor::GetDoc()const -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} -/* -----------------22.07.99 13:52------------------- - - --------------------------------------------------*/ -SwDoc* SwXTextCursor::GetDoc() -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} - /*-- 09.12.98 14:19:03--------------------------------------------------- @@ -2638,16 +2139,3 @@ throw (uno::RuntimeException) g_nServicesParaFrameEnum, g_ServicesParaFrameEnum); } - -// ----------------------------------------------------------------------------- -IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) - -uno::Any SAL_CALL SwXTextCursor::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) -{ - if( _rType == ::getCppuType( (uno::Reference*)0) ) - return OTextCursorHelper::queryInterface( _rType ); - else - return SwXTextCursor_Base::queryInterface( _rType ); -} - - -- cgit v1.2.3 From 707a8056246df700f59a3dfec7f6cecfdabeee50 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:54 +0100 Subject: swunolocking1: #i105557#: SwXTextCursor: move enum SwGetPropertyStatesCaller to unocrsrhelper.hxx. move static methods of SwXTextCursor to namespace SwUnoCursorHelper. move various not-actually-local functions with declarations in multiple cxx files to namespace SwUnoCursorHelper. clean up the implementation a little. --- sw/inc/unocrsrhelper.hxx | 113 +++- sw/inc/unotextcursor.hxx | 84 --- sw/source/core/access/accpara.cxx | 4 +- sw/source/core/edit/editsh.cxx | 4 +- sw/source/core/unocore/SwXTextDefaults.cxx | 11 +- sw/source/core/unocore/unocrsrhelper.cxx | 12 +- sw/source/core/unocore/unoobj.cxx | 991 +++++++++++++++++------------ sw/source/core/unocore/unoobj2.cxx | 168 +++-- sw/source/core/unocore/unoparagraph.cxx | 17 +- sw/source/core/unocore/unoport.cxx | 23 +- sw/source/core/unocore/unoportenum.cxx | 4 +- sw/source/core/unocore/unosect.cxx | 2 +- sw/source/core/unocore/unotbl.cxx | 59 +- sw/source/core/unocore/unotext.cxx | 22 +- sw/source/ui/uno/unotxvw.cxx | 31 +- 15 files changed, 863 insertions(+), 682 deletions(-) diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index 27a511d969..2a25fb24ac 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -30,12 +30,25 @@ #ifndef _UNOCRSRHELPER_HXX #define _UNOCRSRHELPER_HXX -#include -#include #include +#include +#include + +#include +#include + + +class String; +class SfxItemSet; +class SfxItemPropertySet; struct SfxItemPropertySimpleEntry; +class SwTxtNode; class SwPaM; +class SwCursor; +class SwUnoCrsr; +class SwFmtColl; +struct SwSortOptions; class SwDoc; namespace com{ namespace sun{ namespace star{ @@ -46,7 +59,18 @@ namespace com{ namespace sun{ namespace star{ struct PropertyValue; } }}} - + +/* -----------------03.12.98 12:16------------------- + * + * --------------------------------------------------*/ +enum SwGetPropertyStatesCaller +{ + SW_PROPERTY_STATE_CALLER_DEFAULT, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT +}; + /* -----------------------------14.12.00 15:06-------------------------------- ---------------------------------------------------------------------------*/ @@ -62,6 +86,7 @@ namespace SwUnoCursorHelper void SetValue( USHORT nWhichId, USHORT nMemberId, const com::sun::star::uno::Any& rAny ); bool FillValue( USHORT nWhichId, USHORT nMemberId, const com::sun::star::uno::Any*& pAny ); }; + sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry , SwPaM& rPam , com::sun::star::uno::Any *pAny @@ -102,6 +127,88 @@ namespace SwUnoCursorHelper const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + /// @param bTableMode: attributes should be applied to a table selection + void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet, + const SetAttrMode nAttrMode, + const bool bTableMode = false); + void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet, + const bool bOnlyTxtAttr = false, + const bool bGetFromChrFmt = true); + void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer); + SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional); + + void SelectPam(SwPaM & rPam, const bool bExpand); + void SetString(SwCursor & rCursor, const ::rtl::OUString & rString); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + CreateSortDescriptor(const bool bFromTable); + sal_Bool ConvertSortProperties( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rDescriptor, + SwSortOptions & rSortOpt); + + /// @param bTableMode: attributes should be applied to a table selection + void SetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName, + const ::com::sun::star::uno::Any & rValue, + const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT, + const bool bTableMode = false) + 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::Any GetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > GetPropertyStates( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const SwGetPropertyStatesCaller eCaller = + SW_PROPERTY_STATE_CALLER_DEFAULT) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::beans::PropertyState GetPropertyState( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + void SetPropertyToDefault( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any GetPropertyDefault( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + bool SetPageDesc( + const ::com::sun::star::uno::Any& rValue, + SwDoc & rDoc, SfxItemSet & rSet); + void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM) + throw (::com::sun::star::lang::IllegalArgumentException); + bool SetCursorPropertyValue( + SfxItemPropertySimpleEntry const& rEntry, + ::com::sun::star::uno::Any const& rValue, + SwPaM & rPam, SfxItemSet & rItemSet) + throw (::com::sun::star::lang::IllegalArgumentException); + } // namespace SwUnoCursorHelper #endif diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index ce91bd2952..fe9b260218 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -58,32 +58,13 @@ #include -class SfxItemSet; class SfxItemPropertySet; class SwDoc; struct SwPosition; -class SwCursor; class SwUnoCrsr; -class SwFmtColl; struct SwSortOptions; -/* -----------------03.12.98 12:16------------------- - * - * --------------------------------------------------*/ -enum SwGetPropertyStatesCaller -{ - SW_PROPERTY_STATE_CALLER_DEFAULT, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, - SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT -}; - -/// attributes should be applied to a table selection -#define CRSR_ATTR_MODE_TABLE 1 -/// attributes should be added, not replaced -#define CRSR_ATTR_MODE_DONTREPLACE 2 - typedef ::cppu::WeakImplHelper12 < ::com::sun::star::lang::XServiceInfo , ::com::sun::star::beans::XPropertySet @@ -152,71 +133,6 @@ public: void DeleteAndInsert(const String& rText, const bool bForceExpandHints); - static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, - USHORT nAttrMode); - static void GetCrsrAttr( SwPaM& rPam, SfxItemSet& rSet, - BOOL bOnlyTxtAttr = FALSE, BOOL bGetFromChrFmt = TRUE ); - static void getTextFromPam(SwPaM& aCrsr, ::rtl::OUString& rBuffer); - static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); - - static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); - static void SetString(SwCursor& rCrsr, const ::rtl::OUString& rString); - - static ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyValue > - createSortDescriptor(sal_Bool bFromTable); - static sal_Bool convertSortProperties( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyValue >& rDescriptor, - SwSortOptions& rSortOpt); - - static void SetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName, - const ::com::sun::star::uno::Any& aValue, - USHORT nAttrMode = 0) - 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); - static ::com::sun::star::uno::Any GetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyState > GetPropertyStates( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames, - SwGetPropertyStatesCaller eCaller=SW_PROPERTY_STATE_CALLER_DEFAULT) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::beans::PropertyState GetPropertyState( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::uno::RuntimeException); - static void SetPropertyToDefault( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyDefault( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - virtual const SwPaM* GetPaM() const; virtual SwPaM* GetPaM(); virtual const SwDoc* GetDoc() const; diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index eac4a4fdaf..d931f65a18 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "fesh.hxx" @@ -1533,7 +1533,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl( SfxItemSet aCharAttrsAtPaM( pPaM->GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END -1, 0 ); - SwXTextCursor::GetCrsrAttr( *pPaM, aCharAttrsAtPaM, TRUE, TRUE ); + SwUnoCursorHelper::GetCrsrAttr(*pPaM, aCharAttrsAtPaM, TRUE, TRUE); aSet.Put( aCharAttrsAtPaM ); } // <-- diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 56df4dac76..b7c272f456 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include @@ -1111,7 +1111,7 @@ String SwEditShell::DeleteExtTextInput( SwExtTextInput* pDel, BOOL bInsText ) if( pDel ) { rtl::OUString sTmp; - SwXTextCursor::getTextFromPam(*pDel, sTmp); + SwUnoCursorHelper::GetTextFromPam(*pDel, sTmp); sRet = sTmp; SET_CURR_SHELL( this ); StartAllAction(); diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index 2218129443..7d1c1cb43d 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -30,9 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + +#include + #include #include -#include + #include #include #include @@ -44,6 +47,7 @@ #include #include #include +#include #include #include @@ -56,9 +60,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; -// declarations -void lcl_setPageDesc(SwDoc*, const uno::Any&, SfxItemSet& ); // from unoobj.cxx - SwXTextDefaults::SwXTextDefaults ( SwDoc * pNewDoc ) : m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_DEFAULT ) ), @@ -97,7 +98,7 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName, { SfxItemSet aSet( m_pDoc->GetAttrPool(), RES_PAGEDESC, RES_PAGEDESC ); aSet.Put(rItem); - lcl_setPageDesc( m_pDoc, aValue, aSet ); + SwUnoCursorHelper::SetPageDesc( aValue, *m_pDoc, aSet ); m_pDoc->SetDefault(aSet.Get(RES_PAGEDESC)); } else if ((RES_PARATR_DROP == pMap->nWID && MID_DROPCAP_CHAR_STYLE_NAME == pMap->nMemberId) || diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 676c1839ad..2e177b40e0 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,12 +32,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + #include #include #include #include -#include #include #include #include @@ -45,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -103,8 +105,9 @@ using ::rtl::OUString; namespace SwUnoCursorHelper { + /* -----------------16.09.98 12:27------------------- - * Lesen spezieller Properties am Cursor +* Lesen spezieller Properties am Cursor * --------------------------------------------------*/ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry , SwPaM& rPam @@ -196,7 +199,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry pFmt = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID ? pNode->GetFmtColl() : &pNode->GetAnyFmtColl(); else - pFmt = SwXTextCursor::GetCurTxtFmtColl(rPam, FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID); + { + pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(rPam, + FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID); + } if(pFmt) { if( pAny ) diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 5deb85dd2a..d86f8f59f8 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -195,25 +196,30 @@ SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM) /*-----------------09.03.98 08:29------------------- --------------------------------------------------*/ -void SwXTextCursor::SelectPam(SwPaM& rCrsr, sal_Bool bExpand) +void SwUnoCursorHelper::SelectPam(SwPaM & rPam, const bool bExpand) { - if(bExpand) + if (bExpand) { - if(!rCrsr.HasMark()) - rCrsr.SetMark(); + if (!rPam.HasMark()) + { + rPam.SetMark(); + } + } + else if (rPam.HasMark()) + { + rPam.DeleteMark(); } - else if(rCrsr.HasMark()) - rCrsr.DeleteMark(); - } /* -----------------20.05.98 14:59------------------- * * --------------------------------------------------*/ -void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) +void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer) { - if(!aCrsr.HasMark()) + if (!rPam.HasMark()) + { return; + } SvCacheStream aStream( 20480 ); #ifdef OSL_BIGENDIAN aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); @@ -225,7 +231,7 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) SwReaderWriter::GetWriter( C2S(FILTER_TEXT_DLG), String(), xWrt ); if( xWrt.Is() ) { - SwWriter aWriter( aStream, aCrsr ); + SwWriter aWriter( aStream, rPam ); xWrt->bASCII_NoLastLineEnd = sal_True; xWrt->bExportPargraphNumbering = sal_False; SwAsciiOptions aOpt = xWrt->GetAsciiOptions(); @@ -253,10 +259,15 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) String sBuf; sal_Int32 nLocalLen = 0; if( lUniLen >= STRING_MAXLEN ) + { nLocalLen = STRING_MAXLEN - 1; + } else + { nLocalLen = lUniLen; - sal_Unicode* pStrBuf = sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); + } + sal_Unicode *const pStrBuf = + sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); aStream.Read( pStrBuf, 2 * nLocalLen ); pStrBuf[ nLocalLen ] = '\0'; aStrBuffer.append( pStrBuf, nLocalLen ); @@ -271,46 +282,52 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) /* -----------------06.07.98 07:33------------------- * * --------------------------------------------------*/ -void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) - throw (lang::IllegalArgumentException) +static void +lcl_setCharStyle(SwDoc *const pDoc, const uno::Any & rValue, SfxItemSet & rSet) +throw (lang::IllegalArgumentException) { - SwDocShell* pDocSh = pDoc->GetDocShell(); + SwDocShell *const pDocSh = pDoc->GetDocShell(); if(pDocSh) { OUString uStyle; - aValue >>= uStyle; - String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); - if(pStyle) + if (!(rValue >>= uStyle)) { - SwFmtCharFmt aFmt(pStyle->GetCharFmt()); - rSet.Put(aFmt); + throw lang::IllegalArgumentException(); } - else + String sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + SwDocStyleSheet *const pStyle = static_cast( + pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); + if (!pStyle) { - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - + const SwFmtCharFmt aFmt(pStyle->GetCharFmt()); + rSet.Put(aFmt); } }; /* -----------------08.06.06 10:43------------------- * * --------------------------------------------------*/ -void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItemSet& rSet, bool bPara ) - throw (lang::IllegalArgumentException) +static void +lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue, + SfxItemSet & rSet, const bool bPara) +throw (lang::IllegalArgumentException) { OUString uStyle; - aValue >>= uStyle; - String sStyle; + if (!(rValue >>= uStyle)) + { + throw lang::IllegalArgumentException(); + } StylePool::SfxItemSet_Pointer_t pStyle = bPara ? rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ): rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR ); if(pStyle.get()) { - SwFmtAutoFmt aFmt( bPara ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE) - : sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) ); + SwFmtAutoFmt aFmt( (bPara) + ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE) + : sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) ); aFmt.SetStyleHandle( pStyle ); rSet.Put(aFmt); } @@ -322,71 +339,77 @@ void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItem /* -----------------30.06.98 08:46------------------- * * --------------------------------------------------*/ -void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) - throw (lang::IllegalArgumentException) +void +SwUnoCursorHelper::SetTxtFmtColl(const uno::Any & rAny, SwPaM & rPaM) +throw (lang::IllegalArgumentException) { - SwDoc* pDoc = rPaM.GetDoc(); - SwDocShell* pDocSh = pDoc->GetDocShell(); + SwDoc *const pDoc = rPaM.GetDoc(); + SwDocShell *const pDocSh = pDoc->GetDocShell(); if(!pDocSh) return; OUString uStyle; rAny >>= uStyle; String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA); - if(pStyle) - { - SwTxtFmtColl *pLocal = pStyle->GetCollection(); - UnoActionContext aAction(pDoc); - pDoc->StartUndo( UNDO_START, NULL ); - SwPaM *pTmpCrsr = &rPaM; - do { - pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); - pTmpCrsr = static_cast(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != &rPaM ); - pDoc->EndUndo( UNDO_END, NULL ); - } - else + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); + SwDocStyleSheet *const pStyle = static_cast( + pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA)); + if (!pStyle) { throw lang::IllegalArgumentException(); } + SwTxtFmtColl *const pLocal = pStyle->GetCollection(); + UnoActionContext aAction(pDoc); + pDoc->StartUndo( UNDO_START, NULL ); + SwPaM *pTmpCrsr = &rPaM; + do { + pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); + pTmpCrsr = static_cast(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); + pDoc->EndUndo( UNDO_END, NULL ); } + /* -----------------06.07.98 07:38------------------- * * --------------------------------------------------*/ - void lcl_setPageDesc(SwDoc* pDoc, const uno::Any& aValue, SfxItemSet& rSet) - { - if(aValue.getValueType() != ::getCppuType((const OUString*)0)) - return; - SwFmtPageDesc *pNewDesc = 0 ; +bool +SwUnoCursorHelper::SetPageDesc( + const uno::Any& rValue, SwDoc & rDoc, SfxItemSet & rSet) +{ + OUString uDescName; + if (!(rValue >>= uDescName)) + { + return false; + } + ::std::auto_ptr pNewDesc; const SfxPoolItem* pItem; if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) { - pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem)); + pNewDesc.reset(new SwFmtPageDesc( + *static_cast(pItem))); + } + if (!pNewDesc.get()) + { + pNewDesc.reset(new SwFmtPageDesc()); } - if(!pNewDesc) - pNewDesc = new SwFmtPageDesc(); - OUString uDescName; - aValue >>= uDescName; String sDescName; - SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); - if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName) + SwStyleNameMapper::FillUIName(uDescName, sDescName, + nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True); + if (!pNewDesc->GetPageDesc() || + (pNewDesc->GetPageDesc()->GetName() != sDescName)) { sal_Bool bPut = sal_False; if(sDescName.Len()) { - SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); - if(pPageDesc) - { - pPageDesc->Add( pNewDesc ); - bPut = sal_True; - } - else + SwPageDesc *const pPageDesc = + ::GetPageDescByName_Impl(rDoc, sDescName); + if (!pPageDesc) { throw lang::IllegalArgumentException(); } + pPageDesc->Add( pNewDesc.get() ); + bPut = sal_True; } if(!bPut) { @@ -394,17 +417,21 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) rSet.Put(SwFmtPageDesc()); } else + { rSet.Put(*pNewDesc); + } } - delete pNewDesc; + return true; } + /* -----------------30.06.98 10:29------------------- * * --------------------------------------------------*/ -void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue ) +static void +lcl_SetNodeNumStart(SwPaM & rCrsr, uno::Any const& rValue) { sal_Int16 nTmp = 1; - aValue >>= nTmp; + rValue >>= nTmp; sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : (sal_uInt16)nTmp); SwDoc* pDoc = rCrsr.GetDoc(); UnoActionContext aAction(pDoc); @@ -429,215 +456,264 @@ void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue ) } } +static bool +lcl_setCharFmtSequence(SwPaM & rPam, uno::Any const& rValue) +{ + uno::Sequence aCharStyles; + if (!(rValue >>= aCharStyles)) + { + return false; + } + + for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) + { + uno::Any aStyle; + rPam.GetDoc()->StartUndo(UNDO_START, NULL); + aStyle <<= aCharStyles.getConstArray()[nStyle]; + // create a local set and apply each format directly + SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT); + lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet); + // the first style should replace the current attributes, + // all other have to be added + SwUnoCursorHelper::SetCrsrAttr(rPam, aSet, (nStyle) + ? nsSetAttrMode::SETATTR_DONTREPLACE + : nsSetAttrMode::SETATTR_DEFAULT); + rPam.GetDoc()->EndUndo(UNDO_START, NULL); + } + return true; +} + +static void +lcl_setDropcapCharStyle(SwPaM & rPam, SfxItemSet & rItemSet, + uno::Any const& rValue) +{ + OUString uStyle; + if (!(rValue >>= uStyle)) + { + throw lang::IllegalArgumentException(); + } + String sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + SwDoc *const pDoc = rPam.GetDoc(); + //default character style must not be set as default format + SwDocStyleSheet *const pStyle = static_cast( + pDoc->GetDocShell() + ->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); + if (!pStyle || + (static_cast(pStyle)->GetCharFmt() == + pDoc->GetDfltCharFmt())) + { + throw lang::IllegalArgumentException(); + } + ::std::auto_ptr pDrop; + SfxPoolItem const* pItem(0); + if (SFX_ITEM_SET == + rItemSet.GetItemState(RES_PARATR_DROP, sal_True, &pItem)) + { + pDrop.reset(new SwFmtDrop(*static_cast(pItem))); + } + if (!pDrop.get()) + { + pDrop.reset(new SwFmtDrop); + } + const rtl::Reference xStyle(new SwDocStyleSheet(*pStyle)); + pDrop->SetCharFmt(xStyle->GetCharFmt()); + rItemSet.Put(*pDrop); +} + +static void +lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue) +{ + OUString sTmp; + if (!(rValue >>= sTmp)) + { + throw lang::IllegalArgumentException(); + } + + ::std::auto_ptr pRuby; + const SfxPoolItem* pItem; + if (SFX_ITEM_SET == + rItemSet.GetItemState(RES_TXTATR_CJK_RUBY, sal_True, &pItem)) + { + pRuby.reset(new SwFmtRuby(*static_cast(pItem))); + } + if (!pRuby.get()) + { + pRuby.reset(new SwFmtRuby(aEmptyStr)); + } + String sStyle; + SwStyleNameMapper::FillUIName(sTmp, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); + pRuby->SetCharFmtName(sStyle); + pRuby->SetCharFmtId(0); + if (sStyle.Len() > 0) + { + const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( + sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); + pRuby->SetCharFmtId(nId); + } + rItemSet.Put(*pRuby); +} + /* -----------------17.09.98 09:44------------------- * * --------------------------------------------------*/ -sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry, - SwPaM& rPam, - SfxItemSet& rItemSet, - const uno::Any& aValue ) throw (lang::IllegalArgumentException) -{ - sal_Bool bRet = sal_True; - if(0 == ( pEntry->nFlags&PropertyAttribute::MAYBEVOID ) && - aValue.getValueType() == ::getCppuVoidType()) - bRet = sal_False; - else - { - switch(pEntry->nWID) +bool +SwUnoCursorHelper::SetCursorPropertyValue( + SfxItemPropertySimpleEntry const& rEntry, const uno::Any& rValue, + SwPaM & rPam, SfxItemSet & rItemSet) +throw (lang::IllegalArgumentException) +{ + if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) && + (rValue.getValueType() == ::getCppuVoidType())) + { + return false; + } + bool bRet = true; + switch (rEntry.nWID) + { + case RES_TXTATR_CHARFMT: + lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet); + break; + case RES_TXTATR_AUTOFMT: + lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), + rValue, rItemSet, false); + break; + case FN_UNO_CHARFMT_SEQUENCE: + lcl_setCharFmtSequence(rPam, rValue); + break; + case FN_UNO_PARA_STYLE : + SwUnoCursorHelper::SetTxtFmtColl(rValue, rPam); + break; + case RES_AUTO_STYLE: + lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), + rValue, rItemSet, true); + break; + case FN_UNO_PAGE_STYLE: + //FIXME nothing here? + break; + case FN_UNO_NUM_START_VALUE: + lcl_SetNodeNumStart( rPam, rValue ); + break; + case FN_UNO_NUM_LEVEL: + // --> OD 2008-07-14 #i91601# + case FN_UNO_LIST_ID: + // <-- + case FN_UNO_IS_NUMBER: { - case RES_TXTATR_CHARFMT: - lcl_setCharStyle(rPam.GetDoc(), aValue, rItemSet ); - break; - case RES_TXTATR_AUTOFMT: - lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, false ); - break; - case FN_UNO_CHARFMT_SEQUENCE: + // multi selection is not considered + SwTxtNode *const pTxtNd = rPam.GetNode()->GetTxtNode(); + // --> OD 2008-05-14 #refactorlists# - check on list style not needed +// const SwNumRule* pRule = pTxtNd->GetNumRule(); +// if( FN_UNO_NUM_LEVEL == rEntry.nWID && pRule != NULL ) + if (FN_UNO_NUM_LEVEL == rEntry.nWID) + // <-- { - Sequence aCharStyles; - if(aValue >>= aCharStyles) + sal_Int16 nLevel = 0; + if (rValue >>= nLevel) { - for(sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) - { - Any aStyle; - rPam.GetDoc()->StartUndo( UNDO_START, NULL); - aStyle <<= aCharStyles.getConstArray()[nStyle]; - //create a local set and apply each format directly - SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT ); - lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet ); - //the first style should replace the current attributes, all other have to be added - SwXTextCursor::SetCrsrAttr(rPam, aSet, nStyle ? CRSR_ATTR_MODE_DONTREPLACE : 0); - rPam.GetDoc()->EndUndo( UNDO_START, NULL ); - } + pTxtNd->SetAttrListLevel(nLevel); } - else - bRet = sal_False; } - break; - case FN_UNO_PARA_STYLE : - lcl_SetTxtFmtColl(aValue, rPam); - break; - case RES_AUTO_STYLE: - lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, true ); - break; - case FN_UNO_PAGE_STYLE : - break; - case FN_UNO_NUM_START_VALUE : - lcl_SetNodeNumStart( rPam, aValue ); - break; - case FN_UNO_NUM_LEVEL : // --> OD 2008-07-14 #i91601# - case FN_UNO_LIST_ID: - // <-- - case FN_UNO_IS_NUMBER : + else if (FN_UNO_LIST_ID == rEntry.nWID) { - // multi selection is not considered - SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode(); - // --> OD 2008-05-14 #refactorlists# - check on list style not needed -// const SwNumRule* pRule = pTxtNd->GetNumRule(); -// if( FN_UNO_NUM_LEVEL == pEntry->nWID && pRule != NULL ) - if ( FN_UNO_NUM_LEVEL == pEntry->nWID ) - // <-- - { - sal_Int16 nLevel = 0; - aValue >>= nLevel; - - pTxtNd->SetAttrListLevel(nLevel); - - } - // --> OD 2008-07-14 #i91601# - else if( FN_UNO_LIST_ID == pEntry->nWID ) + ::rtl::OUString sListId; + if (rValue >>= sListId) { - ::rtl::OUString sListId; - aValue >>= sListId; pTxtNd->SetListId( sListId ); } - // <-- - else if( FN_UNO_IS_NUMBER == pEntry->nWID ) + } + // <-- + else if (FN_UNO_IS_NUMBER == rEntry.nWID) + { + sal_Bool bIsNumber(sal_False); + if (rValue >>= bIsNumber) { - BOOL bIsNumber = *(sal_Bool*) aValue.getValue(); - if(!bIsNumber) + if (!bIsNumber) + { pTxtNd->SetCountedInList( false ); + } } - //PROPERTY_MAYBEVOID! } - break; - case FN_NUMBER_NEWSTART : + //PROPERTY_MAYBEVOID! + } + break; + case FN_NUMBER_NEWSTART: + { + sal_Bool bVal = sal_False; + if (!(rValue >>= bVal)) { - sal_Bool bVal = sal_False; - if (aValue >>= bVal) - rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case FN_UNO_NUM_RULES: - SwUnoCursorHelper::setNumberingProperty(aValue, rPam); - break; - case RES_PARATR_DROP: + rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal); + } + break; + case FN_UNO_NUM_RULES: + SwUnoCursorHelper::setNumberingProperty(rValue, rPam); + break; + case RES_PARATR_DROP: + { + if (MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId) { - if( MID_DROPCAP_CHAR_STYLE_NAME == pEntry->nMemberId) - { - OUString uStyle; - if(aValue >>= uStyle) - { - String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - SwDoc* pDoc = rPam.GetDoc(); - //default character style mustn't be set as default format - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); - SwFmtDrop* pDrop = 0; - if(pStyle && - ((SwDocStyleSheet*)pStyle)->GetCharFmt() != pDoc->GetDfltCharFmt()) - { - const SfxPoolItem* pItem; - if(SFX_ITEM_SET == rItemSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) ) - pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem)); - if(!pDrop) - pDrop = new SwFmtDrop(); - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) ); - pDrop->SetCharFmt(xStyle->GetCharFmt()); - } - else - throw lang::IllegalArgumentException(); - rItemSet.Put(*pDrop); - delete pDrop; - } - else - throw lang::IllegalArgumentException(); - } - else - bRet = sal_False; + lcl_setDropcapCharStyle(rPam, rItemSet, rValue); } - break; - case RES_TXTATR_CJK_RUBY: - if(MID_RUBY_CHARSTYLE == pEntry->nMemberId ) - { - OUString sTmp; - if(aValue >>= sTmp) - { - SwFmtRuby* pRuby = 0; - const SfxPoolItem* pItem; - if(SFX_ITEM_SET == rItemSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) ) - pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem)); - if(!pRuby) - pRuby = new SwFmtRuby(aEmptyStr); - String sStyle; - SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - pRuby->SetCharFmtName( sStyle ); - pRuby->SetCharFmtId( 0 ); - if(sStyle.Len() > 0) - { - sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); - pRuby->SetCharFmtId(nId); - } - rItemSet.Put(*pRuby); - delete pRuby; - } - else - throw lang::IllegalArgumentException(); - bRet = sal_True; - } - else - bRet = sal_False; - break; - case RES_PAGEDESC : - if(MID_PAGEDESC_PAGEDESCNAME == pEntry->nMemberId ) + else { - lcl_setPageDesc(rPam.GetDoc(), aValue, rItemSet); - break; + bRet = false; } - //hier kein break - default: bRet = sal_False; } + break; + case RES_TXTATR_CJK_RUBY: + { + if (MID_RUBY_CHARSTYLE == rEntry.nMemberId) + { + lcl_setRubyCharstyle(rItemSet, rValue); + } + else + { + bRet = false; + } + } + break; + case RES_PAGEDESC: + { + if (MID_PAGEDESC_PAGEDESCNAME == rEntry.nMemberId) + { + SwUnoCursorHelper::SetPageDesc( + rValue, *rPam.GetDoc(), rItemSet); + } + else + { + bRet = false; + } + } + break; + default: + bRet = false; } -return bRet; + return bRet; } /* -----------------30.06.98 08:39------------------- * * --------------------------------------------------*/ -SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) +SwFmtColl * +SwUnoCursorHelper::GetCurTxtFmtColl(SwPaM & rPaM, const bool bConditional) { static const sal_uInt16 nMaxLookup = 1000; SwFmtColl *pFmt = 0; // if ( GetCrsrCnt() > nMaxLookup ) // return 0; - sal_Bool bError = sal_False; + bool bError = false; SwPaM *pTmpCrsr = &rPaM; - do { - - ULONG nSttNd = pTmpCrsr->GetMark()->nNode.GetIndex(); - ULONG nEndNd = pTmpCrsr->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = pTmpCrsr->GetMark()->nContent.GetIndex(); - xub_StrLen nEndCnt = pTmpCrsr->GetPoint()->nContent.GetIndex(); - - if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) - { - sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp; - nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp; - } + do + { + const ULONG nSttNd = pTmpCrsr->Start()->nNode.GetIndex(); + const ULONG nEndNd = pTmpCrsr->End()->nNode.GetIndex(); if( nEndNd - nSttNd >= nMaxLookup ) { @@ -648,33 +724,33 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) const SwNodes& rNds = rPaM.GetDoc()->GetNodes(); for( ULONG n = nSttNd; n <= nEndNd; ++n ) { - const SwTxtNode* pNd = rNds[ n ]->GetTxtNode(); + SwTxtNode const*const pNd = rNds[ n ]->GetTxtNode(); if( pNd ) { - SwFmtColl* pNdFmt = bConditional ? pNd->GetFmtColl() - : &pNd->GetAnyFmtColl(); + SwFmtColl *const pNdFmt = (bConditional) + ? pNd->GetFmtColl() : &pNd->GetAnyFmtColl(); if( !pFmt ) + { pFmt = pNdFmt; + } else if( pFmt != pNdFmt ) { - bError = sal_True; + bError = true; break; } } } - if(bError) - break; pTmpCrsr = static_cast(pTmpCrsr->GetNext()); } while ( pTmpCrsr != &rPaM ); - return bError ? 0 : pFmt; + return (bError) ? 0 : pFmt; } /* -----------------26.06.98 16:20------------------- * Hilfsfunktion fuer PageDesc * --------------------------------------------------*/ - SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) - { +SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) +{ SwPageDesc* pRet = 0; sal_uInt16 nDCount = rDoc.GetPageDescCnt(); sal_uInt16 i; @@ -695,7 +771,8 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) const String aFmtName(SW_RES(i)); if(aFmtName == rName) { - pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); + pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >( + RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); break; } } @@ -934,7 +1011,7 @@ void SwXTextCursor::DeleteAndInsert(const String& rText, DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); (void) bSuccess; - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); } } while( (_pStartCrsr=(SwCursor*)_pStartCrsr->GetNext()) != pUnoCrsr ); @@ -945,7 +1022,8 @@ void SwXTextCursor::DeleteAndInsert(const String& rText, enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END }; -sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, +static sal_Bool +lcl_ForceIntoMeta(SwPaM & rCursor, uno::Reference const & xParentText, const enum ForceIntoMetaMode eMode) { @@ -1106,7 +1184,7 @@ sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::Ru SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); if (CURSOR_META == eType) { @@ -1130,7 +1208,7 @@ sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::R SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); if (CURSOR_META == eType) { @@ -1153,7 +1231,7 @@ void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) { pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); @@ -1209,7 +1287,7 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) { pUnoCrsr->Move( fnMoveForward, fnGoDoc ); @@ -1424,7 +1502,7 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti SwNode *pOldNode = &pPoint->nNode.GetNode(); xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); //Absatzende? if(pUnoCrsr->GetCntntNode() && pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) @@ -1470,7 +1548,7 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc SwNode *pOldNode = &pPoint->nNode.GetNode(); xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); //Absatzanfang ? if(pPoint->nContent == 0) { @@ -1514,7 +1592,7 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(!pUnoCrsr->IsEndWordWT( nWordType )) pUnoCrsr->GoEndWordWT( nWordType ); @@ -1554,7 +1632,7 @@ sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeExce xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(!pUnoCrsr->IsStartWordWT( nWordType )) pUnoCrsr->GoStartWordWT( nWordType ); @@ -1646,7 +1724,7 @@ sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeExc if(pUnoCrsr) { BOOL bWasEOS = isEndOfSentence(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->GoSentence(SwCursor::NEXT_SENT); if(!bRet) bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); @@ -1680,7 +1758,7 @@ sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::Runtim SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->GoSentence(SwCursor::PREV_SENT); if(!bRet) { @@ -1712,7 +1790,7 @@ sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::Runtime SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); // if we're at the para start then we wont move // but bRet is also true if GoSentence failed but // the start of the sentence is reached @@ -1739,7 +1817,7 @@ sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeEx SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); // bRet is true if GoSentence() succeeded or if the // MovePara() succeeded while the end of the para is // not reached already @@ -1798,7 +1876,7 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr ) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); if(!bRet) bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaStart); @@ -1824,7 +1902,7 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); if(!bRet) bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); @@ -1850,7 +1928,7 @@ sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeEx SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); } else @@ -1869,7 +1947,7 @@ sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::Runti SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart); } else @@ -1967,7 +2045,7 @@ OUString SwXTextCursor::getString(void) throw( uno::RuntimeException ) else */ { //Text ueber mehrere Absaetze - SwXTextCursor::getTextFromPam(*pUnoCrsr, aTxt); + SwUnoCursorHelper::GetTextFromPam(*pUnoCrsr, aTxt); } } else @@ -1993,242 +2071,307 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept /* -----------------------------03.05.00 12:56-------------------------------- ---------------------------------------------------------------------------*/ -Any SwXTextCursor::GetPropertyValue( +uno::Any SwUnoCursorHelper::GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Any aAny; - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( - rPropertyName); - if(pEntry) + uno::Any aAny; + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + + if (!pEntry) { - PropertyState eTemp; - BOOL bDone = SwUnoCursorHelper::getCrsrPropertyValue( *pEntry, rPaM, &aAny, eTemp ); - if(!bDone) - { - SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_FRMATR_END -1, - RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, - 0L); - SwXTextCursor::GetCrsrAttr(rPaM, aSet); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast(0)); + } - rPropSet.getPropertyValue(*pEntry, aSet, aAny); - } + beans::PropertyState eTemp; + const sal_Bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, rPaM, &aAny, eTemp ); + + if (!bDone) + { + SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_FRMATR_END - 1, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, + 0L); + SwUnoCursorHelper::GetCrsrAttr(rPaM, aSet); + + rPropSet.getPropertyValue(*pEntry, aSet, aAny); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); return aAny; } /* -----------------------------03.05.00 12:57-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextCursor::SetPropertyValue( - SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName, - const Any& aValue, USHORT nAttrMode) - throw (UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException) +void SwUnoCursorHelper::SetPropertyValue( + SwPaM& rPaM, const SfxItemPropertySet& rPropSet, + const OUString& rPropertyName, + const uno::Any& rValue, + const SetAttrMode nAttrMode, const bool bTableMode) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName(rPropertyName); - if(pEntry) + SwDoc *const pDoc = rPaM.GetDoc(); + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - if( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(0)); + } - SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( rPaM, aItemSet ); + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast(0)); + } + + SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); + SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet ); - if(!lcl_setCrsrPropertyValue( pEntry, rPaM, aItemSet, aValue )) - rPropSet.setPropertyValue(*pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr(rPaM, aItemSet, nAttrMode ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, rValue, rPaM, aItemSet)) + { + rPropSet.setPropertyValue(*pEntry, rValue, aItemSet ); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode); } + /* -----------------------------03.05.00 13:16-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< PropertyState > SwXTextCursor::GetPropertyStates( +uno::Sequence< beans::PropertyState > +SwUnoCursorHelper::GetPropertyStates( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - const Sequence< OUString >& PropertyNames, - SwGetPropertyStatesCaller eCaller ) - throw(UnknownPropertyException, RuntimeException) + const uno::Sequence< OUString >& rPropertyNames, + const SwGetPropertyStatesCaller eCaller) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - const OUString* pNames = PropertyNames.getConstArray(); - Sequence< PropertyState > aRet ( PropertyNames.getLength() ); - PropertyState* pStates = aRet.getArray(); + const OUString* pNames = rPropertyNames.getConstArray(); + uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); + beans::PropertyState* pStates = aRet.getArray(); + SfxItemPropertyMap const*const pMap = rPropSet.getPropertyMap(); + ::std::auto_ptr pSet; + ::std::auto_ptr pSetParent; - SfxItemSet *pSet = 0, *pSetParent = 0; - const SfxItemPropertyMap *pMap = rPropSet.getPropertyMap(); - for( INT32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++ ) + for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pNames[i] ); if(!pEntry) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + if (pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { pStates[i] = beans::PropertyState_DEFAULT_VALUE; continue; } - else if( SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller ) + else if (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == + eCaller) { //this values marks the element as unknown property pStates[i] = beans::PropertyState_MAKE_FIXED_SIZE; continue; } else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); + { + throw beans::UnknownPropertyException( + OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast(0)); + } } - if ((eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION || eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT) && + if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) || + (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller)) && pEntry->nWID < FN_UNO_RANGE_BEGIN && pEntry->nWID > FN_UNO_RANGE_END && pEntry->nWID < RES_CHRATR_BEGIN && pEntry->nWID > RES_TXTATR_END ) + { pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } else { if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN && pEntry->nWID <= FN_UNO_RANGE_END ) - SwUnoCursorHelper::getCrsrPropertyValue(*pEntry, rPaM, 0, pStates[i] ); + { + SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, rPaM, 0, pStates[i] ); + } else { - if( !pSet ) + if (!pSet.get()) { switch ( eCaller ) { case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT: case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_TXTATR_END ); + pSet.reset( + new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_TXTATR_END )); break; case SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), - pEntry->nWID, pEntry->nWID ); + pSet.reset( + new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + pEntry->nWID, pEntry->nWID )); break; default: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + pSet.reset( new SfxItemSet( + rPaM.GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_FRMATR_END - 1, RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - 0L ); + 0L )); } // --> OD 2006-07-12 #i63870# - SwXTextCursor::GetCrsrAttr( rPaM, *pSet ); + SwUnoCursorHelper::GetCrsrAttr( rPaM, *pSet ); // <-- } - if( pSet->Count() ) - pStates[i] = rPropSet.getPropertyState( *pEntry, *pSet ); - else - pStates[i] = PropertyState_DEFAULT_VALUE; + pStates[i] = ( pSet->Count() ) + ? rPropSet.getPropertyState( *pEntry, *pSet ) + : beans::PropertyState_DEFAULT_VALUE; //try again to find out if a value has been inherited if( beans::PropertyState_DIRECT_VALUE == pStates[i] ) { - if( !pSetParent ) + if (!pSetParent.get()) { - pSetParent = pSet->Clone( FALSE ); + pSetParent.reset( pSet->Clone( FALSE ) ); // --> OD 2006-07-12 #i63870# - SwXTextCursor::GetCrsrAttr( rPaM, *pSetParent, TRUE, FALSE ); + SwUnoCursorHelper::GetCrsrAttr( + rPaM, *pSetParent, TRUE, FALSE ); // <-- } - if( (pSetParent)->Count() ) - pStates[i] = rPropSet.getPropertyState( *pEntry, *pSetParent ); - else - pStates[i] = PropertyState_DEFAULT_VALUE; + pStates[i] = ( (pSetParent)->Count() ) + ? rPropSet.getPropertyState( *pEntry, *pSetParent ) + : beans::PropertyState_DEFAULT_VALUE; } } } } - delete pSet; - delete pSetParent; return aRet; } /* -----------------------------03.05.00 13:17-------------------------------- ---------------------------------------------------------------------------*/ -PropertyState SwXTextCursor::GetPropertyState( - SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SwUnoCursorHelper::GetPropertyState( + SwPaM& rPaM, const SfxItemPropertySet& rPropSet, + const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - Sequence < OUString > aStrings ( 1 ); + uno::Sequence< OUString > aStrings ( 1 ); aStrings[0] = rPropertyName; - Sequence < PropertyState > aSeq = GetPropertyStates( rPaM, rPropSet, aStrings, SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY ); + uno::Sequence< beans::PropertyState > aSeq = + GetPropertyStates(rPaM, rPropSet, aStrings, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY ); return aSeq[0]; } /* -----------------------------03.05.00 13:20-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_SelectParaAndReset ( SwPaM &rPaM, SwDoc* pDoc, const SvUShortsSort* pWhichIds = 0 ) +static void +lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc, + SvUShortsSort const*const pWhichIds = 0 ) { // if we are reseting paragraph attributes, we need to select the full paragraph first SwPosition aStart = *rPaM.Start(); SwPosition aEnd = *rPaM.End(); - auto_ptr < SwUnoCrsr > pTemp ( pDoc->CreateUnoCrsr(aStart, FALSE) ); + ::std::auto_ptr< SwUnoCrsr > pTemp ( rDoc.CreateUnoCrsr(aStart, FALSE) ); if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) + { pTemp->MovePara(fnParaCurr, fnParaStart); + } pTemp->SetMark(); *pTemp->GetPoint() = aEnd; - SwXTextCursor::SelectPam(*pTemp, sal_True); + SwUnoCursorHelper::SelectPam(*pTemp, true); if(!SwUnoCursorHelper::IsEndOfPara(*pTemp)) + { pTemp->MovePara(fnParaCurr, fnParaEnd); - pDoc->ResetAttrs(*pTemp, sal_True, pWhichIds); + } + rDoc.ResetAttrs(*pTemp, sal_True, pWhichIds); } -void SwXTextCursor::SetPropertyToDefault( +void SwUnoCursorHelper::SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw(UnknownPropertyException, RuntimeException) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( rPropertyName); - if(pEntry) + SwDoc & rDoc = *rPaM.GetDoc(); + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast(0)); + } + + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertyToDefault: property is read-only: ")) + + rPropertyName, 0); + } + + if (pEntry->nWID < RES_FRMATR_END) { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, 0 ); - if(pEntry->nWID < RES_FRMATR_END) + SvUShortsSort aWhichIds; + aWhichIds.Insert(pEntry->nWID); + if (pEntry->nWID < RES_PARATR_BEGIN) { - SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); - if(pEntry->nWID < RES_PARATR_BEGIN) - pDoc->ResetAttrs(rPaM, sal_True, &aWhichIds); - else - lcl_SelectParaAndReset ( rPaM, pDoc, &aWhichIds ); + rDoc.ResetAttrs(rPaM, sal_True, &aWhichIds); } else - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM); + { + lcl_SelectParaAndReset ( rPaM, rDoc, &aWhichIds ); + } } else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM); + } } + /* -----------------------------03.05.00 13:19-------------------------------- ---------------------------------------------------------------------------*/ -Any SwXTextCursor::GetPropertyDefault( +uno::Any SwUnoCursorHelper::GetPropertyDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Any aRet; - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( rPropertyName); - if(pEntry) + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast(0)); + } + + uno::Any aRet; + if (pEntry->nWID < RES_FRMATR_END) + { + SwDoc & rDoc = *rPaM.GetDoc(); + const SfxPoolItem& rDefItem = + rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); return aRet; } /*-- 09.12.98 14:18:54--------------------------------------------------- @@ -2276,7 +2419,10 @@ void SwXTextCursor::setPropertyValue(const OUString& rPropertyName, const uno::A pUnoCrsr->SetSkipOverProtectSections(bSet); } else - SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); + { + SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, + *m_pPropSet, rPropertyName, aValue); + } } else throw uno::RuntimeException(); @@ -2304,7 +2450,10 @@ Any SwXTextCursor::getPropertyValue(const OUString& rPropertyName) aAny.setValue(&bSet, ::getBooleanCppuType()); } else - aAny = GetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName); + { + aAny = SwUnoCursorHelper::GetPropertyValue(*pUnoCrsr, + *m_pPropSet, rPropertyName); + } } else throw uno::RuntimeException(); @@ -2350,7 +2499,8 @@ beans::PropertyState SwXTextCursor::getPropertyState(const OUString& rPropertyNa SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - eRet = GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); + eRet = SwUnoCursorHelper::GetPropertyState( + *pUnoCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -2367,7 +2517,8 @@ uno::Sequence< beans::PropertyState > SwXTextCursor::getPropertyStates( SwUnoCrsr* pUnoCrsr = GetCrsr(); if(!pUnoCrsr) throw RuntimeException(); - return GetPropertyStates(*pUnoCrsr, *m_pPropSet, PropertyNames); + return SwUnoCursorHelper::GetPropertyStates( + *pUnoCrsr, *m_pPropSet, PropertyNames); } /*-- 05.03.99 11:36:12--------------------------------------------------- @@ -2430,7 +2581,7 @@ void SAL_CALL SwXTextCursor::setAllPropertiesToDefault() } } if (aParaWhichIds.Count()) - lcl_SelectParaAndReset( *pUnoCrsr, pUnoCrsr->GetDoc(), &aParaWhichIds ); + lcl_SelectParaAndReset( *pUnoCrsr, *pUnoCrsr->GetDoc(), &aParaWhichIds ); if (aWhichIds.Count() ) pUnoCrsr->GetDoc()->ResetAttrs( *pUnoCrsr, sal_True, &aWhichIds ); } @@ -2479,7 +2630,7 @@ void SAL_CALL SwXTextCursor::setPropertiesToDefault( const Sequence< OUString >& } if ( aParaWhichIds.Count() ) - lcl_SelectParaAndReset ( *pUnoCrsr, pDoc, &aParaWhichIds ); + lcl_SelectParaAndReset ( *pUnoCrsr, *pDoc, &aParaWhichIds ); if (aWhichIds.Count() ) pDoc->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); } @@ -2565,7 +2716,7 @@ throw (lang::IllegalArgumentException, io::IOException, ---------------------------------------------------------------------------*/ uno::Sequence< beans::PropertyValue > -SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) +SwUnoCursorHelper::CreateSortDescriptor(const bool bFromTable) { uno::Sequence< beans::PropertyValue > aRet(5); beans::PropertyValue* pArray = aRet.getArray(); @@ -2575,10 +2726,7 @@ SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - String sSpace(String::CreateFromAscii(" ")); - sal_Unicode uSpace = sSpace.GetChar(0); - - aVal <<= uSpace; + aVal <<= sal_Unicode(' '); pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, beans::PropertyState_DIRECT_VALUE); @@ -2593,15 +2741,17 @@ SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) uno::Sequence< table::TableSortField > aFields(3); table::TableSortField* pFields = aFields.getArray(); - Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); + lang::Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); // get collator algorithm to be used for the locale uno::Sequence< OUString > aSeq( GetAppCollator().listCollatorAlgorithms( aLang ) ); - INT32 nLen = aSeq.getLength(); + const sal_Int32 nLen = aSeq.getLength(); DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); OUString aCollAlg; if (nLen > 0) + { aCollAlg = aSeq.getConstArray()[0]; + } #if OSL_DEBUG_LEVEL > 1 const OUString *pTxt = aSeq.getConstArray(); @@ -2643,13 +2793,14 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextCursor::createSortDescriptor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_False); + + return SwUnoCursorHelper::CreateSortDescriptor(false); } /* -----------------------------15.12.00 14:06-------------------------------- ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::convertSortProperties( +sal_Bool SwUnoCursorHelper::ConvertSortProperties( const uno::Sequence< beans::PropertyValue >& rDescriptor, SwSortOptions& rSortOpt) { @@ -2679,14 +2830,14 @@ sal_Bool SwXTextCursor::convertSortProperties( sal_Bool bOldSortdescriptor(sal_False); sal_Bool bNewSortdescriptor(sal_False); - for (int n = 0; n < rDescriptor.getLength(); ++n) + for (sal_Int32 n = 0; n < rDescriptor.getLength(); ++n) { uno::Any aValue( pProperties[n].Value ); // String sPropName = pProperties[n].Name; const OUString& rPropName = pProperties[n].Name; // old and new sortdescriptor - if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) + if (rPropName.equalsAscii("IsSortInTable")) { if (aValue.getValueType() == ::getBooleanCppuType()) { @@ -2697,7 +2848,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) + else if (rPropName.equalsAscii("Delimiter")) { sal_Unicode uChar = sal_Unicode(); if (aValue >>= uChar) @@ -2710,12 +2861,12 @@ sal_Bool SwXTextCursor::convertSortProperties( } } // old sortdescriptor - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) + else if (rPropName.equalsAscii("SortColumns")) { bOldSortdescriptor = sal_True; - if (aValue.getValueType() == ::getBooleanCppuType()) + sal_Bool bTemp(sal_False); + if (aValue >>= bTemp) { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; } else @@ -2723,12 +2874,12 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) + else if ( rPropName.equalsAscii("IsCaseSensitive")) { bOldSortdescriptor = sal_True; - if (aValue.getValueType() == ::getBooleanCppuType()) + sal_Bool bTemp(sal_False); + if (aValue >>= bTemp) { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); rSortOpt.bIgnoreCase = !bTemp; } else @@ -2736,10 +2887,10 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) + else if (rPropName.equalsAscii("CollatorLocale")) { bOldSortdescriptor = sal_True; - Locale aLocale; + lang::Locale aLocale; if (aValue >>= aLocale) { rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); @@ -2749,8 +2900,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", - 17) && + else if (rPropName.matchAsciiL("CollatorAlgorithm", 17) && rPropName.getLength() == 18 && (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) { @@ -2767,8 +2917,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", - 17) && + else if (rPropName.matchAsciiL("SortRowOrColumnNo", 17) && rPropName.getLength() == 18 && (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) { @@ -2826,7 +2975,7 @@ sal_Bool SwXTextCursor::convertSortProperties( } } // new sortdescriptor - else if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) + else if (rPropName.equalsAscii("IsSortColumns")) { bNewSortdescriptor = sal_True; if (aValue.getValueType() == ::getBooleanCppuType()) @@ -2839,7 +2988,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) + else if (rPropName.equalsAscii("SortFields")) { bNewSortdescriptor = sal_True; uno::Sequence < table::TableSortField > aFields; @@ -2917,7 +3066,7 @@ throw (uno::RuntimeException) if (pUnoCrsr->HasMark()) { - if (!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { throw uno::RuntimeException(); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 1bdd873ff9..e1abe7a715 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -132,14 +131,6 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::drawing; - using ::rtl::OUString; @@ -359,28 +350,29 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew) /*-- 09.12.98 14:19:03--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAttrMode) +void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam, + const SfxItemSet& rSet, + const SetAttrMode nAttrMode, const bool bTableMode) { - sal_uInt16 nFlags = nsSetAttrMode::SETATTR_APICALL | (nAttrMode & nsSetAttrMode::SETATTR_NOFORMATATTR); - if(nAttrMode & CRSR_ATTR_MODE_DONTREPLACE) - nFlags |= nsSetAttrMode::SETATTR_DONTREPLACE; + const SetAttrMode nFlags = nAttrMode | nsSetAttrMode::SETATTR_APICALL; SwDoc* pDoc = rPam.GetDoc(); //StartEndAction UnoActionContext aAction(pDoc); - SwPaM* pCrsr = &rPam; - if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn + if (rPam.GetNext() != &rPam) // Ring of Cursors { pDoc->StartUndo(UNDO_INSATTR, NULL); - SwPaM *_pStartCrsr = &rPam; + SwPaM *pCurrent = &rPam; do { - if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) || - *_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() )) + if (pCurrent->HasMark() && + ( (bTableMode) || + (*pCurrent->GetPoint() != *pCurrent->GetMark()) )) { - pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags); + pDoc->InsertItemSet(*pCurrent, rSet, nFlags); } - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); + pCurrent= static_cast(pCurrent->GetNext()); + } while (pCurrent != &rPam); pDoc->EndUndo(UNDO_INSATTR, NULL); } @@ -388,7 +380,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { // if( !HasSelection() ) // UpdateAttr(); - pDoc->InsertItemSet( *pCrsr, rSet, nFlags ); + pDoc->InsertItemSet( rPam, rSet, nFlags ); } //#outline level,add by zhaojianwei if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE ) @@ -398,7 +390,6 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { rPam.GetDoc()->GetNodes().UpdateOutlineNode( *pTmpNode ); } - } //<-end,zhaojianwei } @@ -408,72 +399,72 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt // --> OD 2006-07-12 #i63870# // split third parameter into new parameters // and to get better control about resulting -void SwXTextCursor::GetCrsrAttr( SwPaM& rPam, - SfxItemSet& rSet, - BOOL bOnlyTxtAttr, - BOOL bGetFromChrFmt ) +void SwUnoCursorHelper::GetCrsrAttr(SwPaM & rPam, + SfxItemSet & rSet, const bool bOnlyTxtAttr, const bool bGetFromChrFmt) { static const sal_uInt16 nMaxLookup = 1000; SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() ); SfxItemSet *pSet = &rSet; - SwPaM *_pStartCrsr = &rPam; + SwPaM *pCurrent = & rPam; do { - ULONG nSttNd = _pStartCrsr->GetMark()->nNode.GetIndex(), - nEndNd = _pStartCrsr->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = _pStartCrsr->GetMark()->nContent.GetIndex(), - nEndCnt = _pStartCrsr->GetPoint()->nContent.GetIndex(); - - if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) - { - sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp; - nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp; - } + SwPosition const & rStart( *pCurrent->Start() ); + SwPosition const & rEnd( *pCurrent->End() ); + const ULONG nSttNd = rStart.nNode.GetIndex(); + const ULONG nEndNd = rEnd .nNode.GetIndex(); - if( nEndNd - nSttNd >= nMaxLookup ) - { - rSet.ClearItem(); - rSet.InvalidateAllItems(); - return;// uno::Any(); - } + if (nEndNd - nSttNd >= nMaxLookup) + { + rSet.ClearItem(); + rSet.InvalidateAllItems(); + return;// uno::Any(); + } - // beim 1.Node traegt der Node die Werte in den GetSet ein (Initial) - // alle weiteren Nodes werden zum GetSet zu gemergt - for( ULONG n = nSttNd; n <= nEndNd; ++n ) + // the first node inserts the values into the get set + // all other nodes merge their values into the get set + for (ULONG n = nSttNd; n <= nEndNd; ++n) + { + SwNode *const pNd = rPam.GetDoc()->GetNodes()[ n ]; + switch (pNd->GetNodeType()) { - SwNode* pNd = rPam.GetDoc()->GetNodes()[ n ]; - switch( pNd->GetNodeType() ) - { case ND_TEXTNODE: - { - xub_StrLen nStt = n == nSttNd ? nSttCnt : 0, - nEnd = n == nEndNd ? nEndCnt - : ((SwTxtNode*)pNd)->GetTxt().Len(); - ((SwTxtNode*)pNd)->GetAttr( *pSet, nStt, nEnd, bOnlyTxtAttr, bGetFromChrFmt ); - } - break; + { + const xub_StrLen nStart = (n == nSttNd) + ? rStart.nContent.GetIndex() : 0; + const xub_StrLen nEnd = (n == nEndNd) + ? rEnd.nContent.GetIndex() + : static_cast(pNd)->GetTxt().Len(); + static_cast(pNd)->GetAttr( + *pSet, nStart, nEnd, bOnlyTxtAttr, bGetFromChrFmt); + } + break; case ND_GRFNODE: case ND_OLENODE: - ((SwCntntNode*)pNd)->GetAttr( *pSet ); - break; + static_cast(pNd)->GetAttr( *pSet ); + break; default: - pNd = 0; - } - - if( pNd ) - { - if( pSet != &rSet ) - rSet.MergeValues( aSet ); - - if( aSet.Count() ) - aSet.ClearItem(); + continue; // skip this node + } - } + if (pSet != &rSet) + { + rSet.MergeValues( aSet ); + } + else + { pSet = &aSet; } - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); + + if (aSet.Count()) + { + aSet.ClearItem(); + } + } + pCurrent= static_cast(pCurrent->GetNext()); + } while ( pCurrent != &rPam ); } + /****************************************************************** * SwXParagraphEnumeration ******************************************************************/ @@ -967,7 +958,7 @@ throw (uno::RuntimeException) SwUnoCursorHelper::DocInsertStringSplitCR( m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints); - SwXTextCursor::SelectPam(aCursor, sal_True); + SwUnoCursorHelper::SelectPam(aCursor, true); aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } SetPositions(aCursor); @@ -1111,7 +1102,7 @@ OUString SAL_CALL SwXTextRange::getString() throw (uno::RuntimeException) SwPaM aPaM(GetDoc()->GetNodes()); if (GetPositions(aPaM) && aPaM.HasMark()) { - SwXTextCursor::getTextFromPam(aPaM, sRet); + SwUnoCursorHelper::GetTextFromPam(aPaM, sRet); } return sRet; } @@ -1488,7 +1479,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - SwXTextCursor::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, + SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, rPropertyName, rValue); } @@ -1505,7 +1496,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1565,7 +1556,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyState(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1581,7 +1572,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1596,7 +1587,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - SwXTextCursor::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, + SwUnoCursorHelper::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1613,7 +1604,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1834,24 +1825,25 @@ sal_Bool SAL_CALL SwXTextRanges::hasElements() throw (uno::RuntimeException) /* -----------------11.12.98 10:07------------------- * * --------------------------------------------------*/ -void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) +void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString) { // Start/EndAction - SwDoc* pDoc = rCrsr.GetDoc(); + SwDoc *const pDoc = rCursor.GetDoc(); UnoActionContext aAction(pDoc); - String aText(rString); - xub_StrLen nTxtLen = aText.Len(); pDoc->StartUndo(UNDO_INSERT, NULL); - if(rCrsr.HasMark()) - pDoc->DeleteAndJoin(rCrsr); - if(nTxtLen) + if (rCursor.HasMark()) + { + pDoc->DeleteAndJoin(rCursor); + } + if (rString.getLength()) { + String aText(rString); const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, rCrsr, aText, false ) ); + *pDoc, rCursor, aText, false ) ); DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" ); (void) bSuccess; - SwXTextCursor::SelectPam(rCrsr, sal_True); - rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE); + SwUnoCursorHelper::SelectPam(rCursor, true); + rCursor.Left(rString.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } pDoc->EndUndo(UNDO_INSERT, NULL); } diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index ee6af202af..57389df869 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -457,7 +456,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, + pPropertyNames[nProp], static_cast< cppu::OWeakObject * >(&m_rThis)); } - SwXTextCursor::SetPropertyValue(aCursor, m_rPropSet, + SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet, pPropertyNames[nProp], pValues[nProp]); } } @@ -659,7 +658,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } else { - SwXTextCursor::SetPropertyValue( + SwUnoCursorHelper::SetPropertyValue( aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]); } } @@ -973,7 +972,7 @@ throw (beans::UnknownPropertyException) case FN_UNO_PARA_STYLE: case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: { - SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl( + SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl( aPam, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; @@ -1132,7 +1131,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) pTemp->SetMark(); *pTemp->GetPoint() = aEnd; //pTemp->Exchange(); - SwXTextCursor::SelectPam(*pTemp, sal_True); + SwUnoCursorHelper::SelectPam(*pTemp, true); if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) { pTemp->MovePara(fnParaCurr, fnParaEnd); @@ -1365,7 +1364,7 @@ OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException) SwPosition aPos( *pTxtNode ); SwCursor aCursor( aPos, 0, false ); SwParaSelection aParaSel( aCursor ); - SwXTextCursor::getTextFromPam(aCursor, aRet); + SwUnoCursorHelper::GetTextFromPam(aCursor, aRet); } else if (m_pImpl->IsDescriptor()) { @@ -1393,12 +1392,12 @@ throw (uno::RuntimeException) if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) { aCursor.MovePara(fnParaCurr, fnParaStart); } - SwXTextCursor::SelectPam(aCursor, sal_True); + SwUnoCursorHelper::SelectPam(aCursor, true); if (pTxtNode->GetTxt().Len()) { aCursor.MovePara(fnParaCurr, fnParaEnd); } - SwXTextCursor::SetString(aCursor, aString); - SwXTextCursor::SelectPam(aCursor, sal_False); + SwUnoCursorHelper::SetString(aCursor, aString); + SwUnoCursorHelper::SelectPam(aCursor, false); } else if (m_pImpl->IsDescriptor()) { diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 8ddb5a7f20..a8e879f56a 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -241,7 +240,7 @@ void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeExcep if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetString(*pUnoCrsr, aString); + SwUnoCursorHelper::SetString(*pUnoCrsr, aString); } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -275,7 +274,7 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName, if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); } /*-- 04.11.03 09:56:58--------------------------------------------------- @@ -426,7 +425,7 @@ void SwXTextPortion::GetPropertyValue( RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, 0L); - SwXTextCursor::GetCrsrAttr(*pUnoCrsr, *pSet); + SwUnoCursorHelper::GetCrsrAttr(*pUnoCrsr, *pSet); } m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); } @@ -503,7 +502,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pPropertyNames[nProp], pValues[nProp]); } } @@ -606,7 +605,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; else { - SwXTextCursor::SetPropertyValue( + SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pProp[i], pValue[i] ); } } @@ -683,7 +682,8 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); - uno::Sequence< beans::PropertyState > aPropertyStates = SwXTextCursor::GetPropertyStates( + uno::Sequence< beans::PropertyState > aPropertyStates = + SwUnoCursorHelper::GetPropertyStates( *pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT ); @@ -832,7 +832,7 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN } else { - eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, + eRet = SwUnoCursorHelper::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); } return eRet; @@ -850,7 +850,7 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates( throw uno::RuntimeException(); uno::Sequence< beans::PropertyState > aRet = - SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); if(GetTextPortionType() == PORTION_RUBY_START) @@ -876,7 +876,8 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); + SwUnoCursorHelper::SetPropertyToDefault( + *pUnoCrsr, *m_pPropSet, rPropertyName); } /*-- 08.03.99 09:41:48--------------------------------------------------- @@ -890,7 +891,7 @@ uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName) if (!pUnoCrsr) throw uno::RuntimeException(); - aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, + aRet = SwUnoCursorHelper::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); return aRet; } diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 931038335d..10c6c1eb07 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include @@ -1150,7 +1150,7 @@ lcl_CreatePortions( // text at nCurrentIndex; i.e. it must be set _once_ per iteration uno::Reference< XTextRange > xRef; - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark + SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); // set mark const sal_Int32 nFirstFrameIndex = lcl_ExportFrames( *PortionStack.top().first, diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index d9d6bafa31..fbe7e6e7eb 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 497f09fa8d..117a96cadc 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -109,10 +109,6 @@ using ::rtl::OUString; //----------------------------------------------------------------------------- -// from unoobj.cxx -extern void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) throw (lang::IllegalArgumentException); -extern void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) throw (lang::IllegalArgumentException); - // from swtable.cxx extern void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm ); @@ -1854,12 +1850,6 @@ uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInf /*-- 11.12.98 12:16:17--------------------------------------------------- -----------------------------------------------------------------------*/ -extern sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry, - SwPaM& rPam, - SfxItemSet& rSet, - const uno::Any& aValue ) throw (lang::IllegalArgumentException); - - void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) throw( beans::UnknownPropertyException, @@ -1903,16 +1893,21 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, } break; case FN_UNO_PARA_STYLE: - lcl_SetTxtFmtColl(aValue, *pUnoCrsr); + SwUnoCursorHelper::SetTxtFmtColl(aValue, *pUnoCrsr); break; default: { SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet ); + SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(), + aItemSet); - if(!lcl_setCrsrPropertyValue( pEntry, pTblCrsr->GetSelRing(), aItemSet, aValue )) - m_pPropSet->setPropertyValue( *pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, pTblCrsr->GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); + } + SwUnoCursorHelper::SetCrsrAttr(pTblCrsr->GetSelRing(), + aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true); } } } @@ -1956,7 +1951,8 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) break; case FN_UNO_PARA_STYLE: { - SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl(*pUnoCrsr, FALSE); + SwFmtColl *const pFmt = + SwUnoCursorHelper::GetCurTxtFmtColl(*pUnoCrsr, FALSE); OUString sRet; if(pFmt) sRet = pFmt->GetName(); @@ -1970,7 +1966,8 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 0L); // erstmal die Attribute des Cursors - SwXTextCursor::GetCrsrAttr(pTblCrsr->GetSelRing(), aSet); + SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(), + aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } } @@ -3162,7 +3159,8 @@ uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_True); + + return SwUnoCursorHelper::CreateSortDescriptor(true); } /*-- 11.12.98 12:42:49--------------------------------------------------- @@ -3174,7 +3172,7 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt && - SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { SwTable* pTable = SwTable::FindTable( pFmt ); SwSelBoxes aBoxes; @@ -4157,11 +4155,16 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, default: { SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( pCrsr->GetSelRing(), aItemSet ); + SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), + aItemSet); - if(!lcl_setCrsrPropertyValue( pEntry, pCrsr->GetSelRing(), aItemSet, aValue )) - m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr(pCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, pCrsr->GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); + } + SwUnoCursorHelper::SetCrsrAttr(pCrsr->GetSelRing(), + aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true); } } } @@ -4214,7 +4217,8 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be break; case FN_UNO_PARA_STYLE: { - SwFmtColl* pTmpFmt = SwXTextCursor::GetCurTxtFmtColl(*pTblCrsr, FALSE); + SwFmtColl *const pTmpFmt = + SwUnoCursorHelper::GetCurTxtFmtColl(*pTblCrsr, FALSE); OUString sRet; if(pFmt) sRet = pTmpFmt->GetName(); @@ -4242,7 +4246,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be 0L); // erstmal die Attribute des Cursors SwUnoTableCrsr* pCrsr = dynamic_cast(pTblCrsr); - SwXTextCursor::GetCrsrAttr(pCrsr->GetSelRing(), aSet); + SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } } @@ -4875,7 +4879,8 @@ double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException ) uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_True); + + return SwUnoCursorHelper::CreateSortDescriptor(true); } /*-- 11.12.98 14:27:39--------------------------------------------------- @@ -4887,7 +4892,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt && - SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { SwUnoTableCrsr* pTableCrsr = dynamic_cast(pTblCrsr); pTableCrsr->MakeBoxSels(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index fb4e04b236..ee02e567ba 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -459,7 +459,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & } SwCursor aCrsr(*aTmp.GetPoint(),0,false); - SwXTextCursor::SelectPam(aCrsr, sal_True); + SwUnoCursorHelper::SelectPam(aCrsr, true); aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); //hier muss der uebergebene PaM umgesetzt werden: if(pRange) @@ -1359,11 +1359,9 @@ uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( { try { - SwXTextCursor::SetPropertyValue( - aPam, - *pParaPropSet, - pValues[nProp].Name, - pValues[nProp].Value); + SwUnoCursorHelper::SetPropertyValue( + aPam, *pParaPropSet, + pValues[nProp].Name, pValues[nProp].Value); } catch( lang::IllegalArgumentException& rIllegal ) { @@ -1448,7 +1446,7 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, false ); - SwXTextCursor::SelectPam(*pCursor, sal_True); + SwUnoCursorHelper::SelectPam(*pCursor, true); pCursor->GetPoint()->nContent = nContentPos; } @@ -1463,12 +1461,10 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( { try { - SwXTextCursor::SetPropertyValue( - *pCursor, - *pCursorPropSet, - pValues[nProp].Name, - pValues[nProp].Value, - nsSetAttrMode::SETATTR_NOFORMATATTR); + SwUnoCursorHelper::SetPropertyValue( + *pCursor, *pCursorPropSet, + pValues[nProp].Name, pValues[nProp].Value, + nsSetAttrMode::SETATTR_NOFORMATATTR); } catch( lang::IllegalArgumentException& rIllegal ) { diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 3645be8506..b9a1bd8fd2 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -79,7 +79,7 @@ #include #include #include -#include +#include #include #include @@ -317,8 +317,9 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg : 0; if(pCursor && pCursor->GetDoc() == GetView()->GetDocShell()->GetDoc()) - pPam = lcl_createPamCopy(*((SwXTextCursor*)pCursor)->GetPaM()); - + { + pPam = lcl_createPamCopy(*pCursor->GetPaM()); + } } else if(xPosN.is() && xIfcTunnel.is() && @@ -1773,7 +1774,7 @@ OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - SwXTextCursor::getTextFromPam(*pShellCrsr, uRet); + SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet); } default:;//prevent warning } @@ -1805,7 +1806,7 @@ void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeEx { SwWrtShell& rSh = m_pView->GetWrtShell(); SwCursor* pShellCrsr = rSh.GetSwCrsr(); - SwXTextCursor::SetString( *pShellCrsr, aString ); + SwUnoCursorHelper::SetString(*pShellCrsr, aString); } default:;//prevent warning } @@ -1834,7 +1835,10 @@ void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const SwPaM* pShellCrsr = rSh.GetCrsr(); SwNode *pNode = pShellCrsr->GetNode(); if (pNode && pNode->IsTxtNode()) - SwXTextCursor::SetPropertyValue(*pShellCrsr, *m_pPropSet, rPropertyName, aValue ); + { + SwUnoCursorHelper::SetPropertyValue( + *pShellCrsr, *m_pPropSet, rPropertyName, aValue ); + } else throw RuntimeException(); } @@ -1853,7 +1857,8 @@ Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyValue( *pShellCrsr, *m_pPropSet, rPropertyName); + aRet = SwUnoCursorHelper::GetPropertyValue( + *pShellCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -1902,7 +1907,8 @@ PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyNam { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - eState = SwXTextCursor::GetPropertyState( *pShellCrsr, *m_pPropSet, rPropertyName); + eState = SwUnoCursorHelper::GetPropertyState( + *pShellCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -1920,7 +1926,8 @@ Sequence< PropertyState > SwXTextViewCursor::getPropertyStates( { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyStates(*pShellCrsr, *m_pPropSet, rPropertyNames); + aRet = SwUnoCursorHelper::GetPropertyStates( + *pShellCrsr, *m_pPropSet, rPropertyNames); } return aRet; } @@ -1935,7 +1942,8 @@ void SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - SwXTextCursor::SetPropertyToDefault( *pShellCrsr, *m_pPropSet, rPropertyName); + SwUnoCursorHelper::SetPropertyToDefault( + *pShellCrsr, *m_pPropSet, rPropertyName); } } /*-- 29.06.00 17:33:43--------------------------------------------------- @@ -1950,7 +1958,8 @@ Any SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyDefault( *pShellCrsr, *m_pPropSet, rPropertyName); + aRet = SwUnoCursorHelper::GetPropertyDefault( + *pShellCrsr, *m_pPropSet, rPropertyName); } return aRet; } -- cgit v1.2.3 From 4c6944934cdebd18960a5e9c9e4c2e0358bbe685 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:55 +0100 Subject: swunolocking1: #i105557#: SwXParagraph: move static methods to namespace sw. --- sw/inc/unoparagraph.hxx | 3 --- sw/inc/unotextrange.hxx | 3 +++ sw/source/core/unocore/unobkm.cxx | 3 +-- sw/source/core/unocore/unoftn.cxx | 2 +- sw/source/core/unocore/unoidx.cxx | 5 +++-- sw/source/core/unocore/unoparagraph.cxx | 10 +++++----- sw/source/core/unocore/unorefmk.cxx | 3 +-- sw/source/core/unocore/unosect.cxx | 5 ++--- sw/source/core/unocore/unotbl.cxx | 3 ++- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index b14aeb7dc3..add936e9c7 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -111,9 +111,6 @@ public: /// for SwXText void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); - static bool getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const ::rtl::OUString& rPropertyName, USHORT nWID = 0); - // MetadatableMixin virtual ::sfx2::Metadatable* GetCoreObject(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index c3c3d362db..164b35b703 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -84,6 +84,9 @@ namespace sw { ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc & rDoc, const SwPosition& rPos); + bool GetDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); + } // namespace sw diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 561f145473..b0cb38b78f 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -461,7 +460,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, vos::OGuard g(Application::GetSolarMutex()); uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) { diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 26333dd73d..9d55ccd0c4 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -526,7 +526,7 @@ uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 5cfaf16fc5..f89fb5a25b 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -1784,8 +1783,10 @@ uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); if (!pEntry) throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) + if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) + { return aRet; + } if(pType && m_pTOXMark) { switch(pEntry->nWID) diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 57389df869..1913c3ba6b 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -512,8 +512,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, + pPropertyNames[nProp], static_cast< cppu::OWeakObject * >(&m_rThis)); } - if (!SwXParagraph::getDefaultTextContentValue( - pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) + if (! ::sw::GetDefaultTextContentValue( + pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) { beans::PropertyState eTemp; const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( @@ -788,7 +788,7 @@ throw (uno::RuntimeException) // get property value // (compare to SwXParagraph::getPropertyValue(s)) uno::Any aValue; - if (!SwXParagraph::getDefaultTextContentValue( + if (! ::sw::GetDefaultTextContentValue( aValue, pProp[i], pEntry->nWID ) ) { SwPosition aPos( rTxtNode ); @@ -848,7 +848,7 @@ throw (uno::RuntimeException) /* -----------------------------12.09.00 11:09-------------------------------- ---------------------------------------------------------------------------*/ -bool SwXParagraph::getDefaultTextContentValue( +bool ::sw::GetDefaultTextContentValue( uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) { if(!nWID) @@ -1158,7 +1158,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); uno::Any aRet; - if (SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { return aRet; } diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index c8b4927b09..a9d58c7e69 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -510,7 +509,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, { // does not seem to need SolarMutex uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { throw beans::UnknownPropertyException(); } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index fbe7e6e7eb..907a2a617c 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -1186,7 +1185,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue( + ::sw::GetDefaultTextContentValue( pRet[nProperty], OUString(), pEntry->nWID); break; case FN_UNO_REDLINE_NODE_START: @@ -1756,7 +1755,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID); + ::sw::GetDefaultTextContentValue(aRet, OUString(), pEntry->nWID); break; default: if(pFmt && pEntry->nWID <= SFX_WHICH_MAX) diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 117a96cadc..ed38bda74a 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3472,7 +3472,8 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID); + ::sw::GetDefaultTextContentValue( + aRet, OUString(), pEntry->nWID); break; case FN_UNO_RANGE_ROW_LABEL: { -- cgit v1.2.3 From ad2df713b5baf3aca1b767071be75f3543efc026 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:55 +0100 Subject: swunolocking1: #i105557#: SwXBodyText: make SwXBodyText::CreateTextCursor() return a pointer, not a UNO reference. --- sw/inc/unotextbodyhf.hxx | 4 +-- sw/source/core/unocore/unotext.cxx | 50 ++++++++++++++++++++------------------ sw/source/ui/uno/unotxdoc.cxx | 15 +++--------- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 8e7a64c186..baab8bc158 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -45,6 +45,7 @@ class SwDoc; class SwFrmFmt; +class SwXTextCursor; typedef ::cppu::WeakAggImplHelper2 @@ -65,8 +66,7 @@ public: SwXBodyText(SwDoc* pDoc); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > - CreateTextCursor(sal_Bool bIgnoreTables = sal_False); + SwXTextCursor * CreateTextCursor(const bool bIgnoreTables = false); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index ee02e567ba..f787f0e0fc 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2301,46 +2301,50 @@ throw (uno::RuntimeException) /* -----------------------------05.01.00 11:07-------------------------------- ---------------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::CreateTextCursor(sal_Bool bIgnoreTables) +SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) { - uno::Reference< text::XTextCursor > xRet; - if(IsValid()) + if(!IsValid()) { - SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); - //the cursor has to skip tables contained in this text - SwPaM aPam(rNode); - aPam.Move( fnMoveBackward, fnGoDoc ); - if(!bIgnoreTables) + return 0; + } + + // the cursor has to skip tables contained in this text + SwPaM aPam(GetDoc()->GetNodes().GetEndOfContent()); + aPam.Move( fnMoveBackward, fnGoDoc ); + if (!bIgnoreTables) + { + SwTableNode * pTblNode = aPam.GetNode()->FindTableNode(); + SwCntntNode * pCont = 0; + while (pTblNode) { - SwTableNode* pTblNode = aPam.GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); - pTblNode = pCont->FindTableNode(); - } - if(pCont) - aPam.GetPoint()->nContent.Assign(pCont, 0); + aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); + pTblNode = pCont->FindTableNode(); + } + if (pCont) + { + aPam.GetPoint()->nContent.Assign(pCont, 0); } - xRet = (text::XWordCursor*)new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); } - return xRet; + return new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); } + /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef = CreateTextCursor(sal_False); - if(!aRef.is()) + + const uno::Reference< text::XTextCursor > xRef( + static_cast(CreateTextCursor(false)) ); + if (!xRef.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - return aRef; + return xRef; } /*-- 10.12.98 11:17:29--------------------------------------------------- diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 4b6e67a8d7..97e419d050 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -728,19 +728,12 @@ Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor( SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr) { getText(); - XText* pText = xBodyText.get(); + XText *const pText = xBodyText.get(); SwXBodyText* pBText = (SwXBodyText*)pText; - xCrsr = pBText->CreateTextCursor(sal_True); + SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true); + xCrsr.set( static_cast(pXTextCursor) ); - Reference xRangeTunnel( xCrsr, UNO_QUERY); - SwXTextCursor* pxUnoCrsr = 0; - if(xRangeTunnel.is()) - { - pxUnoCrsr = reinterpret_cast(xRangeTunnel->getSomething( - SwXTextCursor::getUnoTunnelId())); - } - - SwUnoCrsr* pUnoCrsr = pxUnoCrsr->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCrsr(); pUnoCrsr->SetRemainInSection(sal_False); return pUnoCrsr; } -- cgit v1.2.3 From e083a56e6c7b427c5b922d6489d4854c08d10f28 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:55 +0100 Subject: swunolocking1: #i105557#: SwXTextCursor: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. remove ugly destruction of SwUnoCrsr via Application::PostUserEvent. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextcursor.hxx | 54 +- sw/source/core/unocore/unoframe.cxx | 14 +- sw/source/core/unocore/unoftn.cxx | 13 +- sw/source/core/unocore/unoobj.cxx | 1884 ++++++++++++----------- sw/source/core/unocore/unoredline.cxx | 15 +- sw/source/core/unocore/unorefmk.cxx | 7 +- sw/source/core/unocore/unotbl.cxx | 13 +- sw/source/core/unocore/unotext.cxx | 28 +- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 10 +- sw/source/ui/uno/unotxdoc.cxx | 6 +- 10 files changed, 1023 insertions(+), 1021 deletions(-) diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index fe9b260218..e976af91e1 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -49,20 +49,14 @@ #include #include -#include -#include -#include -#include #include #include -class SfxItemPropertySet; class SwDoc; struct SwPosition; class SwUnoCrsr; -struct SwSortOptions; typedef ::cppu::WeakImplHelper12 @@ -82,65 +76,45 @@ typedef ::cppu::WeakImplHelper12 class SwXTextCursor : public SwXTextCursor_Base - , public SwClient , public OTextCursorHelper { private: - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwSortOptions* pLastSortOptions; - - CursorType eType; - - // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl - // user event has been posted. In this case we have to remove the user - // event in ~SwXTextCursor(). - ULONG mnUserEventId; - bool mbRemoveUserEvent; - // <-- - - DECL_STATIC_LINK(SwXTextCursor, RemoveCursor_Impl, - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>*); - -protected: + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXTextCursor(); public: SwXTextCursor( + SwDoc & rDoc, ::com::sun::star::uno::Reference< - ::com::sun::star::text::XText > xParent, - const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); + ::com::sun::star::text::XText > const& xParent, + const enum CursorType eType, + SwPosition const& rPos, + SwPosition const*const pMark = 0); SwXTextCursor( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XText > xParent, - SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); - - SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} - const SwUnoCrsr* GetCrsr() const {return (SwUnoCrsr*)GetRegisteredIn();} + ::com::sun::star::text::XText > const& xParent, + SwPaM const& rSourceCursor, + const enum CursorType eType = CURSOR_ALL); - // --> FME 2006-03-07 #126177# - void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } - // <-- + SwUnoCrsr * GetCursor(); + const SwUnoCrsr * GetCursor() const; bool IsAtEndOfMeta() const; - void DeleteAndInsert(const String& rText, + void DeleteAndInsert(::rtl::OUString const& rText, const bool bForceExpandHints); + // OTextCursorHelper virtual const SwPaM* GetPaM() const; virtual SwPaM* GetPaM(); virtual const SwDoc* GetDoc() const; virtual SwDoc* GetDoc(); - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - DECLARE_XINTERFACE() static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 841465009f..c1a5a632e5 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2652,10 +2652,11 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void) throw( throw aExcept; } - SwXTextCursor* pXCrsr = new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_FRAME, pFmt->GetDoc()); - aRef = (text::XWordCursor*)pXCrsr; + SwXTextCursor *const pXCursor = new SwXTextCursor( + *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint()); + aRef = static_cast(pXCursor); #if OSL_DEBUG_LEVEL > 1 - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); (void) pUnoCrsr; #endif } @@ -2682,8 +2683,11 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const (void)p2; #endif if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode()) - aRef = (text::XWordCursor*)new SwXTextCursor(this , - *aPam.GetPoint(), CURSOR_FRAME, pFmt->GetDoc(), aPam.GetMark()); + { + aRef = static_cast( + new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME, + *aPam.GetPoint(), aPam.GetMark())); + } } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 9d55ccd0c4..c0eeb66a9e 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -391,9 +391,10 @@ uno::Reference< text::XTextCursor > SwXFootnote::createTextCursor(void) throw( { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor* pXCrsr = new SwXTextCursor(this, aPos, CURSOR_FOOTNOTE, GetDoc()); - aRef = (text::XWordCursor*)pXCrsr; - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); + aRef = static_cast(pXCursor); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); } else @@ -421,8 +422,10 @@ uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); if( pStart != pFtnStartNode ) throw uno::RuntimeException(); - - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_FOOTNOTE, GetDoc(), aPam.GetMark()); + + aRef = static_cast( + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, + *aPam.GetPoint(), aPam.GetMark())); } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index d86f8f59f8..37fa35e035 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -131,17 +131,10 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::drawing; -using std::auto_ptr; using ::rtl::OUString; using ::rtl::OUStringBuffer; + /**************************************************************************** static methods ****************************************************************************/ @@ -780,185 +773,146 @@ SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) return pRet; } -/****************************************************************************** - ****************************************************************************** - ****************************************************************************** - * Taskforce ONE51 - ******************************************************************************/ /****************************************************************** * SwXTextCursor ******************************************************************/ -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ -IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - uno::Reference< XInterface >*, EMPTYARG ) +class SwXTextCursor::Impl + : public SwClient { - ASSERT( pThis != NULL, "no reference?" ); - //ASSERT( pArg != NULL, "no reference?" ); - // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event - // has been executed. It is not necessary to remove the user event in - // ~SwXTextCursor - pThis->DoNotRemoveUserEvent(); - // <-- +public: + + const SfxItemPropertySet & m_rPropSet; + const enum CursorType m_eType; + const uno::Reference< text::XText > m_xParentText; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDisposed; - SwUnoCrsr* pCursor = pThis->GetCrsr(); - if( pCursor != NULL ) + Impl( SwXTextCursor & rThis, + SwDoc & rDoc, + const enum CursorType eType, + uno::Reference xParent, + SwPosition const& rPoint, SwPosition const*const pMark) + : SwClient(rDoc.CreateUnoCrsr(rPoint, sal_False)) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) + , m_eType(eType) + , m_xParentText(xParent) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDisposed(false) { - pCursor->Remove( pThis ); - delete pCursor; + if (pMark) + { + GetCursor()->SetMark(); + *GetCursor()->GetMark() = *pMark; + } } - // --> FME 2006-03-07 #126177# - //delete pArg; - // <-- + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } - return 0; -} + SwUnoCrsr * GetCursor() { + return (m_bIsDisposed) ? 0 : + static_cast(const_cast(GetRegisteredIn())); + } -void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); + SwUnoCrsr & GetCursorOrThrow() { + SwUnoCrsr *const pUnoCursor( GetCursor() ); + if (!pUnoCursor) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXTextCursor: disposed or invalid")), 0); + } + return *pUnoCursor; + } - // if the cursor leaves its designated section, it becomes invalid - if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) - { - // --> FME 2006-03-07 #126177# We don't need to create a reference - // to the SwXTextCursor to prevent its deletion. If the destructor - // of the SwXTextCursor is called before the user event is executed, - // the user event will be removed. This is necessary, because an other - // thread might be currently waiting in ~SwXTextCursor. In this case - // the pRef = new ... stuff did not work! + void Invalidate() { + m_bIsDisposed = true; + m_ListenerContainer.Disposing(); + } - // create reference to this object to prevent deletion before - // the STATIC_LINK is executed. The link will delete the - // reference. - //uno::Reference* pRef = - //new uno::Reference( static_cast( this ) ); + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - mbRemoveUserEvent = true; - // <-- +}; - mnUserEventId = Application::PostUserEvent( - STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); +void SwXTextCursor::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn() || + // if the cursor leaves its designated section, it becomes invalid + (pOld != NULL) && (pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)) + { + Invalidate(); } +} + - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); +SwUnoCrsr const* SwXTextCursor::GetCursor() const +{ + return m_pImpl->GetCursor(); +} +SwUnoCrsr * SwXTextCursor::GetCursor() +{ + return m_pImpl->GetCursor(); } /*-- 09.12.98 14:19:01--------------------------------------------------- -----------------------------------------------------------------------*/ -const SwPaM* SwXTextCursor::GetPaM() const +SwPaM const* SwXTextCursor::GetPaM() const { - return GetCrsr() ? GetCrsr() : 0; + return m_pImpl->GetCursor(); } -SwPaM* SwXTextCursor::GetPaM() +SwPaM * SwXTextCursor::GetPaM() { - return GetCrsr() ? GetCrsr() : 0; + return m_pImpl->GetCursor(); } /*-- 09.12.98 14:19:02--------------------------------------------------- -----------------------------------------------------------------------*/ -const SwDoc* SwXTextCursor::GetDoc()const +SwDoc const* SwXTextCursor::GetDoc() const { - return GetCrsr() ? GetCrsr()->GetDoc() : 0; + return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0; } /* -----------------22.07.99 13:52------------------- --------------------------------------------------*/ -SwDoc* SwXTextCursor::GetDoc() -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} - - -/*-- 09.12.98 14:19:19--------------------------------------------------- - - -----------------------------------------------------------------------*/ -OUString SwXTextCursor::getImplementationName(void) throw( RuntimeException ) +SwDoc * SwXTextCursor::GetDoc() { - return C2U("SwXTextCursor"); + return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0; } -/*-- 09.12.98 14:19:19--------------------------------------------------- - -----------------------------------------------------------------------*/ -BOOL SwXTextCursor::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextCursor") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex") || - sServiceName.EqualsAscii("com.sun.star.text.TextSortable"); -} -/*-- 09.12.98 14:19:19--------------------------------------------------- - -----------------------------------------------------------------------*/ -Sequence< OUString > SwXTextCursor::getSupportedServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(8); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.TextCursor"); - pArray[1] = C2U("com.sun.star.style.CharacterProperties"); - pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); - pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); - pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); - pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); - pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - pArray[7] = C2U("com.sun.star.text.TextSortable"); - return aRet; -} /*-- 09.12.98 14:19:19--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark) : - aLstnrCntnr(( util::XSortable*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(xParent), - pLastSortOptions(0), - eType(eSet), - mbRemoveUserEvent( false ) +SwXTextCursor::SwXTextCursor( + SwDoc & rDoc, + uno::Reference< text::XText > const& xParent, + const enum CursorType eType, + const SwPosition& rPos, + SwPosition const*const pMark) + : m_pImpl( new SwXTextCursor::Impl(*this, rDoc, eType, xParent, + rPos, pMark ) ) { - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(rPos, sal_False); - if(pMark) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pMark; - } - pUnoCrsr->Add(this); } /* -----------------04.03.99 09:02------------------- * * --------------------------------------------------*/ -SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, - SwUnoCrsr* pSourceCrsr, CursorType eSet) : - aLstnrCntnr( (util::XSortable*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(xParent), - pLastSortOptions(0), - eType(eSet), - mbRemoveUserEvent( false ) +SwXTextCursor::SwXTextCursor(uno::Reference< text::XText > const& xParent, + SwPaM const& rSourceCursor, const enum CursorType eType) + : m_pImpl( new SwXTextCursor::Impl(*this, *rSourceCursor.GetDoc(), eType, + xParent, *rSourceCursor.GetPoint(), + rSourceCursor.HasMark() ? rSourceCursor.GetMark() : 0) ) { - SwUnoCrsr* pUnoCrsr = pSourceCrsr->GetDoc()->CreateUnoCrsr(*pSourceCrsr->GetPoint(), sal_False); - if(pSourceCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pSourceCrsr->GetMark(); - } - pUnoCrsr->Add(this); } /*-- 09.12.98 14:19:20--------------------------------------------------- @@ -966,55 +920,43 @@ SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, -----------------------------------------------------------------------*/ SwXTextCursor::~SwXTextCursor() { - vos::OGuard aGuard(Application::GetSolarMutex()); - - // --> FME 2006-03-07 #126177# A user event has been posted in order - // to delete the SwUnoCursor. Remove the user event if the SwXTextCursor - // is destroyed before the user event could be handled. - if ( mbRemoveUserEvent ) - { - mbRemoveUserEvent = false; - Application::RemoveUserEvent( mnUserEventId ); - } - // <-- - - SwUnoCrsr* pUnoCrsr = GetCrsr(); - delete pUnoCrsr; - delete pLastSortOptions; } + /*-- 09.12.98 14:19:18--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::DeleteAndInsert(const String& rText, +void SwXTextCursor::DeleteAndInsert(const ::rtl::OUString& rText, const bool bForceExpandHints) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor(); if(pUnoCrsr) { // Start/EndAction SwDoc* pDoc = pUnoCrsr->GetDoc(); UnoActionContext aAction(pDoc); - xub_StrLen nTxtLen = rText.Len(); + const xub_StrLen nTxtLen = rText.getLength(); pDoc->StartUndo(UNDO_INSERT, NULL); - SwCursor *_pStartCrsr = pUnoCrsr; + SwCursor * pCurrent = pUnoCrsr; do { - if(_pStartCrsr->HasMark()) + if (pCurrent->HasMark()) { - pDoc->DeleteAndJoin(*_pStartCrsr); + pDoc->DeleteAndJoin(*pCurrent); } if(nTxtLen) { const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, *_pStartCrsr, rText, bForceExpandHints ) ); + *pDoc, *pCurrent, rText, bForceExpandHints ) ); DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); (void) bSuccess; SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); - _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); + pCurrent->Left(rText.getLength(), + CRSR_SKIP_CHARS, FALSE, FALSE); } - } while( (_pStartCrsr=(SwCursor*)_pStartCrsr->GetNext()) != pUnoCrsr ); + pCurrent = static_cast(pCurrent->GetNext()); + } while (pCurrent != pUnoCrsr); pDoc->EndUndo(UNDO_INSERT, NULL); } } @@ -1068,10 +1010,11 @@ lcl_ForceIntoMeta(SwPaM & rCursor, bool SwXTextCursor::IsAtEndOfMeta() const { - if (CURSOR_META == eType) + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCrsr const * const pCursor( GetCrsr() ); - SwXMeta const*const pXMeta( dynamic_cast(xParentText.get()) ); + SwUnoCrsr const * const pCursor( m_pImpl->GetCursor() ); + SwXMeta const*const pXMeta( + dynamic_cast(m_pImpl->m_xParentText.get()) ); ASSERT(pXMeta, "no meta?"); if (pCursor && pXMeta) { @@ -1095,6 +1038,45 @@ bool SwXTextCursor::IsAtEndOfMeta() const return false; } +/*-- 09.12.98 14:19:19--------------------------------------------------- + + -----------------------------------------------------------------------*/ +OUString SwXTextCursor::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXTextCursor"); +} + +/*-- 09.12.98 14:19:19--------------------------------------------------- + + -----------------------------------------------------------------------*/ +static char const*const g_ServicesTextCursor[] = +{ + "com.sun.star.text.TextCursor", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", + "com.sun.star.text.TextSortable", +}; +static const size_t g_nServicesTextCursor( + sizeof(g_ServicesTextCursor)/sizeof(g_ServicesTextCursor[0])); + +sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesTextCursor, g_ServicesTextCursor, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXTextCursor::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextCursor, g_ServicesTextCursor); +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -1106,231 +1088,219 @@ const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextCursor::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXTextCursor::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return OTextCursorHelper::getSomething(rId); + const sal_Int64 nRet( ::sw::UnoTunnelImpl(rId, this) ); + return (nRet) ? nRet : OTextCursorHelper::getSomething(rId); } /*-- 09.12.98 14:18:12--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::collapseToStart(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextCursor::collapseToStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) { - if(pUnoCrsr->HasMark()) + if (*rUnoCursor.GetPoint() > *rUnoCursor.GetMark()) { - if(*pUnoCrsr->GetPoint() > *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + rUnoCursor.Exchange(); } - } - else - { - throw uno::RuntimeException(); + rUnoCursor.DeleteMark(); } } /*-- 09.12.98 14:18:14--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::collapseToEnd(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextCursor::collapseToEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) { - if(pUnoCrsr->HasMark()) + if (*rUnoCursor.GetPoint() < *rUnoCursor.GetMark()) { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + rUnoCursor.Exchange(); } - } - else - { - throw uno::RuntimeException(); + rUnoCursor.DeleteMark(); } } /*-- 09.12.98 14:18:41--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isCollapsed(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isCollapsed() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + sal_Bool bRet = sal_True; - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor(); if(pUnoCrsr && pUnoCrsr->GetMark()) { bRet = (*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark()); } return bRet; } + /*-- 09.12.98 14:18:42--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } - } - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } return bRet; } /*-- 09.12.98 14:18:42--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } - } - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } return bRet; } + /*-- 09.12.98 14:18:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoStart(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (CURSOR_BODY == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(eType == CURSOR_BODY) + rUnoCursor.Move( fnMoveBackward, fnGoDoc ); + //check, that the cursor is not in a table + SwTableNode * pTblNode = rUnoCursor.GetNode()->FindTableNode(); + SwCntntNode * pCNode = 0; + while (pTblNode) { - pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); - //check, that the cursor is not in a table - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); - pTblNode = pCont ? pCont->FindTableNode() : 0; - } - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - const SwStartNode* pTmp = pUnoCrsr->GetNode()->StartOfSectionNode(); - if(pTmp->IsSectionNode()) - { - SwSectionNode* pSectionStartNode = (SwSectionNode*)pTmp; - if(pSectionStartNode->GetSection().IsHiddenFlag()) - { - pCont = GetDoc()->GetNodes().GoNextSection( - &pUnoCrsr->GetPoint()->nNode, sal_True, sal_False); - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - } - } + rUnoCursor.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + pTblNode = (pCNode) ? pCNode->FindTableNode() : 0; } - else if(eType == CURSOR_FRAME || - eType == CURSOR_TBLTEXT || - eType == CURSOR_HEADER || - eType == CURSOR_FOOTER || - eType == CURSOR_FOOTNOTE|| - eType == CURSOR_REDLINE) + if (pCNode) { - pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart); + rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); } - else if (CURSOR_META == eType) + SwStartNode const*const pTmp = + rUnoCursor.GetNode()->StartOfSectionNode(); + if (pTmp->IsSectionNode()) { - lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START); + SwSectionNode const*const pSectionStartNode = + static_cast(pTmp); + if (pSectionStartNode->GetSection().IsHiddenFlag()) + { + pCNode = GetDoc()->GetNodes().GoNextSection( + &rUnoCursor.GetPoint()->nNode, sal_True, sal_False); + if (pCNode) + { + rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); + } + } } } - else + else if ( (CURSOR_FRAME == m_pImpl->m_eType) + || (CURSOR_TBLTEXT == m_pImpl->m_eType) + || (CURSOR_HEADER == m_pImpl->m_eType) + || (CURSOR_FOOTER == m_pImpl->m_eType) + || (CURSOR_FOOTNOTE== m_pImpl->m_eType) + || (CURSOR_REDLINE == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + rUnoCursor.MoveSection(fnSectionCurr, fnSectionStart); + } + else if (CURSOR_META == m_pImpl->m_eType) + { + lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_START); } } /*-- 09.12.98 14:18:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoEnd(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (CURSOR_BODY == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(eType == CURSOR_BODY) - { - pUnoCrsr->Move( fnMoveForward, fnGoDoc ); - } - else if(eType == CURSOR_FRAME || - eType == CURSOR_TBLTEXT || - eType == CURSOR_HEADER || - eType == CURSOR_FOOTER || - eType == CURSOR_FOOTNOTE|| - eType == CURSOR_REDLINE) - { - pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd); - } - else if (CURSOR_META == eType) - { - lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END); - } + rUnoCursor.Move( fnMoveForward, fnGoDoc ); } - else + else if ( (CURSOR_FRAME == m_pImpl->m_eType) + || (CURSOR_TBLTEXT == m_pImpl->m_eType) + || (CURSOR_HEADER == m_pImpl->m_eType) + || (CURSOR_FOOTER == m_pImpl->m_eType) + || (CURSOR_FOOTNOTE== m_pImpl->m_eType) + || (CURSOR_REDLINE == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + rUnoCursor.MoveSection( fnSectionCurr, fnSectionEnd); + } + else if (CURSOR_META == m_pImpl->m_eType) + { + lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_END); } } -void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_Bool bExpand ) - throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoRange( + const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pOwnCursor = GetCrsr(); - if(!pOwnCursor || !xRange.is()) + + if (!xRange.is()) { throw uno::RuntimeException(); } + SwUnoCrsr & rOwnCursor( m_pImpl->GetCursorOrThrow() ); + uno::Reference xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); } if (!pRange && !pCursor) @@ -1339,7 +1309,7 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B } SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eType) + switch (m_pImpl->m_eType) { case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; @@ -1351,8 +1321,8 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B default: ; } - const SwStartNode* pOwnStartNode = pOwnCursor->GetNode()-> - FindSttNodeByType(eSearchNodeType); + const SwStartNode* pOwnStartNode = + rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType); SwPaM aPam(GetDoc()->GetNodes()); const SwPaM * pPam(0); @@ -1389,11 +1359,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B throw uno::RuntimeException(); } - if (CURSOR_META == eType) + if (CURSOR_META == m_pImpl->m_eType) { SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint()); - const bool bNotForced( - lcl_ForceIntoMeta(CopyPam, xParentText, META_CHECK_BOTH) ); + const bool bNotForced( lcl_ForceIntoMeta( + CopyPam, m_pImpl->m_xParentText, META_CHECK_BOTH) ); if (!bNotForced) { throw uno::RuntimeException( @@ -1408,40 +1378,30 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B { // der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen // Range eingeschlossen wurde - SwPosition aOwnLeft(*pOwnCursor->GetPoint()); - SwPosition aOwnRight(pOwnCursor->HasMark() ? *pOwnCursor->GetMark() : aOwnLeft); - if(aOwnRight < aOwnLeft) - { - SwPosition aTmp = aOwnLeft; - aOwnLeft = aOwnRight; - aOwnRight = aTmp; - } - SwPosition const* pParamLeft = pPam->Start(); - SwPosition const* pParamRight = pPam->End(); + const SwPosition aOwnLeft(*rOwnCursor.Start()); + const SwPosition aOwnRight(*rOwnCursor.End()); + SwPosition const& rParamLeft = *pPam->Start(); + SwPosition const& rParamRight = *pPam->End(); // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche? - if(aOwnRight > *pParamRight) - *pOwnCursor->GetPoint() = aOwnRight; - else - *pOwnCursor->GetPoint() = *pParamRight; - pOwnCursor->SetMark(); - if(aOwnLeft < *pParamLeft) - *pOwnCursor->GetMark() = aOwnLeft; - else - *pOwnCursor->GetMark() = *pParamLeft; + *rOwnCursor.GetPoint() = (aOwnRight > rParamRight) + ? aOwnRight : *rOwnCursor.GetPoint() = rParamRight; + rOwnCursor.SetMark(); + *rOwnCursor.GetMark() = (aOwnLeft < rParamLeft) + ? aOwnLeft : *rOwnCursor.GetMark() = rParamLeft; } else { // cursor should be the given range - *pOwnCursor->GetPoint() = *pPam->GetPoint(); + *rOwnCursor.GetPoint() = *pPam->GetPoint(); if (pPam->HasMark()) { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = *pPam->GetMark(); + rOwnCursor.SetMark(); + *rOwnCursor.GetMark() = *pPam->GetMark(); } else { - pOwnCursor->DeleteMark(); + rOwnCursor.DeleteMark(); } } } @@ -1449,169 +1409,157 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfWord(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isStartOfWord() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - bRet = pUnoCrsr->IsStartWordWT( i18n::WordType::DICTIONARY_WORD ); - } - else - { - throw uno::RuntimeException(); - } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = + rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD ); return bRet; } /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfWord(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isEndOfWord() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - bRet = pUnoCrsr->IsEndWordWT( i18n::WordType::DICTIONARY_WORD ); - } - else - { - throw uno::RuntimeException(); - } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = + rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD ); return bRet; } + /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt. - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt. sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - // remember old position to check if cursor has moved - // since the called functions are sometimes a bit unreliable - // in specific cases... - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode *pOldNode = &pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - //Absatzende? - if(pUnoCrsr->GetCntntNode() && - pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) - { - pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } - else - { - sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); - //if there is no next word within the current paragraph try to go to the start of the next paragraph - if(!bTmp) - pUnoCrsr->MovePara(fnParaNext, fnParaStart); - } + // remember old position to check if cursor has moved + // since the called functions are sometimes a bit unreliable + // in specific cases... + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode *const pOldNode = &pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - // return true if cursor has moved - bRet = &pPoint->nNode.GetNode() != pOldNode || - pPoint->nContent.GetIndex() != nOldIndex; - if (bRet && (CURSOR_META == eType)) + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // end of paragraph + if (rUnoCursor.GetCntntNode() && + (pPoint->nContent == rUnoCursor.GetCntntNode()->Len())) + { + rUnoCursor.Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } + else + { + const bool bTmp = + rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); + // if there is no next word within the current paragraph + // try to go to the start of the next paragraph + if (!bTmp) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + rUnoCursor.MovePara(fnParaNext, fnParaStart); } } - else + + // return true if cursor has moved + bRet = (&pPoint->nNode.GetNode() != pOldNode) || + (pPoint->nContent.GetIndex() != nOldIndex); + if (bRet && (CURSOR_META == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:45--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // hier machen Leerzeichen am Absatzanfang Probleme - SwUnoCrsr* pUnoCrsr = GetCrsr(); - sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode *pOldNode = &pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - //Absatzanfang ? - if(pPoint->nContent == 0) - { - pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } - else - { - pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); - if(pPoint->nContent == 0) - pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } + // hier machen Leerzeichen am Absatzanfang Probleme + sal_Bool bRet = sal_False; + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode *const pOldNode = &pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - // return true if cursor has moved - bRet = &pPoint->nNode.GetNode() != pOldNode || - pPoint->nContent.GetIndex() != nOldIndex; - if (bRet && (CURSOR_META == eType)) + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // start of paragraph? + if (pPoint->nContent == 0) + { + rUnoCursor.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } + else + { + rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); + if (pPoint->nContent == 0) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + rUnoCursor.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); } } - else + + // return true if cursor has moved + bRet = (&pPoint->nNode.GetNode() != pOldNode) || + (pPoint->nContent.GetIndex() != nOldIndex); + if (bRet && (CURSOR_META == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:45--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode &rOldNode = pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode & rOldNode = pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(!pUnoCrsr->IsEndWordWT( nWordType )) - pUnoCrsr->GoEndWordWT( nWordType ); + const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (!rUnoCursor.IsEndWordWT( nWordType )) + { + rUnoCursor.GoEndWordWT( nWordType ); + } - // restore old cursor if we are not at the end of a word by now - // otherwise use current one - bRet = pUnoCrsr->IsEndWordWT( nWordType ); - if (!bRet) - { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; - } - else if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); - } + // restore old cursor if we are not at the end of a word by now + // otherwise use current one + bRet = rUnoCursor.IsEndWordWT( nWordType ); + if (!bRet) + { + pPoint->nNode = rOldNode; + pPoint->nContent = nOldIndex; } - else + else if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; @@ -1619,270 +1567,266 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept /*-- 09.12.98 14:18:46--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode &rOldNode = pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode & rOldNode = pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(!pUnoCrsr->IsStartWordWT( nWordType )) - pUnoCrsr->GoStartWordWT( nWordType ); + const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (!rUnoCursor.IsStartWordWT( nWordType )) + { + rUnoCursor.GoStartWordWT( nWordType ); + } - // restore old cursor if we are not at the start of a word by now - // otherwise use current one - bRet = pUnoCrsr->IsStartWordWT( nWordType ); - if (!bRet) - { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; - } - else if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); - } + // restore old cursor if we are not at the start of a word by now + // otherwise use current one + bRet = rUnoCursor.IsStartWordWT( nWordType ); + if (!bRet) + { + pPoint->nNode = rOldNode; + pPoint->nContent = nOldIndex; } - else + else if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:46--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfSentence(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isStartOfSentence() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // start of paragraph? + sal_Bool bRet = rUnoCursor.GetPoint()->nContent == 0; + // with mark ->no sentence start + // (check if cursor is no selection, i.e. it does not have + // a mark or else point and mark are identical) + if (!bRet && (!rUnoCursor.HasMark() || + *rUnoCursor.GetPoint() == *rUnoCursor.GetMark())) { - // start of paragraph? - bRet = pUnoCrsr->GetPoint()->nContent == 0; - // with mark ->no sentence start - // (check if cursor is no selection, i.e. it does not have - // a mark or else point and mark are identical) - if(!bRet && (!pUnoCrsr->HasMark() || - *pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark())) - { - SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false); - SwPosition aOrigPos = *aCrsr.GetPoint(); - aCrsr.GoSentence(SwCursor::START_SENT ); - bRet = aOrigPos == *aCrsr.GetPoint(); - } + SwCursor aCrsr(*rUnoCursor.GetPoint(),0,false); + SwPosition aOrigPos = *aCrsr.GetPoint(); + aCrsr.GoSentence(SwCursor::START_SENT ); + bRet = aOrigPos == *aCrsr.GetPoint(); } - else - throw uno::RuntimeException(); return bRet; } /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfSentence(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isEndOfSentence() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // end of paragraph? + sal_Bool bRet = rUnoCursor.GetCntntNode() && + (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetCntntNode()->Len()); + // with mark->no sentence end + // (check if cursor is no selection, i.e. it does not have + // a mark or else point and mark are identical) + if (!bRet && (!rUnoCursor.HasMark() || + *rUnoCursor.GetPoint() == *rUnoCursor.GetMark())) { - //end of paragraph? - bRet = pUnoCrsr->GetCntntNode() && - pUnoCrsr->GetPoint()->nContent == pUnoCrsr->GetCntntNode()->Len(); - // with mark->no sentence end - // (check if cursor is no selection, i.e. it does not have - // a mark or else point and mark are identical) - if(!bRet && (!pUnoCrsr->HasMark() || - *pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark())) - { - SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false); - SwPosition aOrigPos = *aCrsr.GetPoint(); - aCrsr.GoSentence(SwCursor::END_SENT ); - bRet = aOrigPos == *aCrsr.GetPoint(); - } + SwCursor aCrsr(*rUnoCursor.GetPoint(), 0, false); + SwPosition aOrigPos = *aCrsr.GetPoint(); + aCrsr.GoSentence(SwCursor::END_SENT); + bRet = aOrigPos == *aCrsr.GetPoint(); } - else - throw uno::RuntimeException(); return bRet; } + /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const bool bWasEOS = isEndOfSentence(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT); + if (!bRet) { - BOOL bWasEOS = isEndOfSentence(); - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->GoSentence(SwCursor::NEXT_SENT); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); + bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart); + } - // if at the end of the sentence (i.e. at the space after the '.') - // advance to next word in order for GoSentence to work properly - // next time and have isStartOfSentence return true after this call - if (!pUnoCrsr->IsStartWord()) - { - BOOL bNextWord = pUnoCrsr->GoNextWord(); - if (bWasEOS && !bNextWord) - bRet = sal_False; - } - if (CURSOR_META == eType) + // if at the end of the sentence (i.e. at the space after the '.') + // advance to next word in order for GoSentence to work properly + // next time and have isStartOfSentence return true after this call + if (!rUnoCursor.IsStartWord()) + { + const bool bNextWord = rUnoCursor.GoNextWord(); + if (bWasEOS && !bNextWord) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; + bRet = sal_False; } } - else - throw uno::RuntimeException(); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; + } return bRet; } /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT); + if (!bRet) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->GoSentence(SwCursor::PREV_SENT); - if(!bRet) - { - if(0 != (bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart))) - { - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - //at the end of a paragraph move to the sentence end again - // - pUnoCrsr->GoSentence(SwCursor::PREV_SENT); - } - } - if (CURSOR_META == eType) + bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart); + if (bRet) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; + rUnoCursor.MovePara(fnParaCurr, fnParaEnd); + // at the end of a paragraph move to the sentence end again + rUnoCursor.GoSentence(SwCursor::PREV_SENT); } } - else - throw uno::RuntimeException(); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; + } return bRet; } + /* -----------------15.10.99 08:24------------------- --------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - // if we're at the para start then we wont move - // but bRet is also true if GoSentence failed but - // the start of the sentence is reached - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr) - || pUnoCrsr->GoSentence(SwCursor::START_SENT) || - SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // if we're at the para start then we wont move + // but bRet is also true if GoSentence failed but + // the start of the sentence is reached + bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor) + || rUnoCursor.GoSentence(SwCursor::START_SENT) + || SwUnoCursorHelper::IsStartOfPara(rUnoCursor); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } - else - throw uno::RuntimeException(); return bRet; } /* -----------------15.10.99 08:24------------------- --------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - // bRet is true if GoSentence() succeeded or if the - // MovePara() succeeded while the end of the para is - // not reached already - sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - bRet = !bAlreadyParaEnd && - (pUnoCrsr->GoSentence(SwCursor::END_SENT) || - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd)); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // bRet is true if GoSentence() succeeded or if the + // MovePara() succeeded while the end of the para is + // not reached already + sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); + bRet = !bAlreadyParaEnd + && (rUnoCursor.GoSentence(SwCursor::END_SENT) + || rUnoCursor.MovePara(fnParaCurr, fnParaEnd)); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } - else - throw uno::RuntimeException(); return bRet; } /*-- 09.12.98 14:18:48--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfParagraph(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isStartOfParagraph() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor); return bRet; } /*-- 09.12.98 14:18:48--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfParagraph(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isEndOfParagraph() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); return bRet; } + /*-- 09.12.98 14:18:49--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr ) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaStart); + return sal_False; + } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor); + if (!bRet) + { + bRet = rUnoCursor.MovePara(fnParaCurr, fnParaStart); } - else - throw uno::RuntimeException(); // since MovePara(fnParaCurr, fnParaStart) only returns false // if we were already at the start of the paragraph this function @@ -1893,22 +1837,23 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim /*-- 09.12.98 14:18:49--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); + return sal_False; + } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); + if (!bRet) + { + bRet = rUnoCursor.MovePara(fnParaCurr, fnParaEnd); } - else - throw uno::RuntimeException(); // since MovePara(fnParaCurr, fnParaEnd) only returns false // if we were already at the end of the paragraph this function @@ -1916,158 +1861,144 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE DBG_ASSERT( bRet, "gotoEndOfParagraph failed" ); return bRet; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); + return sal_False; } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + const sal_Bool bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart); return bRet; } /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart); + return sal_False; } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + const sal_Bool bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart); return bRet; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XText > SwXTextCursor::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXTextCursor::getText() throw (uno::RuntimeException) { - return xParentText; + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->m_xParentText; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextCursor::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< text::XTextRange > xRet; + SwPaM aPam(*rUnoCursor.Start()); + const uno::Reference< text::XText > xParent = getText(); + if (CURSOR_META == m_pImpl->m_eType) { - SwPaM aPam(*pUnoCrsr->Start()); - uno::Reference< XText > xParent = getText(); - if (CURSOR_META == eType) - { - // return cursor to prevent modifying SwXTextRange for META - SwXTextCursor * const pCursor( - new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), - CURSOR_META, pUnoCrsr->GetDoc()) ); - pCursor->gotoStart(sal_False); - xRet = static_cast(pCursor); - } - else - { - xRet = new SwXTextRange(aPam, xParent); - } + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pXCursor( + new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META, + *rUnoCursor.GetPoint()) ); + pXCursor->gotoStart(sal_False); + xRet = static_cast(pXCursor); } else - throw uno::RuntimeException(); + { + xRet = new SwXTextRange(aPam, xParent); + } return xRet; } /*-- 09.12.98 14:18:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextCursor::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< text::XTextRange > xRet; + SwPaM aPam(*rUnoCursor.End()); + const uno::Reference< text::XText > xParent = getText(); + if (CURSOR_META == m_pImpl->m_eType) { - SwPaM aPam(*pUnoCrsr->End()); - uno::Reference< XText > xParent = getText(); - if (CURSOR_META == eType) - { - // return cursor to prevent modifying SwXTextRange for META - SwXTextCursor * const pCursor( - new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), - CURSOR_META, pUnoCrsr->GetDoc()) ); - pCursor->gotoEnd(sal_False); - xRet = static_cast(pCursor); - } - else - { - xRet = new SwXTextRange(aPam, xParent); - } + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pXCursor( + new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META, + *rUnoCursor.GetPoint()) ); + pXCursor->gotoEnd(sal_False); + xRet = static_cast(pXCursor); } else - throw uno::RuntimeException(); + { + xRet = new SwXTextRange(aPam, xParent); + } return xRet; } + /*-- 09.12.98 14:18:51--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextCursor::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextCursor::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + OUString aTxt; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) - { -/* if( pUnoCrsr->GetPoint()->nNode.GetIndex() == - pUnoCrsr->GetMark()->nNode.GetIndex() ) - { - SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); - if( pTxtNd ) - { - sal_uInt16 nStt = pUnoCrsr->Start()->nContent.GetIndex(); - aTxt = pTxtNd->GetExpandTxt( nStt, - pUnoCrsr->End()->nContent.GetIndex() - nStt ); - } - } - else -*/ { - //Text ueber mehrere Absaetze - SwUnoCursorHelper::GetTextFromPam(*pUnoCrsr, aTxt); - } - } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aTxt); return aTxt; } /*-- 09.12.98 14:18:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::setString(const OUString& aString) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) - throw uno::RuntimeException(); - const bool bForceExpandHints( (CURSOR_META != eType) + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + (void) rUnoCursor; // just to check if valid + + const bool bForceExpandHints( (CURSOR_META != m_pImpl->m_eType) ? false - : dynamic_cast(xParentText.get())->CheckForOwnMemberMeta( - *GetPaM(), true) ); + : dynamic_cast(m_pImpl->m_xParentText.get()) + ->CheckForOwnMemberMeta(*GetPaM(), true) ); DeleteAndInsert(aString, bForceExpandHints); } + /* -----------------------------03.05.00 12:56-------------------------------- ---------------------------------------------------------------------------*/ @@ -2374,11 +2305,15 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, } return aRet; } + /*-- 09.12.98 14:18:54--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextCursor::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRef; if(!xRef.is()) { @@ -2388,7 +2323,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(voi { SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT), FN_SKIP_PROTECTED_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0}, {0,0,0,0,0,0} }; - uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + const uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); // PropertySetInfo verlaengern! const uno::Sequence aPropSeq = xInfo->getProperties(); xRef = new SfxExtItemPropertySetInfo( @@ -2397,283 +2333,361 @@ uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(voi } return xRef; } + /*-- 09.12.98 14:18:54--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextCursor::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) { - if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) + sal_Bool bSet(sal_False); + if (!(rValue >>= bSet)) { - sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - pUnoCrsr->SetSkipOverHiddenSections(bSet); - } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - pUnoCrsr->SetSkipOverProtectSections(bSet); + throw lang::IllegalArgumentException(); } - else + rUnoCursor.SetSkipOverHiddenSections(bSet); + } + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + sal_Bool bSet(sal_False); + if (!(rValue >>= bSet)) { - SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, - *m_pPropSet, rPropertyName, aValue); + throw lang::IllegalArgumentException(); } + rUnoCursor.SetSkipOverProtectSections(bSet); } else - throw uno::RuntimeException(); - + { + SwUnoCursorHelper::SetPropertyValue(rUnoCursor, + m_pImpl->m_rPropSet, rPropertyName, rValue); + } } + /*-- 09.12.98 14:18:55--------------------------------------------------- -----------------------------------------------------------------------*/ -Any SwXTextCursor::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextCursor::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + uno::Any aAny; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) { - if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) - { - BOOL bSet = pUnoCrsr->IsSkipOverHiddenSections(); - aAny.setValue(&bSet, ::getBooleanCppuType()); - } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - BOOL bSet = pUnoCrsr->IsSkipOverProtectSections(); - aAny.setValue(&bSet, ::getBooleanCppuType()); - } - else - { - aAny = SwUnoCursorHelper::GetPropertyValue(*pUnoCrsr, - *m_pPropSet, rPropertyName); - } + const sal_Bool bSet = rUnoCursor.IsSkipOverHiddenSections(); + aAny <<= bSet; + } + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + const sal_Bool bSet = rUnoCursor.IsSkipOverProtectSections(); + aAny <<= bSet; } else - throw uno::RuntimeException(); + { + aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor, + m_pImpl->m_rPropSet, rPropertyName); + } return aAny; - } + /*-- 09.12.98 14:18:55--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::addPropertyChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::removePropertyChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::addVetoableChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:58--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::removeVetoableChangeListener(): not implemented"); } + /*-- 05.03.99 11:36:11--------------------------------------------------- -----------------------------------------------------------------------*/ -beans::PropertyState SwXTextCursor::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +beans::PropertyState SAL_CALL +SwXTextCursor::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - eRet = SwUnoCursorHelper::GetPropertyState( - *pUnoCrsr, *m_pPropSet, rPropertyName); - } - else - throw RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState( + rUnoCursor, m_pImpl->m_rPropSet, rPropertyName); return eRet; } /*-- 05.03.99 11:36:11--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyState > SwXTextCursor::getPropertyStates( - const uno::Sequence< OUString >& PropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextCursor::getPropertyStates( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) - throw RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + return SwUnoCursorHelper::GetPropertyStates( - *pUnoCrsr, *m_pPropSet, PropertyNames); + rUnoCursor, m_pImpl->m_rPropSet, rPropertyNames); } + /*-- 05.03.99 11:36:12--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - Sequence < OUString > aSequence ( &rPropertyName, 1 ); + // forward: need no solar mutex here + uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); setPropertiesToDefault ( aSequence ); } /*-- 05.03.99 11:36:12--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextCursor::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextCursor::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - const Sequence < OUString > aSequence ( &rPropertyName, 1 ); + // forward: need no solar mutex here + const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); return getPropertyDefaults ( aSequence ).getConstArray()[0]; } -void SAL_CALL SwXTextCursor::setAllPropertiesToDefault() - throw (RuntimeException) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); +// para specific attribut ranges +static USHORT g_ParaResetableSetRange[] = { + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_PARATR_BEGIN, RES_PARATR_END-1, + // --> OD 2008-02-25 #refactorlists# + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, + // <-- + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, + 0 +}; + +// selection specific attribut ranges +static USHORT g_ResetableSetRange[] = { + RES_CHRATR_BEGIN, RES_CHRATR_END-1, + RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, + RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + 0 +}; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (pUnoCrsr) +static void +lcl_EnumerateIds(USHORT const* pIdRange, SvUShortsSort & rWhichIds) +{ + while (*pIdRange) { - // para specific attribut ranges - USHORT aParaResetableSetRange[] = { - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - RES_PARATR_BEGIN, RES_PARATR_END-1, - // --> OD 2008-02-25 #refactorlists# - RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, - // <-- - RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, - 0 - }; - // selection specific attribut ranges - USHORT aResetableSetRange[] = { - RES_CHRATR_BEGIN, RES_CHRATR_END-1, - RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, - RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, - RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, - RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - 0 - }; - SvUShortsSort aParaWhichIds; - SvUShortsSort aWhichIds; - for (USHORT k = 0; k < 2; ++k) + const USHORT nStart = sal::static_int_cast(*pIdRange++); + const USHORT nEnd = sal::static_int_cast(*pIdRange++); + for (USHORT nId = nStart + 1; nId <= nEnd; ++nId) { - SvUShortsSort &rWhichIds = k == 0? aParaWhichIds : aWhichIds; - USHORT *pResetableSetRange = k == 0? aParaResetableSetRange : aResetableSetRange; - while (*pResetableSetRange) - { - USHORT nStart = sal::static_int_cast< USHORT >(*pResetableSetRange++); - USHORT nEnd = sal::static_int_cast< USHORT >(*pResetableSetRange++); - for (USHORT nId = nStart + 1; nId <= nEnd; ++nId) - rWhichIds.Insert( nId ); - } + rWhichIds.Insert( nId ); } - if (aParaWhichIds.Count()) - lcl_SelectParaAndReset( *pUnoCrsr, *pUnoCrsr->GetDoc(), &aParaWhichIds ); - if (aWhichIds.Count() ) - pUnoCrsr->GetDoc()->ResetAttrs( *pUnoCrsr, sal_True, &aWhichIds ); } - else - throw uno::RuntimeException(); } -void SAL_CALL SwXTextCursor::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) - throw (UnknownPropertyException, RuntimeException) +void SAL_CALL +SwXTextCursor::setAllPropertiesToDefault() +throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SvUShortsSort aParaWhichIds; + SvUShortsSort aWhichIds; + lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds); + lcl_EnumerateIds(g_ResetableSetRange, aWhichIds); + if (aParaWhichIds.Count()) + { + lcl_SelectParaAndReset(rUnoCursor, *rUnoCursor.GetDoc(), + &aParaWhichIds); + } + if (aWhichIds.Count()) + { + rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, sal_True, &aWhichIds); + } +} + +void SAL_CALL +SwXTextCursor::setPropertiesToDefault( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nCount = aPropertyNames.getLength(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Int32 nCount = rPropertyNames.getLength(); if ( nCount ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwDoc & rDoc = *rUnoCursor.GetDoc(); + const OUString * pNames = rPropertyNames.getConstArray(); + SvUShortsSort aWhichIds; + SvUShortsSort aParaWhichIds; + for (sal_Int32 i = 0; i < nCount; i++) { - SwDoc* pDoc = pUnoCrsr->GetDoc(); - const OUString * pNames = aPropertyNames.getConstArray(); - SvUShortsSort aWhichIds, aParaWhichIds; - for ( sal_Int32 i = 0; i < nCount; i++ ) + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[i] ); - if(!pEntry) + if (pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - continue; - } - else - throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); + continue; } - if( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertiesToDefault: property is read-only: ")) + + pNames[i], + static_cast(this)); + } - if( pEntry->nWID < RES_FRMATR_END) + if (pEntry->nWID < RES_FRMATR_END) + { + if (pEntry->nWID < RES_PARATR_BEGIN) { - if(pEntry->nWID < RES_PARATR_BEGIN) - aWhichIds.Insert(pEntry->nWID); - else - aParaWhichIds.Insert (pEntry->nWID); + aWhichIds.Insert(pEntry->nWID); } - else if ( pEntry->nWID == FN_UNO_NUM_START_VALUE ) - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, *pUnoCrsr); + else + { + aParaWhichIds.Insert(pEntry->nWID); + } + } + else if (pEntry->nWID == FN_UNO_NUM_START_VALUE) + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rUnoCursor); } + } - if ( aParaWhichIds.Count() ) - lcl_SelectParaAndReset ( *pUnoCrsr, *pDoc, &aParaWhichIds ); - if (aWhichIds.Count() ) - pDoc->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); + if (aParaWhichIds.Count()) + { + lcl_SelectParaAndReset(rUnoCursor, rDoc, &aParaWhichIds); + } + if (aWhichIds.Count()) + { + rDoc.ResetAttrs(rUnoCursor, sal_True, &aWhichIds); } - else - throw uno::RuntimeException(); } } -Sequence< Any > SAL_CALL SwXTextCursor::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) - throw (UnknownPropertyException, WrappedTargetException, RuntimeException) + +uno::Sequence< uno::Any > SAL_CALL +SwXTextCursor::getPropertyDefaults( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nCount = aPropertyNames.getLength(); - Sequence < Any > aRet ( nCount ); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Int32 nCount = rPropertyNames.getLength(); + uno::Sequence< uno::Any > aRet(nCount); if ( nCount ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (pUnoCrsr) + SwDoc & rDoc = *rUnoCursor.GetDoc(); + const OUString *pNames = rPropertyNames.getConstArray(); + uno::Any *pAny = aRet.getArray(); + for (sal_Int32 i = 0; i < nCount; i++) { - SwDoc* pDoc = pUnoCrsr->GetDoc(); - const OUString *pNames = aPropertyNames.getConstArray(); - Any *pAny = aRet.getArray(); - for ( sal_Int32 i = 0; i < nCount; i++) + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[i] ); - if(!pEntry) + if (pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - continue; - } - else - throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); - } - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(pAny[i], pEntry->nMemberId); + continue; } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast(0)); + } + if (pEntry->nWID < RES_FRMATR_END) + { + const SfxPoolItem& rDefItem = + rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(pAny[i], pEntry->nMemberId); } } - else - throw UnknownPropertyException(); } return aRet; } @@ -2681,17 +2695,17 @@ Sequence< Any > SAL_CALL SwXTextCursor::getPropertyDefaults( const Sequence< OUS /*-- 10.03.2008 09:58:47--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::makeRedline( +void SAL_CALL +SwXTextCursor::makeRedline( const ::rtl::OUString& rRedlineType, - const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rRedlineProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - SwUnoCursorHelper::makeRedline( *pUnoCrsr, rRedlineType, rRedlineProperties ); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties); } /*-- 09.12.98 14:18:58--------------------------------------------------- @@ -2704,12 +2718,9 @@ throw (lang::IllegalArgumentException, io::IOException, { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (!pUnoCrsr) - { - throw uno::RuntimeException(); - } - SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions); } /* -----------------------------15.12.00 14:01-------------------------------- @@ -3056,46 +3067,41 @@ throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSortOptions aSortOpt; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - - if (!pUnoCrsr) - { - throw uno::RuntimeException(); - } + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); - if (pUnoCrsr->HasMark()) + if (rUnoCursor.HasMark()) { + SwSortOptions aSortOpt; if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { - throw uno::RuntimeException(); + throw uno::RuntimeException(); } - UnoActionContext aContext( pUnoCrsr->GetDoc() ); + UnoActionContext aContext( rUnoCursor.GetDoc() ); - SwPosition* pStart = pUnoCrsr->Start(); - SwPosition* pEnd = pUnoCrsr->End(); + SwPosition & rStart = *rUnoCursor.Start(); + SwPosition & rEnd = *rUnoCursor.End(); - SwNodeIndex aPrevIdx( pStart->nNode, -1 ); - ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); - xub_StrLen nCntStt = pStart->nContent.GetIndex(); + SwNodeIndex aPrevIdx( rStart.nNode, -1 ); + const ULONG nOffset = rEnd.nNode.GetIndex() - rStart.nNode.GetIndex(); + const xub_StrLen nCntStt = rStart.nContent.GetIndex(); - pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); + rUnoCursor.GetDoc()->SortText(rUnoCursor, aSortOpt); // Selektion wieder setzen - pUnoCrsr->DeleteMark(); - pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); - SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); + rUnoCursor.DeleteMark(); + rUnoCursor.GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode *const pCNd = rUnoCursor.GetCntntNode(); xub_StrLen nLen = pCNd->Len(); if (nLen > nCntStt) { nLen = nCntStt; } - pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); - pUnoCrsr->SetMark(); + rUnoCursor.GetPoint()->nContent.Assign(pCNd, nLen ); + rUnoCursor.SetMark(); - pUnoCrsr->GetPoint()->nNode += nOffset; - pCNd = pUnoCrsr->GetCntntNode(); - pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + rUnoCursor.GetPoint()->nNode += nOffset; + SwCntntNode *const pCNd2 = rUnoCursor.GetCntntNode(); + rUnoCursor.GetPoint()->nContent.Assign( pCNd2, pCNd2->Len() ); } } @@ -3106,15 +3112,17 @@ uno::Reference< container::XEnumeration > SAL_CALL SwXTextCursor::createContentEnumeration(const OUString& rServiceName) throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (!pUnoCrsr || - 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent")) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) { throw uno::RuntimeException(); } + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + uno::Reference< container::XEnumeration > xRet = - new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); + new SwXParaFrameEnumeration(rUnoCursor, PARAFRAME_PORTION_TEXTRANGE); return xRet; } @@ -3124,18 +3132,16 @@ throw (uno::RuntimeException) uno::Reference< container::XEnumeration > SAL_CALL SwXTextCursor::createEnumeration() throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (!pUnoCrsr) - { - throw uno::RuntimeException(); - } - uno::Reference xTunnel(xParentText, UNO_QUERY); + vos::OGuard g(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const uno::Reference xTunnel( + m_pImpl->m_xParentText, uno::UNO_QUERY); SwXText* pParentText = 0; if (xTunnel.is()) { - pParentText = reinterpret_cast< SwXText *>( - sal::static_int_cast< sal_IntPtr >( - xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + pParentText = ::sw::UnoTunnelGetImplementation(xTunnel); } DBG_ASSERT(pParentText, "parent is not a SwXText"); if (!pParentText) @@ -3144,15 +3150,15 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException) } ::std::auto_ptr pNewCrsr( - pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); - if (pUnoCrsr->HasMark()) + rUnoCursor.GetDoc()->CreateUnoCrsr(*rUnoCursor.GetPoint()) ); + if (rUnoCursor.HasMark()) { pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); + *pNewCrsr->GetMark() = *rUnoCursor.GetMark(); } - const CursorType eSetType = (CURSOR_TBLTEXT == eType) + const CursorType eSetType = (CURSOR_TBLTEXT == m_pImpl->m_eType) ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - const uno::Reference< XEnumeration > xRet = + const uno::Reference< container::XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); return xRet; @@ -3164,7 +3170,7 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException) uno::Type SAL_CALL SwXTextCursor::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /* -----------------------------07.03.01 15:43-------------------------------- diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 04162db925..4e7122560f 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -141,9 +141,9 @@ uno::Reference SwXRedlineText::createTextCursor(void) vos::OGuard aGuard(Application::GetSolarMutex()); SwPosition aPos(aNodeIndex); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, - GetDoc()); - SwUnoCrsr* pUnoCursor = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_REDLINE, aPos); + SwUnoCrsr *const pUnoCursor = pXCursor->GetCursor(); pUnoCursor->Move(fnMoveForward, fnGoNode); // #101929# prevent a newly created text cursor from running inside a table @@ -175,7 +175,7 @@ uno::Reference SwXRedlineText::createTextCursor(void) throw aExcept; } - return (text::XWordCursor*)pCrsr; + return static_cast(pXCursor); } /* --------------------------------------------------------------------------- @@ -716,8 +716,9 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u if(pNodeIndex) { SwPosition aPos(*pNodeIndex); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, pDoc); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, this, CURSOR_REDLINE, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); //steht hier eine Tabelle? @@ -731,7 +732,7 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u } if(pCont) pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - xRet = (text::XWordCursor*)pCrsr; + xRet = static_cast(pXCursor); } else { diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index a9d58c7e69..f1f6cba52f 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -638,8 +639,8 @@ void SwXMetaText::PrepareForAttach( uno::Reference & xRange, { // create a new cursor to prevent modifying SwXTextRange xRange = static_cast( - new SwXTextCursor(&m_rMeta, *rPam.GetPoint(), CURSOR_META, - GetDoc(), (rPam.HasMark()) ? rPam.GetMark() : 0)); + new SwXTextCursor(*GetDoc(), &m_rMeta, CURSOR_META, *rPam.GetPoint(), + (rPam.HasMark()) ? rPam.GetMark() : 0)); } bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) @@ -663,7 +664,7 @@ throw (uno::RuntimeException) { SwPosition aPos(*pTxtNode, nMetaStart); xRet = static_cast( - new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc())); + new SwXTextCursor(*GetDoc(), &m_rMeta, CURSOR_META, aPos)); } } return xRet; diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index ed38bda74a..3087e3c90c 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1035,10 +1035,11 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursor(void) throw( uno: { const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd(); SwPosition aPos(*pSttNd); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_TBLTEXT, GetDoc()); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = (text::XWordCursor*)pCrsr; + aRef = static_cast(pXCursor); // // no Cursor in protected sections // SwCrsrSaveState aSave( *pUnoCrsr ); // if(pUnoCrsr->IsInProtectTable( sal_True ) || @@ -1068,7 +1069,11 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno: p1 = p1->StartOfSectionNode(); if( p1 == pSttNd ) - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_TBLTEXT, GetDoc(), aPam.GetMark()); + { + aRef = static_cast( + new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, + *aPam.GetPoint(), aPam.GetMark())); + } } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index f787f0e0fc..c3bffeb924 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -116,7 +116,7 @@ uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::Runtim SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); xRet = static_cast( - new SwXTextCursor(this, aPos, GetTextType(), GetDoc())); + new SwXTextCursor(*GetDoc(), this, GetTextType(), aPos)); xRet->gotoStart(sal_False); } return xRet; @@ -1437,7 +1437,7 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( // SwPaM aPam(*pStartNode->EndOfSectionNode()); //aPam.Move( fnMoveBackward, fnGoNode ); - SwUnoCrsr* pCursor = pTextCursor->GetCrsr(); + SwUnoCrsr * pCursor = pTextCursor->GetCursor(); pCursor->MovePara( fnParaCurr, fnParaEnd ); pDoc->DontExpandFmt( *pCursor->Start() ); @@ -2326,7 +2326,7 @@ SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) aPam.GetPoint()->nContent.Assign(pCont, 0); } } - return new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); + return new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, *aPam.GetPoint()); } /*-- 10.12.98 11:17:29--------------------------------------------------- @@ -2374,7 +2374,11 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( SwStartNode* p2 = rNode.StartOfSectionNode(); if(p1 == p2) - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_BODY, GetDoc(), aPam.GetMark()); + { + aRef = static_cast( + new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, + *aPam.GetPoint(), aPam.GetMark())); + } } if(!aRef.is()) throw uno::RuntimeException(); @@ -2554,8 +2558,9 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) thr const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); SwPosition aPos(rNode); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER, GetDoc()); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); //save current start node to be able to check if there is content after the table - @@ -2578,12 +2583,11 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) thr bIsHeader ? SwHeaderStartNode : SwFooterStartNode); if(!pNewStartNode || pNewStartNode != pOwnStartNode) { - pCrsr = NULL; uno::RuntimeException aExcept; aExcept.Message = S2U("no text available"); throw aExcept; } - xRet = (text::XWordCursor*)pCrsr; + xRet = static_cast(pXCursor); } else { @@ -2614,8 +2618,12 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( SwStartNode* p1 = aPam.GetNode()->FindSttNodeByType( bIsHeader ? SwHeaderStartNode : SwFooterStartNode); if(p1 == pOwnStartNode) - xRet = (text::XWordCursor*)new SwXTextCursor(this, *aPam.GetPoint(), - bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER, GetDoc(), aPam.GetMark()); + { + xRet = static_cast( + new SwXTextCursor(*GetDoc(), this, + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, + *aPam.GetPoint(), aPam.GetMark())); + } } return xRet; } diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index b28c444f26..b3318dbe9b 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -500,11 +500,11 @@ Reference XMLRedlineImportHelper::CreateRedlineTextSection( // create (UNO-) cursor SwPosition aPos(*pRedlineNode); - SwXTextCursor* pCursor = - new SwXTextCursor(pXText, aPos, CURSOR_REDLINE, pDoc); - pCursor->GetCrsr()->Move(fnMoveForward, fnGoNode); - - xReturn = (XWordCursor*)pCursor; // cast to avoid ambigiouty + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, pXText, CURSOR_REDLINE, aPos); + pXCursor->GetCursor()->Move(fnMoveForward, fnGoNode); + // cast to avoid ambiguity + xReturn = static_cast(pXCursor); } // else: unknown redline -> Ignore diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 97e419d050..f2d43e070a 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -733,7 +733,7 @@ SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xC SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true); xCrsr.set( static_cast(pXTextCursor) ); - SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor(); pUnoCrsr->SetRemainInSection(sal_False); return pUnoCrsr; } @@ -987,7 +987,7 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear const uno::Reference< text::XText > xParent = ::sw::CreateParentXText(*pDocShell->GetDoc(), *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xParent, pResultCrsr); + xRet = *new SwXTextCursor(xParent, *pResultCrsr); delete pResultCrsr; } return xRet; @@ -1015,7 +1015,7 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > ::sw::CreateParentXText(*pDocShell->GetDoc(), *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xParent, pResultCrsr); + xRet = *new SwXTextCursor(xParent, *pResultCrsr); delete pResultCrsr; } return xRet; -- cgit v1.2.3 From 61f644ad8e16e0bda13339e962f3c90fd933c384 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:56 +0100 Subject: 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. --- sw/inc/unofootnote.hxx | 2 +- sw/inc/unoframe.hxx | 10 +- sw/inc/unotbl.hxx | 14 +- sw/inc/unotext.hxx | 63 +- sw/inc/unotextbodyhf.hxx | 2 +- sw/source/core/unocore/unoframe.cxx | 3 +- sw/source/core/unocore/unoftn.cxx | 3 +- sw/source/core/unocore/unoobj2.cxx | 2 +- sw/source/core/unocore/unorefmk.cxx | 11 +- sw/source/core/unocore/unotbl.cxx | 21 +- sw/source/core/unocore/unotext.cxx | 2137 ++++++++++++++++++----------------- 11 files changed, 1162 insertions(+), 1106 deletions(-) diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx index d1c869404d..8710f7effa 100644 --- a/sw/inc/unofootnote.hxx +++ b/sw/inc/unofootnote.hxx @@ -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(); diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index e48f029b00..1d7b17cf22 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -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(); diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index bc66e61c26..7b2272b090 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -106,14 +106,16 @@ 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(); public: diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx index 97a45ece73..3c805da512 100644 --- a/sw/inc/unotext.hxx +++ b/sw/inc/unotext.hxx @@ -40,8 +40,6 @@ #include #include -#include - #include @@ -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 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( diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index baab8bc158..98656ca68c 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -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(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index c1a5a632e5..afea552fd2 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -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(); } diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index c0eeb66a9e..19787cdbd0 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -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(); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e1abe7a715..4c25d821eb 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -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 xCrsrTunnel( xTextCursor, uno::UNO_QUERY); diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index f1f6cba52f..b3fe08f3a3 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -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 & xTextPosition) throw (uno::RuntimeException) { - const uno::Reference xCursor( createCursor() ); + const uno::Reference xCursor( CreateCursor() ); xCursor->gotoRange(xTextPosition, sal_False); return xCursor; } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 3087e3c90c..d94cce8a73 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -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(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(this)->FindBox(pTable, pBox); + if (!pFoundBox) + { + const_cast(this)->pBox = 0; + } } return 0 != pBox; } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index c3bffeb924..82ad2cccc9 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -84,13 +84,92 @@ using ::rtl::OUString; const sal_Char cInvalidObject[] = "this object is invalid"; + /****************************************************************** * SwXText ******************************************************************/ + +class SwXText::Impl +{ + +public: + SwXText & m_rThis; + SfxItemPropertySet const& m_rPropSet; + const enum CursorType m_eType; + SwDoc * m_pDoc; + bool m_bIsValid; + + Impl( SwXText & rThis, + SwDoc *const pDoc, const enum CursorType eType) + : m_rThis(rThis) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT)) + , m_eType(eType) + , m_pDoc(pDoc) + , m_bIsValid(0 != pDoc) + { + } + + uno::Reference< text::XTextRange > + finishOrAppendParagraph( + const bool bFinish, + const uno::Sequence< beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + sal_Int16 ComparePositions( + const uno::Reference& xPos1, + const uno::Reference& xPos2) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + bool CheckForOwnMember(const SwPaM & rPaM) + throw (lang::IllegalArgumentException, uno::RuntimeException); +}; + +/* -----------------------------15.03.2002 12:39------------------------------ + + ---------------------------------------------------------------------------*/ +SwXText::SwXText(SwDoc *const pDoc, const enum CursorType eType) + : m_pImpl( new SwXText::Impl(*this, pDoc, eType) ) +{ +} +/*-- 09.12.98 12:43:55--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXText::~SwXText() +{ +} + /*-- 09.12.98 12:44:07--------------------------------------------------- -----------------------------------------------------------------------*/ +const SwDoc * SwXText::GetDoc() const +{ + return m_pImpl->m_pDoc; +} + SwDoc * SwXText::GetDoc() +{ + return m_pImpl->m_pDoc; +} + +bool SwXText::IsValid() const +{ + return m_pImpl->m_bIsValid; +} + +void SwXText::Invalidate() +{ + m_pImpl->m_bIsValid = false; +} + +void SwXText::SetDoc(SwDoc *const pDoc) +{ + OSL_ENSURE(!m_pImpl->m_pDoc || !pDoc, + "SwXText::SetDoc: already have a doc?"); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsValid = (0 != pDoc); +} + void SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) { @@ -99,7 +178,7 @@ SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool) throw (lang::IllegalArgumentException, uno::RuntimeException) { - ASSERT(CURSOR_META != eCrsrType, "should not be called!"); + ASSERT(CURSOR_META != m_pImpl->m_eType, "should not be called!"); return false; } @@ -108,7 +187,8 @@ const SwStartNode *SwXText::GetStartNode() const return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); } -uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXText::CreateCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; if(IsValid()) @@ -116,525 +196,457 @@ uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::Runtim SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); xRet = static_cast( - new SwXTextCursor(*GetDoc(), this, GetTextType(), aPos)); + new SwXTextCursor(*GetDoc(), this, m_pImpl->m_eType, aPos)); xRet->gotoStart(sal_False); } return xRet; } -/* -----------------------------15.03.2002 12:39------------------------------ - - ---------------------------------------------------------------------------*/ -SwXText::SwXText(SwDoc* pDc, CursorType eType) : - pDoc(pDc), - bObjectValid(0 != pDc), - eCrsrType(eType), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT)) -{ -} -/*-- 09.12.98 12:43:55--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXText::~SwXText() -{ -} /*-- 09.12.98 12:43:02--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXText::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) -{ - const uno::Type& rXTextType = ::getCppuType((uno::Reference< text::XText >*)0); - const uno::Type& rXTextRangeCompareType = ::getCppuType((uno::Reference< text::XTextRangeCompare >*)0); - const uno::Type& rXSimpleTextType = ::getCppuType((const uno::Reference< XSimpleText >*)0); - const uno::Type& rXTextRangeType = ::getCppuType((uno::Reference< text::XTextRange >*)0); - const uno::Type& rXTypeProviderType = ::getCppuType((uno::Reference< lang::XTypeProvider >*)0); - const uno::Type& rXTextContentInsert = ::getCppuType((uno::Reference< text::XRelativeTextContentInsert >*)0); - const uno::Type& rXTextContentRemove = ::getCppuType((uno::Reference< text::XRelativeTextContentRemove >*)0); - const uno::Type& rXPropertySet = ::getCppuType((uno::Reference*)0); - const uno::Type& rXUnoTunnel = ::getCppuType((uno::Reference< lang::XUnoTunnel >*)0); - const uno::Type& rXTextPortionAppend = ::getCppuType((uno::Reference< text::XTextPortionAppend >*)0); - const uno::Type& rXParagraphAppend = ::getCppuType((uno::Reference< text::XParagraphAppend >*)0); - const uno::Type& rXTextContentAppend = ::getCppuType((uno::Reference< text::XTextContentAppend >*)0); - const uno::Type& rXTextConvert = ::getCppuType((uno::Reference< text::XTextConvert >*)0); - const uno::Type& rXTextAppend = ::getCppuType((uno::Reference< text::XTextAppend >*)0); - const uno::Type& rXTextAppendAndConvert = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0); - +uno::Any SAL_CALL +SwXText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) +{ uno::Any aRet; - if(rType == rXTextType) + if (rType == text::XText::static_type()) { - uno::Reference< text::XText > xRet = this; - aRet.setValue(&xRet, rXTextType); + aRet <<= uno::Reference< text::XText >(this); } - else if(rType == rXSimpleTextType) + else if (rType == text::XSimpleText::static_type()) { - uno::Reference< XSimpleText > xRet = this; - aRet.setValue(&xRet, rXSimpleTextType); + aRet <<= uno::Reference< text::XSimpleText >(this); } - else if(rType == rXTextRangeType) + else if (rType == text::XTextRange::static_type()) { - uno::Reference< text::XTextRange > xRet = this; - aRet.setValue(&xRet, rXTextRangeType); + aRet <<= uno::Reference< text::XTextRange>(this); } - else if(rType == rXTextRangeCompareType) + else if (rType == text::XTextRangeCompare::static_type()) { - uno::Reference< text::XTextRangeCompare > xRet = this; - aRet.setValue(&xRet, rXTextRangeCompareType); + aRet <<= uno::Reference< text::XTextRangeCompare >(this); } - else if(rType == rXTypeProviderType) + else if (rType == lang::XTypeProvider::static_type()) { - uno::Reference< lang::XTypeProvider > xRet = this; - aRet.setValue(&xRet, rXTypeProviderType); + aRet <<= uno::Reference< lang::XTypeProvider >(this); } - else if(rType == rXTextContentInsert) + else if (rType == text::XRelativeTextContentInsert::static_type()) { - uno::Reference< text::XRelativeTextContentInsert > xRet = this; - aRet.setValue(&xRet, rXTextContentInsert); + aRet <<= uno::Reference< text::XRelativeTextContentInsert >(this); } - else if(rType == rXTextContentRemove) + else if (rType == text::XRelativeTextContentRemove::static_type()) { - uno::Reference< text::XRelativeTextContentRemove > xRet = this; - aRet.setValue(&xRet, rXTextContentRemove); + aRet <<= uno::Reference< text::XRelativeTextContentRemove >(this); } - else if(rType == rXPropertySet) + else if (rType == beans::XPropertySet::static_type()) { - uno::Reference< beans::XPropertySet > xRet = this; - aRet.setValue(&xRet, rXPropertySet); + aRet <<= uno::Reference< beans::XPropertySet >(this); } - else if(rType == rXUnoTunnel ) + else if (rType == lang::XUnoTunnel::static_type()) { - uno::Reference< lang::XUnoTunnel > xRet = this; - aRet.setValue(&xRet, rXUnoTunnel); + aRet <<= uno::Reference< lang::XUnoTunnel >(this); } - else if(rType == rXTextAppendAndConvert ) + else if (rType == text::XTextAppendAndConvert::static_type()) { - uno::Reference< XTextAppendAndConvert > xRet = this; - aRet.setValue(&xRet, rXTextAppendAndConvert); + aRet <<= uno::Reference< text::XTextAppendAndConvert >(this); } - else if(rType == rXTextAppend ) + else if (rType == text::XTextAppend::static_type()) { - uno::Reference< XTextAppend > xRet = this; - aRet.setValue(&xRet, rXTextAppend); + aRet <<= uno::Reference< text::XTextAppend >(this); } - else if(rType == rXTextPortionAppend ) + else if (rType == text::XTextPortionAppend::static_type()) { - uno::Reference< XTextPortionAppend > xRet = this; - aRet.setValue(&xRet, rXTextPortionAppend); + aRet <<= uno::Reference< text::XTextPortionAppend >(this); } - else if(rType == rXParagraphAppend ) + else if (rType == text::XParagraphAppend::static_type()) { - uno::Reference< XParagraphAppend > xRet = this; - aRet.setValue(&xRet, rXParagraphAppend ); + aRet <<= uno::Reference< text::XParagraphAppend >(this); } - else if(rType == rXTextConvert ) + else if (rType == text::XTextConvert::static_type() ) { - uno::Reference< XTextConvert > xRet = this; - aRet.setValue(&xRet, rXParagraphAppend ); + aRet <<= uno::Reference< text::XTextConvert >(this); } - else if(rType == rXTextContentAppend ) + else if (rType == text::XTextContentAppend::static_type()) { - uno::Reference< XTextContentAppend > xRet = this; - aRet.setValue(&xRet, rXTextContentAppend ); + aRet <<= uno::Reference< text::XTextContentAppend >(this); } return aRet; } /* -----------------------------15.03.00 17:42-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SAL_CALL SwXText::getTypes() throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXText::getTypes() throw (uno::RuntimeException) { uno::Sequence< uno::Type > aRet(12); uno::Type* pTypes = aRet.getArray(); - pTypes[0] = ::getCppuType((uno::Reference< text::XText >*)0); - pTypes[1] = ::getCppuType((uno::Reference< text::XTextRangeCompare >*)0); - pTypes[2] = ::getCppuType((uno::Reference< text::XRelativeTextContentInsert >*)0); - pTypes[3] = ::getCppuType((uno::Reference< text::XRelativeTextContentRemove >*)0); - pTypes[4] = ::getCppuType((uno::Reference< lang::XUnoTunnel >*)0); - pTypes[5] = ::getCppuType((uno::Reference< beans::XPropertySet >*)0); - pTypes[6] = ::getCppuType((uno::Reference< text::XTextPortionAppend >*)0); - pTypes[7] = ::getCppuType((uno::Reference< text::XParagraphAppend >*)0); - pTypes[8] = ::getCppuType((uno::Reference< text::XTextContentAppend >*)0); - pTypes[9] = ::getCppuType((uno::Reference< text::XTextConvert >*)0); - pTypes[10] = ::getCppuType((uno::Reference< text::XTextAppend >*)0); - pTypes[11] = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0); + pTypes[0] = text::XText::static_type(); + pTypes[1] = text::XTextRangeCompare::static_type(); + pTypes[2] = text::XRelativeTextContentInsert::static_type(); + pTypes[3] = text::XRelativeTextContentRemove::static_type(); + pTypes[4] = lang::XUnoTunnel::static_type(); + pTypes[5] = beans::XPropertySet::static_type(); + pTypes[6] = text::XTextPortionAppend::static_type(); + pTypes[7] = text::XParagraphAppend::static_type(); + pTypes[8] = text::XTextContentAppend::static_type(); + pTypes[9] = text::XTextConvert::static_type(); + pTypes[10] = text::XTextAppend::static_type(); + pTypes[11] = text::XTextAppendAndConvert::static_type(); return aRet; } // belongs the range in the text ? insert it then. -void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, - const OUString& aString, - sal_Bool bAbsorb) - throw( uno::RuntimeException ) +void SAL_CALL +SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, + const OUString& rString, sal_Bool bAbsorb) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetDoc() && xTextRange.is()) + + if (!xTextRange.is()) { - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + throw uno::RuntimeException(); + } + if (!GetDoc()) + { + throw uno::RuntimeException(); + } + const uno::Reference xRangeTunnel(xTextRange, + uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + if ((!pRange || pRange ->GetDoc() != GetDoc()) && + (!pCursor || pCursor->GetDoc() != GetDoc())) + { + throw uno::RuntimeException(); + } + + const SwStartNode *const pOwnStartNode = GetStartNode(); + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) + { + pPam = pCursor->GetPaM(); + } + else // pRange + { + if (pRange->GetPositions(aPam)) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pPam = &aPam; } + } + if (!pPam) + { + throw uno::RuntimeException(); + } - if(pRange && pRange->GetDoc() == GetDoc() || - pCursor && pCursor->GetDoc() == GetDoc()) - { - const SwStartNode *const pOwnStartNode = GetStartNode(); - SwPaM aPam(GetDoc()->GetNodes()); - const SwPaM * pPam(0); - if (pCursor) - { - pPam = pCursor->GetPaM(); - } - else // pRange - { - if (pRange->GetPositions(aPam)) - { - pPam = &aPam; - } - } - if (!pPam) - { - throw uno::RuntimeException(); - } - else - { - const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); - while (pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - if (!pOwnStartNode || (pOwnStartNode != pTmp)) - { - throw uno::RuntimeException(); - } - } + const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); + while (pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + if (!pOwnStartNode || (pOwnStartNode != pTmp)) + { + throw uno::RuntimeException(); + } - bool bForceExpandHints( false ); - if (CURSOR_META == eCrsrType) - { - try - { - bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); - } - catch (lang::IllegalArgumentException & iae) - { - // stupid method not allowed to throw iae - throw uno::RuntimeException(iae.Message, 0); - } - } - if(bAbsorb) + bool bForceExpandHints( false ); + if (CURSOR_META == m_pImpl->m_eType) + { + try + { + bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); + } + catch (lang::IllegalArgumentException & iae) + { + // stupid method not allowed to throw iae + throw uno::RuntimeException(iae.Message, 0); + } + } + if (bAbsorb) + { + //!! scan for CR characters and inserting the paragraph breaks + //!! has to be done in the called function. + //!! Implemented in SwXTextRange::DeleteAndInsert + if (pCursor) + { + SwXTextCursor * const pTextCursor( + dynamic_cast(pCursor) ); + if (pTextCursor) { - //!! scan for CR characters and inserting the paragraph breaks - //!! has to be done in the called function. - //!! Implemented in SwXTextRange::DeleteAndInsert - if (pCursor) - { - SwXTextCursor * const pTextCursor( dynamic_cast(pCursor) ); - if (pTextCursor) - { - pTextCursor->DeleteAndInsert(aString, bForceExpandHints); - } - else - { - xTextRange->setString(aString); - } - } - else - { - pRange->DeleteAndInsert(aString, bForceExpandHints); - } + pTextCursor->DeleteAndInsert(rString, bForceExpandHints); } else { - //hier wird ein PaM angelegt, der vor dem Parameter-PaM liegt, damit der - //Text davor eingefuegt wird - UnoActionContext aContext(GetDoc()); - SwPaM aInsertPam(*pPam->Start()); - const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); - GetDoc()->DoGroupUndo(sal_False); - - SwUnoCursorHelper::DocInsertStringSplitCR( - *GetDoc(), aInsertPam, aString, bForceExpandHints ); - GetDoc()->DoGroupUndo(bGroupUndo); + xTextRange->setString(rString); } } else - throw uno::RuntimeException(); + { + pRange->DeleteAndInsert(rString, bForceExpandHints); + } } else - throw uno::RuntimeException(); + { + // create a PaM positioned before the parameter PaM, + // so the text is inserted before + UnoActionContext aContext(GetDoc()); + SwPaM aInsertPam(*pPam->Start()); + const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); + GetDoc()->DoGroupUndo(sal_False); + + SwUnoCursorHelper::DocInsertStringSplitCR( + *GetDoc(), aInsertPam, rString, bForceExpandHints ); + GetDoc()->DoGroupUndo(bGroupUndo); + } } /*-- 09.12.98 12:43:16--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & xTextRange, - sal_Int16 nControlCharacter, sal_Bool bAbsorb) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXText::insertControlCharacter( + const uno::Reference< text::XTextRange > & xTextRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if (!xTextRange.is()) + { throw lang::IllegalArgumentException(); - if (GetDoc()) + } + if (!GetDoc()) { - SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, xTextRange)) + throw uno::RuntimeException(); + } + + SwUnoInternalPaM aPam(*GetDoc()); + if (!::sw::XTextRangeToSwPaM(aPam, xTextRange)) + { + throw uno::RuntimeException(); + } + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); + + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + + SwPaM aTmp(*aPam.Start()); + if (bAbsorb && aPam.HasMark()) + { + m_pImpl->m_pDoc->DeleteAndJoin(aPam); + } + + sal_Unicode cIns = 0; + switch (nControlCharacter) + { + case text::ControlCharacter::PARAGRAPH_BREAK : + // a table cell now becomes an ordinary text cell! + m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); + m_pImpl->m_pDoc->SplitNode( *aTmp.GetPoint(), sal_False ); + break; + case text::ControlCharacter::APPEND_PARAGRAPH: { - const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); - - const enum IDocumentContentOperations::InsertFlags nInsertFlags = - (bForceExpandHints) - ? static_cast( - IDocumentContentOperations::INS_FORCEHINTEXPAND | - IDocumentContentOperations::INS_EMPTYEXPAND) - : IDocumentContentOperations::INS_EMPTYEXPAND; - - //Steuerzeichen einfuegen - SwPaM aTmp(*aPam.Start()); - if(bAbsorb && aPam.HasMark()) + m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); + m_pImpl->m_pDoc->AppendTxtNode( *aTmp.GetPoint() ); + + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation( + xRangeTunnel); + if (pRange) { - pDoc->DeleteAndJoin(aPam); + pRange->SetPositions(aTmp); } - - sal_Unicode cIns = 0; - switch( nControlCharacter ) + else if (pCursor) { - case text::ControlCharacter::PARAGRAPH_BREAK : - // eine Tabellen Zelle wird jetzt zu einer normalen Textzelle! - pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); - pDoc->SplitNode( *aTmp.GetPoint(), sal_False ); - break; - case text::ControlCharacter::APPEND_PARAGRAPH: - { - pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); - pDoc->AppendTxtNode( *aTmp.GetPoint() ); - - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - if(pRange) - { - pRange->SetPositions(aTmp); - } - else if(pCursor) - { - SwPaM* pCrsr = pCursor->GetPaM(); - *pCrsr->GetPoint() = *aTmp.GetPoint(); - pCrsr->DeleteMark(); - } - } - break; - case text::ControlCharacter::LINE_BREAK: cIns = 10; break; - case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; - case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break; - case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; + SwPaM *const pCrsr = pCursor->GetPaM(); + *pCrsr->GetPoint() = *aTmp.GetPoint(); + pCrsr->DeleteMark(); } - if( cIns ) + } + break; + case text::ControlCharacter::LINE_BREAK: cIns = 10; break; + case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; + case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break; + case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; + } + if (cIns) + { + m_pImpl->m_pDoc->InsertString( aTmp, cIns, nInsertFlags ); + } + + if (bAbsorb) + { + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + + SwCursor aCrsr(*aTmp.GetPoint(),0,false); + SwUnoCursorHelper::SelectPam(aCrsr, true); + aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + //hier muss der uebergebene PaM umgesetzt werden: + if (pRange) + { + pRange->SetPositions(aCrsr); + } + else + { + SwPaM *const pUnoCrsr = pCursor->GetPaM(); + *pUnoCrsr->GetPoint() = *aCrsr.GetPoint(); + if (aCrsr.HasMark()) { - pDoc->InsertString( aTmp, cIns, nInsertFlags ); + pUnoCrsr->SetMark(); + *pUnoCrsr->GetMark() = *aCrsr.GetMark(); } - - if(bAbsorb) + else { - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - - SwCursor aCrsr(*aTmp.GetPoint(),0,false); - SwUnoCursorHelper::SelectPam(aCrsr, true); - aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - //hier muss der uebergebene PaM umgesetzt werden: - if(pRange) - { - pRange->SetPositions(aCrsr); - } - else - { - SwPaM* pUnoCrsr = pCursor->GetPaM(); - *pUnoCrsr->GetPoint() = *aCrsr.GetPoint(); - if(aCrsr.HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *aCrsr.GetMark(); - } - else - pUnoCrsr->DeleteMark(); - } + pUnoCrsr->DeleteMark(); } } } - else - throw uno::RuntimeException(); } + /*-- 09.12.98 12:43:17--------------------------------------------------- -----------------------------------------------------------------------*/ - -void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRange, - const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXText::insertTextContent( + const uno::Reference< text::XTextRange > & xRange, + const uno::Reference< text::XTextContent > & xContent, + sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // erstmal testen, ob der Range an der richtigen Stelle ist und dann - // am Sw-Content attachToRange aufrufen + + if (!xRange.is()) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message = C2U("first parameter invalid;"); + throw aIllegal; + } + if (!xContent.is()) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message += C2U("second parameter invalid"); + throw aIllegal; + } if(!GetDoc()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - if(xRange.is() && xContent.is()) - { - SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, xRange)) - { - uno::Reference xRangeTunnel( xRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - SwXTextPortion* pPortion = 0; - SwXText* pText = 0; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pPortion = reinterpret_cast< SwXTextPortion * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) )); - pText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) )); - } + SwUnoInternalPaM aPam(*GetDoc()); + if (!::sw::XTextRangeToSwPaM(aPam, xRange)) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message = C2U("first parameter invalid"); + throw aIllegal; + } + // first test if the range is at the right position, then call + // xContent->attach + const SwStartNode* pOwnStartNode = GetStartNode(); + SwStartNodeType eSearchNodeType = SwNormalStartNode; + switch (m_pImpl->m_eType) + { + case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; + case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; + case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break; + case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break; + case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break; + //case CURSOR_INVALID: + //case CURSOR_BODY: + default: + break; + } - uno::Reference< text::XTextCursor > xOwnCursor = createCursor(); - uno::Reference xOwnTunnel( xOwnCursor, uno::UNO_QUERY); -// OTextCursorHelper* pOwnCursor = reinterpret_cast< OTextCursorHelper * >( -// sal::static_int_cast< sal_IntPtr >( xOwnTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + const SwStartNode* pTmp = + aPam.GetNode()->FindSttNodeByType(eSearchNodeType); - const SwStartNode* pOwnStartNode = GetStartNode(); - SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eCrsrType) - { - case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; - case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; - case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break; - case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break; - case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break; - //case CURSOR_INVALID: - //case CURSOR_BODY: - default: - ; - } + // ignore SectionNodes + while (pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + // if the document starts with a section + while (pOwnStartNode->IsSectionNode()) + { + pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } + // this checks if (this) and xRange are in the same text::XText interface + if (pOwnStartNode != pTmp) + { + uno::RuntimeException aRunException; + aRunException.Message = C2U("text interface and cursor not related"); + throw aRunException; + } - const SwStartNode* pTmp = - aPam.GetNode()->FindSttNodeByType(eSearchNodeType); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); - //SectionNodes ueberspringen - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - //if the document starts with a section - while(pOwnStartNode->IsSectionNode()) - { - pOwnStartNode = pOwnStartNode->StartOfSectionNode(); - } - //this checks if (this) and xRange are in the same text::XText interface - if(pOwnStartNode != pTmp) - { - uno::RuntimeException aRunException; - aRunException.Message = C2U("text interface and cursor not related"); - throw aRunException; - } + // special treatment for Contents that do not replace the range, but + // instead are "overlaid" + const uno::Reference xContentTunnel(xContent, + uno::UNO_QUERY); + if (!xContentTunnel.is()) + { + lang::IllegalArgumentException aArgException; + aArgException.Message = + C2U("text content does not support lang::XUnoTunnel"); + throw aArgException; + } + SwXDocumentIndexMark *const pDocumentIndexMark = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXTextSection *const pSection = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXBookmark *const pBookmark = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXReferenceMark *const pReferenceMark = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXMeta *const pMeta = + ::sw::UnoTunnelGetImplementation(xContentTunnel); - const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); + const bool bAttribute = pBookmark || pDocumentIndexMark + || pSection || pReferenceMark || pMeta; - // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden - // Bookmarks, IndexEntry - uno::Reference xContentTunnel( xContent, uno::UNO_QUERY); - if(!xContentTunnel.is()) - { - lang::IllegalArgumentException aArgException; - aArgException.Message = C2U("text content doesn't support lang::XUnoTunnel"); - throw aArgException; - } - SwXDocumentIndexMark* pDocumentIndexMark = reinterpret_cast< SwXDocumentIndexMark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXDocumentIndexMark::getUnoTunnelId()) )); - SwXTextSection* pSection = reinterpret_cast< SwXTextSection * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXTextSection::getUnoTunnelId()) )); - SwXBookmark* pBookmark = reinterpret_cast< SwXBookmark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXBookmark::getUnoTunnelId()) )); - SwXReferenceMark* pReferenceMark = reinterpret_cast< SwXReferenceMark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXReferenceMark::getUnoTunnelId()) )); - SwXMeta *const pMeta = reinterpret_cast< SwXMeta* >( - sal::static_int_cast< sal_IntPtr >( - xContentTunnel->getSomething( SwXMeta::getUnoTunnelId()))); - - const bool bAttribute = pBookmark || pDocumentIndexMark - || pSection || pReferenceMark || pMeta; - - if(bAbsorb && !bAttribute) - { - xRange->setString(aEmptyStr); - } - //hier wird tatsaechlich eingefuegt - uno::Reference< text::XTextRange > xTempRange; - if(bAttribute && bAbsorb) - xTempRange = xRange; - else - xTempRange = xRange->getStart(); - if (bForceExpandHints) - { - // if necessary, replace xTempRange with a new SwXTextCursor - PrepareForAttach(xTempRange, aPam); - } - xContent->attach(xTempRange); - } - else - { - lang::IllegalArgumentException aIllegal; - aIllegal.Message = C2U("first parameter invalid"); - throw aIllegal; - } + if (bAbsorb && !bAttribute) + { + xRange->setString(aEmptyStr); } - else + uno::Reference< text::XTextRange > xTempRange = + (bAttribute && bAbsorb) ? xRange : xRange->getStart(); + if (bForceExpandHints) { - lang::IllegalArgumentException aIllegal; - if(!xRange.is()) - aIllegal.Message = C2U("first parameter invalid;"); - if(!xContent.is()) - aIllegal.Message += C2U("second parameter invalid"); - throw aIllegal; + // if necessary, replace xTempRange with a new SwXTextCursor + PrepareForAttach(xTempRange, aPam); } - + xContent->attach(xTempRange); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::insertTextContentBefore( +void SAL_CALL +SwXText::insertTextContentBefore( const uno::Reference< text::XTextContent>& xNewContent, const uno::Reference< text::XTextContent>& xSuccessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -646,35 +658,37 @@ void SwXText::insertTextContentBefore( uno::UNO_QUERY); SwXParagraph *const pPara = ::sw::UnoTunnelGetImplementation(xParaTunnel); - if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) + if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) + { throw lang::IllegalArgumentException(); + } sal_Bool bRet = sal_False; const uno::Reference xSuccTunnel(xSuccessor, uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xSuccTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xSuccTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwNodeIndex aTblIdx( *pTblNode, -1 ); + const SwNodeIndex aTblIdx( *pTblNode, -1 ); SwPosition aBefore(aTblIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); - SwNodeIndex aSectIdx( *pSectNode, -1 ); + const SwNodeIndex aSectIdx( *pSectNode, -1 ); SwPosition aBefore(aSectIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); @@ -683,55 +697,59 @@ void SwXText::insertTextContentBefore( { throw lang::IllegalArgumentException(); } - else - { - pPara->attachToText(*this, *pTxtNode); - } - + pPara->attachToText(*this, *pTxtNode); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::insertTextContentAfter( +void SAL_CALL +SwXText::insertTextContentAfter( const uno::Reference< text::XTextContent>& xNewContent, const uno::Reference< text::XTextContent>& xPredecessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) + { throw uno::RuntimeException(); + } + const uno::Reference xParaTunnel(xNewContent, uno::UNO_QUERY); SwXParagraph *const pPara = ::sw::UnoTunnelGetImplementation(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) + { throw lang::IllegalArgumentException(); + } const uno::Reference xPredTunnel(xPredecessor, uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xPredTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xPredTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; sal_Bool bRet = sal_False; SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); + SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode(); SwPosition aTableEnd(*pTableEnd); bRet = GetDoc()->AppendTxtNode( aTableEnd ); pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode(); } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); - SwEndNode* pEnd = pSectNode->EndOfSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); + SwEndNode *const pEnd = pSectNode->EndOfSectionNode(); SwPosition aEnd(*pEnd); bRet = GetDoc()->AppendTxtNode( aEnd ); pTxtNode = aEnd.nNode.GetNode().GetTxtNode(); @@ -740,19 +758,19 @@ void SwXText::insertTextContentAfter( { throw lang::IllegalArgumentException(); } - else - { - pPara->attachToText(*this, *pTxtNode); - } + pPara->attachToText(*this, *pTxtNode); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::removeTextContentBefore( +void SAL_CALL +SwXText::removeTextContentBefore( const uno::Reference< text::XTextContent>& xSuccessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -765,28 +783,28 @@ void SwXText::removeTextContentBefore( uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xSuccTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xSuccTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwNodeIndex aTblIdx( *pTblNode, -1 ); + const SwNodeIndex aTblIdx( *pTblNode, -1 ); if(aTblIdx.GetNode().IsTxtNode()) { SwPaM aBefore(aTblIdx); bRet = GetDoc()->DelFullPara( aBefore ); } } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); - SwNodeIndex aSectIdx( *pSectNode, -1 ); + const SwNodeIndex aSectIdx( *pSectNode, -1 ); if(aSectIdx.GetNode().IsTxtNode()) { SwPaM aBefore(aSectIdx); @@ -794,15 +812,21 @@ void SwXText::removeTextContentBefore( } } if(!bRet) + { throw lang::IllegalArgumentException(); + } } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& xPredecessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +void SAL_CALL +SwXText::removeTextContentAfter( + const uno::Reference< text::XTextContent>& xPredecessor) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -815,29 +839,29 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xPredTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xPredTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); + SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode(); - SwNodeIndex aTblIdx( *pTableEnd, 1 ); + const SwNodeIndex aTblIdx( *pTableEnd, 1 ); if(aTblIdx.GetNode().IsTxtNode()) { SwPaM aPaM(aTblIdx); bRet = GetDoc()->DelFullPara( aPaM ); } } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); - SwEndNode* pEnd = pSectNode->EndOfSectionNode(); - SwNodeIndex aSectIdx( *pEnd, 1 ); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); + SwEndNode *const pEnd = pSectNode->EndOfSectionNode(); + const SwNodeIndex aSectIdx( *pEnd, 1 ); if(aSectIdx.GetNode().IsTxtNode()) { SwPaM aAfter(aSectIdx); @@ -845,42 +869,50 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& } } if(!bRet) + { throw lang::IllegalArgumentException(); + } } + /*-- 09.12.98 12:43:19--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removeTextContent(const uno::Reference< text::XTextContent > & xContent) - throw( container::NoSuchElementException, uno::RuntimeException ) +void SAL_CALL +SwXText::removeTextContent( + const uno::Reference< text::XTextContent > & xContent) +throw (container::NoSuchElementException, uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + // forward: need no solar mutex here if(!xContent.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U("first parameter invalid"); throw aRuntime; } - else - xContent->dispose(); + xContent->dispose(); } + /*-- 09.12.98 12:43:22--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXText::getText(void) - throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXText::getText() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XText > xRet = (SwXText*)this; - return xRet; + const uno::Reference< text::XText > xRet(this); + return xRet; } + /*-- 09.12.98 12:43:24--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRef = createCursor(); + + const uno::Reference< text::XTextCursor > xRef = CreateCursor(); if(!xRef.is()) { uno::RuntimeException aRuntime; @@ -888,16 +920,18 @@ uno::Reference< text::XTextRange > SwXText::getStart(void) throw( uno::RuntimeE throw aRuntime; } xRef->gotoStart(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } /*-- 09.12.98 12:43:27--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRef = createCursor(); + + const uno::Reference< text::XTextCursor > xRef = CreateCursor(); if(!xRef.is()) { uno::RuntimeException aRuntime; @@ -905,42 +939,52 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc throw aRuntime; } xRef->gotoEnd(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } + /*-- 09.12.98 12:43:29--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXText::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXText::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet = createCursor(); + + const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - { - xRet->gotoEnd(sal_True); - } + xRet->gotoEnd(sal_True); return xRet->getString(); } /*-- 09.12.98 12:43:30--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL +SwXText::setString(const OUString& rString) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!GetDoc()) + { + uno::RuntimeException aRuntime; + aRuntime.Message = C2U(cInvalidObject); + throw aRuntime; + } + const SwStartNode* pStartNode = GetStartNode(); - if(!pStartNode) + if (!pStartNode) + { throw uno::RuntimeException(); + } GetDoc()->StartUndo(UNDO_START, NULL); //insert an empty paragraph at the start and at the end to ensure that //all tables and sections can be removed by the selecting text::XTextCursor - if (CURSOR_META != eCrsrType) + if (CURSOR_META != m_pImpl->m_eType) { SwPosition aStartPos(*pStartNode); const SwEndNode* pEnd = pStartNode->EndOfSectionNode(); @@ -972,7 +1016,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) } } - uno::Reference< text::XTextCursor > xRet = createCursor(); + const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { GetDoc()->EndUndo(UNDO_END, NULL); @@ -980,36 +1024,28 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - { - xRet->gotoEnd(sal_True); - } - xRet->setString(aString); + xRet->gotoEnd(sal_True); + xRet->setString(rString); GetDoc()->EndUndo(UNDO_END, NULL); } //FIXME why is CheckForOwnMember duplicated in some insert methods? // Description: Checks if pRange/pCursor are member of the same text interface. // Only one of the pointers has to be set! -sal_Bool SwXText::CheckForOwnMember( - const SwXTextRange* pRange, - const OTextCursorHelper* pCursor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +bool SwXText::Impl::CheckForOwnMember( + const SwPaM & rPaM) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - DBG_ASSERT((!pRange || !pCursor) && (pRange || pCursor), "only one pointer will be checked" ); - uno::Reference xOwnCursor = createCursor(); + const uno::Reference xOwnCursor(m_rThis.CreateCursor()); - uno::Reference xTunnel( xOwnCursor, uno::UNO_QUERY); - OTextCursorHelper* pOwnCursor = 0; - if(xTunnel.is()) - { - pOwnCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()) )); - } + const uno::Reference xTunnel(xOwnCursor, uno::UNO_QUERY); + OTextCursorHelper *const pOwnCursor = + ::sw::UnoTunnelGetImplementation(xTunnel); DBG_ASSERT(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? "); - const SwStartNode* pOwnStartNode = pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode(); + const SwStartNode* pOwnStartNode = + pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode(); SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eCrsrType) + switch (m_eType) { case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; @@ -1022,101 +1058,62 @@ sal_Bool SwXText::CheckForOwnMember( ; } - const SwNode* pSrcNode; - if (pCursor) - { - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else // pRange - { - SwPaM aPam(pRange->GetDoc()->GetNodes().GetEndOfContent()); - if (pRange->GetPositions(aPam)) - { - pSrcNode = aPam.GetNode(); - } - } - if (!pSrcNode) { return sal_False; } + SwNode const*const pSrcNode(rPaM.GetNode()); + if (!pSrcNode) { return false; } const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) + { pTmp = pTmp->StartOfSectionNode(); + } //if the document starts with a section while(pOwnStartNode->IsSectionNode()) + { pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } //this checks if (this) and xRange are in the same text::XText interface - return(pOwnStartNode == pTmp); + return (pOwnStartNode == pTmp); } -sal_Int16 SwXText::ComparePositions( +sal_Int16 +SwXText::Impl::ComparePositions( const uno::Reference& xPos1, const uno::Reference& xPos2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - sal_Int16 nCompare = 0; - SwUnoInternalPaM aPam1(*GetDoc()); - SwUnoInternalPaM aPam2(*GetDoc()); + SwUnoInternalPaM aPam1(*m_pDoc); + SwUnoInternalPaM aPam2(*m_pDoc); - BOOL bExcept = FALSE; - if (::sw::XTextRangeToSwPaM(aPam1, xPos1) && - ::sw::XTextRangeToSwPaM(aPam2, xPos2)) + if (!::sw::XTextRangeToSwPaM(aPam1, xPos1) || + !::sw::XTextRangeToSwPaM(aPam2, xPos2)) { - uno::Reference xRangeTunnel1( xPos1, uno::UNO_QUERY); - SwXTextRange* pRange1 = 0; - OTextCursorHelper* pCursor1 = 0; - if(xRangeTunnel1.is()) - { - pRange1 = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel1->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor1 = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel1->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - uno::Reference xRangeTunnel2( xPos2, uno::UNO_QUERY); - SwXTextRange* pRange2 = 0; - OTextCursorHelper* pCursor2 = 0; - if(xRangeTunnel2.is()) - { - pRange2 = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel2->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor2 = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel2->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - - if((pRange1||pCursor1) && (pRange2||pCursor2)) - { - if(CheckForOwnMember(pRange1, pCursor1) - && CheckForOwnMember( pRange2, pCursor2)) - { - SwPosition const*const pStart1 = aPam1.Start(); - SwPosition const*const pStart2 = aPam2.Start(); + throw lang::IllegalArgumentException(); + } + if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2)) + { + throw lang::IllegalArgumentException(); + } - if(pStart1 && pStart2) - { - if(*pStart1 < *pStart2) - nCompare = 1; - else if(*pStart1 > *pStart2) - nCompare = -1; - else - { - DBG_ASSERT(*pStart1 == *pStart2, "SwPositions should be equal here"); - nCompare = 0; - } - } - else - bExcept = TRUE; - } - else - bExcept = TRUE; - } - else - bExcept = TRUE; + sal_Int16 nCompare = 0; + SwPosition const*const pStart1 = aPam1.Start(); + SwPosition const*const pStart2 = aPam2.Start(); + if (*pStart1 < *pStart2) + { + nCompare = 1; + } + else if (*pStart1 > *pStart2) + { + nCompare = -1; } else - bExcept = TRUE; - if(bExcept) - throw lang::IllegalArgumentException(); + { + DBG_ASSERT(*pStart1 == *pStart2, + "SwPositions should be equal here"); + nCompare = 0; + } return nCompare; } @@ -1124,50 +1121,64 @@ sal_Int16 SwXText::ComparePositions( /*-- 28.03.00 10:37:22--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int16 SwXText::compareRegionStarts( - const uno::Reference& xR1, - const uno::Reference& xR2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +sal_Int16 SAL_CALL +SwXText::compareRegionStarts( + const uno::Reference& xRange1, + const uno::Reference& xRange2) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xR1.is() || !xR2.is()) + + if (!xRange1.is() || !xRange2.is()) + { throw lang::IllegalArgumentException(); - uno::Reference xStart1 = xR1->getStart(); - uno::Reference xStart2 = xR2->getStart(); + } + const uno::Reference xStart1 = xRange1->getStart(); + const uno::Reference xStart2 = xRange2->getStart(); - return ComparePositions(xStart1, xStart2); + return m_pImpl->ComparePositions(xStart1, xStart2); } /*-- 28.03.00 10:37:25--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int16 SwXText::compareRegionEnds( - const uno::Reference& xR1, - const uno::Reference& xR2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +sal_Int16 SAL_CALL +SwXText::compareRegionEnds( + const uno::Reference& xRange1, + const uno::Reference& xRange2) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xR1.is() || !xR2.is()) + + if (!xRange1.is() || !xRange2.is()) + { throw lang::IllegalArgumentException(); - uno::Reference xEnd1 = xR1->getEnd(); - uno::Reference xEnd2 = xR2->getEnd(); + } + uno::Reference xEnd1 = xRange1->getEnd(); + uno::Reference xEnd2 = xRange2->getEnd(); - return ComparePositions(xEnd1, xEnd2); + return m_pImpl->ComparePositions(xEnd1, xEnd2); } /*-- 15.03.2002 12:30:40--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXText::getPropertySetInfo( ) - throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXText::getPropertySetInfo() throw(uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xInfo; } + /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const uno::Any& /*aValue*/ ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, +void SAL_CALL +SwXText::setPropertyValue(const ::rtl::OUString& /*aPropertyName*/, + const uno::Any& /*aValue*/) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { @@ -1176,100 +1187,113 @@ void SwXText::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXText::getPropertyValue( - const ::rtl::OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXText::getPropertyValue( + const ::rtl::OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + } + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + beans::UnknownPropertyException aExcept; + aExcept.Message = C2U("Unknown property: "); + aExcept.Message += rPropertyName; + throw aExcept; + } + uno::Any aRet; - if(pEntry) + switch (pEntry->nWID) { - switch(pEntry->nWID) - { // no code necessary - the redline is always located at the end node // case FN_UNO_REDLINE_NODE_START: // break; - case FN_UNO_REDLINE_NODE_END: + case FN_UNO_REDLINE_NODE_END: + { + const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl(); + const USHORT nRedTblCount = rRedTbl.Count(); + if (nRedTblCount > 0) { - const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl(); - USHORT nRedTblCount = rRedTbl.Count(); - if ( nRedTblCount > 0 ) + SwStartNode const*const pStartNode = GetStartNode(); + const ULONG nOwnIndex = pStartNode->EndOfSectionIndex(); + for (USHORT nRed = 0; nRed < nRedTblCount; nRed++) { - const SwStartNode* pStartNode = GetStartNode(); - ULONG nOwnIndex = pStartNode->EndOfSectionIndex(); - for(USHORT nRed = 0; nRed < nRedTblCount; nRed++) + SwRedline const*const pRedline = rRedTbl[nRed]; + SwPosition const*const pRedStart = pRedline->Start(); + const SwNodeIndex nRedNode = pRedStart->nNode; + if (nOwnIndex == nRedNode.GetIndex()) { - const SwRedline* pRedline = rRedTbl[nRed]; - const SwPosition* pRedStart = pRedline->Start(); - const SwNodeIndex nRedNode = pRedStart->nNode; - if(nOwnIndex == nRedNode.GetIndex()) - { - aRet <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, TRUE); - break; - } + aRet <<= SwXRedlinePortion::CreateRedlineProperties( + *pRedline, TRUE); + break; } } } - break; } - } - else - { - beans::UnknownPropertyException aExcept; - aExcept.Message = C2U("Unknown property: "); - aExcept.Message += rPropertyName; - throw aExcept; + break; } return aRet; - } + /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::addPropertyChangeListener( - const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::addPropertyChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removePropertyChangeListener( - const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::removePropertyChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::addVetoableChangeListener( - const ::rtl::OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::addVetoableChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removeVetoableChangeListener( - const ::rtl::OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, +void SAL_CALL +SwXText::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::removeVetoableChangeListener(): not implemented"); } /* -----------------------------08.01.01 09:07-------------------------------- @@ -1283,488 +1307,527 @@ const uno::Sequence< sal_Int8 > & SwXText::getUnoTunnelId() /* -----------------------------08.01.01 09:07-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SwXText::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXText::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } + /*-- 23.06.2006 08:56:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendParagraph( - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendParagraph( + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - return finishOrAppendParagraph(false, rProperties); + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->finishOrAppendParagraph(false, rProperties); } /*-- 23.06.2006 08:56:22--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::finishParagraph( - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::finishParagraph( + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - return finishOrAppendParagraph(true, rProperties); + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->finishOrAppendParagraph(true, rProperties); } /*-- 08.05.2006 13:26:26--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( - bool bFinish, - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) - +uno::Reference< text::XTextRange > +SwXText::Impl::finishOrAppendParagraph( + const bool bFinish, + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if (!m_bIsValid) + { throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet; + } - const SwStartNode* pStartNode = GetStartNode(); + const SwStartNode* pStartNode = m_rThis.GetStartNode(); if(!pStartNode) + { throw uno::RuntimeException(); + } + + uno::Reference< text::XTextRange > xRet; + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + m_pDoc->StartUndo(UNDO_START , NULL); + // find end node, go backward - don't skip tables because the new + // paragraph has to be the last node + //aPam.Move( fnMoveBackward, fnGoNode ); + SwPosition aInsertPosition( + SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) ); + SwPaM aPam(aInsertPosition); + m_pDoc->AppendTxtNode( *aPam.GetPoint() ); + // remove attributes from the previous paragraph + m_pDoc->ResetAttrs(aPam); + // in case of finishParagraph the PaM needs to be moved to the + // previous paragraph + if (bFinish) { - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_START , NULL); - //find end node, go backward - don't skip tables because the new paragraph has to be the last node - //aPam.Move( fnMoveBackward, fnGoNode ); - SwPosition aInsertPosition( SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) ); - SwPaM aPam(aInsertPosition); - pDoc->AppendTxtNode( *aPam.GetPoint() ); - //remove attributes from the previous paragraph - pDoc->ResetAttrs(aPam); - //in case of finishParagraph the PaM needs to be moved to the previous paragraph - if(bFinish) - aPam.Move( fnMoveBackward, fnGoNode ); - if(rProperties.getLength()) - { - // now set the properties - const SfxItemPropertySet* pParaPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); - const SfxItemPropertyMap* pParagraphMap = pParaPropSet->getPropertyMap(); + aPam.Move( fnMoveBackward, fnGoNode ); + } + if (rProperties.getLength()) + { + // now set the properties + SfxItemPropertySet const*const pParaPropSet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); + SfxItemPropertyMap const*const pParagraphMap = + pParaPropSet->getPropertyMap(); - const beans::PropertyValue* pValues = rProperties.getConstArray(); + const beans::PropertyValue* pValues = rProperties.getConstArray(); - for( sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp) + for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp) + { + if (!pParagraphMap->getByName(pValues[nProp].Name)) { - if(pParagraphMap->getByName( pValues[nProp].Name )) - { - try - { - SwUnoCursorHelper::SetPropertyValue( - aPam, *pParaPropSet, - pValues[nProp].Name, pValues[nProp].Value); - } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) - { - sMessage = rRuntime.Message; - bRuntimeException = true; - } - } - else - bIllegalException = true; - if( bIllegalException || bRuntimeException ) - { - break; - } + bIllegalException = true; + break; } - } - pDoc->EndUndo(UNDO_END, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) + try { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; + SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet, + pValues[nProp].Name, pValues[nProp].Value); } - else //if(bRuntimeException) + catch (lang::IllegalArgumentException& rIllegal) { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rIllegal.Message; + bIllegalException = true; + break; + } + catch (uno::RuntimeException& rRuntime) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + break; } } - SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); - OSL_ENSURE(pTxtNode, "no SwTxtNode?"); - if (pTxtNode) + } + m_pDoc->EndUndo(UNDO_END, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); + m_pDoc->Undo(aUndoIter); + if (bIllegalException) + { + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; + } + else // if(bRuntimeException) { - xRet.set(SwXParagraph::CreateXParagraph(*pDoc, *pTxtNode, this), uno::UNO_QUERY); + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; } } + SwTxtNode *const pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); + OSL_ENSURE(pTxtNode, "no SwTxtNode?"); + if (pTxtNode) + { + xRet.set(SwXParagraph::CreateXParagraph(*m_pDoc, *pTxtNode, &m_rThis), + uno::UNO_QUERY); + } return xRet; } + /*-- 08.05.2006 13:28:26--------------------------------------------------- Append text portions at the end of the last paragraph of the text interface. Support of import filters. -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendTextPortion( +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendTextPortion( const ::rtl::OUString& rText, - const uno::Sequence< beans::PropertyValue > & rCharacterAndParagraphProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue > & + rCharacterAndParagraphProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet; - uno::Reference< text::XTextCursor > xTextCursor = createCursor(); + } + uno::Reference< text::XTextRange > xRet; + const uno::Reference< text::XTextCursor > xTextCursor = CreateCursor(); xTextCursor->gotoEnd(sal_False); - uno::Reference< lang::XUnoTunnel > xRangeTunnel( xTextCursor, uno::UNO_QUERY_THROW ); - SwXTextCursor* pTextCursor = reinterpret_cast< SwXTextCursor * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextCursor::getUnoTunnelId()))); - { - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_INSERT, NULL); - -// SwPaM aPam(*pStartNode->EndOfSectionNode()); - //aPam.Move( fnMoveBackward, fnGoNode ); - SwUnoCrsr * pCursor = pTextCursor->GetCursor(); - pCursor->MovePara( fnParaCurr, fnParaEnd ); - pDoc->DontExpandFmt( *pCursor->Start() ); + const uno::Reference< lang::XUnoTunnel > xRangeTunnel( + xTextCursor, uno::UNO_QUERY_THROW ); + SwXTextCursor *const pTextCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); - if(rText.getLength()) - { - xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); - SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, - false ); - SwUnoCursorHelper::SelectPam(*pCursor, true); - pCursor->GetPoint()->nContent = nContentPos; - } + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); - if(rCharacterAndParagraphProperties.getLength()) +// SwPaM aPam(*pStartNode->EndOfSectionNode()); + //aPam.Move( fnMoveBackward, fnGoNode ); + SwUnoCrsr *const pCursor = pTextCursor->GetCursor(); + pCursor->MovePara( fnParaCurr, fnParaEnd ); + m_pImpl->m_pDoc->DontExpandFmt( *pCursor->Start() ); + + if (rText.getLength()) + { + const xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); + SwUnoCursorHelper::DocInsertStringSplitCR( + *m_pImpl->m_pDoc, *pCursor, rText, false); + SwUnoCursorHelper::SelectPam(*pCursor, true); + pCursor->GetPoint()->nContent = nContentPos; + } + + if (rCharacterAndParagraphProperties.getLength()) + { + SfxItemPropertyMap const*const pCursorMap = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR) + ->getPropertyMap(); + beans::PropertyValue const*const pValues = + rCharacterAndParagraphProperties.getConstArray(); + SfxItemPropertySet const*const pCursorPropSet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR); + const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength()); + for (sal_Int32 nProp = 0; nProp < nLen; ++nProp) { - const SfxItemPropertyMap* pCursorMap = aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap(); - const beans::PropertyValue* pValues = rCharacterAndParagraphProperties.getConstArray(); - const SfxItemPropertySet* pCursorPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR); - for( sal_Int32 nProp = 0; nProp < rCharacterAndParagraphProperties.getLength(); ++nProp) + if (!pCursorMap->getByName( pValues[nProp].Name )) { - if( pCursorMap->getByName( pValues[nProp].Name ) ) - { - try - { - SwUnoCursorHelper::SetPropertyValue( - *pCursor, *pCursorPropSet, - pValues[nProp].Name, pValues[nProp].Value, - nsSetAttrMode::SETATTR_NOFORMATATTR); - } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) - { - sMessage = rRuntime.Message; - bRuntimeException = true; - } - } - else - bIllegalException = true; - if( bIllegalException || bRuntimeException ) - { - break; - } + bIllegalException = true; + break; } - } - pDoc->EndUndo(UNDO_INSERT, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - delete pCursor; - pCursor = 0; - if(bIllegalException) + try { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; + SwUnoCursorHelper::SetPropertyValue( + *pCursor, *pCursorPropSet, + pValues[nProp].Name, pValues[nProp].Value, + nsSetAttrMode::SETATTR_NOFORMATATTR); } - else //if(bRuntimeException) + catch( lang::IllegalArgumentException& rIllegal ) { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rIllegal.Message; + bIllegalException = true; + break; + } + catch( uno::RuntimeException& rRuntime ) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + break; } } - xRet = new SwXTextRange(*pCursor, this); - delete pCursor; } - return xRet; + m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); + m_pImpl->m_pDoc->Undo(aUndoIter); + if (bIllegalException) + { + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; + } + else //if(bRuntimeException) + { + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; + } + } + xRet = new SwXTextRange(*pCursor, this); + return xRet; } + /*-- 11.05.2006 15:46:26--------------------------------------------------- enable appending text contents like graphic objects, shapes and so on to support import filters -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendTextContent( +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendTextContent( const uno::Reference< text::XTextContent >& xTextContent, - const uno::Sequence< beans::PropertyValue >& rCharacterAndParagraphProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& + rCharacterAndParagraphProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + + if (!IsValid()) + { throw uno::RuntimeException(); - const SwStartNode* pStartNode = GetStartNode(); + } + SwStartNode const*const pStartNode = GetStartNode(); if(!pStartNode) + { throw uno::RuntimeException(); + } + uno::Reference< text::XTextRange > xRet; + m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); + // find end node, go backward - don't skip tables because the + // new paragraph has to be the last node + SwPaM aPam(*pStartNode->EndOfSectionNode()); + aPam.Move( fnMoveBackward, fnGoNode ); + // set cursor to the end of the last text node + SwCursor aCursor( *aPam.Start(), 0, false ); + xRet = new SwXTextRange(aCursor, this); + aCursor.MovePara( fnParaCurr, fnParaEnd ); + m_pImpl->m_pDoc->DontExpandFmt( *aCursor.Start() ); + // now attach the text content here + insertTextContent( xRet, xTextContent, false ); + // now apply the properties to the anchor + if (rCharacterAndParagraphProperties.getLength()) { - pDoc->StartUndo(UNDO_INSERT, NULL); - //find end node, go backward - don't skip tables because the new paragraph has to be the last node - SwPaM aPam(*pStartNode->EndOfSectionNode()); - aPam.Move( fnMoveBackward, fnGoNode ); - //set cursor to the end of the last text node - SwCursor* pCursor = new SwCursor( *aPam.Start(),0,false ); - xRet = new SwXTextRange(*pCursor, this); - pCursor->MovePara( fnParaCurr, fnParaEnd ); - pDoc->DontExpandFmt( *pCursor->Start() ); - //now attach the text content here - insertTextContent( xRet, xTextContent, false ); - //now apply the properties to the anchor - if( rCharacterAndParagraphProperties.getLength()) + try { - try + const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength()); + const uno::Reference< beans::XPropertySet > xAnchor( + xTextContent->getAnchor(), uno::UNO_QUERY); + if (xAnchor.is()) { - uno::Reference< beans::XPropertySet > xAnchor( xTextContent->getAnchor(), uno::UNO_QUERY); - if( xAnchor.is() ) + for (sal_Int32 nElement = 0; nElement < nLen; ++nElement) { - for( sal_Int32 nElement = 0; nElement < rCharacterAndParagraphProperties.getLength(); ++nElement ) - { - xAnchor->setPropertyValue( rCharacterAndParagraphProperties[nElement].Name, rCharacterAndParagraphProperties[nElement].Value ); - } + xAnchor->setPropertyValue( + rCharacterAndParagraphProperties[nElement].Name, + rCharacterAndParagraphProperties[nElement].Value); } - - } - catch(const uno::Exception&) - { - throw uno::RuntimeException(); } } - delete pCursor; - pDoc->EndUndo(UNDO_INSERT, NULL); + catch (const uno::Exception&) + { + throw uno::RuntimeException(); + } } + m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); return xRet; } // move previously appended paragraphs into a text frames // to support import filters -uno::Reference< text::XTextContent > SwXText::convertToTextFrame( +uno::Reference< text::XTextContent > SAL_CALL +SwXText::convertToTextFrame( const uno::Reference< text::XTextRange >& xStart, const uno::Reference< text::XTextRange >& xEnd, - const uno::Sequence< beans::PropertyValue >& rFrameProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rFrameProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); + } uno::Reference< text::XTextContent > xRet; SwUnoInternalPaM aStartPam(*GetDoc()); - std::auto_ptr < SwUnoInternalPaM > pEndPam( new SwUnoInternalPaM(*GetDoc())); - if (::sw::XTextRangeToSwPaM(aStartPam, xStart) && - ::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) - { - uno::Reference xStartRangeTunnel( xStart, uno::UNO_QUERY); - SwXTextRange* pStartRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xStartRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - uno::Reference xEndRangeTunnel( xEnd, uno::UNO_QUERY); - SwXTextRange* pEndRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xEndRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - //bookmarks have to be removed before the referenced text node is deleted in DelFullPara - if(pStartRange) - { - pStartRange->Invalidate(); - } - if(pEndRange) - { - pEndRange->Invalidate(); - } + std::auto_ptr< SwUnoInternalPaM > pEndPam(new SwUnoInternalPaM(*GetDoc())); + if (!::sw::XTextRangeToSwPaM(aStartPam, xStart) || + !::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) + { + throw lang::IllegalArgumentException(); + } - pDoc->StartUndo( UNDO_START, NULL ); - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); - while(pStartStartNode && pStartStartNode->IsSectionNode()) + const uno::Reference xStartRangeTunnel(xStart, + uno::UNO_QUERY); + SwXTextRange *const pStartRange = + ::sw::UnoTunnelGetImplementation(xStartRangeTunnel); + const uno::Reference xEndRangeTunnel(xEnd, + uno::UNO_QUERY); + SwXTextRange *const pEndRange = + ::sw::UnoTunnelGetImplementation(xEndRangeTunnel); + // bookmarks have to be removed before the referenced text node + // is deleted in DelFullPara + if (pStartRange) + { + pStartRange->Invalidate(); + } + if (pEndRange) + { + pEndRange->Invalidate(); + } + + m_pImpl->m_pDoc->StartUndo( UNDO_START, NULL ); + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); + while (pStartStartNode && pStartStartNode->IsSectionNode()) + { + pStartStartNode = pStartStartNode->StartOfSectionNode(); + } + SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); + while (pEndStartNode && pEndStartNode->IsSectionNode()) + { + pEndStartNode = pEndStartNode->StartOfSectionNode(); + } + bool bParaAfterInserted = false; + bool bParaBeforeInserted = false; + if (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + { + // todo: if the start/end is in a table then insert a paragraph + // before/after, move the start/end nodes, then convert and + // remove the addtional paragraphs in the end + if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode) { - pStartStartNode = pStartStartNode->StartOfSectionNode(); + SwTableNode *const pSartTableNode(pStartStartNode->FindTableNode()); + const SwNodeIndex aTblIdx( *pSartTableNode, -1 ); + SwPosition aBefore(aTblIdx); + bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore ); + aStartPam.DeleteMark(); + *aStartPam.GetPoint() = aBefore; + pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); } - SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); - while(pEndStartNode && pEndStartNode->IsSectionNode()) + if (pEndStartNode->GetStartNodeType() == SwTableBoxStartNode) { - pEndStartNode = pEndStartNode->StartOfSectionNode(); + SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode(); + SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode(); + SwPosition aTableEnd(*pTableEnd); + bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd ); + pEndPam->DeleteMark(); + *pEndPam->GetPoint() = aTableEnd; + pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); } - bool bParaAfterInserted = false; - bool bParaBeforeInserted = false; - if(pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + // now we should have the positions in the same hierarchy + if ((pStartStartNode != pEndStartNode) || + (pStartStartNode != GetStartNode())) { - //todo: if the start/end is in a table then insert a paragraph before/after, move - //the start/end nodes, then convert and remove the addtional paragraphs in the end - if( pStartStartNode->GetStartNodeType() == SwTableBoxStartNode ) - { - SwTableNode* pSartTableNode = pStartStartNode->FindTableNode(); - SwNodeIndex aTblIdx( *pSartTableNode, -1 ); - SwPosition aBefore(aTblIdx); - bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore ); - aStartPam.DeleteMark(); - *aStartPam.GetPoint() = aBefore; - pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); - } - if( pEndStartNode->GetStartNodeType() == SwTableBoxStartNode ) + // if not - remove the additional paragraphs and throw + if (bParaBeforeInserted) { - SwTableNode* pEndTableNode = pEndStartNode->FindTableNode(); - SwEndNode* pTableEnd = pEndTableNode->EndOfSectionNode(); - SwPosition aTableEnd(*pTableEnd); - bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd ); - pEndPam->DeleteMark(); - *pEndPam->GetPoint() = aTableEnd; - pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); + SwCursor aDelete(*aStartPam.GetPoint(), 0, false); + aDelete.MovePara(fnParaCurr, fnParaStart); + aDelete.SetMark(); + aDelete.MovePara(fnParaCurr, fnParaEnd); + GetDoc()->DelFullPara(aDelete); } - //now we should have the positions in the same hierarchy - if(pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + if (bParaAfterInserted) { - //if not - remove the additional paragraphs and throw - if( bParaBeforeInserted ) - { - SwCursor aDelete(*aStartPam.GetPoint(), 0, false); - aDelete.MovePara(fnParaCurr, fnParaStart); - aDelete.SetMark(); - aDelete.MovePara(fnParaCurr, fnParaEnd); - GetDoc()->DelFullPara(aDelete); - } - if( bParaAfterInserted ) - { - SwCursor aDelete(*pEndPam->GetPoint(), 0, false); - aDelete.MovePara(fnParaCurr, fnParaStart); - aDelete.SetMark(); - aDelete.MovePara(fnParaCurr, fnParaEnd); - GetDoc()->DelFullPara(aDelete); - } - throw lang::IllegalArgumentException(); + SwCursor aDelete(*pEndPam->GetPoint(), 0, false); + aDelete.MovePara(fnParaCurr, fnParaStart); + aDelete.SetMark(); + aDelete.MovePara(fnParaCurr, fnParaEnd); + GetDoc()->DelFullPara(aDelete); } - } - - //make a selection from aStartPam to a EndPam - SwSelBoxes aBoxes; - SfxItemSet aFrameItemSet(pDoc->GetAttrPool(), - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - 0 ); - - aStartPam.SetMark(); - *aStartPam.End() = *pEndPam->End(); - pEndPam.reset(0); - - SwXTextFrame* pNewFrame; - uno::Reference< text::XTextFrame > xNewFrame = pNewFrame = new SwXTextFrame( pDoc ); - pNewFrame->SetSelection( aStartPam ); - try + throw lang::IllegalArgumentException(); + } + } + + // make a selection from aStartPam to a EndPam + SwSelBoxes aBoxes; + SfxItemSet aFrameItemSet(m_pImpl->m_pDoc->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0 ); + + aStartPam.SetMark(); + *aStartPam.End() = *pEndPam->End(); + pEndPam.reset(0); + + SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc); + const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame; + pNewFrame->SetSelection( aStartPam ); + try + { + const beans::PropertyValue* pValues = rFrameProperties.getConstArray(); + for (sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp) + { + pNewFrame->SwXFrame::setPropertyValue( + pValues[nProp].Name, pValues[nProp].Value); + } + + { // has to be in a block to remove the SwIndexes before + // DelFullPara is called + const uno::Reference< text::XTextRange> xInsertTextRange = + new SwXTextRange(aStartPam, this); + pNewFrame->attach( xInsertTextRange ); + pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName()); + } + + if (!aStartPam.GetTxt().Len()) { - const beans::PropertyValue* pValues = rFrameProperties.getConstArray(); - for(sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp) - pNewFrame->SwXFrame::setPropertyValue(pValues[nProp].Name, pValues[nProp].Value); - - {//has to be in a block to remove the SwIndexes before DelFullPara is called - uno::Reference< text::XTextRange> xInsertTextRange = new SwXTextRange(aStartPam, this); - pNewFrame->attach( xInsertTextRange ); - pNewFrame->setName(pDoc->GetUniqueFrameName()); + bool bMoved = false; + { // has to be in a block to remove the SwIndexes before + // DelFullPara is called + SwPaM aMovePam( *aStartPam.GetNode() ); + if (aMovePam.Move( fnMoveForward, fnGoCntnt )) + { + // move the anchor to the next paragraph + SwFmtAnchor aNewAnchor(pNewFrame->GetFrmFmt()->GetAnchor()); + aNewAnchor.SetAnchor( aMovePam.Start() ); + m_pImpl->m_pDoc->SetAttr( + aNewAnchor, *pNewFrame->GetFrmFmt() ); + } + bMoved = true; } - - if( !aStartPam.GetTxt().Len() ) + if (bMoved) { - - bool bMoved = false; - {//has to be in a block to remove the SwIndexes before DelFullPara is called - SwPaM aMovePam( *aStartPam.GetNode() ); - if( aMovePam.Move( fnMoveForward, fnGoCntnt ) ) - { - //move the anchor to the next paragraph - SwFmtAnchor aNewAnchor( pNewFrame->GetFrmFmt()->GetAnchor() ); - aNewAnchor.SetAnchor( aMovePam.Start() ); - pDoc->SetAttr( aNewAnchor, *pNewFrame->GetFrmFmt() ); - } - bMoved = true; - } - if(bMoved) - { - aStartPam.DeleteMark(); + aStartPam.DeleteMark(); // SwPaM aDelPam( *aStartPam.GetNode() ); - pDoc->DelFullPara(aStartPam/*aDelPam*/); - } + m_pImpl->m_pDoc->DelFullPara(aStartPam/*aDelPam*/); } } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) + } + catch (lang::IllegalArgumentException& rIllegal) + { + sMessage = rIllegal.Message; + bIllegalException = true; + } + catch (uno::RuntimeException& rRuntime) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + } + xRet = pNewFrame; + if (bParaBeforeInserted || bParaAfterInserted) + { + const uno::Reference xFrameTextCursor = + pNewFrame->createTextCursor(); + const uno::Reference xTunnel(xFrameTextCursor, + uno::UNO_QUERY); + SwXTextCursor *const pFrameCursor = + ::sw::UnoTunnelGetImplementation(xTunnel); + if (bParaBeforeInserted) { - sMessage = rRuntime.Message; - bRuntimeException = true; + // todo: remove paragraph before frame + m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM()); } - xRet = pNewFrame; - uno::Reference xFrameTextCursor; - if( bParaBeforeInserted ) + if (bParaAfterInserted) { - //todo: remove paragraph before frame - xFrameTextCursor = pNewFrame->createTextCursor(); - uno::Reference xTunnel(xFrameTextCursor, uno::UNO_QUERY); - SwXTextCursor* pFrameCursor = reinterpret_cast< SwXTextCursor* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextCursor::getUnoTunnelId()) )); - pDoc->DelFullPara(*pFrameCursor->GetPaM()); + xFrameTextCursor->gotoEnd(sal_False); + m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM()); } - if( bParaAfterInserted ) + } + + m_pImpl->m_pDoc->EndUndo(UNDO_END, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); + m_pImpl->m_pDoc->Undo(aUndoIter); + if (bIllegalException) { - //todo: remove paragraph after frame - if( xFrameTextCursor.is() ) - xFrameTextCursor = pNewFrame->createTextCursor(); - xFrameTextCursor->gotoEnd( false ); - uno::Reference xTunnel(xFrameTextCursor, uno::UNO_QUERY); - SwXTextCursor* pFrameCursor = reinterpret_cast< SwXTextCursor* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextCursor::getUnoTunnelId()) )); - pDoc->DelFullPara(*pFrameCursor->GetPaM()); + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; } - - pDoc->EndUndo(UNDO_END, NULL); - if( bIllegalException || bRuntimeException ) + else //if(bRuntimeException) { - SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) - { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; - } - else //if(bRuntimeException) - { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; - } + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; } } - else - throw lang::IllegalArgumentException(); return xRet; } + /*-- 11.05.2006 15:46:26--------------------------------------------------- Move previously imported paragraphs into a new text table. @@ -1788,12 +1851,15 @@ bool lcl_SimilarPosition( sal_Int32 nPos1, sal_Int32 nPos2 ) return abs( nPos1 - nPos2 ) < COL_POS_FUZZY; } -uno::Reference< text::XTextTable > SwXText::convertToTable( - const uno::Sequence< uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > > >& rTableRanges, - const uno::Sequence< uno::Sequence< uno::Sequence< beans::PropertyValue > > >& rCellProperties, +uno::Reference< text::XTextTable > SAL_CALL +SwXText::convertToTable( + const uno::Sequence< uno::Sequence< uno::Sequence< + uno::Reference< text::XTextRange > > > >& rTableRanges, + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties, const uno::Sequence< uno::Sequence< beans::PropertyValue > >& rRowProperties, - const uno::Sequence< beans::PropertyValue >& rTableProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rTableProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) @@ -1804,7 +1870,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( std::auto_ptr < SwPaM > pFirstPaM; std::vector< std::vector > aTableNodes; bool bExcept = false; - SwPaM aLastPaM(pDoc->GetNodes()); + SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); for( sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); ++nRow) { std::vector aRowNodes; @@ -1817,8 +1883,8 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( throw lang::IllegalArgumentException(); const uno::Reference< text::XTextRange > xStartRange = pRow[nCell][0]; const uno::Reference< text::XTextRange > xEndRange = pRow[nCell][1]; - SwUnoInternalPaM aStartCellPam(*pDoc); - SwUnoInternalPaM aEndCellPam(*pDoc); + SwUnoInternalPaM aStartCellPam(*m_pImpl->m_pDoc); + SwUnoInternalPaM aEndCellPam(*m_pImpl->m_pDoc); // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! @@ -1865,7 +1931,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( { //align the beginning - if necessary if(aStartCellPam.Start()->nContent.GetIndex()) - pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); } else { @@ -1880,7 +1946,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( bExcept = true; else { - pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); } } else if(nStartCellNodeIndex == ( nLastNodeEndIndex + 1)) @@ -1898,7 +1964,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( //now check if there's a need to insert another paragraph break if( aEndCellPam.End()->nContent.GetIndex() < aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) { - pDoc->SplitNode(*aEndCellPam.End(), sal_False); + m_pImpl->m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); //take care that the new start/endcell is moved to the right position //aStartCellPam has to point to the start of the new (previous) node //aEndCellPam has to point the the end of the new (previous) node @@ -1931,7 +1997,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( if(bExcept) { SwUndoIter aUndoIter( &aLastPaM, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->Undo(aUndoIter); throw lang::IllegalArgumentException(); } @@ -1939,7 +2005,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( std::vector< TableColumnSeparators > aRowSeparators(rRowProperties.getLength()); std::vector aMergedCells; - const SwTable* pTable = pDoc->TextToTable( aTableNodes ); + const SwTable* pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); SwXTextTable* pTextTable = 0; uno::Reference< text::XTextTable > xRet = pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); uno::Reference< beans::XPropertySet > xPrSet = pTextTable; @@ -2159,12 +2225,12 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( bool bIllegalException = false; bool bRuntimeException = false; ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_START, NULL); - pDoc->EndUndo(UNDO_START, NULL); + m_pImpl->m_pDoc->StartUndo(UNDO_START, NULL); + m_pImpl->m_pDoc->EndUndo(UNDO_START, NULL); if( bIllegalException || bRuntimeException ) { SwUndoIter aUndoIter( pFirstPaM.get(), UNDO_EMPTY ); - pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->Undo(aUndoIter); if(bIllegalException) { lang::IllegalArgumentException aEx; @@ -2493,7 +2559,8 @@ const SwStartNode *SwXHeadFootText::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXHeadFootText::createCursor() throw(uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXHeadFootText::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } -- cgit v1.2.3 From a9e1a67de6aefe1231e00f5531e1f4ec7d6296a7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:56 +0100 Subject: swunolocking1: #i105557#: clean up implementation of SwXText::convertToTable(). --- sw/source/core/unocore/unotext.cxx | 747 +++++++++++++++++++++---------------- 1 file changed, 423 insertions(+), 324 deletions(-) diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 82ad2cccc9..b96aec2bd3 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -123,6 +123,15 @@ public: bool CheckForOwnMember(const SwPaM & rPaM) throw (lang::IllegalArgumentException, uno::RuntimeException); + + void ConvertCell( + const bool bFirstCell, + const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, + ::std::vector & rRowNodes, + ::std::auto_ptr< SwPaM > & rpFirstPaM, + SwPaM & rLastPaM, + bool & rbExcept); + }; /* -----------------------------15.03.2002 12:39------------------------------ @@ -1838,158 +1847,407 @@ struct VerticallyMergedCell sal_Int32 nLeftPosition; bool bOpen; - VerticallyMergedCell( uno::Reference< beans::XPropertySet >& rxCell, sal_Int32 nLeft ) : - nLeftPosition( nLeft ), - bOpen( true ) - { - aCells.push_back( rxCell ); - } + VerticallyMergedCell(uno::Reference< beans::XPropertySet > const& rxCell, + const sal_Int32 nLeft) + : nLeftPosition( nLeft ) + , bOpen( true ) + { + aCells.push_back( rxCell ); + } }; #define COL_POS_FUZZY 2 -bool lcl_SimilarPosition( sal_Int32 nPos1, sal_Int32 nPos2 ) +static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 ) { return abs( nPos1 - nPos2 ) < COL_POS_FUZZY; } -uno::Reference< text::XTextTable > SAL_CALL -SwXText::convertToTable( - const uno::Sequence< uno::Sequence< uno::Sequence< - uno::Reference< text::XTextRange > > > >& rTableRanges, - const uno::Sequence< uno::Sequence< uno::Sequence< - beans::PropertyValue > > >& rCellProperties, - const uno::Sequence< uno::Sequence< beans::PropertyValue > >& rRowProperties, - const uno::Sequence< beans::PropertyValue >& rTableProperties) -throw (lang::IllegalArgumentException, uno::RuntimeException) +void SwXText::Impl::ConvertCell( + const bool bFirstCell, + const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, + ::std::vector & rRowNodes, + ::std::auto_ptr< SwPaM > & rpFirstPaM, + SwPaM & rLastPaM, + bool & rbExcept) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) - throw uno::RuntimeException(); + if (rCell.getLength() != 2) + { + throw lang::IllegalArgumentException(); + } + const uno::Reference xStartRange = rCell[0]; + const uno::Reference xEndRange = rCell[1]; + SwUnoInternalPaM aStartCellPam(*m_pDoc); + SwUnoInternalPaM aEndCellPam(*m_pDoc); - //at first collect the text ranges as SwPaMs - const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* pTableRanges = rTableRanges.getConstArray(); - std::auto_ptr < SwPaM > pFirstPaM; - std::vector< std::vector > aTableNodes; - bool bExcept = false; - SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); - for( sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); ++nRow) + // !!! TODO - PaMs in tables and sections do not work here - + // the same applies to PaMs in frames !!! + + if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || + !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) { - std::vector aRowNodes; - const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >& rRow = pTableRanges[nRow]; - const uno::Sequence< uno::Reference< text::XTextRange > >* pRow = pTableRanges[nRow].getConstArray(); + throw lang::IllegalArgumentException(); + } + /** check the nodes between start and end + it is allowed to have pairs of StartNode/EndNodes + */ + if (aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode) + { + // increment on each StartNode and decrement on each EndNode + // we must reach zero at the end and must not go below zero + long nOpenNodeBlock = 0; + SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode; + while (aCellIndex < aEndCellPam.End()->nNode.GetIndex()) + { + if (aCellIndex.GetNode().IsStartNode()) + { + ++nOpenNodeBlock; + } + else if (aCellIndex.GetNode().IsEndNode()) + { + --nOpenNodeBlock; + } + if (nOpenNodeBlock < 0) + { + rbExcept = true; + break; + } + ++aCellIndex; + } + if (nOpenNodeBlock != 0) + { + rbExcept = true; + return; + } + } - for( sal_Int32 nCell = 0; nCell < rRow.getLength(); ++nCell) + /** The vector NodeRanges has to contain consecutive nodes. + In rTableRanges the ranges don't need to be full paragraphs but + they have to follow each other. To process the ranges they + have to be aligned on paragraph borders by inserting paragraph + breaks. Non-consecutive ranges must initiate an exception. + */ + if (bFirstCell) + { + // align the beginning - if necessary + if (aStartCellPam.Start()->nContent.GetIndex()) { - if( pRow[nCell].getLength() != 2 ) - throw lang::IllegalArgumentException(); - const uno::Reference< text::XTextRange > xStartRange = pRow[nCell][0]; - const uno::Reference< text::XTextRange > xEndRange = pRow[nCell][1]; - SwUnoInternalPaM aStartCellPam(*m_pImpl->m_pDoc); - SwUnoInternalPaM aEndCellPam(*m_pImpl->m_pDoc); - - // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! - - if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || - !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) - throw lang::IllegalArgumentException(); - /** check the nodes between start and end - it is allowed to have pairs of StartNode/EndNodes - */ - if(aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode) + m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + } + } + else + { + // check the predecessor + const ULONG nLastNodeIndex = rLastPaM.End()->nNode.GetIndex(); + const ULONG nStartCellNodeIndex = + aStartCellPam.Start()->nNode.GetIndex(); + const ULONG nLastNodeEndIndex = rLastPaM.End()->nNode.GetIndex(); + if (nLastNodeIndex == nStartCellNodeIndex) + { + // same node as predecessor then equal nContent? + if (rLastPaM.End()->nContent != aStartCellPam.Start()->nContent) { - // increment on each StartNode and decrement on each EndNode - // we must reach zero at the end and must not go below zero - long nOpenNodeBlock = 0; - SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode; - while( aCellIndex < aEndCellPam.End()->nNode.GetIndex()) - { - if( aCellIndex.GetNode().IsStartNode() ) - ++nOpenNodeBlock; - else if(aCellIndex.GetNode().IsEndNode() ) - --nOpenNodeBlock; - if( nOpenNodeBlock < 0 ) - { - bExcept = true; - break; - } - ++aCellIndex; - } - if( nOpenNodeBlock != 0) - { - bExcept = true; - break; - } + rbExcept = true; } + else + { + m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + } + } + else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1)) + { + // next paragraph - now the content index of the new should be 0 + // and of the old one should be equal to the text length + // but if it isn't we don't care - the cell is being inserted on + // the node border anyway + } + else + { + rbExcept = true; + } + } + // now check if there's a need to insert another paragraph break + if (aEndCellPam.End()->nContent.GetIndex() < + aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) + { + m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); + // take care that the new start/endcell is moved to the right position + // aStartCellPam has to point to the start of the new (previous) node + // aEndCellPam has to point to the end of the new (previous) node + aStartCellPam.DeleteMark(); + aStartCellPam.Move(fnMoveBackward, fnGoNode); + aStartCellPam.GetPoint()->nContent = 0; + aEndCellPam.DeleteMark(); + aEndCellPam.Move(fnMoveBackward, fnGoNode); + aEndCellPam.GetPoint()->nContent = + aEndCellPam.GetNode()->GetTxtNode()->Len(); + } + + *rLastPaM.GetPoint() = *aEndCellPam.Start(); + if (aStartCellPam.HasMark()) + { + rLastPaM.SetMark(); + *rLastPaM.GetMark() = *aEndCellPam.End(); + } + else + { + rLastPaM.DeleteMark(); + } + + SwNodeRange aCellRange(aStartCellPam.Start()->nNode, + aEndCellPam.End()->nNode); + rRowNodes.push_back(aCellRange); + if (bFirstCell) + { + rpFirstPaM.reset(new SwPaM(*aStartCellPam.Start())); + } +} + +typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators; + +static void +lcl_ApplyRowProperties( + uno::Sequence const& rRowProperties, + uno::Any const& rRow, + TableColumnSeparators & rRowSeparators) +{ + uno::Reference< beans::XPropertySet > xRow; + rRow >>= xRow; + const beans::PropertyValue* pProperties = rRowProperties.getConstArray(); + for (sal_Int32 nProperty = 0; nProperty < rRowProperties.getLength(); + ++nProperty) + { + if (pProperties[ nProperty ].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TableColumnSeparators"))) + { + // add the separators to access the cell's positions + // for vertical merging later + TableColumnSeparators aSeparators; + pProperties[ nProperty ].Value >>= aSeparators; + rRowSeparators = aSeparators; + } + xRow->setPropertyValue( + pProperties[ nProperty ].Name, pProperties[ nProperty ].Value); + } +} + +#ifdef DEBUG +//-->debug cell properties of all rows +static void +lcl_DebugCellProperties( + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties) +{ + ::rtl::OUString sNames; + for (sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength(); + ++nDebugRow) + { + const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = + rCellProperties[nDebugRow]; + sal_Int32 nDebugCells = aDebugCurrentRow.getLength(); + (void) nDebugCells; + for (sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells; + ++nDebugCell) + { + const uno::Sequence< beans::PropertyValue >& + rDebugCellProperties = aDebugCurrentRow[nDebugCell]; + const sal_Int32 nDebugCellProperties = + rDebugCellProperties.getLength(); + for (sal_Int32 nDebugProperty = 0; + nDebugProperty < nDebugCellProperties; ++nDebugProperty) + { + const ::rtl::OUString sName = + rDebugCellProperties[nDebugProperty].Name; + sNames += sName; + sNames += ::rtl::OUString('-'); + } + sNames += ::rtl::OUString('+'); + } + sNames += ::rtl::OUString('|'); + } + (void)sNames; +} +//--< +#endif - /** The vector NodeRanges has to contain consecutive nodes. - In rTableRanges the ranges don't need to be full paragraphs but they have to follow - each other. To process the ranges they have to be aligned on paragraph borders - by inserting paragraph breaks. Non-consecutive ranges must initiate an - exception. - */ - if(!nRow && !nCell) +static void +lcl_ApplyCellProperties( + const sal_Int32 nCell, + TableColumnSeparators const& rRowSeparators, + const uno::Sequence< beans::PropertyValue >& rCellProperties, + uno::Reference< uno::XInterface > xCell, + ::std::vector & rMergedCells) +{ + const sal_Int32 nCellProperties = rCellProperties.getLength(); + const uno::Reference< beans::XPropertySet > xCellPS(xCell, uno::UNO_QUERY); + for (sal_Int32 nProperty = 0; nProperty < nCellProperties; ++nProperty) + { + const OUString & rName = rCellProperties[nProperty].Name; + const uno::Any & rValue = rCellProperties[nProperty].Value; + if (rName.equalsAscii("VerticalMerge")) + { + // determine left border position + // add the cell to a queue of merged cells + sal_Bool bMerge = sal_False; + rValue >>= bMerge; + sal_Int32 nLeftPos = -1; + if (!nCell) { - //align the beginning - if necessary - if(aStartCellPam.Start()->nContent.GetIndex()) - m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + nLeftPos = 0; } - else + else if (rRowSeparators.getLength() >= nCell) { - //check the predecessor - ULONG nLastNodeIndex = aLastPaM.End()->nNode.GetIndex(); - ULONG nStartCellNodeIndex = aStartCellPam.Start()->nNode.GetIndex(); - ULONG nLastNodeEndIndex = aLastPaM.End()->nNode.GetIndex(); - if( nLastNodeIndex == nStartCellNodeIndex) + const text::TableColumnSeparator* pSeparators = + rRowSeparators.getConstArray(); + nLeftPos = pSeparators[nCell - 1].Position; + } + if (bMerge) + { + // 'close' all the cell with the same left position + // if separate vertical merges in the same column exist + if (rMergedCells.size()) { - //- same node as predecessor then equal nContent? - if(aLastPaM.End()->nContent != aStartCellPam.Start()->nContent) - bExcept = true; - else + std::vector::iterator aMergedIter = + rMergedCells.begin(); + while (aMergedIter != rMergedCells.end()) { - m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + if (lcl_SimilarPosition(aMergedIter->nLeftPosition, + nLeftPos)) + { + aMergedIter->bOpen = false; + } + ++aMergedIter; } } - else if(nStartCellNodeIndex == ( nLastNodeEndIndex + 1)) - { - //next paragraph - now the content index of the new should be 0 - //and of the old one should be equal to the text length - //but if it isn't we don't care - the cell is being inserted on the - //node border anyway - } - else + // add the new group of merged cells + rMergedCells.push_back(VerticallyMergedCell(xCellPS, nLeftPos)); + } + else + { + // find the cell that + DBG_ASSERT(rMergedCells.size(), + "the first merged cell is missing"); + if (rMergedCells.size()) { - bExcept = true; + std::vector::iterator aMergedIter = + rMergedCells.begin(); +#if OSL_DEBUG_LEVEL > 1 + bool bDbgFound = false; +#endif + while (aMergedIter != rMergedCells.end()) + { + if (aMergedIter->bOpen && + lcl_SimilarPosition(aMergedIter->nLeftPosition, + nLeftPos)) + { + aMergedIter->aCells.push_back( xCellPS ); +#if OSL_DEBUG_LEVEL > 1 + bDbgFound = true; +#endif + } + ++aMergedIter; + } +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( bDbgFound, + "couldn't find first vertically merged cell" ); +#endif } } - //now check if there's a need to insert another paragraph break - if( aEndCellPam.End()->nContent.GetIndex() < aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) - { - m_pImpl->m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); - //take care that the new start/endcell is moved to the right position - //aStartCellPam has to point to the start of the new (previous) node - //aEndCellPam has to point the the end of the new (previous) node - aStartCellPam.DeleteMark(); - aStartCellPam.Move(fnMoveBackward, fnGoNode); - aStartCellPam.GetPoint()->nContent = 0; - aEndCellPam.DeleteMark(); - aEndCellPam.Move(fnMoveBackward, fnGoNode); - aEndCellPam.GetPoint()->nContent = aEndCellPam.GetNode()->GetTxtNode()->Len(); - - } - - *aLastPaM.GetPoint() = *aEndCellPam.Start(); - if( aStartCellPam.HasMark() ) + } + else + { + try + { + xCellPS->setPropertyValue(rName, rValue); + } + catch (uno::Exception const& e) { - aLastPaM.SetMark(); - *aLastPaM.GetMark() = *aEndCellPam.End(); + // Apply the paragraph and char properties to the cell's content + const uno::Reference< text::XText > xCellText(xCell, + uno::UNO_QUERY); + const uno::Reference< text::XTextCursor > xCellCurs = + xCellText->createTextCursor(); + xCellCurs->gotoStart( sal_False ); + xCellCurs->gotoEnd( sal_True ); + const uno::Reference< beans::XPropertySet > xCellTextProps( + xCellCurs, uno::UNO_QUERY); + xCellTextProps->setPropertyValue(rName, rValue); } - else - aLastPaM.DeleteMark(); + } + } +} - SwNodeRange aCellRange( aStartCellPam.Start()->nNode, aEndCellPam.End()->nNode); - aRowNodes.push_back(aCellRange); - if( !nRow && !nCell ) - pFirstPaM.reset( new SwPaM(*aStartCellPam.Start())); +static void +lcl_MergeCells(::std::vector & rMergedCells) +{ + if (rMergedCells.size()) + { + std::vector::iterator aMergedIter = + rMergedCells.begin(); + while (aMergedIter != rMergedCells.end()) + { + sal_Int32 nCellCount = + static_cast(aMergedIter->aCells.size()); + std::vector >::iterator + aCellIter = aMergedIter->aCells.begin(); + bool bFirstCell = true; + // the first of the cells gets the number of cells set as RowSpan + // the others get the inverted number of remaining merged cells + // (3,-2,-1) + while (aCellIter != aMergedIter->aCells.end()) + { + (*aCellIter)->setPropertyValue( + C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)), + uno::makeAny(nCellCount)); + if (bFirstCell) + { + nCellCount *= -1; + bFirstCell = false; + } + ++nCellCount; + ++aCellIter; + } + ++aMergedIter; + } + } +} + +uno::Reference< text::XTextTable > SAL_CALL +SwXText::convertToTable( + const uno::Sequence< uno::Sequence< uno::Sequence< + uno::Reference< text::XTextRange > > > >& rTableRanges, + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties, + const uno::Sequence< uno::Sequence< beans::PropertyValue > >& + rRowProperties, + const uno::Sequence< beans::PropertyValue >& rTableProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + if(!IsValid()) + { + throw uno::RuntimeException(); + } + + //at first collect the text ranges as SwPaMs + const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* + pTableRanges = rTableRanges.getConstArray(); + std::auto_ptr < SwPaM > pFirstPaM; + std::vector< std::vector > aTableNodes; + bool bExcept = false; + SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); + for (sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); + ++nRow) + { + std::vector aRowNodes; + const uno::Sequence< uno::Reference< text::XTextRange > >* pRow = + pTableRanges[nRow].getConstArray(); + const sal_Int32 nCells(pTableRanges[nRow].getLength()); + + for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) + { + m_pImpl->ConvertCell((nCell == 0) && (nRow == 0), pRow[nCell], + aRowNodes, pFirstPaM, aLastPaM, bExcept); } aTableNodes.push_back(aRowNodes); } @@ -2001,216 +2259,80 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) throw lang::IllegalArgumentException(); } - typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators; - std::vector< TableColumnSeparators > aRowSeparators(rRowProperties.getLength()); - std::vector aMergedCells; + std::vector< TableColumnSeparators > + aRowSeparators(rRowProperties.getLength()); + std::vector aMergedCells; - const SwTable* pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); - SwXTextTable* pTextTable = 0; - uno::Reference< text::XTextTable > xRet = pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); - uno::Reference< beans::XPropertySet > xPrSet = pTextTable; - // set properties to the table - catch lang::WrappedTargetException and lang::IndexOutOfBoundsException + SwTable const*const pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); + SwXTextTable *const pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); + const uno::Reference< text::XTextTable > xRet = pTextTable; + const uno::Reference< beans::XPropertySet > xPrSet = pTextTable; + // set properties to the table + // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException try { //apply table properties - const beans::PropertyValue* pTableProperties = rTableProperties.getConstArray(); - sal_Int32 nProperty = 0; - for( ; nProperty < rTableProperties.getLength(); ++nProperty) + const beans::PropertyValue* pTableProperties = + rTableProperties.getConstArray(); + for (sal_Int32 nProperty = 0; nProperty < rTableProperties.getLength(); + ++nProperty) { - try + try { - xPrSet->setPropertyValue( pTableProperties[nProperty].Name, pTableProperties[nProperty].Value ); + xPrSet->setPropertyValue( pTableProperties[nProperty].Name, + pTableProperties[nProperty].Value ); } - catch ( const uno::Exception e ) + catch ( uno::Exception const& e ) { #if DEBUG std::clog << "Exception when setting property: "; - std::clog << rtl::OUStringToOString( pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8 ).getStr( ); + std::clog << rtl::OUStringToOString( + pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8) + .getStr(); std::clog << ". Message: "; - std::clog << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ); + std::clog << rtl::OUStringToOString( e.Message, + RTL_TEXTENCODING_UTF8 ).getStr(); std::clog << std::endl; #endif } } //apply row properties - uno::Reference< table::XTableRows > xRows = xRet->getRows(); - const beans::PropertyValues* pRowProperties = rRowProperties.getConstArray(); - sal_Int32 nRow = 0; - for( ; nRow < xRows->getCount(); ++nRow) + const uno::Reference< table::XTableRows > xRows = xRet->getRows(); + + const beans::PropertyValues* pRowProperties = + rRowProperties.getConstArray(); + for (sal_Int32 nRow = 0; nRow < xRows->getCount(); ++nRow) { if( nRow >= rRowProperties.getLength()) { break; } - uno::Reference< beans::XPropertySet > xRow; - xRows->getByIndex( nRow ) >>= xRow; - const beans::PropertyValue* pProperties = pRowProperties[nRow].getConstArray(); - for( nProperty = 0; nProperty < pRowProperties[nRow].getLength(); ++nProperty) - { - if( pProperties[ nProperty ].Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM ( "TableColumnSeparators" ))) - { - //add the separators to access the cell's positions for vertical merging later - TableColumnSeparators aSeparators; - pProperties[ nProperty ].Value >>= aSeparators; - aRowSeparators[nRow] = aSeparators; - } - xRow->setPropertyValue( pProperties[ nProperty ].Name, pProperties[ nProperty ].Value ); - } + lcl_ApplyRowProperties(pRowProperties[nRow], + xRows->getByIndex(nRow), aRowSeparators[nRow]); } #ifdef DEBUG -//-->debug cell properties of all rows - { - ::rtl::OUString sNames; - for( sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength(); ++nDebugRow) - { - const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = rCellProperties[nDebugRow]; - sal_Int32 nDebugCells = aDebugCurrentRow.getLength(); - (void) nDebugCells; - for( sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells; ++nDebugCell) - { - const uno::Sequence< beans::PropertyValue >& aDebugCellProperties = aDebugCurrentRow[nDebugCell]; - sal_Int32 nDebugCellProperties = aDebugCellProperties.getLength(); - for( sal_Int32 nDebugProperty = 0; nDebugProperty < nDebugCellProperties; ++nDebugProperty) - { - const ::rtl::OUString sName = aDebugCellProperties[nDebugProperty].Name; - sNames += sName; - sNames += ::rtl::OUString('-'); - } - sNames += ::rtl::OUString('+'); - } - sNames += ::rtl::OUString('|'); - } - (void)sNames; - } -//--< + lcl_DebugCellProperties(rCellProperties); #endif - //apply cell properties - for( nRow = 0; nRow < rCellProperties.getLength(); ++nRow) + for (sal_Int32 nRow = 0; nRow < rCellProperties.getLength(); ++nRow) { - const uno::Sequence< beans::PropertyValues > aCurrentRow = rCellProperties[nRow]; + const uno::Sequence< beans::PropertyValues > aCurrentRow = + rCellProperties[nRow]; sal_Int32 nCells = aCurrentRow.getLength(); - for( sal_Int32 nCell = 0; nCell < nCells; ++nCell) - { - const uno::Sequence< beans::PropertyValue >& aCellProperties = aCurrentRow[nCell]; - sal_Int32 nCellProperties = aCellProperties.getLength(); - uno::Reference< beans::XPropertySet > xCell( pTextTable->getCellByPosition(nCell, nRow), uno::UNO_QUERY ); - for( nProperty = 0; nProperty < nCellProperties; ++nProperty) - { - const OUString& rName = aCellProperties[nProperty].Name; - if( rName.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM ( "VerticalMerge"))) - { - //determine left border position - //add the cell to a queue of merged cells - // - sal_Bool bMerge = sal_False; - aCellProperties[nProperty].Value >>= bMerge; - sal_Int32 nLeftPos = -1; - if( !nCell ) - nLeftPos = 0; - else if( aRowSeparators[nRow].getLength() >= nCell ) - { - const text::TableColumnSeparator* pSeparators = aRowSeparators[nRow].getConstArray(); - nLeftPos = pSeparators[nCell - 1].Position; - } - if( bMerge ) - { - // 'close' all the cell with the same left position - // if separate vertical merges in the same column exist - if( aMergedCells.size() ) - { - std::vector::iterator aMergedIter = aMergedCells.begin(); - while( aMergedIter != aMergedCells.end()) - { - if( lcl_SimilarPosition( aMergedIter->nLeftPosition, nLeftPos) ) - { - aMergedIter->bOpen = false; - } - ++aMergedIter; - } - } - //add the new group of merged cells - aMergedCells.push_back(VerticallyMergedCell(xCell, nLeftPos )); - } - else - { - //find the cell that - DBG_ASSERT(aMergedCells.size(), "the first merged cell is missing"); - if( aMergedCells.size() ) - { - std::vector::iterator aMergedIter = aMergedCells.begin(); -#if OSL_DEBUG_LEVEL > 1 - bool bDbgFound = false; -#endif - while( aMergedIter != aMergedCells.end()) - { - if( aMergedIter->bOpen && - lcl_SimilarPosition( aMergedIter->nLeftPosition, nLeftPos) ) - { - aMergedIter->aCells.push_back( xCell ); -#if OSL_DEBUG_LEVEL > 1 - bDbgFound = true; -#endif - } - ++aMergedIter; - } -#if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( bDbgFound, "couldn't find first vertically merged cell" ); -#endif - } - } - } - else - { - try - { - xCell->setPropertyValue(rName, aCellProperties[nProperty].Value); - } - catch ( const uno::Exception e ) - { - // Apply the paragraph and char properties to the cell's content - uno::Reference< text::XText > xCellText( xCell, uno::UNO_QUERY ); - uno::Reference< text::XTextCursor > xCellCurs = xCellText->createTextCursor( ); - xCellCurs->gotoStart( false ); - xCellCurs->gotoEnd( true ); - - uno::Reference< beans::XPropertySet > xCellTextProps( xCellCurs, uno::UNO_QUERY ); - xCellTextProps->setPropertyValue( rName, aCellProperties[nProperty].Value ); - } - } - } - } - } - //now that the cell properties are set the vertical merge values have to be applied - if( aMergedCells.size() ) - { - std::vector::iterator aMergedIter = aMergedCells.begin(); - while( aMergedIter != aMergedCells.end()) + for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) { - sal_Int32 nCellCount = (sal_Int32)aMergedIter->aCells.size(); - std::vector >::iterator aCellIter = aMergedIter->aCells.begin(); - bool bFirstCell = true; - //the first of the cells get's the number of cells set as RowSpan - //the others get the inverted number of remaining merged cells (3,-2,-1) - while( aCellIter != aMergedIter->aCells.end() ) - { - (*aCellIter)->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)), uno::makeAny( nCellCount )); - if( bFirstCell ) - { - nCellCount *= -1; - bFirstCell = false; - } - ++nCellCount; - ++aCellIter; - } - ++aMergedIter; + lcl_ApplyCellProperties(nCell, + aRowSeparators[nRow], aCurrentRow[nCell], + pTextTable->getCellByPosition(nCell, nRow), + aMergedCells); } } + // now that the cell properties are set the vertical merge values + // have to be applied + lcl_MergeCells(aMergedCells); } catch( const lang::WrappedTargetException& rWrapped ) { @@ -2221,29 +2343,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) (void)rBounds; } - - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - m_pImpl->m_pDoc->StartUndo(UNDO_START, NULL); - m_pImpl->m_pDoc->EndUndo(UNDO_START, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( pFirstPaM.get(), UNDO_EMPTY ); - m_pImpl->m_pDoc->Undo(aUndoIter); - if(bIllegalException) - { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; - } - else //if(bRuntimeException) - { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; - } - } return xRet; } -- cgit v1.2.3 From 1e8f5622f9bdfc964cc95b3120380a5c6c02e1e7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:56 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXBodyText: use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextbodyhf.hxx | 2 +- sw/source/core/unocore/unotext.cxx | 145 ++++++++++++++++++++----------------- 2 files changed, 80 insertions(+), 67 deletions(-) diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 98656ca68c..15c38044e4 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -64,7 +64,7 @@ protected: public: - SwXBodyText(SwDoc* pDoc); + SwXBodyText(SwDoc *const pDoc); SwXTextCursor * CreateTextCursor(const bool bIgnoreTables = false); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index b96aec2bd3..a1fe00dba1 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -36,9 +36,11 @@ #include #include +#include + #include #include -#include +#include #include #include @@ -2349,8 +2351,8 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) /****************************************************************** * SwXBodyText ******************************************************************/ -SwXBodyText::SwXBodyText(SwDoc* _pDoc) : - SwXText(_pDoc, CURSOR_BODY) +SwXBodyText::SwXBodyText(SwDoc *const pDoc) + : SwXText(pDoc, CURSOR_BODY) { } @@ -2364,82 +2366,81 @@ SwXBodyText::~SwXBodyText() /* -----------------------------06.04.00 16:33-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXBodyText::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXBodyText::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXBodyText"); } /* -----------------------------06.04.00 16:33-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXBodyText::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesBodyText[] = { - return C2U("com.sun.star.text.Text") == rServiceName; + "com.sun.star.text.Text", +}; +static const size_t g_nServicesBodyText( + sizeof(g_ServicesBodyText)/sizeof(g_ServicesBodyText[0])); + +sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesBodyText, g_ServicesBodyText, rServiceName); } -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXBodyText::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXBodyText::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Text"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesBodyText, g_ServicesBodyText); } + /*-- 10.12.98 11:17:27--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXBodyText::queryAggregation( - const uno::Type& rType ) - throw(uno::RuntimeException) +uno::Any SAL_CALL +SwXBodyText::queryAggregation(const uno::Type& rType) +throw (uno::RuntimeException) { uno::Any aRet; - const uno::Type& rXEnumerationAccessType = ::getCppuType((uno::Reference< container::XEnumerationAccess >*)0); - const uno::Type& rXElementAccessType = ::getCppuType((uno::Reference< container::XElementAccess >*)0); - const uno::Type& rXServiceInfoType = ::getCppuType((uno::Reference< lang::XServiceInfo >*)0); - - if(rType == rXEnumerationAccessType) + if (rType == container::XEnumerationAccess::static_type()) { - uno::Reference xRet = this; - aRet.setValue(&xRet, rXEnumerationAccessType); + aRet <<= uno::Reference< container::XEnumerationAccess >(this); } - else if(rType == rXElementAccessType) + else if (rType == container::XElementAccess::static_type()) { - uno::Reference xRet = this; - aRet.setValue(&xRet, rXElementAccessType); + aRet <<= uno::Reference< container::XElementAccess >(this); } - else if(rType == rXServiceInfoType) + else if (rType == lang::XServiceInfo::static_type()) { - uno::Reference xRet = this; - aRet.setValue(&xRet, rXServiceInfoType); + aRet <<= uno::Reference< lang::XServiceInfo >(this); } else { aRet = SwXText::queryInterface( rType ); } if(aRet.getValueType() == ::getCppuVoidType()) + { aRet = OWeakAggObject::queryAggregation( rType ); + } return aRet; } /*-- 10.12.98 11:17:28--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SwXBodyText::getTypes( ) throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXBodyText::getTypes() throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); - long nIndex = aTypes.getLength(); - aTypes.realloc(aTypes.getLength() + aTextTypes.getLength()); - uno::Type* pTypes = aTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(int i = 0; i < aTextTypes.getLength(); i++) - pTypes[nIndex++] = pTextTypes[i]; - return aTypes; + const uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SwXBodyText::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXBodyText::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -2497,7 +2498,8 @@ SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXBodyText::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2514,19 +2516,23 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXBodyText::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef; + if(!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } + + uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); @@ -2536,7 +2542,7 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( { p1 = p1->StartOfSectionNode(); } - SwStartNode* p2 = rNode.StartOfSectionNode(); + SwStartNode *const p2 = rNode.StartOfSectionNode(); if(p1 == p2) { @@ -2546,57 +2552,64 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( } } if(!aRef.is()) + { throw uno::RuntimeException(); + } return aRef; } + /*-- 10.12.98 11:17:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXBodyText::createEnumeration(void) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXBodyText::createEnumeration() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - if(IsValid()) - { - SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); - SwPosition aPos(rNode); - ::std::auto_ptr pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, sal_False)); - pUnoCursor->Move(fnMoveBackward, fnGoDoc); - aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); - } - else + + if (!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - return aRef; + SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); + SwPosition aPos(rNode); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveBackward, fnGoDoc); + const uno::Reference< container::XEnumeration > xRet + = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); + return xRet; } + /* -----------------18.12.98 13:36------------------- * * --------------------------------------------------*/ -uno::Type SwXBodyText::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXBodyText::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /* -----------------18.12.98 13:36------------------- * * --------------------------------------------------*/ -sal_Bool SwXBodyText::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXBodyText::hasElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) - return sal_True; - else + + if (!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } + + return sal_True; } + /****************************************************************** * SwXHeadFootText ******************************************************************/ -- cgit v1.2.3 From 2cfba5835c734c1b761e58454f2bbd1306e9eb98 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:57 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXHeadFootText: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in SwFrmFmt. make constructor protected, and add factory function CreateXHeadFootText. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextbodyhf.hxx | 18 +- sw/source/core/layout/atrfrm.cxx | 3 +- sw/source/core/unocore/unoobj2.cxx | 13 +- sw/source/core/unocore/unostyle.cxx | 53 +++--- sw/source/core/unocore/unotext.cxx | 331 +++++++++++++++++++++--------------- 5 files changed, 242 insertions(+), 176 deletions(-) diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 15c38044e4..8fd4e8c2a4 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -38,8 +38,6 @@ #include -#include -#include #include @@ -136,13 +134,12 @@ typedef ::cppu::WeakImplHelper2 class SwXHeadFootText : public SwXHeadFootText_Base , public SwXText - , public SwClient { private: - SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } - BOOL bIsHeader; + class Impl; + ::sw::UnoImplPtr m_pImpl; protected: @@ -154,14 +151,13 @@ protected: virtual ~SwXHeadFootText(); -public: - - SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); + SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader); - TYPEINFO(); +public: - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader); + static bool IsXHeadFootText(SwClient *const pClient); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index cd834bacd7..ead6b57f1d 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -198,7 +198,8 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt ) SwClient *pLast = aIter.GoStart(); if( pLast ) do { - bDel = pLast->IsA( TYPE(SwFrm) )|| pLast->IsA(TYPE(SwXHeadFootText)); + bDel = pLast->IsA( TYPE(SwFrm) ) + || SwXHeadFootText::IsXHeadFootText(pLast); } while( bDel && 0 != ( pLast = aIter++ )); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 4c25d821eb..95a027f8a6 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1317,17 +1317,10 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) pHeadFootFmt); } - if(pHeadFootFmt) + if (pHeadFootFmt) { - SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ). - First( TYPE( SwXHeadFootText )); - xParentText = pxHdFt; - if(!pxHdFt) - { - xParentText = - new SwXHeadFootText(*pHeadFootFmt, bHeader); - } - break; + xParentText = SwXHeadFootText::CreateXHeadFootText( + *pHeadFootFmt, bHeader); } } } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 1108dcf71f..2b648ec87a 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3436,6 +3436,29 @@ void SwXPageStyle::setPropertyValues( /* -----------------------------04.11.03 13:50-------------------------------- ---------------------------------------------------------------------------*/ +static uno::Reference +lcl_makeHeaderFooter( + const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt) +{ + if (!pFrmFmt) { return 0; } + + const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); + const SfxPoolItem* pItem; + if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem)) + { + SwFrmFmt *const pHeadFootFmt = (bHeader) + ? static_cast(const_cast(pItem))-> + GetHeaderFmt() + : static_cast(const_cast(pItem))-> + GetFooterFmt(); + if (pHeadFootFmt) + { + return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader); + } + } + return 0; +} + uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames ) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) @@ -3468,7 +3491,8 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); } sal_uInt16 nRes = 0; - sal_Bool bHeader = sal_False, bAll = sal_False, bLeft = sal_False, bRight = sal_False; + bool bHeader = false; + sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False; switch(pEntry->nWID) { case FN_UNO_HEADER_ON: @@ -3574,7 +3598,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( case FN_UNO_HEADER_RIGHT : bRight = sal_True; goto Header; Header: - bHeader = sal_True; + bHeader = true; nRes = RES_HEADER; goto MakeObject; case FN_UNO_FOOTER : bAll = sal_True; goto Footer; @@ -3595,27 +3619,18 @@ MakeObject: // TextRight does the same as Text and is for // comptability only. if( bLeft && !bShare ) + { pFrmFmt = &rDesc.GetLeft(); + } else + { pFrmFmt = &rDesc.GetMaster(); - if(pFrmFmt) + } + const uno::Reference< text::XText > xRet = + lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt); + if (xRet.is()) { - const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); - const SfxPoolItem* pItem; - SwFrmFmt* pHeadFootFmt; - if(SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem) && - 0 != (pHeadFootFmt = bHeader ? - ((SwFmtHeader*)pItem)->GetHeaderFmt() : - ((SwFmtFooter*)pItem)->GetFooterFmt())) - { - // gibt es schon ein Objekt dafuer? - SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ). - First( TYPE( SwXHeadFootText )); - uno::Reference< text::XText > xRet = pxHdFt; - if(!pxHdFt) - xRet = new SwXHeadFootText(*pHeadFootFmt, bHeader); - pRet[nProp].setValue(&xRet, ::getCppuType((uno::Reference*)0)); - } + pRet[nProp] <<= xRet; } } break; diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index a1fe00dba1..ddbb40bccf 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2613,60 +2613,136 @@ SwXBodyText::hasElements() throw (uno::RuntimeException) /****************************************************************** * SwXHeadFootText ******************************************************************/ -TYPEINIT1(SwXHeadFootText, SwClient); -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXHeadFootText::getImplementationName(void) throw( uno::RuntimeException ) +class SwXHeadFootText::Impl + : public SwClient { - return C2U("SwXHeadFootText"); + +public: + + bool m_bIsHeader; + + Impl( SwXHeadFootText & /*rThis*/, + SwFrmFmt & rHeadFootFmt, const bool bIsHeader) + : SwClient(& rHeadFootFmt) + , m_bIsHeader(bIsHeader) + { + } + + SwFrmFmt * GetHeadFootFmt() const { + return static_cast( + const_cast(GetRegisteredIn())); + } + + SwFrmFmt & GetHeadFootFmtOrThrow() { + SwFrmFmt *const pFmt( GetHeadFootFmt() ); + if (!pFmt) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXHeadFootText: disposed or invalid")), 0); + } + return *pFmt; + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 11.12.98 10:14:51--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXHeadFootText::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); } -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXHeadFootText::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +bool SwXHeadFootText::IsXHeadFootText(SwClient *const pClient) { - return C2U("com.sun.star.text.Text") == rServiceName; + return 0 != dynamic_cast(pClient); } -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXHeadFootText::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > +SwXHeadFootText::CreateXHeadFootText( + SwFrmFmt & rHeadFootFmt, const bool bIsHeader) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Text"); - return aRet; + // re-use existing SwXHeadFootText + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XText > xText(rHeadFootFmt.GetXObject(), + uno::UNO_QUERY); + if (!xText.is()) + { + SwXHeadFootText *const pXHFT( + new SwXHeadFootText(rHeadFootFmt, bIsHeader)); + xText.set(pXHFT); + rHeadFootFmt.SetXObject(xText); + } + return xText; } + /*-- 11.12.98 10:14:48--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXHeadFootText::SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader) : - SwXText(rHeadFootFmt.GetDoc(), bHeader ? CURSOR_HEADER : CURSOR_FOOTER), - SwClient(&rHeadFootFmt), - bIsHeader(bHeader) +SwXHeadFootText::SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader) + : SwXText(rHeadFootFmt.GetDoc(), + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER) + , m_pImpl( new SwXHeadFootText::Impl(*this, rHeadFootFmt, bIsHeader) ) { - } + /*-- 11.12.98 10:14:48--------------------------------------------------- -----------------------------------------------------------------------*/ SwXHeadFootText::~SwXHeadFootText() { +} + +/* -----------------------------06.04.00 16:40-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXHeadFootText::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXHeadFootText"); +} + +/* -----------------------------06.04.00 16:40-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesHeadFootText[] = +{ + "com.sun.star.text.Text", +}; +static const size_t g_nServicesHeadFootText( + sizeof(g_ServicesHeadFootText)/sizeof(g_ServicesHeadFootText[0])); + +sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesHeadFootText, g_ServicesHeadFootText, rServiceName); +} +uno::Sequence< OUString > SAL_CALL +SwXHeadFootText::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesHeadFootText, g_ServicesHeadFootText); } + /*-- 11.12.98 10:14:49--------------------------------------------------- -----------------------------------------------------------------------*/ const SwStartNode *SwXHeadFootText::GetStartNode() const { const SwStartNode *pSttNd = 0; - SwFrmFmt* pHeadFootFmt = GetFmt(); + SwFrmFmt *const pHeadFootFmt = m_pImpl->GetHeadFootFmt(); if(pHeadFootFmt) { const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); if( rFlyCntnt.GetCntntIdx() ) + { pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode(); + } } return pSttNd; } @@ -2679,28 +2755,19 @@ SwXHeadFootText::CreateCursor() throw (uno::RuntimeException) /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SwXHeadFootText::getTypes( ) throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXHeadFootText::getTypes() throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aHFTypes = SwXHeadFootText_Base::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); - - long nIndex = aHFTypes.getLength(); - aHFTypes.realloc( - aHFTypes.getLength() + - aTextTypes.getLength()); - - uno::Type* pHFTypes = aHFTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(long nPos = 0; nPos < aTextTypes.getLength(); nPos++) - pHFTypes[nIndex++] = pTextTypes[nPos]; - - return aHFTypes; + const uno::Sequence< uno::Type > aTypes = SwXHeadFootText_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXHeadFootText::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -2715,7 +2782,8 @@ uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::Ru /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SwXHeadFootText::queryInterface(const uno::Type& rType) +uno::Any SAL_CALL +SwXHeadFootText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) { const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType); @@ -2727,135 +2795,128 @@ throw (uno::RuntimeException) /*-- 11.12.98 10:14:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXHeadFootText::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet; - SwFrmFmt* pHeadFootFmt = GetFmt(); - if(pHeadFootFmt) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, - (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); - SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - - //save current start node to be able to check if there is content after the table - - //otherwise the cursor would be in the body text! - - const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - //steht hier eine Tabelle? - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); - pTblNode = pCont->FindTableNode(); - } - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - const SwStartNode* pNewStartNode = pUnoCrsr->GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - if(!pNewStartNode || pNewStartNode != pOwnStartNode) - { - uno::RuntimeException aExcept; - aExcept.Message = S2U("no text available"); - throw aExcept; - } - xRet = static_cast(pXCursor); - } - else - { - uno::RuntimeException aRuntime; - aRuntime.Message = C2U(cInvalidObject); - throw aRuntime; + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + + uno::Reference< text::XTextCursor > xRet; + const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + + // save current start node to be able to check if there is content + // after the table - otherwise the cursor would be in the body text! + SwStartNode const*const pOwnStartNode = rNode.FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + // is there a table here? + SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + SwCntntNode* pCont = 0; + while (pTblNode) + { + pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); + pTblNode = pCont->FindTableNode(); + } + if (pCont) + { + pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); + } + SwStartNode const*const pNewStartNode = + pUnoCrsr->GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (!pNewStartNode || (pNewStartNode != pOwnStartNode)) + { + uno::RuntimeException aExcept; + aExcept.Message = S2U("no text available"); + throw aExcept; } + xRet = static_cast(pXCursor); return xRet; } + /*-- 11.12.98 10:14:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXHeadFootText::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet; - SwFrmFmt* pHeadFootFmt = GetFmt(); + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + SwUnoInternalPaM aPam(*GetDoc()); - if (pHeadFootFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { - SwNode& rNode = pHeadFootFmt->GetCntnt().GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwPaM aHFPam(aPos); - aHFPam.Move(fnMoveForward, fnGoNode); - SwStartNode* pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - SwStartNode* p1 = aPam.GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - if(p1 == pOwnStartNode) - { - xRet = static_cast( - new SwXTextCursor(*GetDoc(), this, - (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, - *aPam.GetPoint(), aPam.GetMark())); - } + uno::RuntimeException aRuntime; + aRuntime.Message = C2U(cInvalidObject); + throw aRuntime; + } + + uno::Reference< text::XTextCursor > xRet; + SwNode& rNode = rHeadFootFmt.GetCntnt().GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + SwPaM aHFPam(aPos); + aHFPam.Move(fnMoveForward, fnGoNode); + SwStartNode *const pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + SwStartNode *const p1 = aPam.GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (p1 == pOwnStartNode) + { + xRet = static_cast( + new SwXTextCursor(*GetDoc(), this, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, + *aPam.GetPoint(), aPam.GetMark())); } return xRet; } + /* -----------------19.03.99 15:44------------------- * * --------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXHeadFootText::createEnumeration(void) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXHeadFootText::createEnumeration() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + uno::Reference< container::XEnumeration > aRef; - //wenn this ungueltig ist, dann kommt die uno::Exception aus createTextCursor() - SwFrmFmt* pHeadFootFmt = GetFmt(); - if(pHeadFootFmt) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - ::std::auto_ptr pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, sal_False)); - pUnoCursor->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCursor, - (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); - } - else - { - uno::RuntimeException aRuntime; - aRuntime.Message = C2U(cInvalidObject); - throw aRuntime; - } + const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); return aRef; } + /* -----------------19.03.99 15:50------------------- * * --------------------------------------------------*/ -uno::Type SwXHeadFootText::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXHeadFootText::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /* -----------------19.03.99 15:50------------------- * * --------------------------------------------------*/ -sal_Bool SwXHeadFootText::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXHeadFootText::hasElements() throw (uno::RuntimeException) { return sal_True; } -/*-- 11.12.98 10:14:51--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXHeadFootText::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify( this, pOld, pNew); -} - -- cgit v1.2.3 From 7c0b2caa588121ab5c4061046a0fe1c668666a0c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:58 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXFootnote: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. disable broken SwClient iteration. make constructor protected, and add factory function CreateXFootnote. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unofootnote.hxx | 37 +- sw/source/core/unocore/unoclbck.cxx | 15 +- sw/source/core/unocore/unocoll.cxx | 11 +- sw/source/core/unocore/unocrsrhelper.cxx | 5 +- sw/source/core/unocore/unoftn.cxx | 743 ++++++++++++++++++------------- sw/source/core/unocore/unoobj2.cxx | 8 +- 6 files changed, 461 insertions(+), 358 deletions(-) diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx index 8710f7effa..8d9a65d963 100644 --- a/sw/inc/unofootnote.hxx +++ b/sw/inc/unofootnote.hxx @@ -41,14 +41,11 @@ #include -#include - -#include -#include #include class SwDoc; +class SwModify; class SwFmtFtn; @@ -66,18 +63,15 @@ typedef ::cppu::WeakImplHelper5 class SwXFootnote : public SwXFootnote_Base , public SwXText - , public SwClient { private: friend class SwXFootnotes; - SwEventListenerContainer aLstnrCntnr; - const SwFmtFtn* pFmtFtn; - BOOL m_bIsDescriptor; - String m_sLabel; - BOOL m_bIsEndnote; + class Impl; + ::sw::UnoImplPtr m_pImpl; + protected: @@ -90,24 +84,17 @@ protected: virtual ~SwXFootnote(); -public: - - SwXFootnote(BOOL bEndnote); - SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); - - 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); + SwXFootnote(SwDoc & rDoc, const SwFmtFtn & rFmt); - const SwFmtFtn* FindFmt() const { return GetDoc() ? pFmtFtn : 0; } - void Invalidate(); +public: - TYPEINFO(); + SwXFootnote(const bool bEndnote); - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static SwXFootnote * + CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt); + /// may return 0 + static SwXFootnote * + GetXFootnote(SwModify const& rUnoCB, SwFmtFtn const& rFootnoteFmt); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 693aaf9674..96ba9b2421 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -72,20 +72,7 @@ SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) ---------------------------------------------------------------------------*/ SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) { - SwClientIter aIter( *this ); - SwXFootnote* pxFootnote = (SwXFootnote*)aIter.First( TYPE( SwXFootnote )); - while(pxFootnote) - { - SwDoc* pDoc = pxFootnote->GetDoc(); - if(pDoc) - { - const SwFmtFtn* pFtn = pxFootnote->FindFmt(); - if(pFtn == &rMark) - return pxFootnote; - } - pxFootnote = (SwXFootnote*)aIter.Next( ); - } - return 0; + return SwXFootnote::GetXFootnote(*this, rMark); } /* -----------------------------27.11.00 17:15-------------------------------- diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index d62b7837cc..aedace0510 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1727,8 +1727,8 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) if(nCount == nIndex) { - xRef = new SwXFootnote(GetDoc(), rFtn); - aRet.setValue(&xRef, ::getCppuType((uno::Reference*)0)); + xRef = SwXFootnote::CreateXFootnote(*GetDoc(), rFtn); + aRet <<= xRef; break; } nCount++; @@ -1762,12 +1762,7 @@ sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException ) ---------------------------------------------------------------------------*/ Reference SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt ) { - Reference xContent = ((SwUnoCallBack*)rDoc.GetUnoCallBack())-> - GetFootnote(rFmt); - if(!xContent.is()) - xContent = new SwXFootnote(&rDoc, rFmt); - Reference xRet(xContent, UNO_QUERY); - return xRet; + return SwXFootnote::CreateXFootnote(rDoc, rFmt); } /****************************************************************** diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 2e177b40e0..76c28f8d22 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -445,8 +445,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - uno::Reference< XFootnote > xFoot = new SwXFootnote(rPam.GetDoc(), rFtn); - pAny->setValue(&xFoot, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XFootnote > xFootnote = + SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn); + *pAny <<= xFootnote; } } else diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 19787cdbd0..3a1509a276 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -31,9 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + #include #include -#include +#include #include #include @@ -42,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -55,118 +58,233 @@ using namespace ::com::sun::star; using ::rtl::OUString; /****************************************************************** - * + * SwXFootnote ******************************************************************/ -/* -----------------------------13.03.00 12:15-------------------------------- - ---------------------------------------------------------------------------*/ -const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId() +class SwXFootnote::Impl + : public SwClient { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} -/* -----------------------------10.03.00 18:04-------------------------------- - ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXFootnote::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) +public: + + SwXFootnote & m_rThis; + const bool m_bIsEndnote; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + const SwFmtFtn * m_pFmtFtn; + ::rtl::OUString m_sLabel; + + Impl( SwXFootnote & rThis, + SwDoc *const pDoc, SwFmtFtn const*const pFootnote, + const bool bIsEndnote) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_rThis(rThis) + , m_bIsEndnote(bIsEndnote) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pFootnote) + , m_pFmtFtn(pFootnote) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); } - return SwXText::getSomething( rId ); -} -/* -----------------------------06.04.00 16:36-------------------------------- + + const SwFmtFtn* GetFootnoteFormat() const { + return m_rThis.GetDoc() ? m_pFmtFtn : 0; + } + + SwFmtFtn const& GetFootnoteFormatOrThrow() { + SwFmtFtn const*const pFootnote( GetFootnoteFormat() ); + if (!pFootnote) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXFootnote: disposed or invalid")), 0); + } + return *pFootnote; + } + + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------07.01.00 12:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXFootnote::getImplementationName(void) throw( uno::RuntimeException ) +void SwXFootnote::Impl::Invalidate() { - return C2U("SwXFootnote"); + if (GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + } + m_ListenerContainer.Disposing(); + m_pFmtFtn = 0; + m_rThis.SetDoc(0); } -/* -----------------------------06.04.00 16:36-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXFootnote::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +/* -----------------18.01.99 09:12------------------- + * + * --------------------------------------------------*/ +void SwXFootnote::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - return !rServiceName.compareToAscii("com.sun.star.text.Footnote") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent") || - !rServiceName.compareToAscii("com.sun.star.text.Text") || - (m_bIsEndnote && !rServiceName.compareToAscii("com.sun.star.text.Endnote")); -; -} -/* -----------------------------06.04.00 16:36-------------------------------- + ClientModify(this, pOld, pNew); - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXFootnote::getSupportedServiceNames(void) throw( uno::RuntimeException ) -{ - uno::Sequence< OUString > aRet(m_bIsEndnote ? 4 : 3); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Footnote"); - pArray[1] = C2U("com.sun.star.text.TextContent"); - pArray[2] = C2U("com.sun.star.text.Text"); - if(m_bIsEndnote) - pArray[3] = C2U("com.sun.star.text.Endnote"); - return aRet; + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_FOOTNOTE_DELETED: + if (static_cast(m_pFmtFtn) == + static_cast(pOld)->pObject) + { + Invalidate(); + } + break; + } + } } + /*-- 10.12.98 15:31:44--------------------------------------------------- -----------------------------------------------------------------------*/ -TYPEINIT1(SwXFootnote, SwClient); - -SwXFootnote::SwXFootnote(sal_Bool bEndnote) : - SwXText(0, CURSOR_FOOTNOTE), - aLstnrCntnr( (text::XTextContent*)this), - pFmtFtn(0), - m_bIsDescriptor(sal_True), - m_bIsEndnote(bEndnote) +SwXFootnote::SwXFootnote(const bool bEndnote) + : SwXText(0, CURSOR_FOOTNOTE) + , m_pImpl( new SwXFootnote::Impl(*this, 0, 0, bEndnote) ) { - } /*-- 10.12.98 15:31:45--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXFootnote::SwXFootnote(SwDoc* _pDoc, const SwFmtFtn& rFmt) : - SwXText(_pDoc, CURSOR_FOOTNOTE), - aLstnrCntnr( (text::XTextContent*)this), - pFmtFtn(&rFmt), - m_bIsDescriptor(sal_False), - m_bIsEndnote(rFmt.IsEndNote()) +SwXFootnote::SwXFootnote(SwDoc & rDoc, const SwFmtFtn& rFmt) + : SwXText(& rDoc, CURSOR_FOOTNOTE) + , m_pImpl( new SwXFootnote::Impl(*this, &rDoc, &rFmt, rFmt.IsEndNote()) ) { - GetDoc()->GetUnoCallBack()->Add(this); } /*-- 10.12.98 15:31:45--------------------------------------------------- -----------------------------------------------------------------------*/ SwXFootnote::~SwXFootnote() { +} + +SwXFootnote * +SwXFootnote::GetXFootnote( + SwModify const& /*rUnoCB*/, SwFmtFtn const& /*rFootnoteFmt*/) +{ + // re-use existing SwXFootnote + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXFootnote to register at the + // SwFmtFtn directly, not at the unocallback + // also this function must return a uno Reference! +#if 0 + SwClientIter aIter( rUnoCB ); + SwXFootnote::Impl * pXFootnote = static_cast( + aIter.First( TYPE( SwXFootnote::Impl ))); + while (pXFootnote) + { + SwDoc *const pDoc = pXFootnote->m_rThis.GetDoc(); + if (pDoc) + { + SwFmtFtn const*const pFtn = pXFootnote->GetFootnoteFormat(); + if (pFtn == &rFootnoteFmt) + { + return & pXFootnote->m_rThis; + } + } + pXFootnote = static_cast(aIter.Next()); + } +#endif + return 0; +} + +SwXFootnote * +SwXFootnote::CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt) +{ + SwXFootnote *const pXFootnote( + GetXFootnote(*rDoc.GetUnoCallBack(), rFootnoteFmt)); + return (pXFootnote) + ? pXFootnote + : new SwXFootnote(rDoc, rFootnoteFmt); +} +/* -----------------------------13.03.00 12:15-------------------------------- + + ---------------------------------------------------------------------------*/ +const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -/* -----------------------------21.03.00 15:39-------------------------------- +/* -----------------------------10.03.00 18:04-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Int64 SAL_CALL +SwXFootnote::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + const sal_Int64 nRet( ::sw::UnoTunnelImpl(rId, this) ); + return (nRet) ? nRet : SwXText::getSomething(rId); +} + +/* -----------------------------06.04.00 16:36-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXFootnote::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXFootnote"); +} + +/* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SAL_CALL SwXFootnote::getTypes( ) throw(uno::RuntimeException) +static char const*const g_ServicesFootnote[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.Footnote", + "com.sun.star.text.Text", + "com.sun.star.text.Endnote", // NB: only supported for endnotes! +}; +static const size_t g_nServicesEndnote( + sizeof(g_ServicesFootnote)/sizeof(g_ServicesFootnote[0])); +static const size_t g_nServicesFootnote( g_nServicesEndnote - 1 ); // NB: omit! + +sal_Bool SAL_CALL SwXFootnote::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aFtnTypes = SwXFootnote_Base::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + vos::OGuard g(Application::GetSolarMutex()); + return ::sw::SupportsServiceImpl( + (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote, + g_ServicesFootnote, rServiceName); +} - long nIndex = aFtnTypes.getLength(); - aFtnTypes.realloc( aFtnTypes.getLength() + aTextTypes.getLength()); +uno::Sequence< OUString > SAL_CALL +SwXFootnote::getSupportedServiceNames() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return ::sw::GetSupportedServiceNamesImpl( + (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote, + g_ServicesFootnote); +} - uno::Type* pFtnTypes = aFtnTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(long nPos = 0; nPos < aTextTypes.getLength(); nPos++) - pFtnTypes[nIndex++] = pTextTypes[nPos]; +/* -----------------------------21.03.00 15:39-------------------------------- - return aFtnTypes; + ---------------------------------------------------------------------------*/ +uno::Sequence< uno::Type > SAL_CALL +SwXFootnote::getTypes() throw (uno::RuntimeException) +{ + const uno::Sequence< uno::Type > aTypes = SwXFootnote_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXFootnote::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -181,7 +299,8 @@ uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(un /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXFootnote::queryInterface(const uno::Type& rType) +uno::Any SAL_CALL +SwXFootnote::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) { const uno::Any ret = SwXFootnote_Base::queryInterface(rType); @@ -193,26 +312,36 @@ throw (uno::RuntimeException) /*-- 10.12.98 15:31:47--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXFootnote::getLabel(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXFootnote::getLabel() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - String sRet; - const SwFmtFtn* pFmt = SwXFootnote::FindFmt(); + + ::rtl::OUString sRet; + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) + { sRet = pFmt->GetNumStr(); - else if(m_bIsDescriptor) - return m_sLabel; + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sLabel; + } else + { throw uno::RuntimeException(); + } return sRet; } + /*-- 10.12.98 15:31:48--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::setLabel(const OUString& aLabel) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::setLabel(const OUString& aLabel) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); + + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); @@ -222,157 +351,172 @@ void SwXFootnote::setLabel(const OUString& aLabel) throw( uno::RuntimeException SwPaM aPam(rTxtNode, *pTxtFtn->GetStart()); GetDoc()->SetCurFtn(aPam, aLabel, pFmt->GetNumber(), pFmt->IsEndNote()); } - else if(m_bIsDescriptor) - m_sLabel = String(aLabel); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sLabel = String(aLabel); + } else + { throw uno::RuntimeException(); - + } } + /* -----------------18.02.99 13:32------------------- * * --------------------------------------------------*/ -void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + } + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + SwDoc *const pNewDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pNewDoc) + { + throw lang::IllegalArgumentException(); + } + + SwUnoInternalPaM aPam(*pNewDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + + UnoActionContext aCont(pNewDoc); + pNewDoc->DeleteAndJoin(aPam); + aPam.DeleteMark(); + SwFmtFtn aFootNote(m_pImpl->m_bIsEndnote); + if (m_pImpl->m_sLabel.getLength()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + aFootNote.SetNumStr(m_pImpl->m_sLabel); } - SwDoc* pNewDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pNewDoc) + + SwXTextCursor const*const pTextCursor( + dynamic_cast(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); + + SwTxtFtn *const pTxtAttr = static_cast( + aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN )); + + if (pTxtAttr) { - SwUnoInternalPaM aPam(*pNewDoc); - //das muss jetzt sal_True liefern - ::sw::XTextRangeToSwPaM(aPam, xTextRange); - - UnoActionContext aCont(pNewDoc); - SwTxtAttr* pTxtAttr = 0; - pNewDoc->DeleteAndJoin(aPam); - aPam.DeleteMark(); - SwFmtFtn aFootNote(m_bIsEndnote); - if(m_sLabel.Len()) - aFootNote.SetNumStr(m_sLabel); - - SwXTextCursor const*const pTextCursor( - dynamic_cast(pCursor)); - const bool bForceExpandHints( (pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) - ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND - : nsSetAttrMode::SETATTR_DEFAULT; - - pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); - - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN ); - - if(pTxtAttr) + const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); + m_pImpl->m_pFmtFtn = &rFtn; + pNewDoc->GetUnoCallBack()->Add(m_pImpl.get()); + // force creation of sequence id - is used for references + if (pNewDoc->IsInReading()) + { + pTxtAttr->SetSeqNo(pNewDoc->GetFtnIdxs().Count()); + } + else { - const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); - pFmtFtn = &rFtn; - pNewDoc->GetUnoCallBack()->Add(this); - //force creation of sequence id - is used for references - if(pNewDoc->IsInReading()) - ((SwTxtFtn*)pTxtAttr)->SetSeqNo(pNewDoc->GetFtnIdxs().Count()); - else - ((SwTxtFtn*)pTxtAttr)->SetSeqRefNo(); + pTxtAttr->SetSeqRefNo(); } - m_bIsDescriptor = sal_False; - SetDoc(pNewDoc); } - else - throw lang::IllegalArgumentException(); + m_pImpl->m_bIsDescriptor = sal_False; + SetDoc(pNewDoc); } -/*-- 10.12.98 15:31:48--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); -} /*-- 10.12.98 15:31:48--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXFootnote::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXFootnote::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() ); - SwPosition aMark( *aPam.Start() ); - aPam.SetMark(); - aPam.GetMark()->nContent++; - aRef = SwXTextRange::CreateXTextRange( - *GetDoc(), *aPam.Start(), aPam.End()); - } - else - throw uno::RuntimeException(); - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() ); + SwPosition aMark( *aPam.Start() ); + aPam.SetMark(); + aPam.GetMark()->nContent++; + const uno::Reference< text::XTextRange > xRet = + SwXTextRange::CreateXTextRange(*GetDoc(), *aPam.Start(), aPam.End()); + return xRet; } /*-- 10.12.98 15:31:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXFootnote::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - DBG_ASSERT(pTxtFtn, "kein TextNode?"); - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtFtn->GetTxtNode(); - xub_StrLen nPos = *pTxtFtn->GetStart(); - SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1 ); - GetDoc()->DeleteAndJoin( aPam ); - } - else - throw uno::RuntimeException(); + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + DBG_ASSERT(pTxtFtn, "no TextNode?"); + SwTxtNode& rTxtNode = const_cast(pTxtFtn->GetTxtNode()); + const xub_StrLen nPos = *pTxtFtn->GetStart(); + SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1); + GetDoc()->DeleteAndJoin( aPam ); } + /*-- 10.12.98 15:31:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetFootnoteFormat()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 10.12.98 15:31:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetFootnoteFormat() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /* -----------------06.05.99 15:31------------------- * * --------------------------------------------------*/ const SwStartNode *SwXFootnote::GetStartNode() const { - const SwStartNode *pSttNd = 0; - const SwFmtFtn* pFmt = FindFmt(); + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); if( pTxtFtn ) - pSttNd = pTxtFtn->GetStartNode()->GetNode().GetStartNode(); + { + return pTxtFtn->GetStartNode()->GetNode().GetStartNode(); + } } - return pSttNd; + return 0; } uno::Reference< text::XTextCursor > @@ -380,144 +524,119 @@ SwXFootnote::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } + /*-- 10.12.98 15:31:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXFootnote::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXFootnote::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor *const pXCursor = - new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); - aRef = static_cast(pXCursor); - SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - } - else - throw uno::RuntimeException(); - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPosition aPos( *pTxtFtn->GetStartNode() ); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + const uno::Reference< text::XTextCursor > xRet = + static_cast(pXCursor); + return xRet; } + /*-- 10.12.98 15:31:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) - throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXFootnote::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); - if( !pFmt ) - throw uno::RuntimeException(); - uno::Reference< text::XTextCursor > aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - const SwNode* pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); + throw uno::RuntimeException(); + } - const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); - if( pStart != pFtnStartNode ) - throw uno::RuntimeException(); + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwNode const*const pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); - aRef = static_cast( + const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); + if (pStart != pFtnStartNode) + { + throw uno::RuntimeException(); + } + + const uno::Reference< text::XTextCursor > xRet = + static_cast( new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, *aPam.GetPoint(), aPam.GetMark())); - } - else - throw uno::RuntimeException(); - return aRef; + return xRet; } + /*-- 13.06.00 14:28:23--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXFootnote::createEnumeration() throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXFootnote::createEnumeration() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPosition aPos( *pTxtFtn->GetStartNode() ); - ::std::auto_ptr pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, sal_False)); - pUnoCursor->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); - } - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPosition aPos( *pTxtFtn->GetStartNode() ); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); + return xRet; } + /*-- 13.06.00 14:28:24--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXFootnote::getElementType( ) throw(uno::RuntimeException) +uno::Type SAL_CALL SwXFootnote::getElementType() throw (uno::RuntimeException) { - return ::getCppuType(static_cast*>(0)); + return text::XTextRange::static_type(); } /*-- 13.06.00 14:28:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXFootnote::hasElements( ) throw(uno::RuntimeException) +sal_Bool SAL_CALL SwXFootnote::hasElements() throw (uno::RuntimeException) { return sal_True; } -/* -----------------------------07.01.00 12:39-------------------------------- - ---------------------------------------------------------------------------*/ -void SwXFootnote::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - pFmtFtn = 0; - aLstnrCntnr.Disposing(); - SetDoc(0); - } -} -/* -----------------18.01.99 09:12------------------- - * - * --------------------------------------------------*/ -void SwXFootnote::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_FOOTNOTE_DELETED: - if( (void*)pFmtFtn == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } -} /*-- 11.09.00 13:12:03--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXFootnote::getPropertySetInfo( ) - throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXFootnote::getPropertySetInfo() +throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE)->getPropertySetInfo(); - return xRef; + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE) + ->getPropertySetInfo(); + return xRet; } + /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::setPropertyValue( const ::rtl::OUString&, - const uno::Any& ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::setPropertyValue(const ::rtl::OUString&, const uno::Any&) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { //no values to be set throw lang::IllegalArgumentException(); @@ -525,28 +644,34 @@ void SwXFootnote::setPropertyValue( const ::rtl::OUString&, /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +uno::Any SAL_CALL +SwXFootnote::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { - if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| - rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) { //redline can only be returned if it's a living object - if(!m_bIsDescriptor) + if (!m_pImpl->m_bIsDescriptor) + { aRet = SwXText::getPropertyValue(rPropertyName); + } } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_REFERENCE_ID))) + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_REFERENCE_ID))) { - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); + if (pFmt) { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); + SwTxtFtn const*const pTxtFtn = pFmt->GetTxtFtn(); DBG_ASSERT(pTxtFtn, "no TextNode?"); - aRet <<= (sal_Int16)pTxtFtn->GetSeqRefNo(); + aRet <<= static_cast(pTxtFtn->GetSeqRefNo()); } } else @@ -558,37 +683,51 @@ uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) } return aRet; } + /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::addPropertyChangeListener( const OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::addPropertyChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::removePropertyChangeListener( const OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::removePropertyChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::addVetoableChangeListener( const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::addVetoableChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:05--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::removeVetoableChangeListener( const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::removeVetoableChangeListener(): not implemented"); } - diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 95a027f8a6..62ae8053e1 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1344,13 +1344,7 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { - xParentText = - static_cast(rDoc.GetUnoCallBack())-> - GetFootnote(rFtn); - if (!xParentText.is()) - { - xParentText = new SwXFootnote(&rDoc, rFtn); - } + xParentText = SwXFootnote::CreateXFootnote(rDoc, rFtn); break; } } -- cgit v1.2.3 From b5e921ac550454d75c90bdff511c95b263e9a124 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:58 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXDocumentIndex: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in SwFrmFmt. make constructor private, and add factory function CreateXDocumentIndex. use new XUnoTunnel helpers. clean up the implementation a little. remove SwXDocumentIndexes::GetObject(). --- sw/inc/unoidx.hxx | 199 ++-- sw/source/core/unocore/unocrsrhelper.cxx | 8 +- sw/source/core/unocore/unoidx.cxx | 1681 +++++++++++++++++------------- sw/source/core/unocore/unosect.cxx | 3 +- 4 files changed, 1083 insertions(+), 808 deletions(-) diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index b9a321f87b..3ea515cf11 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -53,101 +53,143 @@ class SwTOXType; /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ -class SwDocIdxProperties_Impl; class SwXIndexStyleAccess_Impl; class SwXIndexTokenAccess_Impl; -class SwXDocumentIndex : public cppu::WeakImplHelper5 -< - ::com::sun::star::text::XDocumentIndex, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient -{ - friend class SwXIndexStyleAccess_Impl; - friend class SwXIndexTokenAccess_Impl; - - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - SwDoc* m_pDoc; - const SwTOXBaseSection* pBase; - TOXTypes eTOXType; - - //Descriptor-Interface - sal_Bool bIsDescriptor; - SwDocIdxProperties_Impl* pProps; +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XDocumentIndex +> SwXDocumentIndex_Base; - SwXIndexStyleAccess_Impl* pStyleAccess; - SwXIndexTokenAccess_Impl* pTokenAccess; +class SwXDocumentIndex + : public SwXDocumentIndex_Base +{ - SwSectionFmt* GetFmt()const {return (SwSectionFmt*)GetRegisteredIn();} +private: - sal_Bool IsDescriptor() const {return bIsDescriptor;} - const SwDocIdxProperties_Impl* GetProperties_Impl() const { return pProps;} - SwDocIdxProperties_Impl* GetProperties_Impl() { return pProps;} - TOXTypes GetTOXType() const {return eTOXType;} + friend class SwXIndexStyleAccess_Impl; + friend class SwXIndexTokenAccess_Impl; - SwXIndexStyleAccess_Impl* GetStyleAccess() const {return pStyleAccess;} - void SetStyleAccess(SwXIndexStyleAccess_Impl* pSet) - {pStyleAccess = pSet;} + class Impl; + ::sw::UnoImplPtr m_pImpl; - SwXIndexTokenAccess_Impl* GetTokenAccess() const {return pTokenAccess;} - void SetTokenAccess(SwXIndexTokenAccess_Impl* pSet) - {pTokenAccess = pSet;} -protected: virtual ~SwXDocumentIndex(); -public: - SwXDocumentIndex(const SwTOXBaseSection* = 0, SwDoc* = 0); - //Descriptor-Ctor - SwXDocumentIndex(TOXTypes eToxType, SwDoc& rDoc); - - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - //XDocumentIndex - virtual ::rtl::OUString SAL_CALL getServiceName( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL update( ) throw(::com::sun::star::uno::RuntimeException); + SwXDocumentIndex(SwTOXBaseSection const&, SwDoc &); - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); +public: - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); + /// descriptor + SwXDocumentIndex(const TOXTypes eToxType, SwDoc& rDoc); - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndex> + CreateXDocumentIndex(SwDoc & rDoc, SwTOXBaseSection const& rSection); - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + + // XDocumentIndex + virtual ::rtl::OUString SAL_CALL getServiceName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL update() + throw (::com::sun::star::uno::RuntimeException); - 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 ); }; + /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ @@ -274,7 +316,6 @@ public: virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - static SwXDocumentIndex* GetObject(const SwTOXBaseSection* pTOX); }; /* -----------------13.09.99 16:39------------------- diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 76c28f8d22..739378f3fb 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -331,9 +332,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - uno::Reference< XDocumentIndex > aRef = - SwXDocumentIndexes::GetObject((SwTOXBaseSection*)pBase); - pAny->setValue(&aRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndex > xRef = + SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(), + *static_cast(pBase)); + (*pAny) <<= xRef; } } else diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index f89fb5a25b..3aef38b685 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,19 +31,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include - -#include -#include -#include -#include -#include #include #include #include #include #include #include + +#include +#include +#include +#include + +#include #include #include #include @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -74,36 +75,61 @@ using namespace ::com::sun::star; using ::rtl::OUString; //----------------------------------------------------------------------------- -String lcl_AnyToString(uno::Any rVal) throw(lang::IllegalArgumentException) +static String +lcl_AnyToString(uno::Any const& rVal) throw (lang::IllegalArgumentException) { OUString sRet; if(!(rVal >>= sRet)) + { throw lang::IllegalArgumentException(); + } return sRet; } //----------------------------------------------------------------------------- -sal_Int16 lcl_AnyToInt16(uno::Any rVal) throw(lang::IllegalArgumentException) +static sal_Int16 +lcl_AnyToInt16(uno::Any const& rVal) throw (lang::IllegalArgumentException) { sal_Int16 nRet = 0; if(!(rVal >>= nRet)) + { throw lang::IllegalArgumentException(); + } return nRet; } //----------------------------------------------------------------------------- -sal_Bool lcl_AnyToBool(uno::Any rVal) throw(lang::IllegalArgumentException) +static sal_Bool +lcl_AnyToBool(uno::Any const& rVal) throw (lang::IllegalArgumentException) { sal_Bool bRet = sal_False; if(!(rVal >>= bRet)) + { throw lang::IllegalArgumentException(); + } return bRet; } -/****************************************************************************** - * - ******************************************************************************/ + +static void +lcl_AnyToBitMask(uno::Any const& rValue, + sal_uInt16 & rBitMask, const sal_uInt16 nBit) +throw (lang::IllegalArgumentException) +{ + rBitMask = lcl_AnyToBool(rValue) + ? (rBitMask | nBit) + : (rBitMask & ~nBit); +} +static void +lcl_BitMaskToAny(uno::Any & o_rValue, + const sal_uInt16 nBitMask, const sal_uInt16 nBit) +{ + const sal_Bool bRet = 0 != (nBitMask & nBit); + o_rValue <<= bRet; +} + //----------------------------------------------------------------------------- -void lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName) +static void +lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName) { - sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER ); + const sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER ); const SwTOXType* pNewType = 0; for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++) { @@ -133,14 +159,19 @@ void lcl_ConvertTOUNameToProgrammaticName(OUString& rTmp) ShellResource* pShellRes = ViewShell::GetShellRes(); if(rTmp.equals(pShellRes->aTOXUserName)) + { rTmp = OUString(C2U(cUserDefined)); - //if the version is not English but the alternative index's name is "User-Defined" - //a " (user)" is appended + } + // if the version is not English but the alternative index's name is + // "User-Defined" a " (user)" is appended else if(rTmp.equalsAscii(cUserDefined)) + { rTmp += C2U(cUserSuffix); + } } //----------------------------------------------------------------------------- -void lcl_ConvertTOUNameToUserName(OUString& rTmp) +static void +lcl_ConvertTOUNameToUserName(OUString& rTmp) { ShellResource* pShellRes = ViewShell::GetShellRes(); if(rTmp.equalsAscii(cUserDefined)) @@ -150,43 +181,189 @@ void lcl_ConvertTOUNameToUserName(OUString& rTmp) else if(!pShellRes->aTOXUserName.EqualsAscii(cUserDefined) && USER_AND_SUFFIXLEN == rTmp.getLength()) { - String sToChange(rTmp); //make sure that in non-English versions the " (user)" suffix is removed - if(!sToChange.SearchAscii(cUserDefined) && USER_LEN == sToChange.SearchAscii(cUserSuffix)) + if (rTmp.matchAsciiL(cUserDefined, sizeof(cUserDefined)) && + rTmp.matchAsciiL(cUserSuffix, sizeof(cUserSuffix), USER_LEN)) + { rTmp = C2U(cUserDefined); + } } } /****************************************************************** * SwXDocumentIndex ******************************************************************/ + /* -----------------20.06.98 11:06------------------- * * --------------------------------------------------*/ -class SwDocIdxProperties_Impl +class SwDocIndexDescriptorProperties_Impl { - SwTOXBase* pTOXBase; - OUString sUserTOXTypeName; +private: + ::std::auto_ptr m_pTOXBase; + OUString m_sUserTOXTypeName; + public: - SwTOXBase& GetTOXBase() {return *pTOXBase;} - SwDocIdxProperties_Impl(const SwTOXType* pType); - ~SwDocIdxProperties_Impl(){delete pTOXBase;} + SwDocIndexDescriptorProperties_Impl(SwTOXType const*const pType); - const OUString& GetTypeName()const {return sUserTOXTypeName;} - void SetTypeName(const OUString& rSet) {sUserTOXTypeName = rSet;} + SwTOXBase & GetTOXBase() { return *m_pTOXBase; } + const OUString& GetTypeName() const { return m_sUserTOXTypeName; } + void SetTypeName(const OUString& rSet) { m_sUserTOXTypeName = rSet; } }; /* -----------------20.06.98 11:41------------------- * * --------------------------------------------------*/ -SwDocIdxProperties_Impl::SwDocIdxProperties_Impl(const SwTOXType* pType) +SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl( + SwTOXType const*const pType) { SwForm aForm(pType->GetType()); - pTOXBase = new SwTOXBase(pType, aForm, - nsSwTOXElement::TOX_MARK, pType->GetTypeName()); + m_pTOXBase.reset(new SwTOXBase(pType, aForm, + nsSwTOXElement::TOX_MARK, pType->GetTypeName())); if(pType->GetType() == TOX_CONTENT || pType->GetType() == TOX_USER) - pTOXBase->SetLevel(MAXLEVEL); - sUserTOXTypeName = pType->GetTypeName(); + { + m_pTOXBase->SetLevel(MAXLEVEL); + } + m_sUserTOXTypeName = pType->GetTypeName(); +} + +static sal_uInt16 +lcl_TypeToPropertyMap(const TOXTypes eType) +{ + switch (eType) + { + case TOX_INDEX: return PROPERTY_MAP_INDEX_IDX; + case TOX_CONTENT: return PROPERTY_MAP_INDEX_CNTNT; + case TOX_TABLES: return PROPERTY_MAP_INDEX_TABLES; + case TOX_ILLUSTRATIONS: return PROPERTY_MAP_INDEX_ILLUSTRATIONS; + case TOX_OBJECTS: return PROPERTY_MAP_INDEX_OBJECTS; + case TOX_AUTHORITIES: return PROPERTY_MAP_BIBLIOGRAPHY; + //case TOX_USER: + default: + return PROPERTY_MAP_INDEX_USER; + } +} + +class SwXDocumentIndex::Impl + : public SwClient +{ + +public: + + SfxItemPropertySet const& m_rPropSet; + const TOXTypes m_eTOXType; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDoc * m_pDoc; + ::std::auto_ptr m_pProps; + uno::WeakReference m_wStyleAccess; + uno::WeakReference m_wTokenAccess; + + Impl( SwXDocumentIndex & rThis, + SwDoc & rDoc, + const TOXTypes eType, + SwTOXBaseSection const*const pBaseSection) + : SwClient((pBaseSection) ? pBaseSection->GetFmt() : 0) + , m_rPropSet( + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap(eType))) + , m_eTOXType(eType) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pBaseSection) + , m_pDoc(&rDoc) + , m_pProps((m_bIsDescriptor) + ? new SwDocIndexDescriptorProperties_Impl(rDoc.GetTOXType(eType, 0)) + : 0) + { + } + + SwSectionFmt * GetSectionFmt() const { + return static_cast( + const_cast(GetRegisteredIn())); + } + + SwTOXBase & GetTOXSectionOrThrow() const + { + SwSectionFmt *const pSectionFmt(GetSectionFmt()); + SwTOXBase *const pTOXSection( (m_bIsDescriptor) + ? &m_pProps->GetTOXBase() + : ((pSectionFmt) + ? static_cast(pSectionFmt->GetSection()) + : 0)); + if (!pTOXSection) + { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXDocumentIndex: disposed or invalid")), 0); + } + return *pTOXSection; + } + + sal_Int32 GetFormMax() const + { + SwTOXBase & rSection( GetTOXSectionOrThrow() ); + return (m_bIsDescriptor) + ? SwForm::GetFormMaxLevel(m_eTOXType) + : rSection.GetTOXForm().GetFormMax(); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 14.12.98 09:35:07--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXDocumentIndex::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) + { + m_ListenerContainer.Disposing(); + } +} + +/*-- 14.12.98 09:35:03--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndex::SwXDocumentIndex( + SwTOXBaseSection const& rBaseSection, SwDoc & rDoc) + : m_pImpl( new SwXDocumentIndex::Impl( *this, + rDoc, rBaseSection.SwTOXBase::GetType(), & rBaseSection) ) +{ +} +/* -----------------15.01.99 14:59------------------- + * + * --------------------------------------------------*/ +SwXDocumentIndex::SwXDocumentIndex(const TOXTypes eType, SwDoc& rDoc) + : m_pImpl( new SwXDocumentIndex::Impl( *this, rDoc, eType, 0) ) +{ +} + +/*-- 14.12.98 09:35:04--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndex::~SwXDocumentIndex() +{ } + +uno::Reference +SwXDocumentIndex::CreateXDocumentIndex( + SwDoc & rDoc, SwTOXBaseSection const& rSection) +{ + // re-use existing SwXDocumentIndex + // #i105557#: do not iterate over the registered clients: race condition + SwSectionFmt *const pFmt = rSection.GetFmt(); + uno::Reference xIndex(pFmt->GetXObject(), + uno::UNO_QUERY); + if (!xIndex.is()) + { + SwXDocumentIndex *const pIndex(new SwXDocumentIndex(rSection, rDoc)); + xIndex.set(pIndex); + pFmt->SetXObject(uno::Reference(xIndex)); + } + return xIndex; +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -198,505 +375,530 @@ const uno::Sequence< sal_Int8 > & SwXDocumentIndex::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXDocumentIndex::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXDocumentIndex::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } + /* -----------------------------06.04.00 15:01-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndex::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXDocumentIndex"); } /* -----------------------------06.04.00 15:01-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndex::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) -{ - return C2U("com.sun.star.text.BaseIndex") == rServiceName || - ( TOX_INDEX == eTOXType && C2U("com.sun.star.text.DocumentIndex") == rServiceName) || - ( TOX_CONTENT == eTOXType && C2U("com.sun.star.text.ContentIndex") == rServiceName) || - ( TOX_USER == eTOXType && C2U("com.sun.star.text.UserDefinedIndex") == rServiceName) || - ( TOX_ILLUSTRATIONS == eTOXType && C2U("com.sun.star.text.IllustrationsIndex") == rServiceName) || - ( TOX_TABLES == eTOXType && C2U("com.sun.star.text.TableIndex") == rServiceName) || - ( TOX_OBJECTS == eTOXType && C2U("com.sun.star.text.ObjectIndex") == rServiceName) || - ( TOX_AUTHORITIES == eTOXType && C2U("com.sun.star.text.Bibliography") == rServiceName); +sal_Bool SAL_CALL +SwXDocumentIndex::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + return C2U("com.sun.star.text.BaseIndex") == rServiceName + || ((TOX_INDEX == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.DocumentIndex")) + || ((TOX_CONTENT == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.ContentIndex")) + || ((TOX_USER == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.UserDefinedIndex")) + || ((TOX_ILLUSTRATIONS == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.IllustrationsIndex")) + || ((TOX_TABLES == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.TableIndex")) + || ((TOX_OBJECTS == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.ObjectIndex")) + || ((TOX_AUTHORITIES == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.Bibliography")); } /* -----------------------------06.04.00 15:01-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndex::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::getSupportedServiceNames() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + uno::Sequence< OUString > aRet(2); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.BaseIndex"); - switch( eTOXType ) - { - case TOX_INDEX: pArray[1] = C2U("com.sun.star.text.DocumentIndex");break; - case TOX_CONTENT: pArray[1] = C2U("com.sun.star.text.ContentIndex");break; - case TOX_TABLES: pArray[1] = C2U("com.sun.star.text.TableIndex");break; - case TOX_ILLUSTRATIONS: pArray[1] = C2U("com.sun.star.text.IllustrationsIndex");break; - case TOX_OBJECTS: pArray[1] = C2U("com.sun.star.text.ObjectIndex");break; - case TOX_AUTHORITIES : pArray[1] = C2U("com.sun.star.text.Bibliography");break; + switch (m_pImpl->m_eTOXType) + { + case TOX_INDEX: + pArray[1] = C2U("com.sun.star.text.DocumentIndex"); + break; + case TOX_CONTENT: + pArray[1] = C2U("com.sun.star.text.ContentIndex"); + break; + case TOX_TABLES: + pArray[1] = C2U("com.sun.star.text.TableIndex"); + break; + case TOX_ILLUSTRATIONS: + pArray[1] = C2U("com.sun.star.text.IllustrationsIndex"); + break; + case TOX_OBJECTS: + pArray[1] = C2U("com.sun.star.text.ObjectIndex"); + break; + case TOX_AUTHORITIES: + pArray[1] = C2U("com.sun.star.text.Bibliography"); + break; //case TOX_USER: default: pArray[1] = C2U("com.sun.star.text.UserDefinedIndex"); } return aRet; } -/*-- 14.12.98 09:35:03--------------------------------------------------- - -----------------------------------------------------------------------*/ -TYPEINIT1(SwXDocumentIndex, SwClient) -SwXDocumentIndex::SwXDocumentIndex(const SwTOXBaseSection* pB, SwDoc* pDc) : - aLstnrCntnr( (text::XTextContent*)this), - m_pPropSet(0), - m_pDoc(pDc), - pBase(pB), - eTOXType(TOX_USER), - bIsDescriptor(sal_False), - pProps(0), - pStyleAccess(0), - pTokenAccess(0) -{ - if(pBase && m_pDoc) - { - pBase->GetFmt()->Add(this); - sal_uInt16 PropertyId; - eTOXType = pBase->SwTOXBase::GetType(); - switch( eTOXType ) - { - case TOX_INDEX: PropertyId = PROPERTY_MAP_INDEX_IDX; break; - case TOX_CONTENT: PropertyId = PROPERTY_MAP_INDEX_CNTNT; break; - case TOX_TABLES: PropertyId = PROPERTY_MAP_INDEX_TABLES; break; - case TOX_ILLUSTRATIONS: PropertyId = PROPERTY_MAP_INDEX_ILLUSTRATIONS; break; - case TOX_OBJECTS: PropertyId = PROPERTY_MAP_INDEX_OBJECTS; break; - case TOX_AUTHORITIES : PropertyId = PROPERTY_MAP_BIBLIOGRAPHY; break; - //case TOX_USER: - default: - PropertyId = PROPERTY_MAP_INDEX_USER; - } - m_pPropSet = aSwMapProvider.GetPropertySet(PropertyId); - } -} -/* -----------------15.01.99 14:59------------------- - * - * --------------------------------------------------*/ -SwXDocumentIndex::SwXDocumentIndex(TOXTypes eType, SwDoc& rDoc) : - aLstnrCntnr( (text::XTextContent*)this), - m_pDoc(0), - pBase(0), - eTOXType(eType), - bIsDescriptor(sal_True), - pProps(new SwDocIdxProperties_Impl(rDoc.GetTOXType(eType, 0))), - pStyleAccess(0), - pTokenAccess(0) -{ - sal_uInt16 PropertyId; - switch(eType) - { - case TOX_INDEX: PropertyId = PROPERTY_MAP_INDEX_IDX; break; - case TOX_CONTENT: PropertyId = PROPERTY_MAP_INDEX_CNTNT; break; - case TOX_TABLES: PropertyId = PROPERTY_MAP_INDEX_TABLES; break; - case TOX_ILLUSTRATIONS: PropertyId = PROPERTY_MAP_INDEX_ILLUSTRATIONS; break; - case TOX_OBJECTS: PropertyId = PROPERTY_MAP_INDEX_OBJECTS; break; - case TOX_AUTHORITIES : PropertyId = PROPERTY_MAP_BIBLIOGRAPHY; break; - //case TOX_USER: - default: - PropertyId = PROPERTY_MAP_INDEX_USER; - } - m_pPropSet = aSwMapProvider.GetPropertySet(PropertyId); -} - -/*-- 14.12.98 09:35:04--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndex::~SwXDocumentIndex() -{ - delete pProps; -} /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXDocumentIndex::getServiceName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXDocumentIndex::getServiceName() +throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + USHORT nObjectType = SW_SERVICE_TYPE_INDEX; - switch(eTOXType) + switch (m_pImpl->m_eTOXType) { // case TOX_INDEX: break; - case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX;break; - case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX;break; - case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS;break; - case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS;break; - case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES;break; - case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY;break; + case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX; + break; + case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX; + break; + case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS; + break; + case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS; + break; + case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES; + break; + case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY; + break; default: - ; + break; } return SwXServiceProvider::GetProviderName(nObjectType); } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::update(void) throw( uno::RuntimeException ) +void SAL_CALL SwXDocumentIndex::update() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt *pFmt = GetFmt(); - SwTOXBase* pTOXBase = pFmt ? (SwTOXBaseSection*)pFmt->GetSection() : 0; + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + SwTOXBaseSection *const pTOXBase = (pFmt) ? + static_cast(pFmt->GetSection()) : 0; if(!pTOXBase) + { throw uno::RuntimeException(); - ((SwTOXBaseSection*)pTOXBase)->Update(); - // Seitennummern eintragen - ((SwTOXBaseSection*)pTOXBase)->UpdatePageNum(); + } + pTOXBase->Update(); + // page numbers + pTOXBase->UpdatePageNum(); } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXDocumentIndex::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXDocumentIndex::getPropertySetInfo() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); - return aRef; + vos::OGuard g(Application::GetSolarMutex()); + + const uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); + return xRef; } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::setPropertyValue(const OUString& rPropertyName, - const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXDocumentIndex::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: " )) + + rPropertyName, + static_cast(this)); + } - SwTOXBase* pTOXBase = 0; - if(GetFmt()) - pTOXBase = (SwTOXBaseSection*)GetFmt()->GetSection(); - else if(bIsDescriptor) - pTOXBase = &pProps->GetTOXBase(); - if(pTOXBase) + SwSectionFmt *const pSectionFmt(m_pImpl->GetSectionFmt()); + SwTOXBase & rTOXBase( m_pImpl->GetTOXSectionOrThrow() ); + + sal_uInt16 nCreate = rTOXBase.GetCreateType(); + sal_uInt16 nTOIOptions = 0; + sal_uInt16 nOLEOptions = rTOXBase.GetOLEOptions(); + const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType(); + if (eTxBaseType == TOX_INDEX) { - sal_uInt16 nCreate = pTOXBase->GetCreateType(); - sal_uInt16 nTOIOptions = 0; - sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); - TOXTypes eTxBaseType = pTOXBase->GetTOXType()->GetType(); - if( eTxBaseType == TOX_INDEX ) - nTOIOptions = pTOXBase->GetOptions(); - SwForm aForm(pTOXBase->GetTOXForm()); - sal_Bool bForm = sal_False; - SfxItemSet* pAttrSet = 0; - switch(pEntry->nWID) + nTOIOptions = rTOXBase.GetOptions(); + } + SwForm aForm(rTOXBase.GetTOXForm()); + sal_Bool bForm = sal_False; + switch (pEntry->nWID) + { + case WID_IDX_TITLE: { - case WID_IDX_TITLE : - { - OUString sNewName; - aValue >>= sNewName; - pTOXBase->SetTitle(sNewName); - } - break; - case WID_IDX_NAME: + OUString sNewName; + if (!(rValue >>= sNewName)) { - OUString sNewName; - aValue >>= sNewName; - pTOXBase->SetTOXName(sNewName); - } - break; - case WID_USER_IDX_NAME: - { - OUString sNewName; - aValue >>= sNewName; - lcl_ConvertTOUNameToUserName(sNewName); - DBG_ASSERT(TOX_USER == eTxBaseType, "tox type name can only be changed for user indexes"); - if(GetFmt()) - { - OUString sTmp = pTOXBase->GetTOXType()->GetTypeName(); - if(sTmp != sNewName) - { - lcl_ReAssignTOXType(GetFmt()->GetDoc(), *pTOXBase, sNewName); - } - } - else - pProps->SetTypeName(sNewName); + throw lang::IllegalArgumentException(); } - break; - case WID_IDX_LOCALE: + rTOXBase.SetTitle(sNewName); + } + break; + case WID_IDX_NAME: + { + OUString sNewName; + if (!(rValue >>= sNewName)) { - lang::Locale aLocale; - if(aValue>>= aLocale) - pTOXBase->SetLanguage(SvxLocaleToLanguage(aLocale)); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case WID_IDX_SORT_ALGORITHM: + rTOXBase.SetTOXName(sNewName); + } + break; + case WID_USER_IDX_NAME: + { + OUString sNewName; + if (!(rValue >>= sNewName)) { - OUString sTmp; - if(aValue >>= sTmp) - pTOXBase->SetSortAlgorithm(sTmp); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case WID_LEVEL : - pTOXBase->SetLevel(lcl_AnyToInt16(aValue)); - break; - case WID_CREATE_FROM_MARKS : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_MARK: nCreate & ~nsSwTOXElement::TOX_MARK; - break; - case WID_CREATE_FROM_OUTLINE : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_OUTLINELEVEL: nCreate & ~nsSwTOXElement::TOX_OUTLINELEVEL; - break; -// case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented") -// break; - case WID_CREATE_FROM_CHAPTER : - pTOXBase->SetFromChapter(lcl_AnyToBool(aValue)); - break; - case WID_CREATE_FROM_LABELS : - pTOXBase->SetFromObjectNames(! lcl_AnyToBool(aValue)); - break; - case WID_PROTECTED : + lcl_ConvertTOUNameToUserName(sNewName); + DBG_ASSERT(TOX_USER == eTxBaseType, + "tox type name can only be changed for user indexes"); + if (pSectionFmt) { - sal_Bool bSet = lcl_AnyToBool(aValue); - pTOXBase->SetProtected(bSet); - if(GetFmt()) - ((SwTOXBaseSection*)pTOXBase)->SetProtect(bSet); + OUString sTmp = rTOXBase.GetTOXType()->GetTypeName(); + if (sTmp != sNewName) + { + lcl_ReAssignTOXType(pSectionFmt->GetDoc(), + rTOXBase, sNewName); + } } - break; - case WID_USE_ALPHABETICAL_SEPARATORS: - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_ALPHA_DELIMITTER : nTOIOptions & ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER; - break; - case WID_USE_KEY_AS_ENTRY : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_KEY_AS_ENTRY : nTOIOptions & ~nsSwTOIOptions::TOI_KEY_AS_ENTRY; - break; - case WID_USE_COMBINED_ENTRIES : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_SAME_ENTRY : nTOIOptions & ~nsSwTOIOptions::TOI_SAME_ENTRY; - break; - case WID_IS_CASE_SENSITIVE : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_CASE_SENSITIVE : nTOIOptions & ~nsSwTOIOptions::TOI_CASE_SENSITIVE; - break; - case WID_USE_P_P : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_FF : nTOIOptions & ~nsSwTOIOptions::TOI_FF; - break; - case WID_USE_DASH : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_DASH : nTOIOptions & ~nsSwTOIOptions::TOI_DASH; - break; - case WID_USE_UPPER_CASE : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_INITIAL_CAPS : nTOIOptions & ~nsSwTOIOptions::TOI_INITIAL_CAPS; - break; - case WID_IS_COMMA_SEPARATED : - bForm = sal_True; - aForm.SetCommaSeparated(lcl_AnyToBool(aValue)); - break; - case WID_LABEL_CATEGORY : + else { - // convert file-format/API/external programmatic english name - // to internal UI name before usage - String aName( SwStyleNameMapper::GetSpecialExtraUIName( - lcl_AnyToString(aValue) ) ); - pTOXBase->SetSequenceName( aName ); + m_pImpl->m_pProps->SetTypeName(sNewName); } - break; - case WID_LABEL_DISPLAY_TYPE : + } + break; + case WID_IDX_LOCALE: + { + lang::Locale aLocale; + if (!(rValue>>= aLocale)) { - sal_Int16 nVal = lcl_AnyToInt16(aValue); - sal_uInt16 nSet = CAPTION_COMPLETE; - switch (nVal) - { - case text::ReferenceFieldPart::TEXT: nSet = CAPTION_COMPLETE; - break; - case text::ReferenceFieldPart::CATEGORY_AND_NUMBER : nSet = CAPTION_NUMBER; - break; - case text::ReferenceFieldPart::ONLY_CAPTION : nSet = CAPTION_TEXT; - break; - default: - throw lang::IllegalArgumentException(); - } - pTOXBase->SetCaptionDisplay((SwCaptionDisplay)nSet); + throw lang::IllegalArgumentException(); } - break; - case WID_USE_LEVEL_FROM_SOURCE : - pTOXBase->SetLevelFromChapter(lcl_AnyToBool(aValue)); - break; - case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME : + rTOXBase.SetLanguage(SvxLocaleToLanguage(aLocale)); + } + break; + case WID_IDX_SORT_ALGORITHM: + { + OUString sTmp; + if (!(rValue >>= sTmp)) { - String aString; - SwStyleNameMapper::FillUIName(lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); - pTOXBase->SetMainEntryCharStyle( aString ); + throw lang::IllegalArgumentException(); } - break; - case WID_CREATE_FROM_TABLES : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_TABLE : nCreate & ~nsSwTOXElement::TOX_TABLE; - break; - case WID_CREATE_FROM_TEXT_FRAMES : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_FRAME : nCreate & ~nsSwTOXElement::TOX_FRAME; - break; - case WID_CREATE_FROM_GRAPHIC_OBJECTS : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_GRAPHIC : nCreate & ~nsSwTOXElement::TOX_GRAPHIC; - break; - case WID_CREATE_FROM_EMBEDDED_OBJECTS : - if(lcl_AnyToBool(aValue)) - nCreate |= nsSwTOXElement::TOX_OLE; - else - nCreate &= ~nsSwTOXElement::TOX_OLE; - break; - case WID_CREATE_FROM_STAR_MATH: - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_MATH : nOLEOptions & ~nsSwTOOElements::TOO_MATH; - break; - case WID_CREATE_FROM_STAR_CHART : - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_CHART : nOLEOptions & ~nsSwTOOElements::TOO_CHART; - break; - case WID_CREATE_FROM_STAR_CALC : - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_CALC : nOLEOptions & ~nsSwTOOElements::TOO_CALC; - break; - case WID_CREATE_FROM_STAR_DRAW : - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_DRAW_IMPRESS : nOLEOptions & ~nsSwTOOElements::TOO_DRAW_IMPRESS; - break; - case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_OTHER : nOLEOptions & ~nsSwTOOElements::TOO_OTHER; - break; - case WID_PARA_HEAD : + rTOXBase.SetSortAlgorithm(sTmp); + } + break; + case WID_LEVEL: + { + rTOXBase.SetLevel(lcl_AnyToInt16(rValue)); + } + break; + case WID_CREATE_FROM_MARKS: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_MARK); + break; + case WID_CREATE_FROM_OUTLINE: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OUTLINELEVEL); + break; +// case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented") +// break; + case WID_CREATE_FROM_CHAPTER: + rTOXBase.SetFromChapter(lcl_AnyToBool(rValue)); + break; + case WID_CREATE_FROM_LABELS: + rTOXBase.SetFromObjectNames(! lcl_AnyToBool(rValue)); + break; + case WID_PROTECTED: + { + sal_Bool bSet = lcl_AnyToBool(rValue); + rTOXBase.SetProtected(bSet); + if (pSectionFmt) { - String aString; - SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); - bForm = sal_True; - //Header steht an Pos 0 - aForm.SetTemplate( 0, aString ); + static_cast(rTOXBase).SetProtect(bSet); } - break; - case WID_IS_RELATIVE_TABSTOPS: - bForm = sal_True; - aForm.SetRelTabPos(lcl_AnyToBool(aValue)); - break; - case WID_PARA_SEP : + } + break; + case WID_USE_ALPHABETICAL_SEPARATORS: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_ALPHA_DELIMITTER); + break; + case WID_USE_KEY_AS_ENTRY: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_KEY_AS_ENTRY); + break; + case WID_USE_COMBINED_ENTRIES: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_SAME_ENTRY); + break; + case WID_IS_CASE_SENSITIVE: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_CASE_SENSITIVE); + break; + case WID_USE_P_P: + lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_FF); + break; + case WID_USE_DASH: + lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_DASH); + break; + case WID_USE_UPPER_CASE: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_INITIAL_CAPS); + break; + case WID_IS_COMMA_SEPARATED: + bForm = sal_True; + aForm.SetCommaSeparated(lcl_AnyToBool(rValue)); + break; + case WID_LABEL_CATEGORY: + { + // convert file-format/API/external programmatic english name + // to internal UI name before usage + String aName( SwStyleNameMapper::GetSpecialExtraUIName( + lcl_AnyToString(rValue) ) ); + rTOXBase.SetSequenceName( aName ); + } + break; + case WID_LABEL_DISPLAY_TYPE: + { + const sal_Int16 nVal = lcl_AnyToInt16(rValue); + sal_uInt16 nSet = CAPTION_COMPLETE; + switch (nVal) { - String aString; - bForm = sal_True; - SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); - aForm.SetTemplate( 1, aString ); + case text::ReferenceFieldPart::TEXT: + nSet = CAPTION_COMPLETE; + break; + case text::ReferenceFieldPart::CATEGORY_AND_NUMBER: + nSet = CAPTION_NUMBER; + break; + case text::ReferenceFieldPart::ONLY_CAPTION: + nSet = CAPTION_TEXT; + break; + default: + throw lang::IllegalArgumentException(); } - break; - case WID_CREATE_FROM_PARAGRAPH_STYLES: - nCreate = lcl_AnyToBool(aValue) ? - (nCreate | nsSwTOXElement::TOX_TEMPLATE) : (nCreate & ~nsSwTOXElement::TOX_TEMPLATE); - break; - - case WID_PARA_LEV1 : - case WID_PARA_LEV2 : - case WID_PARA_LEV3 : - case WID_PARA_LEV4 : - case WID_PARA_LEV5 : - case WID_PARA_LEV6 : - case WID_PARA_LEV7 : - case WID_PARA_LEV8 : - case WID_PARA_LEV9 : - case WID_PARA_LEV10 : + rTOXBase.SetCaptionDisplay(static_cast(nSet)); + } + break; + case WID_USE_LEVEL_FROM_SOURCE: + rTOXBase.SetLevelFromChapter(lcl_AnyToBool(rValue)); + break; + case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: + { + String aString; + SwStyleNameMapper::FillUIName(lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + rTOXBase.SetMainEntryCharStyle( aString ); + } + break; + case WID_CREATE_FROM_TABLES: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TABLE); + break; + case WID_CREATE_FROM_TEXT_FRAMES: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_FRAME); + break; + case WID_CREATE_FROM_GRAPHIC_OBJECTS: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_GRAPHIC); + break; + case WID_CREATE_FROM_EMBEDDED_OBJECTS: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OLE); + break; + case WID_CREATE_FROM_STAR_MATH: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_MATH); + break; + case WID_CREATE_FROM_STAR_CHART: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CHART); + break; + case WID_CREATE_FROM_STAR_CALC: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CALC); + break; + case WID_CREATE_FROM_STAR_DRAW: + lcl_AnyToBitMask(rValue, nOLEOptions, + nsSwTOOElements::TOO_DRAW_IMPRESS); + break; + case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_OTHER); + break; + case WID_PARA_HEAD: + { + String aString; + SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + bForm = sal_True; + // Header is on Pos 0 + aForm.SetTemplate( 0, aString ); + } + break; + case WID_IS_RELATIVE_TABSTOPS: + bForm = sal_True; + aForm.SetRelTabPos(lcl_AnyToBool(rValue)); + break; + case WID_PARA_SEP: + { + String aString; + bForm = sal_True; + SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + aForm.SetTemplate( 1, aString ); + } + break; + case WID_CREATE_FROM_PARAGRAPH_STYLES: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TEMPLATE); + break; + + case WID_PARA_LEV1: + case WID_PARA_LEV2: + case WID_PARA_LEV3: + case WID_PARA_LEV4: + case WID_PARA_LEV5: + case WID_PARA_LEV6: + case WID_PARA_LEV7: + case WID_PARA_LEV8: + case WID_PARA_LEV9: + case WID_PARA_LEV10: + { + bForm = sal_True; + // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 + const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1; + String aString; + SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString ); + } + break; + default: + //this is for items only + if (WID_PRIMARY_KEY > pEntry->nWID) { - bForm = sal_True; - // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1 - sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1; - String aString; - SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); - aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString ); - } - break; - default: - //this is for items only - if(WID_PRIMARY_KEY > pEntry->nWID) + const SwAttrSet& rSet = + m_pImpl->m_pDoc->GetTOXBaseAttrSet(rTOXBase); + SfxItemSet aAttrSet(rSet); + m_pImpl->m_rPropSet.setPropertyValue( + rPropertyName, rValue, aAttrSet); + + const SwSectionFmts& rSects = m_pImpl->m_pDoc->GetSections(); + for (sal_uInt16 i = 0; i < rSects.Count(); i++) { - const SwAttrSet& rSet = m_pDoc->GetTOXBaseAttrSet(*pTOXBase); - pAttrSet = new SfxItemSet(rSet); - m_pPropSet->setPropertyValue(rPropertyName, aValue, *pAttrSet); - - const SwSectionFmts& rSects = m_pDoc->GetSections(); - const SwSectionFmt* pOwnFmt = GetFmt(); - for(sal_uInt16 i = 0; i < rSects.Count(); i++) + const SwSectionFmt* pTmpFmt = rSects[ i ]; + if (pTmpFmt == pSectionFmt) { - const SwSectionFmt* pTmpFmt = rSects[ i ]; - if(pTmpFmt == pOwnFmt) - { - m_pDoc->ChgSection( i, *(SwTOXBaseSection*)pTOXBase, pAttrSet ); - break; - } + m_pImpl->m_pDoc->ChgSection( i, + static_cast(rTOXBase), + & aAttrSet); + break; } } - } - pTOXBase->SetCreate(nCreate); - pTOXBase->SetOLEOptions(nOLEOptions); - if(pTOXBase->GetTOXType()->GetType() == TOX_INDEX) - pTOXBase->SetOptions(nTOIOptions); - if(bForm) - pTOXBase->SetTOXForm(aForm); - delete pAttrSet; + } + } + rTOXBase.SetCreate(nCreate); + rTOXBase.SetOLEOptions(nOLEOptions); + if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX) + { + rTOXBase.SetOptions(nTOIOptions); + } + if (bForm) + { + rTOXBase.SetTOXForm(aForm); } - else - throw uno::RuntimeException(); - } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast< cppu::OWeakObject * >(this)); + } + + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); SwTOXBase* pTOXBase = 0; - if(GetFmt()) - pTOXBase = (SwTOXBaseSection*)GetFmt()->GetSection(); - else if(bIsDescriptor) - pTOXBase = &pProps->GetTOXBase(); + if (pSectionFmt) + { + pTOXBase = static_cast(pSectionFmt->GetSection()); + } + else if (m_pImpl->m_bIsDescriptor) + { + pTOXBase = &m_pImpl->m_pProps->GetTOXBase(); + } if(pTOXBase) { - sal_uInt16 nCreate = pTOXBase->GetCreateType(); - sal_uInt16 nTOIOptions = 0; - sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); - if(pTOXBase->GetTOXType()->GetType() == TOX_INDEX) - nTOIOptions = pTOXBase->GetOptions(); + const sal_uInt16 nCreate = pTOXBase->GetCreateType(); + const sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); + const sal_uInt16 nTOIOptions = + (pTOXBase->GetTOXType()->GetType() == TOX_INDEX) + ? pTOXBase->GetOptions() + : 0U; const SwForm& rForm = pTOXBase->GetTOXForm(); - sal_Bool bBOOL = sal_True; - sal_Bool bRet = sal_False; switch(pEntry->nWID) { case WID_IDX_CONTENT_SECTION: case WID_IDX_HEADER_SECTION : - bBOOL = sal_False; if(WID_IDX_CONTENT_SECTION == pEntry->nWID) { - uno::Reference xContentSect = SwXTextSections::GetObject( *GetFmt() ); + const uno::Reference xContentSect = + SwXTextSection::CreateXTextSection( pSectionFmt ); aRet <<= xContentSect; } else { SwSections aSectArr; - GetFmt()->GetChildSections( aSectArr, SORTSECT_NOT, FALSE); + pSectionFmt->GetChildSections(aSectArr, + SORTSECT_NOT, FALSE); for(USHORT i = 0; i < aSectArr.Count(); i++) { SwSection* pSect = aSectArr[i]; if(pSect->GetType() == TOX_HEADER_SECTION) { - uno::Reference xHeaderSect = SwXTextSections::GetObject( *pSect->GetFmt() ); - aRet <<= xHeaderSect; + const uno::Reference xHeader = + SwXTextSection::CreateXTextSection( + pSect->GetFmt() ); + aRet <<= xHeader; break; } } @@ -704,80 +906,96 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) break; case WID_IDX_TITLE : { - bBOOL = sal_False; OUString uRet(pTOXBase->GetTitle()); aRet <<= uRet; break; } case WID_IDX_NAME: - bBOOL = sal_False; aRet <<= OUString(pTOXBase->GetTOXName()); break; case WID_USER_IDX_NAME: { - bBOOL = sal_False; OUString sTmp; - if(!IsDescriptor()) + if (!m_pImpl->m_bIsDescriptor) + { sTmp = pTOXBase->GetTOXType()->GetTypeName(); + } else - sTmp = pProps->GetTypeName(); + { + sTmp = m_pImpl->m_pProps->GetTypeName(); + } //I18N lcl_ConvertTOUNameToProgrammaticName(sTmp); aRet <<= sTmp; } break; case WID_IDX_LOCALE: - bBOOL = sal_False; aRet <<= SvxCreateLocale(pTOXBase->GetLanguage()); break; case WID_IDX_SORT_ALGORITHM: - bBOOL = sal_False; aRet <<= OUString(pTOXBase->GetSortAlgorithm()); break; case WID_LEVEL : - bBOOL = sal_False; - aRet <<= (sal_Int16)pTOXBase->GetLevel(); + aRet <<= static_cast(pTOXBase->GetLevel()); break; - case WID_CREATE_FROM_MARKS : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_MARK); + case WID_CREATE_FROM_MARKS: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_MARK); break; - case WID_CREATE_FROM_OUTLINE : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_OUTLINELEVEL); + case WID_CREATE_FROM_OUTLINE: + lcl_BitMaskToAny(aRet, nCreate, + nsSwTOXElement::TOX_OUTLINELEVEL); break; - case WID_CREATE_FROM_CHAPTER : - bRet = pTOXBase->IsFromChapter(); + case WID_CREATE_FROM_CHAPTER: + { + const sal_Bool bRet = pTOXBase->IsFromChapter(); + aRet <<= bRet; + } break; - case WID_CREATE_FROM_LABELS : - bRet = ! pTOXBase->IsFromObjectNames(); + case WID_CREATE_FROM_LABELS: + { + const sal_Bool bRet = ! pTOXBase->IsFromObjectNames(); + aRet <<= bRet; + } break; - case WID_PROTECTED : - bRet = pTOXBase->IsProtected(); + case WID_PROTECTED: + { + const sal_Bool bRet = pTOXBase->IsProtected(); + aRet <<= bRet; + } break; case WID_USE_ALPHABETICAL_SEPARATORS: - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_ALPHA_DELIMITTER); + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_ALPHA_DELIMITTER); break; - case WID_USE_KEY_AS_ENTRY : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_KEY_AS_ENTRY); + case WID_USE_KEY_AS_ENTRY: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_KEY_AS_ENTRY); break; - case WID_USE_COMBINED_ENTRIES : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_SAME_ENTRY); + case WID_USE_COMBINED_ENTRIES: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_SAME_ENTRY); break; - case WID_IS_CASE_SENSITIVE : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE); + case WID_IS_CASE_SENSITIVE: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_CASE_SENSITIVE); break; case WID_USE_P_P: - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_FF); + lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_FF); break; - case WID_USE_DASH : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_DASH); + case WID_USE_DASH: + lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_DASH); break; - case WID_USE_UPPER_CASE : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_INITIAL_CAPS); + case WID_USE_UPPER_CASE: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_INITIAL_CAPS); break; - case WID_IS_COMMA_SEPARATED : - bRet = rForm.IsCommaSeparated(); + case WID_IS_COMMA_SEPARATED: + { + const sal_Bool bRet = rForm.IsCommaSeparated(); + aRet <<= bRet; + } break; - case WID_LABEL_CATEGORY : + case WID_LABEL_CATEGORY: { // convert internal UI name to // file-format/API/external programmatic english name @@ -785,50 +1003,58 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) String aName( SwStyleNameMapper::GetSpecialExtraProgName( pTOXBase->GetSequenceName() ) ); aRet <<= OUString( aName ); - bBOOL = sal_False; } break; - case WID_LABEL_DISPLAY_TYPE : + case WID_LABEL_DISPLAY_TYPE: { - bBOOL = sal_False; sal_Int16 nSet = text::ReferenceFieldPart::TEXT; switch (pTOXBase->GetCaptionDisplay()) { - case CAPTION_COMPLETE: nSet = text::ReferenceFieldPart::TEXT;break; - case CAPTION_NUMBER : nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; break; - case CAPTION_TEXT : nSet = text::ReferenceFieldPart::ONLY_CAPTION; break; + case CAPTION_COMPLETE: + nSet = text::ReferenceFieldPart::TEXT; + break; + case CAPTION_NUMBER: + nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; + break; + case CAPTION_TEXT: + nSet = text::ReferenceFieldPart::ONLY_CAPTION; + break; } aRet <<= nSet; } break; - case WID_USE_LEVEL_FROM_SOURCE : - bRet = pTOXBase->IsLevelFromChapter(); + case WID_USE_LEVEL_FROM_SOURCE: + { + const sal_Bool bRet = pTOXBase->IsLevelFromChapter(); + aRet <<= bRet; + } break; - case WID_LEVEL_FORMAT : + case WID_LEVEL_FORMAT: { - uno::Reference< container::XIndexReplace > xTokenAcc = - ((SwXDocumentIndex*)this)->GetTokenAccess(); - if(!xTokenAcc.is()) - xTokenAcc = new SwXIndexTokenAccess_Impl(* - (SwXDocumentIndex*)this); - aRet.setValue(&xTokenAcc, ::getCppuType((const uno::Reference*)0)); - bBOOL = sal_False; + uno::Reference< container::XIndexReplace > xTokenAccess( + m_pImpl->m_wTokenAccess); + if (!xTokenAccess.is()) + { + xTokenAccess = new SwXIndexTokenAccess_Impl(*this); + m_pImpl->m_wTokenAccess = xTokenAccess; + } + aRet <<= xTokenAccess; } break; - case WID_LEVEL_PARAGRAPH_STYLES : + case WID_LEVEL_PARAGRAPH_STYLES: { - uno::Reference< container::XIndexReplace > xStyleAcc = - ((SwXDocumentIndex*)this)->GetStyleAccess(); - if(!xStyleAcc.is()) - xStyleAcc = new SwXIndexStyleAccess_Impl(* - (SwXDocumentIndex*)this); - aRet.setValue(&xStyleAcc, ::getCppuType((const uno::Reference*)0)); - bBOOL = sal_False; + uno::Reference< container::XIndexReplace > xStyleAccess( + m_pImpl->m_wStyleAccess); + if (!xStyleAccess.is()) + { + xStyleAccess = new SwXIndexStyleAccess_Impl(*this); + m_pImpl->m_wStyleAccess = xStyleAccess; + } + aRet <<= xStyleAccess; } break; - case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME : + case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: { - bBOOL = sal_False; String aString; SwStyleNameMapper::FillProgName( pTOXBase->GetMainEntryCharStyle(), @@ -838,47 +1064,47 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) aRet <<= OUString( aString ); } break; - case WID_CREATE_FROM_TABLES : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_TABLE); + case WID_CREATE_FROM_TABLES: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TABLE); break; - case WID_CREATE_FROM_TEXT_FRAMES : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_FRAME); + case WID_CREATE_FROM_TEXT_FRAMES: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_FRAME); break; - case WID_CREATE_FROM_GRAPHIC_OBJECTS : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_GRAPHIC); + case WID_CREATE_FROM_GRAPHIC_OBJECTS: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_GRAPHIC); break; - case WID_CREATE_FROM_EMBEDDED_OBJECTS : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_OLE); + case WID_CREATE_FROM_EMBEDDED_OBJECTS: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_OLE); break; case WID_CREATE_FROM_STAR_MATH: - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_MATH); + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_MATH); break; - case WID_CREATE_FROM_STAR_CHART : - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_CHART); + case WID_CREATE_FROM_STAR_CHART: + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CHART); break; - case WID_CREATE_FROM_STAR_CALC : - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_CALC); + case WID_CREATE_FROM_STAR_CALC: + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CALC); break; - case WID_CREATE_FROM_STAR_DRAW : - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_DRAW_IMPRESS); + case WID_CREATE_FROM_STAR_DRAW: + lcl_BitMaskToAny(aRet, nOLEOptions, + nsSwTOOElements::TOO_DRAW_IMPRESS); break; case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_OTHER); + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_OTHER); break; case WID_CREATE_FROM_PARAGRAPH_STYLES: - bRet = 0 != (nCreate & nsSwTOXElement::TOX_TEMPLATE); + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TEMPLATE); break; - case WID_PARA_HEAD : + case WID_PARA_HEAD: { //Header steht an Pos 0 String aString; SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); aRet <<= OUString( aString ); - bBOOL = sal_False; } break; - case WID_PARA_SEP : + case WID_PARA_SEP: { String aString; SwStyleNameMapper::FillProgName( @@ -887,21 +1113,20 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); aRet <<= OUString( aString ); - bBOOL = sal_False; } break; - case WID_PARA_LEV1 : - case WID_PARA_LEV2 : - case WID_PARA_LEV3 : - case WID_PARA_LEV4 : - case WID_PARA_LEV5 : - case WID_PARA_LEV6 : - case WID_PARA_LEV7 : - case WID_PARA_LEV8 : - case WID_PARA_LEV9 : - case WID_PARA_LEV10 : + case WID_PARA_LEV1: + case WID_PARA_LEV2: + case WID_PARA_LEV3: + case WID_PARA_LEV4: + case WID_PARA_LEV5: + case WID_PARA_LEV6: + case WID_PARA_LEV7: + case WID_PARA_LEV8: + case WID_PARA_LEV9: + case WID_PARA_LEV10: { - // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1 + // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1; String aString; SwStyleNameMapper::FillProgName( @@ -910,282 +1135,319 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); aRet <<= OUString( aString ); - bBOOL = sal_False; } break; case WID_IS_RELATIVE_TABSTOPS: - bRet = rForm.IsRelTabPos(); + { + const sal_Bool bRet = rForm.IsRelTabPos(); + aRet <<= bRet; + } break; case WID_INDEX_MARKS: { SwTOXMarks aMarks; - const SwTOXType* pType = pTOXBase->GetTOXType(); - SwClientIter aIter(*(SwTOXType*)pType); - SwTOXMark* pMark = (SwTOXMark*)aIter.First(TYPE(SwTOXMark)); + SwTOXType const*const pType = pTOXBase->GetTOXType(); + SwClientIter aIter(*pType); + SwTOXMark * pMark = + static_cast(aIter.First(TYPE(SwTOXMark))); while( pMark ) { if(pMark->GetTxtTOXMark()) + { aMarks.C40_INSERT(SwTOXMark, pMark, aMarks.Count()); - pMark = (SwTOXMark*)aIter.Next(); + } + pMark = static_cast(aIter.Next()); } - uno::Sequence< uno::Reference < text::XDocumentIndexMark > > aXMarks(aMarks.Count()); - uno::Reference* pxMarks = aXMarks.getArray(); + uno::Sequence< uno::Reference > + aXMarks(aMarks.Count()); + uno::Reference* pxMarks = + aXMarks.getArray(); for(USHORT i = 0; i < aMarks.Count(); i++) { pMark = aMarks.GetObject(i); - pxMarks[i] = SwXDocumentIndexMark::GetObject((SwTOXType*)pType, pMark, m_pDoc); + pxMarks[i] = SwXDocumentIndexMark::GetObject( + const_cast(pType), pMark, m_pImpl->m_pDoc); } - aRet.setValue(&aXMarks, ::getCppuType((uno::Sequence< uno::Reference< text::XDocumentIndexMark > >*)0)); - bBOOL = sal_False; + aRet <<= aXMarks; } break; default: //this is for items only - bBOOL = sal_False; if(WID_PRIMARY_KEY > pEntry->nWID) { - const SwAttrSet& rSet = m_pDoc->GetTOXBaseAttrSet(*pTOXBase); - aRet = m_pPropSet->getPropertyValue(rPropertyName, rSet); + const SwAttrSet& rSet = + m_pImpl->m_pDoc->GetTOXBaseAttrSet(*pTOXBase); + aRet = m_pImpl->m_rPropSet.getPropertyValue( + rPropertyName, rSet); } } - if(bBOOL) - aRet.setValue(&bRet, ::getCppuBooleanType()); } return aRet; } -/*-- 14.12.98 09:35:06--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ - DBG_WARNING("not implemented"); -} /*-- 14.12.98 09:35:06--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndex::addPropertyChangeListener(): not implemented"); } -/*-- 14.12.98 09:35:06--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndex::removePropertyChangeListener(): not implemented"); } -/*-- 14.12.98 09:35:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndex::addVetoableChangeListener(): not implemented"); } -/*-- 14.12.98 09:35:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SAL_CALL +SwXDocumentIndex::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - BOOL bRemove = FALSE; - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - bRemove = (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject; - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - bRemove = ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR(); - break; - } - if( bRemove ) - { - ((SwModify*)GetRegisteredIn())->Remove( this ); - aLstnrCntnr.Disposing(); - } + OSL_ENSURE(false, + "SwXDocumentIndex::removeVetoableChangeListener(): not implemented"); } + /* -----------------18.02.99 13:39------------------- * * --------------------------------------------------*/ -void SwXDocumentIndex::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + } + const uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + throw lang::IllegalArgumentException(); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDoc ) + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + + const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); + if (pOld) { - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - ::sw::XTextRangeToSwPaM(aPam, xTextRange); + throw lang::IllegalArgumentException(); + } - const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); - if(!pOld) - { - UnoActionContext aAction(pDoc); - if(aPam.HasMark()) - pDoc->DeleteAndJoin(aPam); + UnoActionContext aAction(pDoc); + if (aPam.HasMark()) + { + pDoc->DeleteAndJoin(aPam); + } - SwTOXBase& rTOXBase = pProps->GetTOXBase(); - const SwTOXType* pTOXType = rTOXBase.GetTOXType(); - if(TOX_USER == pTOXType->GetType() && !pProps->GetTypeName().equals(pTOXType->GetTypeName())) - { - lcl_ReAssignTOXType(pDoc, rTOXBase, pProps->GetTypeName()); - } - //TODO: apply Section attributes (columns and background) - const SwTOXBaseSection* pTOX = pDoc->InsertTableOf( - *aPam.GetPoint(), rTOXBase, 0, sal_False ); + SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase(); + SwTOXType const*const pTOXType = rTOXBase.GetTOXType(); + if ((TOX_USER == pTOXType->GetType()) && + !m_pImpl->m_pProps->GetTypeName().equals(pTOXType->GetTypeName())) + { + lcl_ReAssignTOXType(pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName()); + } + //TODO: apply Section attributes (columns and background) + SwTOXBaseSection const*const pTOX = + pDoc->InsertTableOf( *aPam.GetPoint(), rTOXBase, 0, sal_False ); - pDoc->SetTOXBaseName( *pTOX, pProps->GetTOXBase().GetTOXName() ); + pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName()); - // Seitennummern eintragen - pBase = (const SwTOXBaseSection*)pTOX; - pBase->GetFmt()->Add(this); - ((SwTOXBaseSection*)pTOX)->UpdatePageNum(); - } - else - throw lang::IllegalArgumentException(); + // update page numbers + pTOX->GetFmt()->Add(m_pImpl.get()); + pTOX->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); + const_cast(pTOX)->UpdatePageNum(); - DELETEZ(pProps); - m_pDoc = pDoc; - bIsDescriptor = sal_False; - } + m_pImpl->m_pProps.reset(); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsDescriptor = sal_False; } -/*-- 15.01.99 14:23:51--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); -} /*-- 15.01.99 14:23:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXDocumentIndex::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXDocumentIndex::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - if(GetRegisteredIn()) + + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (!pSectionFmt) { - SwSectionFmt* pSectFmt = GetFmt(); - const SwNodeIndex* pIdx; - if( 0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) && - pIdx->GetNode().GetNodes().IsDocNodes() ) - { - SwPaM aPaM(*pIdx); - aPaM.Move( fnMoveForward, fnGoCntnt ); - aPaM.SetMark(); - aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); - aPaM.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), - *aPaM.GetMark(), aPaM.GetPoint()); - } - } - else throw uno::RuntimeException(); + } + + uno::Reference< text::XTextRange > xRet; + SwNodeIndex const*const pIdx( pSectionFmt->GetCntnt().GetCntntIdx() ); + if (pIdx && pIdx->GetNode().GetNodes().IsDocNodes()) + { + SwPaM aPaM(*pIdx); + aPaM.Move( fnMoveForward, fnGoCntnt ); + aPaM.SetMark(); + aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); + aPaM.Move( fnMoveBackward, fnGoCntnt ); + xRet = SwXTextRange::CreateXTextRange(*pSectionFmt->GetDoc(), + *aPaM.GetMark(), aPaM.GetPoint()); + } return xRet; } + /*-- 15.01.99 15:46:48--------------------------------------------------- -----------------------------------------------------------------------*/ void lcl_RemoveChildSections(SwSectionFmt& rParentFmt) { SwSections aTmpArr; - SwDoc* pDoc = rParentFmt.GetDoc(); - sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr,SORTSECT_POS); + SwDoc *const pDoc = rParentFmt.GetDoc(); + const sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr, SORTSECT_POS); if( nCnt ) { for( sal_uInt16 n = 0; n < nCnt; ++n ) + { if( aTmpArr[n]->GetFmt()->IsInNodesArr() ) { SwSectionFmt* pFmt = aTmpArr[n]->GetFmt(); lcl_RemoveChildSections(*pFmt); pDoc->DelSectionFmt( pFmt ); } + } } } -void SwXDocumentIndex::dispose(void) throw( uno::RuntimeException ) + +void SAL_CALL SwXDocumentIndex::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetRegisteredIn()) + + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (pSectionFmt) { - SwSectionFmt* pSectFmt = GetFmt(); - pSectFmt->GetDoc()->DeleteTOX( *(SwTOXBaseSection*)pSectFmt->GetSection(), sal_True); + pSectionFmt->GetDoc()->DeleteTOX( + *static_cast(pSectionFmt->GetSection()), + sal_True); } - else - throw uno::RuntimeException(); } + /*-- 15.01.99 15:46:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 15.01.99 15:46:54--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /* -----------------30.07.99 11:28------------------- --------------------------------------------------*/ -OUString SwXDocumentIndex::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXDocumentIndex::getName() throw (uno::RuntimeException) { - SwSectionFmt* pSectionFmt = GetFmt(); + vos::OGuard g(Application::GetSolarMutex()); + OUString uRet; - if(bIsDescriptor) + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (m_pImpl->m_bIsDescriptor) { - uRet = OUString(pProps->GetTOXBase().GetTOXName()); + uRet = OUString(m_pImpl->m_pProps->GetTOXBase().GetTOXName()); } else if(pSectionFmt) { uRet = OUString(pSectionFmt->GetSection()->GetName()); } else + { throw uno::RuntimeException(); + } return uRet; } /* -----------------30.07.99 11:28------------------- --------------------------------------------------*/ -void SwXDocumentIndex::setName(const OUString& rName) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::setName(const OUString& rName) throw (uno::RuntimeException) { - SwSectionFmt* pSectionFmt = GetFmt(); - String sNewName(rName); - sal_Bool bExcept = sal_False; - if(!sNewName.Len()) - bExcept = sal_True; - if(bIsDescriptor) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rName.getLength()) { - pProps->GetTOXBase().SetTOXName(sNewName); + throw uno::RuntimeException(); } - else if(!pSectionFmt || - !pSectionFmt->GetDoc()->SetTOXBaseName( - *(SwTOXBaseSection*)pSectionFmt->GetSection(), sNewName)) - bExcept = sal_True; - if(bExcept) + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName); + } + else if (pSectionFmt) + { + const bool bSuccess = pSectionFmt->GetDoc()->SetTOXBaseName( + *static_cast(pSectionFmt->GetSection()), rName); + if (!bSuccess) + { + throw uno::RuntimeException(); + } + } + else + { throw uno::RuntimeException(); + } } /****************************************************************** @@ -2018,7 +2280,6 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) if(!IsValid()) throw uno::RuntimeException(); - uno::Any aRet; sal_Int32 nIdx = 0; const SwSectionFmts& rFmts = GetDoc()->GetSections(); @@ -2029,9 +2290,11 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) pSect->GetFmt()->GetSectionNode() && nIdx++ == nIndex ) { - uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex( - (SwTOXBaseSection*)pSect, GetDoc() ); - aRet.setValue(&xTmp, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; return aRet; } } @@ -2049,7 +2312,6 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName) if(!IsValid()) throw uno::RuntimeException(); - uno::Any aRet; String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); @@ -2060,9 +2322,11 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName) pSect->GetFmt()->GetSectionNode() && ((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind) { - uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex( - (SwTOXBaseSection*)pSect, GetDoc() ); - aRet.setValue(&xTmp, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; return aRet; } } @@ -2145,17 +2409,6 @@ sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException ) return 0 != getCount(); } -SwXDocumentIndex* SwXDocumentIndexes::GetObject(const SwTOXBaseSection* pTOX) -{ - SwSectionFmt* pFmt = pTOX->GetFmt(); - SwClientIter aIter(*pFmt); - SwXDocumentIndex* pxIdx = (SwXDocumentIndex*)aIter.First(TYPE(SwXDocumentIndex)); - if(pxIdx) - return pxIdx; - else - return new SwXDocumentIndex(pTOX, pFmt->GetDoc()); -} - /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ @@ -2187,16 +2440,12 @@ SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx) rParent(rParentIdx), xParent(&rParentIdx) { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetStyleAccess(this); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl() { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetStyleAccess(0); } /*-- 13.09.99 16:52:29--------------------------------------------------- @@ -2206,14 +2455,13 @@ void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); + if(nIndex < 0 || nIndex > MAXLEVEL) + { throw lang::IndexOutOfBoundsException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + } + + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); uno::Sequence aSeq; if(!(rElement >>= aSeq)) @@ -2247,14 +2495,13 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); + if(nIndex < 0 || nIndex > MAXLEVEL) + { throw lang::IndexOutOfBoundsException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + } + + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); const String& rStyles = pTOXBase->GetStyleNames((sal_uInt16) nIndex); sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); @@ -2322,18 +2569,14 @@ uno::Sequence< OUString > SwXIndexTokenAccess_Impl::getSupportedServiceNames(voi SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx) : rParent(rParentIdx), xParent(&rParentIdx), - nCount(SwForm::GetFormMaxLevel(rParent.GetTOXType())) + nCount(0) { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetTokenAccess(this); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl() { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetTokenAccess(0); } /*-- 13.09.99 16:52:29--------------------------------------------------- @@ -2343,13 +2586,9 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + if(nIndex < 0 || (nIndex > pTOXBase->GetTOXForm().GetFormMax())) throw lang::IndexOutOfBoundsException(); @@ -2358,6 +2597,7 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& if(!(rElement >>= aSeq)) throw lang::IllegalArgumentException(); + String sPattern; sal_Int32 nTokens = aSeq.getLength(); const beans::PropertyValues* pTokens = aSeq.getConstArray(); @@ -2519,14 +2759,8 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& sal_Int32 SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); - sal_Int32 nRet = bDescriptor ? - nCount : - ((SwTOXBaseSection*)pSectFmt->GetSection())-> - GetTOXForm().GetFormMax(); + + const sal_Int32 nRet = rParent.m_pImpl->GetFormMax(); return nRet; } /*-- 13.09.99 16:52:30--------------------------------------------------- @@ -2537,12 +2771,9 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + if(nIndex < 0 || (nIndex > pTOXBase->GetTOXForm().GetFormMax())) throw lang::IndexOutOfBoundsException(); diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 907a2a617c..6eeb9757e4 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -1169,7 +1169,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, SwTOXBaseSection *const pTOXBaseSect = PTR_CAST(SwTOXBaseSection, pEnclosingSection); const uno::Reference xIndex = - SwXDocumentIndexes::GetObject(pTOXBaseSect); + SwXDocumentIndex::CreateXDocumentIndex( + *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect); pRet[nProperty] <<= xIndex; } // else: no enclosing index found -> empty return value -- cgit v1.2.3 From fd162033b86e6baef8488e0f540a5d5e488a2c36 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:58 +0100 Subject: swunolocking1: #i105557#: move SwXDocumentIndex helper classes out of header. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoidx.hxx | 80 +----- sw/source/core/unocore/unoidx.cxx | 549 ++++++++++++++++++++++++++------------ 2 files changed, 381 insertions(+), 248 deletions(-) diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 3ea515cf11..553e6e8f7e 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -32,9 +32,7 @@ #include #include -#include #include -#include #include #include @@ -53,8 +51,6 @@ class SwTOXType; /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ -class SwXIndexStyleAccess_Impl; -class SwXIndexTokenAccess_Impl; typedef ::cppu::WeakImplHelper5 < ::com::sun::star::lang::XUnoTunnel @@ -70,8 +66,8 @@ class SwXDocumentIndex private: - friend class SwXIndexStyleAccess_Impl; - friend class SwXIndexTokenAccess_Impl; + class StyleAccess_Impl; + class TokenAccess_Impl; class Impl; ::sw::UnoImplPtr m_pImpl; @@ -316,79 +312,7 @@ public: virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); -}; -/* -----------------13.09.99 16:39------------------- - - --------------------------------------------------*/ -class SwXIndexStyleAccess_Impl : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XIndexReplace, - ::com::sun::star::lang::XServiceInfo -> -{ - SwXDocumentIndex& rParent; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndex > xParent; -protected: - virtual ~SwXIndexStyleAccess_Impl(); -public: - SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx); - - - //XIndexReplace - virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - -}; - -/* -----------------13.09.99 16:39------------------- - - --------------------------------------------------*/ -class SwXIndexTokenAccess_Impl : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XIndexReplace, - ::com::sun::star::lang::XServiceInfo -> -{ - SwXDocumentIndex& rParent; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndex > xParent; - sal_Int32 nCount; -protected: - virtual ~SwXIndexTokenAccess_Impl(); -public: - SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx); - - - - //XIndexReplace - virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - }; #endif - diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 3aef38b685..76f28ac107 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,12 +31,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include +#include #include #include #include -#include #include -#include #include #include @@ -75,7 +76,7 @@ using namespace ::com::sun::star; using ::rtl::OUString; //----------------------------------------------------------------------------- -static String +static OUString lcl_AnyToString(uno::Any const& rVal) throw (lang::IllegalArgumentException) { OUString sRet; @@ -190,6 +191,104 @@ lcl_ConvertTOUNameToUserName(OUString& rTmp) } } +/* -----------------13.09.99 16:39------------------- + + --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< lang::XServiceInfo +, container::XIndexReplace +> SwXDocumentIndexStyleAccess_Base; + +class SwXDocumentIndex::StyleAccess_Impl + : public SwXDocumentIndexStyleAccess_Base +{ + +private: + /// can be destroyed threadsafely, so no UnoImplPtr here + ::rtl::Reference m_xParent; + + virtual ~StyleAccess_Impl(); + +public: + StyleAccess_Impl(SwXDocumentIndex& rParentIdx); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL + supportsService(const ::rtl::OUString& rServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL + replaceByIndex(sal_Int32 Index, const uno::Any& rElement) + throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException); + +}; + +/* -----------------13.09.99 16:39------------------- + + --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< lang::XServiceInfo +, container::XIndexReplace +> SwXDocumentIndexTokenAccess_Base; + +class SwXDocumentIndex::TokenAccess_Impl + : public SwXDocumentIndexTokenAccess_Base +{ + +private: + /// can be destroyed threadsafely, so no UnoImplPtr here + ::rtl::Reference m_xParent; + + virtual ~TokenAccess_Impl(); + +public: + + TokenAccess_Impl(SwXDocumentIndex& rParentIdx); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL + supportsService(const ::rtl::OUString& rServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL + replaceByIndex(sal_Int32 Index, const uno::Any& rElement) + throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException); + +}; + + /****************************************************************** * SwXDocumentIndex ******************************************************************/ @@ -1035,7 +1134,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, m_pImpl->m_wTokenAccess); if (!xTokenAccess.is()) { - xTokenAccess = new SwXIndexTokenAccess_Impl(*this); + xTokenAccess = new TokenAccess_Impl(*this); m_pImpl->m_wTokenAccess = xTokenAccess; } aRet <<= xTokenAccess; @@ -1047,7 +1146,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, m_pImpl->m_wStyleAccess); if (!xStyleAccess.is()) { - xStyleAccess = new SwXIndexStyleAccess_Impl(*this); + xStyleAccess = new StyleAccess_Impl(*this); m_pImpl->m_wStyleAccess = xStyleAccess; } aRet <<= xStyleAccess; @@ -2409,49 +2508,66 @@ sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException ) return 0 != getCount(); } -/* -----------------------------06.04.00 15:08-------------------------------- +/****************************************************************** + * SwXDocumentIndex::StyleAccess_Impl + ******************************************************************/ - ---------------------------------------------------------------------------*/ -OUString SwXIndexStyleAccess_Impl::getImplementationName(void) throw( uno::RuntimeException ) +/*-- 13.09.99 16:52:28--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndex::StyleAccess_Impl::StyleAccess_Impl( + SwXDocumentIndex& rParentIdx) + : m_xParent(&rParentIdx) { - return C2U("SwXIndexStyleAccess_Impl"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:29--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXIndexStyleAccess_Impl::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::StyleAccess_Impl::~StyleAccess_Impl() { - return C2U("com.sun.star.text.DocumentIndexParagraphStyles") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXIndexStyleAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexParagraphStyles"); - return aRet; + return C2U("SwXDocumentIndex::StyleAccess_Impl"); } -/*-- 13.09.99 16:52:28--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx) : - rParent(rParentIdx), - xParent(&rParentIdx) +static char const*const g_ServicesIndexStyleAccess[] = { + "com.sun.star.text.DocumentIndexParagraphStyles", +}; +static const size_t g_nServicesIndexStyleAccess( + sizeof(g_ServicesIndexStyleAccess)/sizeof(g_ServicesIndexStyleAccess[0])); + +sal_Bool SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::supportsService( + const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess, rServiceName); } -/*-- 13.09.99 16:52:29--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getSupportedServiceNames() +throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess); } + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement) - throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, +void SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::replaceByIndex( + sal_Int32 nIndex, const uno::Any& rElement) +throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2461,38 +2577,45 @@ void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& throw lang::IndexOutOfBoundsException(); } - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); uno::Sequence aSeq; if(!(rElement >>= aSeq)) + { throw lang::IllegalArgumentException(); + } - sal_Int32 nStyles = aSeq.getLength(); + const sal_Int32 nStyles = aSeq.getLength(); const OUString* pStyles = aSeq.getConstArray(); String sSetStyles; String aString; for(sal_Int32 i = 0; i < nStyles; i++) { if(i) + { sSetStyles += TOX_STYLE_DELIMITER; - SwStyleNameMapper::FillUIName(pStyles[i], aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + } + SwStyleNameMapper::FillUIName(pStyles[i], aString, + nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); sSetStyles += aString; } - pTOXBase->SetStyleNames(sSetStyles, (sal_uInt16) nIndex); + rTOXBase.SetStyleNames(sSetStyles, static_cast(nIndex)); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXIndexStyleAccess_Impl::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getCount() throw (uno::RuntimeException) { return MAXLEVEL; } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2501,10 +2624,11 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) throw lang::IndexOutOfBoundsException(); } - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - const String& rStyles = pTOXBase->GetStyleNames((sal_uInt16) nIndex); - sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); + const String& rStyles = + rTOXBase.GetStyleNames(static_cast(nIndex)); + const sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); uno::Sequence aStyles(nStyles); OUString* pStyles = aStyles.getArray(); String aString; @@ -2523,116 +2647,143 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXIndexStyleAccess_Impl::getElementType(void) - throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getElementType() +throw (uno::RuntimeException) { return ::getCppuType((uno::Sequence*)0); } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXIndexStyleAccess_Impl::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::hasElements() throw (uno::RuntimeException) { return sal_True; } -/* -----------------13.09.99 16:51------------------- - - --------------------------------------------------*/ -/* -----------------------------06.04.00 15:08-------------------------------- +/****************************************************************** + * SwXDocumentIndex::TokenAccess_Impl + ******************************************************************/ +/*-- 13.09.99 16:52:28--------------------------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXIndexTokenAccess_Impl::getImplementationName(void) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::TokenAccess_Impl::TokenAccess_Impl( + SwXDocumentIndex& rParentIdx) + : m_xParent(&rParentIdx) { - return C2U("SwXIndexTokenAccess_Impl"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:29--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXIndexTokenAccess_Impl::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::TokenAccess_Impl::~TokenAccess_Impl() { - return C2U("com.sun.star.text.DocumentIndexLevelFormat") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXIndexTokenAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexLevelFormat"); - return aRet; + return C2U("SwXDocumentIndex::TokenAccess_Impl"); } -/*-- 13.09.99 16:52:28--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx) : - rParent(rParentIdx), - xParent(&rParentIdx), - nCount(0) +static char const*const g_ServicesIndexTokenAccess[] = +{ + "com.sun.star.text.DocumentIndexLevelFormat", +}; +static const size_t g_nServicesIndexTokenAccess( + sizeof(g_ServicesIndexTokenAccess)/sizeof(g_ServicesIndexTokenAccess[0])); + +sal_Bool SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::supportsService( + const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess, rServiceName); } -/*-- 13.09.99 16:52:29--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getSupportedServiceNames() +throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess); } + +struct TokenType { + const char *pName; + const enum FormTokenType eTokenType; +}; + +static const struct TokenType g_TokenTypes[] = +{ + { "TokenEntryNumber", TOKEN_ENTRY_NO }, + { "TokenEntryText", TOKEN_ENTRY_TEXT }, + { "TokenTabStop", TOKEN_TAB_STOP }, + { "TokenText", TOKEN_TEXT }, + { "TokenPageNumber", TOKEN_PAGE_NUMS }, + { "TokenChapterInfo", TOKEN_CHAPTER_INFO }, + { "TokenHyperlinkStart", TOKEN_LINK_START }, + { "TokenHyperlinkEnd", TOKEN_LINK_END }, + { "TokenBibliographyDataField", TOKEN_AUTHORITY }, + { 0, static_cast(0) } +}; + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement) - throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, - lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( + sal_Int32 nIndex, const uno::Any& rElement) +throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - if(nIndex < 0 || - (nIndex > pTOXBase->GetTOXForm().GetFormMax())) - throw lang::IndexOutOfBoundsException(); + if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) + { + throw lang::IndexOutOfBoundsException(); + } uno::Sequence aSeq; if(!(rElement >>= aSeq)) + { throw lang::IllegalArgumentException(); - + } String sPattern; - sal_Int32 nTokens = aSeq.getLength(); + const sal_Int32 nTokens = aSeq.getLength(); const beans::PropertyValues* pTokens = aSeq.getConstArray(); for(sal_Int32 i = 0; i < nTokens; i++) { const beans::PropertyValue* pProperties = pTokens[i].getConstArray(); - sal_Int32 nProperties = pTokens[i].getLength(); + const sal_Int32 nProperties = pTokens[i].getLength(); //create an invalid token SwFormToken aToken(TOKEN_END); for(sal_Int32 j = 0; j < nProperties; j++) { - if( COMPARE_EQUAL == pProperties[j].Name.compareToAscii("TokenType")) + if (pProperties[j].Name.equalsAscii("TokenType")) { - const String sTokenType = + const OUString sTokenType = lcl_AnyToString(pProperties[j].Value); - if(sTokenType.EqualsAscii("TokenEntryNumber")) - aToken.eTokenType = TOKEN_ENTRY_NO; - else if(sTokenType.EqualsAscii("TokenEntryText" )) - aToken.eTokenType = TOKEN_ENTRY_TEXT; - else if(sTokenType.EqualsAscii("TokenTabStop" )) - aToken.eTokenType = TOKEN_TAB_STOP; - else if(sTokenType.EqualsAscii("TokenText" )) - aToken.eTokenType = TOKEN_TEXT; - else if(sTokenType.EqualsAscii("TokenPageNumber")) - aToken.eTokenType = TOKEN_PAGE_NUMS; - else if(sTokenType.EqualsAscii("TokenChapterInfo" )) - aToken.eTokenType = TOKEN_CHAPTER_INFO; - else if(sTokenType.EqualsAscii("TokenHyperlinkStart" )) - aToken.eTokenType = TOKEN_LINK_START; - else if(sTokenType.EqualsAscii("TokenHyperlinkEnd")) - aToken.eTokenType = TOKEN_LINK_END; - else if(sTokenType.EqualsAscii("TokenBibliographyDataField" )) - aToken.eTokenType = TOKEN_AUTHORITY; + for (TokenType const* pTokenType = g_TokenTypes; + pTokenType->pName; ++pTokenType) + { + if (sTokenType.equalsAscii(pTokenType->pName)) + { + aToken.eTokenType = pTokenType->eTokenType; + break; + } + } } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("CharacterStyleName" ) )) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("CharacterStyleName"))) { String sCharStyleName; SwStyleNameMapper::FillUIName( @@ -2642,54 +2793,68 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& sal_True); aToken.sCharStyleName = sCharStyleName; aToken.nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( - sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); + sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned") )) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned"))) { - sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); + const sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); aToken.eTabAlign = bRight ? SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopPosition" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopPosition"))) { sal_Int32 nPosition = 0; - if(pProperties[j].Value.getValueType() != ::getCppuType((sal_Int32*)0)) + if (!(pProperties[j].Value >>= nPosition)) + { throw lang::IllegalArgumentException(); - pProperties[j].Value >>= nPosition; + } nPosition = MM100_TO_TWIP(nPosition); if(nPosition < 0) + { throw lang::IllegalArgumentException(); + } aToken.nTabStopPosition = nPosition; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter"))) { - const String sFillChar = + const OUString sFillChar = lcl_AnyToString(pProperties[j].Value); - if(sFillChar.Len() > 1) + if (sFillChar.getLength() > 1) + { throw lang::IllegalArgumentException(); - aToken.cTabFillChar = sFillChar.Len() ? - sFillChar.GetChar(0) : ' '; + } + aToken.cTabFillChar = + (sFillChar.getLength()) ? sFillChar[0] : ' '; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Text" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("Text"))) { - const String sText = - lcl_AnyToString(pProperties[j].Value); + const OUString sText = lcl_AnyToString(pProperties[j].Value); aToken.sText = sText; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterFormat" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ChapterFormat"))) { sal_Int16 nFormat = lcl_AnyToInt16(pProperties[j].Value); switch(nFormat) { - case text::ChapterFormat::NUMBER: nFormat = CF_NUMBER; + case text::ChapterFormat::NUMBER: + nFormat = CF_NUMBER; break; - case text::ChapterFormat::NAME: nFormat = CF_TITLE; + case text::ChapterFormat::NAME: + nFormat = CF_TITLE; break; - case text::ChapterFormat::NAME_NUMBER: nFormat = CF_NUM_TITLE; + case text::ChapterFormat::NAME_NUMBER: + nFormat = CF_NUM_TITLE; break; - case text::ChapterFormat::NO_PREFIX_SUFFIX:nFormat = CF_NUMBER_NOPREPST; + case text::ChapterFormat::NO_PREFIX_SUFFIX: + nFormat = CF_NUMBER_NOPREPST; break; - case text::ChapterFormat::DIGIT: nFormat = CF_NUM_NOPREPST_TITLE; + case text::ChapterFormat::DIGIT: + nFormat = CF_NUM_NOPREPST_TITLE; break; default: throw lang::IllegalArgumentException(); @@ -2697,15 +2862,19 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& aToken.nChapterFormat = nFormat; } //--->i53420 - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterLevel")) ) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ChapterLevel"))) { const sal_Int16 nLevel = lcl_AnyToInt16(pProperties[j].Value); if( nLevel < 1 || nLevel > MAXLEVEL ) + { throw lang::IllegalArgumentException(); + } aToken.nOutlineLevel = nLevel; } //<--- - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) { sal_Int16 nType = 0; pProperties[j].Value >>= nType; @@ -2719,7 +2888,8 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& aToken.nAuthorityField = nType; } // #i21237# - else if ( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("WithTab"))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WithTab"))) { aToken.bWithTab = lcl_AnyToBool(pProperties[j].Value); } @@ -2727,17 +2897,22 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& } //exception if wrong TokenType if(TOKEN_END <= aToken.eTokenType ) + { throw lang::IllegalArgumentException(); + } // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is // not a content index if(TOKEN_ENTRY_TEXT == aToken.eTokenType && - TOX_CONTENT != pTOXBase->GetType()) + (TOX_CONTENT != rTOXBase.GetType())) + { aToken.eTokenType = TOKEN_ENTRY; + } //---> i53420 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE // reading from file if( TOKEN_ENTRY_NO == aToken.eTokenType ) + { switch(aToken.nChapterFormat) { case CF_NUMBER: @@ -2746,41 +2921,47 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& default: throw lang::IllegalArgumentException(); } + } //<--- sPattern += aToken.GetString(); } - SwForm aForm(pTOXBase->GetTOXForm()); - aForm.SetPattern((sal_uInt16) nIndex, sPattern); - pTOXBase->SetTOXForm(aForm); + SwForm aForm(rTOXBase.GetTOXForm()); + aForm.SetPattern(static_cast(nIndex), sPattern); + rTOXBase.SetTOXForm(aForm); } + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Int32 nRet = rParent.m_pImpl->GetFormMax(); + const sal_Int32 nRet = m_xParent->m_pImpl->GetFormMax(); return nRet; } + /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - if(nIndex < 0 || - (nIndex > pTOXBase->GetTOXForm().GetFormMax())) + if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) + { throw lang::IndexOutOfBoundsException(); + } // #i21237# - SwFormTokens aPattern = pTOXBase->GetTOXForm(). - GetPattern((sal_uInt16) nIndex); + SwFormTokens aPattern = rTOXBase.GetTOXForm(). + GetPattern(static_cast(nIndex)); SwFormTokens::iterator aIt = aPattern.begin(); sal_uInt16 nTokenCount = 0; @@ -2793,7 +2974,8 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) beans::PropertyValues* pTokenProps = aRetSeq.getArray(); SwFormToken aToken = *aIt; // #i21237# - uno::Sequence< beans::PropertyValue >& rCurTokenSeq = pTokenProps[nTokenCount-1]; + uno::Sequence< beans::PropertyValue >& rCurTokenSeq = + pTokenProps[nTokenCount-1]; SwStyleNameMapper::FillProgName( aToken.sCharStyleName, aString, @@ -2802,25 +2984,30 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) const OUString aProgCharStyle( aString ); switch(aToken.eTokenType) { - case TOKEN_ENTRY_NO : + case TOKEN_ENTRY_NO: { //--->i53420 // writing to file (from doc to properties) sal_Int32 nElements = 2; sal_Int32 nCurrentElement = 0; - if( aToken.nChapterFormat != CF_NUMBER )//check for default value + // check for default value + if (aToken.nChapterFormat != CF_NUMBER) + { nElements++;//we need the element + } if( aToken.nOutlineLevel != MAXLEVEL ) + { nElements++; + } rCurTokenSeq.realloc( nElements ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[nCurrentElement].Name = C2U("TokenType"); - pArr[nCurrentElement++].Value <<= OUString::createFromAscii("TokenEntryNumber"); -// pArr[0].Value <<= C2U("TokenEntryNumber"); + pArr[nCurrentElement++].Value <<= + OUString::createFromAscii("TokenEntryNumber"); pArr[nCurrentElement].Name = C2U("CharacterStyleName"); pArr[nCurrentElement++].Value <<= aProgCharStyle; @@ -2828,18 +3015,24 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) { pArr[nCurrentElement].Name = C2U("ChapterFormat"); sal_Int16 nVal; -//! the allowed values for chapter format, when used as entry number, are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to +// the allowed values for chapter format, when used as entry number, +// are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to //CF_NUMBER switch(aToken.nChapterFormat) { default: - case CF_NUMBER: nVal = text::ChapterFormat::NUMBER; break; - case CF_NUM_NOPREPST_TITLE: nVal = text::ChapterFormat::DIGIT; break; + case CF_NUMBER: + nVal = text::ChapterFormat::NUMBER; + break; + case CF_NUM_NOPREPST_TITLE: + nVal = text::ChapterFormat::DIGIT; + break; } - pArr[nCurrentElement++].Value <<= (sal_Int16)nVal; + pArr[nCurrentElement++].Value <<= nVal; } - if( aToken.nOutlineLevel != MAXLEVEL ) //only a ChapterLevel != MAXLEVEL is registered + // only a ChapterLevel != MAXLEVEL is registered + if (aToken.nOutlineLevel != MAXLEVEL) { pArr[nCurrentElement].Name = C2U("ChapterLevel"); pArr[nCurrentElement].Value <<= aToken.nOutlineLevel; @@ -2847,8 +3040,8 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) //<--- } break; - case TOKEN_ENTRY : // no difference between Entry and Entry Text - case TOKEN_ENTRY_TEXT : + case TOKEN_ENTRY: // no difference between Entry and Entry Text + case TOKEN_ENTRY_TEXT: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2860,7 +3053,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_TAB_STOP : + case TOKEN_TAB_STOP: { rCurTokenSeq.realloc(5); // #i21237# beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2868,7 +3061,6 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Name = C2U("TokenType"); pArr[0].Value <<= OUString::createFromAscii("TokenTabStop"); - if(SVX_TAB_ADJUST_END == aToken.eTabAlign) { pArr[1].Name = C2U("TabStopRightAligned"); @@ -2889,10 +3081,10 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[3].Value <<= aProgCharStyle; // #i21237# pArr[4].Name = C2U("WithTab"); - pArr[4].Value.setValue(&aToken.bWithTab, ::getCppuBooleanType()); + pArr[4].Value <<= static_cast(aToken.bWithTab); } break; - case TOKEN_TEXT : + case TOKEN_TEXT: { rCurTokenSeq.realloc( 3 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2907,7 +3099,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[2].Value <<= OUString(aToken.sText); } break; - case TOKEN_PAGE_NUMS : + case TOKEN_PAGE_NUMS: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2919,7 +3111,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_CHAPTER_INFO : + case TOKEN_CHAPTER_INFO: { rCurTokenSeq.realloc( 4 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2934,13 +3126,23 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) sal_Int16 nVal = text::ChapterFormat::NUMBER; switch(aToken.nChapterFormat) { - case CF_NUMBER: nVal = text::ChapterFormat::NUMBER; break; - case CF_TITLE: nVal = text::ChapterFormat::NAME; break; - case CF_NUM_TITLE: nVal = text::ChapterFormat::NAME_NUMBER; break; - case CF_NUMBER_NOPREPST: nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; break; - case CF_NUM_NOPREPST_TITLE: nVal = text::ChapterFormat::DIGIT; break; + case CF_NUMBER: + nVal = text::ChapterFormat::NUMBER; + break; + case CF_TITLE: + nVal = text::ChapterFormat::NAME; + break; + case CF_NUM_TITLE: + nVal = text::ChapterFormat::NAME_NUMBER; + break; + case CF_NUMBER_NOPREPST: + nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; + break; + case CF_NUM_NOPREPST_TITLE: + nVal = text::ChapterFormat::DIGIT; + break; } - pArr[2].Value <<= (sal_Int16)nVal; + pArr[2].Value <<= nVal; //--->i53420 pArr[3].Name = C2U("ChapterLevel"); // @@ -2948,33 +3150,36 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) //<--- } break; - case TOKEN_LINK_START : + case TOKEN_LINK_START: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenHyperlinkStart"); + pArr[0].Value <<= + OUString::createFromAscii("TokenHyperlinkStart"); pArr[1].Name = C2U("CharacterStyleName"); pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_LINK_END : + case TOKEN_LINK_END: { rCurTokenSeq.realloc( 1 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenHyperlinkEnd"); + pArr[0].Value <<= + OUString::createFromAscii("TokenHyperlinkEnd"); } break; - case TOKEN_AUTHORITY : + case TOKEN_AUTHORITY: { rCurTokenSeq.realloc( 3 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenBibliographyDataField"); + pArr[0].Value <<= + OUString::createFromAscii("TokenBibliographyDataField"); pArr[1].Name = C2U("CharacterStyleName"); pArr[1].Value <<= aProgCharStyle; @@ -2991,22 +3196,26 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) aIt++; // #i21237# } - uno::Any aRet(&aRetSeq, ::getCppuType((uno::Sequence< beans::PropertyValues >*)0)); - + uno::Any aRet; + aRet <<= aRetSeq; return aRet; } + /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXIndexTokenAccess_Impl::getElementType(void) - throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getElementType() +throw (uno::RuntimeException) { return ::getCppuType((uno::Sequence< beans::PropertyValues >*)0); } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXIndexTokenAccess_Impl::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::hasElements() +throw (uno::RuntimeException) { return sal_True; } -- cgit v1.2.3 From fd8c8bf1502e9c77665e116a8a024f35f4389f0f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:59 +0100 Subject: swunolocking1: #i105557#: SwXDocumentIndexes: use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoidx.hxx | 67 ++++++++++------- sw/source/core/unocore/unoidx.cxx | 150 +++++++++++++++++++++++--------------- 2 files changed, 131 insertions(+), 86 deletions(-) diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 553e6e8f7e..c4737e0e68 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -271,46 +271,57 @@ public: SwDoc* pDoc); void Invalidate(); }; + /* -----------------05.05.99 12:27------------------- * * --------------------------------------------------*/ - -class SwXDocumentIndexes : public SwCollectionBaseClass, - public SwUnoCollection +class SwXDocumentIndexes + : public SwCollectionBaseClass + , public SwUnoCollection { -protected: - virtual ~SwXDocumentIndexes(); -public: - SwXDocumentIndexes(SwDoc* pDoc); - -// SMART_UNO_DECLARATION( SwXDocumentIndexes, UsrObject ); +private: -// automatisch auskommentiert - [getIdlClass or queryInterface] - Bitte XTypeProvider benutzen! -// virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > > getIdlClasses(void) + virtual ~SwXDocumentIndexes(); -// throw( ::com::sun::star::uno::RuntimeException ); -// automatisch auskommentiert - [getIdlClass or queryInterface] - Bitte XTypeProvider benutzen! -// virtual sal_Bool queryInterface( ::com::sun::star::uno::Uik aUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rOut ); +public: + SwXDocumentIndexes(SwDoc *const pDoc); - //XNameAccess - virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + // XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( + const ::rtl::OUString& rName) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getElementNames() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); }; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 76f28ac107..ee94746f0a 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -2312,49 +2312,63 @@ void SwXDocumentIndexMark::Invalidate() m_pDoc = 0; } } -/* -----------------------------06.04.00 15:08-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndexes::getImplementationName(void) throw( uno::RuntimeException ) +/****************************************************************** + * SwXDocumentIndexes + ******************************************************************/ +/*-- 05.05.99 13:14:59--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexes::SwXDocumentIndexes(SwDoc *const _pDoc) + : SwUnoCollection(_pDoc) { - return C2U("SwXDocumentIndexes"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 05.05.99 13:15:00--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndexes::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndexes::~SwXDocumentIndexes() { - return C2U("com.sun.star.text.DocumentIndexes") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexes::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexes::getImplementationName() throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexes"); - return aRet; + return C2U("SwXDocumentIndexes"); } -/*-- 05.05.99 13:14:59--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexes::SwXDocumentIndexes(SwDoc* _pDoc) : - SwUnoCollection(_pDoc) +static char const*const g_ServicesDocumentIndexes[] = +{ + "com.sun.star.text.DocumentIndexes", +}; +static const size_t g_nServicesDocumentIndexes( + sizeof(g_ServicesDocumentIndexes)/sizeof(g_ServicesDocumentIndexes[0])); + +sal_Bool SAL_CALL +SwXDocumentIndexes::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesDocumentIndexes, g_ServicesDocumentIndexes, rServiceName); } -/*-- 05.05.99 13:15:00--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexes::~SwXDocumentIndexes() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexes::getSupportedServiceNames() throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesDocumentIndexes, g_ServicesDocumentIndexes); } + /*-- 05.05.99 13:15:01--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndexes::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2365,17 +2379,23 @@ sal_Int32 SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException ) const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() ) + { ++nRet; + } } return nRet; } + /*-- 05.05.99 13:15:01--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2388,14 +2408,14 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() && nIdx++ == nIndex ) - { - const uno::Reference< text::XDocumentIndex > xTmp = - SwXDocumentIndex::CreateXDocumentIndex( - *GetDoc(), static_cast(*pSect)); - uno::Any aRet; - aRet <<= xTmp; - return aRet; - } + { + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; + return aRet; + } } throw lang::IndexOutOfBoundsException(); @@ -2404,14 +2424,16 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) /*-- 31.01.00 10:12:31--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexes::getByName(const OUString& rName) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexes::getByName(const OUString& rName) +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); - String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) @@ -2419,25 +2441,28 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName) const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() && - ((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind) - { - const uno::Reference< text::XDocumentIndex > xTmp = - SwXDocumentIndex::CreateXDocumentIndex( - *GetDoc(), static_cast(*pSect)); - uno::Any aRet; - aRet <<= xTmp; - return aRet; - } + (static_cast(pSect)->GetTOXName() + == sToFind)) + { + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; + return aRet; + } } throw container::NoSuchElementException(); } + /*-- 31.01.00 10:12:31--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void) - throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexes::getElementNames() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2446,10 +2471,12 @@ uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void) sal_uInt16 n; for( n = 0; n < rFmts.Count(); ++n ) { - const SwSection* pSect = rFmts[ n ]->GetSection(); + SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() ) + { ++nCount; + } } uno::Sequence< OUString > aRet(nCount); @@ -2457,22 +2484,26 @@ uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void) sal_uInt16 nCnt; for( n = 0, nCnt = 0; n < rFmts.Count(); ++n ) { - const SwSection* pSect = rFmts[ n ]->GetSection(); + SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode()) { - pArray[nCnt++] = OUString(((SwTOXBaseSection*)pSect)->GetTOXName()); + pArray[nCnt++] = OUString( + static_cast(pSect)->GetTOXName()); } } return aRet; } + /*-- 31.01.00 10:12:31--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXDocumentIndexes::hasByName(const OUString& rName) - throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexes::hasByName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2480,31 +2511,34 @@ sal_Bool SwXDocumentIndexes::hasByName(const OUString& rName) const SwSectionFmts& rFmts = GetDoc()->GetSections(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) { - const SwSection* pSect = rFmts[ n ]->GetSection(); + SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode()) { - if(((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind) + if (static_cast(pSect)->GetTOXName() + == sToFind) + { return sal_True; + } } } return sal_False; } + /*-- 05.05.99 13:15:01--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXDocumentIndexes::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndexes::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference< text::XDocumentIndex> *)0); + return text::XDocumentIndex::static_type(); } /*-- 05.05.99 13:15:02--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexes::hasElements() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) - throw uno::RuntimeException(); return 0 != getCount(); } -- cgit v1.2.3 From 04dfba1fe39ee428e812417c47704353aede0423 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:59 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXDocumentIndexMark: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. disable broken SwClient iteration. make constructor private, and add factory function CreateXDocumentIndexMark. use new XUnoTunnel helpers. clean up the implementation a little. remove SwXDocumentIndexMark::GetObject(). --- sw/inc/unoidx.hxx | 179 +++--- sw/source/core/unocore/unoclbck.cxx | 12 +- sw/source/core/unocore/unocrsrhelper.cxx | 8 +- sw/source/core/unocore/unoidx.cxx | 992 ++++++++++++++++++------------- sw/source/core/unocore/unoportenum.cxx | 5 +- 5 files changed, 700 insertions(+), 496 deletions(-) diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index c4737e0e68..4824068b3f 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -36,14 +36,13 @@ #include #include +#include #include -#include #include #include -class SfxItemPropertySet; class SwTOXBaseSection; class SwTOXMark; class SwTOXType; @@ -189,87 +188,129 @@ public: /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ -class SwXDocumentIndexMark : public cppu::WeakImplHelper4 -< - ::com::sun::star::text::XDocumentIndexMark, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient +typedef ::cppu::WeakImplHelper4 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XDocumentIndexMark +> SwXDocumentIndexMark_Base; + +class SwXDocumentIndexMark + : public SwXDocumentIndexMark_Base { - SwEventListenerContainer aLstnrCntnr; - SwDepend aTypeDepend; - SwDoc* m_pDoc; - const SwTOXMark* m_pTOXMark; - const SfxItemPropertySet* m_pPropSet; - - sal_Bool bIsDescriptor; - sal_Bool bMainEntry; - TOXTypes eType; - sal_uInt16 nLevel; - String sAltText; - String sPrimaryKey; - String sSecondaryKey; - String sTextReading; - String sPrimaryKeyReading; - String sSecondaryKeyReading; - String sUserIndexName; - - void InitMap(TOXTypes eToxType); -protected: + +private: + + class Impl; + ::sw::UnoImplPtr m_pImpl; + virtual ~SwXDocumentIndexMark(); -public: - SwXDocumentIndexMark(TOXTypes eToxType); - SwXDocumentIndexMark(const SwTOXType* pType, - const SwTOXMark* pMark, - SwDoc* pDc); - - TYPEINFO(); + SwXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, const SwTOXMark & rMark); - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); +public: - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + /// descriptor + SwXDocumentIndexMark(const TOXTypes eToxType); - virtual rtl::OUString SAL_CALL getMarkEntry(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setMarkEntry(const rtl::OUString& aIndexEntry) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark> + CreateXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, const SwTOXMark & rMark); - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + 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); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); - 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 ); + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); - SwTOXType* GetTOXType() const {return (SwTOXType*)aTypeDepend.GetRegisteredIn();} - const SwTOXMark* GetTOXMark() const {return m_pTOXMark;} + // XDocumentIndexMark + virtual rtl::OUString SAL_CALL getMarkEntry() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMarkEntry(const rtl::OUString& rIndexEntry) + throw (::com::sun::star::uno::RuntimeException); - static SwXDocumentIndexMark* GetObject(SwTOXType* pType, const SwTOXMark* pMark, - SwDoc* pDoc); - void Invalidate(); }; /* -----------------05.05.99 12:27------------------- diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 96ba9b2421..a05a37abf7 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -78,18 +78,8 @@ SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) /* -----------------------------27.11.00 17:15-------------------------------- ---------------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& rMark) +SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& /*rMark*/) { - SwClientIter aIter( *this ); - SwXDocumentIndexMark* pxIndexMark = (SwXDocumentIndexMark*)aIter.First( TYPE( SwXDocumentIndexMark )); - while(pxIndexMark) - { - const SwTOXMark* pMark = pxIndexMark->GetTOXMark(); - if(pMark == &rMark) - return pxIndexMark; - - pxIndexMark = (SwXDocumentIndexMark*)aIter.Next( ); - } return 0; } diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 739378f3fb..cb0aa83e22 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -314,9 +314,11 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry if( pAny ) { const SwTOXMark& rMark = pTxtAttr->GetTOXMark(); - uno::Reference< XDocumentIndexMark > xRef = SwXDocumentIndexMark::GetObject( - (SwTOXType*)rMark.GetTOXType(), &rMark, rPam.GetDoc()); - pAny->setValue(&xRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndexMark > xRef = + SwXDocumentIndexMark::CreateXDocumentIndexMark( + *rPam.GetDoc(), + *const_cast(rMark.GetTOXType()), rMark); + (*pAny) <<= xRef; } } else diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index ee94746f0a..8e4d56e705 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -70,6 +70,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -326,7 +327,7 @@ SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl( } static sal_uInt16 -lcl_TypeToPropertyMap(const TOXTypes eType) +lcl_TypeToPropertyMap_Index(const TOXTypes eType) { switch (eType) { @@ -363,7 +364,7 @@ public: SwTOXBaseSection const*const pBaseSection) : SwClient((pBaseSection) ? pBaseSection->GetFmt() : 0) , m_rPropSet( - *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap(eType))) + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Index(eType))) , m_eTOXType(eType) , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) , m_bIsDescriptor(0 == pBaseSection) @@ -1264,8 +1265,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, for(USHORT i = 0; i < aMarks.Count(); i++) { pMark = aMarks.GetObject(i); - pxMarks[i] = SwXDocumentIndexMark::GetObject( - const_cast(pType), pMark, m_pImpl->m_pDoc); + pxMarks[i] = SwXDocumentIndexMark::CreateXDocumentIndexMark( + *m_pImpl->m_pDoc, + *const_cast(pType), *pMark); } aRet <<= aXMarks; } @@ -1552,6 +1554,165 @@ SwXDocumentIndex::setName(const OUString& rName) throw (uno::RuntimeException) /****************************************************************** * SwXDocumentIndexMark ******************************************************************/ +/* -----------------21.04.99 09:36------------------- + * + * --------------------------------------------------*/ +static sal_uInt16 +lcl_TypeToPropertyMap_Mark(const TOXTypes eType) +{ + switch (eType) + { + case TOX_INDEX: return PROPERTY_MAP_INDEX_MARK; + case TOX_CONTENT: return PROPERTY_MAP_CNTIDX_MARK; + //case TOX_USER: + default: + return PROPERTY_MAP_USER_MARK; + } +} + +class SwXDocumentIndexMark::Impl + : public SwClient +{ + +public: + + SfxItemPropertySet const& m_rPropSet; + const TOXTypes m_eTOXType; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDepend m_TypeDepend; + const SwTOXMark * m_pTOXMark; + SwDoc * m_pDoc; + + sal_Bool m_bMainEntry; + sal_uInt16 m_nLevel; + OUString m_sAltText; + OUString m_sPrimaryKey; + OUString m_sSecondaryKey; + OUString m_sTextReading; + OUString m_sPrimaryKeyReading; + OUString m_sSecondaryKeyReading; + OUString m_sUserIndexName; + + Impl( SwXDocumentIndexMark & rThis, + SwDoc *const pDoc, + const enum TOXTypes eType, + SwTOXType *const pType, SwTOXMark const*const pMark) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_rPropSet( + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType))) + , m_eTOXType(eType) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pMark) + , m_TypeDepend(this, pType) + , m_pTOXMark(pMark) + , m_pDoc(pDoc) + , m_bMainEntry(sal_False) + , m_nLevel(0) + { + } + + SwTOXType * GetTOXType() const { + return static_cast( + const_cast(m_TypeDepend.GetRegisteredIn())); + } + + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------16.10.00 11:24-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwXDocumentIndexMark::Impl::Invalidate() +{ + if (GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + if (m_TypeDepend.GetRegisteredIn()) + { + const_cast(m_TypeDepend.GetRegisteredIn())->Remove( + &m_TypeDepend); + } + } + m_ListenerContainer.Disposing(); + m_pDoc = 0; + m_pTOXMark = 0; +} + +/*-- 14.12.98 10:25:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXDocumentIndexMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_TOXMARK_DELETED: + if (static_cast(m_pTOXMark) == + static_cast(pOld)->pObject) + { + Invalidate(); + } + break; + } + } +} + +/*-- 14.12.98 10:25:43--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::SwXDocumentIndexMark(const TOXTypes eToxType) + : m_pImpl( new SwXDocumentIndexMark::Impl(*this, 0, eToxType, 0, 0) ) +{ +} +/*-- 14.12.98 10:25:44--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::SwXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, const SwTOXMark & rMark) + : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(), + &rType, &rMark) ) +{ +} +/*-- 14.12.98 10:25:44--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::~SwXDocumentIndexMark() +{ +} + +uno::Reference +SwXDocumentIndexMark::CreateXDocumentIndexMark( + SwDoc & rDoc, SwTOXType & rType, const SwTOXMark & rMark) +{ + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXDocumentIndexMark to register at the + // format directly, not at the unocallback +#if 0 + SwClientIter aIter(*pType); + SwXDocumentIndexMark::Impl* pxMark = (SwXDocumentIndexMark::Impl*) + aIter.First(TYPE(SwXDocumentIndexMark::Impl)); + while( pxMark ) + { + if(pxMark->m_pTOXMark == pMark) + return pxMark->m_rThis; + pxMark = (SwXDocumentIndexMark::Impl*)aIter.Next(); + } +#endif + return new SwXDocumentIndexMark(rDoc, rType, rMark); +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -1563,55 +1724,62 @@ const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXDocumentIndexMark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXDocumentIndexMark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } -TYPEINIT1(SwXDocumentIndexMark, SwClient) -const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; -const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; -const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; -const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; -const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; -const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; +static const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; +static const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; +static const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; +static const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; +static const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; +static const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; + /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndexMark::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexMark::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXDocumentIndexMark"); } /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndexMark::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexMark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - return !rServiceName.compareToAscii(cBaseMark)|| - !rServiceName.compareToAscii(cTextContent) || - (eType == TOX_USER && !rServiceName.compareToAscii(cUserMark)) || - (eType == TOX_CONTENT && !rServiceName.compareToAscii(cContentMark)) || - (eType == TOX_INDEX && !rServiceName.compareToAscii(cIdxMark)) || - (eType == TOX_INDEX && !rServiceName.compareToAscii(cIdxMarkAsian)); + vos::OGuard g(Application::GetSolarMutex()); + + return rServiceName.equalsAscii(cBaseMark) + || rServiceName.equalsAscii(cTextContent) + || ((m_pImpl->m_eTOXType == TOX_USER) + && rServiceName.equalsAscii(cUserMark)) + || ((m_pImpl->m_eTOXType == TOX_CONTENT) + && rServiceName.equalsAscii(cContentMark)) + || ((m_pImpl->m_eTOXType == TOX_INDEX) + && rServiceName.equalsAscii(cIdxMark)) + || ((m_pImpl->m_eTOXType == TOX_INDEX) + && rServiceName.equalsAscii(cIdxMarkAsian)); } /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexMark::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexMark::getSupportedServiceNames() throw (uno::RuntimeException) { - INT32 nCnt = (eType == TOX_INDEX) ? 4 : 3; + vos::OGuard g(Application::GetSolarMutex()); + + const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3; uno::Sequence< OUString > aRet(nCnt); OUString* pArray = aRet.getArray(); pArray[0] = C2U(cBaseMark); pArray[1] = C2U(cTextContent); - switch(eType) + switch (m_pImpl->m_eTOXType) { case TOX_USER: pArray[2] = C2U(cUserMark); @@ -1629,97 +1797,47 @@ uno::Sequence< OUString > SwXDocumentIndexMark::getSupportedServiceNames(void) t } return aRet; } -/*-- 14.12.98 10:25:43--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::SwXDocumentIndexMark(TOXTypes eToxType) : - aLstnrCntnr( (text::XTextContent*)this), - aTypeDepend(this, 0), - m_pDoc(0), - m_pTOXMark(0), - bIsDescriptor(sal_True), - bMainEntry(sal_False), - eType(eToxType), - nLevel(0) -{ - InitMap(eToxType); -} -/*-- 14.12.98 10:25:44--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::SwXDocumentIndexMark(const SwTOXType* pType, - const SwTOXMark* pMark, - SwDoc* pDc) : - aLstnrCntnr( (text::XTextContent*)this), - aTypeDepend(this, (SwTOXType*)pType), - m_pDoc(pDc), - m_pTOXMark(pMark), - bIsDescriptor(sal_False), - bMainEntry(sal_False), - eType(pType->GetType()), - nLevel(0) -{ - m_pDoc->GetUnoCallBack()->Add(this); - InitMap(eType); -} -/*-- 14.12.98 10:25:44--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::~SwXDocumentIndexMark() -{ - -} -/* -----------------21.04.99 09:36------------------- - * - * --------------------------------------------------*/ -void SwXDocumentIndexMark::InitMap(TOXTypes eToxType) -{ - sal_uInt16 nMapId = PROPERTY_MAP_USER_MARK; //case TOX_USER: - switch( eToxType ) - { - case TOX_INDEX: - nMapId = PROPERTY_MAP_INDEX_MARK ; - break; - case TOX_CONTENT: - nMapId = PROPERTY_MAP_CNTIDX_MARK; - break; - //case TOX_USER: - default: - ; - } - m_pPropSet = aSwMapProvider.GetPropertySet(nMapId); -} /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXDocumentIndexMark::getMarkEntry(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexMark::getMarkEntry() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); + OUString sRet; - if(pType && m_pTOXMark) + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - sRet = OUString(m_pTOXMark->GetAlternativeText()); + sRet = OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sAltText; } - else if(bIsDescriptor) - sRet = sAltText; else + { throw uno::RuntimeException(); + } return sRet; } /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - SwTOXMark aMark(*m_pTOXMark); + SwTOXMark aMark(*m_pImpl->m_pTOXMark); aMark.SetAlternativeText(rIndexEntry); - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); + SwTxtTOXMark const*const pTxtMark = + m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); if(pTxtMark->GetEnd()) @@ -1729,9 +1847,9 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: else aPam.GetPoint()->nContent++; - //die alte Marke loeschen - m_pDoc->DeleteTOXMark(m_pTOXMark); - m_pTOXMark = 0; + // delete old mark + m_pImpl->m_pDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); + m_pImpl->m_pTOXMark = 0; SwTxtAttr* pTxtAttr = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); @@ -1740,311 +1858,377 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: if( bInsAtPos ) { SwPaM aTmp( *pStt ); - m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); + m_pImpl->m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK); } else if( *pEnd != *pStt ) { - m_pDoc->InsertPoolItem( aPam, aMark, + m_pImpl->m_pDoc->InsertPoolItem( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK); } - //und sonst - Marke geloescht? if(pTxtAttr) - m_pTOXMark = &pTxtAttr->GetTOXMark(); + { + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { - sAltText = rIndexEntry; + m_pImpl->m_sAltText = rIndexEntry; } else + { throw uno::RuntimeException(); + } } + /* -----------------18.02.99 13:40------------------- * * --------------------------------------------------*/ -void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::attach( + const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!bIsDescriptor) - throw uno::RuntimeException(); - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + if (!m_pImpl->m_bIsDescriptor) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + throw uno::RuntimeException(); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; + const uno::Reference xRangeTunnel(xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) + { + throw lang::IllegalArgumentException(); + } - if(pDoc ) + const SwTOXType* pTOXType = 0; + switch (m_pImpl->m_eTOXType) { - const SwTOXType* pTOXType = 0; - switch(eType) + case TOX_INDEX: + case TOX_CONTENT: + pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); + break; + case TOX_USER: { - case TOX_INDEX: - case TOX_CONTENT: - pTOXType = pDoc->GetTOXType( eType, 0 ); - break; - case TOX_USER: + if (!m_pImpl->m_sUserIndexName.getLength()) { - if(!sUserIndexName.Len()) - pTOXType = pDoc->GetTOXType( eType, 0 ); - else + pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); + } + else + { + const sal_uInt16 nCount = + pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType); + for (sal_uInt16 i = 0; i < nCount; i++) { - sal_uInt16 nCount = pDoc->GetTOXTypeCount( eType); - for(sal_uInt16 i = 0; i < nCount; i++) + SwTOXType const*const pTemp = + pDoc->GetTOXType( m_pImpl->m_eTOXType, i ); + if (m_pImpl->m_sUserIndexName == + OUString(pTemp->GetTypeName())) { - const SwTOXType* pTemp = pDoc->GetTOXType( eType, i ); - if(sUserIndexName == pTemp->GetTypeName()) - { - pTOXType = pTemp; - break; - } - } - if(!pTOXType) - { - SwTOXType aUserType(TOX_USER, sUserIndexName); - pTOXType = pDoc->InsertTOXType(aUserType); + pTOXType = pTemp; + break; } } + if (!pTOXType) + { + SwTOXType aUserType(TOX_USER, m_pImpl->m_sUserIndexName); + pTOXType = pDoc->InsertTOXType(aUserType); + } } - break; - - default: - ; } - if(!pTOXType) - throw lang::IllegalArgumentException(); - pDoc->GetUnoCallBack()->Add(this); - ((SwTOXType*)pTOXType)->Add(&aTypeDepend); - - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - ::sw::XTextRangeToSwPaM(aPam, xTextRange); - SwTOXMark aMark (pTOXType); - if(sAltText.Len()) - aMark.SetAlternativeText(sAltText); - switch(eType) - { - case TOX_INDEX: - if(sPrimaryKey.Len()) - aMark.SetPrimaryKey(sPrimaryKey); - if(sSecondaryKey.Len()) - aMark.SetSecondaryKey(sSecondaryKey); - if(sTextReading.Len()) - aMark.SetTextReading(sTextReading); - if(sPrimaryKeyReading.Len()) - aMark.SetPrimaryKeyReading(sPrimaryKeyReading); - if(sSecondaryKeyReading.Len()) - aMark.SetSecondaryKeyReading(sSecondaryKeyReading); - aMark.SetMainEntry(bMainEntry); - break; - case TOX_USER: - case TOX_CONTENT: - if(USHRT_MAX != nLevel) - aMark.SetLevel(nLevel+1); - break; + break; - default: - ; - } - UnoActionContext aAction(pDoc); - sal_Bool bMark = *aPam.GetPoint() != *aPam.GetMark(); - // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, - // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? - if(!bMark && !aMark.GetAlternativeText().Len()) - aMark.SetAlternativeText( String(' ') ); - - SwXTextCursor const*const pTextCursor( - dynamic_cast(pCursor)); - const bool bForceExpandHints( (!bMark && pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) - ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND - | nsSetAttrMode::SETATTR_DONTEXPAND) - : nsSetAttrMode::SETATTR_DONTEXPAND; - - pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); - if( bMark && *aPam.GetPoint() > *aPam.GetMark()) - aPam.Exchange(); + default: + break; + } + if (!pTOXType) + { + throw lang::IllegalArgumentException(); + } + pDoc->GetUnoCallBack()->Add(m_pImpl.get()); + const_cast(pTOXType)->Add(&m_pImpl->m_TypeDepend); - SwTxtAttr* pTxtAttr = 0; - if( bMark ) - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( - aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); - else - { - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); - } + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + SwTOXMark aMark (pTOXType); + if (m_pImpl->m_sAltText.getLength()) + { + aMark.SetAlternativeText(m_pImpl->m_sAltText); + } + switch (m_pImpl->m_eTOXType) + { + case TOX_INDEX: + if (m_pImpl->m_sPrimaryKey.getLength()) + { + aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey); + } + if (m_pImpl->m_sSecondaryKey.getLength()) + { + aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey); + } + if (m_pImpl->m_sTextReading.getLength()) + { + aMark.SetTextReading(m_pImpl->m_sTextReading); + } + if (m_pImpl->m_sPrimaryKeyReading.getLength()) + { + aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading); + } + if (m_pImpl->m_sSecondaryKeyReading.getLength()) + { + aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading); + } + aMark.SetMainEntry(m_pImpl->m_bMainEntry); + break; + case TOX_USER: + case TOX_CONTENT: + if (USHRT_MAX != m_pImpl->m_nLevel) + { + aMark.SetLevel(m_pImpl->m_nLevel+1); + } + break; - if(pTxtAttr) - { - m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pDoc = pDoc; - bIsDescriptor = sal_False; - } - else - throw uno::RuntimeException(); + default: + break; + } + UnoActionContext aAction(pDoc); + const sal_Bool bMark = *aPam.GetPoint() != *aPam.GetMark(); + // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, + // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? + if (!bMark && !aMark.GetAlternativeText().Len()) + { + aMark.SetAlternativeText( String(' ') ); } -} -/*-- 14.12.98 10:25:45--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + SwXTextCursor const*const pTextCursor( + dynamic_cast(pCursor)); + const bool bForceExpandHints( (!bMark && pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); + if (bMark && *aPam.GetPoint() > *aPam.GetMark()) + { + aPam.Exchange(); + } + + SwTxtAttr* pTxtAttr = 0; + if (bMark) + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); + } + else + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); + } + + if (!pTxtAttr) + { + throw uno::RuntimeException(); + } + + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsDescriptor = sal_False; } + /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXDocumentIndexMark::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXDocumentIndexMark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (!pType || !m_pImpl->m_pTOXMark) { - if( m_pTOXMark->GetTxtTOXMark() ) - { - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); - SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); - aPam.SetMark(); - if(pTxtMark->GetEnd()) - { - aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); - } - else - aPam.GetPoint()->nContent++; - uno::Reference< frame::XModel > xModel = m_pDoc->GetDocShell()->GetBaseModel(); - uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); - aRet = new SwXTextRange(aPam, xTDoc->getText()); - } + throw uno::RuntimeException(); } - if(!aRet.is()) + if (!m_pImpl->m_pTOXMark->GetTxtTOXMark()) + { throw uno::RuntimeException(); - return aRet; + } + const SwTxtTOXMark* pTxtMark = m_pImpl->m_pTOXMark->GetTxtTOXMark(); + SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); + aPam.SetMark(); + if(pTxtMark->GetEnd()) + { + aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); + } + else + { + aPam.GetPoint()->nContent++; + } + const uno::Reference< frame::XModel > xModel = + m_pImpl->m_pDoc->GetDocShell()->GetBaseModel(); + const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xTDoc->getText()); + + return xRet; } + /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - m_pDoc->DeleteTOXMark(m_pTOXMark); + m_pImpl->m_pDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); } - else - throw uno::RuntimeException(); } /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXDocumentIndexMark::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXDocumentIndexMark::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xInfos[3]; int nPos = 0; - switch(eType) + switch (m_pImpl->m_eTOXType) { - case TOX_INDEX: nPos = 0; break; - case TOX_CONTENT: nPos = 1; break; - case TOX_USER: nPos = 2; break; + case TOX_INDEX: nPos = 0; break; + case TOX_CONTENT: nPos = 1; break; + case TOX_USER: nPos = 2; break; default: ; } if(!xInfos[nPos].is()) { - uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + const uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); // extend PropertySetInfo! const uno::Sequence aPropSeq = xInfo->getProperties(); xInfos[nPos] = new SfxExtItemPropertySetInfo( - aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS), + aSwMapProvider.GetPropertyMapEntries( + PROPERTY_MAP_PARAGRAPH_EXTENSIONS), aPropSeq ); } return xInfos[nPos]; } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, - const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if(pType && m_pTOXMark) { - SwDoc* pLocalDoc = m_pDoc; + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast(this)); + } + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) + { + SwDoc* pLocalDoc = m_pImpl->m_pDoc; - SwTOXMark aMark(*m_pTOXMark); + SwTOXMark aMark(*m_pImpl->m_pTOXMark); switch(pEntry->nWID) { case WID_ALT_TEXT: - aMark.SetAlternativeText(lcl_AnyToString(aValue)); + aMark.SetAlternativeText(lcl_AnyToString(rValue)); break; case WID_LEVEL: - aMark.SetLevel(Min( (sal_Int8) ( MAXLEVEL ), - (sal_Int8)(lcl_AnyToInt16(aValue)+1))); + aMark.SetLevel(Min( static_cast( MAXLEVEL ), + static_cast(lcl_AnyToInt16(rValue)+1))); break; case WID_PRIMARY_KEY : - aMark.SetPrimaryKey(lcl_AnyToString(aValue)); + aMark.SetPrimaryKey(lcl_AnyToString(rValue)); break; case WID_SECONDARY_KEY: - aMark.SetSecondaryKey(lcl_AnyToString(aValue)); + aMark.SetSecondaryKey(lcl_AnyToString(rValue)); break; case WID_MAIN_ENTRY: - aMark.SetMainEntry(lcl_AnyToBool(aValue)); + aMark.SetMainEntry(lcl_AnyToBool(rValue)); break; case WID_TEXT_READING: - aMark.SetTextReading(lcl_AnyToString(aValue)); + aMark.SetTextReading(lcl_AnyToString(rValue)); break; case WID_PRIMARY_KEY_READING: - aMark.SetPrimaryKeyReading(lcl_AnyToString(aValue)); + aMark.SetPrimaryKeyReading(lcl_AnyToString(rValue)); break; case WID_SECONDARY_KEY_READING: - aMark.SetSecondaryKeyReading(lcl_AnyToString(aValue)); + aMark.SetSecondaryKeyReading(lcl_AnyToString(rValue)); break; } - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); + SwTxtTOXMark const*const pTxtMark = + m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); if(pTxtMark->GetEnd()) @@ -2052,15 +2236,17 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); } else + { aPam.GetPoint()->nContent++; + } //delete the old mark - pLocalDoc->DeleteTOXMark(m_pTOXMark); - m_pTOXMark = 0; + pLocalDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); + m_pImpl->m_pTOXMark = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); - const SwPosition *pStt = aPam.Start(), - *pEnd = aPam.End(); + const SwPosition *pStt = aPam.Start(); + const SwPosition *pEnd = aPam.End(); SwTxtAttr* pTxtAttr = 0; if( bInsAtPos ) @@ -2077,101 +2263,120 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK ); } - m_pDoc = pLocalDoc; + m_pImpl->m_pDoc = pLocalDoc; if(pTxtAttr) { - m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pDoc->GetUnoCallBack()->Add(this); - pType->Add(&aTypeDepend); + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); + pType->Add(&m_pImpl->m_TypeDepend); } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { switch(pEntry->nWID) { case WID_ALT_TEXT: - sAltText = lcl_AnyToString(aValue); + m_pImpl->m_sAltText = lcl_AnyToString(rValue); break; case WID_LEVEL: { - sal_Int16 nVal = lcl_AnyToInt16(aValue); + const sal_Int16 nVal = lcl_AnyToInt16(rValue); if(nVal >= 0 && nVal < MAXLEVEL) - nLevel = nVal; + { + m_pImpl->m_nLevel = nVal; + } else + { throw lang::IllegalArgumentException(); + } } break; - case WID_PRIMARY_KEY : - sPrimaryKey = lcl_AnyToString(aValue); + case WID_PRIMARY_KEY: + m_pImpl->m_sPrimaryKey = lcl_AnyToString(rValue); break; case WID_SECONDARY_KEY: - sSecondaryKey = lcl_AnyToString(aValue); + m_pImpl->m_sSecondaryKey = lcl_AnyToString(rValue); break; case WID_TEXT_READING: - sTextReading = lcl_AnyToString(aValue); + m_pImpl->m_sTextReading = lcl_AnyToString(rValue); break; case WID_PRIMARY_KEY_READING: - sPrimaryKeyReading = lcl_AnyToString(aValue); + m_pImpl->m_sPrimaryKeyReading = lcl_AnyToString(rValue); break; case WID_SECONDARY_KEY_READING: - sSecondaryKeyReading = lcl_AnyToString(aValue); + m_pImpl->m_sSecondaryKeyReading = lcl_AnyToString(rValue); break; - case WID_USER_IDX_NAME : + case WID_USER_IDX_NAME: { - OUString sTmp(lcl_AnyToString(aValue)); + OUString sTmp(lcl_AnyToString(rValue)); lcl_ConvertTOUNameToUserName(sTmp); - sUserIndexName = sTmp; + m_pImpl->m_sUserIndexName = sTmp; } break; case WID_MAIN_ENTRY: - bMainEntry = lcl_AnyToBool(aValue); + m_pImpl->m_bMainEntry = lcl_AnyToBool(rValue); break; } } else + { throw uno::RuntimeException(); + } } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) { return aRet; } - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { switch(pEntry->nWID) { case WID_ALT_TEXT: - aRet <<= OUString(m_pTOXMark->GetAlternativeText()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); break; case WID_LEVEL: - aRet <<= (sal_Int16)(m_pTOXMark->GetLevel() - 1); + aRet <<= static_cast( + m_pImpl->m_pTOXMark->GetLevel() - 1); break; case WID_PRIMARY_KEY : - aRet <<= OUString(m_pTOXMark->GetPrimaryKey()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKey()); break; case WID_SECONDARY_KEY: - aRet <<= OUString(m_pTOXMark->GetSecondaryKey()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetSecondaryKey()); break; case WID_TEXT_READING: - aRet <<= OUString(m_pTOXMark->GetTextReading()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetTextReading()); break; case WID_PRIMARY_KEY_READING: - aRet <<= OUString(m_pTOXMark->GetPrimaryKeyReading()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKeyReading()); break; case WID_SECONDARY_KEY_READING: - aRet <<= OUString(m_pTOXMark->GetSecondaryKeyReading()); + aRet <<= OUString( + m_pImpl->m_pTOXMark->GetSecondaryKeyReading()); break; case WID_USER_IDX_NAME : { @@ -2182,136 +2387,101 @@ uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) break; case WID_MAIN_ENTRY: { - sal_Bool bTemp = m_pTOXMark->IsMainEntry(); - aRet.setValue(&bTemp, ::getBooleanCppuType()); + const sal_Bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry(); + aRet <<= bTemp; } break; } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { switch(pEntry->nWID) { case WID_ALT_TEXT: - aRet <<= OUString(sAltText); + aRet <<= m_pImpl->m_sAltText; break; case WID_LEVEL: - aRet <<= (sal_Int16)nLevel; + aRet <<= static_cast(m_pImpl->m_nLevel); break; - case WID_PRIMARY_KEY : - aRet <<= OUString(sPrimaryKey); + case WID_PRIMARY_KEY: + aRet <<= m_pImpl->m_sPrimaryKey; break; case WID_SECONDARY_KEY: - aRet <<= OUString(sSecondaryKey); + aRet <<= m_pImpl->m_sSecondaryKey; break; case WID_TEXT_READING: - aRet <<= OUString(sTextReading); + aRet <<= m_pImpl->m_sTextReading; break; case WID_PRIMARY_KEY_READING: - aRet <<= OUString(sPrimaryKeyReading); + aRet <<= m_pImpl->m_sPrimaryKeyReading; break; case WID_SECONDARY_KEY_READING: - aRet <<= OUString(sSecondaryKeyReading); + aRet <<= m_pImpl->m_sSecondaryKeyReading; break; case WID_USER_IDX_NAME : - aRet <<= OUString(sUserIndexName); + aRet <<= m_pImpl->m_sUserIndexName; break; case WID_MAIN_ENTRY: { - aRet.setValue(&bMainEntry, ::getBooleanCppuType()); + aRet <<= static_cast(m_pImpl->m_bMainEntry); } break; } } else + { throw uno::RuntimeException(); + } return aRet; } -/*-- 14.12.98 10:25:46--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ - DBG_WARNING("not implemented"); -} /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ - DBG_WARNING("not implemented"); -} -/*-- 14.12.98 10:25:47--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndexMark::addPropertyChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndexMark::removePropertyChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwXDocumentIndexMark::GetObject(SwTOXType* pType, - const SwTOXMark* pMark, SwDoc* pDoc) +void SAL_CALL +SwXDocumentIndexMark::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - SwClientIter aIter(*pType); - SwXDocumentIndexMark* pxMark = (SwXDocumentIndexMark*) - aIter.First(TYPE(SwXDocumentIndexMark)); - while( pxMark ) - { - if(pxMark->m_pTOXMark == pMark) - return pxMark; - pxMark = (SwXDocumentIndexMark*)aIter.Next(); - } - return new SwXDocumentIndexMark(pType, pMark, pDoc); + OSL_ENSURE(false, + "SwXDocumentIndexMark::addVetoableChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SAL_CALL +SwXDocumentIndexMark::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_TOXMARK_DELETED: - if( (void*)m_pTOXMark == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } + OSL_ENSURE(false, + "SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented"); } -/* -----------------------------16.10.00 11:24-------------------------------- - ---------------------------------------------------------------------------*/ -void SwXDocumentIndexMark::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - if(aTypeDepend.GetRegisteredIn()) - ((SwModify*)aTypeDepend.GetRegisteredIn())->Remove(&aTypeDepend); - aLstnrCntnr.Disposing(); - m_pTOXMark = 0; - m_pDoc = 0; - } -} /****************************************************************** * SwXDocumentIndexes diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 10c6c1eb07..cf5853b06b 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -481,8 +481,9 @@ lcl_CreateTOXMarkPortion( ->GetTOXMark(rTOXMark); if (!xContent.is()) { - xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), - &rTOXMark, pDoc); + xContent.set( SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, + *const_cast(rTOXMark.GetTOXType()), rTOXMark), + uno::UNO_QUERY); } SwXTextPortion* pPortion = 0; -- cgit v1.2.3 From 7caf10ec48f530f4702a954e878695027e84674a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:59 +0100 Subject: swunolocking1: #i105557#: remove class SwUnoCallBack. everything SwUnoCallBack class does has unfixable race conditions. in SwDoc, the uno callback is now a plain SwModify. --- sw/inc/doc.hxx | 3 +- sw/source/core/doc/docnew.cxx | 3 +- sw/source/core/inc/unoclbck.hxx | 52 --------------------- sw/source/core/unocore/makefile.mk | 1 - sw/source/core/unocore/unoclbck.cxx | 85 ---------------------------------- sw/source/core/unocore/unocoll.cxx | 1 - sw/source/core/unocore/unoobj.cxx | 1 - sw/source/core/unocore/unoobj2.cxx | 1 - sw/source/core/unocore/unoportenum.cxx | 16 ++----- 9 files changed, 6 insertions(+), 157 deletions(-) delete mode 100644 sw/source/core/inc/unoclbck.hxx delete mode 100644 sw/source/core/unocore/unoclbck.cxx diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 66695efba4..eccdcf2815 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -199,7 +199,6 @@ class SwLayouter; class SdrView; class SdrMarkList; class SwAuthEntry; -class SwUnoCallBack; class SwLayoutCache; class IStyleAccess; struct SwCallMouseEvent; @@ -391,7 +390,7 @@ class SW_DLLPUBLIC SwDoc : SwLayoutCache *pLayoutCache; // Layout cache to read and save with the // document for a faster formatting - SwUnoCallBack *pUnoCallBack; + SwModify *pUnoCallBack; IGrammarContact *mpGrammarContact; // for grammar checking in paragraphs during editing mutable comphelper::ImplementationReference< SwChartDataProvider diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 16d3bc4162..1944579c45 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -90,7 +90,6 @@ #include #include #include -#include #include #include #include @@ -259,7 +258,7 @@ SwDoc::SwDoc() : pStyleAccess( 0 ), // <-- pLayoutCache( 0 ), - pUnoCallBack(new SwUnoCallBack(0)), + pUnoCallBack(new SwModify(0)), mpGrammarContact( 0 ), aChartDataProviderImplRef(), pChartControllerHelper( 0 ), diff --git a/sw/source/core/inc/unoclbck.hxx b/sw/source/core/inc/unoclbck.hxx deleted file mode 100644 index 230b7eb503..0000000000 --- a/sw/source/core/inc/unoclbck.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoclbck.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _UNOCLBCK_HXX -#define _UNOCLBCK_HXX -#include - -class SwXReferenceMark; -class SwFmtRefMark; -class SwFmtFtn; -class SwXFootnote; -class SwTOXMark; -class SwXDocumentIndexMark; - -class SwUnoCallBack : public SwModify -{ -public: - SwUnoCallBack(SwModify *pToRegisterIn); - virtual ~SwUnoCallBack(); - - // returns the API object of a reference mark if available - SwXReferenceMark* GetRefMark(const SwFmtRefMark& rMark); - SwXFootnote* GetFootnote(const SwFmtFtn& rMark); - SwXDocumentIndexMark* GetTOXMark(const SwTOXMark& rMark); -}; -#endif diff --git a/sw/source/core/unocore/makefile.mk b/sw/source/core/unocore/makefile.mk index b364956a3d..31c6f4f726 100644 --- a/sw/source/core/unocore/makefile.mk +++ b/sw/source/core/unocore/makefile.mk @@ -115,7 +115,6 @@ SLOFILES = \ $(SLO)$/unotextmarkup.obj\ $(SLO)$/TextCursorHelper.obj \ $(SLO)$/unotext.obj\ - $(SLO)$/unoclbck.obj\ $(SLO)$/unomap.obj\ $(SLO)$/unoprnms.obj\ $(SLO)$/XMLRangeHelper.obj diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx deleted file mode 100644 index a05a37abf7..0000000000 --- a/sw/source/core/unocore/unoclbck.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoclbck.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* -----------------------------06.01.00 13:51-------------------------------- - - ---------------------------------------------------------------------------*/ -SwUnoCallBack::SwUnoCallBack(SwModify *pToRegisterIn) : - SwModify(pToRegisterIn) -{ -} -/* -----------------------------06.01.00 13:51-------------------------------- - - ---------------------------------------------------------------------------*/ -SwUnoCallBack::~SwUnoCallBack() -{ -} -/* -----------------------------01.09.00 12:03-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) -{ - return SwXReferenceMark::GetReferenceMark(*this, rMark); -} - -/* -----------------------------05.09.00 12:38-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) -{ - return SwXFootnote::GetXFootnote(*this, rMark); -} - -/* -----------------------------27.11.00 17:15-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& /*rMark*/) -{ - return 0; -} - diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index aedace0510..71f4ce5b25 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 37fa35e035..a0903cf049 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -84,7 +84,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 62ae8053e1..40f1234896 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -75,7 +75,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index cf5853b06b..f1e567faf5 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -429,9 +428,7 @@ lcl_CreateRefMarkPortion( SwDoc* pDoc = pUnoCrsr->GetDoc(); const SwFmtRefMark& rRefMark = static_cast(rAttr.GetAttr()); - Reference xContent = - static_cast(pDoc->GetUnoCallBack()) - ->GetRefMark(rRefMark); + Reference xContent; if (!xContent.is()) { xContent = new SwXReferenceMark(pDoc, &rRefMark); @@ -476,15 +473,10 @@ lcl_CreateTOXMarkPortion( SwDoc* pDoc = pUnoCrsr->GetDoc(); const SwTOXMark& rTOXMark = static_cast(rAttr.GetAttr()); - Reference xContent = - static_cast(pDoc->GetUnoCallBack()) - ->GetTOXMark(rTOXMark); - if (!xContent.is()) - { - xContent.set( SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, + Reference xContent( + SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, *const_cast(rTOXMark.GetTOXType()), rTOXMark), - uno::UNO_QUERY); - } + uno::UNO_QUERY); SwXTextPortion* pPortion = 0; if (!bEnd) -- cgit v1.2.3 From f6ace25c679545cff5c18e781b2067df9ad00329 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:14:00 +0100 Subject: swunolocking1: #i107771#: SwXDocumentIndexMark: register at SwTOXMark instead of UnoCallBack. implement instance caching with a WeakReference in SwTOXMark. [the ODF export depends on caching: see XMLIndexMarkExport::GetID()] --- sw/inc/tox.hxx | 32 ++++++++++++++++++--- sw/inc/unoidx.hxx | 4 +-- sw/source/core/docnode/nodes.cxx | 4 ++- sw/source/core/tox/tox.cxx | 34 +++++++++++++++++----- sw/source/core/txtnode/thints.cxx | 2 +- sw/source/core/unocore/unocrsrhelper.cxx | 3 +- sw/source/core/unocore/unoidx.cxx | 49 +++++++++++--------------------- sw/source/core/unocore/unoportenum.cxx | 8 +++--- 8 files changed, 84 insertions(+), 52 deletions(-) diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index 17c9c3103e..07810f6b63 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -27,8 +27,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _TOX_HXX -#define _TOX_HXX +#ifndef SW_TOX_HXX +#define SW_TOX_HXX + +#include #include #include @@ -47,6 +49,11 @@ #define INCLUDED_VECTOR #endif + +namespace com { namespace sun { namespace star { + namespace text { class XDocumentIndexMark; } +} } } + class SwTOXType; class SwTOXMark; class SwTxtTOXMark; @@ -61,7 +68,9 @@ SV_DECL_PTRARR(SwTOXMarks, SwTOXMark*, 0, 10) #define IVER_TOXMARK_STRPOOL ((USHORT)1) #define IVER_TOXMARK_NEWTOX ((USHORT)2) -class SW_DLLPUBLIC SwTOXMark : public SfxPoolItem, public SwClient +class SW_DLLPUBLIC SwTOXMark + : public SfxPoolItem + , public SwModify { friend void _InitCore(); friend class SwTxtTOXMark; @@ -80,6 +89,8 @@ class SW_DLLPUBLIC SwTOXMark : public SfxPoolItem, public SwClient BOOL bAutoGenerated : 1; // generated using a concordance file BOOL bMainEntry : 1; // main entry emphasized by character style + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XDocumentIndexMark> m_wXDocumentIndexMark; SwTOXMark(); // to create the dflt. atr. in _InitCore @@ -97,6 +108,11 @@ public: virtual int operator==( const SfxPoolItem& ) const; virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; + // SwClient + virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ); + + void InvalidateTOXMark(); + String GetText() const; inline BOOL IsAlternativeText() const; @@ -131,6 +147,14 @@ public: const SwTxtTOXMark* GetTxtTOXMark() const { return pTxtAttr; } SwTxtTOXMark* GetTxtTOXMark() { return pTxtAttr; } + + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XDocumentIndexMark> const& GetXTOXMark() const + { return m_wXDocumentIndexMark; } + SW_DLLPRIVATE void SetXTOXMark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark> const& xMark) + { m_wXDocumentIndexMark = xMark; } + }; /*-------------------------------------------------------------------- @@ -769,4 +793,4 @@ inline void SwTOXBase::SetOptions(USHORT nOpt) } -#endif // _TOX_HXX +#endif // SW_TOX_HXX diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 4824068b3f..d262e1784a 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -207,7 +207,7 @@ private: virtual ~SwXDocumentIndexMark(); SwXDocumentIndexMark(SwDoc & rDoc, - SwTOXType & rType, const SwTOXMark & rMark); + SwTOXType & rType, SwTOXMark & rMark); public: @@ -217,7 +217,7 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndexMark> CreateXDocumentIndexMark(SwDoc & rDoc, - SwTOXType & rType, const SwTOXMark & rMark); + SwTOXType & rType, SwTOXMark & rMark); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 4656d96a0b..069ea638bd 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -48,6 +48,7 @@ #include #include #include +#include // InvalidateTOXMark #include #include @@ -341,7 +342,8 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, break; case RES_TXTATR_TOXMARK: - nDelMsg = RES_TOXMARK_DELETED; + static_cast(pAttr->GetAttr()) + .InvalidateTOXMark(); break; case RES_TXTATR_REFMARK: diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 5a1795a237..268d6a3aaa 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -50,6 +50,7 @@ #include #include #include +#include // SwPtrMsgPoolItem // -> #i21237# #include @@ -176,10 +177,11 @@ SwFormTokens lcl_GetAuthPattern(USHORT nTypeId) --------------------------------------------------------------------*/ - // Konstruktor fuers Default vom Attribut-Pool +/// pool default constructor SwTOXMark::SwTOXMark() - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient( 0 ), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify( 0 ) + , pTxtAttr( 0 ), bAutoGenerated(FALSE), bMainEntry(FALSE) @@ -188,8 +190,9 @@ SwTOXMark::SwTOXMark() SwTOXMark::SwTOXMark( const SwTOXType* pTyp ) - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient( (SwModify*)pTyp ), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify( const_cast(pTyp) ) + , pTxtAttr( 0 ), nLevel( 0 ), bAutoGenerated(FALSE), bMainEntry(FALSE) @@ -198,8 +201,9 @@ SwTOXMark::SwTOXMark( const SwTOXType* pTyp ) SwTOXMark::SwTOXMark( const SwTOXMark& rCopy ) - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient((SwModify*)rCopy.GetRegisteredIn()), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify(rCopy.pRegisteredIn) + , aPrimaryKey( rCopy.aPrimaryKey ), aSecondaryKey( rCopy.aSecondaryKey ), aTextReading( rCopy.aTextReading ), aPrimaryKeyReading( rCopy.aPrimaryKeyReading ), @@ -230,6 +234,22 @@ SfxPoolItem* SwTOXMark::Clone( SfxItemPool* ) const return new SwTOXMark( *this ); } +void SwTOXMark::Modify(SfxPoolItem* pOld, SfxPoolItem* pNew) +{ + SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXTOXMark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark>(0)); + } +} + +void SwTOXMark::InvalidateTOXMark() +{ + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast(*this) ); // cast to base class! + Modify(&aMsgHint, &aMsgHint); +} String SwTOXMark::GetText() const { diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index dfb147fbbe..7819ecd496 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1174,7 +1174,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) break; case RES_TXTATR_TOXMARK: - nDelMsg = RES_TOXMARK_DELETED; + static_cast(pAttr->GetAttr()).InvalidateTOXMark(); break; case RES_TXTATR_REFMARK: diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index cb0aa83e22..725c287111 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -313,7 +313,8 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - const SwTOXMark& rMark = pTxtAttr->GetTOXMark(); + SwTOXMark & rMark = + static_cast(pTxtAttr->GetAttr()); const uno::Reference< text::XDocumentIndexMark > xRef = SwXDocumentIndexMark::CreateXDocumentIndexMark( *rPam.GetDoc(), diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 8e4d56e705..19dda1dd91 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1598,7 +1598,7 @@ public: SwDoc *const pDoc, const enum TOXTypes eType, SwTOXType *const pType, SwTOXMark const*const pMark) - : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + : SwClient(const_cast(pMark)) , m_rPropSet( *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType))) , m_eTOXType(eType) @@ -1654,19 +1654,6 @@ void SwXDocumentIndexMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { Invalidate(); } - else if (pOld) - { - switch (pOld->Which()) - { - case RES_TOXMARK_DELETED: - if (static_cast(m_pTOXMark) == - static_cast(pOld)->pObject) - { - Invalidate(); - } - break; - } - } } /*-- 14.12.98 10:25:43--------------------------------------------------- @@ -1680,7 +1667,7 @@ SwXDocumentIndexMark::SwXDocumentIndexMark(const TOXTypes eToxType) -----------------------------------------------------------------------*/ SwXDocumentIndexMark::SwXDocumentIndexMark(SwDoc & rDoc, - SwTOXType & rType, const SwTOXMark & rMark) + SwTOXType & rType, SwTOXMark & rMark) : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(), &rType, &rMark) ) { @@ -1694,23 +1681,20 @@ SwXDocumentIndexMark::~SwXDocumentIndexMark() uno::Reference SwXDocumentIndexMark::CreateXDocumentIndexMark( - SwDoc & rDoc, SwTOXType & rType, const SwTOXMark & rMark) + SwDoc & rDoc, SwTOXType & rType, SwTOXMark & rMark) { + // re-use existing SwXDocumentIndexMark + // NB: xmloff depends on this caching to generate ID from the address! // #i105557#: do not iterate over the registered clients: race condition - // to do this properly requires the SwXDocumentIndexMark to register at the - // format directly, not at the unocallback -#if 0 - SwClientIter aIter(*pType); - SwXDocumentIndexMark::Impl* pxMark = (SwXDocumentIndexMark::Impl*) - aIter.First(TYPE(SwXDocumentIndexMark::Impl)); - while( pxMark ) - { - if(pxMark->m_pTOXMark == pMark) - return pxMark->m_rThis; - pxMark = (SwXDocumentIndexMark::Impl*)aIter.Next(); + uno::Reference< text::XDocumentIndexMark > xTOXMark(rMark.GetXTOXMark()); + if (!xTOXMark.is()) + { + SwXDocumentIndexMark *const pNew = + new SwXDocumentIndexMark(rDoc, rType, rMark); + xTOXMark.set(pNew); + rMark.SetXTOXMark(xTOXMark); } -#endif - return new SwXDocumentIndexMark(rDoc, rType, rMark); + return xTOXMark; } /* -----------------------------10.03.00 18:02-------------------------------- @@ -1955,8 +1939,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) { throw lang::IllegalArgumentException(); } - pDoc->GetUnoCallBack()->Add(m_pImpl.get()); - const_cast(pTOXType)->Add(&m_pImpl->m_TypeDepend); SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern @@ -2046,6 +2028,9 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); m_pImpl->m_pDoc = pDoc; m_pImpl->m_bIsDescriptor = sal_False; + + const_cast(m_pImpl->m_pTOXMark)->Add(m_pImpl.get()); + const_cast(pTOXType)->Add(&m_pImpl->m_TypeDepend); } /*-- 14.12.98 10:25:45--------------------------------------------------- @@ -2268,7 +2253,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, if(pTxtAttr) { m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); + const_cast(m_pImpl->m_pTOXMark)->Add(m_pImpl.get()); pType->Add(&m_pImpl->m_TypeDepend); } } diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index f1e567faf5..be4befde2f 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -468,12 +468,12 @@ static Reference lcl_CreateTOXMarkPortion( Reference const& xParent, const SwUnoCrsr * const pUnoCrsr, - const SwTxtAttr & rAttr, const bool bEnd) + SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - const SwTOXMark& rTOXMark = static_cast(rAttr.GetAttr()); + SwTOXMark & rTOXMark = static_cast(rAttr.GetAttr()); - Reference xContent( + const Reference xContent( SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, *const_cast(rTOXMark.GetTOXType()), rTOXMark), uno::UNO_QUERY); @@ -742,7 +742,7 @@ lcl_ExportHints( while(nStartIndex < pHints->GetStartCount() && nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart()))) { - const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); + SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); USHORT nAttrWhich = pAttr->Which(); if (nNextStart == nCurrentIndex) { -- cgit v1.2.3 From a609fbf16e0df2cbe9fcbd8dd6ddd603e8e26d26 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 20 Jan 2010 16:59:56 +0100 Subject: swunolocking1: #i108489#: fix crash: XTextRangeToSwPaM(): do not prematurely release newly created text cursor. SwXTextViewCursor::gotoRange(): do not throw IllegalArgumentException. --- sw/source/core/unocore/unoobj2.cxx | 7 ++++--- sw/source/ui/uno/unotxvw.cxx | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 40f1234896..d1f24c7544 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1160,10 +1160,11 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, // if it's a text then create a temporary cursor there and re-use // the pCursor variable - if(pText) + // #i108489#: Reference in outside scope to keep cursor alive + uno::Reference< text::XTextCursor > xTextCursor; + if (pText) { - const uno::Reference< text::XTextCursor > xTextCursor = - pText->CreateCursor(); + xTextCursor.set( pText->CreateCursor() ); xTextCursor->gotoEnd(sal_True); const uno::Reference xCrsrTunnel( xTextCursor, uno::UNO_QUERY); diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index b9a1bd8fd2..3b7b10f516 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -1364,7 +1364,9 @@ void SwXTextViewCursor::gotoRange( SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) - throw IllegalArgumentException(); + { + throw uno::RuntimeException(); + } ShellModes eSelMode = m_pView->GetShellMode(); SwWrtShell& rSh = m_pView->GetWrtShell(); -- cgit v1.2.3 From e832b802d33f63a8ae62df1ce053d978cbd1b908 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 22 Jan 2010 19:07:50 +0100 Subject: swunolocking1: fix regression: SwXParagraphEnumeration constructor really needs the start node as a parameter because determining it from the cursor cannot work in nested tables. --- sw/inc/unoparagraph.hxx | 6 ++++- sw/source/core/unocore/unoobj.cxx | 8 ++++++- sw/source/core/unocore/unoobj2.cxx | 45 ++++++++++---------------------------- sw/source/core/unocore/unotbl.cxx | 6 ++++- 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index add936e9c7..8743737c33 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -55,7 +55,9 @@ struct SwPosition; class SwPaM; class SwUnoCrsr; +class SwStartNode; class SwTxtNode; +class SwTable; class SwXText; @@ -339,7 +341,9 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const & xParent, ::std::auto_ptr pCursor, - const CursorType eType); + const CursorType eType, + SwStartNode const*const pStartNode = 0, + SwTable const*const pTable = 0); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index a0903cf049..1cb0d4f660 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -3157,8 +3157,14 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException) } const CursorType eSetType = (CURSOR_TBLTEXT == m_pImpl->m_eType) ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + SwTableNode const*const pStartNode( (CURSOR_TBLTEXT == m_pImpl->m_eType) + ? rUnoCursor.GetPoint()->nNode.GetNode().FindTableNode() + : 0); + SwTable const*const pTable( + (pStartNode) ? & pStartNode->GetTable() : 0 ); const uno::Reference< container::XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + new SwXParagraphEnumeration( + pParentText, pNewCrsr, eSetType, pStartNode, pTable); return xRet; } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index d1f24c7544..cef43782d4 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -468,34 +468,6 @@ void SwUnoCursorHelper::GetCrsrAttr(SwPaM & rPam, * SwXParagraphEnumeration ******************************************************************/ -static SwStartNode * -lcl_InitStartNode(const CursorType eType, SwUnoCrsr *const pCursor) -{ - switch (eType) - { - case CURSOR_TBLTEXT: // table cell: pCursor points at first paragraph - return pCursor->Start()->nNode.GetNode().StartOfSectionNode(); - case CURSOR_SELECTION_IN_TABLE: // table - return pCursor->Start()->nNode.GetNode().FindTableNode(); - default: - return 0; - } -} - -static SwTable const* -lcl_InitTable(const CursorType eType, SwStartNode const*const pStartNode) -{ - switch (eType) - { - case CURSOR_TBLTEXT: // table cell - return & pStartNode->FindTableNode()->GetTable(); - case CURSOR_SELECTION_IN_TABLE: // table - return & static_cast(pStartNode)->GetTable(); - default: - return 0; - } -} - class SwXParagraphEnumeration::Impl : public SwClient { @@ -517,16 +489,17 @@ public: Impl( uno::Reference< text::XText > const& xParent, ::std::auto_ptr pCursor, - const CursorType eType) + const CursorType eType, + SwStartNode const*const pStartNode, SwTable const*const pTable) : SwClient( pCursor.release() ) , m_xParentText( xParent ) , m_eCursorType( eType ) // remember table and start node for later travelling // (used in export of tables in tables) - , m_pOwnStartNode( lcl_InitStartNode(eType, GetCursor()) ) + , m_pOwnStartNode( pStartNode ) // for import of tables in tables we have to remember the actual // table and start node of the current position in the enumeration. - , m_pOwnTable( lcl_InitTable(eType, m_pOwnStartNode) ) + , m_pOwnTable( pTable ) , m_nEndIndex( GetCursor()->End()->nNode.GetIndex() ) , m_nFirstParaStart( -1 ) , m_nLastParaEnd( -1 ) @@ -534,6 +507,10 @@ public: { OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?"); OSL_ENSURE(GetRegisteredIn(), "SwXParagraphEnumeration: no cursor?"); + OSL_ENSURE( !((CURSOR_SELECTION_IN_TABLE == eType) || + (CURSOR_TBLTEXT == eType)) + || (m_pOwnTable && m_pOwnStartNode), + "SwXParagraphEnumeration: table type but no start node or table?"); if ((CURSOR_SELECTION == m_eCursorType) || (CURSOR_SELECTION_IN_TABLE == m_eCursorType)) @@ -576,8 +553,10 @@ void SwXParagraphEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) SwXParagraphEnumeration::SwXParagraphEnumeration( uno::Reference< text::XText > const& xParent, ::std::auto_ptr pCursor, - const CursorType eType) - : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType) ) + const CursorType eType, + SwStartNode const*const pStartNode, SwTable const*const pTable) + : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType, + pStartNode, pTable) ) { } /*-- 10.12.98 11:52:12--------------------------------------------------- diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d94cce8a73..a6e9b8cd10 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1227,8 +1227,12 @@ uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) thro GetDoc()->CreateUnoCrsr(aPos, sal_False)); pUnoCursor->Move(fnMoveForward, fnGoNode); + // remember table and start node for later travelling + // (used in export of tables in tables) + SwTable const*const pTable( & pSttNd->FindTableNode()->GetTable() ); SwXParagraphEnumeration *const pEnum = - new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT); + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT, + pSttNd, pTable); aRef = pEnum; // // no Cursor in protected sections -- cgit v1.2.3