summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-01-08 17:13:52 +0100
committerMichael Stahl <mst@openoffice.org>2010-01-08 17:13:52 +0100
commit220dc1e003f4a26a2d92b6c9bb2464a9b9d63b0e (patch)
treeefd80fb4622ba6e01bd704f7554465c809372403 /sw
parent30bfe9b171379f987c470761acf6735a8b48fe67 (diff)
swunolocking1: #i105557#: SwXTextRange:
try to hide the implementation detail that SwXTextRange registers at a bookmark from its clients by using SwXTextRange::GetPositions().
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unotext.hxx5
-rw-r--r--sw/inc/unotextrange.hxx6
-rwxr-xr-xsw/source/core/inc/unometa.hxx4
-rw-r--r--sw/source/core/unocore/unoobj.cxx87
-rw-r--r--sw/source/core/unocore/unoobj2.cxx8
-rw-r--r--sw/source/core/unocore/unorefmk.cxx63
-rw-r--r--sw/source/core/unocore/unotext.cxx128
-rw-r--r--sw/source/ui/uno/unoatxt.cxx48
-rw-r--r--sw/source/ui/uno/unotxvw.cxx9
9 files changed, 130 insertions, 228 deletions
diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx
index 499e0620dae4..97a45ece73cf 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 94d4996b4633..079296d2a441 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 5568aa88b52e..39f81caa902a 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 eb89201cf978..b48451b90cf9 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<SwXMeta*>(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 57c533833985..6ca031d041ba 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 39e93acd19dc..68516a923eb7 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<text::XTextRange> & 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<text::XWordCursor*>(
- new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark));
- }
+ xRange = static_cast<text::XWordCursor*>(
+ 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 4b0a259f2120..7c0fe114b489 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<text::XTextCursor> xTextCursor = pText->createCursor();
- xTextCursor->gotoEnd(sal_True);
- uno::Reference<lang::XUnoTunnel> 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 87d27b15a76b..d3e03aa307a6 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<SwTextBlocks> 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 6df8553be298..9e637ca58260 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())
{