summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore/unoportenum.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-06-21 13:53:24 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-06-21 18:01:24 +0200
commitbf4b40f720146e7f76dab4deb72e85ea158e2d17 (patch)
tree040496cbceeae0204429177a06fcb37e6f526047 /sw/source/core/unocore/unoportenum.cxx
parent98e186a37388d35320b813142b4fc7f0071f5b43 (diff)
sw comments on frames: fix annotation start order in UNO portion enum
The problem was similar to commit 76a4305d1e90b6617054dd33036e64f005dbcf04 (sw: fix inconsistent bookmark behavior around at-char/as-char anchored frames, 2017-12-21), except here we have an (annotation) mark which does have a range, but still around at-char anchored frames, similar to the bookmark situation in that commit. Fix the problem similarly, by first adding comment-start portions to the enumeration, then frames, and finally the rest of the comment portions (as before). With this, an ODF <office:annotation/><draw:frame text:anchor-type="char"/><office:annotation-end/> sequence (commented at-char image) is roundtripped correctly. Change-Id: I8790d9efae625de48c689ca4180fe75f15b4833c Reviewed-on: https://gerrit.libreoffice.org/74503 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/unocore/unoportenum.cxx')
-rw-r--r--sw/source/core/unocore/unoportenum.cxx44
1 files changed, 37 insertions, 7 deletions
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 30cf25ade0bd..9660d3187754 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -1161,12 +1161,25 @@ static void lcl_ExportBkmAndRedline(
lcl_ExportSoftPageBreak(rPortions, xParent, pUnoCursor, rBreakArr, nIndex);
}
+/**
+ * Exports all start annotation marks from rAnnotationStartArr into rPortions that have the same
+ * start position as nIndex.
+ *
+ * @param rAnnotationStartArr the array of annotation marks. Consumed entries are removed.
+ *
+ * @param rFramePositions the list of positions where there is an at-char anchored frame.
+ *
+ * @param bOnlyFrame If true: export only the start of annotation marks which cover an at-char
+ * anchored frame. If false: export everything else.
+ */
static void lcl_ExportAnnotationStarts(
TextRangeList_t & rPortions,
Reference<XText> const & xParent,
const SwUnoCursor * const pUnoCursor,
SwAnnotationStartPortion_ImplList& rAnnotationStartArr,
- const sal_Int32 nIndex)
+ const sal_Int32 nIndex,
+ const std::set<sal_Int32>& rFramePositions,
+ bool bOnlyFrame)
{
for ( SwAnnotationStartPortion_ImplList::iterator aIter = rAnnotationStartArr.begin(), aEnd = rAnnotationStartArr.end();
aIter != aEnd; )
@@ -1182,12 +1195,18 @@ static void lcl_ExportAnnotationStarts(
break;
}
- SwXTextPortion* pPortion =
- new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION );
- pPortion->SetTextField( pPtr->mxAnnotationField );
- rPortions.emplace_back(pPortion);
+ bool bFrameStart = rFramePositions.find(nIndex) != rFramePositions.end();
+ if (bFrameStart || !bOnlyFrame)
+ {
+ SwXTextPortion* pPortion =
+ new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION );
+ pPortion->SetTextField( pPtr->mxAnnotationField );
+ rPortions.emplace_back(pPortion);
- aIter = rAnnotationStartArr.erase(aIter);
+ aIter = rAnnotationStartArr.erase(aIter);
+ }
+ else
+ ++aIter;
}
}
@@ -1356,6 +1375,15 @@ static void lcl_CreatePortions(
lcl_ExportBkmAndRedline( *PortionStack.top().first, i_xParentText,
pUnoCursor, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex, aFramePositions, /*bOnlyFrameBookmarkStarts=*/true );
+ lcl_ExportAnnotationStarts(
+ *PortionStack.top().first,
+ i_xParentText,
+ pUnoCursor,
+ AnnotationStarts,
+ nCurrentIndex,
+ aFramePositions,
+ /*bOnlyFrame=*/true );
+
const sal_Int32 nFirstFrameIndex =
lcl_ExportFrames( *PortionStack.top().first,
i_xParentText, pUnoCursor, i_rFrames, nCurrentIndex);
@@ -1370,7 +1398,9 @@ static void lcl_CreatePortions(
i_xParentText,
pUnoCursor,
AnnotationStarts,
- nCurrentIndex );
+ nCurrentIndex,
+ aFramePositions,
+ /*bOnlyFrame=*/false );
bool bCursorMoved( false );
sal_Int32 nNextAttrIndex = -1;