sw/source/core/text/itrform2.cxx | 8 - sw/source/core/text/porfly.cxx | 180 +++++++++++++++++++++------------------ sw/source/core/text/porfly.hxx | 38 +++++--- 3 files changed, 128 insertions(+), 98 deletions(-)
New commits: commit 65042d82a474fb6020add272cd7615517d606dc9 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Mon Dec 19 04:09:55 2016 +0100 dont encde typeinfo in bool members Change-Id: I5eeb566fd023d261d4236ec6de2b3f17e6744a07 Reviewed-on: https://gerrit.libreoffice.org/32147 Reviewed-by: Björn Michaelsen <bjoern.michael...@canonical.com> Tested-by: Björn Michaelsen <bjoern.michael...@canonical.com> diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index e03d118..1ff4763 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2476,7 +2476,6 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, SwTextAttr *pHint ) const { - SwFlyCntPortion *pRet = nullptr; const SwFrame *pFrame = static_cast<SwFrame*>(m_pFrame); SwFlyInContentFrame *pFly; @@ -2537,10 +2536,10 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, if ( GetInfo().GetTextFrame()->IsVertical() ) GetInfo().GetTextFrame()->SwitchHorizontalToVertical( aTmpBase ); + SwFlyCntPortion* pRet(nullptr); if( pFly ) { - pRet = new SwFlyCntPortion( *GetInfo().GetTextFrame(), pFly, aTmpBase, - nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode ); + pRet = SwFlyCntPortion::Create(*GetInfo().GetTextFrame(), pFly, aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode); // We need to make sure that our font is set again in the OutputDevice // It could be that the FlyInCnt was added anew and GetFlyFrame() would // in turn cause, that it'd be created anew again. @@ -2563,8 +2562,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, } else { - pRet = new SwFlyCntPortion( *rInf.GetTextFrame(), static_cast<SwDrawContact*>(pFrameFormat->FindContactObj()), - aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode ); + pRet = sw::DrawFlyCntPortion::Create(*rInf.GetTextFrame(), static_cast<SwDrawContact*>(pFrameFormat->FindContactObj()), aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode); } return pRet; } diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 1d35375..298f4ea 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -205,74 +205,92 @@ sal_Int32 SwTextFrame::CalcFlyPos( SwFrameFormat* pSearch ) void SwFlyCntPortion::Paint( const SwTextPaintInfo &rInf ) const { - if( bDraw ) - { - if( !static_cast<SwDrawContact*>(pContact)->GetAnchorFrame() ) - { - // No direct positioning of the drawing object is needed - SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pContact); - pDrawContact->ConnectToLayout(); - } - } - else - { - // Baseline output - // Re-paint everything at a CompletePaint call - SwRect aRepaintRect( rInf.GetPaintRect() ); + // Baseline output + // Re-paint everything at a CompletePaint call + SwRect aRepaintRect( rInf.GetPaintRect() ); - if ( rInf.GetTextFrame()->IsRightToLeft() ) - rInf.GetTextFrame()->SwitchLTRtoRTL( aRepaintRect ); + if ( rInf.GetTextFrame()->IsRightToLeft() ) + rInf.GetTextFrame()->SwitchLTRtoRTL( aRepaintRect ); - if ( rInf.GetTextFrame()->IsVertical() ) - rInf.GetTextFrame()->SwitchHorizontalToVertical( aRepaintRect ); + if ( rInf.GetTextFrame()->IsVertical() ) + rInf.GetTextFrame()->SwitchHorizontalToVertical( aRepaintRect ); - if( (GetFlyFrame()->IsCompletePaint() || - GetFlyFrame()->Frame().IsOver( aRepaintRect )) && - SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(GetFlyFrame()->GetVirtDrawObj()), - GetFlyFrame()->getRootFrame()->GetCurrShell() )) - { - SwRect aRect( GetFlyFrame()->Frame() ); - if( !GetFlyFrame()->IsCompletePaint() ) - aRect.Intersection_( aRepaintRect ); + if( (GetFlyFrame()->IsCompletePaint() || + GetFlyFrame()->Frame().IsOver( aRepaintRect )) && + SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(GetFlyFrame()->GetVirtDrawObj()), + GetFlyFrame()->getRootFrame()->GetCurrShell() )) + { + SwRect aRect( GetFlyFrame()->Frame() ); + if( !GetFlyFrame()->IsCompletePaint() ) + aRect.Intersection_( aRepaintRect ); - // GetFlyFrame() may change the layout mode at the output device. - { - SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); - GetFlyFrame()->Paint( const_cast<vcl::RenderContext&>(*rInf.GetOut()), aRect ); - } - ((SwTextPaintInfo&)rInf).GetRefDev()->SetLayoutMode( - rInf.GetOut()->GetLayoutMode() ); + // GetFlyFrame() may change the layout mode at the output device. + { + SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); + GetFlyFrame()->Paint( const_cast<vcl::RenderContext&>(*rInf.GetOut()), aRect ); + } + ((SwTextPaintInfo&)rInf).GetRefDev()->SetLayoutMode( + rInf.GetOut()->GetLayoutMode() ); - // As the OutputDevice might be anything, the font must be re-selected. - // Being in const method should not be a problem. - ((SwTextPaintInfo&)rInf).SelectFont(); + // As the OutputDevice might be anything, the font must be re-selected. + // Being in const method should not be a problem. + ((SwTextPaintInfo&)rInf).SelectFont(); - OSL_ENSURE( ! rInf.GetVsh() || rInf.GetVsh()->GetOut() == rInf.GetOut(), - "SwFlyCntPortion::Paint: Outdev has changed" ); - if( rInf.GetVsh() ) - ((SwTextPaintInfo&)rInf).SetOut( rInf.GetVsh()->GetOut() ); - } + OSL_ENSURE( ! rInf.GetVsh() || rInf.GetVsh()->GetOut() == rInf.GetOut(), + "SwFlyCntPortion::Paint: Outdev has changed" ); + if( rInf.GetVsh() ) + ((SwTextPaintInfo&)rInf).SetOut( rInf.GetVsh()->GetOut() ); + } +} +void sw::DrawFlyCntPortion::Paint(const SwTextPaintInfo&) const +{ + if(!static_cast<SwDrawContact*>(pContact)->GetAnchorFrame()) + { + // No direct positioning of the drawing object is needed + SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pContact); + pDrawContact->ConnectToLayout(); } } /** * Use the dimensions of pFly->OutRect() */ -SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame, - SwFlyInContentFrame *pFly, const Point &rBase, - long nLnAscent, long nLnDescent, - long nFlyAsc, long nFlyDesc, - AsCharFlags nFlags ) : - pContact( pFly ), - bDraw( false ), - bMax( false ), - nAlign( 0 ) +SwFlyCntPortion::SwFlyCntPortion(SwFlyInContentFrame* pFly) + : pContact(pFly) + , bMax(false) + , nAlign(0) { - OSL_ENSURE( pFly, "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!" ); + SAL_WARN_IF(!pFly, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!"); nLineLength = 1; - nFlags |= AsCharFlags::UlSpace | AsCharFlags::Init; - SetBase( rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags ); - SetWhichPor( POR_FLYCNT ); + SetWhichPor(POR_FLYCNT); +} + +sw::DrawFlyCntPortion::DrawFlyCntPortion(SwDrawContact* pDrawContact) + : SwFlyCntPortion((SwFlyInContentFrame*) pDrawContact) +{ + SAL_WARN_IF(!pDrawContact, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwDrawContact!"); + if(!pDrawContact->GetAnchorFrame()) + { + // No direct positioning needed any more + pDrawContact->ConnectToLayout(); + // Move object to visible layer + pDrawContact->MoveObjToVisibleLayer(pDrawContact->GetMaster()); + } + +} + +SwFlyCntPortion* SwFlyCntPortion::Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags) +{ + auto pNew(new SwFlyCntPortion(pFly)); + pNew->SetBase(rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags | AsCharFlags::UlSpace | AsCharFlags::Init); + return pNew; +} + +sw::DrawFlyCntPortion* sw::DrawFlyCntPortion::Create(const SwTextFrame& rFrame, SwDrawContact* pDrawContact, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags) +{ + auto pNew(new DrawFlyCntPortion(pDrawContact)); + pNew->SetBase(rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags | AsCharFlags::UlSpace | AsCharFlags::Init); + return pNew; } SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame, @@ -281,11 +299,9 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags ) : pContact( pDrawContact ), - bDraw( true ), bMax( false ), nAlign( 0 ) { - OSL_ENSURE( pDrawContact, "SwFlyCntPortion::SwFlyCntPortion: no SwDrawContact!" ); if( !pDrawContact->GetAnchorFrame() ) { // No direct positioning needed any more @@ -302,6 +318,33 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame, SetWhichPor( POR_FLYCNT ); } +SwFlyCntPortion::~SwFlyCntPortion() {}; + +sw::DrawFlyCntPortion::~DrawFlyCntPortion() {}; + +SdrObject* SwFlyCntPortion::GetSdrObj(const SwTextFrame&) +{ + return GetFlyFrame()->GetVirtDrawObj(); +} + +SdrObject* sw::DrawFlyCntPortion::GetSdrObj(const SwTextFrame& rFrame) +{ + SdrObject* pSdrObj; + // Determine drawing object ('master' or 'virtual') by frame + pSdrObj = GetDrawContact()->GetDrawObjectByAnchorFrame(rFrame); + if(!pSdrObj) + { + SAL_WARN("sw.core", "SwFlyCntPortion::SetBase(..) - No drawing object found by <GetDrawContact()->GetDrawObjectByAnchorFrame( rFrame )>"); + pSdrObj = GetDrawContact()->GetMaster(); + } + + // Call <SwAnchoredDrawObject::MakeObjPos()> to assure that flag at + // the <DrawFrameFormat> and at the <SwAnchoredDrawObject> instance are + // correctly set + if(pSdrObj) + GetDrawContact()->GetAnchoredObj(pSdrObj)->MakeObjPos(); + return pSdrObj; +} /** * After setting the RefPoints, the ascent needs to be recalculated * because it is dependent on RelPos @@ -315,30 +358,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase, { // Use new class to position object // Determine drawing object - SdrObject* pSdrObj = nullptr; - if( bDraw ) - { - // Determine drawing object ('master' or 'virtual') by frame - pSdrObj = GetDrawContact()->GetDrawObjectByAnchorFrame( rFrame ); - if ( !pSdrObj ) - { - OSL_FAIL( "SwFlyCntPortion::SetBase(..) - No drawing object found by <GetDrawContact()->GetDrawObjectByAnchorFrame( rFrame )>" ); - pSdrObj = GetDrawContact()->GetMaster(); - } - - // Call <SwAnchoredDrawObject::MakeObjPos()> to assure that flag at - // the <DrawFrameFormat> and at the <SwAnchoredDrawObject> instance are - // correctly set - if ( pSdrObj ) - { - GetDrawContact()->GetAnchoredObj( pSdrObj )->MakeObjPos(); - } - } - else - { - pSdrObj = GetFlyFrame()->GetVirtDrawObj(); - } - + SdrObject* pSdrObj = GetSdrObj(rFrame); if (!pSdrObj) return; diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx index 67e29f1..28749ea 100644 --- a/sw/source/core/text/porfly.hxx +++ b/sw/source/core/text/porfly.hxx @@ -44,23 +44,23 @@ public: /// This portion represents an as-character anchored fly (shape, frame, etc.) class SwFlyCntPortion : public SwLinePortion { +protected: + void *pContact; // bDraw ? DrawContact : FlyInContentFrame Point aRef; // Relatively to this point we calculate the AbsPos - bool bDraw : 1; // DrawContact? bool bMax : 1; // Line adjustment and height == line height sal_uInt8 nAlign : 3; // Line adjustment? No, above, middle, bottom -public: - // Use new datatype for parameter <nFlags> - SwFlyCntPortion( const SwTextFrame& rFrame, SwFlyInContentFrame *pFly, - const Point &rBase, - long nAscent, long nDescent, long nFlyAsc, long nFlyDesc, - AsCharFlags nFlags ); // Use new datatype for parameter <nFlags> SwFlyCntPortion( const SwTextFrame& rFrame, SwDrawContact *pDrawContact, const Point &rBase, long nAscent, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags ); + virtual SdrObject* GetSdrObj(const SwTextFrame&); + +public: + SwFlyCntPortion(SwFlyInContentFrame* pFly); + static SwFlyCntPortion* Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nAscent, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags); inline const Point& GetRefPoint() const { return aRef; } inline SwFlyInContentFrame *GetFlyFrame() { return static_cast<SwFlyInContentFrame*>(pContact); } inline const SwFlyInContentFrame *GetFlyFrame() const @@ -68,22 +68,34 @@ public: inline SwDrawContact *GetDrawContact() { return static_cast<SwDrawContact*>(pContact); } inline const SwDrawContact* GetDrawContact() const { return static_cast<SwDrawContact*>(pContact); } - inline bool IsDraw() const { return bDraw; } + virtual bool IsDraw() const { return false; } inline bool IsMax() const { return bMax; } inline sal_uInt8 GetAlign() const { return nAlign; } inline void SetAlign( sal_uInt8 nNew ) { nAlign = nNew; } inline void SetMax( bool bNew ) { bMax = bNew; } - // Use new datatype for parameter <nFlags> - void SetBase( const SwTextFrame& rFrame, const Point &rBase, - long nLnAscent, long nLnDescent, - long nFlyAscent, long nFlyDescent, - AsCharFlags nFlags ); + void SetBase(const SwTextFrame& rFrame, const Point &rBase, long nLnAscent, long nLnDescent, long nFlyAscent, long nFlyDescent, AsCharFlags nFlags); void GetFlyCursorOfst(Point &rPoint, SwPosition& rPos, SwCursorMoveState* pCMS) const; virtual bool Format( SwTextFormatInfo &rInf ) override; virtual void Paint( const SwTextPaintInfo &rInf ) const override; OUTPUT_OPERATOR_OVERRIDE + virtual ~SwFlyCntPortion(); }; +namespace sw +{ + class DrawFlyCntPortion : public SwFlyCntPortion + { + protected: + virtual SdrObject* GetSdrObj(const SwTextFrame&) override; + public: + DrawFlyCntPortion(SwDrawContact* pDrawContact); + static DrawFlyCntPortion* Create(const SwTextFrame& rFrame, SwDrawContact* pDrawContact, const Point& rBase, long nAsc, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags); + virtual bool IsDraw() const { return true; } + virtual void Paint( const SwTextPaintInfo &rInf ) const override; + virtual ~DrawFlyCntPortion(); + }; +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits