[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - lotuswordpro/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 30 08:55:35 UTC 2018


 lotuswordpro/source/filter/lwplayout.cxx |   31 ++++++++++++++++++++++++-------
 lotuswordpro/source/filter/lwplayout.hxx |   12 ++----------
 2 files changed, 26 insertions(+), 17 deletions(-)

New commits:
commit 6e3db4997a81f4139169ce9d44da6b5e4c4475ed
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jul 27 08:58:56 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Jul 30 10:55:19 2018 +0200

    ofz#9603 infinite recursion
    
    Change-Id: Ia4d0e3c1bb12330bd2f754e663055e1218da926f
    Reviewed-on: https://gerrit.libreoffice.org/58178
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 4423178aeeeb..dfb9883f0714 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -588,6 +588,7 @@ void LwpLayoutMisc::Read(LwpObjectStream* pStrm)
 LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm )
     : LwpVirtualLayout(objHdr, pStrm)
     , m_bGettingGeometry(false)
+    , m_bGettingBackgroundStuff(false)
 {
 }
 
@@ -655,21 +656,28 @@ rtl::Reference<LwpObject> LwpMiddleLayout::GetBasedOnStyle()
 * @descr:   Get the geometry of current layout
 *
 */
-LwpLayoutGeometry* LwpMiddleLayout::Geometry()
+LwpLayoutGeometry* LwpMiddleLayout::GetGeometry()
 {
+    if (m_bGettingGeometry)
+        throw std::runtime_error("recursion in layout");
+    m_bGettingGeometry = true;
+
+    LwpLayoutGeometry* pRet = nullptr;
     if( !m_LayGeometry.IsNull() )
     {
-        return dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj().get());
+        pRet = dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj().get());
     }
     else
     {
         rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
         if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
         {
-            return pLay->GetGeometry();
+            pRet = pLay->GetGeometry();
         }
     }
-    return nullptr;
+
+    m_bGettingGeometry = false;
+    return pRet;
 }
 
 /**
@@ -818,21 +826,30 @@ LwpBorderStuff* LwpMiddleLayout::GetBorderStuff()
 */
 LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
 {
+    if (m_bGettingBackgroundStuff)
+        throw std::runtime_error("recursion in layout");
+    m_bGettingBackgroundStuff = true;
+
+    LwpBackgroundStuff* pRet = nullptr;
+
     if(m_nOverrideFlag & OVER_BACKGROUND)
     {
         LwpLayoutBackground* pLayoutBackground = dynamic_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj().get());
-        return pLayoutBackground ? &pLayoutBackground->GetBackgoudStuff() : nullptr;
+        pRet = pLayoutBackground ? &pLayoutBackground->GetBackgoudStuff() : nullptr;
     }
     else
     {
         rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
         if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
         {
-            return pLay->GetBackgroundStuff();
+            pRet = pLay->GetBackgroundStuff();
         }
     }
-    return nullptr;
+
+    m_bGettingBackgroundStuff = false;
+    return pRet;
 }
+
 /**
  * @descr:  create xfborder.
 */
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
index 2d0694b67864..98d7ca515906 100644
--- a/lotuswordpro/source/filter/lwplayout.hxx
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -347,19 +347,11 @@ class LwpMiddleLayout : public LwpVirtualLayout
 public:
     LwpMiddleLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
     virtual ~LwpMiddleLayout() override;
-    LwpLayoutGeometry* GetGeometry()
-    {
-        if (m_bGettingGeometry)
-            throw std::runtime_error("recursion in layout");
-        m_bGettingGeometry = true;
-        auto pRet = Geometry();
-        m_bGettingGeometry = false;
-        return pRet;
-    }
     double GetGeometryHeight();
     double GetGeometryWidth();
     LwpBorderStuff* GetBorderStuff();
     LwpBackgroundStuff* GetBackgroundStuff();
+    LwpLayoutGeometry* GetGeometry();
     enumXFTextDir GetTextDirection();
     XFBorders* GetXFBorders();
     LwpColor* GetBackColor();
@@ -402,7 +394,6 @@ protected:
     virtual bool IsAutoGrowDown() override;
 private:
     LwpObjectID m_BasedOnStyle;
-    LwpLayoutGeometry* Geometry();
 protected:
     enum
     {
@@ -422,6 +413,7 @@ protected:
     LwpObjectID     m_LayBackgroundStuff;
     LwpObjectID     m_LayExtBorderStuff;
     bool            m_bGettingGeometry;
+    bool            m_bGettingBackgroundStuff;
 public:
     LwpObjectID& GetContent() { return m_Content; }
     LwpTabOverride* GetTabOverride();


More information about the Libreoffice-commits mailing list