diff options
author | Bakos Attila <bakos.attilakaroly@nisz.hu> | 2020-01-16 13:45:47 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-01-17 12:51:52 +0100 |
commit | 14ad64270e4fbca3c24da6f55f260b1fb229556a (patch) | |
tree | dd783e9a7c290cd0bcc437ab33c265c63ef547c5 /writerfilter/source/ooxml | |
parent | f7e071a00542c414a7e9d7bcf4434d908f225e59 (diff) |
tdf#129888 DOCX shape import: handle o:allowincell
(VML) and layoutInCell (DrawingML) attributes to fix
regressions caused by commit 10f29d8bf05d44ca8bc11d34d1294ec17f8ac0f1
(tdf#87569 tdf#109411 DOCX import: fix shape anchor in tables).
Position of shapes anchored to tables is calculated from
the cell margin only if the previous attributes allow that.
Change-Id: Ifcfcb7f4959aea522dd45dff00cefd1bb9f4edda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86922
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter/source/ooxml')
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 24 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 6f7839d0512b..19dc3bb917e0 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/xml/sax/FastShapeContextHandler.hpp> @@ -65,6 +67,7 @@ OOXMLFastContextHandler::OOXMLFastContextHandler mpStream(nullptr), mnTableDepth(0), inPositionV(false), + mbLayoutInCell(true), m_xContext(context), m_bDiscardChildren(false), m_bTookChoice(false) @@ -85,6 +88,7 @@ OOXMLFastContextHandler::OOXMLFastContextHandler(OOXMLFastContextHandler * pCont mpParserState(pContext->mpParserState), mnTableDepth(pContext->mnTableDepth), inPositionV(pContext->inPositionV), + mbLayoutInCell(pContext->mbLayoutInCell), m_xContext(pContext->m_xContext), m_bDiscardChildren(pContext->m_bDiscardChildren), m_bTookChoice(pContext->m_bTookChoice) @@ -1663,6 +1667,21 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element ) bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic ); + + //tdf#87569: Fix table layout with correcting anchoring + //If anchored object is in table, Word calculates its position from cell border + //instead of page (what is set in the sample document) + if (mnTableDepth > 0 && mbLayoutInCell) //if we had a table + { + uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY); + sal_Int16 nCurrentHorOriRel; //A temp variable for storaging the current setting + xShapePropSet->getPropertyValue("HoriOrientRelation") >>= nCurrentHorOriRel; + //and the correction: + if (nCurrentHorOriRel == com::sun::star::text::RelOrientation::PAGE_FRAME) + xShapePropSet->setPropertyValue("HoriOrientRelation", + uno::makeAny(text::RelOrientation::FRAME)); + } + // Notify the dmapper that the shape is ready to use if ( !bIsPicture ) { @@ -1735,6 +1754,11 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext pChildContext, this); + //tdf129888 store allowincell attribute of the VML shape + if (Attribs->hasAttribute(NMSP_vmlOffice | XML_allowincell)) + mbLayoutInCell + = !(Attribs->getValue(NMSP_vmlOffice | XML_allowincell) == "f"); + if (!bGroupShape) { pWrapper->addNamespace(NMSP_doc); diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index d5de5a778ee0..0cc3fb1791a9 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -226,6 +226,7 @@ protected: const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const { return m_xContext;} bool inPositionV; + bool mbLayoutInCell; // o:allowincell OOXMLValue::Pointer_t mpGridAfter; private: |