diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-09-24 14:57:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-09-24 16:16:48 +0200 |
commit | ac7047f72087f09f2ab223f1af2518778382c06a (patch) | |
tree | cae956d91e318b713ccf2e632ace5bee9b9212be /sw/qa | |
parent | 1c03df6e82e4bf30294fc0b9e64de5cc39efc5c4 (diff) |
Related: tdf#124600 sw anchored object allow overlap: wrap-through handling
Wrap-through and allow-overlap are conflicting requirements. Word gives
wrap-though a priority, i.e. those objects can still overlap, even if
allow-overlap=false is set.
Let Writer have the same priority, this flag was added primarily for
interoperability purposes.
[ No compatibility flag, AllowOverlap is "@since LibreOffice 6.4", so
the behavior can be just changed. ]
Change-Id: I3743e6c94f8430c86c1ab5ffe0aabc4537e35ccc
Reviewed-on: https://gerrit.libreoffice.org/79458
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index ccbfd0b944a3..a6d70234f423 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -12,6 +12,7 @@ #include <comphelper/propertysequence.hxx> #include <com/sun/star/linguistic2/LinguServiceManager.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> +#include <com/sun/star/text/WrapTextMode.hpp> #include <comphelper/scopeguard.hxx> #include <unotools/syslocaleoptions.hxx> #include <i18nlangtag/languagetag.hxx> @@ -3154,6 +3155,55 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testShapeAllowOverlap) #endif } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testShapeAllowOverlapWrap) +{ + // Create an empty document with two, intentionally overlapping shapes. + // Set their AllowOverlap property to false and their wrap to through. + loadURL("private:factory/swriter", nullptr); + uno::Reference<lang::XMultiServiceFactory> xDocument(mxComponent, uno::UNO_QUERY); + awt::Point aPoint(1000, 1000); + awt::Size aSize(2000, 2000); + uno::Reference<drawing::XShape> xShape( + xDocument->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); + xShape->setPosition(aPoint); + xShape->setSize(aSize); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xDocument, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); + xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false)); + xShapeProperties->setPropertyValue("AnchorType", + uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); + xShapeProperties->setPropertyValue("Surround", uno::makeAny(text::WrapTextMode_THROUGH)); + xDrawPageSupplier->getDrawPage()->add(xShape); + + aPoint = awt::Point(2000, 2000); + xShape.set(xDocument->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); + xShape->setPosition(aPoint); + xShape->setSize(aSize); + xShapeProperties.set(xShape, uno::UNO_QUERY); + xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false)); + xShapeProperties->setPropertyValue("AnchorType", + uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); + xShapeProperties->setPropertyValue("Surround", uno::makeAny(text::WrapTextMode_THROUGH)); + xDrawPageSupplier->getDrawPage()->add(xShape); + + // Now verify that the rectangle of the anchored objects do overlap. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPageFrame = pLayout->GetLower(); + SwFrame* pBodyFrame = pPageFrame->GetLower(); + SwFrame* pTextFrame = pBodyFrame->GetLower(); + CPPUNIT_ASSERT(pTextFrame->GetDrawObjs()); + SwSortedObjs& rObjs = *pTextFrame->GetDrawObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rObjs.size()); + SwAnchoredObject* pFirst = rObjs[0]; + SwAnchoredObject* pSecond = rObjs[1]; + // Without the accompanying fix in place, this test would have failed: AllowOverlap=no had + // priority over Surround=through (which is bad for Word compat). + CPPUNIT_ASSERT(pSecond->GetObjRect().IsOver(pFirst->GetObjRect())); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124600) { createDoc("tdf124600.docx"); |