summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2014-01-08 14:20:43 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-01-09 16:21:44 +0000
commit6af2caab7271e11d9501fd6a597e05194d33fd10 (patch)
tree1a0415067ba8ca0b69a6214aaa3b27a06bb5da75 /sw
parent57ded88656b548063cc000628920a601f0c708f6 (diff)
Resolves: #i123792# correction for comments/annotations on table cell ranges
(cherry picked from commit c25523dd3a302d1bd36297a817a869afb3605d1f) Conflicts: sw/inc/IDocumentMarkAccess.hxx sw/inc/doc.hxx sw/source/core/doc/docbm.cxx sw/source/core/undo/undobj.cxx sw/source/ui/shells/textfld.cxx xmloff/source/text/txtfldi.cxx Change-Id: Ic2e12f47e7775ee16f31bedf89d5644b18734d7a
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentMarkAccess.hxx2
-rw-r--r--sw/inc/doc.hxx27
-rw-r--r--sw/source/core/crsr/annotationmark.cxx1
-rw-r--r--sw/source/core/doc/docbm.cxx104
-rw-r--r--sw/source/core/doc/doccorr.cxx20
-rw-r--r--sw/source/core/undo/undobj.cxx13
-rw-r--r--sw/source/core/unocore/unoobj.cxx72
-rw-r--r--sw/source/ui/docvw/SidebarWin.cxx25
-rw-r--r--sw/source/ui/shells/textfld.cxx3
-rw-r--r--sw/source/ui/wrtsh/wrtsh2.cxx21
10 files changed, 190 insertions, 98 deletions
diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 917a57f892d4..271266fdd1de 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -262,7 +262,7 @@ class IDocumentMarkAccess
/** Returns the MarkType used to create the mark
*/
- static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark);
+ static SAL_DLLPUBLIC_EXPORT MarkType GetType(const ::sw::mark::IMark& rMark);
static SAL_DLLPUBLIC_EXPORT OUString GetCrossRefHeadingBookmarkNamePrefix();
static SAL_DLLPUBLIC_EXPORT bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM );
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 48b7b80d72da..de4487cdf0fa 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1467,20 +1467,31 @@ public:
// If bMoveCrsr is set move Crsr too.
/// Set everything in rOldNode on rNewPos + Offset.
- void CorrAbs( const SwNodeIndex& rOldNode, const SwPosition& rNewPos,
- const xub_StrLen nOffset = 0, sal_Bool bMoveCrsr = sal_False );
+ void CorrAbs(
+ const SwNodeIndex& rOldNode,
+ const SwPosition& rNewPos,
+ const xub_StrLen nOffset = 0,
+ sal_Bool bMoveCrsr = sal_False );
/// Set everything in the range of [rStartNode, rEndNode] to rNewPos.
- void CorrAbs( const SwNodeIndex& rStartNode, const SwNodeIndex& rEndNode,
- const SwPosition& rNewPos, sal_Bool bMoveCrsr = sal_False );
+ void CorrAbs(
+ const SwNodeIndex& rStartNode,
+ const SwNodeIndex& rEndNode,
+ const SwPosition& rNewPos,
+ sal_Bool bMoveCrsr = sal_False );
/// Set everything in this range from rRange to rNewPos.
- void CorrAbs( const SwPaM& rRange, const SwPosition& rNewPos,
- sal_Bool bMoveCrsr = sal_False );
+ void CorrAbs(
+ const SwPaM& rRange,
+ const SwPosition& rNewPos,
+ sal_Bool bMoveCrsr = sal_False );
/// Set everything in rOldNode to relative Pos.
- void CorrRel( const SwNodeIndex& rOldNode, const SwPosition& rNewPos,
- const xub_StrLen nOffset = 0, sal_Bool bMoveCrsr = sal_False );
+ void CorrRel(
+ const SwNodeIndex& rOldNode,
+ const SwPosition& rNewPos,
+ const xub_StrLen nOffset = 0,
+ sal_Bool bMoveCrsr = sal_False );
/// Query / set rules for Outline.
inline SwNumRule* GetOutlineNumRule() const
diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx
index 964e736a14f9..80751a4c6992 100644
--- a/sw/source/core/crsr/annotationmark.cxx
+++ b/sw/source/core/crsr/annotationmark.cxx
@@ -54,6 +54,7 @@ namespace sw { namespace mark
SwTxtFld* pTxtFld =
GetMarkEnd().nNode.GetNode().GetTxtNode()->GetFldTxtAttrAt(
GetMarkEnd().nContent.GetIndex()-1, true );
+ OSL_ENSURE( pTxtFld != NULL, "<AnnotationMark::InitDoc(..)> - missing text attribute for annotation field!" );
if ( pTxtFld != NULL )
{
const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTxtFld->GetFmtFld().GetField());
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 194680f4b793..e914069c3b63 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -156,18 +156,34 @@ namespace
return max_element(vCandidates.begin(), vCandidates.end(), &lcl_MarkOrderingByEnd)->get();
}
- static bool lcl_FixCorrectedMark(bool bChangedPos, bool bChangedOPos, MarkBase* io_pMark)
+ static bool lcl_FixCorrectedMark(
+ const bool bChangedPos,
+ const bool bChangedOPos,
+ MarkBase* io_pMark )
{
- if( (bChangedPos || bChangedOPos) && io_pMark->IsExpanded() &&
- io_pMark->GetOtherMarkPos().nNode.GetNode().FindTableBoxStartNode() !=
- io_pMark->GetMarkPos().nNode.GetNode().FindTableBoxStartNode() )
+ if ( IDocumentMarkAccess::GetType(*io_pMark) == IDocumentMarkAccess::ANNOTATIONMARK )
{
- if(!bChangedOPos)
- io_pMark->SetMarkPos(io_pMark->GetOtherMarkPos());
+ // annotation marks are allowed to span a table cell range.
+ // but trigger sorting to be save
+ return true;
+ }
+
+ if ( ( bChangedPos || bChangedOPos )
+ && io_pMark->IsExpanded()
+ && io_pMark->GetOtherMarkPos().nNode.GetNode().FindTableBoxStartNode() !=
+ io_pMark->GetMarkPos().nNode.GetNode().FindTableBoxStartNode() )
+ {
+ if ( !bChangedOPos )
+ {
+ io_pMark->SetMarkPos( io_pMark->GetOtherMarkPos() );
+ }
io_pMark->ClearOtherMarkPos();
DdeBookmark * const pDdeBkmk = dynamic_cast< DdeBookmark*>(io_pMark);
- if(pDdeBkmk && pDdeBkmk->IsServer())
+ if ( pDdeBkmk != NULL
+ && pDdeBkmk->IsServer() )
+ {
pDdeBkmk->SetRefObject(NULL);
+ }
return true;
}
return false;
@@ -632,14 +648,14 @@ namespace sw { namespace mark
lcl_GreaterThan(pMark->GetOtherMarkPos(), rStt, pSttIdx) &&
lcl_Lower(pMark->GetOtherMarkPos(), rEnd, pEndIdx));
// special case: completely in range, touching the end?
- if(pEndIdx &&
- ((isOtherPosInRange
- && pMark->GetMarkPos().nNode == rEnd
- && pMark->GetMarkPos().nContent == *pEndIdx)
- || (isPosInRange
- && pMark->IsExpanded()
- && pMark->GetOtherMarkPos().nNode == rEnd
- && pMark->GetOtherMarkPos().nContent == *pEndIdx)))
+ if ( pEndIdx != NULL
+ && ( ( isOtherPosInRange
+ && pMark->GetMarkPos().nNode == rEnd
+ && pMark->GetMarkPos().nContent == *pEndIdx )
+ || ( isPosInRange
+ && pMark->IsExpanded()
+ && pMark->GetOtherMarkPos().nNode == rEnd
+ && pMark->GetOtherMarkPos().nContent == *pEndIdx ) ) )
{
isPosInRange = true, isOtherPosInRange = true;
}
@@ -667,39 +683,51 @@ namespace sw { namespace mark
vMarksToDelete.push_back(ppMark);
}
}
- else if(isPosInRange ^ isOtherPosInRange)
+ else if ( isPosInRange ^ isOtherPosInRange )
{
// the bookmark is partitially in the range
// move position of that is in the range out of it
SAL_WNODEPRECATED_DECLARATIONS_PUSH
- auto_ptr<SwPosition> pNewPos;
- if(pEndIdx)
- pNewPos = auto_ptr<SwPosition>(new SwPosition(
- rEnd,
- *pEndIdx));
- else
- pNewPos = lcl_FindExpelPosition(
- rStt,
- rEnd,
- isPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos());
- SAL_WNODEPRECATED_DECLARATIONS_POP
+ auto_ptr< SwPosition > pNewPos;
+ {
+ if ( pEndIdx != NULL )
+ {
+ pNewPos = auto_ptr< SwPosition >( new SwPosition( rEnd, *pEndIdx ) );
+ }
+ else
+ {
+ pNewPos = lcl_FindExpelPosition( rStt, rEnd, isPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos() );
+ }
+ }
- // #i92125#
- // no move of position for cross-reference bookmarks,
- // if move occurs inside a certain node
- if ( ( IDocumentMarkAccess::GetType(*pMark) !=
- IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK &&
- IDocumentMarkAccess::GetType(*pMark) !=
- IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK ) ||
- pMark->GetMarkPos().nNode != pNewPos->nNode )
+ bool bMoveMark = true;
+ {
+ switch ( IDocumentMarkAccess::GetType( *pMark ) )
+ {
+ case IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK:
+ case IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK:
+ // no move of cross-reference bookmarks, if move occurs inside a certain node
+ bMoveMark = pMark->GetMarkPos().nNode != pNewPos->nNode;
+ break;
+ case IDocumentMarkAccess::ANNOTATIONMARK:
+ // no move of annotation marks, if method is called to collect deleted marks
+ bMoveMark = pSaveBkmk == NULL;
+ break;
+ default:
+ bMoveMark = true;
+ break;
+ }
+ }
+ SAL_WNODEPRECATED_DECLARATIONS_POP
+ if ( bMoveMark )
{
- if(isPosInRange)
+ if ( isPosInRange )
pMark->SetMarkPos(*pNewPos);
else
pMark->SetOtherMarkPos(*pNewPos);
// illegal selection? collapse the mark and restore sorting later
- isSortingNeeded |= lcl_FixCorrectedMark(isPosInRange, isOtherPosInRange, pMark);
+ isSortingNeeded |= lcl_FixCorrectedMark( isPosInRange, isOtherPosInRange, pMark );
}
}
}
@@ -843,7 +871,7 @@ namespace sw { namespace mark
find_if(
pMarkLow,
pMarkHigh,
- boost::bind(equal_to<const IMark*>(), boost::bind(&boost::shared_ptr<IMark>::get, _1), pMark) );
+ boost::bind(equal_to<const IMark*>(), boost::bind(&boost::shared_ptr<IMark>::get, _1), pMark));
if(pMarkFound != pMarkHigh)
deleteMark(pMarkFound);
}
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 6eeb2f42f36c..6f8b07d82738 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -214,26 +214,28 @@ void SwDoc::CorrAbs(const SwNodeIndex& rOldNode,
}
}
-void SwDoc::CorrAbs(const SwPaM& rRange,
+void SwDoc::CorrAbs(
+ const SwPaM& rRange,
const SwPosition& rNewPos,
- sal_Bool bMoveCrsr)
+ sal_Bool bMoveCrsr )
{
SwPosition aStart(*rRange.Start());
SwPosition aEnd(*rRange.End());
SwPosition aNewPos(rNewPos);
- _DelBookmarks(aStart.nNode, aEnd.nNode, NULL,
- &aStart.nContent, &aEnd.nContent);
+ _DelBookmarks( aStart.nNode, aEnd.nNode, NULL, &aStart.nContent, &aEnd.nContent );
+
if(bMoveCrsr)
::PaMCorrAbs(rRange, rNewPos);
}
-void SwDoc::CorrAbs(const SwNodeIndex& rStartNode,
- const SwNodeIndex& rEndNode,
- const SwPosition& rNewPos,
- sal_Bool bMoveCrsr)
+void SwDoc::CorrAbs(
+ const SwNodeIndex& rStartNode,
+ const SwNodeIndex& rEndNode,
+ const SwPosition& rNewPos,
+ sal_Bool bMoveCrsr )
{
- _DelBookmarks(rStartNode, rEndNode);
+ _DelBookmarks( rStartNode, rEndNode );
if(bMoveCrsr)
{
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index e108f3cb538b..f552dc90fd66 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -826,12 +826,21 @@ void SwUndoSaveSection::SaveSection( SwDoc* pDoc, const SwNodeIndex& rSttIdx )
SaveSection( pDoc, aRg );
}
-void SwUndoSaveSection::SaveSection( SwDoc* , const SwNodeRange& rRange )
+void SwUndoSaveSection::SaveSection(
+ SwDoc* pDoc,
+ const SwNodeRange& rRange )
{
SwPaM aPam( rRange.aStart, rRange.aEnd );
- // delete all Footnotes / FlyFrames / Bookmarks / Directories
+ // delete all footnotes, fly frames, bookmarks and indexes
DelCntntIndex( *aPam.GetMark(), *aPam.GetPoint() );
+ {
+ // move certain indexes out of deleted range
+ SwNodeIndex aSttIdx( aPam.Start()->nNode.GetNode() );
+ SwNodeIndex aEndIdx( aPam.End()->nNode.GetNode() );
+ SwNodeIndex aMvStt( aEndIdx, 1 );
+ pDoc->CorrAbs( aSttIdx, aEndIdx, SwPosition( aMvStt ), sal_True );
+ }
pRedlSaveData = new SwRedlineSaveDatas;
if( !SwUndo::FillSaveData( aPam, *pRedlSaveData, sal_True, sal_True ))
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 43ab2881d260..999993187de1 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1143,22 +1143,6 @@ throw (uno::RuntimeException)
throw uno::RuntimeException();
}
- 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:
- ;
- }
- const SwStartNode* pOwnStartNode =
- rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType);
-
SwPaM aPam(GetDoc()->GetNodes());
const SwPaM * pPam(0);
if (pCursor)
@@ -1177,21 +1161,51 @@ throw (uno::RuntimeException)
{
throw uno::RuntimeException();
}
- const SwStartNode* pTmp =
- pPam->GetNode()->FindSttNodeByType(eSearchNodeType);
- //SectionNodes ueberspringen
- while(pTmp && pTmp->IsSectionNode())
{
- pTmp = pTmp->StartOfSectionNode();
- }
- while(pOwnStartNode && pOwnStartNode->IsSectionNode())
- {
- pOwnStartNode = pOwnStartNode->StartOfSectionNode();
- }
- if(pOwnStartNode != pTmp)
- {
- throw uno::RuntimeException();
+ 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:
+ ;
+ }
+
+ const SwStartNode* pOwnStartNode = rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType);
+ while ( pOwnStartNode != NULL
+ && pOwnStartNode->IsSectionNode())
+ {
+ pOwnStartNode = pOwnStartNode->StartOfSectionNode();
+ }
+
+ const SwStartNode* pTmp =
+ pPam->GetNode()->FindSttNodeByType(eSearchNodeType);
+ while ( pTmp != NULL
+ && pTmp->IsSectionNode() )
+ {
+ pTmp = pTmp->StartOfSectionNode();
+ }
+
+ if ( eSearchNodeType == SwTableBoxStartNode )
+ {
+ if ( pOwnStartNode->FindTableNode() != pTmp->FindTableNode() )
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ {
+ if ( pOwnStartNode != pTmp )
+ {
+ throw uno::RuntimeException();
+ }
+ }
}
if (CURSOR_META == m_pImpl->m_eType)
diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx
index 851923d22adc..0d2d1be9f01c 100644
--- a/sw/source/ui/docvw/SidebarWin.cxx
+++ b/sw/source/ui/docvw/SidebarWin.cxx
@@ -584,11 +584,26 @@ void SwSidebarWin::SetPosAndSize()
SwNodes& rNds = pTxtNode->GetDoc()->GetNodes();
SwCntntNode* const pCntntNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetCntntNode();
SwPosition aStartPos( *pCntntNd, mrSidebarItem.maLayoutInfo.mnStartContent );
- ::boost::scoped_ptr<SwShellCrsr> pTmpCrsrForAnnotationTextRange(
- new SwShellCrsr( DocView().GetWrtShell(), aStartPos ) );
- pTmpCrsrForAnnotationTextRange->SetMark();
- pTmpCrsrForAnnotationTextRange->GetMark()->nNode = *pTxtNode;
- pTmpCrsrForAnnotationTextRange->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+ SwShellCrsr* pTmpCrsr = NULL;
+ const bool bTableCrsrNeeded = pTxtNode->FindTableBoxStartNode() != pCntntNd->FindTableBoxStartNode();
+ if ( bTableCrsrNeeded )
+ {
+ SwShellTableCrsr* pTableCrsr = new SwShellTableCrsr( DocView().GetWrtShell(), aStartPos );
+ pTableCrsr->SetMark();
+ pTableCrsr->GetMark()->nNode = *pTxtNode;
+ pTableCrsr->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+ pTableCrsr->NewTableSelection();
+ pTmpCrsr = pTableCrsr;
+ }
+ else
+ {
+ SwShellCrsr* pCrsr = new SwShellCrsr( DocView().GetWrtShell(), aStartPos );
+ pCrsr->SetMark();
+ pCrsr->GetMark()->nNode = *pTxtNode;
+ pCrsr->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+ pTmpCrsr = pCrsr;
+ }
+ ::boost::scoped_ptr<SwShellCrsr> pTmpCrsrForAnnotationTextRange( pTmpCrsr );
pTmpCrsrForAnnotationTextRange->FillRects();
diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx
index 8b829670ef2a..ca167c05f8d0 100644
--- a/sw/source/ui/shells/textfld.cxx
+++ b/sw/source/ui/shells/textfld.cxx
@@ -358,9 +358,8 @@ void SwTextShell::ExecField(SfxRequest &rReq)
if( (sAuthor = aUserOpt.GetID()).isEmpty() )
sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR );
- if( rSh.HasSelection() )
+ if ( rSh.HasSelection() && !rSh.IsTableMode() )
{
- rSh.NormalizePam(false);
rSh.KillPams();
}
diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx
index 38d8ee65a55c..6a277ed7ba4d 100644
--- a/sw/source/ui/wrtsh/wrtsh2.cxx
+++ b/sw/source/ui/wrtsh/wrtsh2.cxx
@@ -85,10 +85,23 @@ void SwWrtShell::Insert(SwField &rFld)
{
// for annotation fields:
// - keep the current selection in order to create a corresponding annotation mark
- // - collapse cursur to its point
- const SwPaM& rCurrPaM = GetCurrentShellCursor();
- pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
- ClearMark();
+ // - collapse cursor to its end
+ if ( IsTableMode() )
+ {
+ GetTblCrs()->Normalize( sal_False );
+ const SwPosition rStartPos( *(GetTblCrs()->GetMark()->nNode.GetNode().GetCntntNode()), 0 );
+ KillPams();
+ EndPara();
+ const SwPosition rEndPos( *GetCurrentShellCursor().GetPoint() );
+ pAnnotationTextRange = new SwPaM( rStartPos, rEndPos );
+ }
+ else
+ {
+ NormalizePam( sal_False );
+ const SwPaM& rCurrPaM = GetCurrentShellCursor();
+ pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
+ ClearMark();
+ }
}
else
{