tdf#77964 doc import: 0x1 placeholder is for AS_CHAR
It looks like MS always provides an sprm that confirms
this, but Kingsoft was saving without that sprm.
Something similar ought to be done for ImportOLE,
but it doesn't have a ready option for specifying
that, so I just left it because I don't care about OLE.
Change-Id: I0ae304a08b381c8c29f3db24f791f25f5e33b0c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138234
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sw/qa/extras/ww8export/data/tdf77964.doc b/sw/qa/extras/ww8export/data/tdf77964.doc
new file mode 100644
index 0000000..6ef50ab
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf77964.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx
index 91b9477..bc0d51f 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -13,6 +13,7 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <comphelper/sequenceashashmap.hxx>
@@ -48,6 +49,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf148360)
assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf77964)
{
loadAndReload("tdf77964.doc");
// both images were loading as AT_PARA instead of AS_CHAR. Image2 visually had text wrapping.
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty<text::TextContentAnchorType>(getShapeByName(u"Image2"), "AnchorType"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index d7e2d41..f9d5a4e 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3727,7 +3727,13 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs)
if (m_bObj)
pResult = ImportOle();
else if (m_bSpec)
pResult = ImportGraf();
{
SwFrameFormat* pAsCharFlyFormat = m_rDoc.GetDfltFrameFormat();
SwFormatAnchor aAnchor(RndStdIds::FLY_AS_CHAR);
pAsCharFlyFormat->SetFormatAttr(aAnchor);
pResult = ImportGraf(nullptr, pAsCharFlyFormat);
}
// If we have a bad 0x1 insert a space instead.
if (!pResult)