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

infinite recurse protection

Change-Id: I7139e67e7b5bcd7e1867dff1cfbd53fa0f5748b7
(cherry picked from commit fb8cba16)
üst fa02fa99
...@@ -132,7 +132,7 @@ public: ...@@ -132,7 +132,7 @@ public:
void RegisterStyle() override; void RegisterStyle() override;
inline bool IsChildDoc(); inline bool IsChildDoc();
inline bool HonorProtection(); inline bool GetHonorProtection();
inline LwpObjectID& GetDocData(); inline LwpObjectID& GetDocData();
inline LwpObjectID& GetSocket(); inline LwpObjectID& GetSocket();
...@@ -176,7 +176,7 @@ inline bool LwpDocument::IsChildDoc() ...@@ -176,7 +176,7 @@ inline bool LwpDocument::IsChildDoc()
{ {
return (m_nPersistentFlags & DOC_CHILDDOC) != 0; return (m_nPersistentFlags & DOC_CHILDDOC) != 0;
} }
inline bool LwpDocument::HonorProtection() inline bool LwpDocument::GetHonorProtection()
{ {
return (m_nPersistentFlags & DOC_PROTECTED) != 0; return (m_nPersistentFlags & DOC_PROTECTED) != 0;
} }
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm) LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
: LwpDLNFPVList(objHdr, pStrm) : LwpDLNFPVList(objHdr, pStrm)
, m_bGettingHonorProtection(false)
, m_nAttributes(0) , m_nAttributes(0)
, m_nAttributes2(0) , m_nAttributes2(0)
, m_nAttributes3(0) , m_nAttributes3(0)
...@@ -139,20 +140,16 @@ bool LwpVirtualLayout::HonorProtection() ...@@ -139,20 +140,16 @@ bool LwpVirtualLayout::HonorProtection()
return false; return false;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get());
if (pParent && !pParent->IsHeader() && pParent != this) if (pParent && !pParent->IsHeader())
{ {
return pParent->HonorProtection(); return pParent->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)
{
return pDoc->HonorProtection();
}*/
if(pDoc && pDoc->GetRootDocument()) if(pDoc && pDoc->GetRootDocument())
return pDoc->GetRootDocument()->HonorProtection(); return pDoc->GetRootDocument()->GetHonorProtection();
} }
return true; return true;
...@@ -169,7 +166,7 @@ bool LwpVirtualLayout::IsProtected() ...@@ -169,7 +166,7 @@ bool LwpVirtualLayout::IsProtected()
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get());
if(pParent && !pParent->IsHeader()) if(pParent && !pParent->IsHeader())
{ {
if(pParent->HonorProtection()&&(pParent->HasProtection()||bProtected)) if(pParent->GetHonorProtection()&&(pParent->GetHasProtection()||bProtected))
{ {
return true; return true;
} }
...@@ -179,7 +176,7 @@ bool LwpVirtualLayout::IsProtected() ...@@ -179,7 +176,7 @@ bool LwpVirtualLayout::IsProtected()
LwpDocument* pDoc = m_pFoundry->GetDocument(); LwpDocument* pDoc = m_pFoundry->GetDocument();
if(pDoc) if(pDoc)
{ {
if (pDoc->HonorProtection() && bProtected) if (pDoc->GetHonorProtection() && bProtected)
{ {
return true; return true;
} }
...@@ -199,9 +196,9 @@ bool LwpVirtualLayout::HasProtection() ...@@ -199,9 +196,9 @@ bool LwpVirtualLayout::HasProtection()
return true; return true;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get());
if (pParent && !pParent->IsHeader() && pParent != this) if (pParent && !pParent->IsHeader())
{ {
return pParent->HasProtection(); return pParent->GetHasProtection();
} }
return false; return false;
...@@ -1235,9 +1232,9 @@ bool LwpMiddleLayout::HonorProtection() ...@@ -1235,9 +1232,9 @@ bool LwpMiddleLayout::HonorProtection()
return false; return false;
LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get()); LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get());
if(pParent && !pParent->IsHeader()) if (pParent && !pParent->IsHeader())
{ {
return pParent->HonorProtection(); return pParent->GetHonorProtection();
} }
if(m_pFoundry)//is null now if(m_pFoundry)//is null now
...@@ -1245,13 +1242,13 @@ bool LwpMiddleLayout::HonorProtection() ...@@ -1245,13 +1242,13 @@ bool LwpMiddleLayout::HonorProtection()
LwpDocument* pDoc = m_pFoundry->GetDocument(); LwpDocument* pDoc = m_pFoundry->GetDocument();
if(pDoc) if(pDoc)
{ {
return pDoc->HonorProtection(); return pDoc->GetHonorProtection();
} }
} }
} }
else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get())) else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get()))
{ {
return pLay->HonorProtection(); return pLay->GetHonorProtection();
} }
return LwpVirtualLayout::HonorProtection(); return LwpVirtualLayout::HonorProtection();
...@@ -1282,7 +1279,7 @@ bool LwpMiddleLayout::IsProtected() ...@@ -1282,7 +1279,7 @@ bool LwpMiddleLayout::IsProtected()
if(pParent->IsProtected()) if(pParent->IsProtected())
return true; return true;
if(pParent->HonorProtection()) if(pParent->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. */
...@@ -1294,7 +1291,7 @@ bool LwpMiddleLayout::IsProtected() ...@@ -1294,7 +1291,7 @@ bool LwpMiddleLayout::IsProtected()
LwpDocument* pDoc = m_pFoundry->GetDocument(); LwpDocument* pDoc = m_pFoundry->GetDocument();
if(pDoc) if(pDoc)
{ {
if (pDoc->HonorProtection()) if (pDoc->GetHonorProtection())
return bProtected; return bProtected;
/* If the document isn't honoring protection then we aren't protected.*/ /* If the document isn't honoring protection then we aren't protected.*/
......
...@@ -111,9 +111,25 @@ public: ...@@ -111,9 +111,25 @@ public:
bool IsAutoGrowWidth(); bool IsAutoGrowWidth();
bool IsInlineToMargin(); bool IsInlineToMargin();
virtual sal_uInt8 GetContentOrientation(){ return TEXT_ORIENT_LRTB;} virtual sal_uInt8 GetContentOrientation(){ return TEXT_ORIENT_LRTB;}
virtual bool HonorProtection(); bool GetHonorProtection()
{
if (m_bGettingHonorProtection)
throw std::runtime_error("recursion in layout");
m_bGettingHonorProtection = true;
bool bRet = HonorProtection();
m_bGettingHonorProtection = false;
return bRet;
}
virtual bool IsProtected(); virtual bool IsProtected();
bool HasProtection(); bool GetHasProtection()
{
if (m_bGettingHasProtection)
throw std::runtime_error("recursion in layout");
m_bGettingHasProtection = true;
bool bRet = HasProtection();
m_bGettingHasProtection = false;
return bRet;
}
OUString GetStyleName(){ return m_StyleName;} OUString GetStyleName(){ return m_StyleName;}
bool IsComplex(); bool IsComplex();
virtual bool IsAnchorPage(){ return false;} virtual bool IsAnchorPage(){ return false;}
...@@ -163,7 +179,11 @@ public: ...@@ -163,7 +179,11 @@ public:
//End by //End by
protected: protected:
void Read() override; void Read() override;
bool HasProtection();
virtual bool HonorProtection();
protected: protected:
bool m_bGettingHonorProtection;
bool m_bGettingHasProtection;
sal_uInt32 m_nAttributes; sal_uInt32 m_nAttributes;
sal_uInt32 m_nAttributes2; sal_uInt32 m_nAttributes2;
sal_uInt32 m_nAttributes3; sal_uInt32 m_nAttributes3;
......
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