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

Caolán McNamara caolanm at redhat.com
Mon Jul 18 09:55:39 UTC 2016


 writerfilter/source/dmapper/DomainMapper.cxx      |   10 ++++++----
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   10 ++++++----
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    9 +++++++--
 3 files changed, 19 insertions(+), 10 deletions(-)

New commits:
commit 9d76d9d9abb08788f2882612cfe6d0df6e19af39
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jul 18 10:42:02 2016 +0100

    protect against empty m_aTableManagers stack
    
    Change-Id: I29fecc5e0efb3b3d907f0c6505d42818fa464ffc

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index b1b4f6d..ba1069a 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1076,8 +1076,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 
 void DomainMapper::lcl_sprm(Sprm & rSprm)
 {
-    if( !m_pImpl->getTableManager().sprm(rSprm))
-        sprmWithProps( rSprm, m_pImpl->GetTopContext() );
+    if (!m_pImpl->hasTableManager() || !m_pImpl->getTableManager().sprm(rSprm))
+        sprmWithProps(rSprm, m_pImpl->GetTopContext());
 }
 
 sal_Int32 lcl_getCurrentNumberingProperty(
@@ -2830,7 +2830,8 @@ void DomainMapper::lcl_endSectionGroup()
 
 void DomainMapper::lcl_startParagraphGroup()
 {
-    m_pImpl->getTableManager().startParagraphGroup();
+    if (m_pImpl->hasTableManager())
+        m_pImpl->getTableManager().startParagraphGroup();
     /*
      * Add new para properties only if paragraph is not split
      * or the top context is not of paragraph properties
@@ -2867,7 +2868,8 @@ void DomainMapper::lcl_startParagraphGroup()
 void DomainMapper::lcl_endParagraphGroup()
 {
     m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
-    m_pImpl->getTableManager().endParagraphGroup();
+    if (m_pImpl->hasTableManager())
+       m_pImpl->getTableManager().endParagraphGroup();
     //frame conversion has to be executed after table conversion
     m_pImpl->ExecuteFrameConversion();
     m_pImpl->SetIsOutsideAParagraph(true);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0bb5062..018f399 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -267,11 +267,13 @@ DomainMapper_Impl::~DomainMapper_Impl()
     // Don't remove last paragraph when pasting, sw expects that empty paragraph.
     if (m_bIsNewDoc)
         RemoveLastParagraph();
-    getTableManager( ).endLevel();
-    popTableManager( );
+    if (hasTableManager())
+    {
+        getTableManager().endLevel();
+        popTableManager();
+    }
 }
 
-
 uno::Reference< container::XNameContainer >    DomainMapper_Impl::GetPageStyles()
 {
     if(!m_xPageStyles.is())
@@ -1031,7 +1033,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap )
     TagLogger::getInstance().attribute("isTextAppend", sal_uInt32(xTextAppend.is()));
 #endif
 
-    if (xTextAppend.is() && !getTableManager( ).isIgnore() && pParaContext != nullptr)
+    if (xTextAppend.is() && pParaContext != nullptr && !getTableManager().isIgnore())
     {
         try
         {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 896f7e1..c0e1370 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -699,6 +699,11 @@ public:
         const bool bStart,
         const sal_Int32 nAnnotationId );
 
+    bool hasTableManager() const
+    {
+        return !m_aTableManagers.empty();
+    }
+
     DomainMapperTableManager& getTableManager()
     {
         std::shared_ptr< DomainMapperTableManager > pMngr = m_aTableManagers.top();
@@ -719,8 +724,8 @@ public:
 
     void popTableManager( )
     {
-        if ( m_aTableManagers.size( ) > 0 )
-            m_aTableManagers.pop( );
+        if (hasTableManager())
+            m_aTableManagers.pop();
     }
 
     void SetLineNumbering( sal_Int32 nLnnMod, sal_uInt32 nLnc, sal_Int32 ndxaLnn );


More information about the Libreoffice-commits mailing list