diff options
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin15.docx | bin | 0 -> 79017 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 10 |
3 files changed, 20 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin15.docx b/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin15.docx Binary files differnew file mode 100755 index 000000000000..0b80c9652fbe --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf160049_anchorMargin15.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index d045e18efa32..8bae715cf4de 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -297,14 +297,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMarginVML, "tdf160049_anchorMarginV { // given a VML (Word 2003) document with a LEFT "column/text" anchored image // (which will import as DML compat12 on the round-trip) - if (isExported()) - return; + // The image takes into account the margin, so it looks like it is in the middle of the doc, // which is "Paragraph text area"/PRINT_AREA/1, not "Entire paragraph area"/FRAME/0 CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation")); } +DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin15, "tdf160049_anchorMargin15.docx") +{ + // given a DML compat15 (Word 2013) document with a LEFT "column/text" anchored image + + // The image ignores the margin, so it is at the left for compat15 (but middle-ish for compat14) + CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::FRAME, + getProperty<sal_Int16>(getShape(1), "HoriOrientRelation")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf153909_followTextFlow, "tdf153909_followTextFlow.docx") { // Although MSO's UI reports "layoutInCell" for the rectangle, it isn't specified or honored diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index a2acdeb604cc..fb34152cda6f 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1839,6 +1839,16 @@ uno::Reference<text::XTextContent> GraphicImport::createGraphicObject(uno::Refer sal_Int32 nWidth = - m_pImpl->m_nLeftPosition; if (m_pImpl->m_rGraphicImportType == IMPORT_AS_DETECTED_ANCHOR) { + if (m_pImpl->m_nHoriRelation == text::RelOrientation::FRAME + && m_pImpl->m_nHoriOrient > text::HoriOrientation::NONE + && m_pImpl->m_nHoriOrient != text::HoriOrientation::CENTER + && m_pImpl->m_nHoriOrient < text::HoriOrientation::FULL) + { + // before compat15, relative left/right/inside/outside honored margins. + if (m_pImpl->m_rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() < 15) + m_pImpl->m_nHoriRelation = text::RelOrientation::PRINT_AREA; + } + //adjust margins if( (m_pImpl->m_nHoriOrient == text::HoriOrientation::LEFT && (m_pImpl->m_nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA || |