"Flags" means a set of bits that are packed together into an integer to save space.  In this case, piItemFlags are used to store color translations and probably other things, too.  Thus, it's hard to understand how the logic here could be correct, because you check if piItemFlags are 0 (why should it matter if the bits that are used for things other than color translations are set?), and then line 131 clobbers those other bits by setting them to 0.

Look how color translations are done in other objects and let's do the same thing here.