Kaydet (Commit) fdc0c739 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) David Tardon

guard against infinite recursion on registering styles

(cherry picked from commit 66686e44)
Reviewed-on: https://gerrit.libreoffice.org/20554Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
(cherry picked from commit 282b1aa3)

Change-Id: Iabedfcce9d8ef21172e6bd0d654f3a258aae97e3
Reviewed-on: https://gerrit.libreoffice.org/20555Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 59ced109
......@@ -192,7 +192,7 @@ void Lwp9Reader::ParseDocument()
//Register Styles
RegisteArrowStyles();
doc->RegisterStyle();
doc->DoRegisterStyle();
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
pXFStyleManager->ToXml(m_pStream);
......
......@@ -598,7 +598,7 @@ void LwpCellLayout::RegisterStyle()
if (pObj.is())
{
pObj->SetFoundry(m_pFoundry);
pObj->RegisterStyle();
pObj->DoRegisterStyle();
}
//register child layout style
......
......@@ -224,7 +224,7 @@ void LwpDocument::RegisterStyle()
rtl::Reference<LwpObject> pDocSock = GetSocket().obj();
if(pDocSock.is())
{
pDocSock->RegisterStyle();
pDocSock->DoRegisterStyle();
}
}
/**
......@@ -322,7 +322,7 @@ void LwpDocument::RegisterGraphicsStyles()
if(pGraphic.is())
{
pGraphic->SetFoundry(m_pFoundry);
pGraphic->RegisterStyle();
pGraphic->DoRegisterStyle();
}
}
/**
......@@ -619,7 +619,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
LwpDocument* pDivision = GetFirstDivision();
while (pDivision)
while (pDivision && pDivision != this)
{
LwpDocument* pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
if(pContentDivision)
......@@ -782,11 +782,11 @@ void LwpDocSock::RegisterStyle()
{
rtl::Reference<LwpObject> pDoc = GetNext().obj();
if(pDoc.is())
pDoc->RegisterStyle();
pDoc->DoRegisterStyle();
pDoc = GetChildHead().obj();
if(pDoc.is())
pDoc->RegisterStyle();
pDoc->DoRegisterStyle();
}
/**
* @descr parse contents of documents plugged
......
......@@ -164,7 +164,7 @@ void LwpFnCellLayout::RegisterStyle()
if (pObj.is())
{
pObj->SetFoundry(m_pFoundry);
pObj->RegisterStyle();
pObj->DoRegisterStyle();
}
}
......@@ -241,7 +241,7 @@ void LwpEnSuperTableLayout::RegisterStyle()
if (pTableLayout != NULL)
{
pTableLayout->SetFoundry(m_pFoundry);
pTableLayout->RegisterStyle();
pTableLayout->DoRegisterStyle();
}
}
......
......@@ -181,7 +181,7 @@ void LwpFootnote::RegisterStyle()
if(pContent)
{
pContent->SetFoundry(m_pFoundry);
pContent->RegisterStyle();
pContent->DoRegisterStyle();
}
}
}
......
......@@ -202,7 +202,7 @@ void LwpFoundry::RegisterAllLayouts()
if( pStyle.is() )
{
pStyle->SetFoundry(this);
pStyle->RegisterStyle();
pStyle->DoRegisterStyle();
}
//register content page layout list: Layout
......@@ -210,7 +210,7 @@ void LwpFoundry::RegisterAllLayouts()
if( pStyle.is() )
{
pStyle->SetFoundry(this);
pStyle->RegisterStyle();
pStyle->DoRegisterStyle();
}
//Register page style layout list: PageStyle, such as "Default Page"
......@@ -218,7 +218,7 @@ void LwpFoundry::RegisterAllLayouts()
if( pStyle.is() )
{
pStyle->SetFoundry(this);
pStyle->RegisterStyle();
pStyle->DoRegisterStyle();
}
//Register FrameStyle
......@@ -226,7 +226,7 @@ void LwpFoundry::RegisterAllLayouts()
if( pStyle.is() )
{
pStyle->SetFoundry(this);
pStyle->RegisterStyle();
pStyle->DoRegisterStyle();
}
}
......
......@@ -867,7 +867,7 @@ void LwpFrameLayout::RegisterStyle()
if (content.is())
{
content->SetFoundry(m_pFoundry);
content->RegisterStyle();
content->DoRegisterStyle();
}
//register child frame style
......
......@@ -108,7 +108,7 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
if (!pLayout)
return;
pLayout->SetFoundry(pFoundry);
pLayout->RegisterStyle();
pLayout->DoRegisterStyle();
//register next frib text style
sal_uInt8 nType = pLayout->GetRelativeType();
......
......@@ -511,7 +511,7 @@ void LwpHeadLayout::RegisterStyle()
OSL_FAIL("Layout points to itself");
break;
}
pLayout->RegisterStyle();
pLayout->DoRegisterStyle();
}
LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
if (pNext == pLayout)
......
......@@ -92,7 +92,7 @@ void LwpFribNote::RegisterNewStyle()
LwpFrib::RegisterStyle(m_pPara->GetFoundry());
//register foonote style
pLayout->SetFoundry(m_pPara->GetFoundry());
pLayout->RegisterStyle();
pLayout->DoRegisterStyle();
}
}
......@@ -172,7 +172,7 @@ void LwpNoteLayout::RegisterStyle()
if(pTextLayout)
{
pTextLayout->SetFoundry(GetFoundry());
pTextLayout->RegisterStyle();
pTextLayout->DoRegisterStyle();
}
}
......@@ -284,7 +284,7 @@ void LwpNoteTextLayout::RegisterStyle()
if(pContent.is())
{
pContent->SetFoundry(GetFoundry());
pContent->RegisterStyle();
pContent->DoRegisterStyle();
}
}
......
......@@ -64,7 +64,7 @@
* @descr construct lwpobject from stream
*/
LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm)
: m_ObjHdr(objHdr), m_pObjStrm(NULL), m_pFoundry(NULL), m_pStrm(pStrm)
: m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr), m_pStrm(pStrm), m_bRegisteringStyle(false)
{
m_pObjStrm = new LwpObjectStream(pStrm, m_ObjHdr.IsCompressed(),
static_cast<sal_uInt16>(m_ObjHdr.GetSize()) );
......
......@@ -92,11 +92,22 @@ protected:
LwpObjectStream* m_pObjStrm;
LwpFoundry* m_pFoundry;
LwpSvStream* m_pStrm;
bool m_bRegisteringStyle;
protected:
virtual void Read();
virtual void RegisterStyle();
public:
void QuickRead();
virtual void RegisterStyle();
//calls RegisterStyle but bails if DoRegisterStyle is called
//on the same object recursively
void DoRegisterStyle()
{
if (m_bRegisteringStyle)
throw std::runtime_error("recursion in styles");
m_bRegisteringStyle = true;
RegisterStyle();
m_bRegisteringStyle = false;
}
virtual void Parse(IXFStream* pOutputStream);
virtual void XFConvert(XFContentContainer* pCont);
......
......@@ -884,7 +884,7 @@ void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
//Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
pStory->SetFoundry(m_pFoundry);
pStory->RegisterStyle();
pStory->DoRegisterStyle();
//, 06/27/2005
//register child layout style for framelayout,
RegisterChildStyle();
......@@ -1037,8 +1037,7 @@ void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
pChangeMgr->SetHeadFootFribMap(true);
pStory->SetFoundry(m_pFoundry);
pStory->RegisterStyle();
//, 06/27/2005
pStory->DoRegisterStyle();
//register child layout style for framelayout,
RegisterChildStyle();
//End
......
......@@ -77,7 +77,7 @@ void LwpVersionedPointer::RegisterStyle()
if( pObj.is() )
{
pObj->SetFoundry(m_pFoundry);
pObj->RegisterStyle();
pObj->DoRegisterStyle();
}
}
......
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