Bug 157034 - FILESAVE loext:theme-type is off by one
Summary: FILESAVE loext:theme-type is off by one
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:24.2.0 target:7.6.2
Keywords: implementationError
Depends on:
Blocks: 156981
  Show dependency treegraph
 
Reported: 2023-08-31 10:05 UTC by Regina Henschel
Modified: 2023-09-04 17:51 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
empty file with color theme (71.65 KB, application/vnd.oasis.opendocument.presentation)
2023-08-31 10:05 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2023-08-31 10:05:47 UTC
Created attachment 189277 [details]
empty file with color theme

Open attached file. It has a custom color theme.

Insert a shape and open its area fill dialog. Select the palette 'Theme Colors'. Set the fill to "Light 1".
Insert a second shape and set its area fill to "Accent 1".
Save the file.

Open the file in an editor and inspect the style of the shapes. You will find
loext:theme-type="dark2" and loext:theme-type="accent2". The colors in draw:fill-color are correct. 

Info: The theme definition itself is in <office:master-styles> - <style:master-page> - <loext:theme> - <loext:theme-colors>
Comment 1 Julien Nabet 2023-08-31 11:47:30 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.

When selecting Light1, I get this bt:
#0  PaletteManager::GetThemeAndEffectIndex(unsigned short, unsigned short&, unsigned short&) (nItemId=2, rThemeIndex=@0x7ffe9d172eae: 0, rEffectIndex=@0x7ffe9d172eac: 32766)
    at svx/source/tbxctrls/PaletteManager.cxx:165
#1  0x00007f1922b4e2d9 in SvxColorTabPage::SelectValSetHdl_Impl(ValueSet*) (this=0x56115d44fb90, pValSet=0x56115d732170) at cui/source/tabpages/tpcolor.cxx:511
#2  0x00007f1922b4cd7d in SvxColorTabPage::LinkStubSelectValSetHdl_Impl(void*, ValueSet*) (instance=0x56115d44fb90, data=0x56115d732170) at cui/source/tabpages/tpcolor.cxx:492

With this patch, it seems to work:
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 9b8f144f66b0..77cbab82207d 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -161,7 +161,10 @@ bool PaletteManager::IsThemePaletteSelected() const
 
 bool PaletteManager::GetThemeAndEffectIndex(sal_uInt16 nItemId, sal_uInt16& rThemeIndex, sal_uInt16& rEffectIndex)
 {
-     // Each column is the same color with different effects.
+    // tdf#157034, nItemId begins with 1 but list of themes begin with 0
+    // so decrement nItemId
+    --nItemId;
+    // Each column is the same color with different effects.
     rThemeIndex = nItemId % 12;
 
     rEffectIndex = nItemId / 12;

Regina: does it seem to you?
Comment 2 Regina Henschel 2023-08-31 13:49:11 UTC
(In reply to Julien Nabet from comment #1)

> With this patch, it seems to work:
> diff --git a/svx/source/tbxctrls/PaletteManager.cxx
> b/svx/source/tbxctrls/PaletteManager.cxx
> index 9b8f144f66b0..77cbab82207d 100644
> --- a/svx/source/tbxctrls/PaletteManager.cxx
> +++ b/svx/source/tbxctrls/PaletteManager.cxx
> @@ -161,7 +161,10 @@ bool PaletteManager::IsThemePaletteSelected() const
>  
>  bool PaletteManager::GetThemeAndEffectIndex(sal_uInt16 nItemId, sal_uInt16&
> rThemeIndex, sal_uInt16& rEffectIndex)
>  {
> -     // Each column is the same color with different effects.
> +    // tdf#157034, nItemId begins with 1 but list of themes begin with 0
> +    // so decrement nItemId
> +    --nItemId;
> +    // Each column is the same color with different effects.
>      rThemeIndex = nItemId % 12;
>  
>      rEffectIndex = nItemId / 12;
> 
> Regina: does it seem to you?

Yes, that looks correct. Do you want to write the fix? If yes, please set Tomaž Vajngerl for review.

Do you have an idea for a unit test? Likely something with dispatcher. But without further research I couldn't write a test.

BTW, the error is visible in export to pptx as well.
Comment 3 Julien Nabet 2023-08-31 14:22:25 UTC
(In reply to Regina Henschel from comment #2)
> (In reply to Julien Nabet from comment #1)
> 
> > With this patch, it seems to work:
> > ...
> > Regina: does it seem to you?
> 
> Yes, that looks correct. Do you want to write the fix? If yes, please set
> Tomaž Vajngerl for review.
Done here https://gerrit.libreoffice.org/c/core/+/156350

> 
> Do you have an idea for a unit test? Likely something with dispatcher. But
> without further research I couldn't write a test.
> 
I don't know much about unit tests, I'm less interested in these (even if I know it's useful to detect regressions early).

> ...
Comment 4 Julien Nabet 2023-08-31 16:41:03 UTC
I abandoned the patch since the unit test failed.
Unassign myself.
Comment 5 Commit Notification 2023-09-01 12:25:20 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/85aa230aebfe383eecdb4fc6704d093db8a18402

tdf#157034: FILESAVE loext:theme-type is off by one

It will be available in 24.2.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 6 Julien Nabet 2023-09-01 12:54:31 UTC
Thank you Regina for the review!

I cherry-picked the patch for 7.6 branch here:
https://gerrit.libreoffice.org/c/core/+/156389

Let's put this one to FIXED then.
Comment 7 Commit Notification 2023-09-04 17:51:45 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

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

tdf#157034: FILESAVE loext:theme-type is off by one

It will be available in 7.6.2.

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.