Kaydet (Commit) 9550737e authored tarafından Caolán McNamara's avatar Caolán McNamara

need more References for life cycle fixes here

32nd and final distinct crash fix of this sequence

Change-Id: Ib9f41091737e66995f332c06083d51408eb1497b
üst 76d3e871
...@@ -187,35 +187,35 @@ void LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle) ...@@ -187,35 +187,35 @@ void LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle)
void LwpFrame::XFConvert(XFContentContainer* pCont) void LwpFrame::XFConvert(XFContentContainer* pCont)
{ {
// parse the frame which anchor to page // parse the frame which anchor to page
LwpVirtualLayout* pParent = m_pLayout->GetParentLayout(); rtl::Reference<LwpVirtualLayout> xParent = m_pLayout->GetParentLayout();
if (!pParent) if (!xParent.is())
throw std::runtime_error("missing Parent Layout"); throw std::runtime_error("missing Parent Layout");
if (pParent->IsPage() && pParent->GetParentLayout() && pParent->GetParentLayout()->IsPage()) if (xParent->IsPage() && xParent->GetParentLayout().is() && xParent->GetParentLayout()->IsPage())
{ {
//for mirror page, problems exist if the parent layout is header or footer layout, //for mirror page, problems exist if the parent layout is header or footer layout,
pParent = pParent->GetParentLayout(); xParent = xParent->GetParentLayout();
} }
if(m_pLayout->IsAnchorPage()&& pParent->IsPage()) if(m_pLayout->IsAnchorPage()&& xParent->IsPage())
{ {
//get parent layout //get parent layout
if(m_pLayout->IsUseOnPage()) if(m_pLayout->IsUseOnPage())
{ {
sal_Int32 nPageNo = pParent->GetPageNumber(m_pLayout->GetUsePage()); sal_Int32 nPageNo = xParent->GetPageNumber(m_pLayout->GetUsePage());
if(nPageNo>0) if(nPageNo>0)
m_pLayout->XFConvertFrame(pCont, nPageNo); m_pLayout->XFConvertFrame(pCont, nPageNo);
} }
else if(m_pLayout->IsUseOnAllPages()) else if(m_pLayout->IsUseOnAllPages())
{ {
sal_Int32 nFirst = pParent->GetPageNumber(FIRST_LAYOUTPAGENO); sal_Int32 nFirst = xParent->GetPageNumber(FIRST_LAYOUTPAGENO);
sal_Int32 nLast = pParent->GetPageNumber(LAST_LAYOUTPAGENO); sal_Int32 nLast = xParent->GetPageNumber(LAST_LAYOUTPAGENO);
if(nLast > 0) if(nLast > 0)
m_pLayout->XFConvertFrame(pCont, nFirst, nLast, true); m_pLayout->XFConvertFrame(pCont, nFirst, nLast, true);
} }
else if(m_pLayout->IsUseOnAllOddPages()||m_pLayout->IsUseOnAllEvenPages()) else if(m_pLayout->IsUseOnAllOddPages()||m_pLayout->IsUseOnAllEvenPages())
{ {
sal_Int32 nFirst = pParent->GetPageNumber(FIRST_LAYOUTPAGENO); sal_Int32 nFirst = xParent->GetPageNumber(FIRST_LAYOUTPAGENO);
sal_Int32 nLast = pParent->GetPageNumber(LAST_LAYOUTPAGENO); sal_Int32 nLast = xParent->GetPageNumber(LAST_LAYOUTPAGENO);
if(nLast > 0) if(nLast > 0)
{ {
sal_uInt16 first = static_cast<sal_uInt16>(nFirst); sal_uInt16 first = static_cast<sal_uInt16>(nFirst);
...@@ -254,7 +254,8 @@ void LwpFrame::ApplyWrapType(XFFrameStyle *pFrameStyle) ...@@ -254,7 +254,8 @@ void LwpFrame::ApplyWrapType(XFFrameStyle *pFrameStyle)
//between the frame object and page margins //between the frame object and page margins
eWrap = enumXFWrapBest; eWrap = enumXFWrapBest;
LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout()); rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
LwpMiddleLayout* pParent = dynamic_cast<LwpMiddleLayout*>(xContainer.get());
if(pParent) if(pParent)
{ {
if(IsLeftWider()) if(IsLeftWider())
...@@ -434,8 +435,8 @@ void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle) ...@@ -434,8 +435,8 @@ void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle)
//set vertical position //set vertical position
if(m_pLayout->IsAnchorPage())//in page if(m_pLayout->IsAnchorPage())//in page
{ {
LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout(); rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter())) if (xContainer.is() && (xContainer->IsHeader() || xContainer->IsFooter()))
{ {
//Only anchor to para, the frame can display in header and footer of each page //Only anchor to para, the frame can display in header and footer of each page
eYPos = enumXFFrameYPosFromTop; //from top eYPos = enumXFFrameYPosFromTop; //from top
...@@ -465,15 +466,15 @@ void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle) ...@@ -465,15 +466,15 @@ void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle)
eXPos = enumXFFrameXPosFromLeft; eXPos = enumXFFrameXPosFromLeft;
eXRel = enumXFFrameXRelPage; eXRel = enumXFFrameXRelPage;
//set vertical position //set vertical position
LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout(); rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
if(pContainer && pContainer->IsPage())//in page if (xContainer.is() && xContainer->IsPage())//in page
{ {
//eYPos = enumXFFrameYPosFromTop; //eYPos = enumXFFrameYPosFromTop;
//eYRel = enumXFFrameYRelPage; //eYRel = enumXFFrameYRelPage;
eYPos = enumXFFrameYPosBelow; eYPos = enumXFFrameYPosBelow;
eYRel = enumXFFrameYRelChar; eYRel = enumXFFrameYRelChar;
} }
else if(pContainer && pContainer->IsFrame()) //in frame else if (xContainer.is() && xContainer->IsFrame()) //in frame
{ {
eYPos = enumXFFrameYPosFromTop; eYPos = enumXFFrameYPosFromTop;
eYRel = enumXFFrameYRelPage; eYRel = enumXFFrameYRelPage;
...@@ -613,11 +614,11 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame) ...@@ -613,11 +614,11 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
//anchor to page, frame and cell //anchor to page, frame and cell
if(m_pLayout->IsAnchorPage())//in page if(m_pLayout->IsAnchorPage())//in page
{ {
LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout(); rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter())) if (xContainer.is() && (xContainer->IsHeader() || xContainer->IsFooter()))
{ {
eAnchor = enumXFAnchorPara; eAnchor = enumXFAnchorPara;
fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP); fYOffset -= xContainer->GetMarginsValue(MARGIN_TOP);
} }
else else
eAnchor = enumXFAnchorPage; eAnchor = enumXFAnchorPage;
...@@ -630,8 +631,9 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame) ...@@ -630,8 +631,9 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
{ {
//eAnchor = enumXFAnchorChar; //eAnchor = enumXFAnchorChar;
eAnchor = enumXFAnchorPara; eAnchor = enumXFAnchorPara;
LwpMiddleLayout* pContainer = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout()); rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
if(pContainer) LwpMiddleLayout* pContainer = dynamic_cast<LwpMiddleLayout*>(xContainer.get());
if (pContainer)
{ {
fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP); fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
} }
...@@ -641,26 +643,26 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame) ...@@ -641,26 +643,26 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE: //same page as text case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE: //same page as text
{ {
eAnchor = enumXFAnchorChar; eAnchor = enumXFAnchorChar;
LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout(); rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
if(pContainer && pContainer->IsPage())//in page if (xContainer.is() && xContainer->IsPage())//in page
{ {
//eAnchor = enumXFAnchorPage; //eAnchor = enumXFAnchorPage;
eAnchor = enumXFAnchorChar;// to character eAnchor = enumXFAnchorChar;// to character
} }
else if(pContainer && pContainer->IsFrame()) //in frame else if (xContainer.is() && xContainer->IsFrame()) //in frame
{ {
eAnchor = enumXFAnchorFrame; eAnchor = enumXFAnchorFrame;
} }
else if(pContainer && pContainer->IsCell()) //in cell else if (xContainer.is() && xContainer->IsCell()) //in cell
{ {
//eAnchor = enumXFAnchorChar; //eAnchor = enumXFAnchorChar;
eAnchor = enumXFAnchorPara; eAnchor = enumXFAnchorPara;
fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP); fYOffset -= xContainer->GetMarginsValue(MARGIN_TOP);
} }
else if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))//in header or footer else if (xContainer.is() && (xContainer->IsHeader() || xContainer->IsFooter()))//in header or footer
{ {
eAnchor = enumXFAnchorPara; eAnchor = enumXFAnchorPara;
fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP); fYOffset -= xContainer->GetMarginsValue(MARGIN_TOP);
} }
break; break;
} }
...@@ -712,9 +714,9 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame) ...@@ -712,9 +714,9 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
*/ */
bool LwpFrame::IsLeftWider() bool LwpFrame::IsLeftWider()
{ {
//LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout()); rtl::Reference<LwpVirtualLayout> xLayout(m_pLayout->GetContainerLayout());
LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*>(m_pLayout->GetContainerLayout()); LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*>(xLayout.get());
if(pParent) if (pParent)
{ {
LwpPoint aPoint = m_pLayout->GetOrigin(); LwpPoint aPoint = m_pLayout->GetOrigin();
double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX()); double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
...@@ -945,8 +947,9 @@ double LwpFrameLayout::GetWidth() ...@@ -945,8 +947,9 @@ double LwpFrameLayout::GetWidth()
double LwpFrameLayout::GetMaxWidth() double LwpFrameLayout::GetMaxWidth()
{ {
double fActualWidth = 0; double fActualWidth = 0;
LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(GetContainerLayout()); rtl::Reference<LwpVirtualLayout> xLayout(GetContainerLayout());
if(pParent) LwpMiddleLayout* pParent = dynamic_cast<LwpMiddleLayout*>(xLayout.get());
if (pParent)
{ {
LwpPoint aPoint = GetOrigin(); LwpPoint aPoint = GetOrigin();
double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX()); double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
......
...@@ -150,13 +150,13 @@ void LwpFribFrame::XFConvert(XFContentContainer* pCont) ...@@ -150,13 +150,13 @@ void LwpFribFrame::XFConvert(XFContentContainer* pCont)
sal_uInt8 nType = pLayout->GetRelativeType(); sal_uInt8 nType = pLayout->GetRelativeType();
if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType) if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
{ {
LwpVirtualLayout* pContainerLayout = pLayout->GetContainerLayout(); rtl::Reference<LwpVirtualLayout> xContainerLayout(pLayout->GetContainerLayout());
if(pContainerLayout && pContainerLayout->IsFrame()) if (xContainerLayout.is() && xContainerLayout->IsFrame())
{ {
//same page as text and in frame //same page as text and in frame
pXFContentContainer = m_pPara->GetXFContainer(); pXFContentContainer = m_pPara->GetXFContainer();
} }
else if(pContainerLayout && pContainerLayout->IsCell()) else if (xContainerLayout.is() && xContainerLayout->IsCell())
{ {
//same page as text and in cell, get the first xfpara //same page as text and in cell, get the first xfpara
rtl::Reference<XFContent> first( rtl::Reference<XFContent> first(
......
...@@ -102,11 +102,11 @@ void LwpFribTable::XFConvert(XFContentContainer* pCont) ...@@ -102,11 +102,11 @@ void LwpFribTable::XFConvert(XFContentContainer* pCont)
if (!pSuper) if (!pSuper)
return; return;
sal_uInt8 nType = pSuper->GetRelativeType(); sal_uInt8 nType = pSuper->GetRelativeType();
LwpVirtualLayout* pContainer = pSuper->GetContainerLayout(); rtl::Reference<LwpVirtualLayout> xContainer(pSuper->GetContainerLayout());
if (!pContainer) if (!xContainer.is())
return; return;
if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
&& !pContainer->IsCell()) && !xContainer->IsCell())
{ {
pXFContentContainer = m_pPara->GetXFContainer(); pXFContentContainer = m_pPara->GetXFContainer();
//delete the additional blank para //delete the additional blank para
...@@ -122,11 +122,11 @@ void LwpFribTable::XFConvert(XFContentContainer* pCont) ...@@ -122,11 +122,11 @@ void LwpFribTable::XFConvert(XFContentContainer* pCont)
else if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType) else if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
{ {
//same page as text and in frame //same page as text and in frame
if(pContainer->IsFrame()) if (xContainer->IsFrame())
{ {
pXFContentContainer = m_pPara->GetXFContainer(); pXFContentContainer = m_pPara->GetXFContainer();
} }
else if(pContainer->IsCell()) else if (xContainer->IsCell())
{ {
//same page as text and in cell, get the first xfpara //same page as text and in cell, get the first xfpara
rtl::Reference<XFContent> first( rtl::Reference<XFContent> first(
......
...@@ -141,10 +141,10 @@ bool LwpVirtualLayout::HonorProtection() ...@@ -141,10 +141,10 @@ bool LwpVirtualLayout::HonorProtection()
if(!(m_nAttributes2 & STYLE2_HONORPROTECTION)) if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
return false; return false;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if (pParent && !pParent->IsHeader()) if (xParent.is() && !xParent->IsHeader())
{ {
return pParent->GetHonorProtection(); return xParent->GetHonorProtection();
} }
if(m_pFoundry)//is null now if(m_pFoundry)//is null now
...@@ -165,10 +165,10 @@ bool LwpVirtualLayout::IsProtected() ...@@ -165,10 +165,10 @@ bool LwpVirtualLayout::IsProtected()
{ {
bool bProtected = (m_nAttributes & STYLE_PROTECTED)!=0; bool bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if(pParent && !pParent->IsHeader()) if (xParent.is() && !xParent->IsHeader())
{ {
if(pParent->GetHonorProtection()&&(pParent->GetHasProtection()||bProtected)) if (xParent->GetHonorProtection() && (xParent->GetHasProtection()||bProtected))
{ {
return true; return true;
} }
...@@ -197,10 +197,10 @@ bool LwpVirtualLayout::HasProtection() ...@@ -197,10 +197,10 @@ bool LwpVirtualLayout::HasProtection()
if(m_nAttributes & STYLE_PROTECTED) if(m_nAttributes & STYLE_PROTECTED)
return true; return true;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if (pParent && !pParent->IsHeader()) if (xParent.is() && !xParent->IsHeader())
{ {
return pParent->GetHasProtection(); return xParent->GetHasProtection();
} }
return false; return false;
...@@ -228,9 +228,9 @@ LwpUseWhen* LwpVirtualLayout::GetUseWhen() ...@@ -228,9 +228,9 @@ LwpUseWhen* LwpVirtualLayout::GetUseWhen()
if(GetLayoutType()!=LWP_PAGE_LAYOUT) if(GetLayoutType()!=LWP_PAGE_LAYOUT)
{ {
//get parent //get parent
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if(pParent && !pParent->IsHeader()&& (pParent->GetLayoutType()!=LWP_PAGE_LAYOUT)) if (xParent.is() && !xParent->IsHeader() && (xParent->GetLayoutType() != LWP_PAGE_LAYOUT))
return pParent->GetUseWhen(); return xParent->GetUseWhen();
} }
...@@ -318,9 +318,9 @@ bool LwpVirtualLayout::IsMinimumHeight() ...@@ -318,9 +318,9 @@ bool LwpVirtualLayout::IsMinimumHeight()
* @descr: Get parent layout * @descr: Get parent layout
* *
*/ */
LwpVirtualLayout* LwpVirtualLayout::GetParentLayout() rtl::Reference<LwpVirtualLayout> LwpVirtualLayout::GetParentLayout()
{ {
return dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); return rtl::Reference<LwpVirtualLayout>(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
} }
/** /**
...@@ -349,9 +349,9 @@ bool LwpVirtualLayout::IsStyleLayout() ...@@ -349,9 +349,9 @@ bool LwpVirtualLayout::IsStyleLayout()
if (m_nAttributes3 & STYLE3_STYLELAYOUT) if (m_nAttributes3 & STYLE3_STYLELAYOUT)
return true; return true;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if (pParent) if (xParent.is())
return pParent->IsStyleLayout(); return xParent->IsStyleLayout();
return false; return false;
} }
...@@ -712,10 +712,10 @@ double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide) ...@@ -712,10 +712,10 @@ double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide)
{ {
if ( MarginsSameAsParent() ) if ( MarginsSameAsParent() )
{ {
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if(pParent && !pParent->IsHeader()) if (xParent.is() && !xParent->IsHeader())
{ {
fValue = pParent->GetMarginsValue(nWhichSide); fValue = xParent->GetMarginsValue(nWhichSide);
return fValue; return fValue;
} }
} }
...@@ -1274,16 +1274,16 @@ bool LwpMiddleLayout::HonorProtection() ...@@ -1274,16 +1274,16 @@ bool LwpMiddleLayout::HonorProtection()
if(!(m_nAttributes2 & STYLE2_HONORPROTECTION)) if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
return false; return false;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if (pParent && !pParent->IsHeader()) if (xParent.is() && !xParent->IsHeader())
{ {
return pParent->GetHonorProtection(); return xParent->GetHonorProtection();
} }
if(m_pFoundry)//is null now if(m_pFoundry)//is null now
{ {
LwpDocument* pDoc = m_pFoundry->GetDocument(); LwpDocument* pDoc = m_pFoundry->GetDocument();
if(pDoc) if (pDoc)
{ {
return pDoc->GetHonorProtection(); return pDoc->GetHonorProtection();
} }
...@@ -1323,14 +1323,14 @@ bool LwpMiddleLayout::IsProtected() ...@@ -1323,14 +1323,14 @@ bool LwpMiddleLayout::IsProtected()
bProtected = LwpVirtualLayout::IsProtected(); bProtected = LwpVirtualLayout::IsProtected();
} }
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
if(pParent && !pParent->IsHeader()) if (xParent.is() && !xParent->IsHeader())
{ {
/* If a parent's protected then none of its children can be accessed. */ /* If a parent's protected then none of its children can be accessed. */
if(pParent->GetIsProtected()) if (xParent->GetIsProtected())
return true; return true;
if(pParent->GetHonorProtection()) if (xParent->GetHonorProtection())
return bProtected; return bProtected;
/* If our parent isn't honoring protection then we aren't protected. */ /* If our parent isn't honoring protection then we aren't protected. */
...@@ -1928,7 +1928,7 @@ XFShadow* LwpLayout::GetXFShadow() ...@@ -1928,7 +1928,7 @@ XFShadow* LwpLayout::GetXFShadow()
* @descr get the layout that containers the current frame layout * @descr get the layout that containers the current frame layout
* *
*/ */
LwpVirtualLayout* LwpLayout::GetContainerLayout() rtl::Reference<LwpVirtualLayout> LwpLayout::GetContainerLayout()
{ {
if(IsRelativeAnchored()) if(IsRelativeAnchored())
{ {
...@@ -2091,9 +2091,8 @@ bool LwpPlacableLayout::IsAnchorPage() ...@@ -2091,9 +2091,8 @@ bool LwpPlacableLayout::IsAnchorPage()
if(IsRelativeAnchored()) if(IsRelativeAnchored())
return false; return false;
LwpVirtualLayout* pLayout = GetParentLayout(); rtl::Reference<LwpVirtualLayout> xLayout = GetParentLayout();
if(pLayout && (pLayout->IsPage() || pLayout->IsHeader() || pLayout->IsFooter())) if (xLayout.is() && (xLayout->IsPage() || xLayout->IsHeader() || xLayout->IsFooter()))
//if(pLayout && pLayout->IsPage())
{ {
return true; return true;
} }
...@@ -2108,8 +2107,8 @@ bool LwpPlacableLayout::IsAnchorFrame() ...@@ -2108,8 +2107,8 @@ bool LwpPlacableLayout::IsAnchorFrame()
if(IsRelativeAnchored()) if(IsRelativeAnchored())
return false; return false;
LwpVirtualLayout* pLayout = GetParentLayout(); rtl::Reference<LwpVirtualLayout> xLayout = GetParentLayout();
if(pLayout && (pLayout->IsFrame()||pLayout->IsGroupHead())) if (xLayout.is() && (xLayout->IsFrame() || xLayout->IsGroupHead()))
{ {
return true; return true;
} }
...@@ -2124,8 +2123,8 @@ bool LwpPlacableLayout::IsAnchorCell() ...@@ -2124,8 +2123,8 @@ bool LwpPlacableLayout::IsAnchorCell()
if(IsRelativeAnchored()) if(IsRelativeAnchored())
return false; return false;
LwpVirtualLayout* pLayout = GetParentLayout(); rtl::Reference<LwpVirtualLayout> xLayout = GetParentLayout();
if(pLayout && pLayout->IsCell()) if (xLayout.is() && xLayout->IsCell())
{ {
return true; return true;
} }
......
...@@ -162,8 +162,8 @@ public: ...@@ -162,8 +162,8 @@ public:
bool IsMinimumHeight(); bool IsMinimumHeight();
virtual bool IsForWaterMark(){ return false;} virtual bool IsForWaterMark(){ return false;}
virtual LwpPara* GetLastParaOfPreviousStory() { return nullptr; } virtual LwpPara* GetLastParaOfPreviousStory() { return nullptr; }
LwpVirtualLayout* GetParentLayout(); rtl::Reference<LwpVirtualLayout> GetParentLayout();
virtual LwpVirtualLayout* GetContainerLayout(){ return nullptr;} virtual rtl::Reference<LwpVirtualLayout> GetContainerLayout() { return rtl::Reference<LwpVirtualLayout>(); }
void RegisterChildStyle(); void RegisterChildStyle();
bool NoContentReference(); bool NoContentReference();
bool IsStyleLayout(); bool IsStyleLayout();
...@@ -418,7 +418,7 @@ public: ...@@ -418,7 +418,7 @@ public:
virtual bool IsUseOnAllOddPages() override; virtual bool IsUseOnAllOddPages() override;
virtual bool IsUseOnPage() override; virtual bool IsUseOnPage() override;
LwpObjectID& GetPosition(){ return m_Positon;} LwpObjectID& GetPosition(){ return m_Positon;}
virtual LwpVirtualLayout* GetContainerLayout() override; virtual rtl::Reference<LwpVirtualLayout> GetContainerLayout() override;
}; };
class LwpPlacableLayout : public LwpLayout class LwpPlacableLayout : public LwpLayout
......
...@@ -205,8 +205,8 @@ void LwpStory::SortPageLayout() ...@@ -205,8 +205,8 @@ void LwpStory::SortPageLayout()
{ {
LwpLayout::UseWhenType eSectionType = static_cast<LwpPageLayout*>(xLayout.get())->GetUseWhenType(); LwpLayout::UseWhenType eSectionType = static_cast<LwpPageLayout*>(xLayout.get())->GetUseWhenType();
//for mirror page, the child is pagelayout //for mirror page, the child is pagelayout
LwpVirtualLayout* pParent = xLayout->GetParentLayout(); rtl::Reference<LwpVirtualLayout> xParent = xLayout->GetParentLayout();
if(eSectionType != LwpLayout::StartWithinColume && pParent && !pParent->IsPage()) if(eSectionType != LwpLayout::StartWithinColume && xParent.is() && !xParent->IsPage())
{ {
aLayoutList.push_back(static_cast<LwpPageLayout*>(xLayout.get())); aLayoutList.push_back(static_cast<LwpPageLayout*>(xLayout.get()));
} }
......
...@@ -352,7 +352,7 @@ void LwpSuperTableLayout::ApplyAlignment(XFTableStyle * pTableStyle) ...@@ -352,7 +352,7 @@ void LwpSuperTableLayout::ApplyAlignment(XFTableStyle * pTableStyle)
void LwpSuperTableLayout::XFConvert(XFContentContainer* pCont) void LwpSuperTableLayout::XFConvert(XFContentContainer* pCont)
{ {
if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == GetRelativeType() if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == GetRelativeType()
&& (!GetContainerLayout() || !GetContainerLayout()->IsCell()) ) && (!GetContainerLayout().is() || !GetContainerLayout()->IsCell()) )
{ {
LwpTableLayout * pTableLayout = GetTableLayout(); LwpTableLayout * pTableLayout = GetTableLayout();
if (pTableLayout) if (pTableLayout)
...@@ -720,7 +720,7 @@ void LwpTableLayout::RegisterStyle() ...@@ -720,7 +720,7 @@ void LwpTableLayout::RegisterStyle()
// If the table is not "with paragraph above" placement, create an frame style // If the table is not "with paragraph above" placement, create an frame style
// by supertable layout // by supertable layout
if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
&& (!pSuper->GetContainerLayout() || !pSuper->GetContainerLayout()->IsCell()) ) && (!pSuper->GetContainerLayout().is() || !pSuper->GetContainerLayout()->IsCell()) )
{ {
//with para above //with para above
// pSuper->ApplyBackColor(pTableStyle); // pSuper->ApplyBackColor(pTableStyle);
......
...@@ -243,11 +243,12 @@ void LwpTocSuperLayout::XFConvert(XFContentContainer* pCont) ...@@ -243,11 +243,12 @@ void LwpTocSuperLayout::XFConvert(XFContentContainer* pCont)
// add TOC content // add TOC content
LwpSuperTableLayout::XFConvert(pToc); LwpSuperTableLayout::XFConvert(pToc);
if (!GetContainerLayout()) rtl::Reference<LwpVirtualLayout> xContainer(GetContainerLayout());
if (!xContainer.is())
return; return;
// if current TOC is located in a cell, we must add a frame between upper level container and TOC // if current TOC is located in a cell, we must add a frame between upper level container and TOC
if ( !GetContainerLayout()->IsCell() ) if (!xContainer->IsCell())
{ {
pCont->Add(pToc); pCont->Add(pToc);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment