summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/ndtxt.hxx2
-rw-r--r--sw/qa/extras/tiledrendering/data/tdf114799_highlight.docxbin0 -> 29040 bytes
-rw-r--r--sw/qa/extras/tiledrendering/data/tdf114799_shd.docx (renamed from sw/qa/extras/tiledrendering/data/tdf114799.docx)bin29049 -> 29049 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx29
-rw-r--r--sw/source/core/text/txtfld.cxx16
-rw-r--r--sw/source/core/txtnode/thints.cxx10
6 files changed, 48 insertions, 9 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index f83bab3cebba..cc071f28b70e 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -804,7 +804,7 @@ public:
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
/// In MS Word, the font underline setting of the paragraph end position won't affect the formatting of numbering, so we ignore it
- static bool IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich);
+ static bool IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich, bool bIsCharStyle = false);
void FormatDropNotify(const SwFormatDrop& rDrop) override
{ TriggerNodeUpdate(sw::LegacyModifyHint(&rDrop, &rDrop)); };
};
diff --git a/sw/qa/extras/tiledrendering/data/tdf114799_highlight.docx b/sw/qa/extras/tiledrendering/data/tdf114799_highlight.docx
new file mode 100644
index 000000000000..3a64d71d7cfd
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/tdf114799_highlight.docx
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/data/tdf114799.docx b/sw/qa/extras/tiledrendering/data/tdf114799_shd.docx
index 730ef91dcef9..730ef91dcef9 100644
--- a/sw/qa/extras/tiledrendering/data/tdf114799.docx
+++ b/sw/qa/extras/tiledrendering/data/tdf114799_shd.docx
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 41249cd9f3ac..54dd09b7d191 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -135,6 +135,7 @@ public:
void testDeselectCustomShape();
void testSemiTransparent();
void testHighlightNumbering();
+ void testHighlightNumbering_shd();
void testPilcrowRedlining();
void testClipText();
void testAnchorTypes();
@@ -212,6 +213,7 @@ public:
CPPUNIT_TEST(testDeselectCustomShape);
CPPUNIT_TEST(testSemiTransparent);
CPPUNIT_TEST(testHighlightNumbering);
+ CPPUNIT_TEST(testHighlightNumbering_shd);
CPPUNIT_TEST(testPilcrowRedlining);
CPPUNIT_TEST(testClipText);
CPPUNIT_TEST(testAnchorTypes);
@@ -2441,7 +2443,7 @@ void SwTiledRenderingTest::testSemiTransparent()
void SwTiledRenderingTest::testHighlightNumbering()
{
// Load a document where the top left tile contains a semi-transparent rectangle shape.
- SwXTextDocument* pXTextDocument = createDoc("tdf114799.docx");
+ SwXTextDocument* pXTextDocument = createDoc("tdf114799_highlight.docx");
// Render a larger area, and then get the color of the bottom right corner of our tile.
size_t nCanvasWidth = 1024;
@@ -2463,6 +2465,31 @@ void SwTiledRenderingTest::testHighlightNumbering()
CPPUNIT_ASSERT_EQUAL(COL_YELLOW, aColor);
}
+void SwTiledRenderingTest::testHighlightNumbering_shd()
+{
+ // Load a document where the top left tile contains a semi-transparent rectangle shape.
+ SwXTextDocument* pXTextDocument = createDoc("tdf114799_shd.docx");
+
+ // Render a larger area, and then get the color of the bottom right corner of our tile.
+ size_t nCanvasWidth = 1024;
+ size_t nCanvasHeight = 512;
+ size_t nTileSize = 256;
+ std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
+ ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
+ pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight),
+ Fraction(1.0), Point(), aPixmap.data());
+ pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0,
+ /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
+ pDevice->EnableMapMode(false);
+ Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize));
+ Bitmap::ScopedReadAccess pAccess(aBitmap);
+
+ // No highlighting over numbering - w:shd does not apply to numbering.
+ Color aColor(pAccess->GetPixel(103, 148));
+ CPPUNIT_ASSERT_EQUAL(COL_WHITE, aColor);
+}
+
void SwTiledRenderingTest::testPilcrowRedlining()
{
// Load a document where the top left tile contains
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index e4211667ba5b..0c303d54b37e 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -472,7 +472,7 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
sal_uInt16 nWhich = aIter.FirstWhich();
while (nWhich)
{
- if (!SwTextNode::IsIgnoredCharFormatForNumbering(nWhich)
+ if (!SwTextNode::IsIgnoredCharFormatForNumbering(nWhich, /*bIsCharStyle=*/true)
&& !pCleanedSet->HasItem(nWhich)
&& !(pFormat && pFormat->HasItem(nWhich)) )
{
@@ -492,12 +492,18 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
const SfxPoolItem* pItem = aIter.GetCurItem();
while (pItem)
{
- if (pItem->Which() != RES_CHRATR_BACKGROUND)
+ if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
+ pCleanedSet->ClearItem(pItem->Which());
+ else if (pFormat && pFormat->HasItem(pItem->Which()))
+ pCleanedSet->ClearItem(pItem->Which());
+ else if (pItem->Which() == RES_CHRATR_BACKGROUND)
{
- if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
- pCleanedSet->ClearItem(pItem->Which());
- else if (pFormat && pFormat->HasItem(pItem->Which()))
+ // If used, BACKGROUND is converted to HIGHLIGHT. So also ignore if a highlight already exists.
+ if (pCleanedSet->HasItem(RES_CHRATR_HIGHLIGHT)
+ || (pFormat && pFormat->HasItem(RES_CHRATR_HIGHLIGHT)))
+ {
pCleanedSet->ClearItem(pItem->Which());
+ }
}
pItem = aIter.NextItem();
};
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 6052754c8b46..41e9adefd9d5 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -45,6 +45,7 @@
#include <txtftn.hxx>
#include <txtfld.hxx>
#include <txtannotationfld.hxx>
+#include <unotools/fltrcfg.hxx>
#include <charfmt.hxx>
#include <frmfmt.hxx>
#include <ftnidx.hxx>
@@ -1809,9 +1810,14 @@ void SwTextNode::DelSoftHyph( const sal_Int32 nStt, const sal_Int32 nEnd )
}
}
-bool SwTextNode::IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich)
+bool SwTextNode::IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich, bool bIsCharStyle)
{
- return (nWhich == RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_BACKGROUND
+ // LO can save the char background as either shading or highlight, so check which mode is currently chosen.
+ // Shading does not affect the numbering. Highlighting does (but isn't allowed in a char style).
+ if (nWhich == RES_CHRATR_BACKGROUND)
+ return bIsCharStyle || SvtFilterOptions::Get().IsCharBackground2Shading();
+
+ return (nWhich == RES_CHRATR_UNDERLINE
|| nWhich == RES_CHRATR_ESCAPEMENT);
}