diff options
author | Bakos Attila <bakos.attilakaroly@nisz.hu> | 2019-12-14 12:36:13 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-12-20 08:04:15 +0100 |
commit | 10f29d8bf05d44ca8bc11d34d1294ec17f8ac0f1 (patch) | |
tree | 0679ed8ae7758ea48944234c3cc204f359c000ee /writerfilter | |
parent | fdb5ce011cb043475869d0b607ea25b8f32b4314 (diff) |
tdf#87569 tdf#109411 DOCX import: fix shape anchor in tables
Import "relative from page" horizontal setting of
VML and DrawingML shapes as "relative from column"
in tables, just as MSO handles it.
Change-Id: If71f2e52bbba324a98651e701feaeb99acfefc48
Reviewed-on: https://gerrit.libreoffice.org/85141
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 15 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 9bbbedf64f9c..ccbe8d8d197b 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3023,6 +3023,21 @@ void DomainMapper::lcl_startShape(uno::Reference<drawing::XShape> const& xShape) m_pImpl->PushPendingShape(xShape); m_pImpl->SetIsFirstParagraphInShape(true); + + //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 (m_pImpl->m_nTableDepth > 0) //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 == text::RelOrientation::PAGE_FRAME) + xShapePropSet->setPropertyValue("HoriOrientRelation", + uno::makeAny(text::RelOrientation::FRAME)); + } + } void DomainMapper::lcl_endShape( ) diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 74fa991eeb10..63a0e7491fb4 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -867,6 +867,15 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) if (nRotation) xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation)); } + + //tdf#109411 If anchored object is in table, Word calculates its position from cell border + //instead of page (what is set in the sample document) + if (m_pImpl->rDomainMapper.IsInTable() && + m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME && IsGraphic()) + { + m_pImpl->nHoriRelation = text::RelOrientation::FRAME; + } + m_pImpl->applyRelativePosition(xShapeProps, /*bRelativeOnly=*/true); xShapeProps->setPropertyValue("SurroundContour", uno::makeAny(m_pImpl->bContour)); |