Author: orw Date: Thu Dec 19 11:40:47 2013 New Revision: 1552283 URL: http://svn.apache.org/r1552283 Log: 123792: corrections regarding copy-and-paste of annotation fields
Modified: openoffice/branches/ooxml-osba/main/sw/inc/doc.hxx openoffice/branches/ooxml-osba/main/sw/source/core/doc/docbm.cxx openoffice/branches/ooxml-osba/main/sw/source/core/doc/doccomp.cxx openoffice/branches/ooxml-osba/main/sw/source/core/doc/doclay.cxx openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblcpy.cxx openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblrwcl.cxx openoffice/branches/ooxml-osba/main/sw/source/core/docnode/ndcopy.cxx openoffice/branches/ooxml-osba/main/sw/source/core/docnode/section.cxx openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/atrftn.cxx openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/thints.cxx openoffice/branches/ooxml-osba/main/sw/source/core/undo/undobj.cxx Modified: openoffice/branches/ooxml-osba/main/sw/inc/doc.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/inc/doc.hxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/inc/doc.hxx (original) +++ openoffice/branches/ooxml-osba/main/sw/inc/doc.hxx Thu Dec 19 11:40:47 2013 @@ -1108,12 +1108,14 @@ public: const SwSelBoxes* pSelBoxes = 0, SwFrmFmt *pParent = 0 ); - void CopyWithFlyInFly( const SwNodeRange& rRg, - const xub_StrLen nEndContentIndex, - const SwNodeIndex& rInsPos, - sal_Bool bMakeNewFrms = sal_True, - sal_Bool bDelRedlines = sal_True, - sal_Bool bCopyFlyAtFly = sal_False ) const; + void CopyWithFlyInFly( + const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, + const SwNodeIndex& rInsPos, + const SwPaM* pCopiedPaM = NULL, + const sal_Bool bMakeNewFrms = sal_True, + const sal_Bool bDelRedlines = sal_True, + const sal_Bool bCopyFlyAtFly = sal_False ) const; sal_Bool SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ); Modified: openoffice/branches/ooxml-osba/main/sw/source/core/doc/docbm.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/doc/docbm.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/doc/docbm.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/doc/docbm.cxx Thu Dec 19 11:40:47 2013 @@ -1360,38 +1360,33 @@ void _SaveCntntIdx(SwDoc* pDoc, const sal_Int32 nMarksCount = pMarkAccess->getAllMarksCount(); for ( ; aSave.GetCount() < nMarksCount; aSave.IncCount() ) { - bool bEqual = false; - bool bLower = false; + bool bMarkPosEqual = false; const ::sw::mark::IMark* pBkmk = (pMarkAccess->getAllMarksBegin() + aSave.GetCount())->get(); if(pBkmk->GetMarkPos().nNode.GetIndex() == nNode && pBkmk->GetMarkPos().nContent.GetIndex() <= nCntnt) { if(pBkmk->GetMarkPos().nContent.GetIndex() < nCntnt) { - bLower = true; // a hint for the other position... aSave.SetContent(pBkmk->GetMarkPos().nContent.GetIndex()); aSave.Add(rSaveArr); } else // if a bookmark position is equal nCntnt, the other position - bEqual = true; // has to decide if it is added to the array + bMarkPosEqual = true; // has to decide if it is added to the array } if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos().nNode.GetIndex() == nNode && pBkmk->GetOtherMarkPos().nContent.GetIndex() <= nCntnt) { - if(bLower || pBkmk->GetOtherMarkPos().nContent.GetIndex() < nCntnt) - { - if(bEqual) - { // the other position is before, the (main) position is equal - aSave.SetContent(pBkmk->GetMarkPos().nContent.GetIndex()); - aSave.Add(rSaveArr); - } - aSave.SetContent(pBkmk->GetOtherMarkPos().nContent.GetIndex()); - aSave.IncType(); + if(bMarkPosEqual) + { // the other position is before, the (main) position is equal + aSave.SetContent(pBkmk->GetMarkPos().nContent.GetIndex()); aSave.Add(rSaveArr); - aSave.DecType(); } + aSave.SetContent(pBkmk->GetOtherMarkPos().nContent.GetIndex()); + aSave.IncType(); + aSave.Add(rSaveArr); + aSave.DecType(); } } Modified: openoffice/branches/ooxml-osba/main/sw/source/core/doc/doccomp.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/doc/doccomp.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/doc/doccomp.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/doc/doccomp.cxx Thu Dec 19 11:40:47 2013 @@ -1354,8 +1354,11 @@ void SwCompareData::ShowInsert( sal_uLon } -void SwCompareData::ShowDelete( const CompareData& rData, sal_uLong nStt, - sal_uLong nEnd, sal_uLong nInsPos ) +void SwCompareData::ShowDelete( + const CompareData& rData, + sal_uLong nStt, + sal_uLong nEnd, + sal_uLong nInsPos ) { SwNodeRange aRg( ((SwCompareLine*)rData.GetLine( nStt ))->GetNode(), 0, Modified: openoffice/branches/ooxml-osba/main/sw/source/core/doc/doclay.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/doc/doclay.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/doc/doclay.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/doc/doclay.cxx Thu Dec 19 11:40:47 2013 @@ -389,9 +389,11 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt |* |*************************************************************************/ -SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, - const SwFmtAnchor& rNewAnchor, - bool bSetTxtFlyAtt, bool bMakeFrms ) +SwFrmFmt *SwDoc::CopyLayoutFmt( + const SwFrmFmt& rSource, + const SwFmtAnchor& rNewAnchor, + bool bSetTxtFlyAtt, + bool bMakeFrms ) { const bool bFly = RES_FLYFRMFMT == rSource.Which(); const bool bDraw = RES_DRAWFRMFMT == rSource.Which(); @@ -497,7 +499,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const Sw // sorge dafuer das auch Fly's in Fly's kopiert werden aIdx = *pSttNd->EndOfSectionNode(); - pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, sal_False, sal_True, sal_True ); + pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, NULL, sal_False, sal_True, sal_True ); } else { Modified: openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblcpy.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblcpy.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblcpy.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblcpy.cxx Thu Dec 19 11:40:47 2013 @@ -561,7 +561,7 @@ void lcl_CpyBox( const SwTable& rCpyTbl, SwNodeIndex aSavePos( aInsIdx, -1 ); if( pRg.get() ) - pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, sal_False ); + pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, NULL, sal_False ); else pDoc->GetNodes().MakeTxtNode( aInsIdx, (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() ); aSavePos++; Modified: openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblrwcl.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblrwcl.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblrwcl.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/doc/tblrwcl.cxx Thu Dec 19 11:40:47 2013 @@ -2098,7 +2098,7 @@ sal_Bool lcl_CopyBoxToDoc( const _FndBox *rpFndBox->GetBox()->GetSttNd()->EndOfSectionNode() ); SwNodeIndex aInsIdx( *pBox->GetSttNd(), 1 ); - pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, sal_False ); + pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, NULL, sal_False ); // den initialen TextNode loeschen pCpyPara->pDoc->GetNodes().Delete( aInsIdx, 1 ); } Modified: openoffice/branches/ooxml-osba/main/sw/source/core/docnode/ndcopy.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/docnode/ndcopy.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/docnode/ndcopy.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/docnode/ndcopy.cxx Thu Dec 19 11:40:47 2013 @@ -132,7 +132,9 @@ namespace } // TODO: use SaveBookmark (from _DelBookmarks) - static void lcl_CopyBookmarks(const SwPaM& rPam, SwPaM& rCpyPam) + static void lcl_CopyBookmarks( + const SwPaM& rPam, + SwPaM& rCpyPam ) { const SwDoc* pSrcDoc = rPam.GetDoc(); SwDoc* pDestDoc = rCpyPam.GetDoc(); @@ -1249,13 +1251,13 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPos if( aInsPos == pEnd->nNode ) { SwNodeIndex aSaveIdx( aInsPos, -1 ); - CopyWithFlyInFly( aRg, 0,aInsPos, bMakeNewFrms, sal_False ); + CopyWithFlyInFly( aRg, 0, aInsPos, &rPam, bMakeNewFrms, sal_False ); aSaveIdx++; pEnd->nNode = aSaveIdx; pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 ); } else - CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, bMakeNewFrms, sal_False ); + CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, bMakeNewFrms, sal_False ); bCopyBookmarks = false; @@ -1322,22 +1324,27 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPos // ----- Copy-Methode vom SwDoc - "kopiere Fly's in Fly's" ------ -void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, - const SwNodeIndex& rInsPos, sal_Bool bMakeNewFrms, - sal_Bool bDelRedlines, sal_Bool bCopyFlyAtFly ) const +void SwDoc::CopyWithFlyInFly( + const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, + const SwNodeIndex& rInsPos, + const SwPaM* pCopiedPaM, + const sal_Bool bMakeNewFrms, + const sal_Bool bDelRedlines, + const sal_Bool bCopyFlyAtFly ) const { - SwDoc* pDest = rInsPos.GetNode().GetDoc(); + SwDoc* pDest = rInsPos.GetNode().GetDoc(); - _SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 ); + _SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 ); - SwNodeIndex aSavePos( rInsPos, -1 ); - sal_Bool bEndIsEqualEndPos = rInsPos == rRg.aEnd; - GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, sal_True ); - aSavePos++; - if( bEndIsEqualEndPos ) - ((SwNodeIndex&)rRg.aEnd) = aSavePos; + SwNodeIndex aSavePos( rInsPos, -1 ); + sal_Bool bEndIsEqualEndPos = rInsPos == rRg.aEnd; + GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, sal_True ); + aSavePos++; + if( bEndIsEqualEndPos ) + ((SwNodeIndex&)rRg.aEnd) = aSavePos; - aRedlRest.Restore(); + aRedlRest.Restore(); #ifdef DBG_UTIL { @@ -1363,21 +1370,23 @@ void SwDoc::CopyWithFlyInFly( const SwNo CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); } - SwNodeRange aCpyRange( aSavePos, rInsPos ); + SwNodeRange aCpyRange( aSavePos, rInsPos ); - // dann kopiere noch alle Bookmarks + // dann kopiere noch alle Bookmarks if( getIDocumentMarkAccess()->getAllMarksCount() ) - { - SwPaM aRgTmp( rRg.aStart, rRg.aEnd ); - SwPaM aCpyTmp( aCpyRange.aStart, aCpyRange.aEnd ); + { + SwPaM aRgTmp( rRg.aStart, rRg.aEnd ); + SwPaM aCpyTmp( aCpyRange.aStart, aCpyRange.aEnd ); - lcl_CopyBookmarks( aRgTmp, aCpyTmp ); - } + lcl_CopyBookmarks( + pCopiedPaM != NULL ? *pCopiedPaM : aRgTmp, + aCpyTmp ); + } - if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() )) - lcl_DeleteRedlines( rRg, aCpyRange ); + if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() )) + lcl_DeleteRedlines( rRg, aCpyRange ); - pDest->GetNodes()._DelDummyNodes( aCpyRange ); + pDest->GetNodes()._DelDummyNodes( aCpyRange ); } void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest ) @@ -1396,9 +1405,11 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, S } } -void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, - const xub_StrLen nEndContentIndex, const SwNodeIndex& rStartIdx, - const bool bCopyFlyAtFly ) const +void SwDoc::CopyFlyInFlyImpl( + const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, + const SwNodeIndex& rStartIdx, + const bool bCopyFlyAtFly ) const { // Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend // ihrer Ordnungsnummer und kopiere sie erst dann. Damit wird Modified: openoffice/branches/ooxml-osba/main/sw/source/core/docnode/section.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/docnode/section.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/docnode/section.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/docnode/section.cxx Thu Dec 19 11:40:47 2013 @@ -1548,7 +1548,7 @@ void SwIntrnlSectRefLink::DataChanged( c SwTblNumFmtMerge aTNFM( *pSrcDoc, *pDoc ); - pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, bCreateFrm ); + pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, NULL, bCreateFrm ); aSave++; if( !bCreateFrm ) Modified: openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/atrftn.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/atrftn.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/atrftn.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/atrftn.cxx Thu Dec 19 11:40:47 2013 @@ -282,7 +282,9 @@ void SwTxtFtn::SetNumber( const sal_uInt } // Die Fussnoten duplizieren -void SwTxtFtn::CopyFtn(SwTxtFtn & rDest, SwTxtNode & rDestNode) const +void SwTxtFtn::CopyFtn( + SwTxtFtn & rDest, + SwTxtNode & rDestNode ) const { if (m_pStartNode && !rDest.GetStartNode()) { @@ -306,7 +308,7 @@ void SwTxtFtn::CopyFtn(SwTxtFtn & rDest, SwNodeIndex aEnd( *aStart.GetNode().EndOfSectionNode() ); sal_uLong nDestLen = aEnd.GetIndex() - aStart.GetIndex() - 1; - m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, 0, aEnd, sal_True ); + m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, 0, aEnd, NULL, sal_True ); // in case the destination section was not empty, delete the old nodes // before: Src: SxxxE, Dst: SnE Modified: openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/thints.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/thints.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/thints.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/txtnode/thints.cxx Thu Dec 19 11:40:47 2013 @@ -1055,6 +1055,14 @@ SwTxtAttr* MakeTxtAttr( case RES_TXTATR_ANNOTATION: { pNew = new SwTxtAnnotationFld( static_cast<SwFmtFld &>(rNew), nStt ); + if ( bIsCopy == COPY ) + { + // On copy of the annotation field do not keep the annotated text range by removing + // the relation to its annotation mark (relation established via annotation field's name). + // If the annotation mark is also copied, the relation and thus the annotated text range will be reestablished, + // when the annotation mark is created and inserted into the document. + const_cast<SwPostItField*>(dynamic_cast< const SwPostItField* >(pNew->GetFmtFld().GetField()))->SetName( String() ); + } } break; @@ -2943,12 +2951,6 @@ bool SwpHints::TryInsertHint( case RES_POSTITFLD: if ( pDoc->GetDocShell() ) pDoc->GetDocShell()->Broadcast( SwFmtFldHint( &((SwTxtFld*)pHint)->GetFmtFld(), SWFMTFLD_INSERTED ) ); - // For annotations on text ranges the corresponding annotation mark is created afterwards. - // Thus, if there is already an annotation mark, clear the annotation's name in order to cut the relation - if ( dynamic_cast< SwTxtAnnotationFld* >(pHint)->GetAnnotationMark( rNode.GetDoc() ) != NULL ) - { - const_cast<SwPostItField*>(dynamic_cast< const SwPostItField* >(pHint->GetFmtFld().GetField()))->SetName( String() ); - } break; } if( bInsFldType ) Modified: openoffice/branches/ooxml-osba/main/sw/source/core/undo/undobj.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/ooxml-osba/main/sw/source/core/undo/undobj.cxx?rev=1552283&r1=1552282&r2=1552283&view=diff ============================================================================== --- openoffice/branches/ooxml-osba/main/sw/source/core/undo/undobj.cxx (original) +++ openoffice/branches/ooxml-osba/main/sw/source/core/undo/undobj.cxx Thu Dec 19 11:40:47 2013 @@ -852,7 +852,7 @@ void SwUndoSaveCntnt::DelCntntIndex( con { // delete annotation marks, if its end position is covered by the deletion const SwPosition& rAnnotationEndPos = pBkmk->GetMarkEnd(); - if ( *pStt <= rAnnotationEndPos && rAnnotationEndPos <= *pEnd ) + if ( *pStt < rAnnotationEndPos && rAnnotationEndPos <= *pEnd ) { bSavePos = true; bSaveOtherPos = true;