summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/shapeimport.cxx40
-rw-r--r--xmloff/source/draw/ximpshap.cxx2
-rw-r--r--xmloff/source/draw/ximpshap.hxx2
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx7
-rw-r--r--xmloff/source/text/XMLTextFrameContext.hxx2
5 files changed, 46 insertions, 7 deletions
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index 121ab34fd6bf..a3da37016a1f 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -699,6 +699,8 @@ struct ZOrderHint
{
sal_Int32 nIs;
sal_Int32 nShould;
+ /// The hint is for this shape.
+ uno::Reference<drawing::XShape> xShape;
bool operator<(const ZOrderHint& rComp) const { return nShould < rComp.nShould; }
};
@@ -833,22 +835,23 @@ void XMLShapeImportHelper::popGroupAndSort()
{
mpImpl->mpSortContext->popGroupAndSort();
}
- catch( uno::Exception& )
+ catch( const uno::Exception& rException )
{
- OSL_FAIL("exception while sorting shapes, sorting failed!");
+ SAL_WARN("xmloff", "exception while sorting shapes, sorting failed: " << rException.Message);
}
// put parent on top and drop current context, we are done
mpImpl->mpSortContext = mpImpl->mpSortContext->mpParentContext;
}
-void XMLShapeImportHelper::shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape >&, sal_Int32 nZIndex )
+void XMLShapeImportHelper::shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nZIndex )
{
if( mpImpl->mpSortContext)
{
ZOrderHint aNewHint;
aNewHint.nIs = mpImpl->mpSortContext->mnCurrentZ++;
aNewHint.nShould = nZIndex;
+ aNewHint.xShape = xShape;
if( nZIndex == -1 )
{
@@ -863,6 +866,37 @@ void XMLShapeImportHelper::shapeWithZIndexAdded( css::uno::Reference< css::drawi
}
}
+void XMLShapeImportHelper::shapeRemoved(const uno::Reference<drawing::XShape>& xShape)
+{
+ auto it = std::find_if(mpImpl->mpSortContext->maZOrderList.begin(), mpImpl->mpSortContext->maZOrderList.end(), [&xShape](const ZOrderHint& rHint)
+ {
+ return rHint.xShape == xShape;
+ });
+ if (it == mpImpl->mpSortContext->maZOrderList.end())
+ // Part of the unsorted list, nothing to do.
+ return;
+
+ sal_Int32 nZIndex = it->nIs;
+
+ for (it = mpImpl->mpSortContext->maZOrderList.begin(); it != mpImpl->mpSortContext->maZOrderList.end();)
+ {
+ if (it->nIs == nZIndex)
+ {
+ // This is xShape: remove it and adjust the max of indexes
+ // accordingly.
+ it = mpImpl->mpSortContext->maZOrderList.erase(it);
+ mpImpl->mpSortContext->mnCurrentZ--;
+ continue;
+ }
+ else if (it->nIs > nZIndex)
+ // On top of xShape: adjust actual index to reflect removal.
+ it->nIs--;
+
+ // On top of or below xShape.
+ ++it;
+ }
+}
+
void XMLShapeImportHelper::addShapeConnection( css::uno::Reference< css::drawing::XShape >& rConnectorShape,
bool bStart,
const OUString& rDestShapeId,
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 0f9b6aaeb068..562a4e71db7c 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3414,7 +3414,7 @@ SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
{
}
-void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
+void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext)
{
const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index fe35475eb5e4..de83ecc5bccb 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -546,7 +546,7 @@ private:
protected:
/// helper to get the created xShape instance, needs to be overridden
virtual OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const override;
- virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) const override;
+ virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) override;
public:
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index 2d72c1758092..7edb08702ac6 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -768,7 +768,7 @@ void XMLTextFrameContext_Impl::Create( bool /*bHRefOrBase64*/ )
}
}
-void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
+void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext)
{
const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
@@ -779,6 +779,11 @@ void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContex
// just dispose to delete
uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
+ // Inform shape importer about the removal so it can adjust
+ // z-indxes.
+ uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY);
+ GetImport().GetShapeImport()->shapeRemoved(xShape);
+
if(xComp.is())
{
xComp->dispose();
diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx
index 8f19eda2d70e..2f82ea50ffac 100644
--- a/xmloff/source/text/XMLTextFrameContext.hxx
+++ b/xmloff/source/text/XMLTextFrameContext.hxx
@@ -60,7 +60,7 @@ class XMLTextFrameContext : public SvXMLImportContext, public MultiImageImportHe
protected:
/// helper to get the created xShape instance, needs to be overridden
virtual OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const override;
- virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) const override;
+ virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) override;
public: