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>
This commit is contained in:
committed by
László Németh
parent
fdb5ce011c
commit
10f29d8bf0
BIN
sw/qa/extras/ooxmlexport/data/tdf87569_drawingml.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/tdf87569_drawingml.docx
Normal file
Binary file not shown.
BIN
sw/qa/extras/ooxmlexport/data/tdf87569_vml.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/tdf87569_vml.docx
Normal file
Binary file not shown.
@@ -17,6 +17,7 @@
|
||||
#include <tools/lineend.hxx>
|
||||
#include <com/sun/star/text/TableColumnSeparator.hpp>
|
||||
#include <com/sun/star/text/XDocumentIndex.hpp>
|
||||
#include <com/sun/star/text/RelOrientation.hpp>
|
||||
|
||||
class Test : public SwModelTestBase
|
||||
{
|
||||
@@ -33,6 +34,25 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testTdf87569v, "tdf87569_vml.docx")
|
||||
{
|
||||
//the original tdf87569 sample has vml shapes...
|
||||
uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), uno::UNO_QUERY);
|
||||
sal_Int16 nValue;
|
||||
xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf87569_vml: The Shape is not in the table!",
|
||||
text::RelOrientation::FRAME, nValue);
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testTdf87569d, "tdf87569_drawingml.docx")
|
||||
{
|
||||
//if the original tdf87569 sample is upgraded it will have drawingml shapes...
|
||||
uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), uno::UNO_QUERY);
|
||||
sal_Int16 nValue;
|
||||
xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf87569_drawingml: The Shape is not in the table!",
|
||||
text::RelOrientation::FRAME, nValue);
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testTdf120315, "tdf120315.docx")
|
||||
{
|
||||
|
@@ -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( )
|
||||
|
@@ -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));
|
||||
|
Reference in New Issue
Block a user