From 5d6da5c1f774b02973085816bb0717d8a2c891a3 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(-) (limited to 'sw') diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 8b34ce7f94c1..c3c3d362db6b 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 29464206c24b..950a0d3fc81c 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 f4b7e0a0b10d..59c8570ba212 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 86b8b3ee8403..ad35f1f28b33 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 9a2eb1dfae45..c8a0b78bb48c 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 59954b6a954e..eb8af4d93673 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 42f2934c5b01..d68fc43a3abc 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 8b3349332895..ac2dc2d55529 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 f18a46d8ad37..3d24e282f7c8 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 92309d6368cf..7119f3708711 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 0af4a74b52ff..0027d8ef0b02 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 404a93005a19..17336d80f64c 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 9cfce5c31a62..e1680cabecc2 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 68516a923eb7..a0903b6ea145 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 c47a3aef1345..d9d6bafa31a1 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 866c4979072e..6143e7ed2661 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 023290984ebf..415a3aaf6933 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 4b89f042977f..bd1dea07179e 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 d53261ea3fe5..704b6af7fa74 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 003318dbe989..9059b98db6b8 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 e2b154178b29..0cf164489eb4 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 85838652d370..0332dfa7058b 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 22d683a0f29d..3bb65ea4e900 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 9e637ca58260..6d001b95f378 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