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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 22 11:25:22 UTC 2019


 sw/qa/extras/ooxmlimport/data/tdf120548.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx    |    8 ++++++++
 sw/source/core/text/txtfld.cxx               |   10 +++++++---
 sw/source/core/txtnode/thints.cxx            |    3 ++-
 4 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 6bbcf6e2839ef2747ec3677e5daa7a6ce118fd81
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 18 21:40:15 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 22 12:24:58 2019 +0100

    tdf#120548 sw ApplyParagraphMarkFormatToNumbering: fix handling of font color
    
    Regression from commit b2c1474c1dc93b69f0ede03fc5c9ab496c669955
    (SwTxtNode::IsIgnoredCharFmtForNumbering: ignore RES_CHRATR_COLOR,
    2014-11-20), where the problem was that unconditionally ignoring or not
    ignoring the font color is not correct.
    
    Re-examining the test document from the above commit, it has an explicit
    font color set in the numbering, while this bugdoc doesn't have it.
    
    So make applying the paragraph mark font color to the numbering
    conditional if the numbering already has a color set, this makes both
    cases work correctly.
    
    (cherry picked from commit 00ac19068de5e120d1620a719aa64f1203c639ae)
    
    Change-Id: I43a6dec7d3a77689e2acbdc9d3671e79a9c4cac8
    Reviewed-on: https://gerrit.libreoffice.org/69476
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf120548.docx b/sw/qa/extras/ooxmlimport/data/tdf120548.docx
new file mode 100644
index 000000000000..60943645e939
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf120548.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 53d46cabe198..991573fd40af 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -103,6 +103,14 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
         getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf120548, "tdf120548.docx")
+{
+    // Without the accompanying fix in place, this test would have failed with 'Expected: 00ff0000;
+    // Actual: ffffffff', i.e. the numbering portion was black, not red.
+    CPPUNIT_ASSERT_EQUAL(OUString("00ff0000"),
+                         parseDump("//Special[@nType='POR_NUMBER']/SwFont", "color"));
+}
+
 DECLARE_OOXMLIMPORT_TEST(test120551, "tdf120551.docx")
 {
     auto nHoriOrientPosition = getProperty<sal_Int32>(getShape(1), "HoriOrientPosition");
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index d0cad7b2569c..9138a35eacdc 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -412,7 +412,9 @@ SwLinePortion *SwTextFormatter::NewExtraPortion( SwTextFormatInfo &rInf )
  * character than can be configured to be shown). However, in practice MSO also uses it as direct formatting
  * for numbering in that paragraph. I don't know if the problem is in the spec or in MSWord.
  */
-static void checkApplyParagraphMarkFormatToNumbering( SwFont* pNumFnt, SwTextFormatInfo& rInf, const IDocumentSettingAccess* pIDSA )
+static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextFormatInfo& rInf,
+                                                     const IDocumentSettingAccess* pIDSA,
+                                                     const SwAttrSet* pFormat)
 {
     if( !pIDSA->get(DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ))
         return;
@@ -447,6 +449,8 @@ static void checkApplyParagraphMarkFormatToNumbering( SwFont* pNumFnt, SwTextFor
                 {
                     if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
                         pCleanedSet->ClearItem(pItem->Which());
+                    else if (pFormat && pFormat->HasItem(pItem->Which()))
+                        pCleanedSet->ClearItem(pItem->Which());
 
                     if (aIter.IsAtEnd())
                         break;
@@ -552,7 +556,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
                 if( pFormat )
                     pNumFnt->SetDiffFnt( pFormat, pIDSA );
 
-                checkApplyParagraphMarkFormatToNumbering( pNumFnt.get(), rInf, pIDSA );
+                checkApplyParagraphMarkFormatToNumbering(pNumFnt.get(), rInf, pIDSA, pFormat);
 
                 if ( pFormatFnt )
                 {
@@ -608,7 +612,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
                     if( pFormat )
                         pNumFnt->SetDiffFnt( pFormat, pIDSA );
 
-                    checkApplyParagraphMarkFormatToNumbering( pNumFnt.get(), rInf, pIDSA );
+                    checkApplyParagraphMarkFormatToNumbering(pNumFnt.get(), rInf, pIDSA, pFormat);
 
                     // we do not allow a vertical font
                     pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() );
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 2fe6bf53c462..5c09174a491c 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1760,7 +1760,8 @@ void SwTextNode::DelSoftHyph( const sal_Int32 nStt, const sal_Int32 nEnd )
 
 bool SwTextNode::IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich)
 {
-    return (nWhich ==  RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_COLOR || nWhich == RES_CHRATR_BACKGROUND || nWhich == RES_CHRATR_ESCAPEMENT);
+    return (nWhich == RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_BACKGROUND
+            || nWhich == RES_CHRATR_ESCAPEMENT);
 }
 
 //In MS Word, following properties of the paragraph end position won't affect the formatting of bullets, so we ignore them:


More information about the Libreoffice-commits mailing list