[Libreoffice-commits] core.git: lotuswordpro/source

Caolán McNamara caolanm at redhat.com
Sun Dec 13 01:34:32 PST 2015


 lotuswordpro/source/filter/lwpdoc.hxx    |    4 ++--
 lotuswordpro/source/filter/lwplayout.cxx |   31 ++++++++++++++-----------------
 lotuswordpro/source/filter/lwplayout.hxx |   24 ++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 21 deletions(-)

New commits:
commit fb8cba16caa87bf21fdd2747b22d90d913557dac
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Dec 13 09:34:01 2015 +0000

    infinite recurse protection
    
    Change-Id: I7139e67e7b5bcd7e1867dff1cfbd53fa0f5748b7

diff --git a/lotuswordpro/source/filter/lwpdoc.hxx b/lotuswordpro/source/filter/lwpdoc.hxx
index ad9d5fd..17ab35d 100644
--- a/lotuswordpro/source/filter/lwpdoc.hxx
+++ b/lotuswordpro/source/filter/lwpdoc.hxx
@@ -132,7 +132,7 @@ public:
     void RegisterStyle() override;
 
     inline bool IsChildDoc();
-    inline bool HonorProtection();
+    inline bool GetHonorProtection();
     inline LwpObjectID& GetDocData();
     inline LwpObjectID& GetSocket();
 
@@ -176,7 +176,7 @@ inline bool LwpDocument::IsChildDoc()
 {
     return (m_nPersistentFlags & DOC_CHILDDOC) != 0;
 }
-inline bool LwpDocument::HonorProtection()
+inline bool LwpDocument::GetHonorProtection()
 {
     return (m_nPersistentFlags & DOC_PROTECTED) != 0;
 }
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 1bef408..86a1863 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -73,6 +73,7 @@
 
 LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     : LwpDLNFPVList(objHdr, pStrm)
+    , m_bGettingHonorProtection(false)
     , m_nAttributes(0)
     , m_nAttributes2(0)
     , m_nAttributes3(0)
@@ -139,20 +140,16 @@ bool LwpVirtualLayout::HonorProtection()
         return false;
 
     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
     {
         LwpDocument* pDoc = m_pFoundry->GetDocument();
-        /*if(pDoc)
-        {
-            return pDoc->HonorProtection();
-        }*/
         if(pDoc && pDoc->GetRootDocument())
-            return pDoc->GetRootDocument()->HonorProtection();
+            return pDoc->GetRootDocument()->GetHonorProtection();
     }
 
     return true;
@@ -169,7 +166,7 @@ bool LwpVirtualLayout::IsProtected()
     LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent().obj().get());
     if(pParent && !pParent->IsHeader())
     {
-        if(pParent->HonorProtection()&&(pParent->HasProtection()||bProtected))
+        if(pParent->GetHonorProtection()&&(pParent->GetHasProtection()||bProtected))
         {
             return true;
         }
@@ -179,7 +176,7 @@ bool LwpVirtualLayout::IsProtected()
         LwpDocument* pDoc = m_pFoundry->GetDocument();
         if(pDoc)
         {
-            if (pDoc->HonorProtection() && bProtected)
+            if (pDoc->GetHonorProtection() && bProtected)
             {
                 return true;
             }
@@ -199,9 +196,9 @@ bool LwpVirtualLayout::HasProtection()
         return true;
 
     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;
@@ -1235,9 +1232,9 @@ bool LwpMiddleLayout::HonorProtection()
             return false;
 
         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
@@ -1245,13 +1242,13 @@ bool LwpMiddleLayout::HonorProtection()
             LwpDocument* pDoc = m_pFoundry->GetDocument();
             if(pDoc)
             {
-                return pDoc->HonorProtection();
+                return pDoc->GetHonorProtection();
             }
         }
     }
     else if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> (GetBasedOnStyle().get()))
     {
-        return pLay->HonorProtection();
+        return pLay->GetHonorProtection();
     }
 
     return LwpVirtualLayout::HonorProtection();
@@ -1282,7 +1279,7 @@ bool LwpMiddleLayout::IsProtected()
         if(pParent->IsProtected())
             return true;
 
-        if(pParent->HonorProtection())
+        if(pParent->GetHonorProtection())
             return bProtected;
 
         /* If our parent isn't honoring protection then we aren't protected. */
@@ -1294,7 +1291,7 @@ bool LwpMiddleLayout::IsProtected()
         LwpDocument* pDoc = m_pFoundry->GetDocument();
         if(pDoc)
         {
-            if (pDoc->HonorProtection())
+            if (pDoc->GetHonorProtection())
                 return bProtected;
 
             /* If the document isn't honoring protection then we aren't protected.*/
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
index 1ed9474..e9c039a 100644
--- a/lotuswordpro/source/filter/lwplayout.hxx
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -111,9 +111,25 @@ public:
     bool IsAutoGrowWidth();
     bool IsInlineToMargin();
     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();
-    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;}
     bool IsComplex();
     virtual bool IsAnchorPage(){ return false;}
@@ -163,7 +179,11 @@ public:
     //End by
 protected:
     void Read() override;
+    bool HasProtection();
+    virtual bool HonorProtection();
 protected:
+    bool m_bGettingHonorProtection;
+    bool m_bGettingHasProtection;
     sal_uInt32 m_nAttributes;
     sal_uInt32 m_nAttributes2;
     sal_uInt32 m_nAttributes3;


More information about the Libreoffice-commits mailing list