sw/source/core/text/txtfld.cxx               |   16 +++++++++++++++-
 sw/source/filter/ww8/docxattributeoutput.cxx |    5 +++++
 2 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 3ab99045e22f82ad8b5d9c862860e4a8a93a52d6
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Feb 22 08:55:58 2021 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Mar 1 11:03:08 2021 +0100

    tdf#114799 Char highlight: don't convert imported shading
    
    Under normal circumstances, this was already done,
    but in this case where the end paragraph properties
    are being written out, there was no context, so the
    grabbag was not found, and thus there could be no
    indication that this came from an imported value.
    
    I'm still mildly uncomfortable with this patch.
    ISet takes priority over ChrIter. The TOX does
    add a fake ChrIter for the whole section,
    but doesn't document why (and the commits don't
    help much either - very early stuff).
    That seems to be the only place where this
    patch overrides an otherwise working situation.
    
    The comment for this function encourages me
    that I'm doing the right thing.
    /// Outputs an item set...
    so it should be appropriate to set pISet, right?
    
    This is just a visual change, so nearly
    impossible to test reliably in a unit test.
    [see https://gerrit.libreoffice.org/c/core/+/93082]
    
    This causes LO to match how MS Word shows
    w:shd on numbering (i.e. it doesn't show anything).
    
    Change-Id: Ic3024c8f26a7e866c0b407a963dd9a1fc20b75cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111295
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 0c303d54b37e..7e5073eb9d6f 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -52,6 +52,7 @@
 #include <IDocumentRedlineAccess.hxx>
 #include <redline.hxx>
 #include <sfx2/docfile.hxx>
+#include <svl/grabbagitem.hxx>
 #include <svl/itemiter.hxx>
 #include <svl/whiter.hxx>
 #include <editeng/colritem.hxx>
@@ -498,8 +499,21 @@ static void 
checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
             pCleanedSet->ClearItem(pItem->Which());
         else if (pItem->Which() == RES_CHRATR_BACKGROUND)
         {
+            bool bShadingWasImported = false;
+            // If Shading was imported, it should not be converted to a 
Highlight,
+            // but remain as Shading which is ignored for numbering.
+            if (pCleanedSet->HasItem(RES_CHRATR_GRABBAG))
+            {
+                SfxGrabBagItem aGrabBag = pCleanedSet->Get(RES_CHRATR_GRABBAG, 
/*bSrchInParent=*/false);
+                std::map<OUString, css::uno::Any>& rMap = 
aGrabBag.GetGrabBag();
+                auto aIterator = rMap.find("CharShadingMarker");
+                if (aIterator != rMap.end())
+                    aIterator->second >>= bShadingWasImported;
+            }
+
             // If used, BACKGROUND is converted to HIGHLIGHT. So also ignore 
if a highlight already exists.
-            if (pCleanedSet->HasItem(RES_CHRATR_HIGHLIGHT)
+            if (bShadingWasImported
+                || pCleanedSet->HasItem(RES_CHRATR_HIGHLIGHT)
                 || (pFormat && pFormat->HasItem(RES_CHRATR_HIGHLIGHT)))
             {
                 pCleanedSet->ClearItem(pItem->Which());
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 457366ee2a6c..b5a793ec196f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1148,6 +1148,9 @@ namespace
 /// Outputs an item set, that contains the formatting of the paragraph marker.
 void lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, 
const SfxItemSet& rParagraphMarkerProperties)
 {
+    const SfxItemSet* pOldI = rAttributeOutput.GetExport().GetCurItemSet();
+    rAttributeOutput.GetExport().SetCurItemSet(&rParagraphMarkerProperties);
+
     SfxWhichIter aIter(rParagraphMarkerProperties);
     sal_uInt16 nWhichId = aIter.FirstWhich();
     const SfxPoolItem* pItem = nullptr;
@@ -1174,6 +1177,7 @@ void 
lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, c
         }
         nWhichId = aIter.NextWhich();
     }
+    rAttributeOutput.GetExport().SetCurItemSet(pOldI);
 }
 
 const char *RubyAlignValues[] =
@@ -1230,6 +1234,7 @@ void DocxAttributeOutput::EndParagraphProperties(const 
SfxItemSet& rParagraphMar
     rtl::Reference<sax_fastparser::FastAttributeList> 
pCharLangAttrList_Original(m_pCharLangAttrList);
     m_pCharLangAttrList.clear();
 
+    assert (!GetExport().GetCurItemSet() && "Information gathering: Changing 
CurItemSet and want to ensure that one doesn't already exist in some context 
that we unknowingly clobber. Known to clobber fake-ish TOX m_pChpIter - have to 
assume that is OK.");
     lcl_writeParagraphMarkerProperties(*this, rParagraphMarkerProperties);
 
     // Write the collected run properties that are stored in 
'm_pFontsAttrList', 'm_pEastAsianLayoutAttrList', 'm_pCharLangAttrList'
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to