From 31ee13b5a40715e217711e48753eeb7170e3349c Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Thu, 31 Aug 2017 14:13:46 +0200 Subject: convert SHAPEFLAG defines to scoped enum ShapeFlag they were defined in escherex.hxx as SHAPEFLAG_* and in msdffimp.hxx as SP_*. Added include for escherex.hxx to msdffimp.hxx. Filled the missing flag bits. ShapeFlag::Deleted is not used at the moment. Convert ADD_SHAPE macro to lambda. Fix horizontal/vertical mixup in RtfSdrExport::AddLineDimensions. Comments for flag Connector were wrong. The flag applies to shapes which ARE connectors. MSO definition: "connector: A line that is used to connect two or more shapes and that remains connected to those shapes." So Rectangles and such with Connector flag don't make sense. Change-Id: I735de00110411b280a302840dc0fcdfac5156399 Reviewed-on: https://gerrit.libreoffice.org/41754 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/filter/ww8/docxsdrexport.cxx | 2 +- sw/source/filter/ww8/escher.hxx | 2 +- sw/source/filter/ww8/rtfsdrexport.cxx | 18 +++++------------- sw/source/filter/ww8/rtfsdrexport.hxx | 4 ++-- sw/source/filter/ww8/wrtw8esh.cxx | 34 +++++++++++++++++++--------------- sw/source/filter/ww8/ww8graf.cxx | 4 ++-- sw/source/filter/ww8/ww8par.cxx | 8 ++++---- 7 files changed, 34 insertions(+), 38 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index ee2c646d536d..4509cc0b9bc9 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -935,7 +935,7 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrame // Depending on the shape type, we actually don't write the shape as DML. OUString sShapeType; - sal_uInt32 nMirrorFlags = 0; + ShapeFlag nMirrorFlags = ShapeFlag::NONE; uno::Reference xShape(const_cast(sdrObj)->getUnoShape(), uno::UNO_QUERY_THROW); // Locked canvas is OK inside DML. diff --git a/sw/source/filter/ww8/escher.hxx b/sw/source/filter/ww8/escher.hxx index 8d008133835c..a38f0c02b0e7 100644 --- a/sw/source/filter/ww8/escher.hxx +++ b/sw/source/filter/ww8/escher.hxx @@ -101,7 +101,7 @@ protected: void WriteBrushAttr(const SvxBrushItem &rBrush, EscherPropertyContainer& rPropOpt); void WriteOLEPicture(EscherPropertyContainer &rPropOpt, - sal_uInt32 nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj, + ShapeFlag nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj, sal_uInt32 nShapeId, const css::awt::Rectangle* pVisArea ); static void WriteGrfAttr(const SwNoTextNode& rNd, const SwFrameFormat& rFormat, EscherPropertyContainer& rPropOpt); diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index e77f0d89bd85..b8d53faf704b 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -42,7 +42,7 @@ RtfSdrExport::RtfSdrExport(RtfExport& rExport) m_rAttrOutput(static_cast(m_rExport.AttrOutput())), m_pSdrObject(nullptr), m_nShapeType(ESCHER_ShpInst_Nil), - m_nShapeFlags(0), + m_nShapeFlags(ShapeFlag::NONE), m_aShapeStyle(200), m_pShapeTypeWritten(new bool[ ESCHER_ShpInst_COUNT ]) { @@ -94,7 +94,7 @@ void RtfSdrExport::LeaveGroup() /* noop */ } -void RtfSdrExport::AddShape(sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 /*nShapeId*/) +void RtfSdrExport::AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 /*nShapeId*/) { m_nShapeType = nShapeType; m_nShapeFlags = nShapeFlags; @@ -407,19 +407,11 @@ void RtfSdrExport::AddLineDimensions(const tools::Rectangle& rRectangle) // We get the position relative to (the current?) character m_aShapeProps.insert(std::pair("posrelh", "3")); - switch (m_nShapeFlags & 0xC0) - { - case 0x40: - m_aShapeProps.insert(std::pair("fFlipV", "1")); - break; - case 0x80: - m_aShapeProps.insert(std::pair("fFlipH", "1")); - break; - case 0xC0: + if (m_nShapeFlags & ShapeFlag::FlipV) m_aShapeProps.insert(std::pair("fFlipV", "1")); + + if (m_nShapeFlags & ShapeFlag::FlipH) m_aShapeProps.insert(std::pair("fFlipH", "1")); - break; - } // the actual dimensions m_aShapeStyle.append(OOO_STRING_SVTOOLS_RTF_SHPLEFT).append(rRectangle.Left()); diff --git a/sw/source/filter/ww8/rtfsdrexport.hxx b/sw/source/filter/ww8/rtfsdrexport.hxx index 2b1302ec0042..f8d29fbc5a8a 100644 --- a/sw/source/filter/ww8/rtfsdrexport.hxx +++ b/sw/source/filter/ww8/rtfsdrexport.hxx @@ -47,7 +47,7 @@ class RtfSdrExport : public EscherEx sal_uInt32 m_nShapeType; /// Remember the shape flags. - sal_uInt32 m_nShapeFlags; + ShapeFlag m_nShapeFlags; /// Remember style, the most important shape attribute ;-) OStringBuffer m_aShapeStyle; @@ -94,7 +94,7 @@ private: sal_uInt32 EnterGroup(const OUString& rShapeName, const tools::Rectangle* pBoundRect) override; void LeaveGroup() override; - void AddShape(sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 nShapeId = 0) override; + void AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId = 0) override; private: /// Add starting and ending point of a line to the m_pShapeAttrList. diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index f5450722ce38..9027122be771 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1513,7 +1513,7 @@ void SwBasicEscherEx::WriteFrameExtraData(const SwFrameFormat&) void SwBasicEscherEx::WriteEmptyFlyFrame(const SwFrameFormat& rFormat, sal_uInt32 nShapeId) { OpenContainer(ESCHER_SpContainer); - AddShape(ESCHER_ShpInst_PictureFrame, 0xa00, nShapeId); + AddShape(ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, nShapeId); // store anchor attribute WriteFrameExtraData(rFormat); @@ -1523,7 +1523,7 @@ void SwBasicEscherEx::WriteEmptyFlyFrame(const SwFrameFormat& rFormat, sal_uInt3 CloseContainer(); // ESCHER_SpContainer } -sal_uInt32 AddMirrorFlags(sal_uInt32 nFlags, const SwMirrorGrf &rMirror) +ShapeFlag AddMirrorFlags(ShapeFlag nFlags, const SwMirrorGrf &rMirror) { switch (rMirror.GetValue()) { @@ -1531,14 +1531,13 @@ sal_uInt32 AddMirrorFlags(sal_uInt32 nFlags, const SwMirrorGrf &rMirror) case MirrorGraph::Dont: break; case MirrorGraph::Vertical: - nFlags |= SHAPEFLAG_FLIPH; + nFlags |= ShapeFlag::FlipH; break; case MirrorGraph::Horizontal: - nFlags |= SHAPEFLAG_FLIPV; + nFlags |= ShapeFlag::FlipV; break; case MirrorGraph::Both: - nFlags |= SHAPEFLAG_FLIPH; - nFlags |= SHAPEFLAG_FLIPV; + nFlags |= ShapeFlag::FlipH | ShapeFlag::FlipV; break; } @@ -1548,7 +1547,7 @@ sal_uInt32 AddMirrorFlags(sal_uInt32 nFlags, const SwMirrorGrf &rMirror) void SwBasicEscherEx::WriteGrfBullet(const Graphic& rGrf) { OpenContainer( ESCHER_SpContainer ); - AddShape(ESCHER_ShpInst_PictureFrame, 0xa00,0x401); + AddShape(ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, 0x401); EscherPropertyContainer aPropOpt; GraphicObject aGraphicObject( rGrf ); OString aUniqueId = aGraphicObject.GetUniqueID(); @@ -1604,8 +1603,9 @@ sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrameFormat& rFormat, sal_uI OpenContainer( ESCHER_SpContainer ); const SwMirrorGrf &rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf(); - AddShape(ESCHER_ShpInst_PictureFrame, AddMirrorFlags(0xa00, rMirror), - nShapeId); + AddShape(ESCHER_ShpInst_PictureFrame, + AddMirrorFlags(ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, rMirror), + nShapeId); EscherPropertyContainer aPropOpt; @@ -1834,8 +1834,9 @@ sal_Int32 SwBasicEscherEx::WriteOLEFlyFrame(const SwFrameFormat& rFormat, sal_uI EscherPropertyContainer aPropOpt; const SwMirrorGrf &rMirror = rOLENd.GetSwAttrSet().GetMirrorGrf(); - WriteOLEPicture(aPropOpt, AddMirrorFlags(0xa00 | SHAPEFLAG_OLESHAPE, - rMirror), pGraphic ? *pGraphic : Graphic(), *pSdrObj, nShapeId, bRectIsSet ? &aRect : nullptr ); + WriteOLEPicture(aPropOpt, + AddMirrorFlags(ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::OLEShape, rMirror), + pGraphic ? *pGraphic : Graphic(), *pSdrObj, nShapeId, bRectIsSet ? &aRect : nullptr ); nBorderThick = WriteFlyFrameAttr(rFormat, mso_sptPictureFrame, aPropOpt); WriteGrfAttr(rOLENd, rFormat, aPropOpt); @@ -2323,7 +2324,9 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt) { OpenContainer( ESCHER_SpContainer ); - AddShape( ESCHER_ShpInst_Rectangle, 0xe00, nSecondShapeId ); + AddShape( ESCHER_ShpInst_Rectangle, + ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::Background, + nSecondShapeId ); EscherPropertyContainer aPropOpt; const SwFrameFormat &rFormat = rWrt.m_pDoc->GetPageDesc(0).GetMaster(); @@ -2886,7 +2889,7 @@ sal_Int32 SwEscherEx::WriteTextFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId sal_Int32 nBorderThick=0; OpenContainer( ESCHER_SpContainer ); - AddShape( ESCHER_ShpInst_TextBox, 0xa00, nShapeId ); + AddShape( ESCHER_ShpInst_TextBox, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, nShapeId ); EscherPropertyContainer aPropOpt; aPropOpt.AddOpt(ESCHER_Prop_lTxid, nTextBox); if (const SwFrameFormat *pNext = rFormat.GetChain().GetNext()) @@ -2929,7 +2932,7 @@ sal_Int32 SwEscherEx::WriteTextFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId } void SwBasicEscherEx::WriteOLEPicture(EscherPropertyContainer &rPropOpt, - sal_uInt32 nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj, + ShapeFlag nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj, sal_uInt32 nShapeId, const awt::Rectangle* pVisArea ) { //nShapeFlags == 0xA00 + flips and ole active @@ -2970,7 +2973,8 @@ void SwEscherEx::WriteOCXControl( const SwFrameFormat& rFormat, sal_uInt32 nShap Graphic aGraphic(SdrExchangeView::GetObjGraphic(pModel, pSdrObj)); EscherPropertyContainer aPropOpt; - WriteOLEPicture(aPropOpt, 0xa00 | SHAPEFLAG_OLESHAPE, aGraphic, + WriteOLEPicture(aPropOpt, + ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::OLEShape, aGraphic, *pSdrObj, nShapeId, nullptr ); WriteFlyFrameAttr( rFormat, mso_sptPictureFrame , aPropOpt ); diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 4b7a47f307dc..fcc10d5b54b0 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -2079,8 +2079,8 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord, pGrfNd->SetAttr( aCrop ); } - bool bFlipH = pRecord->nFlags & SHAPEFLAG_FLIPH; - bool bFlipV = pRecord->nFlags & SHAPEFLAG_FLIPV; + bool bFlipH(pRecord->nFlags & ShapeFlag::FlipH); + bool bFlipV(pRecord->nFlags & ShapeFlag::FlipV); if ( bFlipH || bFlipV ) { SwMirrorGrf aMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index ca10f1b6d45b..a135234ee669 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -906,7 +906,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, } } - if ( ( ( rObjData.nSpFlags & SP_FFLIPV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) ) + if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) ) { SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj ); if (pCustomShape) @@ -916,7 +916,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, { // text is already rotated, we have to take back the object rotation if DFF_Prop_RotateText is false fExtraTextRotation = -mnFix16Angle; } - if ( rObjData.nSpFlags & SP_FFLIPV ) // sj: in ppt the text is flipped, whereas in word the text + if ( rObjData.nSpFlags & ShapeFlag::FlipV ) // sj: in ppt the text is flipped, whereas in word the text { // remains unchanged, so we have to take back the flipping here fExtraTextRotation += 18000.0; // because our core will flip text if the shape is flipped. } @@ -1058,7 +1058,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, // Only store objects which are not deep inside the tree if( ( rObjData.nCalledByGroup == 0 ) || - ( (rObjData.nSpFlags & SP_FGROUP) + ( (rObjData.nSpFlags & ShapeFlag::Group) && (rObjData.nCalledByGroup < 2) ) ) StoreShapeOrder( pImpRec->nShapeId, @@ -4260,7 +4260,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection, if (mrReader.m_xMSDffManager->GetShape(0x401, pObject, aData) && !aData.empty()) { // Only handle shape if it is a background shape - if (((*aData.begin())->nFlags & 0x400) != 0) + if (aData.begin()->get()->nFlags & ShapeFlag::Background) { SfxItemSet aSet(rFormat.GetAttrSet()); mrReader.MatchSdrItemsIntoFlySet(pObject, aSet, mso_lineSimple, -- cgit