tdf#135329 sw MS export: prevent skipping at-char anchors

This patch is step 1 - write out bypassed flies.
Step 2 - don't bypass fly positions.

The SearchNext function is skipping some flies
because it is not returning them as a stopping
position (nextAttr), and so OutFly just skipped
them since they didn't exactly match the position
it was acting on.

Generally a bad idea to just ignore a picture etc.
Perhaps this is safe enough to backport all the
way to stable. But pictures are such a mess in
general, and so fragile that I don't know what
the implications might be. Thus I am breaking
this fix down into as small pieces as I possibly
can for the benefit of regression finding/fixing.

Prior to this test, there were no unit tests that failed
    assert ( nPos >= nSwPos );

Change-Id: Idad0ea9d229f107a8b55150c476f3d4a6bdef3f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100375
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135329_lostImage.odt b/sw/qa/extras/ooxmlexport/data/tdf135329_lostImage.odt
new file mode 100644
index 0000000..234109a
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf135329_lostImage.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index f8dc2b8..1700318a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -237,6 +237,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf134609_gridAfter, "tdf134609_gridAfter.docx")
    CPPUNIT_ASSERT_MESSAGE("Top border is not an edge border", aBorder.LineWidth < 100);
}

DECLARE_OOXMLEXPORT_TEST(testTdf135329_lostImage, "tdf135329_lostImage.odt")
{
    // the character-anchored image was being skipped, since searchNext didn't notice it.
    uno::Reference<beans::XPropertySet> xImageProps(getShape(2), uno::UNO_QUERY_THROW);
}

DECLARE_OOXMLEXPORT_TEST(testTdf134063, "tdf134063.docx")
{
    CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 85b215f..82799ab 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -725,7 +725,7 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
        const SwPosition &rAnchor = maFlyIter->GetPosition();
        const sal_Int32 nPos = rAnchor.nContent.GetIndex();

        if ( nPos != nSwPos )
        if ( nPos > nSwPos )
            return FLY_NOT_PROCESSED ; // We haven't processed the fly

        const SdrObject* pSdrObj = maFlyIter->GetFrameFormat().FindRealSdrObject();