Index: wrtw8nds.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtw8nds.cxx,v retrieving revision 1.38 diff -u -r1.38 wrtw8nds.cxx --- wrtw8nds.cxx 19 Sep 2002 13:54:59 -0000 1.38 +++ wrtw8nds.cxx 7 Oct 2002 13:51:28 -0000 @@ -294,6 +294,8 @@ bool mbCharIsRTL; bool mbParaIsRTL; + SwPosFlyFrms maFlyFrms; // i2916 + xub_StrLen SearchNext( xub_StrLen nStartPos ); void SetCharSet(const SwTxtAttr& rTxtAttr, bool bStart); void FieldVanish( const String& rTxt ); @@ -388,6 +390,32 @@ } aIter = maDirChanges.begin(); + // i2916 + // Create list of any graphics which may be anchored in this + // paragraph. + { + SwPosFlyFrms maAllFlys; + + rWrt.pDoc->GetAllFlyFmts(maAllFlys, rWrt.bWriteAll ? 0 : rWrt.GetEndPaM(), rWrt.bWrtWW8); + ULONG nCurPos = rNd.GetIndex(); + + for (USHORT n = 0; n < maAllFlys.Count(); n++) + { + // Do stuff + ULONG flyNdPos = maAllFlys[n]->GetNdIndex().GetIndex(); + + if (flyNdPos == nCurPos) + { + maFlyFrms.Insert(maAllFlys[n]); + } + else if (flyNdPos > nCurPos) + { + // Array is sorted and we've run past our node? + break; + } + } + } + if( rWrt.pDoc->GetRedlineTbl().Count() ) { SwPosition aPos( rNd, SwIndex( (SwTxtNode*)&rNd ) ); @@ -498,6 +526,32 @@ } } + // i2916 + // Check to see if there are any graphics anchored to characters + // in this paragraph's text. + // Set nMinPos to 1 past the placement because anchors in Word + // appear after the character they are anchored to. + if (maFlyFrms.Count() > 0) + { + for (i = 0; i < maFlyFrms.Count(); i++) + { + const SwPosition* pAnchorPos = maFlyFrms[i]->GetFmt().GetAnchor().GetCntntAnchor(); + + nPos = pAnchorPos->nContent.GetIndex(); + if (nPos >= nStartPos && nPos <= nMinPos) + { + nMinPos = nPos; + } + + nPos++; + + if (nPos >= nStartPos && nPos <= nMinPos) + { + nMinPos = nPos; + } + } + } + return nMinPos; } @@ -584,6 +638,36 @@ rWrt.pOutFmtNode = pOldMod; } + // i2916 + // May have an anchored graphic to be placed. + if (maFlyFrms.Count() > 0) + { + for (xub_StrLen i = 0; i < maFlyFrms.Count(); i++) + { + const SwFmtAnchor& rAnchor = maFlyFrms[i]->GetFmt().GetAnchor(); + + const SwPosition* pAnchorPos = rAnchor.GetCntntAnchor(); + + xub_StrLen nPos = pAnchorPos->nContent.GetIndex(); + + if (nPos == nSwPos) + { + const SwFrmFmt& rFmt = maFlyFrms[i]->GetFmt(); + + if ( rAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) + { + // OutWW8FlyFrm will flush the attributes + // for the anchored character. + Point aNdPos = rNd.FindLayoutRect(false, &aNdPos).Pos(); + Point* pLayPos = &aNdPos; + + rWrt.OutWW8FlyFrm(rFmt, *pLayPos); + } + break; + } + } + } + OutRedlines( nSwPos ); } @@ -601,6 +685,7 @@ return true; } } + return false; } @@ -2319,7 +2404,18 @@ pLayPos = &aNdPos; } - OutWW8FlyFrm( rFmt, *pLayPos ); + + // i2916: + // Anchored Escher objects should be dealt with by the + // Attribute Iterator as part of the text processing, + // in a similar manner to inline graphics, rather than + // simply writing them all out at the start of the + // paragraph. + if ( rFmt.GetAnchor().GetAnchorId() != FLY_AUTO_CNTNT ) + { + OutWW8FlyFrm( rFmt, *pLayPos ); + } + ++n; } }