Bug 130252 - Impress: Clone formatting not cloning highlight color, rather removing it
Summary: Impress: Clone formatting not cloning highlight color, rather removing it
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
4.4.0.3 release
Hardware: All All
: low minor
Assignee: Julien Nabet
URL:
Whiteboard: target:7.5.0 target:7.4.0.0.beta2 tar...
Keywords: implementationError
Depends on:
Blocks:
 
Reported: 2020-01-29 09:22 UTC by Abdulaziz
Modified: 2022-07-03 23:50 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Abdulaziz 2020-01-29 09:22:11 UTC
Description:
I was highlighting some text on Impress, and upon setting background color of text, i wanted to iterate the process by using clone format but was not fully success.

It would copy the format of the text successfully, but didn't clone the color background.

I tested it on another platform (Writer), and (clone format) was working fine and copied all attributes of text including background color. As for impress, so far the background color was not cloned.

Thanks.

Steps to Reproduce:
1. Write a text on Impress->add any format to it and include background coloring.
2. Write another text, also add any format to it.
3. Use Clone format to copy text format from first text to second-> all success except background color is not cloned.

Actual Results:
1. Write a text on Impress->add any format to it and include background coloring.
2. Write another text, also add any format to it.
3. Use Clone format to copy text format from first text to second-> all success except background color is not cloned.

Expected Results:
The clone format should copy the background-color as well.


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Following the steps of its sister application (Writer), when using clone format, to copy all attributes of the first to clone it at destination.

Using PC:

Windows 10 (v. 1909)
8GB ram
CPU & Graphic: intel i3 4th gen - Intel HD 4400
Comment 1 Julien Nabet 2020-01-29 10:59:00 UTC
On Win10 with LO 6.3.4, I could reproduce this.
Comment 2 Timur 2020-01-29 17:01:54 UTC
I guess it's not "background" but "highlight", so changing title. 
Repro 7.0+. Highlight was not available in Lo 4.3, repro 4.4.
Comment 3 Julien Nabet 2020-01-29 20:05:18 UTC
Code pointer:
#0  0x00007ffff72100b0 in OutlinerEditEng::SetParaAttribs(int, SfxItemSet const&) (this=0x555556d46840, nPara=0, rSet=...) at /home/julien/lo/libo_perf/editeng/source/outliner/outleeng.cxx:173
#1  0x00007ffff5de86ba in SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const&, SdrTextObj&, SdrText*, bool, bool)
    (rFormatSet=..., rTextObj=..., pText=0x555557090870, bNoCharacterFormats=false, bNoParagraphFormats=<optimized out>) at /home/julien/lo/libo_perf/svx/source/svdraw/svdedxv.cxx:2727
#2  0x00007ffff5de8aaa in SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet&, bool, bool)
    (this=0x5555571495c0, rFormatSet=..., bNoCharacterFormats=bNoCharacterFormats@entry=false, bNoParagraphFormats=bNoParagraphFormats@entry=false)
    at /home/julien/lo/libo_perf/svx/source/svdraw/svdedxv.cxx:2790
#3  0x00007fffe51a8df6 in sd::FuFormatPaintBrush::Paste(bool, bool) (this=0x55555b0afde0, bNoCharacterFormats=<optimized out>, bNoParagraphFormats=<optimized out>)
    at /usr/include/c++/9/bits/shared_ptr_base.h:1020
#4  0x00007fffe51a8ee2 in sd::FuFormatPaintBrush::MouseButtonUp(MouseEvent const&) (this=0x55555b0afde0, rMEvt=...) at /home/julien/lo/libo_perf/sd/source/ui/func/fuformatpaintbrush.cxx:181
Comment 4 Julien Nabet 2020-01-29 20:33:16 UTC
(In reply to Julien Nabet from comment #3)
> Code pointer:
> #0  0x00007ffff72100b0 in OutlinerEditEng::SetParaAttribs(int, SfxItemSet
> const&) (this=0x555556d46840, nPara=0, rSet=...) at
>...
Argh, it's a bt when trying to paste the format on a selection. Perhaps the pb is just before, I mean perhaps it's just after original text is selected and we click on icon clone format.
Comment 5 Julien Nabet 2022-07-03 16:04:03 UTC
The relevant part is here:
#0  CreatePaintSet(WhichRangesContainer const&, SfxItemPool&, SfxItemSet const&, SfxItemSet const&, bool, bool)
    (pRanges=..., rPool=..., rSourceSet=SfxItemSet of pool 0x435e300 with parent 0x0 and Which ranges: [(1068, 1093), (4008, 4027), (4028, 4060)] = {...}, rTargetSet=SfxItemSet of pool 0x435e300 with parent 0x0 and Which ranges: [(4008, 4060)] = {...}, bNoCharacterFormats=false, bNoParagraphFormats=false) at svx/source/svdraw/svdedxv.cxx:2705
#1  0x00007f260ffc3073 in SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const&, SdrTextObj&, SdrText*, bool, bool)
    (rFormatSet=SfxItemSet of pool 0x435e300 with parent 0x0 and Which ranges: [(1068, 1093), (4008, 4027), (4028, 4060)] = {...}, rTextObj=..., pText=
    0x455f770, bNoCharacterFormats=false, bNoParagraphFormats=false) at svx/source/svdraw/svdedxv.cxx:2755
#2  0x00007f260ffc388f in SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet&, bool, bool)
    (this=0x7749700, rFormatSet=SfxItemSet of pool 0x435e300 with parent 0x0 and Which ranges: [(1068, 1093), (4008, 4027), (4028, 4060)] = {...}, bNoCharacterFormats=false, bNoParagraphFormats=false)
    at svx/source/svdraw/svdedxv.cxx:2831
#3  0x00007f25fb2a9842 in sd::FuFormatPaintBrush::Paste(bool, bool) (this=0x9d58330, bNoCharacterFormats=false, bNoParagraphFormats=false) at sd/source/ui/func/fuformatpaintbrush.cxx:253
#4  0x00007f25fb2a9512 in sd::FuFormatPaintBrush::MouseButtonUp(MouseEvent const&) (this=0x9d58330, rMEvt=...) at sd/source/ui/func/fuformatpaintbrush.cxx:181
#5  0x00007f25fb7a2e8f in sd::ViewShell::MouseButtonUp(MouseEvent const&, sd::Window*) (this=0x44adfe0, rMEvt=..., pWin=0x3cf0520) at sd/source/ui/view/viewshel.cxx:604

In frame 1 svx/source/svdraw/svdedxv.cxx we call "GetFormatRangeImpl"
see https://opengrok.libreoffice.org/xref/core/svx/source/svdraw/svdedxv.cxx?r=226847e3#2755

Here's the beginning of implementation:
2652  static const WhichRangesContainer& GetFormatRangeImpl(bool bTextOnly)
2653  {
2654      static const WhichRangesContainer gFull(
2655          svl::Items<XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTRSET_FILL,
2656                     SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, SDRATTR_MISC_FIRST,
2657                     SDRATTR_MISC_LAST, // table cell formats
2658                     SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
2659                     EE_PARA_START, EE_PARA_END, EE_CHAR_START, EE_CHAR_END>);

In include/editeng/eeitem.hxx
we got:
131  constexpr TypedWhichId<SvxColorItem> EE_CHAR_BKGCOLOR  (EE_CHAR_START+32);
132
133  constexpr sal_uInt16        EE_CHAR_END            (EE_CHAR_START + 32);

(see https://opengrok.libreoffice.org/xref/core/include/editeng/eeitem.hxx?r=8c018910#133)

Ok so background color is the last of the list.

Now once we retrieved ranges from "GetFormatRangeImpl", we call "CreatePaintSet"

This one takes each range and loops on every element of it, BUT here's the loop:
   2718         for (; nWhich < nLastWhich; nWhich++)
   2719         {
   2720             const SfxPoolItem* pSourceItem = rSourceSet.GetItem(nWhich);
   2721             const SfxPoolItem* pTargetItem = rTargetSet.GetItem(nWhich);
(See https://opengrok.libreoffice.org/xref/core/svx/source/svdraw/svdedxv.cxx?r=226847e3#2718)

It doesn't take into account the last element of the range!

Obvious patch, replace:
for (; nWhich < nLastWhich; nWhich++)
by:
for (; nWhich <= nLastWhich; nWhich++)
Comment 6 Julien Nabet 2022-07-03 16:10:48 UTC
https://gerrit.libreoffice.org/c/core/+/136785

BTW, this patch may help for other issues (every case corresponding to the end of a range).
Comment 7 Commit Notification 2022-07-03 18:54:09 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7b49b3ebc17378566942e7b263e0e5f2b400dbd1

tdf#130252: Impress: Clone formatting not cloning highlight color

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Julien Nabet 2022-07-03 19:10:31 UTC
Patch waiting for review here in 7.4:
https://gerrit.libreoffice.org/c/core/+/136757

There's also one for review here in 7.3:
https://gerrit.libreoffice.org/c/core/+/136758
this one may be refused because we're already at version 7.3.4 and it's not a critical bug.
Comment 9 Commit Notification 2022-07-03 23:50:03 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/c957471bc57a89ec71f1a91838646e664a7dc6f1

tdf#130252: Impress: Clone formatting not cloning highlight color

It will be available in 7.4.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2022-07-03 23:50:13 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/3788d8be31764a3f44dc662f2d6e040a2a24510e

tdf#130252: Impress: Clone formatting not cloning highlight color

It will be available in 7.3.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.