sw/inc/IDocumentMarkAccess.hxx | 2 sw/inc/doc.hxx | 38 ++++++++--- sw/source/core/crsr/annotationmark.cxx | 1 sw/source/core/doc/docbm.cxx | 106 ++++++++++++++++++++------------- sw/source/core/doc/doccorr.cxx | 20 +++--- sw/source/core/undo/undobj.cxx | 13 +++- sw/source/core/unocore/unoobj.cxx | 72 +++++++++++++--------- sw/source/ui/docvw/SidebarWin.cxx | 25 ++++++- sw/source/ui/shells/textfld.cxx | 3 sw/source/ui/wrtsh/wrtsh2.cxx | 21 +++++- xmloff/source/text/txtfldi.cxx | 4 - 11 files changed, 200 insertions(+), 105 deletions(-)
New commits: commit c25523dd3a302d1bd36297a817a869afb3605d1f Author: Oliver-Rainer Wittmann <o...@apache.org> Date: Wed Jan 8 14:20:43 2014 +0000 123792: correction for comments/annotations on table cell ranges diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index d263d0e..7cde48a 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -260,7 +260,7 @@ class IDocumentMarkAccess virtual const_iterator_t findAnnotationMark( const ::rtl::OUString& rName ) const = 0; // 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 const ::rtl::OUString& GetCrossRefHeadingBookmarkNamePrefix(); static SAL_DLLPUBLIC_EXPORT bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& ); diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 3f67f86..d18e58b 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1491,18 +1491,32 @@ public: // wie z.B. die ::com::sun::star::text::Bookmarks oder die Verzeichnisse. // JP 22.06.95: ist bMoveCrsr gesetzt, verschiebe auch die Crsr - // Setzt alles in rOldNode auf rNewPos + Offset - void CorrAbs( const SwNodeIndex& rOldNode, const SwPosition& rNewPos, - const xub_StrLen nOffset = 0, sal_Bool bMoveCrsr = sal_False ); - // Setzt alles im Bereich von [rStartNode, rEndNode] nach rNewPos - void CorrAbs( const SwNodeIndex& rStartNode, const SwNodeIndex& rEndNode, - const SwPosition& rNewPos, sal_Bool bMoveCrsr = sal_False ); - // Setzt alles im Bereich von rRange nach rNewPos - void CorrAbs( const SwPaM& rRange, const SwPosition& rNewPos, - sal_Bool bMoveCrsr = sal_False ); - // Setzt alles in rOldNode auf relative Pos - void CorrRel( const SwNodeIndex& rOldNode, const SwPosition& rNewPos, - const xub_StrLen nOffset = 0, sal_Bool bMoveCrsr = sal_False ); + // Setzt alles in rOldNode auf rNewPos + Offset + void CorrAbs( + const SwNodeIndex& rOldNode, + const SwPosition& rNewPos, + const xub_StrLen nOffset = 0, + sal_Bool bMoveCrsr = sal_False ); + + // Setzt alles im Bereich von [rStartNode, rEndNode] nach rNewPos + void CorrAbs( + const SwNodeIndex& rStartNode, + const SwNodeIndex& rEndNode, + const SwPosition& rNewPos, + sal_Bool bMoveCrsr = sal_False ); + + // Setzt alles im Bereich von rRange nach rNewPos + void CorrAbs( + const SwPaM& rRange, + const SwPosition& rNewPos, + sal_Bool bMoveCrsr = sal_False ); + + // Setzt alles in rOldNode auf relative Pos + void CorrRel( + const SwNodeIndex& rOldNode, + const SwPosition& rNewPos, + const xub_StrLen nOffset = 0, + sal_Bool bMoveCrsr = sal_False ); // GliederungsRegeln erfragen / setzen // --> OD 2005-11-02 #i51089 - TUNING# diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx index 1c81537..47a92d0 100755 --- a/sw/source/core/crsr/annotationmark.cxx +++ b/sw/source/core/crsr/annotationmark.cxx @@ -60,6 +60,7 @@ namespace sw { namespace mark SwTxtFld* pTxtFld = GetMarkEnd().nNode.GetNode().GetTxtNode()->GetFldTxtAttrAt( GetMarkEnd().nContent.GetIndex()-1, true ); + ASSERT( 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 fc091af..07890d6 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -161,18 +161,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; @@ -645,14 +661,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; } @@ -679,39 +695,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 - 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()); - - // --> OD 2009-08-06 #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 ) + + 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() ); + } + } + + 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; + } + } + 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 ); } - // <-- } } @@ -827,7 +855,7 @@ namespace sw { namespace mark find_if( pMarkLow, pMarkHigh, - bind(equal_to<const IMark*>(), bind(&boost::shared_ptr<IMark>::get, _1), pMark) ); + bind( equal_to<const IMark*>(), 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 16f3455..483a8ad 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -233,26 +233,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 280f550..b6b4075 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -907,12 +907,21 @@ void SwUndoSaveSection::SaveSection( SwDoc* pDoc, const SwNodeIndex& rSttIdx ) } -void SwUndoSaveSection::SaveSection( SwDoc* , const SwNodeRange& rRange ) +void SwUndoSaveSection::SaveSection( + SwDoc* pDoc, + const SwNodeRange& rRange ) { SwPaM aPam( rRange.aStart, rRange.aEnd ); - // loesche alle Fussnoten / FlyFrames / Bookmarks / Verzeichnisse + // 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 fbfc76b..c23d9fe 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1300,22 +1300,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) @@ -1334,21 +1318,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 2967698..cdcbcb7 100644 --- a/sw/source/ui/docvw/SidebarWin.cxx +++ b/sw/source/ui/docvw/SidebarWin.cxx @@ -593,11 +593,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 7f8368b..486feaa 100644 --- a/sw/source/ui/shells/textfld.cxx +++ b/sw/source/ui/shells/textfld.cxx @@ -367,9 +367,8 @@ void SwTextShell::ExecField(SfxRequest &rReq) if( !(sAuthor = aUserOpt.GetID()).Len() ) sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); - if( rSh.HasSelection() ) + if ( rSh.HasSelection() && !rSh.IsTableMode() ) { - rSh.NormalizePam( sal_False ); rSh.KillPams(); } diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 098180e..77d16e5 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -94,10 +94,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 { diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index f801d65..3e506fc 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -3776,8 +3776,8 @@ void XMLAnnotationImportContext::EndElement() // let's create a text range covering the start and the current position. uno::Reference< text::XText > xText = GetImportHelper().GetText(); uno::Reference< text::XTextCursor > xCursor = - xText->createTextCursorByRange( xPrevField->getAnchor() ); - xCursor->gotoRange( GetImportHelper().GetCursorAsRange(), true ); + xText->createTextCursorByRange( GetImportHelper().GetCursorAsRange() ); + xCursor->gotoRange( xPrevField->getAnchor(), true ); uno::Reference< text::XTextRange > xTextRange( xCursor, uno::UNO_QUERY ); xText->insertTextContent( xTextRange, xPrevField, !xCursor->isCollapsed() ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits