sw/qa/extras/ooxmlimport/data/tdf127825.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 26 ++++++++++++++++++++++++++ sw/source/core/layout/fly.cxx | 2 +- writerfilter/source/dmapper/GraphicImport.cxx | 20 +++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-)
New commits: commit a89f71f7195881b75a933a925f845a9c6447f7a3 Author: Miklos Vajna <[email protected]> AuthorDate: Mon Oct 7 21:10:33 2019 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Wed Oct 9 16:32:31 2019 +0200 tdf#127825 DOCX import: fix handling for tbrl, auto-height and rel size shapes Regression from commit ff17478e069cc82681df62514876c06365dd5cd6 (sw btlr writing mode: implement DOCX shape import for tbrl, 2019-04-25), there were two problems here: 1) Relative size currently only works properly for the lrtb direction, so disable that during import till sw core is improved. 2) When SwFlyFrame::Format() auto-grows a text frame which is the textbox of a shape, it needs to notify the shape about the physical size of the frame, not the logical one. So going via the SwRectFnSet abstraction is not correct in this case. (cherry picked from commit 9c81d0a268cca4ff36eff94c0842361b9c0287ef) Conflicts: sw/qa/extras/ooxmlimport/ooxmlimport2.cxx Change-Id: Ie185c7415d90594434eac8f459630d6a3212328a Reviewed-on: https://gerrit.libreoffice.org/80427 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/qa/extras/ooxmlimport/data/tdf127825.docx b/sw/qa/extras/ooxmlimport/data/tdf127825.docx new file mode 100644 index 000000000000..2caf612fd811 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf127825.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 99c6d5aaca51..3dd937ecbd2d 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -19,6 +19,8 @@ #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/style/BreakType.hpp> +#include <sortedobjs.hxx> +#include <anchoredobject.hxx> class Test : public SwModelTestBase { @@ -407,6 +409,30 @@ DECLARE_OOXMLIMPORT_TEST(testTdf126114, "tdf126114.docx") CPPUNIT_ASSERT_EQUAL(7, getLength()); } +DECLARE_OOXMLIMPORT_TEST(testTdf127825, "tdf127825.docx") +{ + // The document has a shape with Japanese-style text in it. The shape has relative size and also + // has automatic height. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + SwRootFrame* pLayout = pWrtShell->GetLayout(); + CPPUNIT_ASSERT(pLayout); + SwFrame* pPage = pLayout->GetLower(); + CPPUNIT_ASSERT(pPage); + SwFrame* pBody = pPage->GetLower(); + CPPUNIT_ASSERT(pBody); + SwFrame* pText = pBody->GetLower(); + CPPUNIT_ASSERT(pText); + CPPUNIT_ASSERT(pText->GetDrawObjs()); + const SwSortedObjs& rDrawObjs = *pText->GetDrawObjs(); + CPPUNIT_ASSERT(rDrawObjs.size()); + + // Without the accompanying fix in place, this overlapped the footer area, not the body area. + CPPUNIT_ASSERT(rDrawObjs[0]->GetObjRect().IsOver(pBody->getFrameArea())); +} + DECLARE_OOXMLIMPORT_TEST(testTdf103345, "numbering-circle.docx") { uno::Reference<beans::XPropertySet> xPropertySet( diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index a2193f24d654..1f566f373125 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -1273,7 +1273,7 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA if (SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>( pShape) ) { // The shape is a customshape: then inform it about the calculated fly size. - Size aSize(aRectFnSet.GetWidth(getFrameArea()), aRectFnSet.GetHeight(getFrameArea())); + Size aSize(getFrameArea().Width(), getFrameArea().Height()); pCustomShape->SuggestTextFrameSize(aSize); // Do the calculations normally done after touching editeng text of the shape. pCustomShape->NbcSetOutlinerParaObjectForText(nullptr, nullptr); diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index a9504a9785b4..e51b440ae7ac 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1114,7 +1114,25 @@ void GraphicImport::lcl_sprm(Sprm& rSprm) { uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY); OUString aProperty = nSprmId == NS_ooxml::LN_CT_SizeRelH_pctWidth ? OUString("RelativeWidth") : OUString("RelativeHeight"); - xPropertySet->setPropertyValue(aProperty, uno::makeAny(nPositivePercentage)); + + sal_Int32 nTextPreRotateAngle = 0; + uno::Any aAny; + if (xPropertySet->getPropertySetInfo()->hasPropertyByName( + "CustomShapeGeometry")) + { + aAny = xPropertySet->getPropertyValue("CustomShapeGeometry"); + } + comphelper::SequenceAsHashMap aCustomShapeGeometry(aAny); + auto it = aCustomShapeGeometry.find("TextPreRotateAngle"); + if (it != aCustomShapeGeometry.end()) + { + nTextPreRotateAngle = it->second.get<sal_Int32>(); + } + if (nTextPreRotateAngle == 0) + { + xPropertySet->setPropertyValue(aProperty, + uno::makeAny(nPositivePercentage)); + } } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
