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

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 28 16:42:16 UTC 2019


 sw/source/core/text/itratr.cxx |   38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

New commits:
commit 09e86f7cef6ca3e2ca451cbbae439006820c71d4
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Nov 28 12:35:40 2019 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Nov 28 17:41:35 2019 +0100

    sw: fix asserts from SwSubFont::GetTextSize_() on ooo54042-1.doc
    
    The function gets passed a single CH_TXT_ATR_FIELDSTART but it looks
    like this is a problem in SwTextNode::GetMinMaxSize().
    
    That one should just skip over the CH_TXT_ATR_FIELD* basically, since
    it's only interested in the text; also CH_TXT_ATR_INPUTFIELD* while at it.
    
    Also adapt the SwTextFrame::GetScalingOfSelectedText(), as indicated by
    the comment.
    
    Change-Id: Idf24e84f000406d265e73441de643b022c0b3cff
    Reviewed-on: https://gerrit.libreoffice.org/83997
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit e7c0f65753e04d2de3dbac56fbe86ce0b6aed9b2)
    Reviewed-on: https://gerrit.libreoffice.org/84009

diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index a27701186c1a..4933bce92c9f 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -1061,8 +1061,17 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM
                CH_TAB != (cChar = m_Text[sal_Int32(nStop)]) &&
                CH_BREAK != cChar && CHAR_HARDBLANK != cChar &&
                CHAR_HARDHYPHEN != cChar && CHAR_SOFTHYPHEN != cChar &&
+               CH_TXT_ATR_INPUTFIELDSTART != cChar &&
+               CH_TXT_ATR_INPUTFIELDEND != cChar &&
+               CH_TXT_ATR_FORMELEMENT != cChar &&
+               CH_TXT_ATR_FIELDSTART != cChar &&
+               CH_TXT_ATR_FIELDSEP != cChar &&
+               CH_TXT_ATR_FIELDEND != cChar &&
                !pHint )
         {
+            // this looks like some defensive programming to handle dummy char
+            // with missing hint? but it's rather silly because it may pass the
+            // dummy char to lcl_MinMaxString in that case...
             if( ( CH_TXTATR_BREAKWORD != cChar && CH_TXTATR_INWORD != cChar )
                 || ( nullptr == ( pHint = aIter.GetAttr( nStop ) ) ) )
                 ++nStop;
@@ -1184,6 +1193,16 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM
                 aIter.SeekAndChgAttrIter( ++nIdx, pOut );
             }
             break;
+            case CH_TXT_ATR_INPUTFIELDSTART:
+            case CH_TXT_ATR_INPUTFIELDEND:
+            case CH_TXT_ATR_FORMELEMENT:
+            case CH_TXT_ATR_FIELDSTART:
+            case CH_TXT_ATR_FIELDSEP:
+            case CH_TXT_ATR_FIELDEND:
+            {   // just skip it and continue with the content...
+                aIter.SeekAndChgAttrIter( ++nIdx, pOut );
+            }
+            break;
         }
     }
     if( static_cast<long>(rMax) < aArg.nRowWidth )
@@ -1296,6 +1315,12 @@ sal_uInt16 SwTextFrame::GetScalingOfSelectedText(
                 CHAR_HARDBLANK == cChar ||
                 CHAR_HARDHYPHEN == cChar ||
                 CHAR_SOFTHYPHEN == cChar ||
+                CH_TXT_ATR_INPUTFIELDSTART == cChar ||
+                CH_TXT_ATR_INPUTFIELDEND == cChar ||
+                CH_TXT_ATR_FORMELEMENT == cChar ||
+                CH_TXT_ATR_FIELDSTART == cChar ||
+                CH_TXT_ATR_FIELDSEP == cChar ||
+                CH_TXT_ATR_FIELDEND == cChar ||
                 (
                   (CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar) &&
                   (nullptr == (pHint = aIter.GetAttr(nStop)))
@@ -1371,8 +1396,17 @@ sal_uInt16 SwTextFrame::GetScalingOfSelectedText(
                 }
             } // end of switch
             nIdx++;
-        } // end of while
-    }
+        }
+        else if (CH_TXT_ATR_INPUTFIELDSTART == cChar ||
+                 CH_TXT_ATR_INPUTFIELDEND == cChar ||
+                 CH_TXT_ATR_FORMELEMENT == cChar ||
+                 CH_TXT_ATR_FIELDSTART == cChar ||
+                 CH_TXT_ATR_FIELDSEP == cChar ||
+                 CH_TXT_ATR_FIELDEND == cChar)
+        {   // just skip it and continue with the content...
+            ++nIdx;
+        }
+    } // end of while
 
     nWidth = std::max( nWidth, nProWidth );
 


More information about the Libreoffice-commits mailing list