online.git: engine/filter

0 views
Skip to first unread message

"Caolán McNamara (via cogerrit)"

unread,
Apr 28, 2026, 11:32:58 AM (19 hours ago) Apr 28
to collaboraon...@googlegroups.com
engine/filter/source/msfilter/svdfppt.cxx | 97 +++++++++++++-----------------
1 file changed, 43 insertions(+), 54 deletions(-)

New commits:
commit 07faeadace3d8d93225f9dd72c4f911e331070e2
Author: Caolán McNamara <caolan....@collabora.com>
AuthorDate: Sun Apr 26 15:49:32 2026 +0000
Commit: Caolán McNamara <caolan....@collabora.com>
CommitDate: Tue Apr 28 15:32:10 2026 +0000

SdrEscherImport::RecolorGraphic reads but doesn't use FillColors

it never did, but at:

commit 025bfa7e510bdab3ef93ad45a731fc25085ba3cc
Date: Thu Apr 23 10:03:58 2015 +0100

cppcheck: unreadVariable

the wrong choice was made wrt the dead store, the dead loop should have
been fixed rather than let the unused fill colors accumulate in the
globalcolors buffer.

This function doesn't need to consume the unused data, all callers don't
expect the entire record to be read so just drop the loop.

Signed-off-by: Caolán McNamara <caolan....@collabora.com>
Change-Id: I02bce4dd78dc566f18edc3d45603534c3f724cc3
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1689

diff --git a/engine/filter/source/msfilter/svdfppt.cxx b/engine/filter/source/msfilter/svdfppt.cxx
index 57cf08345bfa..a8df888650d7 100644
--- a/engine/filter/source/msfilter/svdfppt.cxx
+++ b/engine/filter/source/msfilter/svdfppt.cxx
@@ -624,65 +624,54 @@ void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic
sal_uInt32 OriginalGlobalColors[ 64 ];
sal_uInt32 NewGlobalColors[ 64 ];

- sal_uInt32 i, j, nGlobalColorsChanged, nFillColorsChanged;
- nGlobalColorsChanged = nFillColorsChanged = 0;
-
- sal_uInt32* pCurrentOriginal = OriginalGlobalColors;
- sal_uInt32* pCurrentNew = NewGlobalColors;
- sal_uInt32* pCount = &nGlobalColorsChanged;
- i = nGlobalColorsCount;
-
- for ( j = 0; j < 2; j++ )
- {
- for ( ; i > 0; i-- )
- {
- sal_uInt64 nPos = rSt.Tell();
- sal_uInt16 nChanged;
- rSt.ReadUInt16( nChanged );
- if ( nChanged & 1 )
- {
- sal_uInt8 nDummy, nRed, nGreen, nBlue;
- sal_uInt32 nColor = 0;
- sal_uInt32 nIndex;
- rSt.ReadUChar( nDummy )
- .ReadUChar( nRed )
- .ReadUChar( nDummy )
- .ReadUChar( nGreen )
- .ReadUChar( nDummy )
- .ReadUChar( nBlue )
- .ReadUInt32( nIndex );
-
- if ( nIndex < 8 )
- {
- Color aColor = MSO_CLR_ToColor( nIndex << 24 );
- nRed = aColor.GetRed();
- nGreen = aColor.GetGreen();
- nBlue = aColor.GetBlue();
- }
- nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
- *pCurrentNew++ = nColor;
- rSt.ReadUChar( nDummy )
- .ReadUChar( nRed )
- .ReadUChar( nDummy )
- .ReadUChar( nGreen )
- .ReadUChar( nDummy )
- .ReadUChar( nBlue );
- nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
- *pCurrentOriginal++ = nColor;
- (*pCount)++;
- }
- rSt.Seek( nPos + 44 );
- }
- pCount = &nFillColorsChanged;
- i = nFillColorsCount;
- }
- if ( !(nGlobalColorsChanged || nFillColorsChanged) )
+ sal_uInt32 nGlobalColorsChanged = 0;
+
+ for ( sal_uInt32 i = 0; i < nGlobalColorsCount; i++ )
+ {
+ sal_uInt64 nPos = rSt.Tell();
+ sal_uInt16 nChanged(0);
+ rSt.ReadUInt16( nChanged );
+ if ( nChanged & 1 )
+ {
+ sal_uInt8 nDummy, nRed, nGreen, nBlue;
+ sal_uInt32 nColor(0);
+ sal_uInt32 nIndex(0);
+ rSt.ReadUChar( nDummy )
+ .ReadUChar( nRed )
+ .ReadUChar( nDummy )
+ .ReadUChar( nGreen )
+ .ReadUChar( nDummy )
+ .ReadUChar( nBlue )
+ .ReadUInt32( nIndex );
+
+ if ( nIndex < 8 )
+ {
+ Color aColor = MSO_CLR_ToColor( nIndex << 24 );
+ nRed = aColor.GetRed();
+ nGreen = aColor.GetGreen();
+ nBlue = aColor.GetBlue();
+ }
+ nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
+ NewGlobalColors[ nGlobalColorsChanged ] = nColor;
+ rSt.ReadUChar( nDummy )
+ .ReadUChar( nRed )
+ .ReadUChar( nDummy )
+ .ReadUChar( nGreen )
+ .ReadUChar( nDummy )
+ .ReadUChar( nBlue );
+ nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 );
+ OriginalGlobalColors[ nGlobalColorsChanged ] = nColor;
+ nGlobalColorsChanged++;
+ }
+ rSt.Seek( nPos + 44 );
+ }
+ if ( !nGlobalColorsChanged )
return;

std::unique_ptr<Color[]> pSearchColors(new Color[ nGlobalColorsChanged ]);
std::unique_ptr<Color[]> pReplaceColors(new Color[ nGlobalColorsChanged ]);

- for ( j = 0; j < nGlobalColorsChanged; j++ )
+ for ( sal_uInt32 j = 0; j < nGlobalColorsChanged; j++ )
{
sal_uInt32 nSearch = OriginalGlobalColors[ j ];
sal_uInt32 nReplace = NewGlobalColors[ j ];

Reply all
Reply to author
Forward
0 new messages