[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/source

Caolán McNamara caolanm at redhat.com
Thu Mar 15 19:13:03 UTC 2018


 sw/source/filter/ww8/ww8par.cxx  |   17 ++++++++++-------
 sw/source/filter/ww8/ww8par.hxx  |    2 ++
 sw/source/filter/ww8/ww8par6.cxx |   34 +++++++++++++++++++++++-----------
 3 files changed, 35 insertions(+), 18 deletions(-)

New commits:
commit 19f0b25acc2a23b790301755a9fee2629eb667b0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 15 17:26:36 2018 +0000

    ofz#6827 Bad-cast
    
    Change-Id: I856d781f122c21c02a0a8cd01369d49f50b8a555
    Reviewed-on: https://gerrit.libreoffice.org/51365
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 162b4203763a..0ca6771ec609 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3957,7 +3957,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
     long nCpOfs = m_pPlcxMan->GetCpOfs(); // Offset for Header/Footer, Footnote
 
     WW8_CP nNext = m_pPlcxMan->Where();
-    SwTextNode* pPreviousNode = nullptr;
+    m_pPreviousNode = nullptr;
     sal_uInt8 nDropLines = 0;
     SwCharFormat* pNewSwCharFormat = nullptr;
     const SwCharFormat* pFormat = nullptr;
@@ -3986,7 +3986,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
 
         // If the previous paragraph was a dropcap then do not
         // create a new txtnode and join the two paragraphs together
-        if (bStartLine && !pPreviousNode) // Line end
+        if (bStartLine && !m_pPreviousNode) // Line end
         {
             bool bSplit = true;
             if (m_bCareFirstParaEndInToc)
@@ -4010,10 +4010,10 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
             }
         }
 
-        if (pPreviousNode && bStartLine)
+        if (m_pPreviousNode && bStartLine)
         {
             SwTextNode* pEndNd = m_pPaM->GetNode().GetTextNode();
-            const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength();
+            const sal_Int32 nDropCapLen = m_pPreviousNode->GetText().getLength();
 
             // Need to reset the font size and text position for the dropcap
             {
@@ -4040,12 +4040,12 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
             SwPosition aStart(*pEndNd);
             m_pCtrlStck->NewAttr(aStart, aDrop);
             m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_PARATR_DROP);
-            pPreviousNode = nullptr;
+            m_pPreviousNode = nullptr;
         }
         else if (m_bDropCap)
         {
             // If we have found a dropcap store the textnode
-            pPreviousNode = m_pPaM->GetNode().GetTextNode();
+            m_pPreviousNode = m_pPaM->GetNode().GetTextNode();
 
             SprmResult aDCS;
             if (m_bVer67)
@@ -4056,7 +4056,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
             if (aDCS.pSprm && aDCS.nRemainingData >= 1)
                 nDropLines = (*aDCS.pSprm) >> 3;
             else    // There is no Drop Cap Specifier hence no dropcap
-                pPreviousNode = nullptr;
+                m_pPreviousNode = nullptr;
 
             SprmResult aDistance = m_pPlcxMan->GetPapPLCF()->HasSprm(0x842F);
             if (aDistance.pSprm && aDistance.nRemainingData >= 2)
@@ -4126,6 +4126,8 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
         }
     }
 
+    m_pPreviousNode = nullptr;
+
     if (m_pPaM->GetPoint()->nContent.GetIndex())
         AppendTextNode(*m_pPaM->GetPoint());
 
@@ -4261,6 +4263,7 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
     , m_nEmbeddedTOXLevel(0)
     , m_bLoadingTOXHyperlink(false)
     , m_pPosAfterTOC(nullptr)
+    , m_pPreviousNode(nullptr)
     , m_bCareFirstParaEndInToc(false)
     , m_bCareLastParaEndInToc(false)
     , m_aTOXEndCps()
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 12e4e37ccf66..364fb41ded43 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1343,6 +1343,8 @@ private:
     bool m_bLoadingTOXHyperlink;
     // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
     SwPaM* m_pPosAfterTOC;
+    // used for some dropcap tweaking
+    SwTextNode* m_pPreviousNode;
 
     std::unique_ptr< SwPosition > m_pLastAnchorPos;
 
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 021a70184f32..728ffe3ea472 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2443,19 +2443,31 @@ bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr)
         if (bStealAttr)
             m_pCtrlStck->StealAttr(rPam.GetPoint()->nNode);
 
-        if (m_pLastAnchorPos.get())
+        if (m_pLastAnchorPos || m_pPreviousNode)
         {
-            //If the last anchor pos is here, then clear the anchor pos.
-            //This "last anchor pos" is only used for fixing up the
-            //positions of things anchored to page breaks and here
-            //we are removing the last paragraph of a frame, so there
-            //cannot be a page break at this point so we can
-            //safely reset m_pLastAnchorPos to avoid any dangling
-            //SwIndex's pointing into the deleted paragraph
-            SwNodeIndex aLastAnchorPos(m_pLastAnchorPos->nNode);
             SwNodeIndex aToBeJoined(aPref, 1);
-            if (aLastAnchorPos == aToBeJoined)
-                m_pLastAnchorPos.reset();
+
+            if (m_pLastAnchorPos)
+            {
+                //If the last anchor pos is here, then clear the anchor pos.
+                //This "last anchor pos" is only used for fixing up the
+                //positions of things anchored to page breaks and here
+                //we are removing the last paragraph of a frame, so there
+                //cannot be a page break at this point so we can
+                //safely reset m_pLastAnchorPos to avoid any dangling
+                //SwIndex's pointing into the deleted paragraph
+                SwNodeIndex aLastAnchorPos(m_pLastAnchorPos->nNode);
+                if (aLastAnchorPos == aToBeJoined)
+                    m_pLastAnchorPos.reset();
+            }
+
+            if (m_pPreviousNode)
+            {
+                //If the drop character start pos is here, then clear it.
+                SwNodeIndex aDropCharPos(*m_pPreviousNode);
+                if (aDropCharPos == aToBeJoined)
+                    m_pPreviousNode = nullptr;
+            }
         }
 
         pNode->JoinNext();


More information about the Libreoffice-commits mailing list