Update to m13
[ooovba.git] / applied_patches / 0827-cws-ooxml03-docx-sw-fix-bookmarks-endless-loop.diff
blob9d66f730fbf3d187b6e477d08fc2bed01149598c
1 Index: wrtww8.hxx
2 ===================================================================
3 --- sw/source/filter/docx/wrtww8.hxx (revision 270990)
4 +++ sw/source/filter/docx/wrtww8.hxx (working copy)
5 @@ -723,9 +723,10 @@
6 /// Format-dependant part of the actual export.
7 virtual void ExportDocument_Impl() = 0;
9 - // Get the next position in the text node to output
10 + /// Get the next position in the text node to output
11 virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
13 + /// Update the information for GetNextPos().
14 virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
16 /// Output SwTxtNode
17 Index: docxexport.cxx
18 ===================================================================
19 --- sw/source/filter/docx/docx-docxexport.cxx (revision 271125)
20 +++ sw/source/filter/docx/docx-docxexport.cxx (working copy)
21 @@ -162,38 +162,49 @@
25 -xub_StrLen DocxExport::GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos )
26 +bool DocxExport::NearestBookmark( xub_StrLen& rNearest )
28 - // Get the bookmarks for the normal run
29 - xub_StrLen nNextPos = MSWordExportBase::GetNextPos( pAttrIter, rNode, nAktPos );
30 - GetSortedBookmarks( rNode, nAktPos, nNextPos - nAktPos );
31 + bool bHasBookmark = false;
33 - // Then return the nearest position between the bookmarks
34 - // starts and ends and the next pos
35 - xub_StrLen nBStart = nNextPos;
36 - if ( m_rSortedBkmksStart.size( ) > 0 )
37 + if ( m_rSortedBkmksStart.size( ) > 0 )
39 SwBookmark* pBkmkStart = m_rSortedBkmksStart[0];
40 - nBStart = pBkmkStart->BookmarkStart( )->nContent.GetIndex( );
41 + rNearest = pBkmkStart->BookmarkStart()->nContent.GetIndex();
42 + bHasBookmark = true;
45 - xub_StrLen nBEnd = nNextPos;
47 if ( m_rSortedBkmksEnd.size( ) > 0 )
49 SwBookmark* pBkmkEnd = m_rSortedBkmksEnd[0];
50 - nBEnd = pBkmkEnd->BookmarkEnd( )->nContent.GetIndex( );
51 + if ( !bHasBookmark )
52 + rNearest = pBkmkEnd->BookmarkEnd()->nContent.GetIndex();
53 + else
54 + rNearest = std::min( rNearest, pBkmkEnd->BookmarkEnd()->nContent.GetIndex() );
55 + bHasBookmark = true;
58 - nNextPos = std::min( nNextPos, std::min( nBStart, nBEnd ) );
60 - return nNextPos;
61 + return bHasBookmark;
64 +xub_StrLen DocxExport::GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos )
66 + // Get the bookmarks for the normal run
67 + xub_StrLen nNextPos = MSWordExportBase::GetNextPos( pAttrIter, rNode, nAktPos );
69 + GetSortedBookmarks( rNode, nAktPos, nNextPos - nAktPos );
71 + xub_StrLen nNextBookmark = nNextPos;
72 + NearestBookmark( nNextPos );
74 + return std::min( nNextPos, nNextBookmark );
77 void DocxExport::UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd )
79 - bool hasBkmks = ( m_rSortedBkmksStart.size() > 0 || m_rSortedBkmksEnd.size() > 0 );
81 - if ( !hasBkmks )
82 + xub_StrLen nNextPos;
84 + // either no bookmark, or it is not at the current position
85 + if ( !NearestBookmark( nNextPos ) || nNextPos > nAktPos )
87 MSWordExportBase::UpdatePosition( pAttrIter, nAktPos, nEnd );
89 Index: docxexport.hxx
90 ===================================================================
91 --- sw/source/filter/docx/docxexport.hxx (revision 270990)
92 +++ sw/source/filter/docx/docxexport.hxx (working copy)
93 @@ -161,12 +161,18 @@
94 const SwNode& rNd,
95 const SwFmtPageDesc* pNewPgDescFmt = 0,
96 const SwPageDesc* pNewPgDesc = 0 );
99 + /// Get the next position in the text node to output
100 virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
102 + /// Update the information for GetNextPos().
103 virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
105 private:
106 + /// Find the nearest bookmark from the current position.
107 + ///
108 + /// Returns false when there is no bookmark.
109 + bool NearestBookmark( xub_StrLen& rNearest );
111 void GetSortedBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos,
112 xub_StrLen nLen );