diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-20 16:44:21 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-20 16:57:49 +0100 |
commit | 01fc08c0b5c57fef8ad3755672f4266d85e849a5 (patch) | |
tree | 9f1a7f71281feae7e9be344a94371495f1a77338 /sw/source/core | |
parent | 3d601cfa4b63580b5a0d18044b5792894d54089f (diff) |
fdo#85554 SwXShape: fix getting ZOrder property when doc contains TextBoxes
Change-Id: I9b6b83f0f6d627bb14a880a19769ee70564cf52b
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 13 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index e48160f7363d..0c8ede9d2ffd 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -215,6 +215,25 @@ uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set< return pRet ? uno::makeAny(uno::Reference<drawing::XShape>(pRet->getUnoShape(), uno::UNO_QUERY)) : uno::Any(); } +sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject, std::set<const SwFrmFmt*>& rTextBoxes) +{ + if (const SdrPage* pPage = pObject->GetPage()) + { + sal_Int32 nOrder = 0; // Current logical order. + for (size_t i = 0; i < pPage->GetObjCount(); ++i) + { + if (lcl_isTextBox(pPage->GetObj(i), rTextBoxes)) + continue; + if (pPage->GetObj(i) == pObject) + return nOrder; + ++nOrder; + } + } + + SAL_WARN("sw.core", "SwTextBoxHelper::getOrdNum: no page or page doesn't contain the object"); + return pObject->GetOrdNum(); +} + SwFrmFmt* SwTextBoxHelper::findTextBox(uno::Reference<drawing::XShape> xShape) { SwXShape* pShape = dynamic_cast<SwXShape*>(xShape.get()); diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index d8b463274a77..b4e0b0bbb68f 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1756,6 +1756,19 @@ uno::Any SwXShape::getPropertyValue(const OUString& rPropertyName) aRet >>= aPath; aRet <<= _ConvertPolyPolygonBezierToLayoutDir( aPath ); } + else if (rPropertyName == "ZOrder") + { + // Convert the real draw page position to the logical one that ignores textboxes. + if (pFmt) + { + const SdrObject* pObj = pFmt->FindRealSdrObject(); + if (pObj) + { + std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pFmt->GetDoc()); + aRet <<= SwTextBoxHelper::getOrdNum(pObj, aTextBoxes); + } + } + } } } return aRet; |