summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-09-19 10:58:59 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-09-19 13:41:50 +0200
commitab825c665c1ee509769bdaf0ae95fc111a357fc6 (patch)
treedc27a2a066bcc93c878088f25da10eb01a27416c
parent34daa253f323cb8b80d6d10a8cdac85e2fa9378d (diff)
Related: tdf#124600 sw anchored object allow overlap: add UNO API
And fix the pool item's operator==() that forgot to take allow-overlap into account. Change-Id: I34ec29eed95d821cfccebbb15675e0f576b6454d Reviewed-on: https://gerrit.libreoffice.org/79115 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--offapi/com/sun/star/text/BaseFrameProperties.idl5
-rw-r--r--offapi/com/sun/star/text/Shape.idl5
-rw-r--r--sw/inc/unomid.h1
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx26
-rw-r--r--sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx25
-rw-r--r--sw/source/core/unocore/unoframe.cxx9
-rw-r--r--sw/source/core/unocore/unomap.cxx1
-rw-r--r--sw/source/core/unocore/unomap1.cxx1
-rw-r--r--sw/source/core/unocore/unomapproperties.hxx1
10 files changed, 70 insertions, 5 deletions
diff --git a/offapi/com/sun/star/text/BaseFrameProperties.idl b/offapi/com/sun/star/text/BaseFrameProperties.idl
index 4f62845fe6ba..bffa5ddf4770 100644
--- a/offapi/com/sun/star/text/BaseFrameProperties.idl
+++ b/offapi/com/sun/star/text/BaseFrameProperties.idl
@@ -367,6 +367,11 @@ published service BaseFrameProperties
@since LibreOffice 6.1
*/
[optional, property] com::sun::star::graphic::XGraphic BackGraphic;
+
+ /** This defines if the frame is allowed to overlap with other anchored objects.
+ @since LibreOffice 6.4
+ */
+ [optional, property] boolean AllowOverlap;
};
diff --git a/offapi/com/sun/star/text/Shape.idl b/offapi/com/sun/star/text/Shape.idl
index 9315b01751de..7e8ba75a23fc 100644
--- a/offapi/com/sun/star/text/Shape.idl
+++ b/offapi/com/sun/star/text/Shape.idl
@@ -187,6 +187,11 @@ published service Shape
@since OOo 2.0
*/
[optional, readonly, property] com::sun::star::awt::Point EndPositionInHoriL2R;
+
+ /** This defines if the shape is allowed to overlap with other anchored objects.
+ @since LibreOffice 6.4
+ */
+ [optional, property] boolean AllowOverlap;
};
diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h
index 06e84c99acb1..0a312a70624a 100644
--- a/sw/inc/unomid.h
+++ b/sw/inc/unomid.h
@@ -146,6 +146,7 @@
// SwFormatWrapInfluenceOnObjPos
#define MID_WRAP_INFLUENCE 0
+#define MID_ALLOW_OVERLAP 1
// SwFormatFollowTextFlow
#define MID_FOLLOW_TEXT_FLOW 0
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 69fadbe60c5f..a6246f9d2d36 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -869,6 +869,7 @@
#define UNO_NAME_TABLE_LAST_ROW_START_COLUMN "LastRowStartColumn"
#define UNO_NAME_RESOLVED "Resolved"
+#define UNO_NAME_ALLOW_OVERLAP "AllowOverlap"
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index ffb57d836f48..e16562372bc3 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -644,6 +644,32 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testXTextCursor_setPropertyValues)
getProperty<OUString>(xCursorProps, "CharStyleName"));
}
+CPPUNIT_TEST_FIXTURE(SwUnoWriter, testShapeAllowOverlap)
+{
+ // Test the AllowOverlap frame/shape property.
+
+ // Create a new document and insert a rectangle.
+ loadURL("private:factory/swriter", nullptr);
+ uno::Reference<lang::XMultiServiceFactory> xDocument(mxComponent, uno::UNO_QUERY);
+ awt::Point aPoint(1000, 1000);
+ awt::Size aSize(10000, 10000);
+ 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);
+ xDrawPageSupplier->getDrawPage()->add(xShape);
+
+ // The property is on by default, turn it off & verify.
+ uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
+ xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false));
+ CPPUNIT_ASSERT(!getProperty<bool>(xShapeProperties, "AllowOverlap"));
+
+ // Turn it back to on & verify.
+ xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(true));
+ CPPUNIT_ASSERT(getProperty<bool>(xShapeProperties, "AllowOverlap"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx b/sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx
index 0a1ef3221e94..a593416407c3 100644
--- a/sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx
+++ b/sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx
@@ -21,6 +21,7 @@
#include <unomid.h>
#include <osl/diagnose.h>
#include <libxml/xmlwriter.h>
+#include <sal/log.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -39,9 +40,10 @@ SwFormatWrapInfluenceOnObjPos::~SwFormatWrapInfluenceOnObjPos()
bool SwFormatWrapInfluenceOnObjPos::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
- return ( mnWrapInfluenceOnPosition ==
- static_cast<const SwFormatWrapInfluenceOnObjPos&>(rAttr).
- GetWrapInfluenceOnObjPos() );
+ const SwFormatWrapInfluenceOnObjPos& rAttribute
+ = static_cast<const SwFormatWrapInfluenceOnObjPos&>(rAttr);
+ return (mnWrapInfluenceOnPosition == rAttribute.GetWrapInfluenceOnObjPos()
+ && mbAllowOverlap == rAttribute.mbAllowOverlap);
}
SfxPoolItem* SwFormatWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const
@@ -57,6 +59,10 @@ bool SwFormatWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId )
{
rVal <<= GetWrapInfluenceOnObjPos();
}
+ else if( nMemberId == MID_ALLOW_OVERLAP )
+ {
+ rVal <<= GetAllowOverlap();
+ }
else
{
OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
@@ -87,6 +93,19 @@ bool SwFormatWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMember
OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
}
}
+ else if( nMemberId == MID_ALLOW_OVERLAP )
+ {
+ bool bAllowOverlap = true;
+ if (rVal >>= bAllowOverlap)
+ {
+ SetAllowOverlap(bAllowOverlap);
+ bRet = true;
+ }
+ else
+ {
+ SAL_WARN("sw.core", "SwFormatWrapInfluenceOnObjPos::PutValue: invalid AllowOverlap type");
+ }
+ }
else
{
OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - unknown MemberId" );
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index aa978f2962ea..b9fe6fb8deba 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -942,10 +942,15 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
// #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS
const ::uno::Any* pWrapInfluenceOnObjPos = nullptr;
GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS, MID_WRAP_INFLUENCE, pWrapInfluenceOnObjPos);
- if ( pWrapInfluenceOnObjPos )
+ const ::uno::Any* pAllowOverlap = nullptr;
+ GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS, MID_ALLOW_OVERLAP, pAllowOverlap);
+ if ( pWrapInfluenceOnObjPos || pAllowOverlap )
{
SwFormatWrapInfluenceOnObjPos aFormatWrapInfluenceOnObjPos;
- aFormatWrapInfluenceOnObjPos.PutValue( *pWrapInfluenceOnObjPos, MID_WRAP_INFLUENCE );
+ if (pWrapInfluenceOnObjPos)
+ aFormatWrapInfluenceOnObjPos.PutValue( *pWrapInfluenceOnObjPos, MID_WRAP_INFLUENCE );
+ if (pAllowOverlap)
+ aFormatWrapInfluenceOnObjPos.PutValue( *pAllowOverlap, MID_ALLOW_OVERLAP );
rToSet.Put(aFormatWrapInfluenceOnObjPos);
}
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 5bc4c3f5871a..bce1731dc993 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -311,6 +311,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ OUString(UNO_NAME_IS_LAYOUT_IN_CELL), RES_FOLLOW_TEXT_FLOW, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_FTF_LAYOUT_IN_CELL},
// #i28701#
{ OUString(UNO_NAME_WRAP_INFLUENCE_ON_POSITION), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<sal_Int8>::get(), PROPERTY_NONE, MID_WRAP_INFLUENCE},
+ { OUString(UNO_NAME_ALLOW_OVERLAP), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_ALLOW_OVERLAP},
// #i28749#
{ OUString(UNO_NAME_TRANSFORMATION_IN_HORI_L2R),
FN_SHAPE_TRANSFORMATION_IN_HORI_L2R,
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index 1cc12a5cb170..13fb8f6df1dd 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -459,6 +459,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetFrameStylePropertyM
{ OUString(UNO_NAME_IS_LAYOUT_IN_CELL), RES_FOLLOW_TEXT_FLOW, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_FTF_LAYOUT_IN_CELL},
// #i28701#
{ OUString(UNO_NAME_WRAP_INFLUENCE_ON_POSITION), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<sal_Int8>::get(), PROPERTY_NONE, MID_WRAP_INFLUENCE},
+ { OUString(UNO_NAME_ALLOW_OVERLAP), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_ALLOW_OVERLAP},
{ OUString(UNO_NAME_WRITING_MODE), RES_FRAMEDIR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0 },
{ OUString(UNO_NAME_HIDDEN), FN_UNO_HIDDEN, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_TEXT_VERT_ADJUST), RES_TEXT_VERT_ADJUST, cppu::UnoType<css::drawing::TextVerticalAdjust>::get(), PROPERTY_NONE ,0},
diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx
index c3a7c0c22fb0..6f772eed1acd 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -325,6 +325,7 @@
{ OUString(UNO_NAME_IS_LAYOUT_IN_CELL), RES_FOLLOW_TEXT_FLOW, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_FTF_LAYOUT_IN_CELL}, \
{ OUString(UNO_NAME_PARENT_TEXT), FN_UNO_PARENT_TEXT, cppu::UnoType<text::XText>::get(), PropertyAttribute::MAYBEVOID | PropertyAttribute::READONLY, 0 }, \
{ OUString(UNO_NAME_WRAP_INFLUENCE_ON_POSITION), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<sal_Int8>::get(), PROPERTY_NONE, MID_WRAP_INFLUENCE}, \
+ { OUString(UNO_NAME_ALLOW_OVERLAP), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_ALLOW_OVERLAP}, \
{ OUString(UNO_NAME_TITLE), FN_UNO_TITLE, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, \
{ OUString(UNO_NAME_DESCRIPTION), FN_UNO_DESCRIPTION, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, \
{ OUString(UNO_NAME_LAYOUT_SIZE), WID_LAYOUT_SIZE, cppu::UnoType<css::awt::Size>::get(), PropertyAttribute::MAYBEVOID | PropertyAttribute::READONLY, 0 }, \