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_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 0c303d5..7e5073e 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 @@
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 457366e..b5a793e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1148,6 +1148,9 @@
/// 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 @@
}
nWhichId = aIter.NextWhich();
}
rAttributeOutput.GetExport().SetCurItemSet(pOldI);
}
const char *RubyAlignValues[] =
@@ -1230,6 +1234,7 @@
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'