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 00ac19068de5e120d1620a719aa64f1203c639ae Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Mar 18 21:40:15 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Mar 19 09:07:15 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. Change-Id: I43a6dec7d3a77689e2acbdc9d3671e79a9c4cac8 Reviewed-on: https://gerrit.libreoffice.org/69400 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.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 7a03744d46f2..3ea6916e2839 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='PortionType::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 a30ee18233b3..b7b80cbfb23c 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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits