From 32013f0dccde8407aa907112399dc2a9efb7f906 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Fri, 9 Apr 2021 11:06:13 +0200 Subject: tdf#120768 doc import: z-order background shapes behind others Interestingly, there were NO ww8export examples where a background item was attempting to insert itself after a foreground one. I think GENERALLY the order of shapes in a DOC file format is from bottom to top - and so it just worked by accident. Change-Id: If5226b4ad071455d1e3c30e334676cc5932a1064 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113837 Tested-by: Justin Luth Reviewed-by: Justin Luth --- sw/source/filter/ww8/ww8graf.cxx | 3 +++ sw/source/filter/ww8/ww8graf.hxx | 6 +++++- sw/source/filter/ww8/ww8graf2.cxx | 9 +++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'sw/source/filter/ww8') diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 89a3e8ac14f2..07ff4d41f730 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -2798,6 +2798,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp ) /* Need to make sure that the correct layer ordering is applied. */ // pass information, if object is in page header|footer to method. m_xWWZOrder->InsertEscherObject( pObject, pF->nSpId, + pRecord->bDrawHell, m_bIsHeader || m_bIsFooter ); } else @@ -3029,6 +3030,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject, { // pass information, if object is in page header|footer to method. m_xWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId, + pRecord->bDrawHell, m_bIsHeader || m_bIsFooter ); } } @@ -3180,6 +3182,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj { // pass information, if object is in page header|footer to method. m_xWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId, + pRecord->bDrawHell, m_bIsHeader || m_bIsFooter ); } } diff --git a/sw/source/filter/ww8/ww8graf.hxx b/sw/source/filter/ww8/ww8graf.hxx index 3b05c53d2c5d..7058fd1af897 100644 --- a/sw/source/filter/ww8/ww8graf.hxx +++ b/sw/source/filter/ww8/ww8graf.hxx @@ -33,12 +33,14 @@ struct EscherShape { sal_uLong mnEscherShapeOrder; sal_uLong mnNoInlines; - // new member + bool mbInHellLayer; bool mbInHeaderFooter; EscherShape( sal_uLong nEscherShapeOrder, + bool bInHellLayer, bool _bInHeaderFooter ) : mnEscherShapeOrder(nEscherShapeOrder), mnNoInlines(0), + mbInHellLayer(bInHellLayer), mbInHeaderFooter( _bInHeaderFooter ) {} }; @@ -71,6 +73,7 @@ private: // new parameter <_bInHeaderFooter>, indicating // that object is in header or footer sal_uLong GetEscherObjectPos( sal_uLong nSpId, + const bool bInHellLayer, const bool _bInHeaderFooter ); sal_uLong GetDrawingObjectPos(short nWwHeight); void InsertObject(SdrObject *pObject, sal_uLong nPos); @@ -86,6 +89,7 @@ public: // new parameter <_bInHeaderFooter>, indicating that object is in header or footer void InsertEscherObject( SdrObject* pObject, sal_uLong nSpId, + const bool bInHellLayer, const bool _bInHeaderFooter ); void InsideEscher(sal_uLong nIndex); void OutsideEscher(); diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index 08ef81f6e397..13bf81c97c9f 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -69,9 +69,10 @@ void wwZOrderer::OutsideEscher() // consider new parameter <_bInHeaderFooter> void wwZOrderer::InsertEscherObject( SdrObject* pObject, sal_uLong nSpId, + const bool bInHellLayer, const bool _bInHeaderFooter ) { - sal_uLong nInsertPos = GetEscherObjectPos( nSpId, _bInHeaderFooter ); + sal_uLong nInsertPos = GetEscherObjectPos( nSpId, bInHellLayer, _bInHeaderFooter ); InsertObject(pObject, nInsertPos + mnNoInitialObjects + mnInlines); } @@ -100,6 +101,7 @@ sal_uInt16 wwZOrderer::GetEscherObjectIdx(sal_uLong nSpId) // consider new parameter <_bInHeaderFooter> sal_uLong wwZOrderer::GetEscherObjectPos( sal_uLong nSpId, + const bool bInHellLayer, const bool _bInHeaderFooter ) { /* @@ -137,12 +139,15 @@ sal_uLong wwZOrderer::GetEscherObjectPos( sal_uLong nSpId, { break; } + if ( bInHellLayer && !aIter->mbInHellLayer ) + break; + if ( aIter->mnEscherShapeOrder > nFound ) break; nRet += aIter->mnNoInlines+1; ++aIter; } - maEscherLayer.insert(aIter, EscherShape( nFound, _bInHeaderFooter ) ); + maEscherLayer.insert(aIter, EscherShape( nFound, bInHellLayer, _bInHeaderFooter ) ); return nRet; } -- cgit v1.2.3