Circuit for supporting, common anode AND cathode RGB LED Matrices
(source)

When looking at the connections for common Cathode / Anode LEDs you can see that once you connect the common node appropriately (i.e. Vdd/Gnd) then you just need to drive the RGB lines High for Common Cathode and Low for Common Anode to illuminate the LEDs.

UPDATE:
If (as OP states) you're prepared to wire-link the common node to Vdd or Gnd then you just need to make the RGB drive signals selectable positive/negative logic (i.e. 1= ON or 0=ON).

You can do this easily with an XOR gate or a MUX.

(source)



Here the MUX selects line selects A or !A to so you can drive common Cathode / Anode respectively.

Looking at the XOR version you can see B is inverted if A=1 .

(source)