diff options
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 20 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/relfromh-insidemargin.docx | bin | 0 -> 16119 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/GraphicHelpers.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicHelpers.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 6 |
5 files changed, 31 insertions, 2 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx index a98288fc40d3..590a93273e92 100644 --- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx +++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/text/RelOrientation.hpp> using namespace ::com::sun::star; @@ -114,6 +115,25 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineInShapeAnchoredZOrder) // i.e. the image was behind the textbox that was hosting it. CPPUNIT_ASSERT_EQUAL(OUString("Picture 1"), xOval->getName()); } + +CPPUNIT_TEST_FIXTURE(Test, testRelfromhInsidemargin) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "relfromh-insidemargin.docx"; + getComponent() = loadFromDesktop(aURL); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + sal_Int16 nRelation = 0; + xShape->getPropertyValue("HoriOrientRelation") >>= nRelation; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 7 (PAGE_FRAME) + // - Actual : 0 (FRAME) + // i.e. the horizontal position was relative to the paragraph area, not to the entire page. + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, nRelation); + bool bPageToggle = false; + xShape->getPropertyValue("PageToggle") >>= bPageToggle; + CPPUNIT_ASSERT(bPageToggle); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/relfromh-insidemargin.docx b/writerfilter/qa/cppunittests/dmapper/data/relfromh-insidemargin.docx Binary files differnew file mode 100644 index 000000000000..1f7a281e8b63 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/relfromh-insidemargin.docx diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx index 34a7bac660eb..95873b512d26 100644 --- a/writerfilter/source/dmapper/GraphicHelpers.cxx +++ b/writerfilter/source/dmapper/GraphicHelpers.cxx @@ -98,6 +98,11 @@ void PositionHandler::lcl_attribute( Id aName, Value& rVal ) m_nRelation = text::RelOrientation::PAGE_FRAME; break; + case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_insideMargin: + m_nRelation = text::RelOrientation::PAGE_FRAME; + m_bPageToggle = true; + break; + case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column: m_nRelation = text::RelOrientation::FRAME; break; diff --git a/writerfilter/source/dmapper/GraphicHelpers.hxx b/writerfilter/source/dmapper/GraphicHelpers.hxx index dbfe9ddd9f13..d28f2fb50bf7 100644 --- a/writerfilter/source/dmapper/GraphicHelpers.hxx +++ b/writerfilter/source/dmapper/GraphicHelpers.hxx @@ -37,6 +37,7 @@ public: sal_Int16 orientation() const; sal_Int16 relation() const { return m_nRelation;} sal_Int32 position() const { return m_nPosition;} + bool GetPageToggle() const { return m_bPageToggle; } private: virtual void lcl_attribute( Id aName, Value& rVal ) override; virtual void lcl_sprm( Sprm& rSprm ) override; @@ -45,6 +46,7 @@ public: sal_Int32 m_nPosition; std::pair<OUString, OUString>& m_rPositionOffsets; std::pair<OUString, OUString>& m_rAligns; + bool m_bPageToggle = false; }; class WrapHandler: public LoggedProperties diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index ce449a6251b2..760bb1bb6b3e 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -201,6 +201,7 @@ public: sal_Int16 nHoriOrient; sal_Int16 nHoriRelation; + bool bPageToggle = false; sal_Int16 nVertOrient; sal_Int16 nVertRelation; text::WrapTextMode nWrap; @@ -357,8 +358,8 @@ public: uno::makeAny(nLeftPosition)); xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_HORI_ORIENT_RELATION ), uno::makeAny(nHoriRelation)); - xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_PAGE_TOGGLE ), - uno::makeAny(false)); + xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_PAGE_TOGGLE), + uno::makeAny(bPageToggle)); if (!bRelativeOnly) xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_VERT_ORIENT_POSITION), uno::makeAny(nTopPosition)); @@ -1102,6 +1103,7 @@ void GraphicImport::lcl_sprm(Sprm& rSprm) if( !m_pImpl->bUseSimplePos ) { m_pImpl->nHoriRelation = pHandler->relation(); + m_pImpl->bPageToggle = pHandler->GetPageToggle(); m_pImpl->nHoriOrient = pHandler->orientation(); m_pImpl->nLeftPosition = pHandler->position(); |