From 80509545cc43893776dd24f441e9b95567ce06db Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 13 Dec 2015 16:59:16 +0000 Subject: hold WaterMarkLayout by reference Change-Id: I7dc7739ee7b958319ddd4e0cf262254728ef0569 --- lotuswordpro/source/filter/lwpframelayout.cxx | 15 ++++++++------- lotuswordpro/source/filter/lwplayout.cxx | 17 +++++++++-------- lotuswordpro/source/filter/lwplayout.hxx | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'lotuswordpro/source') diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx index b31791aca1aa..7312e81da5eb 100644 --- a/lotuswordpro/source/filter/lwpframelayout.cxx +++ b/lotuswordpro/source/filter/lwpframelayout.cxx @@ -272,7 +272,7 @@ void LwpFrame::ApplyWrapType(XFFrameStyle *pFrameStyle) case LwpPlacableLayout::LAY_NO_WRAP_AROUND: { eWrap = enumXFWrapRunThrough; - if(!m_pLayout->GetBackColor() && !m_pLayout->GetWaterMarkLayout()) + if(!m_pLayout->GetBackColor() && !m_pLayout->GetWaterMarkLayout().is()) { //pFrameStyle->SetBackGround(sal_True); XFColor aXFColor(0xffffff); //white color @@ -534,12 +534,13 @@ void LwpFrame::ApplyWatermark(XFFrameStyle *pFrameStyle) { pFrameStyle->SetBackImage(pBGImage); //set watermark transparent - LwpMiddleLayout* pLay = static_cast(m_pLayout->GetWaterMarkLayout()); - LwpBackgroundStuff* pBackgroundStuff = pLay->GetBackgroundStuff(); - if(pBackgroundStuff && !pBackgroundStuff->IsTransparent()) - { - pFrameStyle->SetTransparency(100); - } + rtl::Reference xWaterMarkLayout(m_pLayout->GetWaterMarkLayout()); + LwpMiddleLayout* pLay = dynamic_cast(xWaterMarkLayout.get()); + LwpBackgroundStuff* pBackgroundStuff = pLay ? pLay->GetBackgroundStuff() : nullptr; + if(pBackgroundStuff && !pBackgroundStuff->IsTransparent()) + { + pFrameStyle->SetTransparency(100); + } } } diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx index b8dd7fae8874..7eeeb51d9dc6 100644 --- a/lotuswordpro/source/filter/lwplayout.cxx +++ b/lotuswordpro/source/filter/lwplayout.cxx @@ -1357,18 +1357,18 @@ bool LwpMiddleLayout::IsProtected() * @descr: Get watermark layout * */ -LwpVirtualLayout* LwpMiddleLayout::GetWaterMarkLayout() +rtl::Reference LwpMiddleLayout::GetWaterMarkLayout() { - LwpVirtualLayout* pLay = dynamic_cast(GetChildHead().obj().get()); - while(pLay) + rtl::Reference xLay(dynamic_cast(GetChildHead().obj().get())); + while (xLay.is()) { - if( pLay->IsForWaterMark()) + if (xLay->IsForWaterMark()) { - return pLay; + return xLay; } - pLay = dynamic_cast (pLay->GetNext().obj().get()); + xLay.set(dynamic_cast(xLay->GetNext().obj().get())); } - return nullptr; + return rtl::Reference(); } /** @@ -1377,7 +1377,8 @@ LwpVirtualLayout* LwpMiddleLayout::GetWaterMarkLayout() */ XFBGImage* LwpMiddleLayout::GetXFBGImage() { - LwpMiddleLayout* pLay = static_cast(GetWaterMarkLayout()); + rtl::Reference xWaterMarkLayout(GetWaterMarkLayout()); + LwpMiddleLayout* pLay = dynamic_cast(xWaterMarkLayout.get()); if(pLay) { //test BGImage diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx index 92210294ca9f..5d115a67d4b6 100644 --- a/lotuswordpro/source/filter/lwplayout.hxx +++ b/lotuswordpro/source/filter/lwplayout.hxx @@ -322,7 +322,7 @@ public: virtual sal_uInt8 GetContentOrientation() override; virtual bool HonorProtection() override; virtual bool IsProtected() override; - LwpVirtualLayout* GetWaterMarkLayout(); + rtl::Reference GetWaterMarkLayout(); XFBGImage* GetXFBGImage(); bool GetUsePrinterSettings(); -- cgit