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

use more references to fix life cycles

Change-Id: I0c903533542608c1d7a3c97e2be7f2b7624b265b
üst ad23fb09
...@@ -327,7 +327,7 @@ XFCell* LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uI ...@@ -327,7 +327,7 @@ XFCell* LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uI
// we should adjust its style by current position // we should adjust its style by current position
if (pTable->GetDefaultCellStyle() == GetObjectID()) if (pTable->GetDefaultCellStyle() == GetObjectID())
{ {
aStyleName = GetCellStyleName(nRow, nCol, pTable->GetTableLayout()); aStyleName = GetCellStyleName(nRow, nCol, pTable->GetTableLayout().get());
} }
// content of cell // content of cell
...@@ -661,8 +661,8 @@ void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID) ...@@ -661,8 +661,8 @@ void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
{ {
// judge whole table // judge whole table
LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get()); LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
LwpTableLayout * pTableLayout = pTable ? dynamic_cast<LwpTableLayout *>(pTable->GetTableLayout()) : nullptr; rtl::Reference<LwpTableLayout> xTableLayout(pTable ? pTable->GetTableLayout() : nullptr);
LwpSuperTableLayout * pSuper = pTableLayout ? pTableLayout->GetSuperTableLayout() : nullptr; LwpSuperTableLayout * pSuper = xTableLayout.is() ? xTableLayout->GetSuperTableLayout() : nullptr;
if (pSuper && pSuper->GetIsProtected()) if (pSuper && pSuper->GetIsProtected())
{ {
bProtected = true; bProtected = true;
......
...@@ -121,17 +121,20 @@ void LwpContent::Read() ...@@ -121,17 +121,20 @@ void LwpContent::Read()
pStrm->SkipExtra(); pStrm->SkipExtra();
} }
LwpVirtualLayout* LwpContent::GetLayout(LwpVirtualLayout* pStartLayout) rtl::Reference<LwpVirtualLayout> LwpContent::GetLayout(LwpVirtualLayout* pStartLayout)
{ {
return m_LayoutsWithMe.GetLayout(pStartLayout); return m_LayoutsWithMe.GetLayout(pStartLayout);
} }
bool LwpContent::HasNonEmbeddedLayouts() bool LwpContent::HasNonEmbeddedLayouts()
{ {
LwpVirtualLayout* pLayout = nullptr; rtl::Reference<LwpVirtualLayout> xLayout;
while( (pLayout = GetLayout(pLayout)) ) while (1)
{ {
if(!pLayout->NoContentReference()) xLayout = GetLayout(xLayout.get());
if (!xLayout.is())
break;
if (!xLayout->NoContentReference())
return true; return true;
} }
return false; return false;
...@@ -139,10 +142,13 @@ bool LwpContent::HasNonEmbeddedLayouts() ...@@ -139,10 +142,13 @@ bool LwpContent::HasNonEmbeddedLayouts()
bool LwpContent::IsStyleContent() bool LwpContent::IsStyleContent()
{ {
LwpVirtualLayout* pLayout = nullptr; rtl::Reference<LwpVirtualLayout> xLayout;
while( (pLayout = GetLayout(pLayout)) ) while (1)
{ {
if(pLayout->IsStyleLayout()) xLayout = GetLayout(xLayout.get());
if (!xLayout.is())
break;
if (xLayout->IsStyleLayout())
return true; return true;
} }
return false; return false;
......
...@@ -106,7 +106,7 @@ protected: ...@@ -106,7 +106,7 @@ protected:
void Read() override; void Read() override;
public: public:
inline LwpAssociatedLayouts& GetLayoutsWithMe(); inline LwpAssociatedLayouts& GetLayoutsWithMe();
LwpVirtualLayout* GetLayout(LwpVirtualLayout* pStartLayout); rtl::Reference<LwpVirtualLayout> GetLayout(LwpVirtualLayout* pStartLayout);
inline bool IsActive(); inline bool IsActive();
virtual bool IsTable(); virtual bool IsTable();
inline OUString GetClassName(); inline OUString GetClassName();
......
...@@ -363,7 +363,7 @@ LwpEnSuperTableLayout* LwpFootnote::FindFootnoteTableLayout() ...@@ -363,7 +363,7 @@ LwpEnSuperTableLayout* LwpFootnote::FindFootnoteTableLayout()
while ((pContent = pFoundry->EnumContents(pContent)) != nullptr) while ((pContent = pFoundry->EnumContents(pContent)) != nullptr)
if (pContent->IsTable() && (strClassName.equals(pContent->GetClassName())) && if (pContent->IsTable() && (strClassName.equals(pContent->GetClassName())) &&
pContent->IsActive() && pContent->GetLayout(nullptr)) pContent->IsActive() && pContent->GetLayout(nullptr).is())
{ {
// Found it! // Found it!
return static_cast<LwpEnSuperTableLayout *>( return static_cast<LwpEnSuperTableLayout *>(
...@@ -381,7 +381,7 @@ LwpContent* LwpFootnote::FindFootnoteContent() ...@@ -381,7 +381,7 @@ LwpContent* LwpFootnote::FindFootnoteContent()
LwpContent* pContent = dynamic_cast<LwpContent*>(m_Content.obj().get()); LwpContent* pContent = dynamic_cast<LwpContent*>(m_Content.obj().get());
//if the content has layout, the content has footnote contents; //if the content has layout, the content has footnote contents;
//or looking for the celllayout and return the footnote contents. //or looking for the celllayout and return the footnote contents.
if(pContent && pContent->GetLayout(nullptr)) if (pContent && pContent->GetLayout(nullptr).is())
return pContent; return pContent;
LwpCellLayout* pCellLayout = GetCellLayout(); LwpCellLayout* pCellLayout = GetCellLayout();
......
...@@ -273,8 +273,8 @@ void LwpGraphicObject::RegisterStyle() ...@@ -273,8 +273,8 @@ void LwpGraphicObject::RegisterStyle()
if (m_sServerContextFormat[1]=='l'&&m_sServerContextFormat[2]=='c'&&m_sServerContextFormat[3]=='h') if (m_sServerContextFormat[1]=='l'&&m_sServerContextFormat[2]=='c'&&m_sServerContextFormat[3]=='h')
{ {
LwpVirtualLayout* pMyLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xMyLayout(GetLayout(nullptr));
if (pMyLayout && pMyLayout->IsFrame()) if (xMyLayout.is() && xMyLayout->IsFrame())
{ {
XFFrameStyle* pXFFrameStyle = new XFFrameStyle(); XFFrameStyle* pXFFrameStyle = new XFFrameStyle();
pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame); pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
......
...@@ -419,42 +419,40 @@ void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm) ...@@ -419,42 +419,40 @@ void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm)
* @descr: Looking for the layout which follows the pStartLayout * @descr: Looking for the layout which follows the pStartLayout
* @param: pStartLayout - the layout which is used for looking for its following layout * @param: pStartLayout - the layout which is used for looking for its following layout
*/ */
LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout) rtl::Reference<LwpVirtualLayout> LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout)
{ {
if (!pStartLayout && !m_OnlyLayout.IsNull()) if (!pStartLayout && !m_OnlyLayout.IsNull())
/* Looking for the first layout and there's only one layout in the list.*/ /* Looking for the first layout and there's only one layout in the list.*/
return dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj().get()); return rtl::Reference<LwpVirtualLayout>(dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj().get()));
LwpObjectHolder* pObjHolder = dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead().obj().get()); rtl::Reference<LwpObjectHolder> xObjHolder(dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead().obj().get()));
if(pObjHolder) if (xObjHolder.is())
{ {
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get()); rtl::Reference<LwpVirtualLayout> xLayout(dynamic_cast<LwpVirtualLayout*>(xObjHolder->GetObject().obj().get()));
if(!pStartLayout ) if (!pStartLayout)
return pLayout; return xLayout;
while(pObjHolder && pStartLayout != pLayout) while (xObjHolder.is() && pStartLayout != xLayout.get())
{ {
pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext().obj().get()); xObjHolder.set(dynamic_cast<LwpObjectHolder*>(xObjHolder->GetNext().obj().get()));
if(pObjHolder) if (xObjHolder.is())
{ {
pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get()); xLayout.set(dynamic_cast<LwpVirtualLayout*>(xObjHolder->GetObject().obj().get()));
} }
} }
if(pObjHolder) if (xObjHolder.is())
{ {
pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext().obj().get()); xObjHolder.set(dynamic_cast<LwpObjectHolder*>(xObjHolder->GetNext().obj().get()));
if(pObjHolder) if (xObjHolder.is())
{ {
pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get()); xLayout.set(dynamic_cast<LwpVirtualLayout*>(xObjHolder->GetObject().obj().get()));
return pLayout; return xLayout;
} }
} }
//return pLayout;
} }
return nullptr; return rtl::Reference<LwpVirtualLayout>();
} }
LwpHeadLayout::LwpHeadLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm) LwpHeadLayout::LwpHeadLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
...@@ -473,27 +471,27 @@ void LwpHeadLayout::Read() ...@@ -473,27 +471,27 @@ void LwpHeadLayout::Read()
void LwpHeadLayout::RegisterStyle() void LwpHeadLayout::RegisterStyle()
{ {
//Register all children styles //Register all children styles
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()); rtl::Reference<LwpVirtualLayout> xLayout(dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
while(pLayout) while (xLayout.is())
{ {
pLayout->SetFoundry(m_pFoundry); xLayout->SetFoundry(m_pFoundry);
//if the layout is relative to para, the layout will be registered in para //if the layout is relative to para, the layout will be registered in para
if(!pLayout->IsRelativeAnchored()) if (!xLayout->IsRelativeAnchored())
{ {
if (pLayout == this) if (xLayout.get() == this)
{ {
OSL_FAIL("Layout points to itself"); OSL_FAIL("Layout points to itself");
break; break;
} }
pLayout->DoRegisterStyle(); xLayout->DoRegisterStyle();
} }
LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get()); rtl::Reference<LwpVirtualLayout> xNext(dynamic_cast<LwpVirtualLayout*>(xLayout->GetNext().obj().get()));
if (pNext == pLayout) if (xNext.get() == xLayout.get())
{ {
OSL_FAIL("Layout points to itself"); OSL_FAIL("Layout points to itself");
break; break;
} }
pLayout = pNext; xLayout = xNext;
} }
} }
......
...@@ -254,7 +254,7 @@ public: ...@@ -254,7 +254,7 @@ public:
LwpAssociatedLayouts(){} LwpAssociatedLayouts(){}
void Read(LwpObjectStream* pStrm); void Read(LwpObjectStream* pStrm);
LwpObjectID& GetOnlyLayout() { return m_OnlyLayout;} LwpObjectID& GetOnlyLayout() { return m_OnlyLayout;}
LwpVirtualLayout* GetLayout(LwpVirtualLayout* pStartLayout); rtl::Reference<LwpVirtualLayout> GetLayout(LwpVirtualLayout* pStartLayout);
protected: protected:
LwpObjectID m_OnlyLayout; //LwpVirtualLayout LwpObjectID m_OnlyLayout; //LwpVirtualLayout
LwpDLVListHeadTail m_Layouts; LwpDLVListHeadTail m_Layouts;
......
...@@ -107,10 +107,10 @@ void LwpGraphicOleObject::GetGrafScaledSize(double & fWidth, double & fHeight) ...@@ -107,10 +107,10 @@ void LwpGraphicOleObject::GetGrafScaledSize(double & fWidth, double & fHeight)
double fSclGrafWidth = fWidth;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth()); double fSclGrafWidth = fWidth;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
double fSclGrafHeight = fHeight;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight()); double fSclGrafHeight = fHeight;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
LwpVirtualLayout* pLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
if (pLayout && pLayout->IsFrame()) if (xLayout.is() && xLayout->IsFrame())
{ {
LwpFrameLayout* pMyFrameLayout = static_cast<LwpFrameLayout*>(pLayout); LwpFrameLayout* pMyFrameLayout = static_cast<LwpFrameLayout*>(xLayout.get());
LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale(); LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale();
LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry(); LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry();
......
...@@ -618,8 +618,10 @@ bool LwpPara::ComparePagePosition(LwpVirtualLayout * pPreLayout, LwpVirtualLayou ...@@ -618,8 +618,10 @@ bool LwpPara::ComparePagePosition(LwpVirtualLayout * pPreLayout, LwpVirtualLayou
bool LwpPara::IsInCell() bool LwpPara::IsInCell()
{ {
LwpStory *pStory = GetStory(); LwpStory *pStory = GetStory();
LwpVirtualLayout* pLayout = pStory ? pStory->GetLayout(nullptr) : nullptr; if (!pStory)
if(pLayout && pLayout->IsCell()) return false;
rtl::Reference<LwpVirtualLayout> xLayout(pStory->GetLayout(nullptr));
if (xLayout.is() && xLayout->IsCell())
return true; return true;
return false; return false;
} }
......
...@@ -129,11 +129,11 @@ void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFram ...@@ -129,11 +129,11 @@ void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFram
m_pStream->SeekRel(2); m_pStream->SeekRel(2);
//for calculating transformation params. //for calculating transformation params.
LwpFrameLayout* pMyFrameLayout = static_cast<LwpFrameLayout*>(m_pGraphicObj->GetLayout(nullptr)); rtl::Reference<LwpFrameLayout> xMyFrameLayout(dynamic_cast<LwpFrameLayout*>(m_pGraphicObj->GetLayout(nullptr).get()));
if (pMyFrameLayout) if (xMyFrameLayout.is())
{ {
LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale(); LwpLayoutScale* pMyScale = xMyFrameLayout->GetLayoutScale();
LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry(); LwpLayoutGeometry* pFrameGeo = xMyFrameLayout->GetGeometry();
if (pMyScale && pFrameGeo) if (pMyScale && pFrameGeo)
{ {
// original drawing size // original drawing size
...@@ -143,10 +143,8 @@ void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFram ...@@ -143,10 +143,8 @@ void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFram
double fGrafOrgHeight = (double)nHeight/TWIPS_PER_CM; double fGrafOrgHeight = (double)nHeight/TWIPS_PER_CM;
// get margin values // get margin values
double fLeftMargin = pMyFrameLayout->GetMarginsValue(MARGIN_LEFT); double fLeftMargin = xMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
// double fRightMargin = pMyFrameLayout->GetMarginsValue(MARGIN_RIGHT); double fTopMargin = xMyFrameLayout->GetMarginsValue(MARGIN_TOP);
double fTopMargin = pMyFrameLayout->GetMarginsValue(MARGIN_TOP);
// double fBottomMargin = pMyFrameLayout->GetMarginsValue(MARGIN_BOTTOM);
// frame size // frame size
double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth()); double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
...@@ -197,7 +195,7 @@ void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFram ...@@ -197,7 +195,7 @@ void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFram
} }
// placement: centered // placement: centered
if (pMyFrameLayout->GetScaleCenter()) if (xMyFrameLayout->GetScaleCenter())
{ {
Rectangle aBoundRect(static_cast<long>(left*m_aTransformData.fScaleX + fLeftMargin), Rectangle aBoundRect(static_cast<long>(left*m_aTransformData.fScaleX + fLeftMargin),
static_cast<long>(top * m_aTransformData.fScaleY + fTopMargin), static_cast<long>(top * m_aTransformData.fScaleY + fTopMargin),
......
...@@ -215,20 +215,20 @@ void LwpStory::SortPageLayout() ...@@ -215,20 +215,20 @@ void LwpStory::SortPageLayout()
{ {
//Get all the pagelayout and store in list //Get all the pagelayout and store in list
std::vector<LwpPageLayout*> aLayoutList; std::vector<LwpPageLayout*> aLayoutList;
LwpVirtualLayout* pLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
while(pLayout) while (xLayout.get())
{ {
if(pLayout->IsPage()) if (xLayout->IsPage())
{ {
LwpLayout::UseWhenType eSectionType = static_cast<LwpPageLayout*>(pLayout)->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 = pLayout->GetParentLayout(); LwpVirtualLayout* pParent = xLayout->GetParentLayout();
if(eSectionType != LwpLayout::StartWithinColume && pParent && !pParent->IsPage()) if(eSectionType != LwpLayout::StartWithinColume && pParent && !pParent->IsPage())
{ {
aLayoutList.push_back(static_cast<LwpPageLayout*>(pLayout)); aLayoutList.push_back(static_cast<LwpPageLayout*>(xLayout.get()));
} }
} }
pLayout = GetLayout(pLayout); xLayout = GetLayout(xLayout.get());
} }
// sort the pagelayout according to their position // sort the pagelayout according to their position
std::vector<LwpPageLayout*>::iterator aIt; std::vector<LwpPageLayout*>::iterator aIt;
...@@ -315,10 +315,10 @@ bool LwpStory::IsNeedSection() ...@@ -315,10 +315,10 @@ bool LwpStory::IsNeedSection()
**************************************************************************/ **************************************************************************/
void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont) void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont)
{ {
LwpVirtualLayout* pLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
while(pLayout) while (xLayout.is())
{ {
LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead().obj().get()); LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get());
while(pFrameLayout) while(pFrameLayout)
{ {
...@@ -334,7 +334,7 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont) ...@@ -334,7 +334,7 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont)
} }
pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get()); pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get());
} }
pLayout = GetLayout(pLayout); xLayout = GetLayout(xLayout.get());
} }
} }
...@@ -343,10 +343,10 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont) ...@@ -343,10 +343,10 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont)
**************************************************************************/ **************************************************************************/
void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont) void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont)
{ {
LwpVirtualLayout* pLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
while(pLayout) while (xLayout.is())
{ {
LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead().obj().get()); LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get());
while(pFrameLayout) while(pFrameLayout)
{ {
if((pFrameLayout->IsAnchorPage() if((pFrameLayout->IsAnchorPage()
...@@ -358,7 +358,7 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont) ...@@ -358,7 +358,7 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont)
} }
pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get()); pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get());
} }
pLayout = GetLayout(pLayout); xLayout = GetLayout(xLayout.get());
} }
} }
/************************************************************************** /**************************************************************************
...@@ -366,10 +366,10 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont) ...@@ -366,10 +366,10 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont)
**************************************************************************/ **************************************************************************/
void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont) void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont)
{ {
LwpVirtualLayout* pLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
while(pLayout) while (xLayout.get())
{ {
LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead().obj().get()); LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get());
while(pFrameLayout) while(pFrameLayout)
{ {
if(pFrameLayout->IsAnchorFrame()) if(pFrameLayout->IsAnchorFrame())
...@@ -378,7 +378,7 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont) ...@@ -378,7 +378,7 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont)
} }
pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get()); pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get());
} }
pLayout = GetLayout(pLayout); xLayout = GetLayout(xLayout.get());
} }
} }
/************************************************************************** /**************************************************************************
...@@ -386,13 +386,13 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont) ...@@ -386,13 +386,13 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont)
**************************************************************************/ **************************************************************************/
void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont) void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont)
{ {
LwpVirtualLayout* pLayout = GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
while(pLayout) while (xLayout.is())
{ {
LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead().obj().get()); LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get());
while(pFrameLayout) while(pFrameLayout)
{ {
if(pFrameLayout->IsAnchorPage() && (pLayout->IsHeader() || pLayout->IsFooter())) if(pFrameLayout->IsAnchorPage() && (xLayout->IsHeader() || xLayout->IsFooter()))
{ {
//The frame must be included by <text:p> //The frame must be included by <text:p>
rtl::Reference<XFContent> first( rtl::Reference<XFContent> first(
...@@ -403,7 +403,7 @@ void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont) ...@@ -403,7 +403,7 @@ void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont)
} }
pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get()); pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext().obj().get());
} }
pLayout = GetLayout(pLayout); xLayout = GetLayout(xLayout.get());
} }
} }
...@@ -423,10 +423,10 @@ XFContentContainer* LwpStory::GetXFContent() ...@@ -423,10 +423,10 @@ XFContentContainer* LwpStory::GetXFContent()
LwpPara* LwpStory::GetLastParaOfPreviousStory() LwpPara* LwpStory::GetLastParaOfPreviousStory()
{ {
LwpVirtualLayout* pVLayout = this->GetLayout(nullptr); rtl::Reference<LwpVirtualLayout> xVLayout(this->GetLayout(nullptr));
if (pVLayout) if (xVLayout.is())
{ {
return pVLayout->GetLastParaOfPreviousStory(); return xVLayout->GetLastParaOfPreviousStory();
} }
return nullptr; return nullptr;
......
...@@ -147,7 +147,7 @@ LwpMiddleLayout* LwpStory::GetTabLayout() ...@@ -147,7 +147,7 @@ LwpMiddleLayout* LwpStory::GetTabLayout()
{ {
if(m_pTabLayout) if(m_pTabLayout)
return m_pTabLayout; return m_pTabLayout;
return static_cast<LwpMiddleLayout*>(GetLayout(nullptr)); return dynamic_cast<LwpMiddleLayout*>(GetLayout(nullptr).get());
} }
void LwpStory::SetPMModified(bool bPMModified) void LwpStory::SetPMModified(bool bPMModified)
{ {
......
...@@ -119,7 +119,10 @@ public: ...@@ -119,7 +119,10 @@ public:
LwpObjectID& GetDefaultCellStyle() {return m_DefaultCellStyle;} LwpObjectID& GetDefaultCellStyle() {return m_DefaultCellStyle;}
sal_uInt16 GetRow() {return m_nRow;} sal_uInt16 GetRow() {return m_nRow;}
sal_uInt16 GetColumn() {return m_nColumn;} sal_uInt16 GetColumn() {return m_nColumn;}
LwpTableLayout * GetTableLayout(){return dynamic_cast<LwpTableLayout *>(GetLayout(nullptr));} rtl::Reference<LwpTableLayout> GetTableLayout()
{
return rtl::Reference<LwpTableLayout>(dynamic_cast<LwpTableLayout*>(GetLayout(nullptr).get()));
}
bool IsNumberDown(); bool IsNumberDown();
virtual bool IsTable() override { return true;} virtual bool IsTable() override { return true;}
LwpSuperTableLayout* GetSuperTableLayout(); LwpSuperTableLayout* GetSuperTableLayout();
......
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